diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
index 9287cdc6..2d0d8196 100644
--- a/.idea/codeStyles/Project.xml
+++ b/.idea/codeStyles/Project.xml
@@ -31,17 +31,17 @@
-
-
-
+
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/.woodpecker/check.yml b/.woodpecker/check.yml
index 678558cb..97d2ee11 100644
--- a/.woodpecker/check.yml
+++ b/.woodpecker/check.yml
@@ -7,12 +7,11 @@ pipeline:
regex: " \\\\* \\\\@author [\\\\S\\\\s]+"
must_contain: true
- #style:
- #image: qwerty287/woodpecker-intellij-formatter
- #group: check
- # settings:
- #file_pattern: "*.java"
- #path: "app/"
+ style:
+ image: alvrme/alpine-android:android-31-jdk11
+ group: check
+ commands:
+ - ./gradlew :app:spotlessCheck
test:
image: alvrme/alpine-android:android-31-jdk11
diff --git a/app/build.gradle b/app/build.gradle
index 33704555..2fc74cce 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -1,3 +1,6 @@
+plugins {
+ id "com.diffplug.spotless" version "6.11.0"
+}
apply plugin: 'com.android.application'
android {
@@ -118,3 +121,18 @@ dependencies {
}
implementation 'io.github.amrdeveloper:codeview:1.3.5'
}
+
+spotless {
+ java {
+ target 'src/**/*.java'
+
+ importOrder('android', 'androidx', 'com', 'junit', 'net', 'org', 'java', 'javax', '', '\\#')
+ removeUnusedImports()
+
+ googleJavaFormat().aosp()
+
+ indentWithTabs()
+
+ formatAnnotations()
+ }
+}
diff --git a/app/src/androidTest/java/org/main/gitnex/activities/MainActivityTest.java b/app/src/androidTest/java/org/main/gitnex/activities/MainActivityTest.java
index c12f24cc..b9dd01c4 100644
--- a/app/src/androidTest/java/org/main/gitnex/activities/MainActivityTest.java
+++ b/app/src/androidTest/java/org/main/gitnex/activities/MainActivityTest.java
@@ -18,5 +18,4 @@ public class MainActivityTest {
ActivityScenario a = ActivityScenario.launch(MainActivity.class);
a.close();
}
-
}
diff --git a/app/src/androidTest/java/org/main/gitnex/helpers/AppUtilTest.java b/app/src/androidTest/java/org/main/gitnex/helpers/AppUtilTest.java
index d8b19d11..53154070 100644
--- a/app/src/androidTest/java/org/main/gitnex/helpers/AppUtilTest.java
+++ b/app/src/androidTest/java/org/main/gitnex/helpers/AppUtilTest.java
@@ -1,5 +1,7 @@
package org.main.gitnex.helpers;
+import static org.junit.Assert.*;
+
import android.content.Context;
import android.net.Uri;
import android.view.View;
@@ -8,7 +10,6 @@ import androidx.test.platform.app.InstrumentationRegistry;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mian.gitnex.helpers.AppUtil;
-import static org.junit.Assert.*;
/**
* @author qwerty287
@@ -91,22 +92,43 @@ public class AppUtilTest {
@Test
public void getUriFromGitUrlTest() {
- assertEquals("https://git@codeberg.org/gitnex/GitNex", AppUtil.getUriFromGitUrl("ssh://git@codeberg.org:gitnex/GitNex").toString());
- assertEquals("https://codeberg.org/gitnex/GitNex", AppUtil.getUriFromGitUrl("codeberg.org:gitnex/GitNex").toString());
- assertEquals("ssh://git@codeberg.org/gitnex/GitNex", AppUtil.getUriFromGitUrl("ssh://git@codeberg.org/gitnex/GitNex").toString());
- assertEquals("https://git@codeberg.org/gitnex/GitNex.git", AppUtil.getUriFromGitUrl("ssh://git@codeberg.org:gitnex/GitNex.git").toString());
- assertEquals("https://codeberg.org/gitnex/GitNex.git", AppUtil.getUriFromGitUrl("codeberg.org:gitnex/GitNex.git").toString());
- assertEquals("https://codeberg.org/gitnex/GitNex.git", AppUtil.getUriFromGitUrl("https://codeberg.org/gitnex/GitNex.git").toString());
- assertEquals("https://gitnex.com", AppUtil.getUriFromGitUrl("https://gitnex.com").toString());
- assertEquals("https://gitnex.com:3000", AppUtil.getUriFromGitUrl("https://gitnex.com:3000").toString());
+ assertEquals(
+ "https://git@codeberg.org/gitnex/GitNex",
+ AppUtil.getUriFromGitUrl("ssh://git@codeberg.org:gitnex/GitNex").toString());
+ assertEquals(
+ "https://codeberg.org/gitnex/GitNex",
+ AppUtil.getUriFromGitUrl("codeberg.org:gitnex/GitNex").toString());
+ assertEquals(
+ "ssh://git@codeberg.org/gitnex/GitNex",
+ AppUtil.getUriFromGitUrl("ssh://git@codeberg.org/gitnex/GitNex").toString());
+ assertEquals(
+ "https://git@codeberg.org/gitnex/GitNex.git",
+ AppUtil.getUriFromGitUrl("ssh://git@codeberg.org:gitnex/GitNex.git").toString());
+ assertEquals(
+ "https://codeberg.org/gitnex/GitNex.git",
+ AppUtil.getUriFromGitUrl("codeberg.org:gitnex/GitNex.git").toString());
+ assertEquals(
+ "https://codeberg.org/gitnex/GitNex.git",
+ AppUtil.getUriFromGitUrl("https://codeberg.org/gitnex/GitNex.git").toString());
+ assertEquals(
+ "https://gitnex.com", AppUtil.getUriFromGitUrl("https://gitnex.com").toString());
+ assertEquals(
+ "https://gitnex.com:3000",
+ AppUtil.getUriFromGitUrl("https://gitnex.com:3000").toString());
}
@Test
public void changeSchemeTest() {
- assertEquals("https://codeberg.org/gitnex/GitNex", AppUtil.changeScheme(Uri.parse("ssh://codeberg.org/gitnex/GitNex"), "https").toString());
- assertEquals("https://gitnex.com", AppUtil.changeScheme(Uri.parse("http://gitnex.com"), "https").toString());
- assertEquals("ssh://codeberg.org/gitnex/GitNex", AppUtil.changeScheme(Uri.parse("http://codeberg.org/gitnex/GitNex"), "ssh").toString());
+ assertEquals(
+ "https://codeberg.org/gitnex/GitNex",
+ AppUtil.changeScheme(Uri.parse("ssh://codeberg.org/gitnex/GitNex"), "https")
+ .toString());
+ assertEquals(
+ "https://gitnex.com",
+ AppUtil.changeScheme(Uri.parse("http://gitnex.com"), "https").toString());
+ assertEquals(
+ "ssh://codeberg.org/gitnex/GitNex",
+ AppUtil.changeScheme(Uri.parse("http://codeberg.org/gitnex/GitNex"), "ssh")
+ .toString());
}
-
}
-
diff --git a/app/src/androidTest/java/org/main/gitnex/helpers/ToastyTest.java b/app/src/androidTest/java/org/main/gitnex/helpers/ToastyTest.java
index ca0b94de..e43299f2 100644
--- a/app/src/androidTest/java/org/main/gitnex/helpers/ToastyTest.java
+++ b/app/src/androidTest/java/org/main/gitnex/helpers/ToastyTest.java
@@ -45,5 +45,4 @@ public class ToastyTest {
Context context = InstrumentationRegistry.getInstrumentation().getTargetContext();
Toasty.success(context, "GitNex success test");
}
-
}
diff --git a/app/src/main/java/org/mian/gitnex/actions/ActionResult.java b/app/src/main/java/org/mian/gitnex/actions/ActionResult.java
index 3fe1077d..f2d94eee 100644
--- a/app/src/main/java/org/mian/gitnex/actions/ActionResult.java
+++ b/app/src/main/java/org/mian/gitnex/actions/ActionResult.java
@@ -11,7 +11,6 @@ import java.util.concurrent.TimeUnit;
/**
* @author opyale
*/
-
public class ActionResult {
private final BlockingQueue blockingQueue;
@@ -22,7 +21,6 @@ public class ActionResult {
blockingQueue = new ArrayBlockingQueue<>(1);
onFinishedListeners = new ArrayList<>();
-
}
public void finish(@NonNull Status status) {
@@ -33,54 +31,48 @@ public class ActionResult {
public void finish(@NonNull Status status, R result) {
try {
- if(blockingQueue.poll(5, TimeUnit.SECONDS)) {
+ if (blockingQueue.poll(5, TimeUnit.SECONDS)) {
- for(OnFinishedListener onFinishedListener : onFinishedListeners)
+ for (OnFinishedListener onFinishedListener : onFinishedListeners)
onFinishedListener.onFinished(status, result);
}
+ } catch (InterruptedException ignored) {
}
- catch(InterruptedException ignored) {
- }
-
}
public void invalidate() {
- if(invalidated) {
+ if (invalidated) {
throw new IllegalStateException("Already invalidated");
}
this.invalidated = true;
-
}
@SafeVarargs
- public synchronized final void accept(@NonNull OnFinishedListener... onFinishedListeners) {
+ public final synchronized void accept(@NonNull OnFinishedListener... onFinishedListeners) {
invalidate();
this.blockingQueue.add(true);
this.onFinishedListeners.addAll(Arrays.asList(onFinishedListeners));
-
}
- public synchronized final void discard() {
+ public final synchronized void discard() {
invalidate();
this.blockingQueue.add(false);
-
}
- public enum Status {SUCCESS, FAILED}
+ public enum Status {
+ SUCCESS,
+ FAILED
+ }
public interface OnFinishedListener {
void onFinished(Status status, R result);
-
- }
-
- public static class None {
-
}
+ public static class None {}
}
diff --git a/app/src/main/java/org/mian/gitnex/actions/AssigneesActions.java b/app/src/main/java/org/mian/gitnex/actions/AssigneesActions.java
index 1bf05b25..d0df8d69 100644
--- a/app/src/main/java/org/mian/gitnex/actions/AssigneesActions.java
+++ b/app/src/main/java/org/mian/gitnex/actions/AssigneesActions.java
@@ -5,6 +5,7 @@ import android.view.View;
import android.widget.ProgressBar;
import androidx.annotation.NonNull;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
+import java.util.List;
import org.gitnex.tea4j.v2.models.Issue;
import org.gitnex.tea4j.v2.models.User;
import org.mian.gitnex.R;
@@ -12,103 +13,130 @@ import org.mian.gitnex.adapters.AssigneesListAdapter;
import org.mian.gitnex.clients.RetrofitClient;
import org.mian.gitnex.databinding.CustomAssigneesSelectionDialogBinding;
import org.mian.gitnex.helpers.Toasty;
-import java.util.List;
import retrofit2.Call;
import retrofit2.Callback;
/**
* @author M M Arif
*/
-
public class AssigneesActions {
- public static void getCurrentIssueAssignees(Context ctx, String repoOwner, String repoName, int issueIndex, List currentAssignees) {
+ public static void getCurrentIssueAssignees(
+ Context ctx,
+ String repoOwner,
+ String repoName,
+ int issueIndex,
+ List currentAssignees) {
- Call callSingleIssueLabels = RetrofitClient.getApiInterface(ctx).issueGetIssue(repoOwner, repoName, (long) issueIndex);
+ Call callSingleIssueLabels =
+ RetrofitClient.getApiInterface(ctx)
+ .issueGetIssue(repoOwner, repoName, (long) issueIndex);
- callSingleIssueLabels.enqueue(new Callback<>() {
+ callSingleIssueLabels.enqueue(
+ new Callback<>() {
- @Override
- public void onResponse(@NonNull Call call, @NonNull retrofit2.Response response) {
+ @Override
+ public void onResponse(
+ @NonNull Call call,
+ @NonNull retrofit2.Response response) {
- if(response.code() == 200) {
+ if (response.code() == 200) {
- Issue issueAssigneesList = response.body();
- assert issueAssigneesList != null;
+ Issue issueAssigneesList = response.body();
+ assert issueAssigneesList != null;
- if(issueAssigneesList.getAssignees() != null) {
+ if (issueAssigneesList.getAssignees() != null) {
- if(issueAssigneesList.getAssignees().size() > 0) {
+ if (issueAssigneesList.getAssignees().size() > 0) {
- for(int i = 0; i < issueAssigneesList.getAssignees().size(); i++) {
+ for (int i = 0;
+ i < issueAssigneesList.getAssignees().size();
+ i++) {
- currentAssignees.add(issueAssigneesList.getAssignees().get(i).getLogin());
+ currentAssignees.add(
+ issueAssigneesList
+ .getAssignees()
+ .get(i)
+ .getLogin());
+ }
+ }
}
+ } else {
+
+ Toasty.error(ctx, ctx.getResources().getString(R.string.genericError));
}
}
- }
- else {
- Toasty.error(ctx, ctx.getResources().getString(R.string.genericError));
- }
- }
+ @Override
+ public void onFailure(@NonNull Call call, @NonNull Throwable t) {
- @Override
- public void onFailure(@NonNull Call call, @NonNull Throwable t) {
-
- Toasty.error(ctx, ctx.getResources().getString(R.string.genericServerResponseError));
- }
- });
+ Toasty.error(
+ ctx,
+ ctx.getResources().getString(R.string.genericServerResponseError));
+ }
+ });
}
- public static void getRepositoryAssignees(Context ctx, String repoOwner, String repoName, List assigneesList, MaterialAlertDialogBuilder materialAlertDialogBuilder, AssigneesListAdapter assigneesAdapter,
- CustomAssigneesSelectionDialogBinding assigneesBinding, ProgressBar progressBar) {
+ public static void getRepositoryAssignees(
+ Context ctx,
+ String repoOwner,
+ String repoName,
+ List assigneesList,
+ MaterialAlertDialogBuilder materialAlertDialogBuilder,
+ AssigneesListAdapter assigneesAdapter,
+ CustomAssigneesSelectionDialogBinding assigneesBinding,
+ ProgressBar progressBar) {
- Call> call = RetrofitClient.getApiInterface(ctx).repoGetAssignees(repoOwner, repoName);
+ Call> call =
+ RetrofitClient.getApiInterface(ctx).repoGetAssignees(repoOwner, repoName);
- call.enqueue(new Callback<>() {
+ call.enqueue(
+ new Callback<>() {
- @Override
- public void onResponse(@NonNull Call> call, @NonNull retrofit2.Response> response) {
+ @Override
+ public void onResponse(
+ @NonNull Call> call,
+ @NonNull retrofit2.Response> response) {
- assigneesList.clear();
- List assigneesList_ = response.body();
+ assigneesList.clear();
+ List assigneesList_ = response.body();
- if(response.code() == 200) {
+ if (response.code() == 200) {
- assert assigneesList_ != null;
+ assert assigneesList_ != null;
- if(assigneesList_.size() > 0) {
+ if (assigneesList_.size() > 0) {
- assigneesList.addAll(assigneesList_);
- materialAlertDialogBuilder.show();
- }
- else {
+ assigneesList.addAll(assigneesList_);
+ materialAlertDialogBuilder.show();
+ } else {
- Toasty.warning(ctx, ctx.getResources().getString(R.string.noAssigneesFound));
+ Toasty.warning(
+ ctx,
+ ctx.getResources().getString(R.string.noAssigneesFound));
+ }
+
+ assigneesBinding.assigneesRecyclerView.setAdapter(assigneesAdapter);
+
+ } else {
+
+ Toasty.error(ctx, ctx.getResources().getString(R.string.genericError));
+ }
+ if (progressBar != null) {
+ progressBar.setVisibility(View.GONE);
+ }
}
- assigneesBinding.assigneesRecyclerView.setAdapter(assigneesAdapter);
+ @Override
+ public void onFailure(@NonNull Call> call, @NonNull Throwable t) {
- }
- else {
-
- Toasty.error(ctx, ctx.getResources().getString(R.string.genericError));
- }
- if(progressBar != null) {
- progressBar.setVisibility(View.GONE);
- }
- }
-
- @Override
- public void onFailure(@NonNull Call> call, @NonNull Throwable t) {
-
- if(progressBar != null) {
- progressBar.setVisibility(View.GONE);
- }
- Toasty.error(ctx, ctx.getResources().getString(R.string.genericServerResponseError));
- }
- });
+ if (progressBar != null) {
+ progressBar.setVisibility(View.GONE);
+ }
+ Toasty.error(
+ ctx,
+ ctx.getResources().getString(R.string.genericServerResponseError));
+ }
+ });
}
-
}
diff --git a/app/src/main/java/org/mian/gitnex/actions/CollaboratorActions.java b/app/src/main/java/org/mian/gitnex/actions/CollaboratorActions.java
index bccf8195..cb24e580 100644
--- a/app/src/main/java/org/mian/gitnex/actions/CollaboratorActions.java
+++ b/app/src/main/java/org/mian/gitnex/actions/CollaboratorActions.java
@@ -16,97 +16,114 @@ import retrofit2.Callback;
/**
* @author M M Arif
*/
-
public class CollaboratorActions {
- public static void deleteCollaborator(final Context context, String userName, RepositoryContext repository) {
+ public static void deleteCollaborator(
+ final Context context, String userName, RepositoryContext repository) {
- Call call = RetrofitClient.getApiInterface(context).repoDeleteCollaborator(repository.getOwner(), repository.getName(), userName);
+ Call call =
+ RetrofitClient.getApiInterface(context)
+ .repoDeleteCollaborator(
+ repository.getOwner(), repository.getName(), userName);
- call.enqueue(new Callback<>() {
+ call.enqueue(
+ new Callback<>() {
- @Override
- public void onResponse(@NonNull Call call, @NonNull retrofit2.Response response) {
+ @Override
+ public void onResponse(
+ @NonNull Call call, @NonNull retrofit2.Response response) {
- if(response.isSuccessful()) {
- if(response.code() == 204) {
+ if (response.isSuccessful()) {
+ if (response.code() == 204) {
- CollaboratorsFragment.refreshCollaborators = true;
- Toasty.success(context, context.getString(R.string.removeCollaboratorToastText));
- ((AddCollaboratorToRepositoryActivity) context).finish();
+ CollaboratorsFragment.refreshCollaborators = true;
+ Toasty.success(
+ context,
+ context.getString(R.string.removeCollaboratorToastText));
+ ((AddCollaboratorToRepositoryActivity) context).finish();
+ }
+ } else if (response.code() == 401) {
+
+ AlertDialogs.authorizationTokenRevokedDialog(context);
+ } else if (response.code() == 403) {
+
+ Toasty.error(context, context.getString(R.string.authorizeError));
+ } else if (response.code() == 404) {
+
+ Toasty.warning(context, context.getString(R.string.apiNotFound));
+ } else {
+
+ Toasty.error(context, context.getString(R.string.genericError));
+ }
}
- }
- else if(response.code() == 401) {
- AlertDialogs.authorizationTokenRevokedDialog(context);
- }
- else if(response.code() == 403) {
-
- Toasty.error(context, context.getString(R.string.authorizeError));
- }
- else if(response.code() == 404) {
-
- Toasty.warning(context, context.getString(R.string.apiNotFound));
- }
- else {
-
- Toasty.error(context, context.getString(R.string.genericError));
- }
- }
-
- @Override
- public void onFailure(@NonNull Call call, @NonNull Throwable t) {
-
- Toasty.error(context, context.getResources().getString(R.string.genericServerResponseError));
- }
- });
+ @Override
+ public void onFailure(@NonNull Call call, @NonNull Throwable t) {
+ Toasty.error(
+ context,
+ context.getResources()
+ .getString(R.string.genericServerResponseError));
+ }
+ });
}
- public static void addCollaborator(final Context context, String permission, String userName, RepositoryContext repository) {
+ public static void addCollaborator(
+ final Context context,
+ String permission,
+ String userName,
+ RepositoryContext repository) {
AddCollaboratorOption permissionString = new AddCollaboratorOption();
permissionString.setPermission(permission);
- Call call = RetrofitClient.getApiInterface(context).repoAddCollaborator(repository.getOwner(), repository.getName(), userName, permissionString);
+ Call call =
+ RetrofitClient.getApiInterface(context)
+ .repoAddCollaborator(
+ repository.getOwner(),
+ repository.getName(),
+ userName,
+ permissionString);
- call.enqueue(new Callback<>() {
+ call.enqueue(
+ new Callback<>() {
- @Override
- public void onResponse(@NonNull Call call, @NonNull retrofit2.Response response) {
+ @Override
+ public void onResponse(
+ @NonNull Call call, @NonNull retrofit2.Response response) {
- if(response.isSuccessful()) {
- if(response.code() == 204) {
+ if (response.isSuccessful()) {
+ if (response.code() == 204) {
- CollaboratorsFragment.refreshCollaborators = true;
- Toasty.success(context, context.getString(R.string.addCollaboratorToastText));
- ((AddCollaboratorToRepositoryActivity) context).finish();
+ CollaboratorsFragment.refreshCollaborators = true;
+ Toasty.success(
+ context,
+ context.getString(R.string.addCollaboratorToastText));
+ ((AddCollaboratorToRepositoryActivity) context).finish();
+ }
+ } else if (response.code() == 401) {
+
+ AlertDialogs.authorizationTokenRevokedDialog(context);
+ } else if (response.code() == 403) {
+
+ Toasty.error(context, context.getString(R.string.authorizeError));
+ } else if (response.code() == 404) {
+
+ Toasty.warning(context, context.getString(R.string.apiNotFound));
+ } else {
+
+ Toasty.error(context, context.getString(R.string.genericError));
+ }
}
- }
- else if(response.code() == 401) {
- AlertDialogs.authorizationTokenRevokedDialog(context);
- }
- else if(response.code() == 403) {
+ @Override
+ public void onFailure(@NonNull Call call, @NonNull Throwable t) {
- Toasty.error(context, context.getString(R.string.authorizeError));
- }
- else if(response.code() == 404) {
-
- Toasty.warning(context, context.getString(R.string.apiNotFound));
- }
- else {
-
- Toasty.error(context, context.getString(R.string.genericError));
- }
- }
-
- @Override
- public void onFailure(@NonNull Call call, @NonNull Throwable t) {
-
- Toasty.error(context, context.getResources().getString(R.string.genericServerResponseError));
- }
- });
+ Toasty.error(
+ context,
+ context.getResources()
+ .getString(R.string.genericServerResponseError));
+ }
+ });
}
-
}
diff --git a/app/src/main/java/org/mian/gitnex/actions/IssueActions.java b/app/src/main/java/org/mian/gitnex/actions/IssueActions.java
index ff8fbe1a..2f5de64e 100644
--- a/app/src/main/java/org/mian/gitnex/actions/IssueActions.java
+++ b/app/src/main/java/org/mian/gitnex/actions/IssueActions.java
@@ -25,243 +25,288 @@ import retrofit2.Response;
/**
* @author M M Arif
*/
-
public class IssueActions {
- public static ActionResult> edit(Context context, String comment, int commentId, IssueContext issue) {
+ public static ActionResult> edit(
+ Context context, String comment, int commentId, IssueContext issue) {
ActionResult> actionResult = new ActionResult<>();
EditIssueCommentOption commentObj = new EditIssueCommentOption();
commentObj.setBody(comment);
- Call call = RetrofitClient.getApiInterface(context).issueEditComment(issue.getRepository().getOwner(), issue.getRepository().getName(), (long) commentId, commentObj);
+ Call call =
+ RetrofitClient.getApiInterface(context)
+ .issueEditComment(
+ issue.getRepository().getOwner(),
+ issue.getRepository().getName(),
+ (long) commentId,
+ commentObj);
- call.enqueue(new Callback<>() {
+ call.enqueue(
+ new Callback<>() {
- @Override
- public void onResponse(@NonNull Call call, @NonNull retrofit2.Response response) {
+ @Override
+ public void onResponse(
+ @NonNull Call call,
+ @NonNull retrofit2.Response response) {
- switch(response.code()) {
+ switch (response.code()) {
+ case 200:
+ actionResult.finish(ActionResult.Status.SUCCESS);
+ break;
- case 200:
- actionResult.finish(ActionResult.Status.SUCCESS);
- break;
+ case 401:
+ actionResult.finish(ActionResult.Status.FAILED, response);
+ AlertDialogs.authorizationTokenRevokedDialog(context);
+ break;
- case 401:
- actionResult.finish(ActionResult.Status.FAILED, response);
- AlertDialogs.authorizationTokenRevokedDialog(context);
- break;
+ default:
+ actionResult.finish(ActionResult.Status.FAILED, response);
+ break;
+ }
+ }
- default:
- actionResult.finish(ActionResult.Status.FAILED, response);
- break;
+ @Override
+ public void onFailure(@NonNull Call call, @NonNull Throwable t) {
- }
- }
-
- @Override
- public void onFailure(@NonNull Call call, @NonNull Throwable t) {
-
- actionResult.finish(ActionResult.Status.FAILED);
- }
- });
+ actionResult.finish(ActionResult.Status.FAILED);
+ }
+ });
return actionResult;
}
- public static void closeReopenIssue(final Context ctx, final String issueState, IssueContext issue) {
+ public static void closeReopenIssue(
+ final Context ctx, final String issueState, IssueContext issue) {
EditIssueOption issueStatJson = new EditIssueOption();
issueStatJson.setState(issueState);
- Call call = RetrofitClient.getApiInterface(ctx).issueEditIssue(issue.getRepository().getOwner(), issue.getRepository().getName(), (long) issue.getIssueIndex(), issueStatJson);
+ Call call =
+ RetrofitClient.getApiInterface(ctx)
+ .issueEditIssue(
+ issue.getRepository().getOwner(),
+ issue.getRepository().getName(),
+ (long) issue.getIssueIndex(),
+ issueStatJson);
- call.enqueue(new Callback<>() {
+ call.enqueue(
+ new Callback<>() {
- @Override
- public void onResponse(@NonNull Call call, @NonNull retrofit2.Response response) {
+ @Override
+ public void onResponse(
+ @NonNull Call call,
+ @NonNull retrofit2.Response response) {
- if(response.isSuccessful()) {
- if(response.code() == 201) {
+ if (response.isSuccessful()) {
+ if (response.code() == 201) {
- if(issue.hasIssue()) {
- IssuesFragment.resumeIssues = issue.getIssue().getPullRequest() == null;
- PullRequestsFragment.resumePullRequests = issue.getIssue().getPullRequest() != null;
- }
- if(issue.getIssueType().equalsIgnoreCase("Pull")) {
- if(issueState.equals("closed")) {
- Toasty.success(ctx, ctx.getString(R.string.prClosed));
+ if (issue.hasIssue()) {
+ IssuesFragment.resumeIssues =
+ issue.getIssue().getPullRequest() == null;
+ PullRequestsFragment.resumePullRequests =
+ issue.getIssue().getPullRequest() != null;
+ }
+ if (issue.getIssueType().equalsIgnoreCase("Pull")) {
+ if (issueState.equals("closed")) {
+ Toasty.success(ctx, ctx.getString(R.string.prClosed));
+ } else if (issueState.equals("open")) {
+ Toasty.success(ctx, ctx.getString(R.string.prReopened));
+ }
+ } else {
+ if (issueState.equals("closed")) {
+ Toasty.success(
+ ctx, ctx.getString(R.string.issueStateClosed));
+ } else if (issueState.equals("open")) {
+ Toasty.success(
+ ctx, ctx.getString(R.string.issueStateReopened));
+ }
+ }
+
+ IssueDetailActivity.singleIssueUpdate = true;
+ ((IssueDetailActivity) ctx).onResume();
+ if (((Activity) ctx).getIntent().getStringExtra("openedFromLink")
+ == null
+ || !((Activity) ctx)
+ .getIntent()
+ .getStringExtra("openedFromLink")
+ .equals("true")) {
+ RepoDetailActivity.updateRepo = true;
+ }
}
- else if(issueState.equals("open")) {
- Toasty.success(ctx, ctx.getString(R.string.prReopened));
- }
- }
- else {
- if(issueState.equals("closed")) {
- Toasty.success(ctx, ctx.getString(R.string.issueStateClosed));
- }
- else if(issueState.equals("open")) {
- Toasty.success(ctx, ctx.getString(R.string.issueStateReopened));
- }
- }
+ } else if (response.code() == 401) {
- IssueDetailActivity.singleIssueUpdate = true;
- ((IssueDetailActivity) ctx).onResume();
- if(((Activity) ctx).getIntent().getStringExtra("openedFromLink") == null || !((Activity) ctx).getIntent().getStringExtra("openedFromLink").equals("true")) {
- RepoDetailActivity.updateRepo = true;
+ AlertDialogs.authorizationTokenRevokedDialog(ctx);
+ } else if (response.code() == 403) {
+
+ Toasty.error(ctx, ctx.getString(R.string.authorizeError));
+ } else if (response.code() == 404) {
+
+ Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
+ } else {
+
+ Toasty.error(ctx, ctx.getString(R.string.genericError));
}
}
- }
- else if(response.code() == 401) {
- AlertDialogs.authorizationTokenRevokedDialog(ctx);
- }
- else if(response.code() == 403) {
-
- Toasty.error(ctx, ctx.getString(R.string.authorizeError));
- }
- else if(response.code() == 404) {
-
- Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
- }
- else {
-
- Toasty.error(ctx, ctx.getString(R.string.genericError));
- }
- }
-
- @Override
- public void onFailure(@NonNull Call call, @NonNull Throwable t) {
-
- Toasty.error(ctx, ctx.getResources().getString(R.string.genericServerResponseError));
- }
- });
+ @Override
+ public void onFailure(@NonNull Call call, @NonNull Throwable t) {
+ Toasty.error(
+ ctx,
+ ctx.getResources().getString(R.string.genericServerResponseError));
+ }
+ });
}
public static void subscribe(final Context ctx, IssueContext issue) {
Call call;
- call = RetrofitClient.getApiInterface(ctx)
- .issueAddSubscription(issue.getRepository().getOwner(), issue.getRepository().getName(), (long) issue.getIssueIndex(), ((BaseActivity) ctx).getAccount().getAccount().getUserName());
+ call =
+ RetrofitClient.getApiInterface(ctx)
+ .issueAddSubscription(
+ issue.getRepository().getOwner(),
+ issue.getRepository().getName(),
+ (long) issue.getIssueIndex(),
+ ((BaseActivity) ctx).getAccount().getAccount().getUserName());
- call.enqueue(new Callback<>() {
+ call.enqueue(
+ new Callback<>() {
- @Override
- public void onResponse(@NonNull Call call, @NonNull retrofit2.Response response) {
+ @Override
+ public void onResponse(
+ @NonNull Call call, @NonNull retrofit2.Response response) {
- if(response.isSuccessful()) {
+ if (response.isSuccessful()) {
- if(response.code() == 201) {
+ if (response.code() == 201) {
- Toasty.success(ctx, ctx.getString(R.string.subscribedSuccessfully));
+ Toasty.success(ctx, ctx.getString(R.string.subscribedSuccessfully));
+ } else if (response.code() == 200) {
+
+ Toasty.success(ctx, ctx.getString(R.string.alreadySubscribed));
+ }
+ } else if (response.code() == 401) {
+
+ AlertDialogs.authorizationTokenRevokedDialog(ctx);
+ } else {
+
+ Toasty.error(ctx, ctx.getString(R.string.subscriptionError));
+ }
}
- else if(response.code() == 200) {
- Toasty.success(ctx, ctx.getString(R.string.alreadySubscribed));
+ @Override
+ public void onFailure(@NonNull Call call, @NonNull Throwable t) {
+
+ Toasty.error(
+ ctx,
+ ctx.getResources().getString(R.string.genericServerResponseError));
}
- }
- else if(response.code() == 401) {
-
- AlertDialogs.authorizationTokenRevokedDialog(ctx);
- }
- else {
-
- Toasty.error(ctx, ctx.getString(R.string.subscriptionError));
- }
- }
-
- @Override
- public void onFailure(@NonNull Call call, @NonNull Throwable t) {
-
- Toasty.error(ctx, ctx.getResources().getString(R.string.genericServerResponseError));
- }
- });
+ });
}
public static void unsubscribe(final Context ctx, IssueContext issue) {
Call call;
- call = RetrofitClient.getApiInterface(ctx)
- .issueDeleteSubscription(issue.getRepository().getOwner(), issue.getRepository().getName(), (long) issue.getIssueIndex(), ((BaseActivity) ctx).getAccount().getAccount().getUserName());
+ call =
+ RetrofitClient.getApiInterface(ctx)
+ .issueDeleteSubscription(
+ issue.getRepository().getOwner(),
+ issue.getRepository().getName(),
+ (long) issue.getIssueIndex(),
+ ((BaseActivity) ctx).getAccount().getAccount().getUserName());
- call.enqueue(new Callback<>() {
+ call.enqueue(
+ new Callback<>() {
- @Override
- public void onResponse(@NonNull Call call, @NonNull retrofit2.Response response) {
+ @Override
+ public void onResponse(
+ @NonNull Call call, @NonNull retrofit2.Response response) {
- if(response.isSuccessful()) {
+ if (response.isSuccessful()) {
- if(response.code() == 201) {
+ if (response.code() == 201) {
- Toasty.success(ctx, ctx.getString(R.string.unsubscribedSuccessfully));
+ Toasty.success(
+ ctx, ctx.getString(R.string.unsubscribedSuccessfully));
+ } else if (response.code() == 200) {
+
+ Toasty.success(ctx, ctx.getString(R.string.alreadyUnsubscribed));
+ }
+ } else if (response.code() == 401) {
+
+ AlertDialogs.authorizationTokenRevokedDialog(ctx);
+ } else {
+
+ Toasty.error(ctx, ctx.getString(R.string.unSubscriptionError));
+ }
}
- else if(response.code() == 200) {
- Toasty.success(ctx, ctx.getString(R.string.alreadyUnsubscribed));
+ @Override
+ public void onFailure(@NonNull Call call, @NonNull Throwable t) {
+
+ Toasty.error(
+ ctx,
+ ctx.getResources().getString(R.string.genericServerResponseError));
}
- }
- else if(response.code() == 401) {
-
- AlertDialogs.authorizationTokenRevokedDialog(ctx);
- }
- else {
-
- Toasty.error(ctx, ctx.getString(R.string.unSubscriptionError));
- }
- }
-
- @Override
- public void onFailure(@NonNull Call call, @NonNull Throwable t) {
-
- Toasty.error(ctx, ctx.getResources().getString(R.string.genericServerResponseError));
- }
- });
+ });
}
- public static ActionResult reply(Context context, String comment, IssueContext issue) {
+ public static ActionResult reply(
+ Context context, String comment, IssueContext issue) {
ActionResult actionResult = new ActionResult<>();
CreateIssueCommentOption issueComment = new CreateIssueCommentOption();
issueComment.setBody(comment);
- Call call = RetrofitClient.getApiInterface(context).issueCreateComment(issue.getRepository().getOwner(), issue.getRepository().getName(), (long) issue.getIssueIndex(), issueComment);
+ Call call =
+ RetrofitClient.getApiInterface(context)
+ .issueCreateComment(
+ issue.getRepository().getOwner(),
+ issue.getRepository().getName(),
+ (long) issue.getIssueIndex(),
+ issueComment);
- call.enqueue(new Callback<>() {
+ call.enqueue(
+ new Callback<>() {
- @Override
- public void onResponse(@NonNull Call call, @NonNull retrofit2.Response response) {
+ @Override
+ public void onResponse(
+ @NonNull Call call,
+ @NonNull retrofit2.Response response) {
- if(response.code() == 201) {
- actionResult.finish(ActionResult.Status.SUCCESS);
+ if (response.code() == 201) {
+ actionResult.finish(ActionResult.Status.SUCCESS);
- if(issue.hasIssue()) {
- IssuesFragment.resumeIssues = issue.getIssue().getPullRequest() == null;
- PullRequestsFragment.resumePullRequests = issue.getIssue().getPullRequest() != null;
+ if (issue.hasIssue()) {
+ IssuesFragment.resumeIssues =
+ issue.getIssue().getPullRequest() == null;
+ PullRequestsFragment.resumePullRequests =
+ issue.getIssue().getPullRequest() != null;
+ }
+ } else if (response.code() == 401) {
+
+ AlertDialogs.authorizationTokenRevokedDialog(context);
+
+ } else {
+
+ actionResult.finish(ActionResult.Status.FAILED);
+ }
}
- }
- else if(response.code() == 401) {
- AlertDialogs.authorizationTokenRevokedDialog(context);
+ @Override
+ public void onFailure(@NonNull Call call, @NonNull Throwable t) {
- }
- else {
-
- actionResult.finish(ActionResult.Status.FAILED);
- }
- }
-
- @Override
- public void onFailure(@NonNull Call call, @NonNull Throwable t) {
-
- Toasty.error(context, context.getResources().getString(R.string.genericServerResponseError));
- }
- });
+ Toasty.error(
+ context,
+ context.getResources()
+ .getString(R.string.genericServerResponseError));
+ }
+ });
return actionResult;
}
-
}
diff --git a/app/src/main/java/org/mian/gitnex/actions/LabelsActions.java b/app/src/main/java/org/mian/gitnex/actions/LabelsActions.java
index c020a977..84bfda13 100644
--- a/app/src/main/java/org/mian/gitnex/actions/LabelsActions.java
+++ b/app/src/main/java/org/mian/gitnex/actions/LabelsActions.java
@@ -5,124 +5,160 @@ import android.view.View;
import android.widget.ProgressBar;
import androidx.annotation.NonNull;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
+import java.util.List;
import org.gitnex.tea4j.v2.models.Label;
import org.mian.gitnex.R;
import org.mian.gitnex.adapters.LabelsListAdapter;
import org.mian.gitnex.clients.RetrofitClient;
import org.mian.gitnex.databinding.CustomLabelsSelectionDialogBinding;
import org.mian.gitnex.helpers.Toasty;
-import java.util.List;
import retrofit2.Call;
import retrofit2.Callback;
/**
* @author M M Arif
*/
-
public class LabelsActions {
- public static void getCurrentIssueLabels(Context ctx, String repoOwner, String repoName, int issueIndex, List currentLabelsIds) {
+ public static void getCurrentIssueLabels(
+ Context ctx,
+ String repoOwner,
+ String repoName,
+ int issueIndex,
+ List currentLabelsIds) {
- Call> callSingleIssueLabels = RetrofitClient.getApiInterface(ctx).issueGetLabels(repoOwner, repoName, (long) issueIndex);
+ Call> callSingleIssueLabels =
+ RetrofitClient.getApiInterface(ctx)
+ .issueGetLabels(repoOwner, repoName, (long) issueIndex);
- callSingleIssueLabels.enqueue(new Callback<>() {
+ callSingleIssueLabels.enqueue(
+ new Callback<>() {
- @Override
- public void onResponse(@NonNull Call> call, @NonNull retrofit2.Response> response) {
+ @Override
+ public void onResponse(
+ @NonNull Call> call,
+ @NonNull retrofit2.Response> response) {
- if(response.isSuccessful()) {
+ if (response.isSuccessful()) {
- List