Add Issue Subscribtion (#203)
rename Context move things to IssueActions rm unused API func get Context only one time add repoWatch into tinyDB add maginal Issue Un-/Subscription support add Issue Subscribtion * api * layout Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://gitea.com/gitnex/GitNex/pulls/203 Reviewed-by: M M Arif <mmarif@swatian.com>
This commit is contained in:
		| @@ -2,6 +2,8 @@ package org.mian.gitnex.actions; | |||||||
|  |  | ||||||
| import android.content.Context; | import android.content.Context; | ||||||
| import android.util.Log; | import android.util.Log; | ||||||
|  | import android.view.View; | ||||||
|  | import android.widget.TextView; | ||||||
| import com.google.gson.JsonElement; | import com.google.gson.JsonElement; | ||||||
| import org.mian.gitnex.R; | import org.mian.gitnex.R; | ||||||
| import org.mian.gitnex.activities.ReplyToIssueActivity; | import org.mian.gitnex.activities.ReplyToIssueActivity; | ||||||
| @@ -22,9 +24,9 @@ import retrofit2.Callback; | |||||||
|  |  | ||||||
| public class IssueActions { | public class IssueActions { | ||||||
|  |  | ||||||
|     public static void editIssueComment(final Context context, final int commentId, final String commentBody) { |     public static void editIssueComment(final Context ctx, final int commentId, final String commentBody) { | ||||||
|  |  | ||||||
|         final TinyDB tinyDb = new TinyDB(context); |         final TinyDB tinyDb = new TinyDB(ctx); | ||||||
|         final String instanceUrl = tinyDb.getString("instanceUrl"); |         final String instanceUrl = tinyDb.getString("instanceUrl"); | ||||||
|         final String loginUid = tinyDb.getString("loginUid"); |         final String loginUid = tinyDb.getString("loginUid"); | ||||||
|         final String instanceToken = "token " + tinyDb.getString(loginUid + "-token"); |         final String instanceToken = "token " + tinyDb.getString(loginUid + "-token"); | ||||||
| @@ -37,9 +39,9 @@ public class IssueActions { | |||||||
|         Call<IssueComments> call; |         Call<IssueComments> call; | ||||||
|  |  | ||||||
|         call = RetrofitClient |         call = RetrofitClient | ||||||
|                 .getInstance(instanceUrl, context) |                 .getInstance(instanceUrl, ctx) | ||||||
|                 .getApiInterface() |                 .getApiInterface() | ||||||
|                 .patchIssueComment(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName, commentId, commentBodyJson); |                 .patchIssueComment(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, commentId, commentBodyJson); | ||||||
|  |  | ||||||
|         call.enqueue(new Callback<IssueComments>() { |         call.enqueue(new Callback<IssueComments>() { | ||||||
|  |  | ||||||
| @@ -50,32 +52,32 @@ public class IssueActions { | |||||||
|                     if(response.code() == 200) { |                     if(response.code() == 200) { | ||||||
|  |  | ||||||
|                         tinyDb.putBoolean("commentEdited", true); |                         tinyDb.putBoolean("commentEdited", true); | ||||||
|                         Toasty.info(context, context.getString(R.string.editCommentUpdatedText)); |                         Toasty.info(ctx, ctx.getString(R.string.editCommentUpdatedText)); | ||||||
|                         ((ReplyToIssueActivity)context).finish(); |                         ((ReplyToIssueActivity)ctx).finish(); | ||||||
|  |  | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|                 else if(response.code() == 401) { |                 else if(response.code() == 401) { | ||||||
|  |  | ||||||
|                     AlertDialogs.authorizationTokenRevokedDialog(context, context.getResources().getString(R.string.alertDialogTokenRevokedTitle), |                     AlertDialogs.authorizationTokenRevokedDialog(ctx, ctx.getResources().getString(R.string.alertDialogTokenRevokedTitle), | ||||||
|                             context.getResources().getString(R.string.alertDialogTokenRevokedMessage), |                             ctx.getResources().getString(R.string.alertDialogTokenRevokedMessage), | ||||||
|                             context.getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton), |                             ctx.getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton), | ||||||
|                             context.getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton)); |                             ctx.getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton)); | ||||||
|  |  | ||||||
|                 } |                 } | ||||||
|                 else if(response.code() == 403) { |                 else if(response.code() == 403) { | ||||||
|  |  | ||||||
|                     Toasty.info(context, context.getString(R.string.authorizeError)); |                     Toasty.info(ctx, ctx.getString(R.string.authorizeError)); | ||||||
|  |  | ||||||
|                 } |                 } | ||||||
|                 else if(response.code() == 404) { |                 else if(response.code() == 404) { | ||||||
|  |  | ||||||
|                     Toasty.info(context, context.getString(R.string.apiNotFound)); |                     Toasty.info(ctx, ctx.getString(R.string.apiNotFound)); | ||||||
|  |  | ||||||
|                 } |                 } | ||||||
|                 else { |                 else { | ||||||
|  |  | ||||||
|                     Toasty.info(context, context.getString(R.string.genericError)); |                     Toasty.info(ctx, ctx.getString(R.string.genericError)); | ||||||
|  |  | ||||||
|                 } |                 } | ||||||
|  |  | ||||||
| @@ -89,9 +91,9 @@ public class IssueActions { | |||||||
|  |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static void closeReopenIssue(final Context context, final int issueIndex, final String issueState) { |     public static void closeReopenIssue(final Context ctx, final int issueIndex, final String issueState) { | ||||||
|  |  | ||||||
|         final TinyDB tinyDb = new TinyDB(context); |         final TinyDB tinyDb = new TinyDB(ctx); | ||||||
|         final String instanceUrl = tinyDb.getString("instanceUrl"); |         final String instanceUrl = tinyDb.getString("instanceUrl"); | ||||||
|         final String loginUid = tinyDb.getString("loginUid"); |         final String loginUid = tinyDb.getString("loginUid"); | ||||||
|         final String instanceToken = "token " + tinyDb.getString(loginUid + "-token"); |         final String instanceToken = "token " + tinyDb.getString(loginUid + "-token"); | ||||||
| @@ -104,9 +106,9 @@ public class IssueActions { | |||||||
|         Call<JsonElement> call; |         Call<JsonElement> call; | ||||||
|  |  | ||||||
|         call = RetrofitClient |         call = RetrofitClient | ||||||
|                 .getInstance(instanceUrl, context) |                 .getInstance(instanceUrl, ctx) | ||||||
|                 .getApiInterface() |                 .getApiInterface() | ||||||
|                 .closeReopenIssue(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName, issueIndex, issueStatJson); |                 .closeReopenIssue(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, issueIndex, issueStatJson); | ||||||
|  |  | ||||||
|         call.enqueue(new Callback<JsonElement>() { |         call.enqueue(new Callback<JsonElement>() { | ||||||
|  |  | ||||||
| @@ -119,35 +121,35 @@ public class IssueActions { | |||||||
|                         tinyDb.putBoolean("resumeIssues", true); |                         tinyDb.putBoolean("resumeIssues", true); | ||||||
|                         tinyDb.putBoolean("resumeClosedIssues", true); |                         tinyDb.putBoolean("resumeClosedIssues", true); | ||||||
|                         if(issueState.equals("closed")) { |                         if(issueState.equals("closed")) { | ||||||
|                             Toasty.info(context, context.getString(R.string.issueStateClosed)); |                             Toasty.info(ctx, ctx.getString(R.string.issueStateClosed)); | ||||||
|                         } |                         } | ||||||
|                         else if(issueState.equals("open")) { |                         else if(issueState.equals("open")) { | ||||||
|                             Toasty.info(context, context.getString(R.string.issueStateReopened)); |                             Toasty.info(ctx, ctx.getString(R.string.issueStateReopened)); | ||||||
|                         } |                         } | ||||||
|  |  | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|                 else if(response.code() == 401) { |                 else if(response.code() == 401) { | ||||||
|  |  | ||||||
|                     AlertDialogs.authorizationTokenRevokedDialog(context, context.getResources().getString(R.string.alertDialogTokenRevokedTitle), |                     AlertDialogs.authorizationTokenRevokedDialog(ctx, ctx.getResources().getString(R.string.alertDialogTokenRevokedTitle), | ||||||
|                             context.getResources().getString(R.string.alertDialogTokenRevokedMessage), |                             ctx.getResources().getString(R.string.alertDialogTokenRevokedMessage), | ||||||
|                             context.getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton), |                             ctx.getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton), | ||||||
|                             context.getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton)); |                             ctx.getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton)); | ||||||
|  |  | ||||||
|                 } |                 } | ||||||
|                 else if(response.code() == 403) { |                 else if(response.code() == 403) { | ||||||
|  |  | ||||||
|                     Toasty.info(context, context.getString(R.string.authorizeError)); |                     Toasty.info(ctx, ctx.getString(R.string.authorizeError)); | ||||||
|  |  | ||||||
|                 } |                 } | ||||||
|                 else if(response.code() == 404) { |                 else if(response.code() == 404) { | ||||||
|  |  | ||||||
|                     Toasty.info(context, context.getString(R.string.apiNotFound)); |                     Toasty.info(ctx, ctx.getString(R.string.apiNotFound)); | ||||||
|  |  | ||||||
|                 } |                 } | ||||||
|                 else { |                 else { | ||||||
|  |  | ||||||
|                     Toasty.info(context, context.getString(R.string.genericError)); |                     Toasty.info(ctx, ctx.getString(R.string.genericError)); | ||||||
|  |  | ||||||
|                 } |                 } | ||||||
|  |  | ||||||
| @@ -161,4 +163,117 @@ public class IssueActions { | |||||||
|  |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     public static void subscribe(final Context ctx, final TextView subscribeIssue, final TextView unsubscribeIssue) { | ||||||
|  |  | ||||||
|  |         final TinyDB tinyDB = new TinyDB(ctx); | ||||||
|  |  | ||||||
|  |         final String instanceUrl = tinyDB.getString("instanceUrl"); | ||||||
|  |         String repoFullName = tinyDB.getString("repoFullName"); | ||||||
|  |         String[] parts = repoFullName.split("/"); | ||||||
|  |         final String repoOwner = parts[0]; | ||||||
|  |         final String repoName = parts[1]; | ||||||
|  |         final String loginUid = tinyDB.getString("loginUid"); | ||||||
|  |         final String userLogin = tinyDB.getString("userLogin"); | ||||||
|  |         final String token = "token " + tinyDB.getString(loginUid + "-token"); | ||||||
|  |         final int issueNr = Integer.parseInt(tinyDB.getString("issueNumber")); | ||||||
|  |  | ||||||
|  |         Call<Void> call; | ||||||
|  |  | ||||||
|  |         call = RetrofitClient | ||||||
|  |                 .getInstance(instanceUrl, ctx) | ||||||
|  |                 .getApiInterface() | ||||||
|  |                 .addIssueSubscriber(token, repoOwner, repoName, issueNr, userLogin); | ||||||
|  |  | ||||||
|  |         call.enqueue(new Callback<Void>() { | ||||||
|  |  | ||||||
|  |             @Override | ||||||
|  |             public void onResponse(@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) { | ||||||
|  |  | ||||||
|  |                 if(response.isSuccessful()) { | ||||||
|  |  | ||||||
|  |                     Toasty.info(ctx, ctx.getString(R.string.issueSubscribtion)); | ||||||
|  |                     subscribeIssue.setVisibility(View.GONE); | ||||||
|  |                     unsubscribeIssue.setVisibility(View.VISIBLE); | ||||||
|  |  | ||||||
|  |                 } | ||||||
|  |                 else if(response.code() == 401) { | ||||||
|  |  | ||||||
|  |                     AlertDialogs.authorizationTokenRevokedDialog(ctx, ctx.getResources().getString(R.string.alertDialogTokenRevokedTitle), | ||||||
|  |                             ctx.getResources().getString(R.string.alertDialogTokenRevokedMessage), | ||||||
|  |                             ctx.getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton), | ||||||
|  |                             ctx.getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton)); | ||||||
|  |  | ||||||
|  |                 } | ||||||
|  |                 else { | ||||||
|  |  | ||||||
|  |                     Toasty.info(ctx, ctx.getString(R.string.issueSubscribtionError)); | ||||||
|  |  | ||||||
|  |                 } | ||||||
|  |  | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |             @Override | ||||||
|  |             public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) { | ||||||
|  |                 Toasty.info(ctx, ctx.getString(R.string.issueSubscribtionError)); | ||||||
|  |             } | ||||||
|  |         }); | ||||||
|  |  | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public static void unsubscribe(final Context ctx, final TextView subscribeIssue, final TextView unsubscribeIssue) { | ||||||
|  |  | ||||||
|  |         final TinyDB tinyDB = new TinyDB(ctx); | ||||||
|  |  | ||||||
|  |         final String instanceUrl = tinyDB.getString("instanceUrl"); | ||||||
|  |         String repoFullName = tinyDB.getString("repoFullName"); | ||||||
|  |         String[] parts = repoFullName.split("/"); | ||||||
|  |         final String repoOwner = parts[0]; | ||||||
|  |         final String repoName = parts[1]; | ||||||
|  |         final String loginUid = tinyDB.getString("loginUid"); | ||||||
|  |         final String userLogin = tinyDB.getString("userLogin"); | ||||||
|  |         final String token = "token " + tinyDB.getString(loginUid + "-token"); | ||||||
|  |         final int issueNr = Integer.parseInt(tinyDB.getString("issueNumber")); | ||||||
|  |  | ||||||
|  |         Call<Void> call; | ||||||
|  |  | ||||||
|  |         call = RetrofitClient | ||||||
|  |                 .getInstance(instanceUrl, ctx) | ||||||
|  |                 .getApiInterface() | ||||||
|  |                 .delIssueSubscriber(token, repoOwner, repoName, issueNr, userLogin); | ||||||
|  |  | ||||||
|  |         call.enqueue(new Callback<Void>() { | ||||||
|  |  | ||||||
|  |             @Override | ||||||
|  |             public void onResponse(@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) { | ||||||
|  |  | ||||||
|  |                 if(response.isSuccessful()) { | ||||||
|  |  | ||||||
|  |                     Toasty.info(ctx, ctx.getString(R.string.issueUnsubscribtion)); | ||||||
|  |                     unsubscribeIssue.setVisibility(View.GONE); | ||||||
|  |                     subscribeIssue.setVisibility(View.VISIBLE); | ||||||
|  |  | ||||||
|  |                 } | ||||||
|  |                 else if(response.code() == 401) { | ||||||
|  |  | ||||||
|  |                     AlertDialogs.authorizationTokenRevokedDialog(ctx, ctx.getResources().getString(R.string.alertDialogTokenRevokedTitle), | ||||||
|  |                             ctx.getResources().getString(R.string.alertDialogTokenRevokedMessage), | ||||||
|  |                             ctx.getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton), | ||||||
|  |                             ctx.getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton)); | ||||||
|  |  | ||||||
|  |                 } | ||||||
|  |                 else { | ||||||
|  |  | ||||||
|  |                     Toasty.info(ctx, ctx.getString(R.string.issueUnsubscribtionError)); | ||||||
|  |  | ||||||
|  |                 } | ||||||
|  |  | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |             @Override | ||||||
|  |             public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) { | ||||||
|  |                 Toasty.info(ctx, ctx.getString(R.string.issueUnsubscribtionError)); | ||||||
|  |             } | ||||||
|  |         }); | ||||||
|  |     } | ||||||
|  |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -20,10 +20,16 @@ import org.mian.gitnex.activities.RepoDetailActivity; | |||||||
| import org.mian.gitnex.activities.RepoStargazersActivity; | import org.mian.gitnex.activities.RepoStargazersActivity; | ||||||
| import org.mian.gitnex.activities.RepoWatchersActivity; | import org.mian.gitnex.activities.RepoWatchersActivity; | ||||||
| import org.mian.gitnex.clients.PicassoService; | import org.mian.gitnex.clients.PicassoService; | ||||||
|  | import org.mian.gitnex.clients.RetrofitClient; | ||||||
|  | import org.mian.gitnex.helpers.AlertDialogs; | ||||||
| import org.mian.gitnex.helpers.RoundedTransformation; | import org.mian.gitnex.helpers.RoundedTransformation; | ||||||
|  | import org.mian.gitnex.helpers.Toasty; | ||||||
| import org.mian.gitnex.models.UserRepositories; | import org.mian.gitnex.models.UserRepositories; | ||||||
|  | import org.mian.gitnex.models.WatchRepository; | ||||||
| import org.mian.gitnex.util.TinyDB; | import org.mian.gitnex.util.TinyDB; | ||||||
| import java.util.List; | import java.util.List; | ||||||
|  | import retrofit2.Call; | ||||||
|  | import retrofit2.Callback; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Author M M Arif |  * Author M M Arif | ||||||
| @@ -75,6 +81,50 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo | |||||||
|                 TinyDB tinyDb = new TinyDB(context); |                 TinyDB tinyDb = new TinyDB(context); | ||||||
|                 tinyDb.putString("repoFullName", repoFullName.getText().toString()); |                 tinyDb.putString("repoFullName", repoFullName.getText().toString()); | ||||||
|                 tinyDb.putBoolean("resumeIssues", true); |                 tinyDb.putBoolean("resumeIssues", true); | ||||||
|  |  | ||||||
|  |                 //store if user is watching this repo | ||||||
|  |                 { | ||||||
|  |                     final String instanceUrl = tinyDb.getString("instanceUrl"); | ||||||
|  |                     String[] parts = repoFullName.getText().toString().split("/"); | ||||||
|  |                     final String repoOwner = parts[0]; | ||||||
|  |                     final String repoName = parts[1]; | ||||||
|  |                     final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token"); | ||||||
|  |  | ||||||
|  |                     WatchRepository watch = new WatchRepository(); | ||||||
|  |  | ||||||
|  |                     Call<WatchRepository> call; | ||||||
|  |  | ||||||
|  |                     call = RetrofitClient.getInstance(instanceUrl, context).getApiInterface().checkRepoWatchStatus(token, repoOwner, repoName); | ||||||
|  |  | ||||||
|  |                     call.enqueue(new Callback<WatchRepository>() { | ||||||
|  |  | ||||||
|  |                         @Override | ||||||
|  |                         public void onResponse(@NonNull Call<WatchRepository> call, @NonNull retrofit2.Response<WatchRepository> response) { | ||||||
|  |  | ||||||
|  |                             if(response.isSuccessful()) { | ||||||
|  |  | ||||||
|  |                                 tinyDb.putBoolean("repoWatch", response.body().getSubscribed()); | ||||||
|  |  | ||||||
|  |                             } | ||||||
|  |                             else { | ||||||
|  |  | ||||||
|  |                                 tinyDb.putBoolean("repoWatch", false); | ||||||
|  |                                 Toasty.info(context, context.getString(R.string.genericApiStatusError)); | ||||||
|  |  | ||||||
|  |                             } | ||||||
|  |  | ||||||
|  |                         } | ||||||
|  |  | ||||||
|  |                         @Override | ||||||
|  |                         public void onFailure(@NonNull Call<WatchRepository> call, @NonNull Throwable t) { | ||||||
|  |  | ||||||
|  |                             tinyDb.putBoolean("repoWatch", false); | ||||||
|  |                             Toasty.info(context, context.getString(R.string.genericApiStatusError)); | ||||||
|  |  | ||||||
|  |                         } | ||||||
|  |                     }); | ||||||
|  |                 } | ||||||
|  |  | ||||||
|                 context.startActivity(intent); |                 context.startActivity(intent); | ||||||
|  |  | ||||||
|             }); |             }); | ||||||
|   | |||||||
| @@ -20,13 +20,18 @@ import org.mian.gitnex.activities.RepoDetailActivity; | |||||||
| import org.mian.gitnex.activities.RepoStargazersActivity; | import org.mian.gitnex.activities.RepoStargazersActivity; | ||||||
| import org.mian.gitnex.activities.RepoWatchersActivity; | import org.mian.gitnex.activities.RepoWatchersActivity; | ||||||
| import org.mian.gitnex.clients.PicassoService; | import org.mian.gitnex.clients.PicassoService; | ||||||
|  | import org.mian.gitnex.clients.RetrofitClient; | ||||||
| import org.mian.gitnex.helpers.RoundedTransformation; | import org.mian.gitnex.helpers.RoundedTransformation; | ||||||
|  | import org.mian.gitnex.helpers.Toasty; | ||||||
| import org.mian.gitnex.models.UserRepositories; | import org.mian.gitnex.models.UserRepositories; | ||||||
|  | import org.mian.gitnex.models.WatchRepository; | ||||||
| import org.mian.gitnex.util.TinyDB; | import org.mian.gitnex.util.TinyDB; | ||||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||||
| import java.util.List; | import java.util.List; | ||||||
| import androidx.annotation.NonNull; | import androidx.annotation.NonNull; | ||||||
| import androidx.recyclerview.widget.RecyclerView; | import androidx.recyclerview.widget.RecyclerView; | ||||||
|  | import retrofit2.Call; | ||||||
|  | import retrofit2.Callback; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Author M M Arif |  * Author M M Arif | ||||||
| @@ -74,6 +79,50 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter. | |||||||
|                 tinyDb.putString("repoFullName", fullNameMy.getText().toString()); |                 tinyDb.putString("repoFullName", fullNameMy.getText().toString()); | ||||||
|                 tinyDb.putString("repoType", repoType.getText().toString()); |                 tinyDb.putString("repoType", repoType.getText().toString()); | ||||||
|                 tinyDb.putBoolean("resumeIssues", true); |                 tinyDb.putBoolean("resumeIssues", true); | ||||||
|  |  | ||||||
|  |                 //store if user is watching this repo | ||||||
|  |                 { | ||||||
|  |                     final String instanceUrl = tinyDb.getString("instanceUrl"); | ||||||
|  |                     String[] parts = fullNameMy.getText().toString().split("/"); | ||||||
|  |                     final String repoOwner = parts[0]; | ||||||
|  |                     final String repoName = parts[1]; | ||||||
|  |                     final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token"); | ||||||
|  |  | ||||||
|  |                     WatchRepository watch = new WatchRepository(); | ||||||
|  |  | ||||||
|  |                     Call<WatchRepository> call; | ||||||
|  |  | ||||||
|  |                     call = RetrofitClient.getInstance(instanceUrl, context).getApiInterface().checkRepoWatchStatus(token, repoOwner, repoName); | ||||||
|  |  | ||||||
|  |                     call.enqueue(new Callback<WatchRepository>() { | ||||||
|  |  | ||||||
|  |                         @Override | ||||||
|  |                         public void onResponse(@NonNull Call<WatchRepository> call, @NonNull retrofit2.Response<WatchRepository> response) { | ||||||
|  |  | ||||||
|  |                             if(response.isSuccessful()) { | ||||||
|  |  | ||||||
|  |                                 tinyDb.putBoolean("repoWatch", response.body().getSubscribed()); | ||||||
|  |  | ||||||
|  |                             } | ||||||
|  |                             else { | ||||||
|  |  | ||||||
|  |                                 tinyDb.putBoolean("repoWatch", false); | ||||||
|  |                                 Toasty.info(context, context.getString(R.string.genericApiStatusError)); | ||||||
|  |  | ||||||
|  |                             } | ||||||
|  |  | ||||||
|  |                         } | ||||||
|  |  | ||||||
|  |                         @Override | ||||||
|  |                         public void onFailure(@NonNull Call<WatchRepository> call, @NonNull Throwable t) { | ||||||
|  |  | ||||||
|  |                             tinyDb.putBoolean("repoWatch", false); | ||||||
|  |                             Toasty.info(context, context.getString(R.string.genericApiStatusError)); | ||||||
|  |  | ||||||
|  |                         } | ||||||
|  |                     }); | ||||||
|  |                 } | ||||||
|  |  | ||||||
|                 context.startActivity(intent); |                 context.startActivity(intent); | ||||||
|  |  | ||||||
|             }); |             }); | ||||||
|   | |||||||
| @@ -22,11 +22,16 @@ import org.mian.gitnex.activities.RepoDetailActivity; | |||||||
| import org.mian.gitnex.activities.RepoStargazersActivity; | import org.mian.gitnex.activities.RepoStargazersActivity; | ||||||
| import org.mian.gitnex.activities.RepoWatchersActivity; | import org.mian.gitnex.activities.RepoWatchersActivity; | ||||||
| import org.mian.gitnex.clients.PicassoService; | import org.mian.gitnex.clients.PicassoService; | ||||||
|  | import org.mian.gitnex.clients.RetrofitClient; | ||||||
| import org.mian.gitnex.helpers.RoundedTransformation; | import org.mian.gitnex.helpers.RoundedTransformation; | ||||||
|  | import org.mian.gitnex.helpers.Toasty; | ||||||
| import org.mian.gitnex.models.UserRepositories; | import org.mian.gitnex.models.UserRepositories; | ||||||
|  | import org.mian.gitnex.models.WatchRepository; | ||||||
| import org.mian.gitnex.util.TinyDB; | import org.mian.gitnex.util.TinyDB; | ||||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||||
| import java.util.List; | import java.util.List; | ||||||
|  | import retrofit2.Call; | ||||||
|  | import retrofit2.Callback; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Author M M Arif |  * Author M M Arif | ||||||
| @@ -77,6 +82,50 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo | |||||||
|                 tinyDb.putString("repoFullName", repoFullName.getText().toString()); |                 tinyDb.putString("repoFullName", repoFullName.getText().toString()); | ||||||
|                 tinyDb.putString("repoType", repoType_.getText().toString()); |                 tinyDb.putString("repoType", repoType_.getText().toString()); | ||||||
|                 tinyDb.putBoolean("resumeIssues", true); |                 tinyDb.putBoolean("resumeIssues", true); | ||||||
|  |  | ||||||
|  |                 //store if user is watching this repo | ||||||
|  |                 { | ||||||
|  |                     final String instanceUrl = tinyDb.getString("instanceUrl"); | ||||||
|  |                     String[] parts = repoFullName.getText().toString().split("/"); | ||||||
|  |                     final String repoOwner = parts[0]; | ||||||
|  |                     final String repoName = parts[1]; | ||||||
|  |                     final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token"); | ||||||
|  |  | ||||||
|  |                     WatchRepository watch = new WatchRepository(); | ||||||
|  |  | ||||||
|  |                     Call<WatchRepository> call; | ||||||
|  |  | ||||||
|  |                     call = RetrofitClient.getInstance(instanceUrl, context).getApiInterface().checkRepoWatchStatus(token, repoOwner, repoName); | ||||||
|  |  | ||||||
|  |                     call.enqueue(new Callback<WatchRepository>() { | ||||||
|  |  | ||||||
|  |                         @Override | ||||||
|  |                         public void onResponse(@NonNull Call<WatchRepository> call, @NonNull retrofit2.Response<WatchRepository> response) { | ||||||
|  |  | ||||||
|  |                             if(response.isSuccessful()) { | ||||||
|  |  | ||||||
|  |                                 tinyDb.putBoolean("repoWatch", response.body().getSubscribed()); | ||||||
|  |  | ||||||
|  |                             } | ||||||
|  |                             else { | ||||||
|  |  | ||||||
|  |                                 tinyDb.putBoolean("repoWatch", false); | ||||||
|  |                                 Toasty.info(context, context.getString(R.string.genericApiStatusError)); | ||||||
|  |  | ||||||
|  |                             } | ||||||
|  |  | ||||||
|  |                         } | ||||||
|  |  | ||||||
|  |                         @Override | ||||||
|  |                         public void onFailure(@NonNull Call<WatchRepository> call, @NonNull Throwable t) { | ||||||
|  |  | ||||||
|  |                             tinyDb.putBoolean("repoWatch", false); | ||||||
|  |                             Toasty.info(context, context.getString(R.string.genericApiStatusError)); | ||||||
|  |  | ||||||
|  |                         } | ||||||
|  |                     }); | ||||||
|  |                 } | ||||||
|  |  | ||||||
|                 context.startActivity(intent); |                 context.startActivity(intent); | ||||||
|  |  | ||||||
|             }); |             }); | ||||||
|   | |||||||
| @@ -20,13 +20,18 @@ import org.mian.gitnex.activities.RepoDetailActivity; | |||||||
| import org.mian.gitnex.activities.RepoStargazersActivity; | import org.mian.gitnex.activities.RepoStargazersActivity; | ||||||
| import org.mian.gitnex.activities.RepoWatchersActivity; | import org.mian.gitnex.activities.RepoWatchersActivity; | ||||||
| import org.mian.gitnex.clients.PicassoService; | import org.mian.gitnex.clients.PicassoService; | ||||||
|  | import org.mian.gitnex.clients.RetrofitClient; | ||||||
| import org.mian.gitnex.helpers.RoundedTransformation; | import org.mian.gitnex.helpers.RoundedTransformation; | ||||||
|  | import org.mian.gitnex.helpers.Toasty; | ||||||
| import org.mian.gitnex.models.UserRepositories; | import org.mian.gitnex.models.UserRepositories; | ||||||
|  | import org.mian.gitnex.models.WatchRepository; | ||||||
| import org.mian.gitnex.util.TinyDB; | import org.mian.gitnex.util.TinyDB; | ||||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||||
| import java.util.List; | import java.util.List; | ||||||
| import androidx.annotation.NonNull; | import androidx.annotation.NonNull; | ||||||
| import androidx.recyclerview.widget.RecyclerView; | import androidx.recyclerview.widget.RecyclerView; | ||||||
|  | import retrofit2.Call; | ||||||
|  | import retrofit2.Callback; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Author M M Arif |  * Author M M Arif | ||||||
| @@ -74,8 +79,51 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB | |||||||
|                 tinyDb.putString("repoFullName", fullName.getText().toString()); |                 tinyDb.putString("repoFullName", fullName.getText().toString()); | ||||||
|                 tinyDb.putString("repoType", repoType.getText().toString()); |                 tinyDb.putString("repoType", repoType.getText().toString()); | ||||||
|                 tinyDb.putBoolean("resumeIssues", true); |                 tinyDb.putBoolean("resumeIssues", true); | ||||||
|                 context.startActivity(intent); |  | ||||||
|  |  | ||||||
|  |                 //store if user is watching this repo | ||||||
|  |                 { | ||||||
|  |                     final String instanceUrl = tinyDb.getString("instanceUrl"); | ||||||
|  |                     String[] parts = fullName.getText().toString().split("/"); | ||||||
|  |                     final String repoOwner = parts[0]; | ||||||
|  |                     final String repoName = parts[1]; | ||||||
|  |                     final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token"); | ||||||
|  |  | ||||||
|  |                     WatchRepository watch = new WatchRepository(); | ||||||
|  |  | ||||||
|  |                     Call<WatchRepository> call; | ||||||
|  |  | ||||||
|  |                     call = RetrofitClient.getInstance(instanceUrl, context).getApiInterface().checkRepoWatchStatus(token, repoOwner, repoName); | ||||||
|  |  | ||||||
|  |                     call.enqueue(new Callback<WatchRepository>() { | ||||||
|  |  | ||||||
|  |                         @Override | ||||||
|  |                         public void onResponse(@NonNull Call<WatchRepository> call, @NonNull retrofit2.Response<WatchRepository> response) { | ||||||
|  |  | ||||||
|  |                             if(response.isSuccessful()) { | ||||||
|  |  | ||||||
|  |                                 tinyDb.putBoolean("repoWatch", response.body().getSubscribed()); | ||||||
|  |  | ||||||
|  |                             } | ||||||
|  |                             else { | ||||||
|  |  | ||||||
|  |                                 tinyDb.putBoolean("repoWatch", false); | ||||||
|  |                                 Toasty.info(context, context.getString(R.string.genericApiStatusError)); | ||||||
|  |  | ||||||
|  |                             } | ||||||
|  |  | ||||||
|  |                         } | ||||||
|  |  | ||||||
|  |                         @Override | ||||||
|  |                         public void onFailure(@NonNull Call<WatchRepository> call, @NonNull Throwable t) { | ||||||
|  |  | ||||||
|  |                             tinyDb.putBoolean("repoWatch", false); | ||||||
|  |                             Toasty.info(context, context.getString(R.string.genericApiStatusError)); | ||||||
|  |  | ||||||
|  |                         } | ||||||
|  |                     }); | ||||||
|  |                 } | ||||||
|  |  | ||||||
|  |                 context.startActivity(intent); | ||||||
|             }); |             }); | ||||||
|  |  | ||||||
|             reposDropdownMenu.setOnClickListener(v -> { |             reposDropdownMenu.setOnClickListener(v -> { | ||||||
|   | |||||||
| @@ -20,13 +20,18 @@ import org.mian.gitnex.activities.RepoDetailActivity; | |||||||
| import org.mian.gitnex.activities.RepoStargazersActivity; | import org.mian.gitnex.activities.RepoStargazersActivity; | ||||||
| import org.mian.gitnex.activities.RepoWatchersActivity; | import org.mian.gitnex.activities.RepoWatchersActivity; | ||||||
| import org.mian.gitnex.clients.PicassoService; | import org.mian.gitnex.clients.PicassoService; | ||||||
|  | import org.mian.gitnex.clients.RetrofitClient; | ||||||
| import org.mian.gitnex.helpers.RoundedTransformation; | import org.mian.gitnex.helpers.RoundedTransformation; | ||||||
|  | import org.mian.gitnex.helpers.Toasty; | ||||||
| import org.mian.gitnex.models.UserRepositories; | import org.mian.gitnex.models.UserRepositories; | ||||||
|  | import org.mian.gitnex.models.WatchRepository; | ||||||
| import org.mian.gitnex.util.TinyDB; | import org.mian.gitnex.util.TinyDB; | ||||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||||
| import java.util.List; | import java.util.List; | ||||||
| import androidx.annotation.NonNull; | import androidx.annotation.NonNull; | ||||||
| import androidx.recyclerview.widget.RecyclerView; | import androidx.recyclerview.widget.RecyclerView; | ||||||
|  | import retrofit2.Call; | ||||||
|  | import retrofit2.Callback; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Author M M Arif |  * Author M M Arif | ||||||
| @@ -74,6 +79,50 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi | |||||||
|                 tinyDb.putString("repoFullName", fullName.getText().toString()); |                 tinyDb.putString("repoFullName", fullName.getText().toString()); | ||||||
|                 tinyDb.putString("repoType", repoType.getText().toString()); |                 tinyDb.putString("repoType", repoType.getText().toString()); | ||||||
|                 tinyDb.putBoolean("resumeIssues", true); |                 tinyDb.putBoolean("resumeIssues", true); | ||||||
|  |  | ||||||
|  |                 //store if user is watching this repo | ||||||
|  |                 { | ||||||
|  |                     final String instanceUrl = tinyDb.getString("instanceUrl"); | ||||||
|  |                     String[] parts = fullName.getText().toString().split("/"); | ||||||
|  |                     final String repoOwner = parts[0]; | ||||||
|  |                     final String repoName = parts[1]; | ||||||
|  |                     final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token"); | ||||||
|  |  | ||||||
|  |                     WatchRepository watch = new WatchRepository(); | ||||||
|  |  | ||||||
|  |                     Call<WatchRepository> call; | ||||||
|  |  | ||||||
|  |                     call = RetrofitClient.getInstance(instanceUrl, context).getApiInterface().checkRepoWatchStatus(token, repoOwner, repoName); | ||||||
|  |  | ||||||
|  |                     call.enqueue(new Callback<WatchRepository>() { | ||||||
|  |  | ||||||
|  |                         @Override | ||||||
|  |                         public void onResponse(@NonNull Call<WatchRepository> call, @NonNull retrofit2.Response<WatchRepository> response) { | ||||||
|  |  | ||||||
|  |                             if(response.isSuccessful()) { | ||||||
|  |  | ||||||
|  |                                 tinyDb.putBoolean("repoWatch", response.body().getSubscribed()); | ||||||
|  |  | ||||||
|  |                             } | ||||||
|  |                             else { | ||||||
|  |  | ||||||
|  |                                 tinyDb.putBoolean("repoWatch", false); | ||||||
|  |                                 Toasty.info(context, context.getString(R.string.genericApiStatusError)); | ||||||
|  |  | ||||||
|  |                             } | ||||||
|  |  | ||||||
|  |                         } | ||||||
|  |  | ||||||
|  |                         @Override | ||||||
|  |                         public void onFailure(@NonNull Call<WatchRepository> call, @NonNull Throwable t) { | ||||||
|  |  | ||||||
|  |                             tinyDb.putBoolean("repoWatch", false); | ||||||
|  |                             Toasty.info(context, context.getString(R.string.genericApiStatusError)); | ||||||
|  |  | ||||||
|  |                         } | ||||||
|  |                     }); | ||||||
|  |                 } | ||||||
|  |  | ||||||
|                 context.startActivity(intent); |                 context.startActivity(intent); | ||||||
|  |  | ||||||
|             }); |             }); | ||||||
|   | |||||||
| @@ -1,5 +1,6 @@ | |||||||
| package org.mian.gitnex.fragments; | package org.mian.gitnex.fragments; | ||||||
|  |  | ||||||
|  | import android.content.Context; | ||||||
| import android.content.Intent; | import android.content.Intent; | ||||||
| import android.os.Bundle; | import android.os.Bundle; | ||||||
| import android.view.LayoutInflater; | import android.view.LayoutInflater; | ||||||
| @@ -15,6 +16,8 @@ import org.mian.gitnex.activities.EditIssueActivity; | |||||||
| import org.mian.gitnex.activities.FileDiffActivity; | import org.mian.gitnex.activities.FileDiffActivity; | ||||||
| import org.mian.gitnex.activities.MergePullRequestActivity; | import org.mian.gitnex.activities.MergePullRequestActivity; | ||||||
| import org.mian.gitnex.activities.ReplyToIssueActivity; | import org.mian.gitnex.activities.ReplyToIssueActivity; | ||||||
|  | import org.mian.gitnex.clients.RetrofitClient; | ||||||
|  | import org.mian.gitnex.helpers.AlertDialogs; | ||||||
| import org.mian.gitnex.helpers.Toasty; | import org.mian.gitnex.helpers.Toasty; | ||||||
| import org.mian.gitnex.util.TinyDB; | import org.mian.gitnex.util.TinyDB; | ||||||
| import androidx.annotation.NonNull; | import androidx.annotation.NonNull; | ||||||
| @@ -22,6 +25,8 @@ import androidx.annotation.Nullable; | |||||||
| import android.content.ClipboardManager; | import android.content.ClipboardManager; | ||||||
| import android.content.ClipData; | import android.content.ClipData; | ||||||
| import java.util.Objects; | import java.util.Objects; | ||||||
|  | import retrofit2.Call; | ||||||
|  | import retrofit2.Callback; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Author M M Arif |  * Author M M Arif | ||||||
| @@ -35,7 +40,8 @@ public class BottomSheetSingleIssueFragment extends BottomSheetDialogFragment { | |||||||
|  |  | ||||||
|         View v = inflater.inflate(R.layout.bottom_sheet_single_issue_layout, container, false); |         View v = inflater.inflate(R.layout.bottom_sheet_single_issue_layout, container, false); | ||||||
|  |  | ||||||
|         final TinyDB tinyDB = new TinyDB(getContext()); |         final Context ctx = getContext(); | ||||||
|  |         final TinyDB tinyDB = new TinyDB(ctx); | ||||||
|  |  | ||||||
|         TextView replyToIssue = v.findViewById(R.id.replyToIssue); |         TextView replyToIssue = v.findViewById(R.id.replyToIssue); | ||||||
|         TextView editIssue = v.findViewById(R.id.editIssue); |         TextView editIssue = v.findViewById(R.id.editIssue); | ||||||
| @@ -47,12 +53,14 @@ public class BottomSheetSingleIssueFragment extends BottomSheetDialogFragment { | |||||||
|         TextView openFilesDiff = v.findViewById(R.id.openFilesDiff); |         TextView openFilesDiff = v.findViewById(R.id.openFilesDiff); | ||||||
|         TextView mergePullRequest = v.findViewById(R.id.mergePullRequest); |         TextView mergePullRequest = v.findViewById(R.id.mergePullRequest); | ||||||
|         TextView shareIssue = v.findViewById(R.id.shareIssue); |         TextView shareIssue = v.findViewById(R.id.shareIssue); | ||||||
|  |         TextView subscribeIssue = v.findViewById(R.id.subscribeIssue); | ||||||
|  |         TextView unsubscribeIssue = v.findViewById(R.id.unsubscribeIssue); | ||||||
|  |  | ||||||
|         replyToIssue.setOnClickListener(new View.OnClickListener() { |         replyToIssue.setOnClickListener(new View.OnClickListener() { | ||||||
|             @Override |             @Override | ||||||
|             public void onClick(View v) { |             public void onClick(View v) { | ||||||
|  |  | ||||||
|                 startActivity(new Intent(getContext(), ReplyToIssueActivity.class)); |                 startActivity(new Intent(ctx, ReplyToIssueActivity.class)); | ||||||
|                 dismiss(); |                 dismiss(); | ||||||
|  |  | ||||||
|             } |             } | ||||||
| @@ -89,7 +97,7 @@ public class BottomSheetSingleIssueFragment extends BottomSheetDialogFragment { | |||||||
|             @Override |             @Override | ||||||
|             public void onClick(View v) { |             public void onClick(View v) { | ||||||
|  |  | ||||||
|                 startActivity(new Intent(getContext(), MergePullRequestActivity.class)); |                 startActivity(new Intent(ctx, MergePullRequestActivity.class)); | ||||||
|                 dismiss(); |                 dismiss(); | ||||||
|  |  | ||||||
|             } |             } | ||||||
| @@ -99,7 +107,7 @@ public class BottomSheetSingleIssueFragment extends BottomSheetDialogFragment { | |||||||
|             @Override |             @Override | ||||||
|             public void onClick(View v) { |             public void onClick(View v) { | ||||||
|  |  | ||||||
|                 startActivity(new Intent(getContext(), FileDiffActivity.class)); |                 startActivity(new Intent(ctx, FileDiffActivity.class)); | ||||||
|                 dismiss(); |                 dismiss(); | ||||||
|  |  | ||||||
|             } |             } | ||||||
| @@ -109,7 +117,7 @@ public class BottomSheetSingleIssueFragment extends BottomSheetDialogFragment { | |||||||
|             @Override |             @Override | ||||||
|             public void onClick(View v) { |             public void onClick(View v) { | ||||||
|  |  | ||||||
|                 startActivity(new Intent(getContext(), EditIssueActivity.class)); |                 startActivity(new Intent(ctx, EditIssueActivity.class)); | ||||||
|                 dismiss(); |                 dismiss(); | ||||||
|  |  | ||||||
|             } |             } | ||||||
| @@ -119,7 +127,7 @@ public class BottomSheetSingleIssueFragment extends BottomSheetDialogFragment { | |||||||
|             @Override |             @Override | ||||||
|             public void onClick(View v) { |             public void onClick(View v) { | ||||||
|  |  | ||||||
|                 startActivity(new Intent(getContext(), AddRemoveLabelsActivity.class)); |                 startActivity(new Intent(ctx, AddRemoveLabelsActivity.class)); | ||||||
|                 dismiss(); |                 dismiss(); | ||||||
|  |  | ||||||
|             } |             } | ||||||
| @@ -129,7 +137,7 @@ public class BottomSheetSingleIssueFragment extends BottomSheetDialogFragment { | |||||||
|             @Override |             @Override | ||||||
|             public void onClick(View v) { |             public void onClick(View v) { | ||||||
|  |  | ||||||
|                 startActivity(new Intent(getContext(), AddRemoveAssigneesActivity.class)); |                 startActivity(new Intent(ctx, AddRemoveAssigneesActivity.class)); | ||||||
|                 dismiss(); |                 dismiss(); | ||||||
|  |  | ||||||
|             } |             } | ||||||
| @@ -173,14 +181,14 @@ public class BottomSheetSingleIssueFragment extends BottomSheetDialogFragment { | |||||||
|                 String issueUrl = instanceUrlWithProtocol + "/" + repoFullName + "/issues/" + tinyDB.getString("issueNumber"); |                 String issueUrl = instanceUrlWithProtocol + "/" + repoFullName + "/issues/" + tinyDB.getString("issueNumber"); | ||||||
|  |  | ||||||
|                 // copy to clipboard |                 // copy to clipboard | ||||||
|                 ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(getContext()).getSystemService(android.content.Context.CLIPBOARD_SERVICE); |                 ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(ctx).getSystemService(android.content.Context.CLIPBOARD_SERVICE); | ||||||
|                 ClipData clip = ClipData.newPlainText("issueUrl", issueUrl); |                 ClipData clip = ClipData.newPlainText("issueUrl", issueUrl); | ||||||
|                 assert clipboard != null; |                 assert clipboard != null; | ||||||
|                 clipboard.setPrimaryClip(clip); |                 clipboard.setPrimaryClip(clip); | ||||||
|  |  | ||||||
|                 dismiss(); |                 dismiss(); | ||||||
|  |  | ||||||
|                 Toasty.info(getContext(), getContext().getString(R.string.copyIssueUrlToastMsg)); |                 Toasty.info(ctx, ctx.getString(R.string.copyIssueUrlToastMsg)); | ||||||
|  |  | ||||||
|             } |             } | ||||||
|         }); |         }); | ||||||
| @@ -195,7 +203,7 @@ public class BottomSheetSingleIssueFragment extends BottomSheetDialogFragment { | |||||||
|                     @Override |                     @Override | ||||||
|                     public void onClick(View v) { |                     public void onClick(View v) { | ||||||
|  |  | ||||||
|                         IssueActions.closeReopenIssue(getContext(), Integer.parseInt(tinyDB.getString("issueNumber")), "closed"); |                         IssueActions.closeReopenIssue(ctx, Integer.parseInt(tinyDB.getString("issueNumber")), "closed"); | ||||||
|                         dismiss(); |                         dismiss(); | ||||||
|  |  | ||||||
|                     } |                     } | ||||||
| @@ -210,7 +218,7 @@ public class BottomSheetSingleIssueFragment extends BottomSheetDialogFragment { | |||||||
|                     @Override |                     @Override | ||||||
|                     public void onClick(View v) { |                     public void onClick(View v) { | ||||||
|  |  | ||||||
|                         IssueActions.closeReopenIssue(getContext(), Integer.parseInt(tinyDB.getString("issueNumber")), "open"); |                         IssueActions.closeReopenIssue(ctx, Integer.parseInt(tinyDB.getString("issueNumber")), "open"); | ||||||
|                         dismiss(); |                         dismiss(); | ||||||
|  |  | ||||||
|                     } |                     } | ||||||
| @@ -226,6 +234,31 @@ public class BottomSheetSingleIssueFragment extends BottomSheetDialogFragment { | |||||||
|  |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         subscribeIssue.setOnClickListener(new View.OnClickListener() { | ||||||
|  |             @Override | ||||||
|  |             public void onClick(View v) { | ||||||
|  |  | ||||||
|  |                 IssueActions.subscribe(ctx, subscribeIssue, unsubscribeIssue); | ||||||
|  |  | ||||||
|  |             } | ||||||
|  |         }); | ||||||
|  |  | ||||||
|  |         unsubscribeIssue.setOnClickListener(new View.OnClickListener() { | ||||||
|  |             @Override | ||||||
|  |             public void onClick(View v) { | ||||||
|  |  | ||||||
|  |                 IssueActions.unsubscribe(ctx, subscribeIssue, unsubscribeIssue); | ||||||
|  |  | ||||||
|  |             } | ||||||
|  |         }); | ||||||
|  |  | ||||||
|  |         //if RepoWatch True Provide Unsubscribe first | ||||||
|  |         // ToDo: API to check if user is subscribed to an issue (do not exist can be guessed by many api endpoints :/) | ||||||
|  |         if (tinyDB.getBoolean("repoWatch")) { | ||||||
|  |             subscribeIssue.setVisibility(View.GONE); | ||||||
|  |             unsubscribeIssue.setVisibility(View.VISIBLE); | ||||||
|  |         } | ||||||
|  |  | ||||||
|         return v; |         return v; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -252,6 +252,12 @@ public interface ApiInterface { | |||||||
|     @DELETE("repos/{owner}/{repo}/subscription") // un watch a repository |     @DELETE("repos/{owner}/{repo}/subscription") // un watch a repository | ||||||
|     Call<JsonElement> unWatchRepository(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName); |     Call<JsonElement> unWatchRepository(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName); | ||||||
|  |  | ||||||
|  |     @PUT("repos/{owner}/{repo}/issues/{index}/subscriptions/{user}") // subscribe user to issue | ||||||
|  |     Call<Void> addIssueSubscriber(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName, @Path("index") int issueIndex, @Path("user") String issueSubscriber); | ||||||
|  |  | ||||||
|  |     @DELETE("repos/{owner}/{repo}/issues/{index}/subscriptions/{user}") // unsubscribe user to issue | ||||||
|  |     Call<Void> delIssueSubscriber(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName, @Path("index") int issueIndex, @Path("user") String issueSubscriber); | ||||||
|  |  | ||||||
|     @GET("repos/{owner}/{repo}/pulls") // get repository pull requests |     @GET("repos/{owner}/{repo}/pulls") // get repository pull requests | ||||||
|     Call<List<PullRequests>> getPullRequests(@Header("Authorization") String token, @Path("owner") String owner, @Path("repo") String repo, @Query("page") int page, @Query("state") String state, @Query("limit") int limit); |     Call<List<PullRequests>> getPullRequests(@Header("Authorization") String token, @Path("owner") String owner, @Path("repo") String repo, @Query("page") int page, @Query("state") String state, @Query("limit") int limit); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -90,6 +90,31 @@ | |||||||
|                 android:textSize="16sp" |                 android:textSize="16sp" | ||||||
|                 android:padding="16dp" /> |                 android:padding="16dp" /> | ||||||
|  |  | ||||||
|  |             <TextView | ||||||
|  |                 android:id="@+id/subscribeIssue" | ||||||
|  |                 android:layout_width="match_parent" | ||||||
|  |                 android:layout_height="wrap_content" | ||||||
|  |                 android:layout_gravity="center_vertical" | ||||||
|  |                 android:text="@string/singleIssueSubscribe" | ||||||
|  |                 android:drawableStart="@drawable/ic_watchers" | ||||||
|  |                 android:drawablePadding="24dp" | ||||||
|  |                 android:textColor="@color/white" | ||||||
|  |                 android:textSize="16sp" | ||||||
|  |                 android:padding="16dp" /> | ||||||
|  |  | ||||||
|  |             <TextView | ||||||
|  |                 android:id="@+id/unsubscribeIssue" | ||||||
|  |                 android:layout_width="match_parent" | ||||||
|  |                 android:layout_height="wrap_content" | ||||||
|  |                 android:layout_gravity="center_vertical" | ||||||
|  |                 android:drawableStart="@drawable/ic_unwatch" | ||||||
|  |                 android:drawablePadding="24dp" | ||||||
|  |                 android:padding="16dp" | ||||||
|  |                 android:text="@string/singleIssueUnSubscribe" | ||||||
|  |                 android:textColor="@color/white" | ||||||
|  |                 android:textSize="16sp" | ||||||
|  |                 android:visibility="gone" /> | ||||||
|  |  | ||||||
|             <View |             <View | ||||||
|                 android:layout_width="match_parent" |                 android:layout_width="match_parent" | ||||||
|                 android:layout_height="1dp" |                 android:layout_height="1dp" | ||||||
| @@ -152,7 +177,8 @@ | |||||||
|                 android:drawablePadding="24dp" |                 android:drawablePadding="24dp" | ||||||
|                 android:textColor="?attr/primaryTextColor" |                 android:textColor="?attr/primaryTextColor" | ||||||
|                 android:textSize="16sp" |                 android:textSize="16sp" | ||||||
|                 android:padding="16dp" /> |                 android:padding="16dp" | ||||||
|  |                 android:visibility="gone" /> | ||||||
|  |  | ||||||
|         </LinearLayout> |         </LinearLayout> | ||||||
|  |  | ||||||
|   | |||||||
| @@ -387,6 +387,8 @@ | |||||||
|     <string name="addRemoveAssignees2">Add Assignees</string> |     <string name="addRemoveAssignees2">Add Assignees</string> | ||||||
|     <string name="addRemoveAssignees">Add / Remove Assignees</string> |     <string name="addRemoveAssignees">Add / Remove Assignees</string> | ||||||
|     <string name="assigneesUpdated">Assignees updated</string> |     <string name="assigneesUpdated">Assignees updated</string> | ||||||
|  |     <string name="singleIssueSubscribe">Subscribe</string> | ||||||
|  |     <string name="singleIssueUnSubscribe">Unsubscribe</string> | ||||||
|     <!-- single issue section --> |     <!-- single issue section --> | ||||||
|  |  | ||||||
|     <!-- multi select dialog --> |     <!-- multi select dialog --> | ||||||
| @@ -591,4 +593,9 @@ | |||||||
|     <string name="mtm_decision_abort">Abort</string> |     <string name="mtm_decision_abort">Abort</string> | ||||||
|  |  | ||||||
|     <string name="issueCommentShare">Share Comment</string> |     <string name="issueCommentShare">Share Comment</string> | ||||||
|  |  | ||||||
|  |     <string name="issueSubscribtion">Issue Subscribed</string> | ||||||
|  |     <string name="issueSubscribtionError">Issue Subscription failed</string> | ||||||
|  |     <string name="issueUnsubscribtion">Issue Unsubscribed</string> | ||||||
|  |     <string name="issueUnsubscribtionError">Issue Un-Subscription failed</string> | ||||||
| </resources> | </resources> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user