mirror of
https://codeberg.org/gitnex/GitNex
synced 2025-03-12 17:40:11 +01:00
Don't use TinyDB as cache (#1034)
Do not use TinyDB as a cache or a way to send data between activities.
### How is this working
Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so).
Due to the size of the changes (after c9172f85ef
, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**.
Additional changes:
* after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account)
* repositories and organizations are clickable on user profiles
* deleted two unused classes
Once finished, hopefully
* closes #354
* replaces #897
* fixes #947
* closes #1001
* closes #1015
* marks #876 and #578 as `Wontfix` since they are not necessary at this point
* and all the other TinyDB issues
Co-authored-by: qwerty287 <ndev@web.de>
Co-authored-by: M M Arif <mmarif@noreply.codeberg.org>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034
Reviewed-by: 6543 <6543@noreply.codeberg.org>
Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org>
Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
This commit is contained in:
parent
ea30556844
commit
7e514041bb
@ -8,12 +8,12 @@ import androidx.annotation.NonNull;
|
||||
import org.gitnex.tea4j.models.Collaborators;
|
||||
import org.gitnex.tea4j.models.Issues;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.adapters.AssigneesListAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.CustomAssigneesSelectionDialogBinding;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.contexts.AccountContext;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
@ -28,7 +28,7 @@ public class AssigneesActions {
|
||||
|
||||
Call<Issues> callSingleIssueLabels = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.getIssueByIndex(Authorization.get(ctx), repoOwner, repoName, issueIndex);
|
||||
.getIssueByIndex(((BaseActivity) ctx).getAccount().getAuthorization(), repoOwner, repoName, issueIndex);
|
||||
|
||||
callSingleIssueLabels.enqueue(new Callback<Issues>() {
|
||||
|
||||
@ -64,11 +64,9 @@ public class AssigneesActions {
|
||||
|
||||
public static void getRepositoryAssignees(Context ctx, String repoOwner, String repoName, List<Collaborators> assigneesList, Dialog dialogAssignees, AssigneesListAdapter assigneesAdapter, CustomAssigneesSelectionDialogBinding assigneesBinding) {
|
||||
|
||||
TinyDB tinyDB = TinyDB.getInstance(ctx);
|
||||
|
||||
Call<List<Collaborators>> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.getCollaborators(Authorization.get(ctx), repoOwner, repoName);
|
||||
.getCollaborators(((BaseActivity) ctx).getAccount().getAuthorization(), repoOwner, repoName);
|
||||
|
||||
call.enqueue(new Callback<List<Collaborators>>() {
|
||||
|
||||
@ -87,7 +85,8 @@ public class AssigneesActions {
|
||||
|
||||
if(assigneesList_.size() > 0) {
|
||||
|
||||
assigneesList.add(new Collaborators(tinyDB.getString("userFullname"), tinyDB.getString("loginUid"), tinyDB.getString("userAvatar")));
|
||||
AccountContext userInfo = ((BaseActivity) ctx).getAccount();
|
||||
assigneesList.add(new Collaborators(userInfo.getFullName(), userInfo.getAccount().getUserName(), userInfo.getUserInfo().getAvatar()));
|
||||
assigneesList.addAll(assigneesList_);
|
||||
}
|
||||
else {
|
||||
|
@ -7,11 +7,12 @@ import org.gitnex.tea4j.models.Collaborators;
|
||||
import org.gitnex.tea4j.models.Permission;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.AddCollaboratorToRepositoryActivity;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.fragments.CollaboratorsFragment;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
@ -23,18 +24,11 @@ import retrofit2.Response;
|
||||
|
||||
public class CollaboratorActions {
|
||||
|
||||
public static void deleteCollaborator(final Context context, final String searchKeyword, String userName) {
|
||||
|
||||
final TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
public static void deleteCollaborator(final Context context, String userName, RepositoryContext repository) {
|
||||
|
||||
Call<Collaborators> call = RetrofitClient
|
||||
.getApiInterface(context)
|
||||
.deleteCollaborator(Authorization.get(context), repoOwner, repoName, userName);
|
||||
.deleteCollaborator(((BaseActivity) context).getAccount().getAuthorization(), repository.getOwner(), repository.getName(), userName);
|
||||
|
||||
call.enqueue(new Callback<Collaborators>() {
|
||||
|
||||
@ -44,10 +38,10 @@ public class CollaboratorActions {
|
||||
if(response.isSuccessful()) {
|
||||
if(response.code() == 204) {
|
||||
|
||||
CollaboratorsFragment.refreshCollaborators = true;
|
||||
Toasty.success(context, context.getString(R.string.removeCollaboratorToastText));
|
||||
((AddCollaboratorToRepositoryActivity)context).finish();
|
||||
//Log.i("addCollaboratorSearch", addCollaboratorSearch.getText().toString());
|
||||
//tinyDb.putBoolean("updateDataSet", true);
|
||||
//AddCollaboratorToRepositoryActivity usersSearchData = new AddCollaboratorToRepositoryActivity();
|
||||
//usersSearchData.loadUserSearchList(instanceToken, searchKeyword, context);
|
||||
|
||||
@ -87,20 +81,13 @@ public class CollaboratorActions {
|
||||
|
||||
}
|
||||
|
||||
public static void addCollaborator(final Context context, String permission, String userName) {
|
||||
|
||||
final TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
public static void addCollaborator(final Context context, String permission, String userName, RepositoryContext repository) {
|
||||
|
||||
Permission permissionString = new Permission(permission);
|
||||
|
||||
Call<Permission> call = RetrofitClient
|
||||
.getApiInterface(context)
|
||||
.addCollaborator(Authorization.get(context), repoOwner, repoName, userName, permissionString);
|
||||
.addCollaborator(((BaseActivity) context).getAccount().getAuthorization(), repository.getOwner(), repository.getName(), userName, permissionString);
|
||||
|
||||
call.enqueue(new Callback<Permission>() {
|
||||
|
||||
@ -110,6 +97,7 @@ public class CollaboratorActions {
|
||||
if(response.isSuccessful()) {
|
||||
if(response.code() == 204) {
|
||||
|
||||
CollaboratorsFragment.refreshCollaborators = true;
|
||||
Toasty.success(context, context.getString(R.string.addCollaboratorToastText));
|
||||
((AddCollaboratorToRepositoryActivity)context).finish();
|
||||
//AddCollaboratorToRepositoryActivity usersSearchData = new AddCollaboratorToRepositoryActivity();
|
||||
@ -152,19 +140,13 @@ public class CollaboratorActions {
|
||||
|
||||
}
|
||||
|
||||
public static ActionResult<List<Collaborators>> getCollaborators(Context context) {
|
||||
public static ActionResult<List<Collaborators>> getCollaborators(Context context, RepositoryContext repository) {
|
||||
|
||||
ActionResult<List<Collaborators>> actionResult = new ActionResult<>();
|
||||
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
String repoOwner = parts[0];
|
||||
String repoName = parts[1];
|
||||
|
||||
Call<List<Collaborators>> call = RetrofitClient
|
||||
.getApiInterface(context)
|
||||
.getCollaborators(Authorization.get(context), repoOwner, repoName);
|
||||
.getCollaborators(((BaseActivity) context).getAccount().getAuthorization(), repository.getOwner(), repository.getName());
|
||||
|
||||
call.enqueue(new Callback<List<Collaborators>>() {
|
||||
|
||||
|
@ -1,17 +1,22 @@
|
||||
package org.mian.gitnex.actions;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import com.google.gson.JsonElement;
|
||||
import org.gitnex.tea4j.models.IssueComments;
|
||||
import org.gitnex.tea4j.models.Issues;
|
||||
import org.gitnex.tea4j.models.UpdateIssueState;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.activities.IssueDetailActivity;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.fragments.IssuesFragment;
|
||||
import org.mian.gitnex.fragments.PullRequestsFragment;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.contexts.IssueContext;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
@ -22,21 +27,14 @@ import retrofit2.Response;
|
||||
|
||||
public class IssueActions {
|
||||
|
||||
public static ActionResult<Response<?>> edit(Context context, String comment, int commentId) {
|
||||
public static ActionResult<Response<?>> edit(Context context, String comment, int commentId, IssueContext issue) {
|
||||
|
||||
ActionResult<Response<?>> actionResult = new ActionResult<>();
|
||||
|
||||
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
|
||||
String repoOwner = parts[0];
|
||||
String repoName = parts[1];
|
||||
|
||||
Call<IssueComments> call = RetrofitClient
|
||||
.getApiInterface(context)
|
||||
.patchIssueComment(Authorization.get(context), repoOwner, repoName, commentId, new IssueComments(comment));
|
||||
.patchIssueComment(((BaseActivity) context).getAccount().getAuthorization(), issue.getRepository().getOwner(),
|
||||
issue.getRepository().getName(), commentId, new IssueComments(comment));
|
||||
|
||||
call.enqueue(new Callback<IssueComments>() {
|
||||
|
||||
@ -51,7 +49,8 @@ public class IssueActions {
|
||||
|
||||
case 401:
|
||||
actionResult.finish(ActionResult.Status.FAILED, response);
|
||||
AlertDialogs.authorizationTokenRevokedDialog(context, context.getResources().getString(R.string.alertDialogTokenRevokedTitle), context.getResources().getString(R.string.alertDialogTokenRevokedMessage), context.getResources().getString(R.string.cancelButton), context.getResources().getString(R.string.navLogout));
|
||||
AlertDialogs.authorizationTokenRevokedDialog(context, context.getResources().getString(R.string.alertDialogTokenRevokedTitle), context.getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||
context.getResources().getString(R.string.cancelButton), context.getResources().getString(R.string.navLogout));
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -72,22 +71,15 @@ public class IssueActions {
|
||||
|
||||
}
|
||||
|
||||
public static void closeReopenIssue(final Context ctx, final int issueIndex, final String issueState) {
|
||||
|
||||
final TinyDB tinyDb = TinyDB.getInstance(ctx);
|
||||
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
public static void closeReopenIssue(final Context ctx, final String issueState, IssueContext issue) {
|
||||
|
||||
UpdateIssueState issueStatJson = new UpdateIssueState(issueState);
|
||||
Call<JsonElement> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.closeReopenIssue(Authorization.get(ctx), repoOwner, repoName, issueIndex, issueStatJson);
|
||||
.closeReopenIssue(((BaseActivity) ctx).getAccount().getAuthorization(), issue.getRepository().getOwner(),
|
||||
issue.getRepository().getName(), issue.getIssueIndex(), issueStatJson);
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
|
||||
@ -97,22 +89,19 @@ public class IssueActions {
|
||||
if(response.isSuccessful()) {
|
||||
if(response.code() == 201) {
|
||||
|
||||
tinyDb.putBoolean("resumeIssues", true);
|
||||
tinyDb.putBoolean("resumeClosedIssues", true);
|
||||
|
||||
if (issue.hasIssue()) {
|
||||
IssuesFragment.resumeIssues = issue.getIssue().getPull_request() == null;
|
||||
PullRequestsFragment.resumePullRequests = issue.getIssue().getPull_request() != null;
|
||||
}
|
||||
if(issueState.equals("closed")) {
|
||||
|
||||
Toasty.success(ctx, ctx.getString(R.string.issueStateClosed));
|
||||
tinyDb.putString("issueState", "closed");
|
||||
|
||||
}
|
||||
else if(issueState.equals("open")) {
|
||||
|
||||
Toasty.success(ctx, ctx.getString(R.string.issueStateReopened));
|
||||
tinyDb.putString("issueState", "open");
|
||||
|
||||
}
|
||||
|
||||
((IssueDetailActivity) ctx).singleIssueUpdate = true;
|
||||
((IssueDetailActivity) ctx).onResume();
|
||||
}
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
@ -147,25 +136,14 @@ public class IssueActions {
|
||||
|
||||
}
|
||||
|
||||
public static void subscribe(final Context ctx) {
|
||||
|
||||
final TinyDB tinyDB = TinyDB.getInstance(ctx);
|
||||
|
||||
String[] repoFullName = tinyDB.getString("repoFullName").split("/");
|
||||
|
||||
if(repoFullName.length != 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
final String userLogin = tinyDB.getString("userLogin");
|
||||
final String token = "token " + tinyDB.getString(tinyDB.getString("loginUid") + "-token");
|
||||
final int issueNr = Integer.parseInt(tinyDB.getString("issueNumber"));
|
||||
public static void subscribe(final Context ctx, IssueContext issue) {
|
||||
|
||||
Call<Void> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.addIssueSubscriber(token, repoFullName[0], repoFullName[1], issueNr, userLogin);
|
||||
.addIssueSubscriber(((BaseActivity) ctx).getAccount().getAuthorization(), issue.getRepository().getOwner(),
|
||||
issue.getRepository().getName(), issue.getIssueIndex(), ((BaseActivity) ctx).getAccount().getAccount().getUserName());
|
||||
|
||||
call.enqueue(new Callback<Void>() {
|
||||
|
||||
@ -177,12 +155,10 @@ public class IssueActions {
|
||||
if(response.code() == 201) {
|
||||
|
||||
Toasty.success(ctx, ctx.getString(R.string.subscribedSuccessfully));
|
||||
tinyDB.putBoolean("issueSubscribed", true);
|
||||
|
||||
}
|
||||
else if(response.code() == 200) {
|
||||
|
||||
tinyDB.putBoolean("issueSubscribed", true);
|
||||
Toasty.success(ctx, ctx.getString(R.string.alreadySubscribed));
|
||||
|
||||
}
|
||||
@ -210,21 +186,12 @@ public class IssueActions {
|
||||
|
||||
}
|
||||
|
||||
public static void unsubscribe(final Context ctx) {
|
||||
|
||||
final TinyDB tinyDB = TinyDB.getInstance(ctx);
|
||||
|
||||
String[] repoFullName = tinyDB.getString("repoFullName").split("/");
|
||||
if(repoFullName.length != 2) {
|
||||
return;
|
||||
}
|
||||
final String userLogin = tinyDB.getString("userLogin");
|
||||
final String token = "token " + tinyDB.getString(tinyDB.getString("loginUid") + "-token");
|
||||
final int issueNr = Integer.parseInt(tinyDB.getString("issueNumber"));
|
||||
public static void unsubscribe(final Context ctx, IssueContext issue) {
|
||||
|
||||
Call<Void> call;
|
||||
|
||||
call = RetrofitClient.getApiInterface(ctx).delIssueSubscriber(token, repoFullName[0], repoFullName[1], issueNr, userLogin);
|
||||
call = RetrofitClient.getApiInterface(ctx).delIssueSubscriber(((BaseActivity) ctx).getAccount().getAuthorization(), issue.getRepository().getOwner(),
|
||||
issue.getRepository().getName(), issue.getIssueIndex(), ((BaseActivity) ctx).getAccount().getAccount().getUserName());
|
||||
|
||||
call.enqueue(new Callback<Void>() {
|
||||
|
||||
@ -236,12 +203,10 @@ public class IssueActions {
|
||||
if(response.code() == 201) {
|
||||
|
||||
Toasty.success(ctx, ctx.getString(R.string.unsubscribedSuccessfully));
|
||||
tinyDB.putBoolean("issueSubscribed", false);
|
||||
|
||||
}
|
||||
else if(response.code() == 200) {
|
||||
|
||||
tinyDB.putBoolean("issueSubscribed", false);
|
||||
Toasty.success(ctx, ctx.getString(R.string.alreadyUnsubscribed));
|
||||
|
||||
}
|
||||
@ -268,22 +233,16 @@ public class IssueActions {
|
||||
});
|
||||
}
|
||||
|
||||
public static ActionResult<ActionResult.None> reply(Context context, String comment, int issueIndex) {
|
||||
public static ActionResult<ActionResult.None> reply(Context context, String comment, IssueContext issue) {
|
||||
|
||||
ActionResult<ActionResult.None> actionResult = new ActionResult<>();
|
||||
|
||||
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
String repoOwner = parts[0];
|
||||
String repoName = parts[1];
|
||||
|
||||
Issues issueComment = new Issues(comment);
|
||||
|
||||
Call<Issues> call = RetrofitClient
|
||||
.getApiInterface(context)
|
||||
.replyCommentToIssue(Authorization.get(context), repoOwner, repoName, issueIndex, issueComment);
|
||||
.replyCommentToIssue(((BaseActivity) context).getAccount().getAuthorization(), issue.getRepository().getOwner(),
|
||||
issue.getRepository().getName(), issue.getIssueIndex(), issueComment);
|
||||
|
||||
call.enqueue(new Callback<Issues>() {
|
||||
|
||||
@ -291,13 +250,12 @@ public class IssueActions {
|
||||
public void onResponse(@NonNull Call<Issues> call, @NonNull retrofit2.Response<Issues> response) {
|
||||
|
||||
if(response.code() == 201) {
|
||||
|
||||
actionResult.finish(ActionResult.Status.SUCCESS);
|
||||
|
||||
tinyDb.putBoolean("commentPosted", true);
|
||||
tinyDb.putBoolean("resumeIssues", true);
|
||||
tinyDb.putBoolean("resumePullRequests", true);
|
||||
|
||||
if (issue.hasIssue()) {
|
||||
IssuesFragment.resumeIssues = issue.getIssue().getPull_request() == null;
|
||||
PullRequestsFragment.resumePullRequests = issue.getIssue().getPull_request() != null;
|
||||
}
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
|
@ -7,10 +7,10 @@ import android.view.View;
|
||||
import androidx.annotation.NonNull;
|
||||
import org.gitnex.tea4j.models.Labels;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.adapters.LabelsListAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.CustomLabelsSelectionDialogBinding;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
@ -26,7 +26,7 @@ public class LabelsActions {
|
||||
|
||||
Call<List<Labels>> callSingleIssueLabels = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.getIssueLabels(Authorization.get(ctx), repoOwner, repoName, issueIndex);
|
||||
.getIssueLabels(((BaseActivity) ctx).getAccount().getAuthorization(), repoOwner, repoName, issueIndex);
|
||||
|
||||
callSingleIssueLabels.enqueue(new Callback<List<Labels>>() {
|
||||
|
||||
@ -63,7 +63,7 @@ public class LabelsActions {
|
||||
|
||||
Call<List<Labels>> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.getLabels(Authorization.get(ctx), repoOwner, repoName);
|
||||
.getLabels(((BaseActivity) ctx).getAccount().getAuthorization(), repoOwner, repoName);
|
||||
|
||||
call.enqueue(new Callback<List<Labels>>() {
|
||||
|
||||
@ -82,7 +82,7 @@ public class LabelsActions {
|
||||
// Load organization labels
|
||||
Call<List<Labels>> callOrgLabels = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.getOrganizationLabels(Authorization.get(ctx), repoOwner);
|
||||
.getOrganizationLabels(((BaseActivity) ctx).getAccount().getAuthorization(), repoOwner);
|
||||
|
||||
callOrgLabels.enqueue(new Callback<List<Labels>>() {
|
||||
|
||||
|
@ -6,10 +6,11 @@ import androidx.annotation.NonNull;
|
||||
import com.google.gson.JsonElement;
|
||||
import org.gitnex.tea4j.models.Milestones;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
@ -21,23 +22,14 @@ public class MilestoneActions {
|
||||
|
||||
static final private String TAG = "MilestoneActions : ";
|
||||
|
||||
public static void closeMilestone(final Context ctx, int milestoneId_) {
|
||||
|
||||
final TinyDB tinyDB = TinyDB.getInstance(ctx);
|
||||
|
||||
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 token = "token " + tinyDB.getString(loginUid + "-token");
|
||||
public static void closeMilestone(final Context ctx, int milestoneId_, RepositoryContext repository) {
|
||||
|
||||
Milestones milestoneStateJson = new Milestones("closed");
|
||||
Call<JsonElement> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.closeReopenMilestone(token, repoOwner, repoName, milestoneId_, milestoneStateJson);
|
||||
.closeReopenMilestone(((BaseActivity) ctx).getAccount().getAuthorization(), repository.getOwner(), repository.getOwner(), milestoneId_, milestoneStateJson);
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
|
||||
@ -77,23 +69,14 @@ public class MilestoneActions {
|
||||
|
||||
}
|
||||
|
||||
public static void openMilestone(final Context ctx, int milestoneId_) {
|
||||
|
||||
final TinyDB tinyDB = TinyDB.getInstance(ctx);
|
||||
|
||||
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 token = "token " + tinyDB.getString(loginUid + "-token");
|
||||
public static void openMilestone(final Context ctx, int milestoneId_, RepositoryContext repository) {
|
||||
|
||||
Milestones milestoneStateJson = new Milestones("open");
|
||||
Call<JsonElement> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.closeReopenMilestone(token, repoOwner, repoName, milestoneId_, milestoneStateJson);
|
||||
.closeReopenMilestone(((BaseActivity) ctx).getAccount().getAuthorization(), repository.getOwner(), repository.getOwner(), milestoneId_, milestoneStateJson);
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
|
||||
|
@ -4,16 +4,16 @@ import android.content.Context;
|
||||
import androidx.annotation.NonNull;
|
||||
import com.google.gson.JsonElement;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
/**
|
||||
* Author qwerty287
|
||||
* @author qwerty287
|
||||
*/
|
||||
|
||||
public class PullRequestActions {
|
||||
@ -21,7 +21,7 @@ public class PullRequestActions {
|
||||
public static void deleteHeadBranch(Context context, String repoOwner, String repoName, String headBranch, boolean showToasts) {
|
||||
Call<JsonElement> call = RetrofitClient
|
||||
.getApiInterface(context)
|
||||
.deleteBranch(Authorization.get(context), repoOwner, repoName, headBranch);
|
||||
.deleteBranch(((BaseActivity) context).getAccount().getAuthorization(), repoOwner, repoName, headBranch);
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
|
||||
@ -71,7 +71,7 @@ public class PullRequestActions {
|
||||
else {
|
||||
strategy = "rebase";
|
||||
}
|
||||
RetrofitClient.getApiInterface(context).updatePullRequest(Authorization.get(context), repoOwner, repoName, Integer.parseInt(index), strategy)
|
||||
RetrofitClient.getApiInterface(context).updatePullRequest(((BaseActivity) context).getAccount().getAuthorization(), repoOwner, repoName, Integer.parseInt(index), strategy)
|
||||
.enqueue(new Callback<Void>() {
|
||||
|
||||
@Override
|
||||
|
@ -5,11 +5,12 @@ import android.util.Log;
|
||||
import androidx.annotation.NonNull;
|
||||
import com.google.gson.JsonElement;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.activities.MainActivity;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
@ -19,20 +20,13 @@ import retrofit2.Callback;
|
||||
|
||||
public class RepositoryActions {
|
||||
|
||||
public static void starRepository(final Context context) {
|
||||
|
||||
final TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
public static void starRepository(final Context context, RepositoryContext repository) {
|
||||
|
||||
Call<JsonElement> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getApiInterface(context)
|
||||
.starRepository(Authorization.get(context), repoOwner, repoName);
|
||||
.starRepository(((BaseActivity) context).getAccount().getAuthorization(), repository.getOwner(), repository.getName());
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
|
||||
@ -42,7 +36,7 @@ public class RepositoryActions {
|
||||
if(response.isSuccessful()) {
|
||||
if(response.code() == 204) {
|
||||
|
||||
tinyDb.putBoolean("repoCreated", true);
|
||||
MainActivity.repoCreated = true;
|
||||
Toasty.success(context, context.getString(R.string.starRepositorySuccess));
|
||||
|
||||
}
|
||||
@ -81,20 +75,13 @@ public class RepositoryActions {
|
||||
|
||||
}
|
||||
|
||||
public static void unStarRepository(final Context context) {
|
||||
|
||||
final TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
public static void unStarRepository(final Context context, RepositoryContext repository) {
|
||||
|
||||
Call<JsonElement> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getApiInterface(context)
|
||||
.unStarRepository(Authorization.get(context), repoOwner, repoName);
|
||||
.unStarRepository(((BaseActivity) context).getAccount().getAuthorization(), repository.getOwner(), repository.getName());
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
|
||||
@ -104,7 +91,7 @@ public class RepositoryActions {
|
||||
if(response.isSuccessful()) {
|
||||
if(response.code() == 204) {
|
||||
|
||||
tinyDb.putBoolean("repoCreated", true);
|
||||
MainActivity.repoCreated = true;
|
||||
Toasty.success(context, context.getString(R.string.unStarRepositorySuccess));
|
||||
|
||||
}
|
||||
@ -143,20 +130,13 @@ public class RepositoryActions {
|
||||
|
||||
}
|
||||
|
||||
public static void watchRepository(final Context context) {
|
||||
|
||||
final TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
public static void watchRepository(final Context context, RepositoryContext repository) {
|
||||
|
||||
Call<JsonElement> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getApiInterface(context)
|
||||
.watchRepository(Authorization.get(context), repoOwner, repoName);
|
||||
.watchRepository(((BaseActivity) context).getAccount().getAuthorization(), repository.getOwner(), repository.getName());
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
|
||||
@ -166,7 +146,6 @@ public class RepositoryActions {
|
||||
if(response.isSuccessful()) {
|
||||
if(response.code() == 200) {
|
||||
|
||||
tinyDb.putBoolean("repoCreated", true);
|
||||
Toasty.success(context, context.getString(R.string.watchRepositorySuccess));
|
||||
|
||||
}
|
||||
@ -205,20 +184,13 @@ public class RepositoryActions {
|
||||
|
||||
}
|
||||
|
||||
public static void unWatchRepository(final Context context) {
|
||||
|
||||
final TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
public static void unWatchRepository(final Context context, RepositoryContext repository) {
|
||||
|
||||
Call<JsonElement> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getApiInterface(context)
|
||||
.unWatchRepository(Authorization.get(context), repoOwner, repoName);
|
||||
.unWatchRepository(((BaseActivity) context).getAccount().getAuthorization(), repository.getOwner(), repository.getName());
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
|
||||
@ -227,7 +199,6 @@ public class RepositoryActions {
|
||||
|
||||
if(response.code() == 204) {
|
||||
|
||||
tinyDb.putBoolean("repoCreated", true);
|
||||
Toasty.success(context, context.getString(R.string.unWatchRepositorySuccess));
|
||||
|
||||
}
|
||||
|
@ -5,10 +5,9 @@ import androidx.annotation.NonNull;
|
||||
import com.google.gson.JsonElement;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.AddNewTeamMemberActivity;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
@ -21,13 +20,9 @@ public class TeamActions {
|
||||
|
||||
public static void removeTeamMember(final Context context, String userName, int teamId) {
|
||||
|
||||
final TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
|
||||
Call<JsonElement> call;
|
||||
|
||||
call = RetrofitClient
|
||||
Call<JsonElement> call = RetrofitClient
|
||||
.getApiInterface(context)
|
||||
.removeTeamMember(Authorization.get(context), teamId, userName);
|
||||
.removeTeamMember(((BaseActivity) context).getAccount().getAuthorization(), teamId, userName);
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
|
||||
@ -38,7 +33,6 @@ public class TeamActions {
|
||||
|
||||
if(response.code() == 204) {
|
||||
|
||||
tinyDb.putBoolean("teamActionFlag", true);
|
||||
Toasty.success(context, context.getString(R.string.memberRemovedMessage));
|
||||
((AddNewTeamMemberActivity)context).finish();
|
||||
|
||||
@ -83,11 +77,9 @@ public class TeamActions {
|
||||
|
||||
public static void addTeamMember(final Context context, String userName, int teamId) {
|
||||
|
||||
final TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
|
||||
Call<JsonElement> call = RetrofitClient
|
||||
.getApiInterface(context)
|
||||
.addTeamMember(Authorization.get(context), teamId, userName);
|
||||
.addTeamMember(((BaseActivity) context).getAccount().getAuthorization(), teamId, userName);
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
|
||||
@ -98,7 +90,6 @@ public class TeamActions {
|
||||
|
||||
if(response.code() == 204) {
|
||||
|
||||
tinyDb.putBoolean("teamActionFlag", true);
|
||||
Toasty.success(context, context.getString(R.string.memberAddedMessage));
|
||||
((AddNewTeamMemberActivity)context).finish();
|
||||
|
||||
|
@ -15,10 +15,10 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import org.gitnex.tea4j.models.UserInfo;
|
||||
import org.gitnex.tea4j.models.UserSearch;
|
||||
import org.mian.gitnex.adapters.UserSearchAdapter;
|
||||
import org.mian.gitnex.adapters.CollaboratorSearchAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.ActivityAddCollaboratorToRepositoryBinding;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
@ -36,6 +36,7 @@ public class AddCollaboratorToRepositoryActivity extends BaseActivity {
|
||||
private ProgressBar mProgressBar;
|
||||
|
||||
private RecyclerView mRecyclerView;
|
||||
private RepositoryContext repository;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
@ -53,6 +54,8 @@ public class AddCollaboratorToRepositoryActivity extends BaseActivity {
|
||||
mProgressBar = activityAddCollaboratorToRepositoryBinding.progressBar;
|
||||
noData = activityAddCollaboratorToRepositoryBinding.noData;
|
||||
|
||||
repository = RepositoryContext.fromIntent(getIntent());
|
||||
|
||||
addCollaboratorSearch.requestFocus();
|
||||
assert imm != null;
|
||||
imm.showSoftInput(addCollaboratorSearch, InputMethodManager.SHOW_IMPLICIT);
|
||||
@ -80,8 +83,8 @@ public class AddCollaboratorToRepositoryActivity extends BaseActivity {
|
||||
public void loadUserSearchList(String searchKeyword) {
|
||||
|
||||
Call<UserSearch> call = RetrofitClient
|
||||
.getApiInterface(appCtx)
|
||||
.getUserBySearch(Authorization.get(ctx), searchKeyword, 10, 1);
|
||||
.getApiInterface(ctx)
|
||||
.getUserBySearch(getAccount().getAuthorization(), searchKeyword, 10, 1);
|
||||
|
||||
call.enqueue(new Callback<UserSearch>() {
|
||||
|
||||
@ -112,7 +115,7 @@ public class AddCollaboratorToRepositoryActivity extends BaseActivity {
|
||||
|
||||
private void getUsersList(List<UserInfo> dataList, Context context) {
|
||||
|
||||
UserSearchAdapter adapter = new UserSearchAdapter(dataList, context);
|
||||
CollaboratorSearchAdapter adapter = new CollaboratorSearchAdapter(dataList, context, repository);
|
||||
|
||||
mRecyclerView.setHasFixedSize(true);
|
||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(ctx));
|
||||
@ -139,4 +142,10 @@ public class AddCollaboratorToRepositoryActivity extends BaseActivity {
|
||||
onClickListener = view -> finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
repository.checkAccountSwitch(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.database.api.BaseApi;
|
||||
import org.mian.gitnex.database.api.UserAccountsApi;
|
||||
import org.mian.gitnex.database.models.UserAccount;
|
||||
import org.mian.gitnex.databinding.ActivityAddNewAccountBinding;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.PathsHelper;
|
||||
@ -50,6 +51,15 @@ public class AddNewAccountActivity extends BaseActivity {
|
||||
initCloseListener();
|
||||
viewBinding.close.setOnClickListener(onClickListener);
|
||||
viewBinding.instanceUrl.setText(getIntent().getStringExtra("instanceUrl"));
|
||||
viewBinding.loginToken.setText(getIntent().getStringExtra("token"));
|
||||
String scheme = getIntent().getStringExtra("scheme");
|
||||
if(scheme != null && scheme.equals("http")) {
|
||||
viewBinding.protocolSpinner.setText(Protocol.HTTP.toString());
|
||||
spinnerSelectedValue = Protocol.HTTP.toString();
|
||||
} else { // default is https
|
||||
viewBinding.protocolSpinner.setText(Protocol.HTTPS.toString());
|
||||
spinnerSelectedValue = Protocol.HTTPS.toString();
|
||||
}
|
||||
|
||||
ArrayAdapter<Protocol> adapterProtocols = new ArrayAdapter<>(ctx, R.layout.list_spinner_items, Protocol.values());
|
||||
|
||||
@ -134,7 +144,6 @@ public class AddNewAccountActivity extends BaseActivity {
|
||||
return;
|
||||
}
|
||||
|
||||
tinyDB.putString("giteaVersion", version.getVersion());
|
||||
Version giteaVersion = new Version(version.getVersion());
|
||||
|
||||
if(giteaVersion.less(getString(R.string.versionLow))) {
|
||||
@ -210,14 +219,24 @@ public class AddNewAccountActivity extends BaseActivity {
|
||||
|
||||
if(!userAccountExists) {
|
||||
|
||||
userAccountsApi.createNewAccount(accountName, instanceUrl, userDetails.getUsername(), loginToken, "");
|
||||
long id = userAccountsApi.createNewAccount(accountName, instanceUrl, userDetails.getUsername(), loginToken, "");
|
||||
UserAccount account = userAccountsApi.getAccountById((int) id);
|
||||
AppUtil.switchToAccount(AddNewAccountActivity.this, account);
|
||||
Toasty.success(ctx, getResources().getString(R.string.accountAddedMessage));
|
||||
finish();
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.warning(ctx, getResources().getString(R.string.accountAlreadyExistsError));
|
||||
UserAccount account = userAccountsApi.getAccountByName(accountName);
|
||||
if(account.isLoggedIn()) {
|
||||
Toasty.warning(ctx, getResources().getString(R.string.accountAlreadyExistsError));
|
||||
AppUtil.switchToAccount(ctx, account);
|
||||
} else {
|
||||
userAccountsApi.updateTokenByAccountName(accountName, loginToken);
|
||||
userAccountsApi.login(account.getAccountId());
|
||||
AppUtil.switchToAccount(AddNewAccountActivity.this, account);
|
||||
}
|
||||
finish();
|
||||
}
|
||||
break;
|
||||
|
||||
@ -228,7 +247,7 @@ public class AddNewAccountActivity extends BaseActivity {
|
||||
|
||||
default:
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.genericApiStatusError) + response.code());
|
||||
Toasty.error(ctx, getResources().getString(R.string.genericApiError, response.code()));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,7 +19,6 @@ import org.gitnex.tea4j.models.UserSearch;
|
||||
import org.mian.gitnex.adapters.UserSearchForTeamMemberAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.ActivityAddNewTeamMemberBinding;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@ -91,8 +90,8 @@ public class AddNewTeamMemberActivity extends BaseActivity {
|
||||
|
||||
if(!addNewTeamMember.getText().toString().equals("") && addNewTeamMember.getText().toString().length() > 1) {
|
||||
|
||||
adapter = new UserSearchForTeamMemberAdapter(dataList, ctx, Integer.parseInt(teamId));
|
||||
loadUserSearchList(addNewTeamMember.getText().toString(), teamId);
|
||||
adapter = new UserSearchForTeamMemberAdapter(dataList, ctx, Integer.parseInt(teamId), getIntent().getStringExtra("orgName"));
|
||||
loadUserSearchList(addNewTeamMember.getText().toString());
|
||||
}
|
||||
}
|
||||
|
||||
@ -108,9 +107,9 @@ public class AddNewTeamMemberActivity extends BaseActivity {
|
||||
|
||||
}
|
||||
|
||||
public void loadUserSearchList(String searchKeyword, String teamId) {
|
||||
public void loadUserSearchList(String searchKeyword) {
|
||||
|
||||
Call<UserSearch> call = RetrofitClient.getApiInterface(ctx).getUserBySearch(Authorization.get(ctx), searchKeyword, 10, 1);
|
||||
Call<UserSearch> call = RetrofitClient.getApiInterface(ctx).getUserBySearch(getAccount().getAuthorization(), searchKeyword, 10, 1);
|
||||
|
||||
mProgressBar.setVisibility(View.VISIBLE);
|
||||
|
||||
|
@ -11,7 +11,6 @@ import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import org.mian.gitnex.adapters.AdminCronTasksAdapter;
|
||||
import org.mian.gitnex.databinding.ActivityAdminCronTasksBinding;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.viewmodels.AdminCronTasksViewModel;
|
||||
|
||||
/**
|
||||
@ -52,11 +51,11 @@ public class AdminCronTasksActivity extends BaseActivity {
|
||||
activityAdminCronTasksBinding.pullToRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
|
||||
activityAdminCronTasksBinding.pullToRefresh.setRefreshing(false);
|
||||
AdminCronTasksViewModel.loadCronTasksList(ctx, Authorization.get(ctx), PAGE, LIMIT);
|
||||
AdminCronTasksViewModel.loadCronTasksList(ctx, getAccount().getAuthorization(), PAGE, LIMIT);
|
||||
|
||||
}, 500));
|
||||
|
||||
fetchDataAsync(ctx, Authorization.get(ctx));
|
||||
fetchDataAsync(ctx, getAccount().getAuthorization());
|
||||
}
|
||||
|
||||
private void fetchDataAsync(Context ctx, String instanceToken) {
|
||||
@ -65,7 +64,7 @@ public class AdminCronTasksActivity extends BaseActivity {
|
||||
|
||||
cronTasksViewModel.getCronTasksList(ctx, instanceToken, PAGE, LIMIT).observe(this, cronTasksListMain -> {
|
||||
|
||||
adapter = new AdminCronTasksAdapter(ctx, cronTasksListMain);
|
||||
adapter = new AdminCronTasksAdapter(cronTasksListMain);
|
||||
|
||||
if(adapter.getItemCount() > 0) {
|
||||
|
||||
|
@ -24,7 +24,6 @@ import org.mian.gitnex.adapters.AdminGetUsersAdapter;
|
||||
import org.mian.gitnex.databinding.ActivityAdminGetUsersBinding;
|
||||
import org.mian.gitnex.fragments.BottomSheetAdminUsersFragment;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.structs.BottomSheetListener;
|
||||
import org.mian.gitnex.viewmodels.AdminGetUsersViewModel;
|
||||
|
||||
@ -70,11 +69,11 @@ public class AdminGetUsersActivity extends BaseActivity implements BottomSheetLi
|
||||
swipeRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
|
||||
swipeRefresh.setRefreshing(false);
|
||||
AdminGetUsersViewModel.loadUsersList(ctx, Authorization.get(ctx));
|
||||
AdminGetUsersViewModel.loadUsersList(ctx, getAccount().getAuthorization());
|
||||
|
||||
}, 500));
|
||||
|
||||
fetchDataAsync(ctx, Authorization.get(ctx));
|
||||
fetchDataAsync(ctx, getAccount().getAuthorization());
|
||||
|
||||
}
|
||||
|
||||
|
@ -7,9 +7,11 @@ import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.biometric.BiometricPrompt;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.core.MainApplication;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.contexts.AccountContext;
|
||||
import org.mian.gitnex.notifications.Notifications;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.Executor;
|
||||
@ -37,47 +39,49 @@ public abstract class BaseActivity extends AppCompatActivity {
|
||||
|
||||
case 1:
|
||||
|
||||
tinyDB.putString("currentTheme", "light");
|
||||
setTheme(R.style.AppThemeLight);
|
||||
break;
|
||||
case 2:
|
||||
|
||||
if(TimeHelper.timeBetweenHours(tinyDB.getInt("darkThemeTimeHour"), tinyDB.getInt("lightThemeTimeHour"), tinyDB.getInt("darkThemeTimeMinute"), tinyDB.getInt("lightThemeTimeMinute"))) {
|
||||
if(TimeHelper.timeBetweenHours(
|
||||
tinyDB.getInt("darkThemeTimeHour", 18),
|
||||
tinyDB.getInt("lightThemeTimeHour", 6),
|
||||
tinyDB.getInt("darkThemeTimeMinute", 0),
|
||||
tinyDB.getInt("lightThemeTimeMinute", 0))
|
||||
) {
|
||||
|
||||
tinyDB.putString("currentTheme", "dark");
|
||||
setTheme(R.style.AppTheme);
|
||||
}
|
||||
else {
|
||||
|
||||
tinyDB.putString("currentTheme", "light");
|
||||
setTheme(R.style.AppThemeLight);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
|
||||
tinyDB.putString("currentTheme", "light");
|
||||
setTheme(R.style.AppThemeRetro);
|
||||
break;
|
||||
case 4:
|
||||
if(TimeHelper.timeBetweenHours(tinyDB.getInt("darkThemeTimeHour"), tinyDB.getInt("lightThemeTimeHour"), tinyDB.getInt("darkThemeTimeMinute"), tinyDB.getInt("lightThemeTimeMinute"))) {
|
||||
if(TimeHelper.timeBetweenHours(
|
||||
tinyDB.getInt("darkThemeTimeHour", 18),
|
||||
tinyDB.getInt("lightThemeTimeHour", 6),
|
||||
tinyDB.getInt("darkThemeTimeMinute", 0),
|
||||
tinyDB.getInt("lightThemeTimeMinute", 0))
|
||||
) {
|
||||
|
||||
tinyDB.putString("currentTheme", "dark");
|
||||
setTheme(R.style.AppTheme);
|
||||
}
|
||||
else {
|
||||
|
||||
tinyDB.putString("currentTheme", "light");
|
||||
setTheme(R.style.AppThemeRetro);
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
|
||||
tinyDB.putString("currentTheme", "dark");
|
||||
setTheme(R.style.AppThemePitchBlack);
|
||||
break;
|
||||
default:
|
||||
|
||||
tinyDB.putString("currentTheme", "dark");
|
||||
setTheme(R.style.AppTheme);
|
||||
|
||||
}
|
||||
@ -96,7 +100,7 @@ public abstract class BaseActivity extends AppCompatActivity {
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
if(tinyDB.getBoolean("biometricStatus") && !tinyDB.getBoolean("biometricLifeCycle")) {
|
||||
if(tinyDB.getBoolean("biometricStatus", false) && !tinyDB.getBoolean("biometricLifeCycle")) {
|
||||
|
||||
Executor executor = ContextCompat.getMainExecutor(this);
|
||||
|
||||
@ -131,6 +135,10 @@ public abstract class BaseActivity extends AppCompatActivity {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public AccountContext getAccount() {
|
||||
return ((MainApplication) getApplication()).currentAccount;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -23,10 +23,10 @@ import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.CommitsAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.ActivityCommitsBinding;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.Constants;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
@ -42,7 +42,7 @@ public class CommitsActivity extends BaseActivity {
|
||||
private View.OnClickListener onClickListener;
|
||||
private TextView noData;
|
||||
private ProgressBar progressBar;
|
||||
private String TAG = "CommitsActivity";
|
||||
private final String TAG = "CommitsActivity";
|
||||
private int resultLimit = Constants.resultLimitOldGiteaInstances;
|
||||
private int pageSize = 1;
|
||||
|
||||
@ -51,10 +51,13 @@ public class CommitsActivity extends BaseActivity {
|
||||
private CommitsAdapter adapter;
|
||||
private ProgressBar progressLoadMore;
|
||||
|
||||
public RepositoryContext repository;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
this.getClass().getName();
|
||||
|
||||
ActivityCommitsBinding activityCommitsBinding = ActivityCommitsBinding.inflate(getLayoutInflater());
|
||||
setContentView(activityCommitsBinding.getRoot());
|
||||
@ -62,12 +65,8 @@ public class CommitsActivity extends BaseActivity {
|
||||
Toolbar toolbar = activityCommitsBinding.toolbar;
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
String repoFullName = tinyDB.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
|
||||
String branchName = getIntent().getStringExtra("branchName");
|
||||
repository = RepositoryContext.fromIntent(getIntent());
|
||||
String branchName = repository.getBranchRef();
|
||||
|
||||
TextView toolbar_title = activityCommitsBinding.toolbarTitle;
|
||||
toolbar_title.setMovementMethod(new ScrollingMovementMethod());
|
||||
@ -83,7 +82,7 @@ public class CommitsActivity extends BaseActivity {
|
||||
closeActivity.setOnClickListener(onClickListener);
|
||||
|
||||
// if gitea is 1.12 or higher use the new limit (resultLimitNewGiteaInstances)
|
||||
if(new Version(tinyDB.getString("giteaVersion")).higherOrEqual("1.12")) {
|
||||
if(getAccount().requiresVersion("1.12")) {
|
||||
|
||||
resultLimit = Constants.resultLimitNewGiteaInstances;
|
||||
}
|
||||
@ -94,7 +93,7 @@ public class CommitsActivity extends BaseActivity {
|
||||
swipeRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
|
||||
swipeRefresh.setRefreshing(false);
|
||||
loadInitial(Authorization.get(ctx), repoOwner, repoName, branchName, resultLimit);
|
||||
loadInitial(getAccount().getAuthorization(), repository.getOwner(), repository.getName(), branchName, resultLimit);
|
||||
adapter.notifyDataChanged();
|
||||
}, 200));
|
||||
|
||||
@ -104,7 +103,7 @@ public class CommitsActivity extends BaseActivity {
|
||||
if(commitsList.size() == resultLimit || pageSize == resultLimit) {
|
||||
|
||||
int page = (commitsList.size() + resultLimit) / resultLimit;
|
||||
loadMore(Authorization.get(ctx), repoOwner, repoName, page, branchName, resultLimit);
|
||||
loadMore(getAccount().getAuthorization(), repository.getOwner(), repository.getName(), page, branchName, resultLimit);
|
||||
}
|
||||
}));
|
||||
|
||||
@ -112,7 +111,7 @@ public class CommitsActivity extends BaseActivity {
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(ctx));
|
||||
recyclerView.setAdapter(adapter);
|
||||
|
||||
loadInitial(Authorization.get(ctx), repoOwner, repoName, branchName, resultLimit);
|
||||
loadInitial(getAccount().getAuthorization(), repository.getOwner(), repository.getName(), branchName, resultLimit);
|
||||
}
|
||||
|
||||
private void loadInitial(String token, String repoOwner, String repoName, String branchName, int resultLimit) {
|
||||
@ -258,11 +257,16 @@ public class CommitsActivity extends BaseActivity {
|
||||
|
||||
onClickListener = view -> {
|
||||
|
||||
getIntent().removeExtra("branchName");
|
||||
finish();
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
repository.checkAccountSwitch(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -2,6 +2,7 @@ package org.mian.gitnex.activities;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
@ -20,9 +21,9 @@ import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.ActivityCreateFileBinding;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.NetworkStatusObserver;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
@ -47,8 +48,7 @@ public class CreateFileActivity extends BaseActivity {
|
||||
|
||||
private final List<String> branches = new ArrayList<>();
|
||||
|
||||
private String repoOwner;
|
||||
private String repoName;
|
||||
private RepositoryContext repository;
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
@Override
|
||||
@ -59,10 +59,7 @@ public class CreateFileActivity extends BaseActivity {
|
||||
binding = ActivityCreateFileBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
|
||||
String repoFullName = tinyDB.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
repoOwner = parts[0];
|
||||
repoName = parts[1];
|
||||
repository = RepositoryContext.fromIntent(getIntent());
|
||||
|
||||
TextView toolbarTitle = binding.toolbarTitle;
|
||||
|
||||
@ -119,7 +116,7 @@ public class CreateFileActivity extends BaseActivity {
|
||||
|
||||
}
|
||||
|
||||
getBranches(repoOwner, repoName);
|
||||
getBranches(repository.getOwner(), repository.getName());
|
||||
|
||||
disableProcessButton();
|
||||
|
||||
@ -162,15 +159,15 @@ public class CreateFileActivity extends BaseActivity {
|
||||
switch(fileAction) {
|
||||
|
||||
case FILE_ACTION_CREATE:
|
||||
createNewFile(repoOwner, repoName, newFileName, AppUtil.encodeBase64(newFileContent), newFileCommitMessage, newFileBranchName);
|
||||
createNewFile(repository.getOwner(), repository.getName(), newFileName, AppUtil.encodeBase64(newFileContent), newFileCommitMessage, newFileBranchName);
|
||||
break;
|
||||
|
||||
case FILE_ACTION_DELETE:
|
||||
deleteFile(repoOwner, repoName, filePath, newFileCommitMessage, newFileBranchName, fileSha);
|
||||
deleteFile(repository.getOwner(), repository.getName(), filePath, newFileCommitMessage, newFileBranchName, fileSha);
|
||||
break;
|
||||
|
||||
case FILE_ACTION_EDIT:
|
||||
editFile(repoOwner, repoName, filePath, AppUtil.encodeBase64(newFileContent), newFileCommitMessage, newFileBranchName, fileSha);
|
||||
editFile(repository.getOwner(), repository.getName(), filePath, AppUtil.encodeBase64(newFileContent), newFileCommitMessage, newFileBranchName, fileSha);
|
||||
break;
|
||||
|
||||
}
|
||||
@ -184,7 +181,7 @@ public class CreateFileActivity extends BaseActivity {
|
||||
|
||||
Call<JsonElement> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.createNewFile(Authorization.get(ctx), repoOwner, repoName, fileName, createNewFileJsonStr);
|
||||
.createNewFile(getAccount().getAuthorization(), repoOwner, repoName, fileName, createNewFileJsonStr);
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
|
||||
@ -196,6 +193,9 @@ public class CreateFileActivity extends BaseActivity {
|
||||
case 201:
|
||||
enableProcessButton();
|
||||
Toasty.success(ctx, getString(R.string.newFileSuccessMessage));
|
||||
Intent result = new Intent();
|
||||
result.putExtra("fileModified", true);
|
||||
setResult(200, result);
|
||||
finish();
|
||||
break;
|
||||
|
||||
@ -239,7 +239,7 @@ public class CreateFileActivity extends BaseActivity {
|
||||
|
||||
Call<JsonElement> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.deleteFile(Authorization.get(ctx), repoOwner, repoName, fileName, deleteFileJsonStr);
|
||||
.deleteFile(getAccount().getAuthorization(), repoOwner, repoName, fileName, deleteFileJsonStr);
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
|
||||
@ -250,10 +250,10 @@ public class CreateFileActivity extends BaseActivity {
|
||||
|
||||
case 200:
|
||||
enableProcessButton();
|
||||
Toasty.info(ctx, getString(R.string.deleteFileMessage, tinyDB.getString("repoBranch")));
|
||||
getIntent().removeExtra("filePath");
|
||||
getIntent().removeExtra("fileSha");
|
||||
getIntent().removeExtra("fileContents");
|
||||
Toasty.info(ctx, getString(R.string.deleteFileMessage, repository.getBranchRef()));
|
||||
Intent result = new Intent();
|
||||
result.putExtra("fileModified", true);
|
||||
setResult(200, result);
|
||||
finish();
|
||||
break;
|
||||
|
||||
@ -296,7 +296,7 @@ public class CreateFileActivity extends BaseActivity {
|
||||
|
||||
Call<JsonElement> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.editFile(Authorization.get(ctx), repoOwner, repoName, fileName, editFileJsonStr);
|
||||
.editFile(getAccount().getAuthorization(), repoOwner, repoName, fileName, editFileJsonStr);
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
|
||||
@ -308,10 +308,9 @@ public class CreateFileActivity extends BaseActivity {
|
||||
case 200:
|
||||
enableProcessButton();
|
||||
Toasty.info(ctx, getString(R.string.editFileMessage, branchName));
|
||||
getIntent().removeExtra("filePath");
|
||||
getIntent().removeExtra("fileSha");
|
||||
getIntent().removeExtra("fileContents");
|
||||
tinyDB.putBoolean("fileModified", true);
|
||||
Intent result = new Intent();
|
||||
result.putExtra("fileModified", true);
|
||||
setResult(200, result);
|
||||
finish();
|
||||
break;
|
||||
|
||||
@ -351,7 +350,7 @@ public class CreateFileActivity extends BaseActivity {
|
||||
|
||||
Call<List<Branches>> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.getBranches(Authorization.get(ctx), repoOwner, repoName);
|
||||
.getBranches(getAccount().getAuthorization(), repoOwner, repoName);
|
||||
|
||||
call.enqueue(new Callback<List<Branches>>() {
|
||||
|
||||
@ -366,7 +365,7 @@ public class CreateFileActivity extends BaseActivity {
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<>(CreateFileActivity.this, R.layout.list_spinner_items, branches);
|
||||
|
||||
binding.newFileBranches.setAdapter(adapter);
|
||||
binding.newFileBranches.setText(tinyDB.getString("repoBranch"), false);
|
||||
binding.newFileBranches.setText(repository.getBranchRef(), false);
|
||||
|
||||
enableProcessButton();
|
||||
|
||||
@ -385,4 +384,10 @@ public class CreateFileActivity extends BaseActivity {
|
||||
private void disableProcessButton() { binding.newFileCreate.setEnabled(false); }
|
||||
private void enableProcessButton() { binding.newFileCreate.setEnabled(true); }
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
repository.checkAccountSwitch(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -27,13 +27,12 @@ import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.ActivityCreateIssueBinding;
|
||||
import org.mian.gitnex.databinding.CustomAssigneesSelectionDialogBinding;
|
||||
import org.mian.gitnex.databinding.CustomLabelsSelectionDialogBinding;
|
||||
import org.mian.gitnex.fragments.IssuesFragment;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.Constants;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
@ -58,9 +57,7 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
||||
private String assigneesSetter;
|
||||
private int milestoneId;
|
||||
|
||||
private String loginUid;
|
||||
private String repoOwner;
|
||||
private String repoName;
|
||||
private RepositoryContext repository;
|
||||
|
||||
private LabelsListAdapter labelsAdapter;
|
||||
private AssigneesListAdapter assigneesAdapter;
|
||||
@ -84,14 +81,10 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
loginUid = tinyDB.getString("loginUid");
|
||||
String repoFullName = tinyDB.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
repoOwner = parts[0];
|
||||
repoName = parts[1];
|
||||
repository = RepositoryContext.fromIntent(getIntent());
|
||||
|
||||
// require gitea 1.12 or higher
|
||||
if(new Version(tinyDB.getString("giteaVersion")).higherOrEqual("1.12.0")) {
|
||||
if(getAccount().requiresVersion("1.12.0")) {
|
||||
|
||||
resultLimit = Constants.resultLimitNewGiteaInstances;
|
||||
}
|
||||
@ -121,7 +114,7 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
||||
viewBinding.newIssueLabels.setOnClickListener(this);
|
||||
viewBinding.newIssueDueDate.setOnClickListener(this);
|
||||
|
||||
getMilestones(repoOwner, repoName, resultLimit);
|
||||
getMilestones(repository.getOwner(), repository.getName(), resultLimit);
|
||||
|
||||
disableProcessButton();
|
||||
|
||||
@ -138,7 +131,7 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
||||
viewBinding.createNewIssueButton.setOnClickListener(this);
|
||||
}
|
||||
|
||||
if(!tinyDB.getBoolean("canPush")) {
|
||||
if(!repository.getPermissions().canPush()) {
|
||||
viewBinding.newIssueAssigneesListLayout.setVisibility(View.GONE);
|
||||
viewBinding.newIssueMilestoneSpinnerLayout.setVisibility(View.GONE);
|
||||
viewBinding.newIssueLabelsLayout.setVisibility(View.GONE);
|
||||
@ -185,7 +178,7 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
||||
assigneesBinding.cancel.setOnClickListener(assigneesBinding_ -> dialogAssignees.dismiss());
|
||||
|
||||
dialogAssignees.show();
|
||||
AssigneesActions.getRepositoryAssignees(ctx, repoOwner, repoName, assigneesList, dialogAssignees, assigneesAdapter, assigneesBinding);
|
||||
AssigneesActions.getRepositoryAssignees(ctx, repository.getOwner(), repository.getName(), assigneesList, dialogAssignees, assigneesAdapter, assigneesBinding);
|
||||
}
|
||||
|
||||
private void showLabels() {
|
||||
@ -205,7 +198,7 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
||||
labelsBinding.cancel.setOnClickListener(labelsBinding_ -> dialogLabels.dismiss());
|
||||
|
||||
dialogLabels.show();
|
||||
LabelsActions.getRepositoryLabels(ctx, repoOwner, repoName, labelsList, dialogLabels, labelsAdapter, labelsBinding);
|
||||
LabelsActions.getRepositoryLabels(ctx, repository.getOwner(), repository.getName(), labelsList, dialogLabels, labelsAdapter, labelsBinding);
|
||||
}
|
||||
|
||||
private void processNewIssue() {
|
||||
@ -238,7 +231,7 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
||||
}
|
||||
|
||||
disableProcessButton();
|
||||
createNewIssueFunc(repoOwner, repoName, loginUid, newIssueDescriptionForm, newIssueDueDateForm, milestoneId, newIssueTitleForm);
|
||||
createNewIssueFunc(repository.getOwner(), repository.getName(), getAccount().getAccount().getUserName(), newIssueDescriptionForm, newIssueDueDateForm, milestoneId, newIssueTitleForm);
|
||||
}
|
||||
|
||||
private void createNewIssueFunc(String repoOwner, String repoName, String loginUid, String newIssueDescriptionForm, String newIssueDueDateForm, int newIssueMilestoneIdForm, String newIssueTitleForm) {
|
||||
@ -249,7 +242,7 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
||||
|
||||
call3 = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.createNewIssue(Authorization.get(ctx), repoOwner, repoName, createNewIssueJson);
|
||||
.createNewIssue(getAccount().getAuthorization(), repoOwner, repoName, createNewIssueJson);
|
||||
|
||||
call3.enqueue(new Callback<JsonElement>() {
|
||||
|
||||
@ -258,8 +251,7 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
||||
|
||||
if(response2.code() == 201) {
|
||||
|
||||
TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||
tinyDb.putBoolean("resumeIssues", true);
|
||||
IssuesFragment.resumeIssues = true;
|
||||
|
||||
Toasty.success(ctx, getString(R.string.issueCreated));
|
||||
enableProcessButton();
|
||||
@ -301,7 +293,7 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
||||
String msState = "open";
|
||||
Call<List<Milestones>> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.getMilestones(Authorization.get(ctx), repoOwner, repoName, 1, resultLimit, msState);
|
||||
.getMilestones(getAccount().getAuthorization(), repoOwner, repoName, 1, resultLimit, msState);
|
||||
|
||||
call.enqueue(new Callback<List<Milestones>>() {
|
||||
|
||||
@ -386,4 +378,10 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
||||
|
||||
viewBinding.createNewIssueButton.setEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
repository.checkAccountSwitch(this);
|
||||
}
|
||||
}
|
||||
|
@ -20,9 +20,8 @@ import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.ActivityCreateLabelBinding;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import org.mian.gitnex.viewmodels.LabelsViewModel;
|
||||
import org.mian.gitnex.viewmodels.OrganizationLabelsViewModel;
|
||||
import java.util.Objects;
|
||||
@ -35,11 +34,16 @@ import retrofit2.Callback;
|
||||
|
||||
public class CreateLabelActivity extends BaseActivity {
|
||||
|
||||
public static boolean refreshLabels = false;
|
||||
|
||||
private View.OnClickListener onClickListener;
|
||||
private TextView colorPicker;
|
||||
private EditText labelName;
|
||||
private Button createLabelButton;
|
||||
private TinyDB tinyDB;
|
||||
|
||||
private RepositoryContext repository;
|
||||
private String labelColor = "";
|
||||
private String labelColorDefault = "";
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
@ -51,15 +55,11 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
tinyDB = TinyDB.getInstance(appCtx);
|
||||
String repoFullName = tinyDB.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
repository = RepositoryContext.fromIntent(getIntent());
|
||||
|
||||
if(getIntent().getStringExtra("labelAction") != null && Objects.requireNonNull(getIntent().getStringExtra("labelAction")).equals("delete")) {
|
||||
|
||||
deleteLabel(repoOwner, repoName, Integer.parseInt(Objects.requireNonNull(getIntent().getStringExtra("labelId"))));
|
||||
deleteLabel(Integer.parseInt(Objects.requireNonNull(getIntent().getStringExtra("labelId"))));
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
@ -85,7 +85,7 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
|
||||
//Log.i("#Hex no alpha", String.format("#%06X", (0xFFFFFF & color)));
|
||||
colorPicker.setBackgroundColor(color);
|
||||
tinyDB.putString("labelColor", String.format("#%06X", (0xFFFFFF & color)));
|
||||
labelColor = String.format("#%06X", (0xFFFFFF & color));
|
||||
cp.dismiss();
|
||||
});
|
||||
|
||||
@ -94,7 +94,7 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
labelName.setText(getIntent().getStringExtra("labelTitle"));
|
||||
int labelColor_ = Color.parseColor("#" + getIntent().getStringExtra("labelColor"));
|
||||
colorPicker.setBackgroundColor(labelColor_);
|
||||
tinyDB.putString("labelColorDefault", "#" + getIntent().getStringExtra("labelColor"));
|
||||
labelColorDefault = "#" + getIntent().getStringExtra("labelColor");
|
||||
|
||||
TextView toolbar_title = activityCreateLabelBinding.toolbarTitle;
|
||||
toolbar_title.setText(getResources().getString(R.string.pageTitleLabelUpdate));
|
||||
@ -123,21 +123,16 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
String repoFullName = tinyDB.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
|
||||
String updateLabelName = labelName.getText().toString();
|
||||
|
||||
String updateLabelColor;
|
||||
if(tinyDB.getString("labelColor").isEmpty()) {
|
||||
if(labelColor.isEmpty()) {
|
||||
|
||||
updateLabelColor = tinyDB.getString("labelColorDefault");
|
||||
updateLabelColor = labelColorDefault;
|
||||
}
|
||||
else {
|
||||
|
||||
updateLabelColor = tinyDB.getString("labelColor");
|
||||
updateLabelColor = labelColor;
|
||||
}
|
||||
|
||||
if(!connToInternet) {
|
||||
@ -159,7 +154,7 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
disableProcessButton();
|
||||
patchLabel(repoOwner, repoName, updateLabelName, updateLabelColor, Integer.parseInt(
|
||||
patchLabel(repository.getOwner(), repository.getName(), updateLabelName, updateLabelColor, Integer.parseInt(
|
||||
Objects.requireNonNull(getIntent().getStringExtra("labelId"))));
|
||||
|
||||
}
|
||||
@ -168,21 +163,16 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
String repoFullName = tinyDB.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
|
||||
String newLabelName = labelName.getText().toString();
|
||||
String newLabelColor;
|
||||
|
||||
if(tinyDB.getString("labelColor").isEmpty()) {
|
||||
if(labelColor.isEmpty()) {
|
||||
|
||||
newLabelColor = String.format("#%06X", (0xFFFFFF & ContextCompat.getColor(ctx, R.color.releasePre)));
|
||||
}
|
||||
else {
|
||||
|
||||
newLabelColor = tinyDB.getString("labelColor");
|
||||
newLabelColor = labelColor;
|
||||
}
|
||||
|
||||
if(!connToInternet) {
|
||||
@ -204,7 +194,7 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
disableProcessButton();
|
||||
createNewLabel(repoOwner, repoName, newLabelName, newLabelColor);
|
||||
createNewLabel(repository.getOwner(), repository.getName(), newLabelName, newLabelColor);
|
||||
}
|
||||
|
||||
private void createNewLabel(String repoOwner, String repoName, String newLabelName, String newLabelColor) {
|
||||
@ -215,11 +205,11 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
|
||||
if(getIntent().getStringExtra("type") != null && Objects.requireNonNull(getIntent().getStringExtra("type")).equals("org")) {
|
||||
|
||||
call = RetrofitClient.getApiInterface(ctx).createOrganizationLabel(Authorization.get(ctx), getIntent().getStringExtra("orgName"), createLabelFunc);
|
||||
call = RetrofitClient.getApiInterface(ctx).createOrganizationLabel(getAccount().getAuthorization(), getIntent().getStringExtra("orgName"), createLabelFunc);
|
||||
}
|
||||
else {
|
||||
|
||||
call = RetrofitClient.getApiInterface(ctx).createLabel(Authorization.get(ctx), repoOwner, repoName, createLabelFunc);
|
||||
call = RetrofitClient.getApiInterface(ctx).createLabel(getAccount().getAuthorization(), repoOwner, repoName, createLabelFunc);
|
||||
}
|
||||
|
||||
call.enqueue(new Callback<CreateLabel>() {
|
||||
@ -230,8 +220,7 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
if(response.code() == 201) {
|
||||
|
||||
Toasty.success(ctx, getString(R.string.labelCreated));
|
||||
tinyDB.putString("labelColor", "");
|
||||
tinyDB.putBoolean("labelsRefresh", true);
|
||||
refreshLabels = true;
|
||||
finish();
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
@ -245,7 +234,7 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
else {
|
||||
|
||||
enableProcessButton();
|
||||
tinyDB.putString("labelColor", "");
|
||||
labelColor = "";
|
||||
Toasty.error(ctx, getString(R.string.labelGeneralError));
|
||||
}
|
||||
}
|
||||
@ -253,7 +242,7 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<CreateLabel> call, @NonNull Throwable t) {
|
||||
|
||||
tinyDB.putString("labelColor", "");
|
||||
labelColor = "";
|
||||
Log.e("onFailure", t.toString());
|
||||
enableProcessButton();
|
||||
}
|
||||
@ -269,11 +258,11 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
|
||||
if(getIntent().getStringExtra("type") != null && Objects.requireNonNull(getIntent().getStringExtra("type")).equals("org")) {
|
||||
|
||||
call = RetrofitClient.getApiInterface(ctx).patchOrganizationLabel(Authorization.get(ctx), getIntent().getStringExtra("orgName"), labelId, createLabelFunc);
|
||||
call = RetrofitClient.getApiInterface(ctx).patchOrganizationLabel(getAccount().getAuthorization(), getIntent().getStringExtra("orgName"), labelId, createLabelFunc);
|
||||
}
|
||||
else {
|
||||
|
||||
call = RetrofitClient.getApiInterface(appCtx).patchLabel(Authorization.get(ctx), repoOwner, repoName, labelId, createLabelFunc);
|
||||
call = RetrofitClient.getApiInterface(ctx).patchLabel(getAccount().getAuthorization(), repoOwner, repoName, labelId, createLabelFunc);
|
||||
}
|
||||
|
||||
call.enqueue(new Callback<CreateLabel>() {
|
||||
@ -286,14 +275,7 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
if(response.code() == 200) {
|
||||
|
||||
Toasty.success(ctx, getString(R.string.labelUpdated));
|
||||
tinyDB.putString("labelColor", "");
|
||||
tinyDB.putBoolean("labelsRefresh", true);
|
||||
tinyDB.putString("labelColorDefault", "");
|
||||
getIntent().removeExtra("labelAction");
|
||||
getIntent().removeExtra("labelId");
|
||||
getIntent().removeExtra("labelTitle");
|
||||
getIntent().removeExtra("labelColor");
|
||||
getIntent().removeExtra("type");
|
||||
refreshLabels = true;
|
||||
finish();
|
||||
}
|
||||
}
|
||||
@ -308,8 +290,8 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
else {
|
||||
|
||||
enableProcessButton();
|
||||
tinyDB.putString("labelColor", "");
|
||||
tinyDB.putString("labelColorDefault", "");
|
||||
labelColor = "";
|
||||
labelColorDefault = "";
|
||||
Toasty.error(ctx, getString(R.string.labelGeneralError));
|
||||
}
|
||||
}
|
||||
@ -317,8 +299,8 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<CreateLabel> call, @NonNull Throwable t) {
|
||||
|
||||
tinyDB.putString("labelColor", "");
|
||||
tinyDB.putString("labelColorDefault", "");
|
||||
labelColor = "";
|
||||
labelColorDefault = "";
|
||||
Log.e("onFailure", t.toString());
|
||||
enableProcessButton();
|
||||
}
|
||||
@ -328,28 +310,20 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
|
||||
private void initCloseListener() {
|
||||
|
||||
onClickListener = view -> {
|
||||
|
||||
getIntent().removeExtra("labelAction");
|
||||
getIntent().removeExtra("labelId");
|
||||
getIntent().removeExtra("labelTitle");
|
||||
getIntent().removeExtra("labelColor");
|
||||
getIntent().removeExtra("type");
|
||||
finish();
|
||||
};
|
||||
onClickListener = view -> finish();
|
||||
}
|
||||
|
||||
private void deleteLabel(final String repoOwner, final String repoName, int labelId) {
|
||||
private void deleteLabel(int labelId) {
|
||||
|
||||
Call<Labels> call;
|
||||
|
||||
if(getIntent().getStringExtra("type") != null && Objects.requireNonNull(getIntent().getStringExtra("type")).equals("org")) {
|
||||
|
||||
call = RetrofitClient.getApiInterface(appCtx).deleteOrganizationLabel(Authorization.get(ctx), getIntent().getStringExtra("orgName"), labelId);
|
||||
call = RetrofitClient.getApiInterface(ctx).deleteOrganizationLabel(getAccount().getAuthorization(), getIntent().getStringExtra("orgName"), labelId);
|
||||
}
|
||||
else {
|
||||
|
||||
call = RetrofitClient.getApiInterface(appCtx).deleteLabel(Authorization.get(ctx), repoOwner, repoName, labelId);
|
||||
call = RetrofitClient.getApiInterface(ctx).deleteLabel(getAccount().getAuthorization(), repository.getOwner(), repository.getName(), labelId);
|
||||
}
|
||||
|
||||
call.enqueue(new Callback<Labels>() {
|
||||
@ -364,15 +338,12 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
Toasty.success(ctx, getString(R.string.labelDeleteText));
|
||||
if(getIntent().getStringExtra("type") != null && Objects.requireNonNull(getIntent().getStringExtra("type")).equals("org")) {
|
||||
|
||||
OrganizationLabelsViewModel.loadOrgLabelsList(Authorization.get(ctx), getIntent().getStringExtra("orgName"), ctx, null, null);
|
||||
OrganizationLabelsViewModel.loadOrgLabelsList(getAccount().getAuthorization(), getIntent().getStringExtra("orgName"), ctx, null, null);
|
||||
}
|
||||
else {
|
||||
|
||||
LabelsViewModel.loadLabelsList(Authorization.get(ctx), repoOwner, repoName, ctx);
|
||||
LabelsViewModel.loadLabelsList(getAccount().getAuthorization(), repository.getOwner(), repository.getName(), ctx);
|
||||
}
|
||||
getIntent().removeExtra("labelAction");
|
||||
getIntent().removeExtra("labelId");
|
||||
getIntent().removeExtra("type");
|
||||
}
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
@ -406,4 +377,11 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
createLabelButton.setEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if(repository == null) return;
|
||||
repository.checkAccountSwitch(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package org.mian.gitnex.activities;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.DatePickerDialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
@ -18,10 +19,8 @@ import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.ActivityCreateMilestoneBinding;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import java.util.Calendar;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
@ -37,6 +36,7 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
||||
private EditText milestoneTitle;
|
||||
private EditText milestoneDescription;
|
||||
private Button createNewMilestoneButton;
|
||||
private RepositoryContext repository;
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
@Override
|
||||
@ -56,6 +56,7 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
||||
createNewMilestoneButton = activityCreateMilestoneBinding.createNewMilestoneButton;
|
||||
milestoneTitle = activityCreateMilestoneBinding.milestoneTitle;
|
||||
milestoneDescription = activityCreateMilestoneBinding.milestoneDescription;
|
||||
repository = RepositoryContext.fromIntent(getIntent());
|
||||
|
||||
milestoneTitle.requestFocus();
|
||||
assert imm != null;
|
||||
@ -93,12 +94,6 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
|
||||
String newMilestoneTitle = milestoneTitle.getText().toString();
|
||||
String newMilestoneDescription = milestoneDescription.getText().toString();
|
||||
String newMilestoneDueDate = milestoneDueDate.getText().toString();
|
||||
@ -130,7 +125,7 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
||||
|
||||
finalMilestoneDueDate = (AppUtil.customDateCombine(AppUtil.customDateFormat(newMilestoneDueDate)));
|
||||
}
|
||||
else if (new Version(tinyDb.getString("giteaVersion")).less("1.10.0")) {
|
||||
else if (!getAccount().requiresVersion("1.10.0")) {
|
||||
|
||||
// if Gitea version is less than 1.10.0 DueDate is required
|
||||
Toasty.warning(ctx, getString(R.string.milestoneDateEmpty));
|
||||
@ -138,7 +133,7 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
||||
}
|
||||
|
||||
disableProcessButton();
|
||||
createNewMilestone(Authorization.get(ctx), repoOwner, repoName, newMilestoneTitle, newMilestoneDescription, finalMilestoneDueDate);
|
||||
createNewMilestone(getAccount().getAuthorization(), repository.getOwner(), repository.getName(), newMilestoneTitle, newMilestoneDescription, finalMilestoneDueDate);
|
||||
}
|
||||
|
||||
private void createNewMilestone(final String token, String repoOwner, String repoName, String newMilestoneTitle, String newMilestoneDescription, String newMilestoneDueDate) {
|
||||
@ -148,7 +143,7 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
||||
Call<Milestones> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getApiInterface(appCtx)
|
||||
.getApiInterface(ctx)
|
||||
.createMilestone(token, repoOwner, repoName, createMilestone);
|
||||
|
||||
call.enqueue(new Callback<Milestones>() {
|
||||
@ -160,8 +155,9 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
||||
|
||||
if(response.code() == 201) {
|
||||
|
||||
TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||
tinyDb.putBoolean("milestoneCreated", true);
|
||||
Intent result = new Intent();
|
||||
result.putExtra("milestoneCreated", true);
|
||||
setResult(201, result);
|
||||
Toasty.success(ctx, getString(R.string.milestoneCreated));
|
||||
enableProcessButton();
|
||||
finish();
|
||||
@ -224,4 +220,10 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
||||
createNewMilestoneButton.setEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
repository.checkAccountSwitch(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,7 +16,6 @@ import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.ActivityCreateNewUserBinding;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
@ -110,7 +109,7 @@ public class CreateNewUserActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
disableProcessButton();
|
||||
createNewUser(Authorization.get(ctx), newFullName, newUserName, newUserEmail, newUserPassword);
|
||||
createNewUser(getAccount().getAuthorization(), newFullName, newUserName, newUserEmail, newUserPassword);
|
||||
}
|
||||
|
||||
private void createNewUser(final String instanceToken, String newFullName, String newUserName, String newUserEmail, String newUserPassword) {
|
||||
@ -120,7 +119,7 @@ public class CreateNewUserActivity extends BaseActivity {
|
||||
Call<UserInfo> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getApiInterface(appCtx)
|
||||
.getApiInterface(ctx)
|
||||
.createNewUser(instanceToken, createUser);
|
||||
|
||||
call.enqueue(new Callback<UserInfo>() {
|
||||
|
@ -15,10 +15,9 @@ import org.gitnex.tea4j.models.UserOrganizations;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.ActivityCreateOrganizationBinding;
|
||||
import org.mian.gitnex.fragments.OrganizationsFragment;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
@ -124,7 +123,7 @@ public class CreateOrganizationActivity extends BaseActivity {
|
||||
else {
|
||||
|
||||
disableProcessButton();
|
||||
createNewOrganization(Authorization.get(ctx), newOrgName, newOrgDesc);
|
||||
createNewOrganization(getAccount().getAuthorization(), newOrgName, newOrgDesc);
|
||||
}
|
||||
|
||||
}
|
||||
@ -134,7 +133,7 @@ public class CreateOrganizationActivity extends BaseActivity {
|
||||
UserOrganizations createOrganization = new UserOrganizations(orgName, null, orgDesc, null, null);
|
||||
|
||||
Call<UserOrganizations> call = RetrofitClient
|
||||
.getApiInterface(appCtx)
|
||||
.getApiInterface(ctx)
|
||||
.createNewOrganization(token, createOrganization);
|
||||
|
||||
call.enqueue(new Callback<UserOrganizations>() {
|
||||
@ -143,9 +142,7 @@ public class CreateOrganizationActivity extends BaseActivity {
|
||||
public void onResponse(@NonNull Call<UserOrganizations> call, @NonNull retrofit2.Response<UserOrganizations> response) {
|
||||
|
||||
if(response.code() == 201) {
|
||||
|
||||
TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||
tinyDb.putBoolean("orgCreated", true);
|
||||
OrganizationsFragment.orgCreated = true;
|
||||
enableProcessButton();
|
||||
Toasty.success(ctx, getString(R.string.orgCreated));
|
||||
finish();
|
||||
|
@ -23,10 +23,10 @@ import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.ActivityCreatePrBinding;
|
||||
import org.mian.gitnex.databinding.CustomLabelsSelectionDialogBinding;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.Constants;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
@ -41,18 +41,13 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
||||
|
||||
private View.OnClickListener onClickListener;
|
||||
private ActivityCreatePrBinding viewBinding;
|
||||
private CustomLabelsSelectionDialogBinding labelsBinding;
|
||||
private int resultLimit = Constants.resultLimitOldGiteaInstances;
|
||||
private Dialog dialogLabels;
|
||||
private String labelsSetter;
|
||||
private List<Integer> labelsIds = new ArrayList<>();
|
||||
private List<String> assignees = new ArrayList<>();
|
||||
private final List<String> assignees = new ArrayList<>();
|
||||
private int milestoneId;
|
||||
|
||||
private String loginUid;
|
||||
private String instanceToken;
|
||||
private String repoOwner;
|
||||
private String repoName;
|
||||
private RepositoryContext repository;
|
||||
|
||||
private LabelsListAdapter labelsAdapter;
|
||||
|
||||
@ -69,15 +64,10 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
||||
viewBinding = ActivityCreatePrBinding.inflate(getLayoutInflater());
|
||||
setContentView(viewBinding.getRoot());
|
||||
|
||||
loginUid = tinyDB.getString("loginUid");
|
||||
String repoFullName = tinyDB.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
repoOwner = parts[0];
|
||||
repoName = parts[1];
|
||||
instanceToken = "token " + tinyDB.getString(loginUid + "-token");
|
||||
repository = RepositoryContext.fromIntent(getIntent());
|
||||
|
||||
// require gitea 1.12 or higher
|
||||
if(new Version(tinyDB.getString("giteaVersion")).higherOrEqual("1.12.0")) {
|
||||
if(getAccount().requiresVersion("1.12.0")) {
|
||||
|
||||
resultLimit = Constants.resultLimitNewGiteaInstances;
|
||||
}
|
||||
@ -106,14 +96,14 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
||||
|
||||
disableProcessButton();
|
||||
|
||||
getMilestones(repoOwner, repoName, resultLimit);
|
||||
getBranches(repoOwner, repoName);
|
||||
getMilestones(repository.getOwner(), repository.getName(), resultLimit);
|
||||
getBranches(repository.getOwner(), repository.getName());
|
||||
|
||||
viewBinding.prLabels.setOnClickListener(prLabels -> showLabels());
|
||||
|
||||
viewBinding.createPr.setOnClickListener(createPr -> processPullRequest());
|
||||
|
||||
if(!tinyDB.getBoolean("canPush")) {
|
||||
if(!repository.getPermissions().canPush()) {
|
||||
viewBinding.prDueDateLayout.setVisibility(View.GONE);
|
||||
viewBinding.prLabelsLayout.setVisibility(View.GONE);
|
||||
}
|
||||
@ -167,11 +157,11 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
||||
|
||||
private void createPullRequest(String prTitle, String prDescription, String mergeInto, String pullFrom, int milestoneId, String dueDate, List<String> assignees) {
|
||||
|
||||
CreatePullRequest createPullRequest = new CreatePullRequest(prTitle, prDescription, loginUid, mergeInto, pullFrom, milestoneId, dueDate, assignees, labelsIds);
|
||||
CreatePullRequest createPullRequest = new CreatePullRequest(prTitle, prDescription, getAccount().getAccount().getUserName(), mergeInto, pullFrom, milestoneId, dueDate, assignees, labelsIds);
|
||||
|
||||
Call<Void> transferCall = RetrofitClient
|
||||
.getApiInterface(appCtx)
|
||||
.createPullRequest(instanceToken, repoOwner, repoName, createPullRequest);
|
||||
.getApiInterface(ctx)
|
||||
.createPullRequest(getAccount().getAuthorization(), repository.getOwner(), repository.getName(), createPullRequest);
|
||||
|
||||
transferCall.enqueue(new Callback<Void>() {
|
||||
|
||||
@ -214,7 +204,7 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
||||
@Override
|
||||
public void labelsInterface(List<String> data) {
|
||||
|
||||
labelsSetter = String.valueOf(data);
|
||||
String labelsSetter = String.valueOf(data);
|
||||
viewBinding.prLabels.setText(labelsSetter.replace("]", "").replace("[", ""));
|
||||
}
|
||||
|
||||
@ -233,7 +223,8 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
||||
dialogLabels.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
}
|
||||
|
||||
labelsBinding = CustomLabelsSelectionDialogBinding.inflate(LayoutInflater.from(ctx));
|
||||
org.mian.gitnex.databinding.CustomLabelsSelectionDialogBinding labelsBinding = CustomLabelsSelectionDialogBinding
|
||||
.inflate(LayoutInflater.from(ctx));
|
||||
|
||||
View view = labelsBinding.getRoot();
|
||||
dialogLabels.setContentView(view);
|
||||
@ -241,14 +232,14 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
||||
labelsBinding.cancel.setOnClickListener(editProperties -> dialogLabels.dismiss());
|
||||
|
||||
dialogLabels.show();
|
||||
LabelsActions.getRepositoryLabels(ctx, repoOwner, repoName, labelsList, dialogLabels, labelsAdapter, labelsBinding);
|
||||
LabelsActions.getRepositoryLabels(ctx, repository.getOwner(), repository.getName(), labelsList, dialogLabels, labelsAdapter, labelsBinding);
|
||||
}
|
||||
|
||||
private void getBranches(String repoOwner, String repoName) {
|
||||
|
||||
Call<List<Branches>> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.getBranches(Authorization.get(ctx), repoOwner, repoName);
|
||||
.getBranches(getAccount().getAuthorization(), repoOwner, repoName);
|
||||
|
||||
call.enqueue(new Callback<List<Branches>>() {
|
||||
|
||||
@ -296,8 +287,8 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
||||
|
||||
String msState = "open";
|
||||
Call<List<Milestones>> call = RetrofitClient
|
||||
.getApiInterface(appCtx)
|
||||
.getMilestones(Authorization.get(ctx), repoOwner, repoName, 1, resultLimit, msState);
|
||||
.getApiInterface(ctx)
|
||||
.getMilestones(getAccount().getAuthorization(), repoOwner, repoName, 1, resultLimit, msState);
|
||||
|
||||
call.enqueue(new Callback<List<Milestones>>() {
|
||||
|
||||
@ -375,4 +366,10 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
||||
|
||||
viewBinding.createPr.setEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
repository.checkAccountSwitch(this);
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package org.mian.gitnex.activities;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
@ -23,8 +24,8 @@ import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.ActivityCreateReleaseBinding;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
@ -48,8 +49,7 @@ public class CreateReleaseActivity extends BaseActivity {
|
||||
private String selectedBranch;
|
||||
private Button createNewTag;
|
||||
|
||||
private String repoOwner;
|
||||
private String repoName;
|
||||
private RepositoryContext repository;
|
||||
|
||||
List<Branches> branchesList = new ArrayList<>();
|
||||
|
||||
@ -66,10 +66,7 @@ public class CreateReleaseActivity extends BaseActivity {
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
String repoFullName = tinyDB.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
repoOwner = parts[0];
|
||||
repoName = parts[1];
|
||||
repository = RepositoryContext.fromIntent(getIntent());
|
||||
|
||||
closeActivity = activityCreateReleaseBinding.close;
|
||||
releaseTagName = activityCreateReleaseBinding.releaseTagName;
|
||||
@ -97,7 +94,7 @@ public class CreateReleaseActivity extends BaseActivity {
|
||||
closeActivity.setOnClickListener(onClickListener);
|
||||
|
||||
releaseBranch = activityCreateReleaseBinding.releaseBranch;
|
||||
getBranches(Authorization.get(ctx), repoOwner, repoName);
|
||||
getBranches(getAccount().getAuthorization(), repository.getOwner(), repository.getName());
|
||||
|
||||
createNewRelease = activityCreateReleaseBinding.createNewRelease;
|
||||
createNewTag = activityCreateReleaseBinding.createNewTag;
|
||||
@ -143,7 +140,7 @@ public class CreateReleaseActivity extends BaseActivity {
|
||||
|
||||
Call<GitTag> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.createTag(Authorization.get(ctx), repoOwner, repoName, createReleaseJson);
|
||||
.createTag(getAccount().getAuthorization(), repository.getOwner(), repository.getName(), createReleaseJson);
|
||||
|
||||
call.enqueue(new Callback<GitTag>() {
|
||||
|
||||
@ -151,7 +148,6 @@ public class CreateReleaseActivity extends BaseActivity {
|
||||
public void onResponse(@NonNull Call<GitTag> call, @NonNull retrofit2.Response<GitTag> response) {
|
||||
|
||||
if (response.code() == 201) {
|
||||
tinyDB.putBoolean("updateReleases", true);
|
||||
Toasty.success(ctx, getString(R.string.tagCreated));
|
||||
finish();
|
||||
}
|
||||
@ -225,7 +221,7 @@ public class CreateReleaseActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
disableProcessButton();
|
||||
createNewReleaseFunc(Authorization.get(ctx), repoOwner, repoName, newReleaseTagName, newReleaseTitle, newReleaseContent, selectedBranch, newReleaseType, newReleaseDraft);
|
||||
createNewReleaseFunc(getAccount().getAuthorization(), repository.getOwner(), repository.getName(), newReleaseTagName, newReleaseTitle, newReleaseContent, selectedBranch, newReleaseType, newReleaseDraft);
|
||||
}
|
||||
|
||||
private void createNewReleaseFunc(final String token, String repoOwner, String repoName, String newReleaseTagName, String newReleaseTitle, String newReleaseContent, String selectedBranch, boolean newReleaseType, boolean newReleaseDraft) {
|
||||
@ -245,9 +241,10 @@ public class CreateReleaseActivity extends BaseActivity {
|
||||
|
||||
if (response.code() == 201) {
|
||||
|
||||
tinyDB.putBoolean("updateReleases", true);
|
||||
Intent result = new Intent();
|
||||
result.putExtra("updateReleases", true);
|
||||
setResult(201, result);
|
||||
Toasty.success(ctx, getString(R.string.releaseCreatedText));
|
||||
enableProcessButton();
|
||||
finish();
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
@ -354,4 +351,10 @@ public class CreateReleaseActivity extends BaseActivity {
|
||||
createNewRelease.setEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
repository.checkAccountSwitch(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -21,8 +21,6 @@ import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.ActivityCreateRepoBinding;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@ -46,7 +44,6 @@ public class CreateRepoActivity extends BaseActivity {
|
||||
private CheckBox repoAccess;
|
||||
|
||||
private String loginUid;
|
||||
private String userLogin;
|
||||
|
||||
private String selectedOwner;
|
||||
|
||||
@ -66,8 +63,7 @@ public class CreateRepoActivity extends BaseActivity {
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(ctx);
|
||||
|
||||
loginUid = tinyDB.getString("loginUid");
|
||||
userLogin = tinyDB.getString("userLogin");
|
||||
loginUid = getAccount().getAccount().getUserName();
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
@ -84,7 +80,7 @@ public class CreateRepoActivity extends BaseActivity {
|
||||
closeActivity.setOnClickListener(onClickListener);
|
||||
|
||||
spinner = activityCreateRepoBinding.ownerSpinner;
|
||||
getOrganizations(Authorization.get(ctx), userLogin);
|
||||
getOrganizations(getAccount().getAuthorization(), loginUid);
|
||||
|
||||
createRepo = activityCreateRepoBinding.createNewRepoButton;
|
||||
disableProcessButton();
|
||||
@ -147,7 +143,7 @@ public class CreateRepoActivity extends BaseActivity {
|
||||
else {
|
||||
|
||||
disableProcessButton();
|
||||
createNewRepository(Authorization.get(ctx), loginUid, newRepoName, newRepoDesc, selectedOwner, newRepoAccess);
|
||||
createNewRepository(getAccount().getAuthorization(), loginUid, newRepoName, newRepoDesc, selectedOwner, newRepoAccess);
|
||||
}
|
||||
}
|
||||
|
||||
@ -176,8 +172,7 @@ public class CreateRepoActivity extends BaseActivity {
|
||||
|
||||
if(response.code() == 201) {
|
||||
|
||||
TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||
tinyDb.putBoolean("repoCreated", true);
|
||||
MainActivity.repoCreated = true;
|
||||
Toasty.success(ctx, getString(R.string.repoCreated));
|
||||
enableProcessButton();
|
||||
finish();
|
||||
@ -235,9 +230,8 @@ public class CreateRepoActivity extends BaseActivity {
|
||||
|
||||
for(int i = 0; i < organizationsList_.size(); i++) {
|
||||
|
||||
if(!tinyDB.getString("organizationId").isEmpty()) {
|
||||
|
||||
if(Integer.parseInt(tinyDB.getString("organizationId")) == organizationsList_.get(i).getId()) {
|
||||
if(!getIntent().getStringExtra("orgName").equals("")) {
|
||||
if(getIntent().getStringExtra("orgName").equals(organizationsList_.get(i).getUsername())) {
|
||||
organizationId = i + 1;
|
||||
}
|
||||
}
|
||||
@ -253,7 +247,7 @@ public class CreateRepoActivity extends BaseActivity {
|
||||
|
||||
spinner.setOnItemClickListener ((parent, view, position, id) -> selectedOwner = organizationsList.get(position).getUsername());
|
||||
|
||||
if(tinyDB.getBoolean("organizationAction") & organizationId != 0) {
|
||||
if(getIntent().getBooleanExtra("organizationAction", false) && organizationId != 0) {
|
||||
|
||||
int selectOwnerById = organizationId;
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
@ -261,8 +255,7 @@ public class CreateRepoActivity extends BaseActivity {
|
||||
spinner.setText(organizationsList.get(selectOwnerById).getUsername(), false);
|
||||
selectedOwner = organizationsList.get(selectOwnerById).getUsername();
|
||||
}, 500);
|
||||
|
||||
tinyDB.putBoolean("organizationAction", false);
|
||||
getIntent().removeExtra("organizationAction");
|
||||
}
|
||||
|
||||
enableProcessButton();
|
||||
|
@ -16,10 +16,9 @@ import org.gitnex.tea4j.models.Teams;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.ActivityCreateTeamByOrgBinding;
|
||||
import org.mian.gitnex.fragments.TeamsByOrgFragment;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@ -224,10 +223,8 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
||||
|
||||
private void processCreateTeam() {
|
||||
|
||||
final TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
final String orgName = tinyDb.getString("orgName");;
|
||||
final String instanceToken = getAccount().getAuthorization();
|
||||
final String orgName = getIntent().getStringExtra("orgName");
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
String newTeamName = teamName.getText().toString();
|
||||
@ -281,7 +278,7 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
||||
newTeamAccessControls_.set(i, newTeamAccessControls_.get(i).trim());
|
||||
}
|
||||
|
||||
createNewTeamCall(instanceToken, orgName, newTeamName, newTeamDesc, newTeamPermission, newTeamAccessControls_, loginUid);
|
||||
createNewTeamCall(instanceToken, orgName, newTeamName, newTeamDesc, newTeamPermission, newTeamAccessControls_, getAccount().getAccount().getUserName());
|
||||
}
|
||||
|
||||
private void createNewTeamCall(final String instanceToken, String orgName, String newTeamName, String newTeamDesc, String newTeamPermission, List<String> newTeamAccessControls, String loginUid) {
|
||||
@ -292,7 +289,7 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
||||
|
||||
call3 = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.createTeamsByOrg(Authorization.get(ctx), orgName, createNewTeamJson);
|
||||
.createTeamsByOrg(getAccount().getAuthorization(), orgName, createNewTeamJson);
|
||||
|
||||
call3.enqueue(new Callback<Teams>() {
|
||||
|
||||
@ -303,8 +300,7 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
||||
|
||||
if(response2.code() == 201) {
|
||||
|
||||
TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||
tinyDb.putBoolean("resumeTeams", true);
|
||||
TeamsByOrgFragment.resumeTeams = true;
|
||||
|
||||
Toasty.success(ctx, getString(R.string.teamCreated));
|
||||
finish();
|
||||
|
@ -19,12 +19,12 @@ import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.database.api.BaseApi;
|
||||
import org.mian.gitnex.database.api.RepositoriesApi;
|
||||
import org.mian.gitnex.database.api.UserAccountsApi;
|
||||
import org.mian.gitnex.database.models.Repository;
|
||||
import org.mian.gitnex.database.models.UserAccount;
|
||||
import org.mian.gitnex.databinding.ActivityDeeplinksBinding;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.UrlHelper;
|
||||
import org.mian.gitnex.helpers.contexts.IssueContext;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -70,16 +70,17 @@ public class DeepLinksActivity extends BaseActivity {
|
||||
assert data != null;
|
||||
|
||||
// check for login
|
||||
if(!tinyDB.getBoolean("loggedInMode")) {
|
||||
if(tinyDB.getInt("currentActiveAccountId", -1) <= -1) {
|
||||
Intent loginIntent = new Intent(ctx, LoginActivity.class);
|
||||
loginIntent.putExtra("instanceUrl", data.getHost());
|
||||
ctx.startActivity(loginIntent);
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
// check for the links(URI) to be in the db
|
||||
UserAccountsApi userAccountsApi = BaseApi.getInstance(ctx, UserAccountsApi.class);
|
||||
List<UserAccount> userAccounts = userAccountsApi.usersAccounts();
|
||||
List<UserAccount> userAccounts = userAccountsApi.loggedInUserAccounts();
|
||||
|
||||
for(UserAccount userAccount : userAccounts) {
|
||||
|
||||
@ -94,7 +95,7 @@ public class DeepLinksActivity extends BaseActivity {
|
||||
|
||||
accountFound = true;
|
||||
|
||||
AppUtil.switchToAccount(ctx, userAccount);
|
||||
AppUtil.switchToAccount(ctx, userAccount, true);
|
||||
break;
|
||||
|
||||
}
|
||||
@ -114,7 +115,7 @@ public class DeepLinksActivity extends BaseActivity {
|
||||
ctx.startActivity(mainIntent);
|
||||
finish();
|
||||
}
|
||||
else if(data.getLastPathSegment().equals(tinyDB.getString("userLogin"))) { // your user profile
|
||||
else if(data.getLastPathSegment().equals(getAccount().getAccount().getUserName())) { // your user profile
|
||||
mainIntent.putExtra("launchFragmentByLinkHandler", "profile");
|
||||
ctx.startActivity(mainIntent);
|
||||
finish();
|
||||
@ -177,29 +178,29 @@ public class DeepLinksActivity extends BaseActivity {
|
||||
issueIntent.putExtra("issueComment", urlSplitted[1]);
|
||||
}
|
||||
|
||||
tinyDB.putString("issueNumber", data.getLastPathSegment());
|
||||
tinyDB.putString("issueType", "Issue");
|
||||
|
||||
tinyDB.putString("repoFullName", data.getPathSegments().get(0) + "/" + data.getPathSegments().get(1));
|
||||
IssueContext issue = new IssueContext(
|
||||
new RepositoryContext(data.getPathSegments().get(0), data.getPathSegments().get(1), ctx),
|
||||
Integer.parseInt(data.getLastPathSegment()),
|
||||
"Issue"
|
||||
);
|
||||
|
||||
final String repoOwner = data.getPathSegments().get(0);
|
||||
final String repoName = data.getPathSegments().get(1);
|
||||
|
||||
int currentActiveAccountId = tinyDB.getInt("currentActiveAccountId");
|
||||
RepositoriesApi repositoryData = BaseApi.getInstance(ctx, RepositoriesApi.class);
|
||||
assert repositoryData != null;
|
||||
|
||||
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
|
||||
int repoId;
|
||||
if(count == 0) {
|
||||
|
||||
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
tinyDB.putLong("repositoryId", id);
|
||||
repoId = (int) repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
}
|
||||
else {
|
||||
|
||||
Repository dataRepo = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
tinyDB.putLong("repositoryId", dataRepo.getRepositoryId());
|
||||
repoId = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName).getRepositoryId();
|
||||
}
|
||||
issue.getRepository().setRepositoryId(repoId);
|
||||
|
||||
ctx.startActivity(issueIntent);
|
||||
finish();
|
||||
@ -383,57 +384,33 @@ public class DeepLinksActivity extends BaseActivity {
|
||||
|
||||
assert prInfo != null;
|
||||
|
||||
issueIntent.putExtra("issueNumber", index);
|
||||
issueIntent.putExtra("prMergeable", prInfo.isMergeable());
|
||||
issueIntent.putExtra("openedFromLink", "true");
|
||||
|
||||
if(prInfo.getHead() != null) {
|
||||
|
||||
issueIntent.putExtra("prHeadBranch", prInfo.getHead().getRef());
|
||||
tinyDB.putString("prHeadBranch", prInfo.getHead().getRef());
|
||||
|
||||
if(prInfo.getHead().getRepo() != null) {
|
||||
|
||||
tinyDB.putString("prIsFork", String.valueOf(prInfo.getHead().getRepo().isFork()));
|
||||
tinyDB.putString("prForkFullName", prInfo.getHead().getRepo().getFull_name());
|
||||
}
|
||||
else {
|
||||
|
||||
// pull was done from a deleted fork
|
||||
tinyDB.putString("prIsFork", "true");
|
||||
tinyDB.putString("prForkFullName", ctx.getString(R.string.prDeletedFork));
|
||||
}
|
||||
}
|
||||
|
||||
tinyDB.putString("issueNumber", String.valueOf(index));
|
||||
tinyDB.putString("prMergeable", String.valueOf(prInfo.isMergeable()));
|
||||
tinyDB.putString("issueType", "Pull");
|
||||
|
||||
tinyDB.putString("repoFullName", repoOwner + "/" + repoName);
|
||||
IssueContext issue = new IssueContext(prInfo, new RepositoryContext(repoOwner, repoName, ctx));
|
||||
|
||||
int currentActiveAccountId = tinyDB.getInt("currentActiveAccountId");
|
||||
RepositoriesApi repositoryData = BaseApi.getInstance(ctx, RepositoriesApi.class);
|
||||
assert repositoryData != null;
|
||||
|
||||
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
|
||||
int id;
|
||||
if(count == 0) {
|
||||
|
||||
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
tinyDB.putLong("repositoryId", id);
|
||||
id = (int) repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
}
|
||||
else {
|
||||
|
||||
Repository dataRepo = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
tinyDB.putLong("repositoryId", dataRepo.getRepositoryId());
|
||||
id = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName).getRepositoryId();
|
||||
}
|
||||
issue.getRepository().setRepositoryId(id);
|
||||
|
||||
issueIntent.putExtra(IssueContext.INTENT_EXTRA, issue);
|
||||
ctx.startActivity(issueIntent);
|
||||
finish();
|
||||
}
|
||||
|
||||
else {
|
||||
|
||||
ctx.startActivity(issueIntent);
|
||||
ctx.startActivity(mainIntent);
|
||||
finish();
|
||||
Log.e("onFailure-links-pr", String.valueOf(response.code()));
|
||||
}
|
||||
@ -459,52 +436,35 @@ public class DeepLinksActivity extends BaseActivity {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<UserRepositories> call, @NonNull retrofit2.Response<UserRepositories> response) {
|
||||
|
||||
UserRepositories repoInfo = response.body();
|
||||
|
||||
if (response.code() == 200) {
|
||||
|
||||
assert repoInfo != null;
|
||||
|
||||
repoIntent.putExtra("repoFullName", repoInfo.getFullName());
|
||||
RepositoryContext repo = new RepositoryContext(repoInfo, ctx);
|
||||
|
||||
repoIntent.putExtra("goToSection", "yes");
|
||||
repoIntent.putExtra("goToSectionType", type);
|
||||
|
||||
tinyDB.putString("repoFullName", repoInfo.getFullName());
|
||||
if(repoInfo.getPrivateFlag()) {
|
||||
|
||||
tinyDB.putString("repoType", getResources().getString(R.string.strPrivate));
|
||||
}
|
||||
else {
|
||||
|
||||
tinyDB.putString("repoType", getResources().getString(R.string.strPublic));
|
||||
}
|
||||
tinyDB.putBoolean("isRepoAdmin", repoInfo.getPermissions().isAdmin());
|
||||
tinyDB.putBoolean("canPush", repoInfo.getPermissions().canPush());
|
||||
tinyDB.putString("repoBranch", repoInfo.getDefault_branch());
|
||||
|
||||
int currentActiveAccountId = tinyDB.getInt("currentActiveAccountId");
|
||||
RepositoriesApi repositoryData = BaseApi.getInstance(ctx, RepositoriesApi.class);
|
||||
|
||||
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
|
||||
int id;
|
||||
if(count == 0) {
|
||||
|
||||
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
tinyDB.putLong("repositoryId", id);
|
||||
id = (int) repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
}
|
||||
else {
|
||||
|
||||
Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
tinyDB.putLong("repositoryId", data.getRepositoryId());
|
||||
id = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName).getRepositoryId();
|
||||
}
|
||||
|
||||
repo.setRepositoryId(id);
|
||||
repoIntent.putExtra(RepositoryContext.INTENT_EXTRA, repo);
|
||||
|
||||
ctx.startActivity(repoIntent);
|
||||
finish();
|
||||
}
|
||||
|
||||
else {
|
||||
|
||||
} else {
|
||||
ctx.startActivity(mainIntent);
|
||||
finish();
|
||||
Log.e("onFailure-goToRepo", String.valueOf(response.code()));
|
||||
@ -536,12 +496,8 @@ public class DeepLinksActivity extends BaseActivity {
|
||||
else if(response.code() == 200) { // org
|
||||
assert response.body() != null;
|
||||
orgIntent.putExtra("orgName", response.body().getUsername());
|
||||
|
||||
|
||||
TinyDB tinyDb = TinyDB.getInstance(ctx);
|
||||
tinyDb.putString("orgName", response.body().getUsername());
|
||||
tinyDb.putString("organizationId", String.valueOf(response.body().getId()));
|
||||
tinyDb.putBoolean("organizationAction", true);
|
||||
orgIntent.putExtra("organizationId", response.body().getId());
|
||||
orgIntent.putExtra("organizationAction", true);
|
||||
ctx.startActivity(orgIntent);
|
||||
finish();
|
||||
}
|
||||
@ -629,73 +585,69 @@ public class DeepLinksActivity extends BaseActivity {
|
||||
private void showNoActionButtons() {
|
||||
viewBinding.progressBar.setVisibility(View.GONE);
|
||||
|
||||
if(tinyDB.getInt("defaultScreenId") == 1) { // repos
|
||||
|
||||
mainIntent.putExtra("launchFragmentByLinkHandler", "repos");
|
||||
ctx.startActivity(mainIntent);
|
||||
finish();
|
||||
}
|
||||
else if(tinyDB.getInt("defaultScreenId") == 2) { // org
|
||||
|
||||
mainIntent.putExtra("launchFragmentByLinkHandler", "org");
|
||||
ctx.startActivity(mainIntent);
|
||||
finish();
|
||||
}
|
||||
else if(tinyDB.getInt("defaultScreenId") == 3) { // notifications
|
||||
|
||||
mainIntent.putExtra("launchFragmentByLinkHandler", "notification");
|
||||
ctx.startActivity(mainIntent);
|
||||
finish();
|
||||
}
|
||||
else if(tinyDB.getInt("defaultScreenId") == 4) { // explore
|
||||
|
||||
mainIntent.putExtra("launchFragmentByLinkHandler", "explore");
|
||||
ctx.startActivity(mainIntent);
|
||||
finish();
|
||||
}
|
||||
else if(tinyDB.getInt("defaultScreenId") == 0) { // show options
|
||||
|
||||
viewBinding.noActionFrame.setVisibility(View.VISIBLE);
|
||||
viewBinding.addNewAccountFrame.setVisibility(View.GONE);
|
||||
|
||||
viewBinding.repository.setOnClickListener(repository -> {
|
||||
|
||||
tinyDB.putInt("defaultScreenId", 1);
|
||||
switch(tinyDB.getInt("defaultScreenId")) {
|
||||
case 1: // repos
|
||||
mainIntent.putExtra("launchFragmentByLinkHandler", "repos");
|
||||
ctx.startActivity(mainIntent);
|
||||
finish();
|
||||
});
|
||||
|
||||
viewBinding.organization.setOnClickListener(organization -> {
|
||||
|
||||
tinyDB.putInt("defaultScreenId", 2);
|
||||
break;
|
||||
case 2: // org
|
||||
mainIntent.putExtra("launchFragmentByLinkHandler", "org");
|
||||
ctx.startActivity(mainIntent);
|
||||
finish();
|
||||
});
|
||||
|
||||
viewBinding.notification.setOnClickListener(notification -> {
|
||||
|
||||
tinyDB.putInt("defaultScreenId", 3);
|
||||
break;
|
||||
case 3: // notifications
|
||||
mainIntent.putExtra("launchFragmentByLinkHandler", "notification");
|
||||
ctx.startActivity(mainIntent);
|
||||
finish();
|
||||
});
|
||||
|
||||
viewBinding.explore.setOnClickListener(explore -> {
|
||||
|
||||
tinyDB.putInt("defaultScreenId", 4);
|
||||
break;
|
||||
case 4: // explore
|
||||
mainIntent.putExtra("launchFragmentByLinkHandler", "explore");
|
||||
ctx.startActivity(mainIntent);
|
||||
finish();
|
||||
});
|
||||
break;
|
||||
default: // show options
|
||||
viewBinding.noActionFrame.setVisibility(View.VISIBLE);
|
||||
viewBinding.addNewAccountFrame.setVisibility(View.GONE);
|
||||
|
||||
viewBinding.launchApp2.setOnClickListener(launchApp2 -> {
|
||||
viewBinding.repository.setOnClickListener(repository -> {
|
||||
|
||||
tinyDB.putInt("defaultScreenId", 0);
|
||||
ctx.startActivity(mainIntent);
|
||||
finish();
|
||||
});
|
||||
tinyDB.putInt("defaultScreenId", 1);
|
||||
mainIntent.putExtra("launchFragmentByLinkHandler", "repos");
|
||||
ctx.startActivity(mainIntent);
|
||||
finish();
|
||||
});
|
||||
|
||||
viewBinding.organization.setOnClickListener(organization -> {
|
||||
|
||||
tinyDB.putInt("defaultScreenId", 2);
|
||||
mainIntent.putExtra("launchFragmentByLinkHandler", "org");
|
||||
ctx.startActivity(mainIntent);
|
||||
finish();
|
||||
});
|
||||
|
||||
viewBinding.notification.setOnClickListener(notification -> {
|
||||
|
||||
tinyDB.putInt("defaultScreenId", 3);
|
||||
mainIntent.putExtra("launchFragmentByLinkHandler", "notification");
|
||||
ctx.startActivity(mainIntent);
|
||||
finish();
|
||||
});
|
||||
|
||||
viewBinding.explore.setOnClickListener(explore -> {
|
||||
|
||||
tinyDB.putInt("defaultScreenId", 4);
|
||||
mainIntent.putExtra("launchFragmentByLinkHandler", "explore");
|
||||
ctx.startActivity(mainIntent);
|
||||
finish();
|
||||
});
|
||||
|
||||
viewBinding.launchApp2.setOnClickListener(launchApp2 -> {
|
||||
|
||||
tinyDB.putInt("defaultScreenId", 0);
|
||||
ctx.startActivity(mainIntent);
|
||||
finish();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package org.mian.gitnex.activities;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.DatePickerDialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
@ -24,12 +25,13 @@ import org.gitnex.tea4j.models.Milestones;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.ActivityEditIssueBinding;
|
||||
import org.mian.gitnex.fragments.IssuesFragment;
|
||||
import org.mian.gitnex.fragments.PullRequestsFragment;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.Constants;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import org.mian.gitnex.helpers.contexts.IssueContext;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
@ -58,11 +60,7 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
||||
|
||||
List<Milestones> milestonesList = new ArrayList<>();
|
||||
|
||||
private String loginUid;
|
||||
private String instanceToken;
|
||||
private String repoOwner;
|
||||
private String repoName;
|
||||
private int issueIndex;
|
||||
private IssueContext issue;
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
@Override
|
||||
@ -75,13 +73,7 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
loginUid = tinyDB.getString("loginUid");
|
||||
instanceToken = "token " + tinyDB.getString(loginUid + "-token");
|
||||
String repoFullName = tinyDB.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
repoOwner = parts[0];
|
||||
repoName = parts[1];
|
||||
issueIndex = Integer.parseInt(tinyDB.getString("issueNumber"));
|
||||
issue = IssueContext.fromIntent(getIntent());
|
||||
|
||||
ImageView closeActivity = activityEditIssueBinding.close;
|
||||
editIssueButton = activityEditIssueBinding.editIssueButton;
|
||||
@ -91,7 +83,7 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
||||
editIssueDueDate = activityEditIssueBinding.editIssueDueDate;
|
||||
|
||||
// if gitea is 1.12 or higher use the new limit
|
||||
if(new Version(tinyDB.getString("giteaVersion")).higherOrEqual("1.12.0")) {
|
||||
if(getAccount().requiresVersion("1.12.0")) {
|
||||
|
||||
resultLimit = Constants.resultLimitNewGiteaInstances;
|
||||
}
|
||||
@ -119,22 +111,19 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
||||
editIssueDueDate.setOnClickListener(this);
|
||||
editIssueButton.setOnClickListener(this);
|
||||
|
||||
if(!tinyDB.getString("issueNumber").isEmpty()) {
|
||||
if(issue.getIssueType().equalsIgnoreCase("Pull")) {
|
||||
|
||||
if(tinyDB.getString("issueType").equalsIgnoreCase("Pull")) {
|
||||
toolbar_title.setText(getString(R.string.editPrNavHeader, String.valueOf(issue.getIssueIndex())));
|
||||
}
|
||||
else {
|
||||
|
||||
toolbar_title.setText(getString(R.string.editPrNavHeader, String.valueOf(issueIndex)));
|
||||
}
|
||||
else {
|
||||
|
||||
toolbar_title.setText(getString(R.string.editIssueNavHeader, String.valueOf(issueIndex)));
|
||||
}
|
||||
toolbar_title.setText(getString(R.string.editIssueNavHeader, String.valueOf(issue.getIssueIndex())));
|
||||
}
|
||||
|
||||
disableProcessButton();
|
||||
getIssue(instanceToken, loginUid, repoOwner, repoName, issueIndex, resultLimit);
|
||||
getIssue(issue.getRepository().getOwner(), issue.getRepository().getName(), issue.getIssueIndex(), resultLimit);
|
||||
|
||||
if(!tinyDB.getBoolean("canPush")) {
|
||||
if(!issue.getRepository().getPermissions().canPush()) {
|
||||
findViewById(R.id.editIssueMilestoneSpinnerLayout).setVisibility(View.GONE);
|
||||
findViewById(R.id.editIssueDueDateLayout).setVisibility(View.GONE);
|
||||
}
|
||||
@ -175,16 +164,16 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
||||
}
|
||||
|
||||
disableProcessButton();
|
||||
editIssue(instanceToken, repoOwner, repoName, issueIndex, loginUid, editIssueTitleForm, editIssueDescriptionForm, editIssueDueDateForm, milestoneId);
|
||||
editIssue(issue.getRepository().getOwner(), issue.getRepository().getName(), issue.getIssueIndex(), editIssueTitleForm, editIssueDescriptionForm, editIssueDueDateForm, milestoneId);
|
||||
}
|
||||
|
||||
private void editIssue(String instanceToken, String repoOwner, String repoName, int issueIndex, String loginUid, String title, String description, String dueDate, int milestoneId) {
|
||||
private void editIssue(String repoOwner, String repoName, int issueIndex, String title, String description, String dueDate, int milestoneId) {
|
||||
|
||||
CreateIssue issueData = new CreateIssue(title, description, dueDate, milestoneId);
|
||||
|
||||
Call<JsonElement> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.patchIssue(Authorization.get(ctx), repoOwner, repoName, issueIndex, issueData);
|
||||
.patchIssue(getAccount().getAuthorization(), repoOwner, repoName, issueIndex, issueData);
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
|
||||
@ -193,7 +182,7 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
||||
|
||||
if(response.code() == 201) {
|
||||
|
||||
if(tinyDB.getString("issueType").equalsIgnoreCase("Pull")) {
|
||||
if(issue.getIssueType().equalsIgnoreCase("Pull")) {
|
||||
|
||||
Toasty.success(ctx, getString(R.string.editPrSuccessMessage));
|
||||
}
|
||||
@ -202,8 +191,11 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
||||
Toasty.success(ctx, getString(R.string.editIssueSuccessMessage));
|
||||
}
|
||||
|
||||
tinyDB.putBoolean("issueEdited", true);
|
||||
tinyDB.putBoolean("resumeIssues", true);
|
||||
Intent result = new Intent();
|
||||
result.putExtra("issueEdited", true);
|
||||
IssuesFragment.resumeIssues = issue.getIssue().getPull_request() == null;
|
||||
PullRequestsFragment.resumePullRequests = issue.getIssue().getPull_request() != null;
|
||||
setResult(200, result);
|
||||
finish();
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
@ -252,11 +244,11 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
||||
|
||||
}
|
||||
|
||||
private void getIssue(final String instanceToken, final String loginUid, final String repoOwner, final String repoName, int issueIndex, int resultLimit) {
|
||||
private void getIssue(final String repoOwner, final String repoName, int issueIndex, int resultLimit) {
|
||||
|
||||
Call<Issues> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.getIssueByIndex(Authorization.get(ctx), repoOwner, repoName, issueIndex);
|
||||
.getIssueByIndex(getAccount().getAuthorization(), repoOwner, repoName, issueIndex);
|
||||
|
||||
call.enqueue(new Callback<Issues>() {
|
||||
|
||||
@ -280,7 +272,7 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
||||
|
||||
Call<List<Milestones>> call_ = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.getMilestones(Authorization.get(ctx), repoOwner, repoName, 1, resultLimit, msState);
|
||||
.getMilestones(getAccount().getAuthorization(), repoOwner, repoName, 1, resultLimit, msState);
|
||||
|
||||
int checkMilestoneId = currentMilestoneId;
|
||||
|
||||
@ -379,4 +371,10 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
||||
editIssueButton.setEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
issue.getRepository().checkAccountSwitch(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -24,11 +24,11 @@ import org.mian.gitnex.databinding.ActivityFileViewBinding;
|
||||
import org.mian.gitnex.fragments.BottomSheetFileViewerFragment;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.Constants;
|
||||
import org.mian.gitnex.helpers.Images;
|
||||
import org.mian.gitnex.helpers.Markdown;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import org.mian.gitnex.notifications.Notifications;
|
||||
import org.mian.gitnex.structs.BottomSheetListener;
|
||||
import java.io.IOException;
|
||||
@ -46,6 +46,18 @@ public class FileViewActivity extends BaseActivity implements BottomSheetListene
|
||||
|
||||
private ActivityFileViewBinding binding;
|
||||
private Files file;
|
||||
private RepositoryContext repository;
|
||||
private boolean renderMd = false;
|
||||
|
||||
public ActivityResultLauncher<Intent> editFileLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(),
|
||||
result -> {
|
||||
if(result.getResultCode() == 200) {
|
||||
assert result.getData() != null;
|
||||
if(result.getData().getBooleanExtra("fileModified", false)) {
|
||||
getSingleFileContents(repository.getOwner(), repository.getName(), file.getPath(), repository.getBranchRef());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
@ -53,12 +65,11 @@ public class FileViewActivity extends BaseActivity implements BottomSheetListene
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
binding = ActivityFileViewBinding.inflate(getLayoutInflater());
|
||||
repository = RepositoryContext.fromIntent(getIntent());
|
||||
|
||||
setContentView(binding.getRoot());
|
||||
setSupportActionBar(binding.toolbar);
|
||||
|
||||
tinyDB.putBoolean("enableMarkdownInFileView", false);
|
||||
|
||||
file = (Files) getIntent().getSerializableExtra("file");
|
||||
|
||||
binding.close.setOnClickListener(view -> finish());
|
||||
@ -66,31 +77,7 @@ public class FileViewActivity extends BaseActivity implements BottomSheetListene
|
||||
binding.toolbarTitle.setMovementMethod(new ScrollingMovementMethod());
|
||||
binding.toolbarTitle.setText(file.getPath());
|
||||
|
||||
String repoFullName = tinyDB.getString("repoFullName");
|
||||
String repoBranch = tinyDB.getString("repoBranch");
|
||||
String[] parts = repoFullName.split("/");
|
||||
String repoOwner = parts[0];
|
||||
String repoName = parts[1];
|
||||
|
||||
getSingleFileContents(repoOwner, repoName, file.getPath(), repoBranch);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
|
||||
super.onResume();
|
||||
|
||||
if(tinyDB.getBoolean("fileModified")) {
|
||||
String repoFullName = tinyDB.getString("repoFullName");
|
||||
String repoBranch = tinyDB.getString("repoBranch");
|
||||
String[] parts = repoFullName.split("/");
|
||||
String repoOwner = parts[0];
|
||||
String repoName = parts[1];
|
||||
|
||||
getSingleFileContents(repoOwner, repoName, file.getPath(), repoBranch);
|
||||
tinyDB.putBoolean("fileModified", false);
|
||||
}
|
||||
getSingleFileContents(repository.getOwner(), repository.getName(), file.getPath(), repository.getBranchRef());
|
||||
}
|
||||
|
||||
private void getSingleFileContents(final String owner, String repo, final String filename, String ref) {
|
||||
@ -99,7 +86,7 @@ public class FileViewActivity extends BaseActivity implements BottomSheetListene
|
||||
|
||||
Call<ResponseBody> call = RetrofitClient
|
||||
.getWebInterface(ctx)
|
||||
.getFileContents(Authorization.getWeb(ctx), owner, repo, ref, filename);
|
||||
.getFileContents(getAccount().getWebAuthorization(), owner, repo, ref, filename);
|
||||
|
||||
try {
|
||||
|
||||
@ -152,8 +139,8 @@ public class FileViewActivity extends BaseActivity implements BottomSheetListene
|
||||
|
||||
binding.contents.setContent(text, fileExtension);
|
||||
|
||||
if(tinyDB.getBoolean("enableMarkdownInFileView")) {
|
||||
Markdown.render(ctx, EmojiParser.parseToUnicode(text), binding.markdown);
|
||||
if(renderMd) {
|
||||
Markdown.render(ctx, EmojiParser.parseToUnicode(text), binding.markdown, repository);
|
||||
|
||||
binding.contents.setVisibility(View.GONE);
|
||||
binding.markdownFrame.setVisibility(View.VISIBLE);
|
||||
@ -252,25 +239,26 @@ public class FileViewActivity extends BaseActivity implements BottomSheetListene
|
||||
} else if(id == R.id.genericMenu) {
|
||||
|
||||
BottomSheetFileViewerFragment bottomSheet = new BottomSheetFileViewerFragment();
|
||||
bottomSheet.setArguments(repository.getBundle());
|
||||
bottomSheet.show(getSupportFragmentManager(), "fileViewerBottomSheet");
|
||||
return true;
|
||||
|
||||
} else if(id == R.id.markdown) {
|
||||
|
||||
if(!tinyDB.getBoolean("enableMarkdownInFileView")) {
|
||||
if(!renderMd) {
|
||||
if(binding.markdown.getAdapter() == null) {
|
||||
Markdown.render(ctx, EmojiParser.parseToUnicode(binding.contents.getContent()), binding.markdown);
|
||||
Markdown.render(ctx, EmojiParser.parseToUnicode(binding.contents.getContent()), binding.markdown, repository);
|
||||
}
|
||||
|
||||
binding.contents.setVisibility(View.GONE);
|
||||
binding.markdownFrame.setVisibility(View.VISIBLE);
|
||||
|
||||
tinyDB.putBoolean("enableMarkdownInFileView", true);
|
||||
renderMd = true;
|
||||
} else {
|
||||
binding.markdownFrame.setVisibility(View.GONE);
|
||||
binding.contents.setVisibility(View.VISIBLE);
|
||||
|
||||
tinyDB.putBoolean("enableMarkdownInFileView", false);
|
||||
renderMd = false;
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -288,12 +276,12 @@ public class FileViewActivity extends BaseActivity implements BottomSheetListene
|
||||
}
|
||||
|
||||
if("deleteFile".equals(text)) {
|
||||
Intent intent = new Intent(ctx, CreateFileActivity.class);
|
||||
Intent intent = repository.getIntent(ctx, CreateFileActivity.class);
|
||||
intent.putExtra("fileAction", CreateFileActivity.FILE_ACTION_DELETE);
|
||||
intent.putExtra("filePath", file.getPath());
|
||||
intent.putExtra("fileSha", file.getSha());
|
||||
|
||||
ctx.startActivity(intent);
|
||||
editFileLauncher.launch(intent);
|
||||
}
|
||||
|
||||
if("editFile".equals(text)) {
|
||||
@ -301,7 +289,7 @@ public class FileViewActivity extends BaseActivity implements BottomSheetListene
|
||||
if(binding.contents.getContent() != null &&
|
||||
!binding.contents.getContent().isEmpty()) {
|
||||
|
||||
Intent intent = new Intent(ctx, CreateFileActivity.class);
|
||||
Intent intent = repository.getIntent(ctx, CreateFileActivity.class);
|
||||
|
||||
intent.putExtra("fileAction", CreateFileActivity.FILE_ACTION_EDIT);
|
||||
intent.putExtra("filePath", file.getPath());
|
||||
@ -352,19 +340,13 @@ public class FileViewActivity extends BaseActivity implements BottomSheetListene
|
||||
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);;
|
||||
notificationManager.notify(notificationId, builder.build());
|
||||
|
||||
String repoFullName = tinyDB.getString("repoFullName");
|
||||
String repoBranch = tinyDB.getString("repoBranch");
|
||||
String[] parts = repoFullName.split("/");
|
||||
String repoOwner = parts[0];
|
||||
String repoName = parts[1];
|
||||
|
||||
Thread thread = new Thread(() -> {
|
||||
|
||||
try {
|
||||
|
||||
Call<ResponseBody> call = RetrofitClient
|
||||
.getWebInterface(ctx)
|
||||
.getFileContents(Authorization.getWeb(ctx), repoOwner, repoName, repoBranch, file.getPath());
|
||||
.getFileContents(getAccount().getWebAuthorization(), repository.getOwner(), repository.getName(), repository.getBranchRef(), file.getPath());
|
||||
|
||||
Response<ResponseBody> response = call.execute();
|
||||
|
||||
@ -400,4 +382,10 @@ public class FileViewActivity extends BaseActivity implements BottomSheetListene
|
||||
|
||||
});
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
repository.checkAccountSwitch(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -20,6 +20,8 @@ import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.ScrollView;
|
||||
import androidx.activity.result.ActivityResultLauncher;
|
||||
import androidx.activity.result.contract.ActivityResultContracts;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.res.ResourcesCompat;
|
||||
import androidx.core.text.HtmlCompat;
|
||||
@ -52,7 +54,6 @@ import org.mian.gitnex.fragments.BottomSheetReplyFragment;
|
||||
import org.mian.gitnex.fragments.BottomSheetSingleIssueFragment;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.ClickListener;
|
||||
import org.mian.gitnex.helpers.ColorInverter;
|
||||
import org.mian.gitnex.helpers.LabelWidthCalculator;
|
||||
@ -61,7 +62,7 @@ import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import org.mian.gitnex.helpers.contexts.IssueContext;
|
||||
import org.mian.gitnex.structs.BottomSheetListener;
|
||||
import org.mian.gitnex.viewmodels.IssueCommentsViewModel;
|
||||
import org.mian.gitnex.views.ReactionList;
|
||||
@ -89,6 +90,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
private String repoName;
|
||||
private int issueIndex;
|
||||
private String issueCreator;
|
||||
private IssueContext issue;
|
||||
|
||||
private LabelsListAdapter labelsAdapter;
|
||||
private AssigneesListAdapter assigneesAdapter;
|
||||
@ -107,6 +109,27 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
private CustomAssigneesSelectionDialogBinding assigneesBinding;
|
||||
private ActivityIssueDetailBinding viewBinding;
|
||||
|
||||
public boolean singleIssueUpdate = false;
|
||||
public boolean commentEdited = false;
|
||||
public boolean commentPosted = false;
|
||||
|
||||
public ActivityResultLauncher<Intent> editIssueLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(),
|
||||
result -> {
|
||||
if(result.getResultCode() == 200) {
|
||||
assert result.getData() != null;
|
||||
if(result.getData().getBooleanExtra("issueEdited", false)) {
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
|
||||
viewBinding.frameAssignees.removeAllViews();
|
||||
viewBinding.frameLabels.removeAllViews();
|
||||
issue.setIssue(null);
|
||||
getSingleIssue(repoOwner, repoName, issueIndex);
|
||||
|
||||
}, 500);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
@ -115,11 +138,10 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
viewBinding = ActivityIssueDetailBinding.inflate(getLayoutInflater());
|
||||
setContentView(viewBinding.getRoot());
|
||||
|
||||
String repoFullName = tinyDB.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
repoOwner = parts[0];
|
||||
repoName = parts[1];
|
||||
issueIndex = Integer.parseInt(tinyDB.getString("issueNumber"));
|
||||
issue = IssueContext.fromIntent(getIntent());
|
||||
repoOwner = issue.getRepository().getOwner();
|
||||
repoName = issue.getRepository().getName();
|
||||
issueIndex = issue.getIssueIndex();
|
||||
|
||||
setSupportActionBar(viewBinding.toolbar);
|
||||
Objects.requireNonNull(getSupportActionBar()).setTitle(repoName);
|
||||
@ -134,7 +156,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
|
||||
viewBinding.addNewComment.setOnClickListener(v -> {
|
||||
|
||||
BottomSheetReplyFragment bottomSheetReplyFragment = BottomSheetReplyFragment.newInstance(new Bundle());
|
||||
BottomSheetReplyFragment bottomSheetReplyFragment = BottomSheetReplyFragment.newInstance(new Bundle(), issue);
|
||||
bottomSheetReplyFragment.setOnInteractedListener(this::onResume);
|
||||
bottomSheetReplyFragment.show(getSupportFragmentManager(), "replyBottomSheet");
|
||||
|
||||
@ -172,7 +194,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
|
||||
viewBinding.pullToRefresh.setRefreshing(false);
|
||||
IssueCommentsViewModel
|
||||
.loadIssueComments(Authorization.get(ctx), repoOwner, repoName, issueIndex,
|
||||
.loadIssueComments(getAccount().getAuthorization(), repoOwner, repoName, issueIndex,
|
||||
ctx);
|
||||
|
||||
}, 500));
|
||||
@ -202,7 +224,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
fetchDataAsync(repoOwner, repoName, issueIndex);
|
||||
|
||||
if(getIntent().getStringExtra("openPrDiff") != null && getIntent().getStringExtra("openPrDiff").equals("true")) {
|
||||
startActivity(new Intent(ctx, DiffActivity.class));
|
||||
startActivity(issue.getIntent(ctx, DiffActivity.class));
|
||||
}
|
||||
}
|
||||
|
||||
@ -322,7 +344,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
|
||||
call3 = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.patchIssueAssignees(Authorization.get(ctx), repoOwner, repoName, issueIndex, updateAssigneeJson);
|
||||
.patchIssueAssignees(getAccount().getAuthorization(), repoOwner, repoName, issueIndex, updateAssigneeJson);
|
||||
|
||||
call3.enqueue(new Callback<JsonElement>() {
|
||||
|
||||
@ -337,6 +359,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
|
||||
viewBinding.frameAssignees.removeAllViews();
|
||||
viewBinding.frameLabels.removeAllViews();
|
||||
issue.setIssue(null);
|
||||
getSingleIssue(repoOwner, repoName, issueIndex);
|
||||
currentAssignees.clear();
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> AssigneesActions.getCurrentIssueAssignees(ctx, repoOwner, repoName, issueIndex, currentAssignees), 1000);
|
||||
@ -377,7 +400,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
|
||||
Call<JsonElement> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.updateIssueLabels(Authorization.get(ctx), repoOwner, repoName, issueIndex, patchIssueLabels);
|
||||
.updateIssueLabels(getAccount().getAuthorization(), repoOwner, repoName, issueIndex, patchIssueLabels);
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
|
||||
@ -391,6 +414,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
|
||||
viewBinding.frameAssignees.removeAllViews();
|
||||
viewBinding.frameLabels.removeAllViews();
|
||||
issue.setIssue(null);
|
||||
getSingleIssue(repoOwner, repoName, issueIndex);
|
||||
currentLabelsIds.clear();
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> LabelsActions.getCurrentIssueLabels(ctx, repoOwner, repoName, issueIndex, currentLabelsIds), 1000);
|
||||
@ -441,7 +465,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
if(id == android.R.id.home) {
|
||||
|
||||
if(getIntent().getStringExtra("openedFromLink") != null && getIntent().getStringExtra("openedFromLink").equals("true")) {
|
||||
Intent intent = new Intent(ctx, RepoDetailActivity.class);
|
||||
Intent intent = issue.getRepository().getIntent(ctx, RepoDetailActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(intent);
|
||||
}
|
||||
@ -450,8 +474,10 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
}
|
||||
else if(id == R.id.genericMenu) {
|
||||
|
||||
BottomSheetSingleIssueFragment bottomSheet = new BottomSheetSingleIssueFragment(issueCreator);
|
||||
bottomSheet.show(getSupportFragmentManager(), "singleIssueBottomSheet");
|
||||
if(issue.hasIssue()) {
|
||||
BottomSheetSingleIssueFragment bottomSheet = new BottomSheetSingleIssueFragment(issue, issueCreator);
|
||||
bottomSheet.show(getSupportFragmentManager(), "singleIssueBottomSheet");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
@ -464,52 +490,40 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
public void onResume() {
|
||||
|
||||
super.onResume();
|
||||
issue.getRepository().checkAccountSwitch(this);
|
||||
|
||||
if(tinyDB.getBoolean("commentPosted")) {
|
||||
if(commentPosted) {
|
||||
|
||||
viewBinding.scrollViewComments.post(() -> {
|
||||
|
||||
IssueCommentsViewModel
|
||||
.loadIssueComments(Authorization.get(ctx), repoOwner, repoName, issueIndex,
|
||||
ctx);
|
||||
.loadIssueComments(getAccount().getAuthorization(), repoOwner, repoName, issueIndex,
|
||||
ctx, () -> viewBinding.scrollViewComments.fullScroll(ScrollView.FOCUS_DOWN));
|
||||
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> viewBinding.scrollViewComments.fullScroll(ScrollView.FOCUS_DOWN), 1000);
|
||||
|
||||
tinyDB.putBoolean("commentPosted", false);
|
||||
commentPosted = false;
|
||||
});
|
||||
}
|
||||
|
||||
if(tinyDB.getBoolean("commentEdited")) {
|
||||
if(commentEdited) {
|
||||
|
||||
viewBinding.scrollViewComments.post(() -> {
|
||||
|
||||
IssueCommentsViewModel
|
||||
.loadIssueComments(Authorization.get(ctx), repoOwner, repoName, issueIndex,
|
||||
.loadIssueComments(getAccount().getAuthorization(), repoOwner, repoName, issueIndex,
|
||||
ctx);
|
||||
tinyDB.putBoolean("commentEdited", false);
|
||||
commentEdited = false;
|
||||
});
|
||||
}
|
||||
|
||||
if(tinyDB.getBoolean("singleIssueUpdate")) {
|
||||
if(singleIssueUpdate) {
|
||||
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
|
||||
viewBinding.frameAssignees.removeAllViews();
|
||||
viewBinding.frameLabels.removeAllViews();
|
||||
issue.setIssue(null);
|
||||
getSingleIssue(repoOwner, repoName, issueIndex);
|
||||
tinyDB.putBoolean("singleIssueUpdate", false);
|
||||
|
||||
}, 500);
|
||||
}
|
||||
|
||||
if(tinyDB.getBoolean("issueEdited")) {
|
||||
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
|
||||
viewBinding.frameAssignees.removeAllViews();
|
||||
viewBinding.frameLabels.removeAllViews();
|
||||
getSingleIssue(repoOwner, repoName, issueIndex);
|
||||
tinyDB.putBoolean("issueEdited", false);
|
||||
singleIssueUpdate = false;
|
||||
|
||||
}, 500);
|
||||
}
|
||||
@ -519,7 +533,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
|
||||
IssueCommentsViewModel issueCommentsModel = new ViewModelProvider(this).get(IssueCommentsViewModel.class);
|
||||
|
||||
issueCommentsModel.getIssueCommentList(Authorization.get(ctx), owner, repo, index, ctx)
|
||||
issueCommentsModel.getIssueCommentList(getAccount().getAuthorization(), owner, repo, index, ctx)
|
||||
.observe(this, issueCommentsMain -> {
|
||||
|
||||
assert issueCommentsMain != null;
|
||||
@ -534,7 +548,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
bundle.putString("repoName", repoName);
|
||||
bundle.putInt("issueNumber", issueIndex);
|
||||
|
||||
adapter = new IssueCommentsAdapter(ctx, bundle, issueCommentsMain, getSupportFragmentManager(), this::onResume);
|
||||
adapter = new IssueCommentsAdapter(ctx, bundle, issueCommentsMain, getSupportFragmentManager(), this::onResume, issue);
|
||||
|
||||
viewBinding.recyclerView.setAdapter(adapter);
|
||||
|
||||
@ -542,263 +556,29 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
}
|
||||
|
||||
private void getSingleIssue(String repoOwner, String repoName, int issueIndex) {
|
||||
updateTinyDBPermissionValues();
|
||||
if(issue.hasIssue()) {
|
||||
viewBinding.progressBar.setVisibility(View.GONE);
|
||||
getSubscribed();
|
||||
initWithIssue();
|
||||
return;
|
||||
}
|
||||
|
||||
final TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||
Call<Issues> call = RetrofitClient.getApiInterface(ctx)
|
||||
.getIssueByIndex(Authorization.get(ctx), repoOwner, repoName, issueIndex);
|
||||
.getIssueByIndex(getAccount().getAuthorization(), repoOwner, repoName, issueIndex);
|
||||
|
||||
call.enqueue(new Callback<Issues>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Issues> call, @NonNull Response<Issues> response) {
|
||||
viewBinding.progressBar.setVisibility(View.GONE);
|
||||
|
||||
if(response.code() == 200) {
|
||||
|
||||
Issues singleIssue = response.body();
|
||||
assert singleIssue != null;
|
||||
|
||||
viewBinding.issuePrState.setVisibility(View.VISIBLE);
|
||||
|
||||
if(singleIssue.getPull_request() != null) {
|
||||
getPullSourceRepo();
|
||||
if(singleIssue.getPull_request().isMerged()) { // merged
|
||||
|
||||
viewBinding.issuePrState.setImageResource(R.drawable.ic_pull_request_merged);
|
||||
}
|
||||
else if(!singleIssue.getPull_request().isMerged() && singleIssue.getState().equals("closed")) { // closed
|
||||
|
||||
viewBinding.issuePrState.setImageResource(R.drawable.ic_pull_request_closed);
|
||||
}
|
||||
else { // open
|
||||
|
||||
viewBinding.issuePrState.setImageResource(R.drawable.ic_pull_request);
|
||||
}
|
||||
}
|
||||
else if(singleIssue.getState().equals("closed")) { // issue closed
|
||||
|
||||
viewBinding.issuePrState.setImageResource(R.drawable.ic_issue_closed_red);
|
||||
}
|
||||
|
||||
TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||
final Locale locale = getResources().getConfiguration().locale;
|
||||
final String timeFormat = tinyDb.getString("dateFormat");
|
||||
tinyDb.putString("issueState", singleIssue.getState());
|
||||
tinyDb.putString("issueTitle", singleIssue.getTitle());
|
||||
tinyDb.putString("singleIssueHtmlUrl", singleIssue.getHtml_url());
|
||||
issueCreator = singleIssue.getUser().getLogin();
|
||||
|
||||
PicassoService.getInstance(ctx).get().load(singleIssue.getUser().getAvatar_url()).placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(viewBinding.assigneeAvatar);
|
||||
String issueNumber_ = "<font color='" + ResourcesCompat.getColor(getResources(), R.color.lightGray, null) + "'>" + appCtx.getResources()
|
||||
.getString(R.string.hash) + singleIssue.getNumber() + "</font>";
|
||||
viewBinding.issueTitle.setText(HtmlCompat.fromHtml(issueNumber_ + " " + EmojiParser.parseToUnicode(singleIssue.getTitle()), HtmlCompat.FROM_HTML_MODE_LEGACY));
|
||||
String cleanIssueDescription = singleIssue.getBody().trim();
|
||||
|
||||
viewBinding.assigneeAvatar.setOnClickListener(loginId -> {
|
||||
Intent intent = new Intent(ctx, ProfileActivity.class);
|
||||
intent.putExtra("username", singleIssue.getUser().getLogin());
|
||||
ctx.startActivity(intent);
|
||||
});
|
||||
|
||||
viewBinding.assigneeAvatar.setOnLongClickListener(loginId -> {
|
||||
AppUtil.copyToClipboard(ctx, singleIssue.getUser().getLogin(), ctx.getString(R.string.copyLoginIdToClipBoard, singleIssue.getUser().getLogin()));
|
||||
return true;
|
||||
});
|
||||
|
||||
Markdown.render(ctx, EmojiParser.parseToUnicode(cleanIssueDescription), viewBinding.issueDescription);
|
||||
|
||||
RelativeLayout.LayoutParams paramsDesc = (RelativeLayout.LayoutParams) viewBinding.issueDescription.getLayoutParams();
|
||||
|
||||
LinearLayout.LayoutParams params1 = new LinearLayout.LayoutParams(80, 80);
|
||||
params1.setMargins(15, 0, 0, 0);
|
||||
|
||||
if(singleIssue.getAssignees() != null) {
|
||||
|
||||
viewBinding.assigneesScrollView.setVisibility(View.VISIBLE);
|
||||
|
||||
for(int i = 0; i < singleIssue.getAssignees().size(); i++) {
|
||||
|
||||
ImageView assigneesView = new ImageView(ctx);
|
||||
|
||||
PicassoService.getInstance(ctx).get().load(singleIssue.getAssignees().get(i).getAvatar_url())
|
||||
.placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(100, 100).centerCrop()
|
||||
.into(assigneesView);
|
||||
|
||||
viewBinding.frameAssignees.addView(assigneesView);
|
||||
assigneesView.setLayoutParams(params1);
|
||||
|
||||
int finalI = i;
|
||||
assigneesView.setOnClickListener(loginId -> {
|
||||
Intent intent = new Intent(ctx, ProfileActivity.class);
|
||||
intent.putExtra("username", singleIssue.getAssignees().get(finalI).getLogin());
|
||||
ctx.startActivity(intent);
|
||||
});
|
||||
|
||||
assigneesView.setOnLongClickListener(loginId -> {
|
||||
AppUtil.copyToClipboard(ctx, singleIssue.getAssignees().get(finalI).getLogin(), ctx.getString(R.string.copyLoginIdToClipBoard, singleIssue.getAssignees().get(finalI).getLogin()));
|
||||
return true;
|
||||
});
|
||||
|
||||
/*if(!singleIssue.getAssignees().get(i).getFull_name().equals("")) {
|
||||
|
||||
assigneesView.setOnClickListener(
|
||||
new ClickListener(getString(R.string.assignedTo, singleIssue.getAssignees().get(i).getFull_name()), ctx));
|
||||
}
|
||||
else {
|
||||
|
||||
assigneesView.setOnClickListener(
|
||||
new ClickListener(getString(R.string.assignedTo, singleIssue.getAssignees().get(i).getLogin()), ctx));
|
||||
}*/
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
viewBinding.assigneesScrollView.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
params.setMargins(0, 0, 15, 0);
|
||||
|
||||
if(singleIssue.getLabels() != null) {
|
||||
|
||||
viewBinding.labelsScrollView.setVisibility(View.VISIBLE);
|
||||
|
||||
for(int i = 0; i < singleIssue.getLabels().size(); i++) {
|
||||
|
||||
String labelColor = singleIssue.getLabels().get(i).getColor();
|
||||
String labelName = singleIssue.getLabels().get(i).getName();
|
||||
int color = Color.parseColor("#" + labelColor);
|
||||
|
||||
ImageView labelsView = new ImageView(ctx);
|
||||
viewBinding.frameLabels.setOrientation(LinearLayout.HORIZONTAL);
|
||||
viewBinding.frameLabels.setGravity(Gravity.START | Gravity.TOP);
|
||||
labelsView.setLayoutParams(params);
|
||||
|
||||
int height = AppUtil.getPixelsFromDensity(ctx, 25);
|
||||
int textSize = AppUtil.getPixelsFromScaledDensity(ctx, 15);
|
||||
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT)
|
||||
.textColor(new ColorInverter().getContrastColor(color)).fontSize(textSize)
|
||||
.width(LabelWidthCalculator.calculateLabelWidth(labelName, Typeface.DEFAULT, textSize, AppUtil.getPixelsFromDensity(ctx, 10)))
|
||||
.height(height).endConfig().buildRoundRect(labelName, color, AppUtil.getPixelsFromDensity(ctx, 5));
|
||||
|
||||
labelsView.setImageDrawable(drawable);
|
||||
viewBinding.frameLabels.addView(labelsView);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
viewBinding.labelsScrollView.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if(singleIssue.getDue_date() != null) {
|
||||
|
||||
if(timeFormat.equals("normal") || timeFormat.equals("pretty")) {
|
||||
|
||||
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd", locale);
|
||||
String dueDate = formatter.format(singleIssue.getDue_date());
|
||||
viewBinding.issueDueDate.setText(dueDate);
|
||||
viewBinding.issueDueDate
|
||||
.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(singleIssue.getDue_date()), ctx));
|
||||
}
|
||||
else if(timeFormat.equals("normal1")) {
|
||||
|
||||
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy", locale);
|
||||
String dueDate = formatter.format(singleIssue.getDue_date());
|
||||
viewBinding.issueDueDate.setText(dueDate);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
viewBinding.issueDueDate.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
String edited;
|
||||
|
||||
if(!singleIssue.getUpdated_at().equals(singleIssue.getCreated_at())) {
|
||||
|
||||
edited = getString(R.string.colorfulBulletSpan) + getString(R.string.modifiedText);
|
||||
viewBinding.issueModified.setVisibility(View.VISIBLE);
|
||||
viewBinding.issueModified.setText(edited);
|
||||
viewBinding.issueModified
|
||||
.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(singleIssue.getUpdated_at()), ctx));
|
||||
}
|
||||
else {
|
||||
|
||||
viewBinding.issueModified.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
if((singleIssue.getDue_date() == null && singleIssue.getMilestone() == null) && singleIssue.getAssignees() != null) {
|
||||
|
||||
paramsDesc.setMargins(0, 35, 0, 0);
|
||||
viewBinding.issueDescription.setLayoutParams(paramsDesc);
|
||||
}
|
||||
else if(singleIssue.getDue_date() == null && singleIssue.getMilestone() == null) {
|
||||
|
||||
paramsDesc.setMargins(0, 55, 0, 0);
|
||||
viewBinding.issueDescription.setLayoutParams(paramsDesc);
|
||||
}
|
||||
else if(singleIssue.getAssignees() == null) {
|
||||
|
||||
paramsDesc.setMargins(0, 35, 0, 0);
|
||||
viewBinding.issueDescription.setLayoutParams(paramsDesc);
|
||||
}
|
||||
else {
|
||||
|
||||
paramsDesc.setMargins(0, 15, 0, 0);
|
||||
viewBinding.issueDescription.setLayoutParams(paramsDesc);
|
||||
}
|
||||
|
||||
viewBinding.issueCreatedTime.setText(TimeHelper.formatTime(singleIssue.getCreated_at(), locale, timeFormat, ctx));
|
||||
viewBinding.issueCreatedTime.setVisibility(View.VISIBLE);
|
||||
|
||||
if(timeFormat.equals("pretty")) {
|
||||
|
||||
viewBinding.issueCreatedTime
|
||||
.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(singleIssue.getCreated_at()), ctx));
|
||||
}
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("repoOwner", repoOwner);
|
||||
bundle.putString("repoName", repoName);
|
||||
bundle.putInt("issueId", singleIssue.getNumber());
|
||||
|
||||
ReactionList reactionList = new ReactionList(ctx, bundle);
|
||||
|
||||
viewBinding.commentReactionBadges.removeAllViews();
|
||||
viewBinding.commentReactionBadges.addView(reactionList);
|
||||
|
||||
reactionList.setOnReactionAddedListener(() -> {
|
||||
|
||||
if(viewBinding.commentReactionBadges.getVisibility() != View.VISIBLE) {
|
||||
viewBinding.commentReactionBadges.post(() -> viewBinding.commentReactionBadges.setVisibility(View.VISIBLE));
|
||||
}
|
||||
});
|
||||
|
||||
if(singleIssue.getMilestone() != null) {
|
||||
|
||||
viewBinding.issueMilestone.setVisibility(View.VISIBLE);
|
||||
viewBinding.issueMilestone.setText(getString(R.string.issueMilestone, singleIssue.getMilestone().getTitle()));
|
||||
}
|
||||
else {
|
||||
|
||||
viewBinding.issueMilestone.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
/*if(!singleIssue.getUser().getFull_name().equals("")) {
|
||||
|
||||
viewBinding.assigneeAvatar.setOnClickListener(
|
||||
new ClickListener(ctx.getResources().getString(R.string.issueCreator) + singleIssue.getUser().getFull_name(), ctx));
|
||||
}
|
||||
else {
|
||||
|
||||
viewBinding.assigneeAvatar.setOnClickListener(
|
||||
new ClickListener(ctx.getResources().getString(R.string.issueCreator) + singleIssue.getUser().getLogin(), ctx));
|
||||
}*/
|
||||
|
||||
viewBinding.progressBar.setVisibility(View.GONE);
|
||||
issue.setIssue(singleIssue);
|
||||
initWithIssue();
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
@ -810,112 +590,338 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
|
||||
if(tinyDb.getString("issueType").equals("Issue")) {
|
||||
|
||||
Toasty.warning(ctx, getResources().getString(R.string.noDataIssueTab));
|
||||
}
|
||||
else if(tinyDb.getString("issueType").equals("Pull")) {
|
||||
|
||||
if("Pull".equals(issue.getIssueType())) {
|
||||
Toasty.warning(ctx, getResources().getString(R.string.noDataPullRequests));
|
||||
}
|
||||
|
||||
Intent mainIntent = new Intent(ctx, MainActivity.class);
|
||||
ctx.startActivity(mainIntent);
|
||||
else {
|
||||
Toasty.warning(ctx, getResources().getString(R.string.noDataIssueTab));
|
||||
}
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Issues> call, @NonNull Throwable t) {
|
||||
|
||||
viewBinding.progressBar.setVisibility(View.GONE);
|
||||
Log.e("onFailure", t.toString());
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
if(new Version(tinyDb.getString("giteaVersion")).higherOrEqual("1.12.0")) {
|
||||
getSubscribed();
|
||||
|
||||
Call<WatchInfo> call2 = RetrofitClient.getApiInterface(appCtx)
|
||||
.checkIssueWatchStatus(Authorization.get(ctx), repoOwner, repoName, issueIndex);
|
||||
|
||||
call2.enqueue(new Callback<WatchInfo>() {
|
||||
}
|
||||
|
||||
private void getSubscribed() {
|
||||
RetrofitClient.getApiInterface(ctx)
|
||||
.checkIssueWatchStatus(getAccount().getAuthorization(), repoOwner, repoName, issueIndex)
|
||||
.enqueue(new Callback<WatchInfo>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<WatchInfo> call, @NonNull Response<WatchInfo> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
|
||||
assert response.body() != null;
|
||||
tinyDb.putBoolean("issueSubscribed", response.body().getSubscribed());
|
||||
}
|
||||
else {
|
||||
|
||||
tinyDb.putBoolean("issueSubscribed", false);
|
||||
issue.setSubscribed(response.body().getSubscribed());
|
||||
} else {
|
||||
issue.setSubscribed(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<WatchInfo> call, @NonNull Throwable t) {
|
||||
|
||||
tinyDb.putBoolean("issueSubscribed", false);
|
||||
issue.setSubscribed(false);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void updateTinyDBPermissionValues() {
|
||||
RetrofitClient.getApiInterface(this).getUserRepository(Authorization.get(this), repoOwner, repoName).enqueue(new Callback<UserRepositories>() {
|
||||
private void initWithIssue() {
|
||||
if(!issue.getRepository().hasRepository()) {
|
||||
getRepoInfo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<UserRepositories> call, @NonNull Response<UserRepositories> response) {
|
||||
if(response.isSuccessful()) {
|
||||
assert response.body() != null;
|
||||
tinyDB.putBoolean("isArchived", response.body().isArchived());
|
||||
if(response.body().isArchived()) {
|
||||
viewBinding.addNewComment.setVisibility(View.GONE);
|
||||
}
|
||||
tinyDB.putBoolean("isRepoAdmin", response.body().getPermissions().isAdmin());
|
||||
tinyDB.putBoolean("canPush", response.body().getPermissions().canPush());
|
||||
viewBinding.issuePrState.setVisibility(View.VISIBLE);
|
||||
|
||||
if(issue.getIssue().getPull_request() != null) {
|
||||
getPullRequest();
|
||||
if(issue.getIssue().getPull_request().isMerged()) { // merged
|
||||
|
||||
viewBinding.issuePrState.setImageResource(R.drawable.ic_pull_request_merged);
|
||||
}
|
||||
else if(!issue.getIssue().getPull_request().isMerged() && issue.getIssue().getState().equals("closed")) { // closed
|
||||
|
||||
viewBinding.issuePrState.setImageResource(R.drawable.ic_pull_request_closed);
|
||||
}
|
||||
else { // open
|
||||
|
||||
viewBinding.issuePrState.setImageResource(R.drawable.ic_pull_request);
|
||||
}
|
||||
}
|
||||
else if(issue.getIssue().getState().equals("closed")) { // issue closed
|
||||
|
||||
viewBinding.issuePrState.setImageResource(R.drawable.ic_issue_closed_red);
|
||||
} else {
|
||||
viewBinding.issuePrState.setImageResource(R.drawable.ic_issue);
|
||||
}
|
||||
|
||||
TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||
final Locale locale = getResources().getConfiguration().locale;
|
||||
final String timeFormat = tinyDb.getString("dateFormat", "pretty");
|
||||
issueCreator = issue.getIssue().getUser().getLogin();
|
||||
|
||||
PicassoService.getInstance(ctx).get().load(issue.getIssue().getUser().getAvatar_url()).placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(viewBinding.assigneeAvatar);
|
||||
String issueNumber_ = "<font color='" + ResourcesCompat.getColor(getResources(), R.color.lightGray, null) + "'>" + appCtx.getResources()
|
||||
.getString(R.string.hash) + issue.getIssue().getNumber() + "</font>";
|
||||
viewBinding.issueTitle.setText(HtmlCompat.fromHtml(issueNumber_ + " " + EmojiParser.parseToUnicode(issue.getIssue().getTitle()), HtmlCompat.FROM_HTML_MODE_LEGACY));
|
||||
String cleanIssueDescription = issue.getIssue().getBody().trim();
|
||||
|
||||
viewBinding.assigneeAvatar.setOnClickListener(loginId -> {
|
||||
Intent intent = new Intent(ctx, ProfileActivity.class);
|
||||
intent.putExtra("username", issue.getIssue().getUser().getLogin());
|
||||
ctx.startActivity(intent);
|
||||
});
|
||||
|
||||
viewBinding.assigneeAvatar.setOnLongClickListener(loginId -> {
|
||||
AppUtil.copyToClipboard(ctx, issue.getIssue().getUser().getLogin(), ctx.getString(R.string.copyLoginIdToClipBoard, issue.getIssue().getUser().getLogin()));
|
||||
return true;
|
||||
});
|
||||
|
||||
Markdown.render(ctx, EmojiParser.parseToUnicode(cleanIssueDescription), viewBinding.issueDescription, issue.getRepository());
|
||||
|
||||
RelativeLayout.LayoutParams paramsDesc = (RelativeLayout.LayoutParams) viewBinding.issueDescription.getLayoutParams();
|
||||
|
||||
LinearLayout.LayoutParams params1 = new LinearLayout.LayoutParams(80, 80);
|
||||
params1.setMargins(15, 0, 0, 0);
|
||||
|
||||
if(issue.getIssue().getAssignees() != null) {
|
||||
|
||||
viewBinding.assigneesScrollView.setVisibility(View.VISIBLE);
|
||||
|
||||
for(int i = 0; i < issue.getIssue().getAssignees().size(); i++) {
|
||||
|
||||
ImageView assigneesView = new ImageView(ctx);
|
||||
|
||||
PicassoService.getInstance(ctx).get().load(issue.getIssue().getAssignees().get(i).getAvatar_url())
|
||||
.placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(100, 100).centerCrop()
|
||||
.into(assigneesView);
|
||||
|
||||
viewBinding.frameAssignees.addView(assigneesView);
|
||||
assigneesView.setLayoutParams(params1);
|
||||
|
||||
int finalI = i;
|
||||
assigneesView.setOnClickListener(loginId -> {
|
||||
Intent intent = new Intent(ctx, ProfileActivity.class);
|
||||
intent.putExtra("username", issue.getIssue().getAssignees().get(finalI).getLogin());
|
||||
ctx.startActivity(intent);
|
||||
});
|
||||
|
||||
assigneesView.setOnLongClickListener(loginId -> {
|
||||
AppUtil.copyToClipboard(ctx, issue.getIssue().getAssignees().get(finalI).getLogin(), ctx.getString(R.string.copyLoginIdToClipBoard, issue.getIssue().getAssignees().get(finalI).getLogin()));
|
||||
return true;
|
||||
});
|
||||
|
||||
/*if(!issue.getIssue().getAssignees().get(i).getFull_name().equals("")) {
|
||||
|
||||
assigneesView.setOnClickListener(
|
||||
new ClickListener(getString(R.string.assignedTo, issue.getIssue().getAssignees().get(i).getFull_name()), ctx));
|
||||
}
|
||||
else {
|
||||
onFailure(call, new Throwable());
|
||||
|
||||
assigneesView.setOnClickListener(
|
||||
new ClickListener(getString(R.string.assignedTo, issue.getIssue().getAssignees().get(i).getLogin()), ctx));
|
||||
}*/
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
viewBinding.assigneesScrollView.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
params.setMargins(0, 0, 15, 0);
|
||||
|
||||
if(issue.getIssue().getLabels() != null) {
|
||||
|
||||
viewBinding.labelsScrollView.setVisibility(View.VISIBLE);
|
||||
|
||||
for(int i = 0; i < issue.getIssue().getLabels().size(); i++) {
|
||||
|
||||
String labelColor = issue.getIssue().getLabels().get(i).getColor();
|
||||
String labelName = issue.getIssue().getLabels().get(i).getName();
|
||||
int color = Color.parseColor("#" + labelColor);
|
||||
|
||||
ImageView labelsView = new ImageView(ctx);
|
||||
viewBinding.frameLabels.setOrientation(LinearLayout.HORIZONTAL);
|
||||
viewBinding.frameLabels.setGravity(Gravity.START | Gravity.TOP);
|
||||
labelsView.setLayoutParams(params);
|
||||
|
||||
int height = AppUtil.getPixelsFromDensity(ctx, 25);
|
||||
int textSize = AppUtil.getPixelsFromScaledDensity(ctx, 15);
|
||||
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT)
|
||||
.textColor(new ColorInverter().getContrastColor(color)).fontSize(textSize)
|
||||
.width(LabelWidthCalculator.calculateLabelWidth(labelName, Typeface.DEFAULT, textSize, AppUtil.getPixelsFromDensity(ctx, 10)))
|
||||
.height(height).endConfig().buildRoundRect(labelName, color, AppUtil.getPixelsFromDensity(ctx, 5));
|
||||
|
||||
labelsView.setImageDrawable(drawable);
|
||||
viewBinding.frameLabels.addView(labelsView);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
viewBinding.labelsScrollView.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if(issue.getIssue().getDue_date() != null) {
|
||||
|
||||
if(timeFormat.equals("normal") || timeFormat.equals("pretty")) {
|
||||
|
||||
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd", locale);
|
||||
String dueDate = formatter.format(issue.getIssue().getDue_date());
|
||||
viewBinding.issueDueDate.setText(dueDate);
|
||||
viewBinding.issueDueDate
|
||||
.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(issue.getIssue().getDue_date()), ctx));
|
||||
}
|
||||
else if(timeFormat.equals("normal1")) {
|
||||
|
||||
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy", locale);
|
||||
String dueDate = formatter.format(issue.getIssue().getDue_date());
|
||||
viewBinding.issueDueDate.setText(dueDate);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
viewBinding.issueDueDate.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
String edited;
|
||||
|
||||
if(!issue.getIssue().getUpdated_at().equals(issue.getIssue().getCreated_at())) {
|
||||
|
||||
edited = getString(R.string.colorfulBulletSpan) + getString(R.string.modifiedText);
|
||||
viewBinding.issueModified.setVisibility(View.VISIBLE);
|
||||
viewBinding.issueModified.setText(edited);
|
||||
viewBinding.issueModified
|
||||
.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(issue.getIssue().getUpdated_at()), ctx));
|
||||
}
|
||||
else {
|
||||
|
||||
viewBinding.issueModified.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
if((issue.getIssue().getDue_date() == null && issue.getIssue().getMilestone() == null) && issue.getIssue().getAssignees() != null) {
|
||||
|
||||
paramsDesc.setMargins(0, 35, 0, 0);
|
||||
viewBinding.issueDescription.setLayoutParams(paramsDesc);
|
||||
}
|
||||
else if(issue.getIssue().getDue_date() == null && issue.getIssue().getMilestone() == null) {
|
||||
|
||||
paramsDesc.setMargins(0, 55, 0, 0);
|
||||
viewBinding.issueDescription.setLayoutParams(paramsDesc);
|
||||
}
|
||||
else if(issue.getIssue().getAssignees() == null) {
|
||||
|
||||
paramsDesc.setMargins(0, 35, 0, 0);
|
||||
viewBinding.issueDescription.setLayoutParams(paramsDesc);
|
||||
}
|
||||
else {
|
||||
|
||||
paramsDesc.setMargins(0, 15, 0, 0);
|
||||
viewBinding.issueDescription.setLayoutParams(paramsDesc);
|
||||
}
|
||||
|
||||
viewBinding.issueCreatedTime.setText(TimeHelper.formatTime(issue.getIssue().getCreated_at(), locale, timeFormat, ctx));
|
||||
viewBinding.issueCreatedTime.setVisibility(View.VISIBLE);
|
||||
|
||||
if(timeFormat.equals("pretty")) {
|
||||
|
||||
viewBinding.issueCreatedTime
|
||||
.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(issue.getIssue().getCreated_at()), ctx));
|
||||
}
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("repoOwner", repoOwner);
|
||||
bundle.putString("repoName", repoName);
|
||||
bundle.putInt("issueId", issue.getIssue().getNumber());
|
||||
|
||||
ReactionList reactionList = new ReactionList(ctx, bundle);
|
||||
|
||||
viewBinding.commentReactionBadges.removeAllViews();
|
||||
viewBinding.commentReactionBadges.addView(reactionList);
|
||||
|
||||
reactionList.setOnReactionAddedListener(() -> {
|
||||
|
||||
if(viewBinding.commentReactionBadges.getVisibility() != View.VISIBLE) {
|
||||
viewBinding.commentReactionBadges.post(() -> viewBinding.commentReactionBadges.setVisibility(View.VISIBLE));
|
||||
}
|
||||
});
|
||||
|
||||
if(issue.getIssue().getMilestone() != null) {
|
||||
|
||||
viewBinding.issueMilestone.setVisibility(View.VISIBLE);
|
||||
viewBinding.issueMilestone.setText(getString(R.string.issueMilestone, issue.getIssue().getMilestone().getTitle()));
|
||||
}
|
||||
else {
|
||||
|
||||
viewBinding.issueMilestone.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
/*if(!issue.getIssue().getUser().getFull_name().equals("")) {
|
||||
|
||||
viewBinding.assigneeAvatar.setOnClickListener(
|
||||
new ClickListener(ctx.getResources().getString(R.string.issueCreator) + issue.getIssue().getUser().getFull_name(), ctx));
|
||||
}
|
||||
else {
|
||||
|
||||
viewBinding.assigneeAvatar.setOnClickListener(
|
||||
new ClickListener(ctx.getResources().getString(R.string.issueCreator) + issue.getIssue().getUser().getLogin(), ctx));
|
||||
}*/
|
||||
}
|
||||
|
||||
private void getPullRequest() {
|
||||
RetrofitClient.getApiInterface(this).getPullRequestByIndex(getAccount().getAuthorization(), repoOwner, repoName, issueIndex).enqueue(new Callback<PullRequests>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<PullRequests> call, @NonNull Response<PullRequests> response) {
|
||||
if(response.isSuccessful() && response.body() != null) {
|
||||
issue.setPullRequest(response.body());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<PullRequests> call, @NonNull Throwable t) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void getRepoInfo() {
|
||||
Call<UserRepositories> call = RetrofitClient.getApiInterface(ctx).getUserRepository(getAccount().getAuthorization(), issue.getRepository().getOwner(), issue.getRepository().getName());
|
||||
call.enqueue(new Callback<UserRepositories>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<UserRepositories> call, @NonNull retrofit2.Response<UserRepositories> response) {
|
||||
|
||||
UserRepositories repoInfo = response.body();
|
||||
|
||||
if(response.code() == 200) {
|
||||
assert repoInfo != null;
|
||||
issue.getRepository().setRepository(repoInfo);
|
||||
}
|
||||
else {
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
Log.e("onFailure", String.valueOf(response.code()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<UserRepositories> call, @NonNull Throwable t) {
|
||||
tinyDB.putBoolean("isRepoAdmin", false);
|
||||
tinyDB.putBoolean("canPush", false);
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
Log.e("onFailure", t.toString());
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
private void getPullSourceRepo() {
|
||||
if(new Version(tinyDB.getString("giteaVersion")).higherOrEqual("1.15.4")) {
|
||||
RetrofitClient.getApiInterface(this).getPullRequestByIndex(Authorization.get(this), repoOwner, repoName, issueIndex).enqueue(new Callback<PullRequests>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<PullRequests> call, @NonNull Response<PullRequests> response) {
|
||||
if(response.isSuccessful() && response.body() != null) {
|
||||
tinyDB.putBoolean("canPushPullSource", response.body().getHead().getRepo().getPermissions().isPush());
|
||||
}
|
||||
else {
|
||||
tinyDB.putBoolean("canPushPullSource", false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<PullRequests> call, @NonNull Throwable t) {
|
||||
tinyDB.putBoolean("canPushPullSource", false);
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
tinyDB.putBoolean("canPushPullSource", true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -20,13 +20,7 @@ import org.mian.gitnex.database.api.BaseApi;
|
||||
import org.mian.gitnex.database.api.UserAccountsApi;
|
||||
import org.mian.gitnex.database.models.UserAccount;
|
||||
import org.mian.gitnex.databinding.ActivityLoginBinding;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.NetworkStatusObserver;
|
||||
import org.mian.gitnex.helpers.PathsHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.UrlHelper;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import org.mian.gitnex.helpers.*;
|
||||
import org.mian.gitnex.structs.Protocol;
|
||||
import java.net.URI;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
@ -52,6 +46,9 @@ public class LoginActivity extends BaseActivity {
|
||||
private String device_id = "token";
|
||||
private String selectedProtocol;
|
||||
|
||||
private URI instanceUrl;
|
||||
private Version giteaVersion;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
@ -143,12 +140,12 @@ public class LoginActivity extends BaseActivity {
|
||||
|
||||
URI rawInstanceUrl = UrlBuilder.fromString(UrlHelper.fixScheme(instanceUrlET.getText().toString(), "http")).toUri();
|
||||
|
||||
URI instanceUrl = UrlBuilder.fromUri(rawInstanceUrl).withScheme(selectedProtocol.toLowerCase()).withPath(PathsHelper.join(rawInstanceUrl.getPath(), "/api/v1/"))
|
||||
instanceUrl = UrlBuilder.fromUri(rawInstanceUrl).withScheme(selectedProtocol.toLowerCase()).withPath(PathsHelper.join(rawInstanceUrl.getPath(), "/api/v1/"))
|
||||
.toUri();
|
||||
|
||||
// cache values to make them available the next time the user wants to log in
|
||||
tinyDB.putString("loginType", loginType.name().toLowerCase());
|
||||
tinyDB.putString("instanceUrlRaw", instanceUrlET.getText().toString());
|
||||
tinyDB.putString("instanceUrl", instanceUrl.toString());
|
||||
|
||||
if(instanceUrlET.getText().toString().equals("")) {
|
||||
|
||||
@ -166,28 +163,19 @@ public class LoginActivity extends BaseActivity {
|
||||
return;
|
||||
}
|
||||
|
||||
if(rawInstanceUrl.getUserInfo() != null) {
|
||||
|
||||
tinyDB.putString("basicAuthPassword", loginPass);
|
||||
tinyDB.putBoolean("basicAuthFlag", true);
|
||||
}
|
||||
|
||||
if(loginUid.equals("")) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.emptyFieldUsername));
|
||||
enableProcessButton();
|
||||
return;
|
||||
}
|
||||
|
||||
if(loginPass.equals("")) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.emptyFieldPassword));
|
||||
enableProcessButton();
|
||||
return;
|
||||
}
|
||||
|
||||
int loginOTP = (otpCode.length() > 0) ? Integer.parseInt(otpCode.getText().toString().trim()) : 0;
|
||||
tinyDB.putString("loginUid", loginUid);
|
||||
|
||||
versionCheck(loginUid, loginPass, loginOTP, loginToken, loginType);
|
||||
|
||||
@ -220,15 +208,15 @@ public class LoginActivity extends BaseActivity {
|
||||
|
||||
if(!loginToken.equals("")) {
|
||||
|
||||
callVersion = RetrofitClient.getApiInterface(appCtx).getGiteaVersionWithToken("token " + loginToken);
|
||||
callVersion = RetrofitClient.getApiInterface(ctx).getGiteaVersionWithToken("token " + loginToken);
|
||||
}
|
||||
else {
|
||||
|
||||
String credential = Credentials.basic(loginUid, loginPass, StandardCharsets.UTF_8);
|
||||
|
||||
callVersion =
|
||||
(loginOTP != 0) ? RetrofitClient.getApiInterface(appCtx).getGiteaVersionWithOTP(credential, loginOTP) :
|
||||
RetrofitClient.getApiInterface(appCtx).getGiteaVersionWithBasic(credential);
|
||||
(loginOTP != 0) ? RetrofitClient.getApiInterface(ctx).getGiteaVersionWithOTP(credential, loginOTP) :
|
||||
RetrofitClient.getApiInterface(ctx).getGiteaVersionWithBasic(credential);
|
||||
}
|
||||
|
||||
callVersion.enqueue(new Callback<GiteaVersion>() {
|
||||
@ -248,10 +236,9 @@ public class LoginActivity extends BaseActivity {
|
||||
return;
|
||||
}
|
||||
|
||||
tinyDB.putString("giteaVersion", version.getVersion());
|
||||
Version gitea_version = new Version(version.getVersion());
|
||||
giteaVersion = new Version(version.getVersion());
|
||||
|
||||
if(gitea_version.less(getString(R.string.versionLow))) {
|
||||
if(giteaVersion.less(getString(R.string.versionLow))) {
|
||||
|
||||
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ctx)
|
||||
.setTitle(getString(R.string.versionAlertDialogHeader))
|
||||
@ -274,7 +261,7 @@ public class LoginActivity extends BaseActivity {
|
||||
alertDialogBuilder.create().show();
|
||||
|
||||
}
|
||||
else if(gitea_version.lessOrEqual(getString(R.string.versionHigh))) {
|
||||
else if(giteaVersion.lessOrEqual(getString(R.string.versionHigh))) {
|
||||
|
||||
login(loginType, loginUid, loginPass, loginOTP, loginToken);
|
||||
}
|
||||
@ -319,7 +306,7 @@ public class LoginActivity extends BaseActivity {
|
||||
|
||||
private void setupUsingExistingToken(final String loginToken) {
|
||||
|
||||
Call<UserInfo> call = RetrofitClient.getApiInterface(appCtx).getUserInfo("token " + loginToken);
|
||||
Call<UserInfo> call = RetrofitClient.getApiInterface(ctx).getUserInfo("token " + loginToken);
|
||||
|
||||
call.enqueue(new Callback<UserInfo>() {
|
||||
|
||||
@ -333,29 +320,25 @@ public class LoginActivity extends BaseActivity {
|
||||
case 200:
|
||||
|
||||
assert userDetails != null;
|
||||
tinyDB.putBoolean("loggedInMode", true);
|
||||
tinyDB.putString(userDetails.getLogin() + "-token", loginToken);
|
||||
tinyDB.putString("loginUid", userDetails.getLogin());
|
||||
tinyDB.putString("userLogin", userDetails.getUsername());
|
||||
|
||||
// insert new account to db if does not exist
|
||||
String accountName = userDetails.getUsername() + "@" + TinyDB.getInstance(ctx).getString("instanceUrl");
|
||||
String accountName = userDetails.getUsername() + "@" + instanceUrl;
|
||||
UserAccountsApi userAccountsApi = BaseApi.getInstance(ctx, UserAccountsApi.class);
|
||||
assert userAccountsApi != null;
|
||||
boolean userAccountExists = userAccountsApi.userAccountExists(accountName);
|
||||
long accountId;
|
||||
|
||||
UserAccount account;
|
||||
if(!userAccountExists) {
|
||||
|
||||
accountId = userAccountsApi.createNewAccount(accountName, TinyDB.getInstance(ctx).getString("instanceUrl"), userDetails.getUsername(), loginToken, "");
|
||||
tinyDB.putInt("currentActiveAccountId", (int) accountId);
|
||||
long accountId = userAccountsApi.createNewAccount(accountName, instanceUrl.toString(), userDetails.getUsername(), loginToken, giteaVersion.toString());
|
||||
account = userAccountsApi.getAccountById((int) accountId);
|
||||
}
|
||||
else {
|
||||
|
||||
userAccountsApi.updateTokenByAccountName(accountName, loginToken);
|
||||
UserAccount data = userAccountsApi.getAccountByName(accountName);
|
||||
tinyDB.putInt("currentActiveAccountId", data.getAccountId());
|
||||
userAccountsApi.login(userAccountsApi.getAccountByName(accountName).getAccountId());
|
||||
account = userAccountsApi.getAccountByName(accountName);
|
||||
}
|
||||
|
||||
AppUtil.switchToAccount(LoginActivity.this, account);
|
||||
|
||||
enableProcessButton();
|
||||
startActivity(new Intent(LoginActivity.this, MainActivity.class));
|
||||
finish();
|
||||
@ -367,7 +350,7 @@ public class LoginActivity extends BaseActivity {
|
||||
break;
|
||||
default:
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.genericApiStatusError) + response.code());
|
||||
Toasty.error(ctx, getResources().getString(R.string.genericApiError, response.code()));
|
||||
enableProcessButton();
|
||||
}
|
||||
}
|
||||
@ -391,11 +374,11 @@ public class LoginActivity extends BaseActivity {
|
||||
Call<List<UserTokens>> call;
|
||||
if(loginOTP != 0) {
|
||||
|
||||
call = RetrofitClient.getApiInterface(appCtx).getUserTokensWithOTP(credential, loginOTP, loginUid);
|
||||
call = RetrofitClient.getApiInterface(ctx).getUserTokensWithOTP(credential, loginOTP, loginUid);
|
||||
}
|
||||
else {
|
||||
|
||||
call = RetrofitClient.getApiInterface(appCtx).getUserTokens(credential, loginUid);
|
||||
call = RetrofitClient.getApiInterface(ctx).getUserTokens(credential, loginUid);
|
||||
}
|
||||
|
||||
call.enqueue(new Callback<List<UserTokens>>() {
|
||||
@ -438,7 +421,7 @@ public class LoginActivity extends BaseActivity {
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.genericApiStatusError) + response.code());
|
||||
Toasty.error(ctx, getResources().getString(R.string.genericApiError, response.code()));
|
||||
enableProcessButton();
|
||||
}
|
||||
}
|
||||
@ -459,7 +442,7 @@ public class LoginActivity extends BaseActivity {
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.genericApiStatusError) + response.code());
|
||||
Toasty.error(ctx, getResources().getString(R.string.genericApiError, response.code()));
|
||||
enableProcessButton();
|
||||
}
|
||||
}
|
||||
@ -520,31 +503,26 @@ public class LoginActivity extends BaseActivity {
|
||||
case 200:
|
||||
|
||||
assert userDetails != null;
|
||||
tinyDB.remove("loginPass");
|
||||
tinyDB.putBoolean("loggedInMode", true);
|
||||
tinyDB.putString("userLogin", userDetails.getUsername());
|
||||
tinyDB.putString(loginUid + "-token", newToken.getSha1());
|
||||
tinyDB.putString(loginUid + "-token-last-eight", newToken.getToken_last_eight());
|
||||
|
||||
// insert new account to db if does not exist
|
||||
String accountName = userDetails.getUsername() + "@" + TinyDB.getInstance(ctx).getString("instanceUrl");
|
||||
String accountName = userDetails.getUsername() + "@" + instanceUrl;
|
||||
UserAccountsApi userAccountsApi = BaseApi.getInstance(ctx, UserAccountsApi.class);
|
||||
assert userAccountsApi != null;
|
||||
boolean userAccountExists = userAccountsApi.userAccountExists(accountName);
|
||||
long accountId;
|
||||
|
||||
UserAccount account;
|
||||
if(!userAccountExists) {
|
||||
|
||||
accountId = userAccountsApi
|
||||
.createNewAccount(accountName, TinyDB.getInstance(ctx).getString("instanceUrl"), userDetails.getUsername(), newToken.getSha1(), "");
|
||||
tinyDB.putInt("currentActiveAccountId", (int) accountId);
|
||||
long accountId = userAccountsApi
|
||||
.createNewAccount(accountName, instanceUrl.toString(), userDetails.getUsername(), newToken.getSha1(), giteaVersion.toString());
|
||||
account = userAccountsApi.getAccountById((int) accountId);
|
||||
}
|
||||
else {
|
||||
|
||||
userAccountsApi.updateTokenByAccountName(accountName, newToken.getSha1());
|
||||
UserAccount data = userAccountsApi.getAccountByName(accountName);
|
||||
tinyDB.putInt("currentActiveAccountId", data.getAccountId());
|
||||
account = userAccountsApi.getAccountByName(accountName);
|
||||
}
|
||||
|
||||
AppUtil.switchToAccount(LoginActivity.this, account);
|
||||
|
||||
startActivity(new Intent(LoginActivity.this, MainActivity.class));
|
||||
finish();
|
||||
break;
|
||||
@ -555,7 +533,7 @@ public class LoginActivity extends BaseActivity {
|
||||
break;
|
||||
default:
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.genericApiStatusError) + response.code());
|
||||
Toasty.error(ctx, getResources().getString(R.string.genericApiError, response.code()));
|
||||
enableProcessButton();
|
||||
}
|
||||
}
|
||||
@ -572,7 +550,7 @@ public class LoginActivity extends BaseActivity {
|
||||
}
|
||||
else if(responseCreate.code() == 500) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.genericApiStatusError) + responseCreate.code());
|
||||
Toasty.error(ctx, getResources().getString(R.string.genericApiError, responseCreate.code()));
|
||||
enableProcessButton();
|
||||
}
|
||||
}
|
||||
@ -602,19 +580,12 @@ public class LoginActivity extends BaseActivity {
|
||||
instanceUrlET.setText(tinyDB.getString("instanceUrlRaw"));
|
||||
}
|
||||
|
||||
if(!tinyDB.getString("loginUid").equals("")) {
|
||||
if(getAccount() != null) {
|
||||
|
||||
loginUidET.setText(tinyDB.getString("loginUid"));
|
||||
}
|
||||
|
||||
if(tinyDB.getBoolean("loggedInMode")) {
|
||||
|
||||
startActivity(new Intent(LoginActivity.this, MainActivity.class));
|
||||
finish();
|
||||
loginUidET.setText(getAccount().getAccount().getUserName());
|
||||
}
|
||||
|
||||
if(!tinyDB.getString("uniqueAppId").isEmpty()) {
|
||||
|
||||
device_id = tinyDB.getString("uniqueAppId");
|
||||
}
|
||||
else {
|
||||
|
@ -1,7 +1,5 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
@ -40,22 +38,19 @@ import org.mian.gitnex.fragments.AdministrationFragment;
|
||||
import org.mian.gitnex.fragments.BottomSheetDraftsFragment;
|
||||
import org.mian.gitnex.fragments.DraftsFragment;
|
||||
import org.mian.gitnex.fragments.ExploreFragment;
|
||||
import org.mian.gitnex.fragments.MyProfileFragment;
|
||||
import org.mian.gitnex.fragments.MyRepositoriesFragment;
|
||||
import org.mian.gitnex.fragments.NotificationsFragment;
|
||||
import org.mian.gitnex.fragments.OrganizationsFragment;
|
||||
import org.mian.gitnex.fragments.MyProfileFragment;
|
||||
import org.mian.gitnex.fragments.RepositoriesFragment;
|
||||
import org.mian.gitnex.fragments.SettingsFragment;
|
||||
import org.mian.gitnex.fragments.StarredRepositoriesFragment;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.ChangeLog;
|
||||
import org.mian.gitnex.helpers.ColorInverter;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import org.mian.gitnex.structs.BottomSheetListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -67,19 +62,25 @@ import retrofit2.Callback;
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public class MainActivity extends BaseActivity implements NavigationView.OnNavigationItemSelectedListener, BottomSheetListener {
|
||||
|
||||
public static boolean repoCreated = false;
|
||||
|
||||
private DrawerLayout drawer;
|
||||
private TextView toolbarTitle;
|
||||
private Typeface myTypeface;
|
||||
|
||||
private String loginUid;
|
||||
private String instanceToken;
|
||||
private boolean noConnection = false;
|
||||
|
||||
private View hView;
|
||||
private NavigationView navigationView;
|
||||
private MenuItem navNotifications;
|
||||
private TextView notificationCounter;
|
||||
|
||||
private BottomSheetListener profileInitListener;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
@ -102,21 +103,11 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
}
|
||||
// DO NOT MOVE
|
||||
|
||||
tinyDB.putBoolean("noConnection", false);
|
||||
|
||||
loginUid = tinyDB.getString("loginUid");
|
||||
instanceToken = "token " + tinyDB.getString(loginUid + "-token");
|
||||
|
||||
if(!tinyDB.getBoolean("loggedInMode")) {
|
||||
|
||||
logout(this, ctx);
|
||||
return;
|
||||
}
|
||||
instanceToken = getAccount().getAuthorization();
|
||||
noConnection = false;
|
||||
|
||||
if(tinyDB.getInt("currentActiveAccountId", -1) <= 0) {
|
||||
AlertDialogs.forceLogoutDialog(ctx,
|
||||
getResources().getString(R.string.forceLogoutDialogHeader),
|
||||
getResources().getString(R.string.forceLogoutDialogDescription), getResources().getString(R.string.navLogout));
|
||||
AppUtil.logout(ctx);
|
||||
}
|
||||
|
||||
Toolbar toolbar = activityMainBinding.toolbar;
|
||||
@ -174,7 +165,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
getNotificationsCount(instanceToken);
|
||||
|
||||
drawer = activityMainBinding.drawerLayout;
|
||||
NavigationView navigationView = activityMainBinding.navView;
|
||||
navigationView = activityMainBinding.navView;
|
||||
navigationView.setNavigationItemSelectedListener(this);
|
||||
hView = navigationView.getHeaderView(0);
|
||||
|
||||
@ -189,9 +180,11 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
@Override
|
||||
public void onDrawerOpened(@NonNull View drawerView) {
|
||||
|
||||
String userEmailNav = tinyDB.getString("userEmail");
|
||||
String userFullNameNav = tinyDB.getString("userFullname");
|
||||
String userAvatarNav = tinyDB.getString("userAvatar");
|
||||
if(noConnection) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
noConnection = false;
|
||||
}
|
||||
|
||||
TextView userEmail = hView.findViewById(R.id.userEmail);
|
||||
TextView userFullName = hView.findViewById(R.id.userFullname);
|
||||
@ -206,7 +199,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
RecyclerView navRecyclerViewUserAccounts = hView.findViewById(R.id.userAccounts);
|
||||
UserAccountsNavAdapter adapterUserAccounts = new UserAccountsNavAdapter(ctx, userAccountsList, drawer);
|
||||
|
||||
userAccountsApi.getAllAccounts().observe((AppCompatActivity) ctx, userAccounts -> {
|
||||
userAccountsApi.getAllLoggedInAccounts().observe((AppCompatActivity) ctx, userAccounts -> {
|
||||
if(userAccounts.size() > 0) {
|
||||
userAccountsList.clear();
|
||||
userAccountsList.addAll(userAccounts);
|
||||
@ -218,40 +211,44 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
userEmail.setTypeface(myTypeface);
|
||||
userFullName.setTypeface(myTypeface);
|
||||
|
||||
if(!userEmailNav.equals("")) {
|
||||
userEmail.setText(userEmailNav);
|
||||
}
|
||||
|
||||
if(!userFullNameNav.equals("")) {
|
||||
userFullName.setText(Html.fromHtml(userFullNameNav));
|
||||
}
|
||||
if (getAccount().getUserInfo() != null) {
|
||||
String userEmailNav = getAccount().getUserInfo().getEmail();
|
||||
String userFullNameNav = getAccount().getFullName();
|
||||
String userAvatarNav = getAccount().getUserInfo().getAvatar();
|
||||
|
||||
if(!userAvatarNav.equals("")) {
|
||||
if(!userEmailNav.equals("")) {
|
||||
userEmail.setText(userEmailNav);
|
||||
}
|
||||
|
||||
int avatarRadius = AppUtil.getPixelsFromDensity(ctx, 3);
|
||||
if(!userFullNameNav.equals("")) {
|
||||
userFullName.setText(Html.fromHtml(userFullNameNav));
|
||||
}
|
||||
|
||||
PicassoService.getInstance(ctx).get()
|
||||
.load(userAvatarNav)
|
||||
.placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(avatarRadius, 0))
|
||||
.resize(160, 160)
|
||||
.centerCrop().into(userAvatar);
|
||||
if(!userAvatarNav.equals("")) {
|
||||
|
||||
PicassoService.getInstance(ctx).get()
|
||||
.load(userAvatarNav)
|
||||
.transform(new BlurTransformation(ctx))
|
||||
.into(userAvatarBackground, new com.squareup.picasso.Callback() {
|
||||
int avatarRadius = AppUtil.getPixelsFromDensity(ctx, 3);
|
||||
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
int textColor = new ColorInverter().getImageViewContrastColor(userAvatarBackground);
|
||||
PicassoService.getInstance(ctx).get().load(userAvatarNav).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(avatarRadius, 0)).resize(160, 160).centerCrop().into(userAvatar);
|
||||
|
||||
userFullName.setTextColor(textColor);
|
||||
userEmail.setTextColor(textColor);
|
||||
}
|
||||
PicassoService.getInstance(ctx).get().load(userAvatarNav).transform(new BlurTransformation(ctx))
|
||||
.into(userAvatarBackground, new com.squareup.picasso.Callback() {
|
||||
|
||||
@Override public void onError(Exception e) {}
|
||||
});
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
|
||||
int textColor = new ColorInverter().getImageViewContrastColor(userAvatarBackground);
|
||||
|
||||
userFullName.setTextColor(textColor);
|
||||
userEmail.setTextColor(textColor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Exception e) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
userAvatar.setOnClickListener(v -> {
|
||||
@ -269,9 +266,12 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
@Override
|
||||
public void onDrawerSlide(@NonNull View drawerView, float slideOffset) {
|
||||
|
||||
navigationView.getMenu().findItem(R.id.nav_administration).setVisible(tinyDB.getBoolean("userIsAdmin"));
|
||||
navigationView.getMenu().findItem(R.id.nav_notifications).setVisible(new Version(tinyDB.getString("giteaVersion")).higherOrEqual("1.12.3"));
|
||||
|
||||
if (getAccount().getUserInfo() != null) {
|
||||
navigationView.getMenu().findItem(R.id.nav_administration).setVisible(getAccount().getUserInfo().getIs_admin());
|
||||
} else {
|
||||
// hide first
|
||||
navigationView.getMenu().findItem(R.id.nav_administration).setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -351,13 +351,13 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
|
||||
if(savedInstanceState == null) {
|
||||
|
||||
if(!new Version(tinyDB.getString("giteaVersion")).higherOrEqual("1.12.3")) {
|
||||
if(tinyDB.getInt("homeScreenId") == 7) {
|
||||
if(!getAccount().requiresVersion("1.12.3")) {
|
||||
if(tinyDB.getInt("homeScreenId", 0) == 7) {
|
||||
tinyDB.putInt("homeScreenId", 0);
|
||||
}
|
||||
}
|
||||
|
||||
switch(tinyDB.getInt("homeScreenId")) {
|
||||
switch(tinyDB.getInt("homeScreenId", 0)) {
|
||||
|
||||
case 1:
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleStarredRepos));
|
||||
@ -414,27 +414,25 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
if(!connToInternet) {
|
||||
|
||||
if(!tinyDB.getBoolean("noConnection")) {
|
||||
if(!noConnection) {
|
||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
}
|
||||
tinyDB.putBoolean("noConnection", true);
|
||||
noConnection = true;
|
||||
}
|
||||
else {
|
||||
|
||||
loadUserInfo(instanceToken, loginUid);
|
||||
loadUserInfo();
|
||||
giteaVersion();
|
||||
tinyDB.putBoolean("noConnection", false);
|
||||
noConnection = false;
|
||||
}
|
||||
Log.e("Network status is: ", String.valueOf(connToInternet));
|
||||
}, 1500);
|
||||
|
||||
// Changelog popup
|
||||
int versionCode = AppUtil.getAppBuildNo(appCtx);
|
||||
|
||||
if(versionCode > tinyDB.getInt("versionCode")) {
|
||||
|
||||
tinyDB.putInt("versionCode", versionCode);
|
||||
tinyDB.putBoolean("versionFlag", true);
|
||||
|
||||
ChangeLog changelogDialog = new ChangeLog(this);
|
||||
changelogDialog.showDialog();
|
||||
@ -448,9 +446,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
|
||||
@Override
|
||||
public void onButtonClicked(String text) {
|
||||
|
||||
TinyDB tinyDb = TinyDB.getInstance(ctx);
|
||||
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
||||
int currentActiveAccountId = tinyDB.getInt("currentActiveAccountId");
|
||||
|
||||
if("deleteDrafts".equals(text)) {
|
||||
|
||||
@ -518,7 +514,6 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new OrganizationsFragment()).commit();
|
||||
}
|
||||
else if(id == R.id.nav_profile) {
|
||||
|
||||
toolbarTitle.setText(getResources().getString(R.string.navProfile));
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new MyProfileFragment()).commit();
|
||||
}
|
||||
@ -534,7 +529,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
}
|
||||
else if(id == R.id.nav_logout) {
|
||||
|
||||
logout(this, ctx);
|
||||
AppUtil.logout(ctx);
|
||||
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
|
||||
}
|
||||
else if(id == R.id.nav_starred_repos) {
|
||||
@ -567,18 +562,6 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void logout(Activity activity, Context ctx) {
|
||||
|
||||
TinyDB tinyDB = TinyDB.getInstance(ctx);
|
||||
|
||||
tinyDB.putBoolean("loggedInMode", false);
|
||||
tinyDB.remove("basicAuthPassword");
|
||||
tinyDB.putBoolean("basicAuthFlag", false);
|
||||
//tinyDb.clear();
|
||||
activity.finish();
|
||||
ctx.startActivity(new Intent(ctx, LoginActivity.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
|
||||
@ -596,7 +579,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
|
||||
private void giteaVersion() {
|
||||
|
||||
Call<GiteaVersion> callVersion = RetrofitClient.getApiInterface(ctx).getGiteaVersionWithToken(Authorization.get(ctx));
|
||||
Call<GiteaVersion> callVersion = RetrofitClient.getApiInterface(ctx).getGiteaVersionWithToken(getAccount().getAuthorization());
|
||||
callVersion.enqueue(new Callback<GiteaVersion>() {
|
||||
|
||||
@Override
|
||||
@ -605,8 +588,8 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
if(responseVersion.code() == 200 && responseVersion.body() != null) {
|
||||
String version = responseVersion.body().getVersion();
|
||||
|
||||
tinyDB.putString("giteaVersion", version);
|
||||
BaseApi.getInstance(ctx, UserAccountsApi.class).updateServerVersion(version, tinyDB.getInt("currentActiveAccountId"));
|
||||
getAccount().setAccount(BaseApi.getInstance(ctx, UserAccountsApi.class).getAccountById(tinyDB.getInt("currentActiveAccountId")));
|
||||
}
|
||||
}
|
||||
|
||||
@ -617,11 +600,8 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
});
|
||||
}
|
||||
|
||||
private void loadUserInfo(String token, String loginUid) {
|
||||
|
||||
final TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||
|
||||
Call<UserInfo> call = RetrofitClient.getApiInterface(ctx).getUserInfo(Authorization.get(ctx));
|
||||
private void loadUserInfo() {
|
||||
Call<UserInfo> call = RetrofitClient.getApiInterface(ctx).getUserInfo(getAccount().getAuthorization());
|
||||
|
||||
call.enqueue(new Callback<UserInfo>() {
|
||||
|
||||
@ -636,34 +616,16 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
|
||||
assert userDetails != null;
|
||||
|
||||
if(userDetails.getIs_admin() != null) {
|
||||
|
||||
tinyDb.putBoolean("userIsAdmin", userDetails.getIs_admin());
|
||||
}
|
||||
|
||||
tinyDb.putString("userLogin", userDetails.getLogin());
|
||||
tinyDb.putInt("userId", userDetails.getId());
|
||||
|
||||
if(!userDetails.getFullname().equals("")) {
|
||||
|
||||
tinyDb.putString("userFullname", userDetails.getFullname());
|
||||
}
|
||||
else {
|
||||
|
||||
tinyDb.putString("userFullname", userDetails.getLogin());
|
||||
}
|
||||
|
||||
tinyDb.putString("userEmail", userDetails.getEmail());
|
||||
tinyDb.putString("userAvatar", userDetails.getAvatar());
|
||||
|
||||
if(userDetails.getLang() != null) {
|
||||
|
||||
tinyDb.putString("userLang", userDetails.getLang());
|
||||
}
|
||||
else {
|
||||
|
||||
tinyDb.putString("userLang", "");
|
||||
getAccount().setUserInfo(userDetails);
|
||||
navigationView.getMenu().findItem(R.id.nav_administration).setVisible(userDetails.getIs_admin());
|
||||
if(!getAccount().getAccount().getUserName().equals(userDetails.getUsername())) {
|
||||
// user changed it's name -> update database
|
||||
int accountId = getAccount().getAccount().getAccountId();
|
||||
BaseApi.getInstance(MainActivity.this, UserAccountsApi.class).updateUsername(accountId,
|
||||
userDetails.getUsername());
|
||||
getAccount().setAccount(BaseApi.getInstance(MainActivity.this, UserAccountsApi.class).getAccountById(accountId));
|
||||
}
|
||||
if(profileInitListener != null) profileInitListener.onButtonClicked(null);
|
||||
}
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
@ -672,7 +634,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
}
|
||||
else {
|
||||
|
||||
String toastError = getResources().getString(R.string.genericApiStatusError) + response.code();
|
||||
String toastError = getResources().getString(R.string.genericApiError, response.code());
|
||||
Toasty.error(ctx, toastError);
|
||||
}
|
||||
}
|
||||
@ -713,4 +675,9 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
});
|
||||
}
|
||||
|
||||
public void setProfileInitListener(BottomSheetListener profileInitListener) {
|
||||
|
||||
this.profileInitListener = profileInitListener;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package org.mian.gitnex.activities;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
@ -14,11 +15,11 @@ import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.actions.PullRequestActions;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.ActivityMergePullRequestBinding;
|
||||
import org.mian.gitnex.fragments.PullRequestsFragment;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import org.mian.gitnex.helpers.contexts.IssueContext;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
import retrofit2.Call;
|
||||
@ -32,9 +33,7 @@ public class MergePullRequestActivity extends BaseActivity {
|
||||
|
||||
private View.OnClickListener onClickListener;
|
||||
|
||||
private String repoOwner;
|
||||
private String repoName;
|
||||
private int prIndex;
|
||||
private IssueContext issue;
|
||||
|
||||
private ActivityMergePullRequestBinding viewBinding;
|
||||
|
||||
@ -49,11 +48,7 @@ public class MergePullRequestActivity extends BaseActivity {
|
||||
viewBinding = ActivityMergePullRequestBinding.inflate(getLayoutInflater());
|
||||
setContentView(viewBinding.getRoot());
|
||||
|
||||
String repoFullName = tinyDB.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
repoOwner = parts[0];
|
||||
repoName = parts[1];
|
||||
prIndex = Integer.parseInt(tinyDB.getString("issueNumber"));
|
||||
issue = IssueContext.fromIntent(getIntent());
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
@ -65,22 +60,22 @@ public class MergePullRequestActivity extends BaseActivity {
|
||||
|
||||
setMergeAdapter();
|
||||
|
||||
if(!tinyDB.getString("issueTitle").isEmpty()) {
|
||||
if(!issue.getPullRequest().getTitle().isEmpty()) {
|
||||
|
||||
viewBinding.toolbarTitle.setText(tinyDB.getString("issueTitle"));
|
||||
viewBinding.mergeTitle.setText(tinyDB.getString("issueTitle") + " (#" + tinyDB.getString("issueNumber") + ")");
|
||||
viewBinding.toolbarTitle.setText(issue.getPullRequest().getTitle());
|
||||
viewBinding.mergeTitle.setText(issue.getPullRequest().getTitle() + " (#" + issue.getIssueIndex() + ")");
|
||||
}
|
||||
|
||||
initCloseListener();
|
||||
viewBinding.close.setOnClickListener(onClickListener);
|
||||
|
||||
// if gitea version is greater/equal(1.12.0) than user installed version (installed.higherOrEqual(compareVer))
|
||||
if(new Version(tinyDB.getString("giteaVersion")).higherOrEqual("1.12.0")) {
|
||||
if(getAccount().requiresVersion("1.12.0")) {
|
||||
|
||||
viewBinding.deleteBranch.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
if(tinyDB.getString("prMergeable").equals("false")) {
|
||||
if(!issue.getPullRequest().isMergeable()) {
|
||||
|
||||
disableProcessButton();
|
||||
viewBinding.mergeInfoDisabledMessage.setVisibility(View.VISIBLE);
|
||||
@ -90,7 +85,7 @@ public class MergePullRequestActivity extends BaseActivity {
|
||||
viewBinding.mergeInfoDisabledMessage.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if(tinyDB.getString("prIsFork").equals("true")) {
|
||||
if(issue.prIsFork()) {
|
||||
|
||||
viewBinding.deleteBranchForkInfo.setVisibility(View.VISIBLE);
|
||||
}
|
||||
@ -108,7 +103,7 @@ public class MergePullRequestActivity extends BaseActivity {
|
||||
viewBinding.mergeButton.setOnClickListener(mergePullRequest);
|
||||
}
|
||||
|
||||
if(!tinyDB.getBoolean("canPushPullSource")) {
|
||||
if(!issue.getPullRequest().getHead().getRepo().getPermissions().isPush()) {
|
||||
viewBinding.deleteBranch.setVisibility(View.GONE);
|
||||
viewBinding.deleteBranchForkInfo.setVisibility(View.GONE);
|
||||
}
|
||||
@ -123,7 +118,7 @@ public class MergePullRequestActivity extends BaseActivity {
|
||||
mergeList.add(new MergePullRequestSpinner("rebase", getResources().getString(R.string.mergeOptionRebase)));
|
||||
mergeList.add(new MergePullRequestSpinner("rebase-merge", getResources().getString(R.string.mergeOptionRebaseCommit)));
|
||||
// squash merge works only on gitea > v1.11.4 due to a bug
|
||||
if(new Version(tinyDB.getString("giteaVersion")).higher("1.11.4")) {
|
||||
if(getAccount().requiresVersion("1.12.0")) {
|
||||
|
||||
mergeList.add(new MergePullRequestSpinner("squash", getResources().getString(R.string.mergeOptionSquash)));
|
||||
}
|
||||
@ -174,7 +169,7 @@ public class MergePullRequestActivity extends BaseActivity {
|
||||
|
||||
MergePullRequest mergePR = new MergePullRequest(Do, mergePRDT, mergeTitle);
|
||||
|
||||
Call<Void> call = RetrofitClient.getApiInterface(ctx).mergePullRequest(Authorization.get(ctx), repoOwner, repoName, prIndex, mergePR);
|
||||
Call<Void> call = RetrofitClient.getApiInterface(ctx).mergePullRequest(getAccount().getAuthorization(), issue.getRepository().getOwner(), issue.getRepository().getName(), issue.getIssueIndex(), mergePR);
|
||||
|
||||
call.enqueue(new Callback<Void>() {
|
||||
|
||||
@ -185,43 +180,24 @@ public class MergePullRequestActivity extends BaseActivity {
|
||||
|
||||
if(deleteBranch) {
|
||||
|
||||
if(tinyDB.getString("prIsFork").equals("true")) {
|
||||
|
||||
String repoFullName = tinyDB.getString("prForkFullName");
|
||||
if(issue.prIsFork()) {
|
||||
String repoFullName = issue.getPullRequest().getHead().getRepo().getFull_name();
|
||||
String[] parts = repoFullName.split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
|
||||
PullRequestActions.deleteHeadBranch(ctx, repoOwner, repoName, tinyDB.getString("prHeadBranch"), false);
|
||||
|
||||
Toasty.success(ctx, getString(R.string.mergePRSuccessMsg));
|
||||
tinyDB.putBoolean("prMerged", true);
|
||||
tinyDB.putBoolean("resumePullRequests", true);
|
||||
finish();
|
||||
PullRequestActions.deleteHeadBranch(ctx, repoOwner, repoName, issue.getPullRequest().getHead().getRef(), false);
|
||||
}
|
||||
else {
|
||||
|
||||
String repoFullName = tinyDB.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
|
||||
PullRequestActions.deleteHeadBranch(ctx, repoOwner, repoName, tinyDB.getString("prHeadBranch"), false);
|
||||
|
||||
Toasty.success(ctx, getString(R.string.mergePRSuccessMsg));
|
||||
tinyDB.putBoolean("prMerged", true);
|
||||
tinyDB.putBoolean("resumePullRequests", true);
|
||||
finish();
|
||||
PullRequestActions.deleteHeadBranch(ctx, issue.getRepository().getOwner(), issue.getRepository().getName(), issue.getPullRequest().getHead().getRef(), false);
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.success(ctx, getString(R.string.mergePRSuccessMsg));
|
||||
tinyDB.putBoolean("prMerged", true);
|
||||
tinyDB.putBoolean("resumePullRequests", true);
|
||||
finish();
|
||||
}
|
||||
Toasty.success(ctx, getString(R.string.mergePRSuccessMsg));
|
||||
Intent result = new Intent();
|
||||
PullRequestsFragment.resumePullRequests = true;
|
||||
setResult(200, result);
|
||||
finish();
|
||||
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
@ -268,4 +244,10 @@ public class MergePullRequestActivity extends BaseActivity {
|
||||
viewBinding.mergeButton.setEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
issue.getRepository().checkAccountSwitch(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -15,10 +15,9 @@ import org.gitnex.tea4j.models.AddEmail;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.ActivityProfileEmailBinding;
|
||||
import org.mian.gitnex.fragments.MyProfileEmailsFragment;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@ -97,18 +96,17 @@ public class MyProfileEmailActivity extends BaseActivity {
|
||||
List<String> newEmailList = new ArrayList<>(Arrays.asList(newUserEmail.split(",")));
|
||||
|
||||
disableProcessButton();
|
||||
addNewEmail(Authorization.get(ctx), newEmailList);
|
||||
addNewEmail(getAccount().getAuthorization(), newEmailList);
|
||||
}
|
||||
|
||||
private void addNewEmail(final String token, List<String> newUserEmail) {
|
||||
|
||||
AddEmail addEmailFunc = new AddEmail(newUserEmail);
|
||||
final TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||
|
||||
Call<JsonElement> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getApiInterface(appCtx)
|
||||
.getApiInterface(ctx)
|
||||
.addNewEmail(token, addEmailFunc);
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
@ -119,7 +117,7 @@ public class MyProfileEmailActivity extends BaseActivity {
|
||||
if(response.code() == 201) {
|
||||
|
||||
Toasty.success(ctx, getString(R.string.emailAddedText));
|
||||
tinyDb.putBoolean("emailsRefresh", true);
|
||||
MyProfileEmailsFragment.refreshEmails = true;
|
||||
enableProcessButton();
|
||||
finish();
|
||||
}
|
||||
|
@ -28,11 +28,8 @@ import org.mian.gitnex.fragments.OrganizationInfoFragment;
|
||||
import org.mian.gitnex.fragments.OrganizationLabelsFragment;
|
||||
import org.mian.gitnex.fragments.RepositoriesByOrgFragment;
|
||||
import org.mian.gitnex.fragments.TeamsByOrgFragment;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.structs.BottomSheetListener;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import io.mikael.urlbuilder.UrlBuilder;
|
||||
import retrofit2.Call;
|
||||
@ -54,7 +51,7 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
||||
|
||||
setContentView(R.layout.activity_org_detail);
|
||||
|
||||
String orgName = tinyDB.getString("orgName");
|
||||
String orgName = getIntent().getStringExtra("orgName");
|
||||
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
TextView toolbarTitle = findViewById(R.id.toolbar_title);
|
||||
@ -113,9 +110,9 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
||||
mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
|
||||
tabLayout.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(mViewPager));
|
||||
|
||||
if(new Version(tinyDB.getString("giteaVersion")).higherOrEqual("1.16.0")) {
|
||||
if(getAccount().requiresVersion("1.16.0")) {
|
||||
RetrofitClient.getApiInterface(this)
|
||||
.getOrgPermissions(Authorization.get(this), tinyDB.getString("loginUid"), orgName).enqueue(new Callback<OrgPermissions>() {
|
||||
.getOrgPermissions(getAccount().getAuthorization(), getAccount().getAccount().getUserName(), orgName).enqueue(new Callback<OrgPermissions>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<OrgPermissions> call, @NonNull Response<OrgPermissions> response) {
|
||||
@ -173,9 +170,11 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
||||
|
||||
switch (text) {
|
||||
case "repository":
|
||||
|
||||
tinyDB.putBoolean("organizationAction", true);
|
||||
startActivity(new Intent(OrganizationDetailActivity.this, CreateRepoActivity.class));
|
||||
Intent intentRepo = new Intent(this, CreateRepoActivity.class);
|
||||
intentRepo.putExtra("organizationAction", true);
|
||||
intentRepo.putExtra("orgName", getIntent().getStringExtra("orgName"));
|
||||
intentRepo.putExtras(getIntent().getExtras());
|
||||
startActivity(intentRepo);
|
||||
break;
|
||||
case "label":
|
||||
|
||||
@ -185,16 +184,17 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
||||
ctx.startActivity(intent);
|
||||
break;
|
||||
case "team":
|
||||
|
||||
startActivity(new Intent(OrganizationDetailActivity.this, CreateTeamByOrgActivity.class));
|
||||
Intent intentTeam = new Intent(OrganizationDetailActivity.this, CreateTeamByOrgActivity.class);
|
||||
intentTeam.putExtras(getIntent().getExtras());
|
||||
startActivity(intentTeam);
|
||||
break;
|
||||
case "copyOrgUrl":
|
||||
|
||||
String url = UrlBuilder.fromString(tinyDB.getString("instanceUrl"))
|
||||
String url = UrlBuilder.fromString(getAccount().getAccount().getInstanceUrl())
|
||||
.withPath("/")
|
||||
.toString();
|
||||
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(ctx).getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipData clip = ClipData.newPlainText("orgUrl", url + tinyDB.getString("orgName"));
|
||||
ClipData clip = ClipData.newPlainText("orgUrl", url + getIntent().getStringExtra("orgName"));
|
||||
assert clipboard != null;
|
||||
clipboard.setPrimaryClip(clip);
|
||||
Toasty.info(ctx, ctx.getString(R.string.copyIssueUrlToastMsg));
|
||||
@ -212,15 +212,7 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
||||
@Override
|
||||
public Fragment getItem(int position) {
|
||||
|
||||
String orgName;
|
||||
if(getIntent().getStringExtra("orgName") != null || !Objects.equals(getIntent().getStringExtra("orgName"), "")) {
|
||||
|
||||
orgName = getIntent().getStringExtra("orgName");
|
||||
}
|
||||
else {
|
||||
|
||||
orgName = tinyDB.getString("orgName");
|
||||
}
|
||||
String orgName = getIntent().getStringExtra("orgName");
|
||||
|
||||
Fragment fragment = null;
|
||||
switch (position) {
|
||||
|
@ -19,7 +19,6 @@ import org.mian.gitnex.databinding.ActivityOrgTeamInfoBinding;
|
||||
import org.mian.gitnex.fragments.BottomSheetOrganizationTeamsFragment;
|
||||
import org.mian.gitnex.fragments.OrganizationTeamInfoMembersFragment;
|
||||
import org.mian.gitnex.fragments.OrganizationTeamInfoPermissionsFragment;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.structs.BottomSheetListener;
|
||||
|
||||
/**
|
||||
@ -28,8 +27,7 @@ import org.mian.gitnex.structs.BottomSheetListener;
|
||||
|
||||
public class OrganizationTeamInfoActivity extends BaseActivity implements BottomSheetListener {
|
||||
|
||||
private ActivityOrgTeamInfoBinding binding;
|
||||
private Teams team;
|
||||
private Teams team;
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
@ -37,7 +35,7 @@ public class OrganizationTeamInfoActivity extends BaseActivity implements Bottom
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
binding = ActivityOrgTeamInfoBinding.inflate(getLayoutInflater());
|
||||
org.mian.gitnex.databinding.ActivityOrgTeamInfoBinding binding = ActivityOrgTeamInfoBinding.inflate(getLayoutInflater());
|
||||
|
||||
setContentView(binding.getRoot());
|
||||
setSupportActionBar(binding.toolbar);
|
||||
@ -87,16 +85,6 @@ public class OrganizationTeamInfoActivity extends BaseActivity implements Bottom
|
||||
}).attach();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||
|
||||
if(tinyDb.getBoolean("teamActionFlag")) {
|
||||
tinyDb.putBoolean("teamActionFlag", false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
OrgPermissions permissions = (OrgPermissions) getIntent().getSerializableExtra("permissions");
|
||||
|
@ -26,7 +26,6 @@ import org.mian.gitnex.fragments.profile.FollowingFragment;
|
||||
import org.mian.gitnex.fragments.profile.OrganizationsFragment;
|
||||
import org.mian.gitnex.fragments.profile.RepositoriesFragment;
|
||||
import org.mian.gitnex.fragments.profile.StarredRepositoriesFragment;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.structs.BottomSheetListener;
|
||||
import java.util.Objects;
|
||||
@ -105,7 +104,7 @@ public class ProfileActivity extends BaseActivity implements BottomSheetListener
|
||||
}
|
||||
}
|
||||
|
||||
if(!username.equals(tinyDB.getString("userLogin"))) {
|
||||
if(!username.equals(getAccount().getAccount().getUserName())) {
|
||||
checkFollowStatus();
|
||||
}
|
||||
}
|
||||
@ -119,7 +118,7 @@ public class ProfileActivity extends BaseActivity implements BottomSheetListener
|
||||
}
|
||||
|
||||
private void checkFollowStatus() {
|
||||
RetrofitClient.getApiInterface(this).checkFollowing(Authorization.get(this), username).enqueue(new Callback<JsonElement>() {
|
||||
RetrofitClient.getApiInterface(this).checkFollowing(getAccount().getAuthorization(), username).enqueue(new Callback<JsonElement>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<JsonElement> call, @NonNull Response<JsonElement> response) {
|
||||
@ -144,10 +143,10 @@ public class ProfileActivity extends BaseActivity implements BottomSheetListener
|
||||
private void followUnfollow() {
|
||||
Call<JsonElement> call;
|
||||
if (following) {
|
||||
call = RetrofitClient.getApiInterface(this).unfollowUser(Authorization.get(this), username);
|
||||
call = RetrofitClient.getApiInterface(this).unfollowUser(getAccount().getAuthorization(), username);
|
||||
}
|
||||
else {
|
||||
call = RetrofitClient.getApiInterface(this).followUser(Authorization.get(this), username);
|
||||
call = RetrofitClient.getApiInterface(this).followUser(getAccount().getAuthorization(), username);
|
||||
}
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
@ -234,7 +233,7 @@ public class ProfileActivity extends BaseActivity implements BottomSheetListener
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
if(!username.equals(tinyDB.getString("userLogin"))) {
|
||||
if(!username.equals(getAccount().getAccount().getUserName())) {
|
||||
getMenuInflater().inflate(R.menu.generic_nav_dotted_menu, menu);
|
||||
}
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
|
@ -18,6 +18,8 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.activity.result.ActivityResultLauncher;
|
||||
import androidx.activity.result.contract.ActivityResultContracts;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
@ -25,6 +27,7 @@ import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentStatePagerAdapter;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
import com.google.android.material.progressindicator.LinearProgressIndicator;
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
import com.google.gson.JsonElement;
|
||||
import org.gitnex.tea4j.models.Branches;
|
||||
@ -50,9 +53,8 @@ import org.mian.gitnex.fragments.PullRequestsFragment;
|
||||
import org.mian.gitnex.fragments.ReleasesFragment;
|
||||
import org.mian.gitnex.fragments.RepoInfoFragment;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import org.mian.gitnex.structs.BottomSheetListener;
|
||||
import org.mian.gitnex.structs.FragmentRefreshListener;
|
||||
import java.util.ArrayList;
|
||||
@ -71,6 +73,7 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
||||
private TextView textViewBadgeIssue;
|
||||
private TextView textViewBadgePull;
|
||||
private TextView textViewBadgeRelease;
|
||||
private Typeface myTypeface;
|
||||
|
||||
private FragmentRefreshListener fragmentRefreshListener;
|
||||
private FragmentRefreshListener fragmentRefreshListenerPr;
|
||||
@ -79,12 +82,53 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
||||
private FragmentRefreshListener fragmentRefreshListenerFilterIssuesByMilestone;
|
||||
private FragmentRefreshListener fragmentRefreshListenerReleases;
|
||||
|
||||
private String repositoryOwner;
|
||||
private String repositoryName;
|
||||
|
||||
public static ViewPager mViewPager;
|
||||
public ViewPager mViewPager;
|
||||
private int tabsCount;
|
||||
|
||||
public RepositoryContext repository;
|
||||
|
||||
private final ActivityResultLauncher<Intent> createReleaseLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(),
|
||||
result -> {
|
||||
if(result.getResultCode() == 201) {
|
||||
assert result.getData() != null;
|
||||
if(result.getData().getBooleanExtra("updateReleases", false)) {
|
||||
if(fragmentRefreshListenerReleases != null) fragmentRefreshListenerReleases.onRefresh(null);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
private final ActivityResultLauncher<Intent> createMilestoneLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(),
|
||||
result -> {
|
||||
if(result.getResultCode() == 201) {
|
||||
assert result.getData() != null;
|
||||
if(result.getData().getBooleanExtra("milestoneCreated", false)) {
|
||||
if(fragmentRefreshListenerMilestone != null) fragmentRefreshListenerMilestone.onRefresh(repository.getMilestoneState().toString());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
private final ActivityResultLauncher<Intent> editFileLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(),
|
||||
result -> {
|
||||
if(result.getResultCode() == 200) {
|
||||
assert result.getData() != null;
|
||||
if(result.getData().getBooleanExtra("fileModified", false)) {
|
||||
if(fragmentRefreshListenerFiles != null) fragmentRefreshListenerFiles.onRefresh(repository.getBranchRef());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
private final ActivityResultLauncher<Intent> settingsLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(),
|
||||
result -> {
|
||||
if(result.getResultCode() == 200) {
|
||||
assert result.getData() != null;
|
||||
if(result.getData().getBooleanExtra("nameChanged", false)) {
|
||||
recreate();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
@ -92,33 +136,17 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
||||
|
||||
setContentView(R.layout.activity_repo_detail);
|
||||
|
||||
String[] repoNameParts = tinyDB.getString("repoFullName").split("/");
|
||||
repositoryOwner = repoNameParts[0];
|
||||
repositoryName = repoNameParts[1];
|
||||
repository = RepositoryContext.fromIntent(getIntent());
|
||||
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
|
||||
TextView toolbarTitle = findViewById(R.id.toolbar_title);
|
||||
ImageView repoTypeToolbar = findViewById(R.id.repoTypeToolbar);
|
||||
|
||||
if(tinyDB.getString("repoType").equalsIgnoreCase("private")) {
|
||||
repoTypeToolbar.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
repoTypeToolbar.setVisibility(View.GONE);
|
||||
}
|
||||
toolbarTitle.setText(repositoryName);
|
||||
toolbarTitle.setText(repository.getName());
|
||||
|
||||
setSupportActionBar(toolbar);
|
||||
Objects.requireNonNull(getSupportActionBar()).setTitle(repositoryName);
|
||||
Objects.requireNonNull(getSupportActionBar()).setTitle(repository.getName());
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
tinyDB.putString("repoIssuesState", "open");
|
||||
tinyDB.putString("repoPrState", "open");
|
||||
tinyDB.putString("milestoneState", "open");
|
||||
|
||||
Typeface myTypeface;
|
||||
|
||||
switch(tinyDB.getInt("customFontId", -1)) {
|
||||
|
||||
case 0:
|
||||
@ -137,208 +165,16 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
||||
|
||||
toolbarTitle.setTypeface(myTypeface);
|
||||
|
||||
TabLayout tabLayout = findViewById(R.id.tabs);
|
||||
getRepoInfo(getAccount().getAuthorization(), repository.getOwner(), repository.getName());
|
||||
|
||||
ViewGroup viewGroup = (ViewGroup) tabLayout.getChildAt(0);
|
||||
tabsCount = viewGroup.getChildCount();
|
||||
|
||||
for(int j = 0; j < tabsCount; j++) {
|
||||
|
||||
ViewGroup vgTab = (ViewGroup) viewGroup.getChildAt(j);
|
||||
int tabChildCount = vgTab.getChildCount();
|
||||
|
||||
for(int i = 0; i < tabChildCount; i++) {
|
||||
|
||||
View tabViewChild = vgTab.getChildAt(i);
|
||||
|
||||
if(tabViewChild instanceof TextView) {
|
||||
|
||||
((TextView) tabViewChild).setTypeface(myTypeface);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Only show collaborators tab, if you have permission to
|
||||
View collaboratorTab = viewGroup.getChildAt(7);
|
||||
|
||||
if(tinyDB.getBoolean("isRepoAdmin") || new Version(tinyDB.getString("giteaVersion")).higherOrEqual("1.12.0")) {
|
||||
|
||||
collaboratorTab.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
|
||||
tabsCount--;
|
||||
collaboratorTab.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
mViewPager = findViewById(R.id.container);
|
||||
|
||||
mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
|
||||
tabLayout.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(mViewPager));
|
||||
|
||||
SectionsPagerAdapter mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
|
||||
mViewPager.setAdapter(mSectionsPagerAdapter);
|
||||
|
||||
if(tinyDB.getBoolean("enableCounterBadges")) {
|
||||
|
||||
@SuppressLint("InflateParams") View tabHeader2 = LayoutInflater.from(this).inflate(R.layout.badge_issue, null);
|
||||
textViewBadgeIssue = tabHeader2.findViewById(R.id.counterBadgeIssue);
|
||||
|
||||
@SuppressLint("InflateParams") View tabHeader4 = LayoutInflater.from(this).inflate(R.layout.badge_pull, null);
|
||||
textViewBadgePull = tabHeader4.findViewById(R.id.counterBadgePull);
|
||||
|
||||
@SuppressLint("InflateParams") View tabHeader6 = LayoutInflater.from(this).inflate(R.layout.badge_release, null);
|
||||
textViewBadgeRelease = tabHeader6.findViewById(R.id.counterBadgeRelease);
|
||||
|
||||
textViewBadgeIssue.setVisibility(View.GONE);
|
||||
textViewBadgePull.setVisibility(View.GONE);
|
||||
textViewBadgeRelease.setVisibility(View.GONE);
|
||||
|
||||
getRepoInfo(Authorization.get(ctx), repositoryOwner, repositoryName);
|
||||
ColorStateList textColor = tabLayout.getTabTextColors();
|
||||
|
||||
// Issue count
|
||||
if(textViewBadgeIssue.getText() != "") {
|
||||
|
||||
TabLayout.Tab tabOpenIssues = tabLayout.getTabAt(2);
|
||||
Objects.requireNonNull(tabLayout.getTabAt(2)).setCustomView(tabHeader2);
|
||||
assert tabOpenIssues != null; // FIXME This should be cleaned up
|
||||
TextView openIssueTabView = Objects.requireNonNull(tabOpenIssues.getCustomView()).findViewById(R.id.counterBadgeIssueText);
|
||||
openIssueTabView.setTextColor(textColor);
|
||||
}
|
||||
|
||||
// Pull request count
|
||||
if(textViewBadgePull.getText() != "") { // only show if API returned a number
|
||||
|
||||
Objects.requireNonNull(tabLayout.getTabAt(3)).setCustomView(tabHeader4);
|
||||
TabLayout.Tab tabOpenPulls = tabLayout.getTabAt(3);
|
||||
assert tabOpenPulls != null; // FIXME This should be cleaned up
|
||||
TextView openPullTabView = Objects.requireNonNull(tabOpenPulls.getCustomView()).findViewById(R.id.counterBadgePullText);
|
||||
openPullTabView.setTextColor(textColor);
|
||||
}
|
||||
|
||||
// Release count
|
||||
if(new Version("1.11.4").less(tinyDB.getString("giteaVersion"))) {
|
||||
|
||||
if(textViewBadgeRelease.getText() != "") { // only show if API returned a number
|
||||
|
||||
Objects.requireNonNull(tabLayout.getTabAt(4)).setCustomView(tabHeader6);
|
||||
TabLayout.Tab tabOpenRelease = tabLayout.getTabAt(4);
|
||||
assert tabOpenRelease != null; // FIXME This should be cleaned up
|
||||
TextView openReleaseTabView = Objects.requireNonNull(tabOpenRelease.getCustomView()).findViewById(R.id.counterBadgeReleaseText);
|
||||
openReleaseTabView.setTextColor(textColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Intent mainIntent = getIntent();
|
||||
String goToSection = mainIntent.getStringExtra("goToSection");
|
||||
String goToSectionType = mainIntent.getStringExtra("goToSectionType");
|
||||
|
||||
if(goToSection != null) {
|
||||
|
||||
mainIntent.removeExtra("goToSection");
|
||||
mainIntent.removeExtra("goToSectionType");
|
||||
|
||||
switch(goToSectionType) {
|
||||
case "branchesList":
|
||||
RepoDetailActivity.mViewPager.setCurrentItem(1);
|
||||
chooseBranch();
|
||||
break;
|
||||
case "branch":
|
||||
RepoDetailActivity.mViewPager.setCurrentItem(1);
|
||||
String selectedBranch = mainIntent.getStringExtra("selectedBranch");
|
||||
tinyDB.putString("repoBranch", selectedBranch);
|
||||
if(getFragmentRefreshListenerFiles() != null) {
|
||||
getFragmentRefreshListenerFiles().onRefresh(selectedBranch);
|
||||
}
|
||||
break;
|
||||
case "file":
|
||||
RepoDetailActivity.mViewPager.setCurrentItem(1);
|
||||
String branch1 = mainIntent.getStringExtra("branch");
|
||||
tinyDB.putString("repoBranch", branch1);
|
||||
if(getFragmentRefreshListenerFiles() != null) {
|
||||
getFragmentRefreshListenerFiles().onRefresh(branch1);
|
||||
}
|
||||
Intent intent = new Intent(ctx, FileViewActivity.class);
|
||||
intent.putExtra("file", mainIntent.getSerializableExtra("file"));
|
||||
startActivity(intent);
|
||||
break;
|
||||
case "dir":
|
||||
RepoDetailActivity.mViewPager.setCurrentItem(1);
|
||||
String branch2 = mainIntent.getStringExtra("branch");
|
||||
tinyDB.putString("repoBranch", branch2);
|
||||
if(getFragmentRefreshListenerFiles() != null) {
|
||||
getFragmentRefreshListenerFiles().onRefresh(branch2);
|
||||
}
|
||||
//((SectionsPagerAdapter) Objects.requireNonNull(RepoDetailActivity.mViewPager.getAdapter())).getItem(1);
|
||||
break;
|
||||
case "commitsList":
|
||||
RepoDetailActivity.mViewPager.setCurrentItem(1);
|
||||
String branch = mainIntent.getStringExtra("branchName");
|
||||
tinyDB.putString("repoBranch", branch);
|
||||
if(getFragmentRefreshListenerFiles() != null) {
|
||||
getFragmentRefreshListenerFiles().onRefresh(branch);
|
||||
}
|
||||
Intent intent1 = new Intent(ctx, CommitsActivity.class);
|
||||
intent1.putExtra("branchName", branch);
|
||||
ctx.startActivity(intent1);
|
||||
break;
|
||||
case "commit":
|
||||
Intent intent2 = new Intent(ctx, CommitDetailActivity.class);
|
||||
intent2.putExtra("sha", mainIntent.getStringExtra("sha"));
|
||||
ctx.startActivity(intent2);
|
||||
break;
|
||||
case "issue":
|
||||
RepoDetailActivity.mViewPager.setCurrentItem(2);
|
||||
break;
|
||||
case "issueNew":
|
||||
RepoDetailActivity.mViewPager.setCurrentItem(2);
|
||||
startActivity(new Intent(RepoDetailActivity.this, CreateIssueActivity.class));
|
||||
break;
|
||||
case "pull":
|
||||
RepoDetailActivity.mViewPager.setCurrentItem(3);
|
||||
break;
|
||||
case "pullNew":
|
||||
RepoDetailActivity.mViewPager.setCurrentItem(3);
|
||||
startActivity(new Intent(RepoDetailActivity.this, CreatePullRequestActivity.class));
|
||||
break;
|
||||
case "releases":
|
||||
RepoDetailActivity.mViewPager.setCurrentItem(4);
|
||||
break;
|
||||
case "newRelease":
|
||||
RepoDetailActivity.mViewPager.setCurrentItem(4);
|
||||
startActivity(new Intent(RepoDetailActivity.this, CreateReleaseActivity.class));
|
||||
break;
|
||||
case "milestones":
|
||||
RepoDetailActivity.mViewPager.setCurrentItem(5);
|
||||
break;
|
||||
case "milestonesNew":
|
||||
RepoDetailActivity.mViewPager.setCurrentItem(5);
|
||||
startActivity(new Intent(RepoDetailActivity.this, CreateMilestoneActivity.class));
|
||||
break;
|
||||
case "labels":
|
||||
RepoDetailActivity.mViewPager.setCurrentItem(6);
|
||||
break;
|
||||
case "settings":
|
||||
startActivity(new Intent(RepoDetailActivity.this, RepositorySettingsActivity.class));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
checkRepositoryStarStatus(Authorization.get(ctx), repositoryOwner, repositoryName);
|
||||
checkRepositoryWatchStatus(Authorization.get(ctx), repositoryOwner, repositoryName);
|
||||
checkRepositoryStarStatus(getAccount().getAuthorization(), repository.getOwner(), repository.getName());
|
||||
checkRepositoryWatchStatus(getAccount().getAuthorization(), repository.getOwner(), repository.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
|
||||
super.onResume();
|
||||
|
||||
if(tinyDB.getBoolean("enableCounterIssueBadge")) {
|
||||
|
||||
getRepoInfo(Authorization.get(ctx), repositoryOwner, repositoryName);
|
||||
}
|
||||
repository.checkAccountSwitch(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -361,8 +197,10 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
||||
}
|
||||
else if(id == R.id.repoMenu) {
|
||||
|
||||
BottomSheetRepoFragment bottomSheet = new BottomSheetRepoFragment();
|
||||
bottomSheet.show(getSupportFragmentManager(), "repoBottomSheet");
|
||||
if(repository.hasRepository()) {
|
||||
BottomSheetRepoFragment bottomSheet = new BottomSheetRepoFragment(repository);
|
||||
bottomSheet.show(getSupportFragmentManager(), "repoBottomSheet");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if(id == R.id.filter) {
|
||||
@ -390,12 +228,12 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
||||
}
|
||||
else if(id == R.id.branchCommits) {
|
||||
|
||||
Intent intent = new Intent(ctx, CommitsActivity.class);
|
||||
intent.putExtra("branchName", tinyDB.getString("repoBranch"));
|
||||
Intent intent = repository.getIntent(ctx, CommitsActivity.class);
|
||||
|
||||
ctx.startActivity(intent);
|
||||
return true;
|
||||
}
|
||||
else if(id == R.id.filterReleases && new Version(tinyDB.getString("giteaVersion")).higherOrEqual("1.15.0")) {
|
||||
else if(id == R.id.filterReleases && getAccount().requiresVersion("1.15.0")) {
|
||||
BottomSheetReleasesTagsFragment bottomSheetReleasesTagsFragment = new BottomSheetReleasesTagsFragment();
|
||||
bottomSheetReleasesTagsFragment.show(getSupportFragmentManager(), "repoFilterReleasesMenuBottomSheet");
|
||||
return true;
|
||||
@ -412,19 +250,19 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
||||
|
||||
case "label":
|
||||
|
||||
startActivity(new Intent(RepoDetailActivity.this, CreateLabelActivity.class));
|
||||
startActivity(repository.getIntent(ctx, CreateLabelActivity.class));
|
||||
break;
|
||||
case "newIssue":
|
||||
|
||||
startActivity(new Intent(RepoDetailActivity.this, CreateIssueActivity.class));
|
||||
startActivity(repository.getIntent(ctx, CreateIssueActivity.class));
|
||||
break;
|
||||
case "newMilestone":
|
||||
|
||||
startActivity(new Intent(RepoDetailActivity.this, CreateMilestoneActivity.class));
|
||||
createMilestoneLauncher.launch(repository.getIntent(ctx, CreateMilestoneActivity.class));
|
||||
break;
|
||||
case "addCollaborator":
|
||||
|
||||
startActivity(new Intent(RepoDetailActivity.this, AddCollaboratorToRepositoryActivity.class));
|
||||
startActivity(repository.getIntent(ctx, AddCollaboratorToRepositoryActivity.class));
|
||||
break;
|
||||
case "chooseBranch":
|
||||
|
||||
@ -432,71 +270,70 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
||||
break;
|
||||
case "createRelease":
|
||||
|
||||
startActivity(new Intent(RepoDetailActivity.this, CreateReleaseActivity.class));
|
||||
createReleaseLauncher.launch(repository.getIntent(ctx, CreateReleaseActivity.class));
|
||||
break;
|
||||
case "openWebRepo":
|
||||
AppUtil.openUrlInBrowser(this, tinyDB.getString("repoHtmlUrl"));
|
||||
AppUtil.openUrlInBrowser(this, repository.getRepository().getHtml_url());
|
||||
break;
|
||||
case "shareRepo":
|
||||
|
||||
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
|
||||
sharingIntent.setType("text/plain");
|
||||
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, tinyDB.getString("repoHtmlUrl"));
|
||||
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, tinyDB.getString("repoHtmlUrl"));
|
||||
startActivity(Intent.createChooser(sharingIntent, tinyDB.getString("repoHtmlUrl")));
|
||||
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, repository.getRepository().getHtml_url());
|
||||
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, repository.getRepository().getHtml_url());
|
||||
startActivity(Intent.createChooser(sharingIntent, repository.getRepository().getHtml_url()));
|
||||
break;
|
||||
case "copyRepoUrl":
|
||||
|
||||
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(ctx).getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipData clip = ClipData.newPlainText("repoUrl", tinyDB.getString("repoHtmlUrl"));
|
||||
ClipData clip = ClipData.newPlainText("repoUrl", repository.getRepository().getHtml_url());
|
||||
assert clipboard != null;
|
||||
clipboard.setPrimaryClip(clip);
|
||||
Toasty.info(ctx, ctx.getString(R.string.copyIssueUrlToastMsg));
|
||||
break;
|
||||
case "newFile":
|
||||
|
||||
startActivity(new Intent(RepoDetailActivity.this, CreateFileActivity.class));
|
||||
editFileLauncher.launch(repository.getIntent(ctx, CreateFileActivity.class));
|
||||
break;
|
||||
case "filterByMilestone":
|
||||
filterIssuesByMilestone();
|
||||
break;
|
||||
case "openIssues":
|
||||
|
||||
repository.setIssueState(RepositoryContext.State.OPEN);
|
||||
if(getFragmentRefreshListener() != null) {
|
||||
|
||||
getFragmentRefreshListener().onRefresh("open");
|
||||
}
|
||||
break;
|
||||
case "closedIssues":
|
||||
|
||||
repository.setIssueState(RepositoryContext.State.CLOSED);
|
||||
if(getFragmentRefreshListener() != null) {
|
||||
|
||||
getFragmentRefreshListener().onRefresh("closed");
|
||||
}
|
||||
break;
|
||||
case "openPr":
|
||||
|
||||
repository.setPrState(RepositoryContext.State.OPEN);
|
||||
if(getFragmentRefreshListenerPr() != null) {
|
||||
|
||||
getFragmentRefreshListenerPr().onRefresh("open");
|
||||
}
|
||||
break;
|
||||
case "closedPr":
|
||||
|
||||
repository.setPrState(RepositoryContext.State.CLOSED);
|
||||
if(getFragmentRefreshListenerPr() != null) {
|
||||
|
||||
getFragmentRefreshListenerPr().onRefresh("closed");
|
||||
}
|
||||
break;
|
||||
case "openMilestone":
|
||||
|
||||
repository.setMilestoneState(RepositoryContext.State.OPEN);
|
||||
if(getFragmentRefreshListenerMilestone() != null) {
|
||||
|
||||
getFragmentRefreshListenerMilestone().onRefresh("open");
|
||||
}
|
||||
break;
|
||||
case "closedMilestone":
|
||||
|
||||
repository.setMilestoneState(RepositoryContext.State.CLOSED);
|
||||
if(getFragmentRefreshListenerMilestone() != null) {
|
||||
|
||||
getFragmentRefreshListenerMilestone().onRefresh("closed");
|
||||
@ -504,11 +341,11 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
||||
break;
|
||||
case "repoSettings":
|
||||
|
||||
startActivity(new Intent(RepoDetailActivity.this, RepositorySettingsActivity.class));
|
||||
settingsLauncher.launch(repository.getIntent(ctx, RepositorySettingsActivity.class));
|
||||
break;
|
||||
case "newPullRequest":
|
||||
|
||||
startActivity(new Intent(RepoDetailActivity.this, CreatePullRequestActivity.class));
|
||||
startActivity(repository.getIntent(ctx, CreatePullRequestActivity.class));
|
||||
break;
|
||||
case "tags":
|
||||
if(getFragmentRefreshListenerReleases() != null) {
|
||||
@ -520,6 +357,18 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
||||
getFragmentRefreshListenerReleases().onRefresh("releases");
|
||||
}
|
||||
break;
|
||||
case "unwatch":
|
||||
repository.setWatched(false);
|
||||
break;
|
||||
case "watch":
|
||||
repository.setWatched(true);
|
||||
break;
|
||||
case "unstar":
|
||||
repository.setStarred(false);
|
||||
break;
|
||||
case "star":
|
||||
repository.setStarred(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -531,7 +380,7 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
||||
|
||||
Call<List<Milestones>> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.getMilestones(Authorization.get(ctx), repositoryOwner, repositoryName, 1, 50, "open");
|
||||
.getMilestones(getAccount().getAuthorization(), repository.getOwner(), repository.getName(), 1, 50, "open");
|
||||
|
||||
call.enqueue(new Callback<List<Milestones>>() {
|
||||
|
||||
@ -550,11 +399,8 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
||||
for(int i = 0; i < response.body().size(); i++) {
|
||||
milestones = response.body().get(i);
|
||||
milestonesList.add(milestones.getTitle());
|
||||
}
|
||||
|
||||
for(int j = 0; j < milestonesList.size(); j++) {
|
||||
if(tinyDB.getString("issueMilestoneFilterId").equals(milestonesList.get(j))) {
|
||||
selectedMilestone = j;
|
||||
if(repository.getIssueMilestoneFilterName().equals(milestones.getTitle())) {
|
||||
selectedMilestone = i;
|
||||
}
|
||||
}
|
||||
|
||||
@ -563,7 +409,7 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
||||
|
||||
pBuilder.setSingleChoiceItems(milestonesList.toArray(new String[0]), selectedMilestone, (dialogInterface, i) -> {
|
||||
|
||||
tinyDB.putString("issueMilestoneFilterId", milestonesList.get(i));
|
||||
repository.setIssueMilestoneFilterName(response.body().get(i).getTitle());
|
||||
|
||||
if(getFragmentRefreshListenerFilterIssuesByMilestone() != null) {
|
||||
getFragmentRefreshListenerFilterIssuesByMilestone().onRefresh(milestonesList.get(i));
|
||||
@ -587,12 +433,13 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
||||
private void chooseBranch() {
|
||||
|
||||
Dialog progressDialog = new Dialog(this);
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.setContentView(R.layout.custom_progress_loader);
|
||||
progressDialog.show();
|
||||
|
||||
Call<List<Branches>> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.getBranches(Authorization.get(ctx), repositoryOwner, repositoryName);
|
||||
.getBranches(getAccount().getAuthorization(), repository.getOwner(), repository.getName());
|
||||
|
||||
call.enqueue(new Callback<List<Branches>>() {
|
||||
|
||||
@ -611,7 +458,7 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
||||
Branches branches = response.body().get(i);
|
||||
branchesList.add(branches.getName());
|
||||
|
||||
if(tinyDB.getString("repoBranch").equals(branches.getName())) {
|
||||
if(repository.getBranchRef().equals(branches.getName())) {
|
||||
selectedBranch = i;
|
||||
}
|
||||
}
|
||||
@ -621,7 +468,7 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
||||
|
||||
pBuilder.setSingleChoiceItems(branchesList.toArray(new String[0]), selectedBranch, (dialogInterface, i) -> {
|
||||
|
||||
tinyDB.putString("repoBranch", branchesList.get(i));
|
||||
repository.setBranchRef(branchesList.get(i));
|
||||
|
||||
if(getFragmentRefreshListenerFiles() != null) {
|
||||
getFragmentRefreshListenerFiles().onRefresh(branchesList.get(i));
|
||||
@ -645,45 +492,43 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
||||
public class SectionsPagerAdapter extends FragmentStatePagerAdapter {
|
||||
|
||||
SectionsPagerAdapter(FragmentManager fm) {
|
||||
|
||||
super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment getItem(int position) {
|
||||
|
||||
Fragment fragment = null;
|
||||
|
||||
switch(position) {
|
||||
|
||||
case 0: // Repository details
|
||||
|
||||
return RepoInfoFragment.newInstance(repositoryOwner, repositoryName);
|
||||
return RepoInfoFragment.newInstance(repository);
|
||||
case 1: // Files
|
||||
|
||||
return FilesFragment.newInstance(repositoryOwner, repositoryName, tinyDB.getString("repoBranch"));
|
||||
return FilesFragment.newInstance(repository);
|
||||
case 2: // Issues
|
||||
|
||||
fragment = new IssuesFragment();
|
||||
fragment = IssuesFragment.newInstance(repository);
|
||||
break;
|
||||
case 3: // Pull requests
|
||||
|
||||
fragment = new PullRequestsFragment();
|
||||
fragment = PullRequestsFragment.newInstance(repository);
|
||||
break;
|
||||
case 4: // Releases
|
||||
|
||||
return ReleasesFragment.newInstance(repositoryOwner, repositoryName);
|
||||
return ReleasesFragment.newInstance(repository);
|
||||
case 5: // Milestones
|
||||
|
||||
fragment = new MilestonesFragment();
|
||||
fragment = MilestonesFragment.newInstance(repository);
|
||||
break;
|
||||
case 6: // Labels
|
||||
|
||||
return LabelsFragment.newInstance(repositoryOwner, repositoryName);
|
||||
return LabelsFragment.newInstance(repository);
|
||||
case 7: // Collaborators
|
||||
|
||||
return CollaboratorsFragment.newInstance(repositoryOwner, repositoryName);
|
||||
return CollaboratorsFragment.newInstance(repository);
|
||||
}
|
||||
|
||||
assert fragment != null;
|
||||
@ -699,6 +544,13 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
||||
|
||||
private void getRepoInfo(String token, final String owner, String repo) {
|
||||
|
||||
LinearProgressIndicator loading = findViewById(R.id.loadingIndicator);
|
||||
if(repository.hasRepository()) {
|
||||
loading.setVisibility(View.GONE);
|
||||
initWithRepo();
|
||||
return;
|
||||
}
|
||||
|
||||
Call<UserRepositories> call = RetrofitClient.getApiInterface(ctx).getUserRepository(token, owner, repo);
|
||||
call.enqueue(new Callback<UserRepositories>() {
|
||||
|
||||
@ -706,49 +558,213 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
||||
public void onResponse(@NonNull Call<UserRepositories> call, @NonNull retrofit2.Response<UserRepositories> response) {
|
||||
|
||||
UserRepositories repoInfo = response.body();
|
||||
loading.setVisibility(View.GONE);
|
||||
|
||||
if(response.code() == 200) {
|
||||
|
||||
if(tinyDB.getBoolean("enableCounterBadges")) {
|
||||
|
||||
assert repoInfo != null;
|
||||
|
||||
if(repoInfo.getOpen_issues_count() != null) {
|
||||
|
||||
textViewBadgeIssue.setVisibility(View.VISIBLE);
|
||||
textViewBadgeIssue.setText(repoInfo.getOpen_issues_count());
|
||||
}
|
||||
|
||||
if(repoInfo.getOpen_pull_count() != null) {
|
||||
|
||||
textViewBadgePull.setVisibility(View.VISIBLE);
|
||||
textViewBadgePull.setText(repoInfo.getOpen_pull_count());
|
||||
}
|
||||
|
||||
if(repoInfo.getRelease_count() != null) {
|
||||
|
||||
textViewBadgeRelease.setVisibility(View.VISIBLE);
|
||||
textViewBadgeRelease.setText(repoInfo.getRelease_count());
|
||||
}
|
||||
}
|
||||
|
||||
assert repoInfo != null;
|
||||
repository.setRepository(repoInfo);
|
||||
initWithRepo();
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
Log.e("onFailure", String.valueOf(response.code()));
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<UserRepositories> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
Log.e("onFailure", t.toString());
|
||||
finish();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void initWithRepo() {
|
||||
repository.setBranchRef(repository.getRepository().getDefault_branch());
|
||||
|
||||
ImageView repoTypeToolbar = findViewById(R.id.repoTypeToolbar);
|
||||
if(repository.getRepository().isPrivateFlag()) {
|
||||
repoTypeToolbar.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
repoTypeToolbar.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
TabLayout tabLayout = findViewById(R.id.tabs);
|
||||
tabLayout.setVisibility(View.VISIBLE);
|
||||
|
||||
ViewGroup viewGroup = (ViewGroup) tabLayout.getChildAt(0);
|
||||
tabsCount = viewGroup.getChildCount();
|
||||
|
||||
for(int j = 0; j < tabsCount; j++) {
|
||||
|
||||
ViewGroup vgTab = (ViewGroup) viewGroup.getChildAt(j);
|
||||
int tabChildCount = vgTab.getChildCount();
|
||||
|
||||
for(int i = 0; i < tabChildCount; i++) {
|
||||
|
||||
View tabViewChild = vgTab.getChildAt(i);
|
||||
|
||||
if(tabViewChild instanceof TextView) {
|
||||
|
||||
((TextView) tabViewChild).setTypeface(myTypeface);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mViewPager = findViewById(R.id.container);
|
||||
mViewPager.setVisibility(View.VISIBLE);
|
||||
|
||||
mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
|
||||
tabLayout.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(mViewPager));
|
||||
|
||||
SectionsPagerAdapter mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
|
||||
mViewPager.setAdapter(mSectionsPagerAdapter);
|
||||
|
||||
if(tinyDB.getBoolean("enableCounterBadges", true)) {
|
||||
@SuppressLint("InflateParams") View tabHeader2 = LayoutInflater.from(ctx).inflate(R.layout.badge_issue, null);
|
||||
textViewBadgeIssue = tabHeader2.findViewById(R.id.counterBadgeIssue);
|
||||
|
||||
@SuppressLint("InflateParams") View tabHeader4 = LayoutInflater.from(ctx).inflate(R.layout.badge_pull, null);
|
||||
textViewBadgePull = tabHeader4.findViewById(R.id.counterBadgePull);
|
||||
|
||||
@SuppressLint("InflateParams") View tabHeader6 = LayoutInflater.from(ctx).inflate(R.layout.badge_release, null);
|
||||
textViewBadgeRelease = tabHeader6.findViewById(R.id.counterBadgeRelease);
|
||||
|
||||
ColorStateList textColor = tabLayout.getTabTextColors();
|
||||
|
||||
if(repository.getRepository().getOpen_issues_count() != null) {
|
||||
textViewBadgeIssue.setVisibility(View.VISIBLE);
|
||||
textViewBadgeIssue.setText(repository.getRepository().getOpen_issues_count());
|
||||
|
||||
TabLayout.Tab tabOpenIssues = tabLayout.getTabAt(2);
|
||||
assert tabOpenIssues != null;
|
||||
|
||||
tabOpenIssues.setCustomView(tabHeader2);
|
||||
TextView openIssueTabView = Objects.requireNonNull(tabOpenIssues.getCustomView()).findViewById(R.id.counterBadgeIssueText);
|
||||
openIssueTabView.setTextColor(textColor);
|
||||
} else {
|
||||
textViewBadgeIssue.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if(repository.getRepository().getOpen_pull_count() != null) {
|
||||
textViewBadgePull.setVisibility(View.VISIBLE);
|
||||
textViewBadgePull.setText(repository.getRepository().getOpen_pull_count());
|
||||
|
||||
Objects.requireNonNull(tabLayout.getTabAt(3)).setCustomView(tabHeader4);
|
||||
TabLayout.Tab tabOpenPulls = tabLayout.getTabAt(3);
|
||||
assert tabOpenPulls != null; // FIXME This should be cleaned up
|
||||
TextView openPullTabView = Objects.requireNonNull(tabOpenPulls.getCustomView()).findViewById(R.id.counterBadgePullText);
|
||||
openPullTabView.setTextColor(textColor);
|
||||
} else {
|
||||
textViewBadgePull.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if(repository.getRepository().getRelease_count() != null) {
|
||||
textViewBadgeRelease.setVisibility(View.VISIBLE);
|
||||
textViewBadgeRelease.setText(repository.getRepository().getRelease_count());
|
||||
|
||||
Objects.requireNonNull(tabLayout.getTabAt(4)).setCustomView(tabHeader6);
|
||||
TabLayout.Tab tabOpenRelease = tabLayout.getTabAt(4);
|
||||
assert tabOpenRelease != null; // FIXME This should be cleaned up
|
||||
TextView openReleaseTabView = Objects.requireNonNull(tabOpenRelease.getCustomView()).findViewById(R.id.counterBadgeReleaseText);
|
||||
openReleaseTabView.setTextColor(textColor);
|
||||
} else {
|
||||
textViewBadgeRelease.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
Intent mainIntent = getIntent();
|
||||
String goToSection = mainIntent.getStringExtra("goToSection");
|
||||
String goToSectionType = mainIntent.getStringExtra("goToSectionType");
|
||||
|
||||
if(goToSection != null) {
|
||||
mainIntent.removeExtra("goToSection");
|
||||
mainIntent.removeExtra("goToSectionType");
|
||||
|
||||
switch(goToSectionType) {
|
||||
case "branchesList":
|
||||
mViewPager.setCurrentItem(1);
|
||||
chooseBranch();
|
||||
break;
|
||||
case "branch":
|
||||
mViewPager.setCurrentItem(1);
|
||||
String selectedBranch = mainIntent.getStringExtra("selectedBranch");
|
||||
repository.setBranchRef(selectedBranch);
|
||||
if(getFragmentRefreshListenerFiles() != null) {
|
||||
getFragmentRefreshListenerFiles().onRefresh(selectedBranch);
|
||||
}
|
||||
break;
|
||||
case "file":
|
||||
mViewPager.setCurrentItem(1);
|
||||
String branch1 = mainIntent.getStringExtra("branch");
|
||||
repository.setBranchRef(branch1);
|
||||
if(getFragmentRefreshListenerFiles() != null) {
|
||||
getFragmentRefreshListenerFiles().onRefresh(branch1);
|
||||
}
|
||||
Intent intent = repository.getIntent(ctx, FileViewActivity.class);
|
||||
intent.putExtra("file", mainIntent.getSerializableExtra("file"));
|
||||
startActivity(intent);
|
||||
break;
|
||||
case "dir":
|
||||
mViewPager.setCurrentItem(1);
|
||||
String branch2 = mainIntent.getStringExtra("branch");
|
||||
repository.setBranchRef(branch2);
|
||||
if(getFragmentRefreshListenerFiles() != null) {
|
||||
getFragmentRefreshListenerFiles().onRefresh(branch2);
|
||||
}
|
||||
break;
|
||||
case "commitsList":
|
||||
mViewPager.setCurrentItem(1);
|
||||
String branch = mainIntent.getStringExtra("branchName");
|
||||
repository.setBranchRef(branch);
|
||||
if(getFragmentRefreshListenerFiles() != null) {
|
||||
getFragmentRefreshListenerFiles().onRefresh(branch);
|
||||
}
|
||||
Intent intent1 = repository.getIntent(ctx, CommitsActivity.class);
|
||||
ctx.startActivity(intent1);
|
||||
break;
|
||||
case "issue":
|
||||
mViewPager.setCurrentItem(2);
|
||||
break;
|
||||
case "issueNew":
|
||||
mViewPager.setCurrentItem(2);
|
||||
startActivity(repository.getIntent(ctx, CreateIssueActivity.class));
|
||||
break;
|
||||
case "pull":
|
||||
mViewPager.setCurrentItem(3);
|
||||
break;
|
||||
case "pullNew":
|
||||
mViewPager.setCurrentItem(3);
|
||||
startActivity(repository.getIntent(ctx, CreatePullRequestActivity.class));
|
||||
break;
|
||||
case "releases":
|
||||
mViewPager.setCurrentItem(4);
|
||||
break;
|
||||
case "newRelease":
|
||||
mViewPager.setCurrentItem(4);
|
||||
createReleaseLauncher.launch(repository.getIntent(ctx, CreateReleaseActivity.class));
|
||||
break;
|
||||
case "milestones":
|
||||
mViewPager.setCurrentItem(5);
|
||||
break;
|
||||
case "milestonesNew":
|
||||
mViewPager.setCurrentItem(5);
|
||||
createMilestoneLauncher.launch(repository.getIntent(ctx, CreateMilestoneActivity.class));
|
||||
break;
|
||||
case "labels":
|
||||
mViewPager.setCurrentItem(6);
|
||||
break;
|
||||
case "settings":
|
||||
settingsLauncher.launch(repository.getIntent(ctx, RepositorySettingsActivity.class));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkRepositoryStarStatus(String instanceToken, final String owner, String repo) {
|
||||
|
||||
Call<JsonElement> call = RetrofitClient.getApiInterface(ctx).checkRepoStarStatus(instanceToken, owner, repo);
|
||||
@ -757,7 +773,7 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
|
||||
|
||||
tinyDB.putInt("repositoryStarStatus", response.code());
|
||||
repository.setStarred(response.code() == 204);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -780,17 +796,11 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
||||
public void onResponse(@NonNull Call<WatchInfo> call, @NonNull retrofit2.Response<WatchInfo> response) {
|
||||
|
||||
if(response.code() == 200) {
|
||||
|
||||
assert response.body() != null;
|
||||
|
||||
if(response.body().getSubscribed()) {
|
||||
|
||||
tinyDB.putBoolean("repositoryWatchStatus", true);
|
||||
}
|
||||
repository.setWatched(response.body().getSubscribed());
|
||||
}
|
||||
else {
|
||||
|
||||
tinyDB.putBoolean("repositoryWatchStatus", false);
|
||||
repository.setWatched(false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -803,19 +813,6 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
if(!isFinishing()) {
|
||||
return;
|
||||
}
|
||||
if(getIntent().getBooleanExtra("switchAccountBackOnFinish", false)) {
|
||||
UserAccount a = BaseApi.getInstance(this, UserAccountsApi.class)
|
||||
.getAccountById(getIntent().getIntExtra("oldAccountId", 0));
|
||||
AppUtil.switchToAccount(this, a);
|
||||
}
|
||||
}
|
||||
|
||||
// Issues milestone filter interface
|
||||
public FragmentRefreshListener getFragmentRefreshListenerFilterIssuesByMilestone() { return fragmentRefreshListenerFilterIssuesByMilestone; }
|
||||
|
||||
|
@ -25,10 +25,7 @@ import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.RepoForksAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.ActivityRepoForksBinding;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.Constants;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
@ -64,8 +61,6 @@ public class RepoForksActivity extends BaseActivity {
|
||||
Toolbar toolbar = activityRepoForksBinding.toolbar;
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||
|
||||
String repoFullNameForForks = getIntent().getStringExtra("repoFullNameForForks");
|
||||
assert repoFullNameForForks != null;
|
||||
String[] parts = repoFullNameForForks.split("/");
|
||||
@ -86,7 +81,8 @@ public class RepoForksActivity extends BaseActivity {
|
||||
});
|
||||
|
||||
// if gitea is 1.12 or higher use the new limit (resultLimitNewGiteaInstances)
|
||||
if(new Version(tinyDb.getString("giteaVersion")).higherOrEqual("1.12")) {
|
||||
if(getAccount().requiresVersion("1.12")) {
|
||||
|
||||
resultLimit = Constants.resultLimitNewGiteaInstances;
|
||||
}
|
||||
|
||||
@ -98,7 +94,7 @@ public class RepoForksActivity extends BaseActivity {
|
||||
swipeRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
|
||||
swipeRefresh.setRefreshing(false);
|
||||
loadInitial(Authorization.get(ctx), repoOwner, repoName, pageSize, resultLimit);
|
||||
loadInitial(getAccount().getAuthorization(), repoOwner, repoName, pageSize, resultLimit);
|
||||
adapter.notifyDataChanged();
|
||||
|
||||
}, 200));
|
||||
@ -109,7 +105,7 @@ public class RepoForksActivity extends BaseActivity {
|
||||
if(forksList.size() == resultLimit || pageSize == resultLimit) {
|
||||
|
||||
int page = (forksList.size() + resultLimit) / resultLimit;
|
||||
loadMore(Authorization.get(ctx), repoOwner, repoName, page, resultLimit);
|
||||
loadMore(getAccount().getAuthorization(), repoOwner, repoName, page, resultLimit);
|
||||
}
|
||||
}));
|
||||
|
||||
@ -117,7 +113,7 @@ public class RepoForksActivity extends BaseActivity {
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(ctx));
|
||||
recyclerView.setAdapter(adapter);
|
||||
|
||||
loadInitial(Authorization.get(ctx), repoOwner, repoName, pageSize, resultLimit);
|
||||
loadInitial(getAccount().getAuthorization(), repoOwner, repoName, pageSize, resultLimit);
|
||||
}
|
||||
|
||||
private void loadInitial(String instanceToken, String repoOwner, String repoName, int pageSize, int resultLimit) {
|
||||
|
@ -10,7 +10,7 @@ import androidx.lifecycle.ViewModelProvider;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.UserGridAdapter;
|
||||
import org.mian.gitnex.databinding.ActivityRepoStargazersBinding;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import org.mian.gitnex.viewmodels.RepoStargazersViewModel;
|
||||
|
||||
/**
|
||||
@ -25,6 +25,8 @@ public class RepoStargazersActivity extends BaseActivity {
|
||||
private GridView mGridView;
|
||||
private ProgressBar mProgressBar;
|
||||
|
||||
private RepositoryContext repository;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
@ -39,17 +41,16 @@ public class RepoStargazersActivity extends BaseActivity {
|
||||
mGridView = activityRepoStargazersBinding.gridView;
|
||||
mProgressBar = activityRepoStargazersBinding.progressBar;
|
||||
|
||||
String repoFullNameForStars = getIntent().getStringExtra("repoFullNameForStars");
|
||||
String[] parts = repoFullNameForStars.split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
repository = RepositoryContext.fromIntent(getIntent());
|
||||
final String repoOwner = repository.getOwner();
|
||||
final String repoName = repository.getName();
|
||||
|
||||
initCloseListener();
|
||||
closeActivity.setOnClickListener(onClickListener);
|
||||
|
||||
toolbarTitle.setText(R.string.repoStargazersInMenu);
|
||||
|
||||
fetchDataAsync(Authorization.get(ctx), repoOwner, repoName);
|
||||
fetchDataAsync(getAccount().getAuthorization(), repoOwner, repoName);
|
||||
}
|
||||
|
||||
private void fetchDataAsync(String instanceToken, String repoOwner, String repoName) {
|
||||
@ -82,4 +83,10 @@ public class RepoStargazersActivity extends BaseActivity {
|
||||
onClickListener = view -> finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
repository.checkAccountSwitch(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import androidx.lifecycle.ViewModelProvider;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.UserGridAdapter;
|
||||
import org.mian.gitnex.databinding.ActivityRepoWatchersBinding;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import org.mian.gitnex.viewmodels.RepoWatchersViewModel;
|
||||
|
||||
/**
|
||||
@ -25,6 +25,8 @@ public class RepoWatchersActivity extends BaseActivity {
|
||||
private GridView mGridView;
|
||||
private ProgressBar mProgressBar;
|
||||
|
||||
private RepositoryContext repository;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
@ -39,17 +41,16 @@ public class RepoWatchersActivity extends BaseActivity {
|
||||
mGridView = activityRepoWatchersBinding.gridView;
|
||||
mProgressBar = activityRepoWatchersBinding.progressBar;
|
||||
|
||||
String repoFullNameForWatchers = getIntent().getStringExtra("repoFullNameForWatchers");
|
||||
String[] parts = repoFullNameForWatchers.split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
repository = RepositoryContext.fromIntent(getIntent());
|
||||
final String repoOwner = repository.getOwner();
|
||||
final String repoName = repository.getName();
|
||||
|
||||
initCloseListener();
|
||||
closeActivity.setOnClickListener(onClickListener);
|
||||
|
||||
toolbarTitle.setText(R.string.repoWatchersInMenu);
|
||||
|
||||
fetchDataAsync(Authorization.get(ctx), repoOwner, repoName);
|
||||
fetchDataAsync(getAccount().getAuthorization(), repoOwner, repoName);
|
||||
}
|
||||
|
||||
private void fetchDataAsync(String instanceToken, String repoOwner, String repoName) {
|
||||
@ -82,4 +83,10 @@ public class RepoWatchersActivity extends BaseActivity {
|
||||
onClickListener = view -> finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
repository.checkAccountSwitch(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ import org.mian.gitnex.databinding.CustomRepositoryDeleteDialogBinding;
|
||||
import org.mian.gitnex.databinding.CustomRepositoryEditPropertiesDialogBinding;
|
||||
import org.mian.gitnex.databinding.CustomRepositoryTransferDialogBinding;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
@ -40,11 +40,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
||||
private Dialog dialogTransferRepository;
|
||||
private View.OnClickListener onClickListener;
|
||||
|
||||
private String loginUid;
|
||||
private String instanceToken;
|
||||
|
||||
private String repositoryOwner;
|
||||
private String repositoryName;
|
||||
private RepositoryContext repository;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
@ -54,12 +50,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
||||
viewBinding = ActivityRepositorySettingsBinding.inflate(getLayoutInflater());
|
||||
setContentView(viewBinding.getRoot());
|
||||
|
||||
loginUid = tinyDB.getString("loginUid");
|
||||
String repoFullName = tinyDB.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
repositoryOwner = parts[0];
|
||||
repositoryName = parts[1];
|
||||
instanceToken = "token " + tinyDB.getString(loginUid + "-token");
|
||||
repository = RepositoryContext.fromIntent(getIntent());
|
||||
|
||||
ImageView closeActivity = findViewById(R.id.close);
|
||||
|
||||
@ -67,7 +58,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
||||
closeActivity.setOnClickListener(onClickListener);
|
||||
|
||||
// require gitea 1.12 or higher
|
||||
if(new Version(tinyDB.getString("giteaVersion")).higherOrEqual("1.12.0")) {
|
||||
if(getAccount().requiresVersion("1.12.0")) {
|
||||
|
||||
viewBinding.transferOwnerFrame.setVisibility(View.VISIBLE);
|
||||
}
|
||||
@ -100,7 +91,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
||||
String newOwner = String.valueOf(transferRepoBinding.ownerNameForTransfer.getText());
|
||||
String repoName = String.valueOf(transferRepoBinding.repoNameForTransfer.getText());
|
||||
|
||||
if(!repositoryName.equals(repoName)) {
|
||||
if(!repository.getName().equals(repoName)) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.repoSettingsDeleteError));
|
||||
}
|
||||
@ -124,7 +115,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
||||
|
||||
Call<JsonElement> transferCall = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.transferRepository(instanceToken, repositoryOwner, repositoryName, repositoryTransfer);
|
||||
.transferRepository(getAccount().getAuthorization(), repository.getOwner(), repository.getName(), repositoryTransfer);
|
||||
|
||||
transferCall.enqueue(new Callback<JsonElement>() {
|
||||
|
||||
@ -140,7 +131,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
||||
Toasty.success(ctx, getString(R.string.repoTransferSuccess));
|
||||
|
||||
finish();
|
||||
BaseApi.getInstance(ctx, RepositoriesApi.class).deleteRepository((int) tinyDB.getLong("repositoryId", 0));
|
||||
BaseApi.getInstance(ctx, RepositoriesApi.class).deleteRepository(repository.getRepositoryId());
|
||||
Intent intent = new Intent(RepositorySettingsActivity.this, MainActivity.class);
|
||||
RepositorySettingsActivity.this.startActivity(intent);
|
||||
}
|
||||
@ -187,7 +178,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
||||
|
||||
deleteRepoBinding.delete.setOnClickListener(deleteRepo -> {
|
||||
|
||||
if(!repositoryName.equals(String.valueOf(deleteRepoBinding.repoNameForDeletion.getText()))) {
|
||||
if(!repository.getName().equals(String.valueOf(deleteRepoBinding.repoNameForDeletion.getText()))) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.repoSettingsDeleteError));
|
||||
}
|
||||
@ -205,7 +196,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
||||
|
||||
Call<JsonElement> deleteCall = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.deleteRepository(instanceToken, repositoryOwner, repositoryName);
|
||||
.deleteRepository(getAccount().getAuthorization(), repository.getOwner(), repository.getName());
|
||||
|
||||
deleteCall.enqueue(new Callback<JsonElement>() {
|
||||
|
||||
@ -221,7 +212,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
||||
Toasty.success(ctx, getString(R.string.repoDeletionSuccess));
|
||||
|
||||
finish();
|
||||
BaseApi.getInstance(ctx, RepositoriesApi.class).deleteRepository((int) tinyDB.getLong("repositoryId", 0));
|
||||
BaseApi.getInstance(ctx, RepositoriesApi.class).deleteRepository(repository.getRepositoryId());
|
||||
Intent intent = new Intent(RepositorySettingsActivity.this, MainActivity.class);
|
||||
RepositorySettingsActivity.this.startActivity(intent);
|
||||
}
|
||||
@ -259,75 +250,47 @@ public class RepositorySettingsActivity extends BaseActivity {
|
||||
dialogProp.setContentView(view);
|
||||
|
||||
propBinding.cancel.setOnClickListener(editProperties -> dialogProp.dismiss());
|
||||
UserRepositories repoInfo = repository.getRepository();
|
||||
|
||||
Call<UserRepositories> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.getUserRepository(instanceToken, repositoryOwner, repositoryName);
|
||||
propBinding.progressBar.setVisibility(View.GONE);
|
||||
propBinding.mainView.setVisibility(View.VISIBLE);
|
||||
|
||||
call.enqueue(new Callback<UserRepositories>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<UserRepositories> call, @NonNull retrofit2.Response<UserRepositories> response) {
|
||||
assert repoInfo != null;
|
||||
propBinding.repoName.setText(repoInfo.getName());
|
||||
propBinding.repoWebsite.setText(repoInfo.getWebsite());
|
||||
propBinding.repoDescription.setText(repoInfo.getDescription());
|
||||
propBinding.repoPrivate.setChecked(repoInfo.getPrivateFlag());
|
||||
propBinding.repoAsTemplate.setChecked(repoInfo.isTemplate());
|
||||
|
||||
UserRepositories repoInfo = response.body();
|
||||
propBinding.repoEnableIssues.setChecked(repoInfo.getHas_issues());
|
||||
|
||||
propBinding.progressBar.setVisibility(View.GONE);
|
||||
propBinding.mainView.setVisibility(View.VISIBLE);
|
||||
|
||||
if (response.code() == 200) {
|
||||
|
||||
assert repoInfo != null;
|
||||
propBinding.repoName.setText(repoInfo.getName());
|
||||
propBinding.repoWebsite.setText(repoInfo.getWebsite());
|
||||
propBinding.repoDescription.setText(repoInfo.getDescription());
|
||||
propBinding.repoPrivate.setChecked(repoInfo.getPrivateFlag());
|
||||
propBinding.repoAsTemplate.setChecked(repoInfo.isTemplate());
|
||||
|
||||
propBinding.repoEnableIssues.setChecked(repoInfo.getHas_issues());
|
||||
|
||||
propBinding.repoEnableIssues.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
|
||||
if (isChecked) {
|
||||
|
||||
propBinding.repoEnableTimer.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
|
||||
propBinding.repoEnableTimer.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
|
||||
if(repoInfo.getInternal_tracker() != null) {
|
||||
|
||||
propBinding.repoEnableTimer.setChecked(repoInfo.getInternal_tracker().isEnable_time_tracker());
|
||||
}
|
||||
else {
|
||||
|
||||
propBinding.repoEnableTimer.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
propBinding.repoEnableWiki.setChecked(repoInfo.isHas_wiki());
|
||||
propBinding.repoEnablePr.setChecked(repoInfo.isHas_pull_requests());
|
||||
propBinding.repoEnableMerge.setChecked(repoInfo.isAllow_merge_commits());
|
||||
propBinding.repoEnableRebase.setChecked(repoInfo.isAllow_rebase());
|
||||
propBinding.repoEnableSquash.setChecked(repoInfo.isAllow_squash_merge());
|
||||
propBinding.repoEnableForceMerge.setChecked(repoInfo.isAllow_rebase_explicit());
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
}
|
||||
propBinding.repoEnableIssues.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
|
||||
if (isChecked) {
|
||||
propBinding.repoEnableTimer.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<UserRepositories> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.genericServerResponseError));
|
||||
else {
|
||||
propBinding.repoEnableTimer.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
|
||||
if(repoInfo.getInternal_tracker() != null) {
|
||||
|
||||
propBinding.repoEnableTimer.setChecked(repoInfo.getInternal_tracker().isEnable_time_tracker());
|
||||
}
|
||||
else {
|
||||
|
||||
propBinding.repoEnableTimer.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
propBinding.repoEnableWiki.setChecked(repoInfo.isHas_wiki());
|
||||
propBinding.repoEnablePr.setChecked(repoInfo.isHas_pull_requests());
|
||||
propBinding.repoEnableMerge.setChecked(repoInfo.isAllow_merge_commits());
|
||||
propBinding.repoEnableRebase.setChecked(repoInfo.isAllow_rebase());
|
||||
propBinding.repoEnableSquash.setChecked(repoInfo.isAllow_squash_merge());
|
||||
propBinding.repoEnableForceMerge.setChecked(repoInfo.isAllow_rebase_explicit());
|
||||
|
||||
propBinding.save.setOnClickListener(saveProperties -> saveRepositoryProperties(String.valueOf(propBinding.repoName.getText()),
|
||||
String.valueOf(propBinding.repoWebsite.getText()),
|
||||
String.valueOf(propBinding.repoDescription.getText()),
|
||||
@ -363,7 +326,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
||||
|
||||
Call<UserRepositories> propsCall = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.updateRepositoryProperties(instanceToken, repositoryOwner, repositoryName, repoProps);
|
||||
.updateRepositoryProperties(getAccount().getAuthorization(), repository.getOwner(), repository.getName(), repoProps);
|
||||
|
||||
propsCall.enqueue(new Callback<UserRepositories>() {
|
||||
|
||||
@ -375,18 +338,17 @@ public class RepositorySettingsActivity extends BaseActivity {
|
||||
|
||||
if (response.code() == 200) {
|
||||
|
||||
tinyDB.putBoolean("hasIssues", repoEnableIssues);
|
||||
tinyDB.putBoolean("hasPullRequests", repoEnablePr);
|
||||
|
||||
dialogProp.dismiss();
|
||||
Toasty.success(ctx, getString(R.string.repoPropertiesSaveSuccess));
|
||||
assert response.body() != null;
|
||||
repository.setRepository(response.body());
|
||||
|
||||
if(!repositoryName.equals(repoName)) {
|
||||
|
||||
if(!repository.getName().equals(repoName)) {
|
||||
BaseApi.getInstance(ctx, RepositoriesApi.class).updateRepositoryOwnerAndName(repository.getOwner(), repoName, repository.getRepositoryId());
|
||||
Intent result = new Intent();
|
||||
result.putExtra("nameChanged", true);
|
||||
setResult(200, result);
|
||||
finish();
|
||||
BaseApi.getInstance(ctx, RepositoriesApi.class).updateRepositoryOwnerAndName(repositoryOwner, repoName, (int) tinyDB.getLong("repositoryId", 0));
|
||||
Intent intent = new Intent(RepositorySettingsActivity.this, MainActivity.class);
|
||||
RepositorySettingsActivity.this.startActivity(intent);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -411,4 +373,10 @@ public class RepositorySettingsActivity extends BaseActivity {
|
||||
onClickListener = view -> finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
repository.checkAccountSwitch(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package org.mian.gitnex.activities;
|
||||
import android.app.Dialog;
|
||||
import android.app.TimePickerDialog;
|
||||
import android.os.Bundle;
|
||||
import android.text.format.DateFormat;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
@ -14,6 +13,7 @@ import androidx.fragment.app.DialogFragment;
|
||||
import com.google.android.material.switchmaterial.SwitchMaterial;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.databinding.ActivitySettingsAppearanceBinding;
|
||||
import org.mian.gitnex.fragments.SettingsFragment;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
|
||||
@ -69,11 +69,15 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
||||
if(darkMinute.length() == 1) darkMinute = "0" + darkMinute;
|
||||
if(darkHour.length() == 1) darkHour = "0" + darkHour;
|
||||
|
||||
timeSelectedChoice = tinyDB.getInt("timeId");
|
||||
customFontSelectedChoice = tinyDB.getInt("customFontId", 1);
|
||||
themeSelectedChoice = tinyDB.getInt("themeId");
|
||||
|
||||
activitySettingsAppearanceBinding.lightThemeSelectedTime.setText(ctx.getResources().getString(R.string.settingsThemeTimeSelectedHint, lightHour,
|
||||
lightMinute));
|
||||
activitySettingsAppearanceBinding.darkThemeSelectedTime.setText(ctx.getResources().getString(R.string.settingsThemeTimeSelectedHint, darkHour,
|
||||
darkMinute));
|
||||
activitySettingsAppearanceBinding.tvDateTimeSelected.setText(tinyDB.getString("timeStr"));
|
||||
activitySettingsAppearanceBinding.tvDateTimeSelected.setText(themeList[themeSelectedChoice]);
|
||||
activitySettingsAppearanceBinding.customFontSelected.setText(tinyDB.getString("customFontStr", "Manrope"));
|
||||
activitySettingsAppearanceBinding.themeSelected.setText(tinyDB.getString("themeStr", "Dark"));
|
||||
|
||||
@ -86,11 +90,7 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
||||
lightTimeFrame.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
timeSelectedChoice = tinyDB.getInt("timeId");
|
||||
customFontSelectedChoice = tinyDB.getInt("customFontId", 1);
|
||||
themeSelectedChoice = tinyDB.getInt("themeId");
|
||||
|
||||
counterBadgesSwitch.setChecked(tinyDB.getBoolean("enableCounterBadges"));
|
||||
counterBadgesSwitch.setChecked(tinyDB.getBoolean("enableCounterBadges", true));
|
||||
|
||||
// counter badge switcher
|
||||
counterBadgesSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
@ -112,10 +112,9 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
||||
|
||||
themeSelectedChoice = i;
|
||||
activitySettingsAppearanceBinding.themeSelected.setText(themeList[i]);
|
||||
tinyDB.putString("themeStr", themeList[i]);
|
||||
tinyDB.putInt("themeId", i);
|
||||
|
||||
tinyDB.putBoolean("refreshParent", true);
|
||||
SettingsFragment.refreshParent = true;
|
||||
this.recreate();
|
||||
this.overridePendingTransition(0, 0);
|
||||
dialogInterfaceTheme.dismiss();
|
||||
@ -151,7 +150,7 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
||||
tinyDB.putString("customFontStr", customFontList[i]);
|
||||
tinyDB.putInt("customFontId", i);
|
||||
|
||||
tinyDB.putBoolean("refreshParent", true);
|
||||
SettingsFragment.refreshParent = true;
|
||||
this.recreate();
|
||||
this.overridePendingTransition(0, 0);
|
||||
dialogInterfaceCustomFont.dismiss();
|
||||
@ -217,7 +216,7 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
||||
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
|
||||
db.putInt("lightThemeTimeHour", hourOfDay);
|
||||
db.putInt("lightThemeTimeMinute", minute);
|
||||
db.putBoolean("refreshParent", true);
|
||||
SettingsFragment.refreshParent = true;
|
||||
requireActivity().overridePendingTransition(0, 0);
|
||||
this.dismiss();
|
||||
Toasty.success(requireActivity().getApplicationContext(), requireContext().getResources().getString(R.string.settingsSave));
|
||||
@ -242,7 +241,7 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
||||
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
|
||||
db.putInt("darkThemeTimeHour", hourOfDay);
|
||||
db.putInt("darkThemeTimeMinute", minute);
|
||||
db.putBoolean("refreshParent", true);
|
||||
SettingsFragment.refreshParent = true;
|
||||
requireActivity().overridePendingTransition(0, 0);
|
||||
this.dismiss();
|
||||
Toasty.success(requireActivity().getApplicationContext(), requireContext().getResources().getString(R.string.settingsSave));
|
||||
|
@ -28,7 +28,7 @@ public class SettingsDraftsActivity extends BaseActivity {
|
||||
initCloseListener();
|
||||
closeActivity.setOnClickListener(onClickListener);
|
||||
|
||||
activitySettingsDraftsBinding.commentsDeletionSwitch.setChecked(tinyDB.getBoolean("draftsCommentsDeletionEnabled"));
|
||||
activitySettingsDraftsBinding.commentsDeletionSwitch.setChecked(tinyDB.getBoolean("draftsCommentsDeletionEnabled", true));
|
||||
|
||||
// delete comments on submit switcher
|
||||
activitySettingsDraftsBinding.commentsDeletionSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
|
@ -44,7 +44,7 @@ public class SettingsGeneralActivity extends BaseActivity {
|
||||
|
||||
String[] appHomeDefaultScreenNew = getResources().getStringArray(R.array.appDefaultHomeScreenNew);
|
||||
|
||||
if(new Version(tinyDB.getString("giteaVersion")).higherOrEqual("1.12.3")) {
|
||||
if(getAccount().requiresVersion("1.12.3")) {
|
||||
|
||||
appHomeDefaultScreen = appHomeDefaultScreenNew;
|
||||
}
|
||||
@ -55,7 +55,7 @@ public class SettingsGeneralActivity extends BaseActivity {
|
||||
|
||||
if(homeScreenSelectedChoice == 0) {
|
||||
|
||||
homeScreenSelectedChoice = tinyDB.getInt("homeScreenId");
|
||||
homeScreenSelectedChoice = tinyDB.getInt("homeScreenId", 0);
|
||||
viewBinding.homeScreenSelected.setText(getResources().getString(R.string.navMyRepos));
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ public class SettingsReportsActivity extends BaseActivity {
|
||||
initCloseListener();
|
||||
closeActivity.setOnClickListener(onClickListener);
|
||||
|
||||
activitySettingsReportsBinding.crashReportsSwitch.setChecked(tinyDB.getBoolean("crashReportingEnabled"));
|
||||
activitySettingsReportsBinding.crashReportsSwitch.setChecked(tinyDB.getBoolean("crashReportingEnabled", true));
|
||||
|
||||
// crash reports switcher
|
||||
activitySettingsReportsBinding.crashReportsSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
|
@ -16,6 +16,7 @@ import com.google.android.material.switchmaterial.SwitchMaterial;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.databinding.ActivitySettingsSecurityBinding;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.ssl.MemorizingTrustManager;
|
||||
import java.io.File;
|
||||
@ -64,15 +65,8 @@ public class SettingsSecurityActivity extends BaseActivity {
|
||||
cacheSizeDataList = getResources().getStringArray(R.array.cacheSizeList);
|
||||
cacheSizeImagesList = getResources().getStringArray(R.array.cacheSizeList);
|
||||
|
||||
if(!tinyDB.getString("cacheSizeStr").isEmpty()) {
|
||||
|
||||
cacheSizeDataSelected.setText(tinyDB.getString("cacheSizeStr"));
|
||||
}
|
||||
|
||||
if(!tinyDB.getString("cacheSizeImagesStr").isEmpty()) {
|
||||
|
||||
cacheSizeImagesSelected.setText(tinyDB.getString("cacheSizeImagesStr"));
|
||||
}
|
||||
cacheSizeDataSelected.setText(tinyDB.getString("cacheSizeStr", getString(R.string.cacheSizeDataSelectionSelectedText)));
|
||||
cacheSizeImagesSelected.setText(tinyDB.getString("cacheSizeImagesStr", getString(R.string.cacheSizeImagesSelectionSelectedText)));
|
||||
|
||||
if(cacheSizeDataSelectedChoice == 0) {
|
||||
|
||||
@ -84,7 +78,7 @@ public class SettingsSecurityActivity extends BaseActivity {
|
||||
cacheSizeImagesSelectedChoice = tinyDB.getInt("cacheSizeImagesId");
|
||||
}
|
||||
|
||||
switchBiometric.setChecked(tinyDB.getBoolean("biometricStatus"));
|
||||
switchBiometric.setChecked(tinyDB.getBoolean("biometricStatus", false));
|
||||
|
||||
// biometric switcher
|
||||
switchBiometric.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
@ -237,14 +231,7 @@ public class SettingsSecurityActivity extends BaseActivity {
|
||||
builder.setPositiveButton(R.string.menuDeleteText, (dialog, which) -> {
|
||||
|
||||
appCtx.getSharedPreferences(MemorizingTrustManager.KEYSTORE_NAME, Context.MODE_PRIVATE).edit().remove(MemorizingTrustManager.KEYSTORE_KEY).apply();
|
||||
|
||||
tinyDB.putBoolean("loggedInMode", false);
|
||||
tinyDB.remove("basicAuthPassword");
|
||||
tinyDB.putBoolean("basicAuthFlag", false);
|
||||
|
||||
Intent loginActivityIntent = new Intent().setClass(appCtx, LoginActivity.class);
|
||||
loginActivityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
appCtx.startActivity(loginActivityIntent);
|
||||
AppUtil.logout(this);
|
||||
});
|
||||
|
||||
builder.setNeutralButton(R.string.cancelButton, (dialog, which) -> dialog.dismiss());
|
||||
|
@ -10,6 +10,7 @@ import android.widget.TextView;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.databinding.ActivitySettingsTranslationBinding;
|
||||
import org.mian.gitnex.fragments.SettingsFragment;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import java.util.LinkedHashMap;
|
||||
@ -54,9 +55,8 @@ public class SettingsTranslationActivity extends BaseActivity {
|
||||
AppUtil.openUrlInBrowser(this, getResources().getString(R.string.crowdInLink));
|
||||
});
|
||||
|
||||
tvLanguageSelected.setText(tinyDB.getString("localeStr"));
|
||||
|
||||
langSelectedChoice = tinyDB.getInt("langId");
|
||||
tvLanguageSelected.setText(langs.get(langs.keySet().toArray(new String[0])[langSelectedChoice]));
|
||||
|
||||
// language dialog
|
||||
langFrame.setOnClickListener(view -> {
|
||||
@ -69,11 +69,10 @@ public class SettingsTranslationActivity extends BaseActivity {
|
||||
lBuilder.setSingleChoiceItems(langs.values().toArray(new String[0]), langSelectedChoice, (dialogInterface, i) -> {
|
||||
|
||||
String selectedLanguage = langs.keySet().toArray(new String[0])[i];
|
||||
tinyDB.putString("localeStr", langs.get(selectedLanguage));
|
||||
tinyDB.putInt("langId", i);
|
||||
tinyDB.putString("locale", selectedLanguage);
|
||||
|
||||
tinyDB.putBoolean("refreshParent", true);
|
||||
SettingsFragment.refreshParent = true;
|
||||
this.overridePendingTransition(0, 0);
|
||||
dialogInterface.dismiss();
|
||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||
|
@ -14,6 +14,7 @@ import com.google.gson.JsonElement;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.gitnex.tea4j.models.CronTasks;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
@ -31,7 +32,6 @@ import retrofit2.Callback;
|
||||
public class AdminCronTasksAdapter extends RecyclerView.Adapter<AdminCronTasksAdapter.CronTasksViewHolder> {
|
||||
|
||||
private final List<CronTasks> tasksList;
|
||||
private static TinyDB tinyDb;
|
||||
|
||||
static class CronTasksViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
@ -45,7 +45,7 @@ public class AdminCronTasksAdapter extends RecyclerView.Adapter<AdminCronTasksAd
|
||||
Context ctx = itemView.getContext();
|
||||
|
||||
final Locale locale = ctx.getResources().getConfiguration().locale;
|
||||
final String timeFormat = tinyDb.getString("dateFormat");
|
||||
final String timeFormat = TinyDB.getInstance(ctx).getString("dateFormat", "pretty");
|
||||
|
||||
ImageView runTask = itemView.findViewById(R.id.runTask);
|
||||
taskName = itemView.findViewById(R.id.taskName);
|
||||
@ -92,9 +92,7 @@ public class AdminCronTasksAdapter extends RecyclerView.Adapter<AdminCronTasksAd
|
||||
}
|
||||
}
|
||||
|
||||
public AdminCronTasksAdapter(Context ctx, List<CronTasks> tasksListMain) {
|
||||
|
||||
tinyDb = TinyDB.getInstance(ctx);
|
||||
public AdminCronTasksAdapter(List<CronTasks> tasksListMain) {
|
||||
this.tasksList = tasksListMain;
|
||||
}
|
||||
|
||||
@ -117,12 +115,9 @@ public class AdminCronTasksAdapter extends RecyclerView.Adapter<AdminCronTasksAd
|
||||
|
||||
private static void runCronTask(final Context ctx, final String taskName) {
|
||||
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
Call<JsonElement> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.adminRunCronTask(instanceToken, taskName);
|
||||
.adminRunCronTask(((BaseActivity) ctx).getAccount().getAuthorization(), taskName);
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
|
||||
|
@ -17,14 +17,14 @@ import org.gitnex.tea4j.models.Collaborators;
|
||||
import org.gitnex.tea4j.models.UserInfo;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.actions.CollaboratorActions;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.activities.ProfileActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
@ -34,17 +34,19 @@ import retrofit2.Response;
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
public class UserSearchAdapter extends RecyclerView.Adapter<UserSearchAdapter.UserSearchViewHolder> {
|
||||
public class CollaboratorSearchAdapter extends RecyclerView.Adapter<CollaboratorSearchAdapter.CollaboratorSearchViewHolder> {
|
||||
|
||||
private final List<UserInfo> usersSearchList;
|
||||
private final Context context;
|
||||
private final RepositoryContext repository;
|
||||
|
||||
public UserSearchAdapter(List<UserInfo> dataList, Context ctx) {
|
||||
public CollaboratorSearchAdapter(List<UserInfo> dataList, Context ctx, RepositoryContext repository) {
|
||||
this.context = ctx;
|
||||
this.usersSearchList = dataList;
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
class UserSearchViewHolder extends RecyclerView.ViewHolder {
|
||||
class CollaboratorSearchViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private UserInfo userInfo;
|
||||
|
||||
@ -57,7 +59,7 @@ public class UserSearchAdapter extends RecyclerView.Adapter<UserSearchAdapter.Us
|
||||
private final String[] permissionList = {"Read", "Write", "Admin"};
|
||||
final private int permissionSelectedChoice = 0;
|
||||
|
||||
private UserSearchViewHolder(View itemView) {
|
||||
private CollaboratorSearchViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
userAvatar = itemView.findViewById(R.id.userAvatar);
|
||||
@ -70,9 +72,7 @@ public class UserSearchAdapter extends RecyclerView.Adapter<UserSearchAdapter.Us
|
||||
AlertDialog.Builder pBuilder = new AlertDialog.Builder(context);
|
||||
|
||||
pBuilder.setTitle(R.string.newTeamPermission);
|
||||
pBuilder.setSingleChoiceItems(permissionList, permissionSelectedChoice, (dialogInterface, i) -> {
|
||||
|
||||
})
|
||||
pBuilder.setSingleChoiceItems(permissionList, permissionSelectedChoice, null)
|
||||
.setCancelable(false)
|
||||
.setNegativeButton(R.string.cancelButton, null)
|
||||
.setPositiveButton(R.string.addButton, (dialog, which) -> {
|
||||
@ -80,20 +80,14 @@ public class UserSearchAdapter extends RecyclerView.Adapter<UserSearchAdapter.Us
|
||||
ListView lw = ((AlertDialog)dialog).getListView();
|
||||
Object checkedItem = lw.getAdapter().getItem(lw.getCheckedItemPosition());
|
||||
|
||||
CollaboratorActions.addCollaborator(context, String.valueOf(checkedItem).toLowerCase(), userInfo.getUsername());
|
||||
CollaboratorActions.addCollaborator(context, String.valueOf(checkedItem).toLowerCase(), userInfo.getUsername(), repository);
|
||||
});
|
||||
|
||||
AlertDialog pDialog = pBuilder.create();
|
||||
pDialog.show();
|
||||
});
|
||||
|
||||
addCollaboratorButtonRemove.setOnClickListener(v -> {
|
||||
AlertDialogs.collaboratorRemoveDialog(context, userInfo.getUsername(),
|
||||
context.getResources().getString(R.string.removeCollaboratorDialogTitle),
|
||||
context.getResources().getString(R.string.removeCollaboratorMessage),
|
||||
context.getResources().getString(R.string.removeButton),
|
||||
context.getResources().getString(R.string.cancelButton), "fa");
|
||||
});
|
||||
addCollaboratorButtonRemove.setOnClickListener(v -> AlertDialogs.collaboratorRemoveDialog(context, userInfo.getUsername(), repository));
|
||||
|
||||
userAvatar.setOnClickListener(loginId -> {
|
||||
Intent intent = new Intent(context, ProfileActivity.class);
|
||||
@ -111,13 +105,13 @@ public class UserSearchAdapter extends RecyclerView.Adapter<UserSearchAdapter.Us
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public UserSearchAdapter.UserSearchViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
public CollaboratorSearchViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_collaborators_search, parent, false);
|
||||
return new UserSearchAdapter.UserSearchViewHolder(v);
|
||||
return new CollaboratorSearchAdapter.CollaboratorSearchViewHolder(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull final UserSearchAdapter.UserSearchViewHolder holder, int position) {
|
||||
public void onBindViewHolder(@NonNull final CollaboratorSearchViewHolder holder, int position) {
|
||||
|
||||
UserInfo currentItem = usersSearchList.get(position);
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||
@ -140,16 +134,11 @@ public class UserSearchAdapter extends RecyclerView.Adapter<UserSearchAdapter.Us
|
||||
|
||||
if(getItemCount() > 0) {
|
||||
|
||||
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
final String loginUid = ((BaseActivity) context).getAccount().getAccount().getUserName();
|
||||
|
||||
Call<Collaborators> call = RetrofitClient
|
||||
.getApiInterface(context)
|
||||
.checkRepoCollaborator(Authorization.get(context), repoOwner, repoName, currentItem.getUsername());
|
||||
.checkRepoCollaborator(((BaseActivity) context).getAccount().getAuthorization(), repository.getOwner(), repository.getName(), currentItem.getUsername());
|
||||
|
||||
call.enqueue(new Callback<Collaborators>() {
|
||||
|
||||
@ -157,7 +146,7 @@ public class UserSearchAdapter extends RecyclerView.Adapter<UserSearchAdapter.Us
|
||||
public void onResponse(@NonNull Call<Collaborators> call, @NonNull Response<Collaborators> response) {
|
||||
|
||||
if(response.code() == 204) {
|
||||
if(!currentItem.getUsername().equals(loginUid) && !currentItem.getUsername().equals(repoOwner)) {
|
||||
if(!currentItem.getUsername().equals(loginUid) && !currentItem.getUsername().equals(repository.getOwner())) {
|
||||
holder.addCollaboratorButtonRemove.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
@ -165,7 +154,7 @@ public class UserSearchAdapter extends RecyclerView.Adapter<UserSearchAdapter.Us
|
||||
}
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
if(!currentItem.getUsername().equals(loginUid) && !currentItem.getUsername().equals(repoOwner)) {
|
||||
if(!currentItem.getUsername().equals(loginUid) && !currentItem.getUsername().equals(repository.getOwner())) {
|
||||
holder.addCollaboratorButtonAdd.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
@ -14,6 +14,7 @@ import com.vdurmont.emoji.EmojiParser;
|
||||
import org.gitnex.tea4j.models.Commits;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.CommitDetailActivity;
|
||||
import org.mian.gitnex.activities.CommitsActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.fragments.CommitDetailFragment;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
@ -169,7 +170,7 @@ public class CommitsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
||||
|
||||
commitSha.setText(commitsModel.getSha().substring(0, Math.min(commitsModel.getSha().length(), 10)));
|
||||
rootView.setOnClickListener(v -> {
|
||||
Intent intent = new Intent(context, CommitDetailActivity.class);
|
||||
Intent intent = ((CommitsActivity) context).repository.getIntent(context, CommitDetailActivity.class);
|
||||
intent.putExtra("sha", commitsModel.getSha());
|
||||
context.startActivity(intent);
|
||||
});
|
||||
|
@ -12,6 +12,7 @@ import androidx.fragment.app.FragmentManager;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.fragments.BottomSheetReplyFragment;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.contexts.IssueContext;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
@ -25,6 +26,7 @@ public class DiffAdapter extends BaseAdapter {
|
||||
private final Context context;
|
||||
private final FragmentManager fragmentManager;
|
||||
private final List<String> lines;
|
||||
private final IssueContext issue;
|
||||
|
||||
private final List<Integer> selectedLines;
|
||||
private final Typeface typeface;
|
||||
@ -36,11 +38,12 @@ public class DiffAdapter extends BaseAdapter {
|
||||
private static int COLOR_SELECTED;
|
||||
private static int COLOR_FONT;
|
||||
|
||||
public DiffAdapter(Context context, FragmentManager fragmentManager, List<String> lines, String type) {
|
||||
public DiffAdapter(Context context, FragmentManager fragmentManager, List<String> lines, IssueContext issue, String type) {
|
||||
|
||||
this.context = context;
|
||||
this.fragmentManager = fragmentManager;
|
||||
this.lines = lines;
|
||||
this.issue = issue;
|
||||
this.type = type;
|
||||
|
||||
selectedLines = new ArrayList<>();
|
||||
@ -120,8 +123,8 @@ public class DiffAdapter extends BaseAdapter {
|
||||
bundle.putString("commentBody", stringBuilder.toString());
|
||||
bundle.putBoolean("cursorToEnd", true);
|
||||
|
||||
BottomSheetReplyFragment.newInstance(bundle).show(fragmentManager, "replyBottomSheet");
|
||||
}
|
||||
BottomSheetReplyFragment.newInstance(bundle, issue).show(fragmentManager, "replyBottomSheet");
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
|
@ -22,8 +22,9 @@ import org.mian.gitnex.database.api.DraftsApi;
|
||||
import org.mian.gitnex.database.models.DraftWithRepository;
|
||||
import org.mian.gitnex.fragments.BottomSheetReplyFragment;
|
||||
import org.mian.gitnex.helpers.Markdown;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.contexts.IssueContext;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -56,7 +57,7 @@ public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsView
|
||||
deleteDraft.setOnClickListener(itemDelete -> {
|
||||
|
||||
int getDraftId = draftWithRepository.getDraftId();
|
||||
deleteDraft(getAdapterPosition());
|
||||
deleteDraft(getBindingAdapterPosition());
|
||||
|
||||
DraftsApi draftsApi = BaseApi.getInstance(context, DraftsApi.class);
|
||||
assert draftsApi != null;
|
||||
@ -66,11 +67,13 @@ public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsView
|
||||
|
||||
itemView.setOnClickListener(itemEdit -> {
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
RepositoryContext repository = new RepositoryContext(draftWithRepository.getRepositoryOwner(), draftWithRepository.getRepositoryName(), context);
|
||||
repository.setRepositoryId(draftWithRepository.getRepositoryId());
|
||||
IssueContext issue = new IssueContext(repository, draftWithRepository.getIssueId(), draftWithRepository.getIssueType());
|
||||
Bundle bundle = issue.getBundle();
|
||||
|
||||
bundle.putString("commentBody", draftWithRepository.getDraftText());
|
||||
bundle.putString("issueNumber", String.valueOf(draftWithRepository.getIssueId()));
|
||||
bundle.putString("repositoryId", String.valueOf(draftWithRepository.getRepositoryId()));
|
||||
bundle.putString("draftTitle", repoInfo.getText().toString());
|
||||
bundle.putString("commentId", draftWithRepository.getCommentId());
|
||||
bundle.putString("draftId", String.valueOf(draftWithRepository.getDraftId()));
|
||||
@ -79,14 +82,20 @@ public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsView
|
||||
bundle.putString("commentAction", "edit");
|
||||
}
|
||||
|
||||
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
tinyDb.putString("issueNumber", String.valueOf(draftWithRepository.getIssueId()));
|
||||
tinyDb.putLong("repositoryId", draftWithRepository.getRepositoryId());
|
||||
tinyDb.putString("issueType", draftWithRepository.getIssueType());
|
||||
tinyDb.putString("repoFullName", draftWithRepository.getRepositoryOwner() + "/" + draftWithRepository.getRepositoryName());
|
||||
|
||||
BottomSheetReplyFragment bottomSheetReplyFragment = BottomSheetReplyFragment.newInstance(bundle);
|
||||
bottomSheetReplyFragment.setOnInteractedListener(() -> context.startActivity(new Intent(context, IssueDetailActivity.class)));
|
||||
BottomSheetReplyFragment bottomSheetReplyFragment = BottomSheetReplyFragment.newInstance(bundle, issue);
|
||||
bottomSheetReplyFragment.setOnInteractedListener(() -> {
|
||||
Intent i = new IssueContext(
|
||||
new RepositoryContext(
|
||||
draftWithRepository.getRepositoryOwner(),
|
||||
draftWithRepository.getRepositoryName(),
|
||||
context
|
||||
),
|
||||
draftWithRepository.getIssueId(),
|
||||
draftWithRepository.getIssueType()
|
||||
).getIntent(context, IssueDetailActivity.class);
|
||||
i.putExtra("openedFromLink", "true");
|
||||
context.startActivity(i);
|
||||
});
|
||||
bottomSheetReplyFragment.show(fragmentManager, "replyBottomSheet");
|
||||
});
|
||||
|
||||
|
@ -14,6 +14,7 @@ import androidx.core.text.HtmlCompat;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import org.gitnex.tea4j.models.Issues;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.activities.IssueDetailActivity;
|
||||
import org.mian.gitnex.activities.ProfileActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
@ -25,6 +26,8 @@ import org.mian.gitnex.helpers.ClickListener;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.contexts.IssueContext;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import org.ocpsoft.prettytime.PrettyTime;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
@ -104,36 +107,34 @@ public class ExploreIssuesAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
issueCreatedTime = itemView.findViewById(R.id.issueCreatedTime);
|
||||
|
||||
itemView.setOnClickListener(v -> {
|
||||
Intent intent = new Intent(context, IssueDetailActivity.class);
|
||||
intent.putExtra("issueNumber", issue.getNumber());
|
||||
intent.putExtra("openedFromLink", "true");
|
||||
|
||||
tinyDb.putString("issueNumber", String.valueOf(issue.getNumber()));
|
||||
tinyDb.putString("issueType", "Issue");
|
||||
|
||||
tinyDb.putString("repoFullName", issue.getRepository().getFull_name());
|
||||
|
||||
String[] parts = issue.getRepository().getFull_name().split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
|
||||
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
||||
|
||||
|
||||
int currentActiveAccountId = ((BaseActivity) context).getAccount().getAccount().getAccountId();
|
||||
RepositoriesApi repositoryData = BaseApi.getInstance(context, RepositoriesApi.class);
|
||||
|
||||
assert repositoryData != null;
|
||||
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
|
||||
if(count == 0) {
|
||||
RepositoryContext repo = new RepositoryContext(repoOwner, repoName, context);
|
||||
|
||||
if(count == 0) {
|
||||
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
tinyDb.putLong("repositoryId", id);
|
||||
repo.setRepositoryId((int) id);
|
||||
}
|
||||
else {
|
||||
|
||||
Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
tinyDb.putLong("repositoryId", data.getRepositoryId());
|
||||
repo.setRepositoryId(data.getRepositoryId());
|
||||
}
|
||||
|
||||
Intent intent = new IssueContext(
|
||||
issue,
|
||||
repo
|
||||
).getIntent(context, IssueDetailActivity.class);
|
||||
intent.putExtra("openedFromLink", "true");
|
||||
context.startActivity(intent);
|
||||
});
|
||||
|
||||
@ -155,7 +156,7 @@ public class ExploreIssuesAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||
|
||||
Locale locale = context.getResources().getConfiguration().locale;
|
||||
String timeFormat = tinyDb.getString("dateFormat");
|
||||
String timeFormat = tinyDb.getString("dateFormat", "pretty");
|
||||
|
||||
PicassoService.getInstance(context).get()
|
||||
.load(issue.getUser().getAvatar_url())
|
||||
|
@ -16,7 +16,6 @@ import org.mian.gitnex.activities.OrganizationDetailActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -91,11 +90,6 @@ public class ExplorePublicOrganizationsAdapter extends RecyclerView.Adapter<Recy
|
||||
Context context = v.getContext();
|
||||
Intent intent = new Intent(context, OrganizationDetailActivity.class);
|
||||
intent.putExtra("orgName", organization.getUsername());
|
||||
|
||||
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
tinyDb.putString("orgName", organization.getUsername());
|
||||
tinyDb.putString("organizationId", String.valueOf(organization.getId()));
|
||||
tinyDb.putBoolean("organizationAction", true);
|
||||
context.startActivity(intent);
|
||||
});
|
||||
}
|
||||
|
@ -15,11 +15,9 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.amulyakhare.textdrawable.TextDrawable;
|
||||
import com.amulyakhare.textdrawable.util.ColorGenerator;
|
||||
import org.gitnex.tea4j.models.UserRepositories;
|
||||
import org.gitnex.tea4j.models.WatchInfo;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.database.api.BaseApi;
|
||||
import org.mian.gitnex.database.api.RepositoriesApi;
|
||||
import org.mian.gitnex.database.models.Repository;
|
||||
@ -28,14 +26,12 @@ import org.mian.gitnex.helpers.ClickListener;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import org.ocpsoft.prettytime.PrettyTime;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
@ -119,79 +115,26 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<RecyclerVie
|
||||
spacerView = itemView.findViewById(R.id.spacerView);
|
||||
|
||||
itemView.setOnClickListener(v -> {
|
||||
|
||||
Context context = v.getContext();
|
||||
Intent intent = new Intent(context, RepoDetailActivity.class);
|
||||
intent.putExtra("repoFullName", userRepositories.getFullName());
|
||||
|
||||
tinyDb.putString("repoFullName", userRepositories.getFullName());
|
||||
tinyDb.putBoolean("resumeIssues", true);
|
||||
tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked());
|
||||
tinyDb.putString("repoBranch", userRepositories.getDefault_branch());
|
||||
|
||||
if(userRepositories.getPrivateFlag()) {
|
||||
tinyDb.putString("repoType", context.getResources().getString(R.string.strPrivate));
|
||||
}
|
||||
else {
|
||||
tinyDb.putString("repoType", context.getResources().getString(R.string.strPublic));
|
||||
}
|
||||
|
||||
String[] parts = userRepositories.getFullName().split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
RepositoryContext repo = new RepositoryContext(userRepositories, context);
|
||||
Intent intent = repo.getIntent(context, RepoDetailActivity.class);
|
||||
|
||||
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
||||
RepositoriesApi repositoryData = BaseApi.getInstance(context, RepositoriesApi.class);
|
||||
|
||||
//RepositoriesRepository.deleteRepositoriesByAccount(currentActiveAccountId);
|
||||
assert repositoryData != null;
|
||||
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
Integer count = repositoryData.checkRepository(currentActiveAccountId, repo.getOwner(), repo.getName());
|
||||
|
||||
if(count == 0) {
|
||||
|
||||
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
tinyDb.putLong("repositoryId", id);
|
||||
long id = repositoryData.insertRepository(currentActiveAccountId, repo.getOwner(), repo.getName());
|
||||
repo.setRepositoryId((int) id);
|
||||
}
|
||||
else {
|
||||
|
||||
Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
tinyDb.putLong("repositoryId", data.getRepositoryId());
|
||||
Repository data = repositoryData.getRepository(currentActiveAccountId, repo.getOwner(), repo.getName());
|
||||
repo.setRepositoryId(data.getRepositoryId());
|
||||
}
|
||||
|
||||
//store if user is watching this repo
|
||||
{
|
||||
|
||||
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
||||
|
||||
WatchInfo watch = new WatchInfo();
|
||||
Call<WatchInfo> call;
|
||||
call = RetrofitClient.getApiInterface(context).checkRepoWatchStatus(token, repoOwner, repoName);
|
||||
|
||||
call.enqueue(new Callback<WatchInfo>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<WatchInfo> call, @NonNull retrofit2.Response<WatchInfo> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
assert response.body() != null;
|
||||
tinyDb.putBoolean("repoWatch", response.body().getSubscribed());
|
||||
}
|
||||
else {
|
||||
tinyDb.putBoolean("repoWatch", false);
|
||||
if(response.code() != 404) {
|
||||
Toasty.error(context, context.getString(R.string.genericApiStatusError));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<WatchInfo> call, @NonNull Throwable t) {
|
||||
tinyDb.putBoolean("repoWatch", false);
|
||||
Toasty.error(context, context.getString(R.string.genericApiStatusError));
|
||||
}
|
||||
});
|
||||
}
|
||||
context.startActivity(intent);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@ -201,7 +144,7 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<RecyclerVie
|
||||
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||
Locale locale = context.getResources().getConfiguration().locale;
|
||||
String timeFormat = tinyDb.getString("dateFormat");
|
||||
String timeFormat = tinyDb.getString("dateFormat", "pretty");
|
||||
|
||||
orgName.setText(userRepositories.getFullName().split("/")[0]);
|
||||
repoName.setText(userRepositories.getFullName().split("/")[1]);
|
||||
|
@ -22,6 +22,7 @@ import com.google.gson.JsonElement;
|
||||
import com.vdurmont.emoji.EmojiParser;
|
||||
import org.gitnex.tea4j.models.IssueComments;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.activities.ProfileActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
@ -33,6 +34,7 @@ import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.contexts.IssueContext;
|
||||
import org.mian.gitnex.views.ReactionList;
|
||||
import org.mian.gitnex.views.ReactionSpinner;
|
||||
import java.util.List;
|
||||
@ -54,8 +56,9 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
||||
private final FragmentManager fragmentManager;
|
||||
private final Runnable onInteractedListener;
|
||||
private final Locale locale;
|
||||
private final IssueContext issue;
|
||||
|
||||
public IssueCommentsAdapter(Context ctx, Bundle bundle, List<IssueComments> issuesCommentsMain, FragmentManager fragmentManager, Runnable onInteractedListener) {
|
||||
public IssueCommentsAdapter(Context ctx, Bundle bundle, List<IssueComments> issuesCommentsMain, FragmentManager fragmentManager, Runnable onInteractedListener, IssueContext issue) {
|
||||
|
||||
this.context = ctx;
|
||||
this.bundle = bundle;
|
||||
@ -64,6 +67,7 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
||||
this.onInteractedListener = onInteractedListener;
|
||||
tinyDB = TinyDB.getInstance(ctx);
|
||||
locale = ctx.getResources().getConfiguration().locale;
|
||||
this.issue = issue;
|
||||
}
|
||||
|
||||
class IssueCommentViewHolder extends RecyclerView.ViewHolder {
|
||||
@ -90,7 +94,7 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
||||
|
||||
menu.setOnClickListener(v -> {
|
||||
|
||||
final String loginUid = tinyDB.getString("loginUid");
|
||||
final String loginUid = ((BaseActivity) context).getAccount().getAccount().getUserName();
|
||||
|
||||
@SuppressLint("InflateParams") View vw = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_issue_comments, null);
|
||||
|
||||
@ -102,14 +106,14 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
||||
TextView issueCommentCopyUrl = vw.findViewById(R.id.issueCommentCopyUrl);
|
||||
LinearLayout linearLayout = vw.findViewById(R.id.commentReactionButtons);
|
||||
|
||||
if(tinyDB.getBoolean("isArchived")) {
|
||||
if(issue.getRepository().getRepository().isArchived()) {
|
||||
commentMenuEdit.setVisibility(View.GONE);
|
||||
commentMenuDelete.setVisibility(View.GONE);
|
||||
commentMenuQuote.setVisibility(View.GONE);
|
||||
linearLayout.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if(!loginUid.contentEquals(issueComment.getUser().getUsername()) && !tinyDB.getBoolean("canPush")) {
|
||||
if(!loginUid.contentEquals(issueComment.getUser().getUsername()) && !issue.getRepository().getPermissions().canPush()) {
|
||||
commentMenuEdit.setVisibility(View.GONE);
|
||||
commentMenuDelete.setVisibility(View.GONE);
|
||||
}
|
||||
@ -134,8 +138,6 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
||||
|
||||
ReactionSpinner reactionSpinner = new ReactionSpinner(context, bundle1);
|
||||
reactionSpinner.setOnInteractedListener(() -> {
|
||||
tinyDB.putBoolean("commentEdited", true);
|
||||
|
||||
onInteractedListener.run();
|
||||
dialog.dismiss();
|
||||
});
|
||||
@ -152,7 +154,7 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
||||
bundle.putString("commentAction", "edit");
|
||||
bundle.putString("commentBody", issueComment.getBody());
|
||||
|
||||
BottomSheetReplyFragment bottomSheetReplyFragment = BottomSheetReplyFragment.newInstance(bundle);
|
||||
BottomSheetReplyFragment bottomSheetReplyFragment = BottomSheetReplyFragment.newInstance(bundle, issue);
|
||||
bottomSheetReplyFragment.setOnInteractedListener(onInteractedListener);
|
||||
bottomSheetReplyFragment.show(fragmentManager, "replyBottomSheet");
|
||||
|
||||
@ -166,7 +168,7 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
||||
// share issue comment
|
||||
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
|
||||
sharingIntent.setType("text/plain");
|
||||
String intentHeader = tinyDB.getString("issueNumber") + context.getResources().getString(R.string.hash) + "issuecomment-" + issueComment.getId() + " " + tinyDB.getString("issueTitle");
|
||||
String intentHeader = issue.getIssueIndex() + context.getResources().getString(R.string.hash) + "issuecomment-" + issueComment.getId() + " " + issue.getIssue().getTitle();
|
||||
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, intentHeader);
|
||||
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, commentUrl);
|
||||
context.startActivity(Intent.createChooser(sharingIntent, intentHeader));
|
||||
@ -192,7 +194,7 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
String commenterName = issueComment.getUser().getUsername();
|
||||
|
||||
if(!commenterName.equals(tinyDB.getString("userLogin"))) {
|
||||
if(!commenterName.equals(((BaseActivity) context).getAccount().getAccount().getUserName())) {
|
||||
stringBuilder.append("@").append(commenterName).append("\n\n");
|
||||
}
|
||||
|
||||
@ -209,14 +211,14 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
||||
bundle.putBoolean("cursorToEnd", true);
|
||||
|
||||
dialog.dismiss();
|
||||
BottomSheetReplyFragment.newInstance(bundle).show(fragmentManager, "replyBottomSheet");
|
||||
BottomSheetReplyFragment.newInstance(bundle, issue).show(fragmentManager, "replyBottomSheet");
|
||||
});
|
||||
|
||||
commentMenuCopy.setOnClickListener(v1 -> {
|
||||
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(context).getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
assert clipboard != null;
|
||||
|
||||
ClipData clip = ClipData.newPlainText("Comment on issue #" + tinyDB.getString("issueNumber"), issueComment.getBody());
|
||||
ClipData clip = ClipData.newPlainText("Comment on issue #" + issue.getIssueIndex(), issueComment.getBody());
|
||||
clipboard.setPrimaryClip(clip);
|
||||
|
||||
dialog.dismiss();
|
||||
@ -252,20 +254,9 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
||||
|
||||
private void deleteIssueComment(final Context ctx, final int commentId, int position) {
|
||||
|
||||
final String loginUid = tinyDB.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDB.getString(loginUid + "-token");
|
||||
String[] repoFullName = tinyDB.getString("repoFullName").split("/");
|
||||
|
||||
if (repoFullName.length != 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
final String repoOwner = repoFullName[0];
|
||||
final String repoName = repoFullName[1];
|
||||
|
||||
Call<JsonElement> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.deleteComment(instanceToken, repoOwner, repoName, commentId);
|
||||
.deleteComment(((BaseActivity) context).getAccount().getAuthorization(), issue.getRepository().getOwner(), issue.getRepository().getName(), commentId);
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
|
||||
@ -318,7 +309,7 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull IssueCommentsAdapter.IssueCommentViewHolder holder, int position) {
|
||||
|
||||
String timeFormat = tinyDB.getString("dateFormat");
|
||||
String timeFormat = tinyDB.getString("dateFormat", "pretty");
|
||||
IssueComments issueComment = issuesComments.get(position);
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||
|
||||
@ -335,7 +326,7 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
||||
.centerCrop()
|
||||
.into(holder.avatar);
|
||||
|
||||
Markdown.render(context, EmojiParser.parseToUnicode(issueComment.getBody()), holder.comment);
|
||||
Markdown.render(context, EmojiParser.parseToUnicode(issueComment.getBody()), holder.comment, issue.getRepository());
|
||||
|
||||
StringBuilder informationBuilder = null;
|
||||
if(issueComment.getCreated_at() != null) {
|
||||
|
@ -17,12 +17,14 @@ import org.gitnex.tea4j.models.Issues;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.IssueDetailActivity;
|
||||
import org.mian.gitnex.activities.ProfileActivity;
|
||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.ClickListener;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.contexts.IssueContext;
|
||||
import org.ocpsoft.prettytime.PrettyTime;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
@ -111,12 +113,10 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
issueCreatedTime = itemView.findViewById(R.id.issueCreatedTime);
|
||||
|
||||
itemView.setOnClickListener(layoutView -> {
|
||||
Intent intent = new Intent(context, IssueDetailActivity.class);
|
||||
intent.putExtra("issueNumber", issue.getNumber());
|
||||
|
||||
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
tinyDb.putString("issueNumber", String.valueOf(issue.getNumber()));
|
||||
tinyDb.putString("issueType", "Issue");
|
||||
Intent intent = new IssueContext(
|
||||
issue,
|
||||
((RepoDetailActivity) context).repository
|
||||
).getIntent(context, IssueDetailActivity.class);
|
||||
context.startActivity(intent);
|
||||
});
|
||||
|
||||
@ -137,7 +137,7 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
|
||||
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
Locale locale = context.getResources().getConfiguration().locale;
|
||||
String timeFormat = tinyDb.getString("dateFormat");
|
||||
String timeFormat = tinyDb.getString("dateFormat", "pretty");
|
||||
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||
|
||||
|
@ -19,9 +19,10 @@ import org.gitnex.tea4j.models.Labels;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.CreateLabelActivity;
|
||||
import org.mian.gitnex.activities.OrganizationDetailActivity;
|
||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.ColorInverter;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -31,10 +32,10 @@ import java.util.List;
|
||||
public class LabelsAdapter extends RecyclerView.Adapter<LabelsAdapter.LabelsViewHolder> {
|
||||
|
||||
private final List<Labels> labelsList;
|
||||
private static String type;
|
||||
private static String orgName;
|
||||
private final String type;
|
||||
private final String orgName;
|
||||
|
||||
static class LabelsViewHolder extends RecyclerView.ViewHolder {
|
||||
class LabelsViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private Labels labels;
|
||||
|
||||
@ -50,7 +51,7 @@ public class LabelsAdapter extends RecyclerView.Adapter<LabelsAdapter.LabelsView
|
||||
labelName = itemView.findViewById(R.id.labelName);
|
||||
ImageView labelsOptionsMenu = itemView.findViewById(R.id.labelsOptionsMenu);
|
||||
|
||||
if((type.equals("repo") && !TinyDB.getInstance(itemView.getContext()).getBoolean("isRepoAdmin")) ||
|
||||
if((type.equals("repo") && !((RepoDetailActivity) itemView.getContext()).repository.getPermissions().canPush()) ||
|
||||
(type.equals("org") && !((OrganizationDetailActivity) itemView.getContext()).permissions.isOwner())) {
|
||||
labelsOptionsMenu.setVisibility(View.GONE);
|
||||
}
|
||||
@ -79,18 +80,21 @@ public class LabelsAdapter extends RecyclerView.Adapter<LabelsAdapter.LabelsView
|
||||
intent.putExtra("labelAction", "edit");
|
||||
intent.putExtra("type", type);
|
||||
intent.putExtra("orgName", orgName);
|
||||
intent.putExtra(RepositoryContext.INTENT_EXTRA, ((RepoDetailActivity) itemView.getContext()).repository);
|
||||
context.startActivity(intent);
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
labelMenuDelete.setOnClickListener(deleteLabel -> {
|
||||
RepositoryContext repo;
|
||||
if(type.equals("repo")) {
|
||||
repo = ((RepoDetailActivity) itemView.getContext()).repository;
|
||||
} else {
|
||||
repo = null;
|
||||
}
|
||||
|
||||
AlertDialogs.labelDeleteDialog(context, labels.getName(), String.valueOf(labels.getId()),
|
||||
context.getResources().getString(R.string.labelDeleteTitle),
|
||||
context.getResources().getString(R.string.labelDeleteMessage),
|
||||
context.getResources().getString(R.string.menuDeleteText),
|
||||
context.getResources().getString(R.string.cancelButton),
|
||||
type, orgName);
|
||||
type, orgName, repo);
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
@ -102,8 +106,8 @@ public class LabelsAdapter extends RecyclerView.Adapter<LabelsAdapter.LabelsView
|
||||
public LabelsAdapter(Context ctx, List<Labels> labelsMain, String type, String orgName) {
|
||||
|
||||
this.labelsList = labelsMain;
|
||||
LabelsAdapter.type = type;
|
||||
LabelsAdapter.orgName = orgName;
|
||||
this.type = type;
|
||||
this.orgName = orgName;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
@ -17,11 +17,13 @@ import com.vdurmont.emoji.EmojiParser;
|
||||
import org.gitnex.tea4j.models.Milestones;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.actions.MilestoneActions;
|
||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||
import org.mian.gitnex.helpers.ClickListener;
|
||||
import org.mian.gitnex.helpers.Constants;
|
||||
import org.mian.gitnex.helpers.Markdown;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
@ -41,9 +43,10 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
private Runnable loadMoreListener;
|
||||
private boolean isLoading = false;
|
||||
private boolean isMoreDataAvailable = true;
|
||||
private final RepositoryContext repository;
|
||||
|
||||
public MilestonesAdapter(Context ctx, List<Milestones> dataListMain) {
|
||||
|
||||
public MilestonesAdapter(Context ctx, List<Milestones> dataListMain, RepositoryContext repository) {
|
||||
this.repository = repository;
|
||||
this.context = ctx;
|
||||
this.dataList = dataListMain;
|
||||
}
|
||||
@ -100,7 +103,7 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
msProgress = itemView.findViewById(R.id.milestoneProgress);
|
||||
ImageView milestonesMenu = itemView.findViewById(R.id.milestonesMenu);
|
||||
|
||||
if(!TinyDB.getInstance(itemView.getContext()).getBoolean("isRepoAdmin")) {
|
||||
if(!((RepoDetailActivity) itemView.getContext()).repository.getPermissions().canPush()) {
|
||||
milestonesMenu.setVisibility(View.GONE);
|
||||
}
|
||||
milestonesMenu.setOnClickListener(v -> {
|
||||
@ -130,14 +133,14 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
|
||||
closeMilestone.setOnClickListener(v12 -> {
|
||||
|
||||
MilestoneActions.closeMilestone(ctx, milestoneId_);
|
||||
MilestoneActions.closeMilestone(ctx, milestoneId_, repository);
|
||||
dialog.dismiss();
|
||||
updateAdapter(getAdapterPosition());
|
||||
});
|
||||
|
||||
openMilestone.setOnClickListener(v12 -> {
|
||||
|
||||
MilestoneActions.openMilestone(ctx, milestoneId_);
|
||||
MilestoneActions.openMilestone(ctx, milestoneId_, repository);
|
||||
dialog.dismiss();
|
||||
updateAdapter(getAdapterPosition());
|
||||
});
|
||||
@ -152,7 +155,7 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
this.milestones = dataModel;
|
||||
final TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
final String locale = context.getResources().getConfiguration().locale.getLanguage();
|
||||
final String timeFormat = tinyDb.getString("dateFormat");
|
||||
final String timeFormat = tinyDb.getString("dateFormat", "pretty");
|
||||
|
||||
Markdown.render(context, dataModel.getTitle(), msTitle);
|
||||
|
||||
|
@ -17,11 +17,7 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.gitnex.tea4j.models.NotificationThread;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.database.api.BaseApi;
|
||||
import org.mian.gitnex.database.api.RepositoriesApi;
|
||||
import org.mian.gitnex.database.models.Repository;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -38,10 +34,9 @@ public class NotificationsAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
private final OnNotificationClickedListener onNotificationClickedListener;
|
||||
private Runnable loadMoreListener;
|
||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
||||
private final TinyDB tinyDb;
|
||||
|
||||
public NotificationsAdapter(Context context, List<NotificationThread> notificationThreads, OnMoreClickedListener onMoreClickedListener, OnNotificationClickedListener onNotificationClickedListener) {
|
||||
this.tinyDb = TinyDB.getInstance(context);
|
||||
|
||||
this.context = context;
|
||||
this.notificationThreads = notificationThreads;
|
||||
this.onMoreClickedListener = onMoreClickedListener;
|
||||
@ -169,28 +164,7 @@ public class NotificationsAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
break;
|
||||
}
|
||||
|
||||
frame.setOnClickListener(v -> {
|
||||
|
||||
onNotificationClickedListener.onNotificationClicked(notificationThread);
|
||||
|
||||
String[] parts = notificationThread.getRepository().getFullName().split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
|
||||
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
||||
RepositoriesApi repositoryData = BaseApi.getInstance(context, RepositoriesApi.class);
|
||||
|
||||
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
|
||||
if(count == 0) {
|
||||
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
tinyDb.putLong("repositoryId", id);
|
||||
}
|
||||
else {
|
||||
Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
tinyDb.putLong("repositoryId", data.getRepositoryId());
|
||||
}
|
||||
});
|
||||
frame.setOnClickListener(v -> onNotificationClickedListener.onNotificationClicked(notificationThread));
|
||||
|
||||
more.setOnClickListener(v -> onMoreClickedListener.onMoreClicked(notificationThread));
|
||||
}
|
||||
|
@ -18,7 +18,6 @@ import org.mian.gitnex.activities.OrganizationDetailActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -47,15 +46,9 @@ public class OrganizationsListAdapter extends RecyclerView.Adapter<Organizations
|
||||
image = itemView.findViewById(R.id.imageAvatar);
|
||||
|
||||
itemView.setOnClickListener(v -> {
|
||||
|
||||
Context context = v.getContext();
|
||||
Intent intent = new Intent(context, OrganizationDetailActivity.class);
|
||||
intent.putExtra("orgName", userOrganizations.getUsername());
|
||||
|
||||
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
tinyDb.putString("orgName", userOrganizations.getUsername());
|
||||
tinyDb.putString("organizationId", String.valueOf(userOrganizations.getId()));
|
||||
tinyDb.putBoolean("organizationAction", true);
|
||||
context.startActivity(intent);
|
||||
});
|
||||
}
|
||||
|
@ -23,6 +23,8 @@ import org.mian.gitnex.helpers.ClickListener;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.contexts.IssueContext;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
@ -105,27 +107,12 @@ public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||
prCreatedTime = itemView.findViewById(R.id.prCreatedTime);
|
||||
|
||||
itemView.setOnClickListener(v -> {
|
||||
Intent intent = new Intent(context, IssueDetailActivity.class);
|
||||
intent.putExtra("issueNumber", pullRequest.getNumber());
|
||||
intent.putExtra("prMergeable", pullRequest.isMergeable());
|
||||
intent.putExtra("prHeadBranch", pullRequest.getHead().getRef());
|
||||
Intent intent = new IssueContext(
|
||||
pullRequest,
|
||||
new RepositoryContext(pullRequest.getBase().getRepo().getFull_name().split("/")[0], pullRequest.getBase().getRepo().getName(), context)
|
||||
)
|
||||
.getIntent(context, IssueDetailActivity.class);
|
||||
|
||||
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
tinyDb.putString("issueNumber", String.valueOf(pullRequest.getNumber()));
|
||||
tinyDb.putString("prMergeable", String.valueOf(pullRequest.isMergeable()));
|
||||
tinyDb.putString("prHeadBranch", pullRequest.getHead().getRef());
|
||||
|
||||
if(pullRequest.getHead() != null && pullRequest.getHead().getRepo() != null) {
|
||||
tinyDb.putString("prIsFork", String.valueOf(pullRequest.getHead().getRepo().isFork()));
|
||||
tinyDb.putString("prForkFullName", pullRequest.getHead().getRepo().getFull_name());
|
||||
}
|
||||
else {
|
||||
// pull was done from a deleted fork
|
||||
tinyDb.putString("prIsFork", "true");
|
||||
tinyDb.putString("prForkFullName", context.getString(R.string.prDeletedFork));
|
||||
}
|
||||
|
||||
tinyDb.putString("issueType", "Pull");
|
||||
context.startActivity(intent);
|
||||
|
||||
});
|
||||
@ -147,7 +134,7 @@ public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||
|
||||
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
Locale locale = context.getResources().getConfiguration().locale;
|
||||
String timeFormat = tinyDb.getString("dateFormat");
|
||||
String timeFormat = tinyDb.getString("dateFormat", "pretty");
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||
|
||||
PicassoService.getInstance(context).get()
|
||||
|
@ -105,7 +105,7 @@ public class ReleasesAdapter extends RecyclerView.Adapter<ReleasesAdapter.Releas
|
||||
|
||||
final TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
final Locale locale = context.getResources().getConfiguration().locale;
|
||||
final String timeFormat = tinyDb.getString("dateFormat");
|
||||
final String timeFormat = tinyDb.getString("dateFormat", "pretty");
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||
|
||||
Releases currentItem = releasesList.get(position);
|
||||
|
@ -15,28 +15,23 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.amulyakhare.textdrawable.TextDrawable;
|
||||
import com.amulyakhare.textdrawable.util.ColorGenerator;
|
||||
import org.gitnex.tea4j.models.UserRepositories;
|
||||
import org.gitnex.tea4j.models.WatchInfo;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.database.api.BaseApi;
|
||||
import org.mian.gitnex.database.api.RepositoriesApi;
|
||||
import org.mian.gitnex.database.models.Repository;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.ClickListener;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import org.ocpsoft.prettytime.PrettyTime;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
@ -133,7 +128,7 @@ public class RepoForksAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||
|
||||
Locale locale = context.getResources().getConfiguration().locale;
|
||||
String timeFormat = tinyDb.getString("dateFormat");
|
||||
String timeFormat = tinyDb.getString("dateFormat", "pretty");
|
||||
this.userRepositories = forksModel;
|
||||
orgName.setText(forksModel.getFullName().split("/")[0]);
|
||||
repoName.setText(forksModel.getFullName().split("/")[1]);
|
||||
@ -203,71 +198,25 @@ public class RepoForksAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
||||
|
||||
Context context = v.getContext();
|
||||
|
||||
Intent intent = new Intent(context, RepoDetailActivity.class);
|
||||
intent.putExtra("repoFullName", userRepositories.getFullName());
|
||||
|
||||
tinyDb.putString("repoFullName", userRepositories.getFullName());
|
||||
//tinyDb.putBoolean("resumeIssues", true);
|
||||
tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked());
|
||||
tinyDb.putString("repoBranch", userRepositories.getDefault_branch());
|
||||
|
||||
if(userRepositories.getPrivateFlag()) {
|
||||
tinyDb.putString("repoType", context.getResources().getString(R.string.strPrivate));
|
||||
}
|
||||
else {
|
||||
tinyDb.putString("repoType", context.getResources().getString(R.string.strPublic));
|
||||
}
|
||||
|
||||
String[] parts = userRepositories.getFullName().split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
RepositoryContext repo = new RepositoryContext(userRepositories, context);
|
||||
Intent intent = repo.getIntent(context, RepoDetailActivity.class);
|
||||
|
||||
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
||||
RepositoriesApi repositoryData = BaseApi.getInstance(context, RepositoriesApi.class);
|
||||
|
||||
//RepositoriesRepository.deleteRepositoriesByAccount(currentActiveAccountId);
|
||||
assert repositoryData != null;
|
||||
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
|
||||
if(count == 0) {
|
||||
|
||||
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
tinyDb.putLong("repositoryId", id);
|
||||
repo.setRepositoryId((int) id);
|
||||
}
|
||||
else {
|
||||
|
||||
Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
tinyDb.putLong("repositoryId", data.getRepositoryId());
|
||||
}
|
||||
|
||||
//store if user is watching this repo
|
||||
{
|
||||
|
||||
RetrofitClient.getApiInterface(context)
|
||||
.checkRepoWatchStatus(Authorization.get(context), repoOwner, repoName)
|
||||
.enqueue(new Callback<WatchInfo>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<WatchInfo> call, @NonNull retrofit2.Response<WatchInfo> response) {
|
||||
|
||||
if(response.isSuccessful() && response.body() != null) {
|
||||
|
||||
tinyDb.putBoolean("repoWatch", response.body().getSubscribed());
|
||||
} else {
|
||||
tinyDb.putBoolean("repoWatch", false);
|
||||
|
||||
if(response.code() != 404) {
|
||||
Toasty.error(context, context.getString(R.string.genericApiStatusError));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<WatchInfo> call, @NonNull Throwable t) {
|
||||
tinyDb.putBoolean("repoWatch", false);
|
||||
Toasty.error(context, context.getString(R.string.genericApiStatusError));
|
||||
}
|
||||
});
|
||||
repo.setRepositoryId(data.getRepositoryId());
|
||||
}
|
||||
|
||||
context.startActivity(intent);
|
||||
|
@ -30,6 +30,7 @@ import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import org.ocpsoft.prettytime.PrettyTime;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
@ -75,95 +76,26 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
||||
spacerView = itemView.findViewById(R.id.spacerView);
|
||||
|
||||
itemView.setOnClickListener(v -> {
|
||||
|
||||
Context context = v.getContext();
|
||||
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
RepositoryContext repo = new RepositoryContext(userRepositories, context);
|
||||
Intent intent = repo.getIntent(context, RepoDetailActivity.class);
|
||||
|
||||
Intent intent = new Intent(context, RepoDetailActivity.class);
|
||||
intent.putExtra("repoFullName", userRepositories.getFullName());
|
||||
|
||||
tinyDb.putString("repoFullName", userRepositories.getFullName());
|
||||
//tinyDb.putBoolean("resumeIssues", true);
|
||||
tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked());
|
||||
tinyDb.putString("repoBranch", userRepositories.getDefault_branch());
|
||||
|
||||
if(userRepositories.getPrivateFlag()) {
|
||||
tinyDb.putString("repoType", context.getResources().getString(R.string.strPrivate));
|
||||
}
|
||||
else {
|
||||
tinyDb.putString("repoType", context.getResources().getString(R.string.strPublic));
|
||||
}
|
||||
|
||||
String[] parts = userRepositories.getFullName().split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
|
||||
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
||||
int currentActiveAccountId = TinyDB.getInstance(context).getInt("currentActiveAccountId");
|
||||
RepositoriesApi repositoryData = BaseApi.getInstance(context, RepositoriesApi.class);
|
||||
|
||||
//RepositoriesRepository.deleteRepositoriesByAccount(currentActiveAccountId);
|
||||
assert repositoryData != null;
|
||||
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
Integer count = repositoryData.checkRepository(currentActiveAccountId, repo.getOwner(), repo.getName());
|
||||
|
||||
if(count == 0) {
|
||||
|
||||
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
tinyDb.putLong("repositoryId", id);
|
||||
long id = repositoryData.insertRepository(currentActiveAccountId, repo.getOwner(), repo.getName());
|
||||
repo.setRepositoryId((int) id);
|
||||
}
|
||||
else {
|
||||
|
||||
Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
tinyDb.putLong("repositoryId", data.getRepositoryId());
|
||||
}
|
||||
|
||||
//store if user is watching this repo
|
||||
{
|
||||
|
||||
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
||||
|
||||
WatchInfo watch = new WatchInfo();
|
||||
|
||||
Call<WatchInfo> call;
|
||||
|
||||
call = RetrofitClient.getApiInterface(context).checkRepoWatchStatus(token, repoOwner, repoName);
|
||||
|
||||
call.enqueue(new Callback<WatchInfo>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<WatchInfo> call, @NonNull retrofit2.Response<WatchInfo> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
|
||||
assert response.body() != null;
|
||||
tinyDb.putBoolean("repoWatch", response.body().getSubscribed());
|
||||
|
||||
} else {
|
||||
|
||||
tinyDb.putBoolean("repoWatch", false);
|
||||
|
||||
if(response.code() != 404) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericApiStatusError));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<WatchInfo> call, @NonNull Throwable t) {
|
||||
|
||||
tinyDb.putBoolean("repoWatch", false);
|
||||
Toasty.error(context, context.getString(R.string.genericApiStatusError));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
Repository data = repositoryData.getRepository(currentActiveAccountId, repo.getOwner(), repo.getName());
|
||||
repo.setRepositoryId(data.getRepositoryId());
|
||||
}
|
||||
|
||||
context.startActivity(intent);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@ -192,7 +124,7 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||
|
||||
Locale locale = context.getResources().getConfiguration().locale;
|
||||
String timeFormat = tinyDb.getString("dateFormat");
|
||||
String timeFormat = tinyDb.getString("dateFormat", "pretty");
|
||||
holder.userRepositories = currentItem;
|
||||
holder.orgName.setText(currentItem.getFullName().split("/")[0]);
|
||||
holder.repoName.setText(currentItem.getFullName().split("/")[1]);
|
||||
|
@ -30,6 +30,7 @@ import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import org.ocpsoft.prettytime.PrettyTime;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
@ -74,94 +75,28 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
||||
repoLastUpdated = itemView.findViewById(R.id.repoLastUpdated);
|
||||
spacerView = itemView.findViewById(R.id.spacerView);
|
||||
|
||||
itemView.setOnClickListener(v -> {
|
||||
itemView.setOnClickListener(v -> {
|
||||
Context context = v.getContext();
|
||||
RepositoryContext repo = new RepositoryContext(userRepositories, context);
|
||||
Intent intent = repo.getIntent(context, RepoDetailActivity.class);
|
||||
|
||||
Context context = v.getContext();
|
||||
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
int currentActiveAccountId = TinyDB.getInstance(context).getInt("currentActiveAccountId");
|
||||
RepositoriesApi repositoryData = BaseApi.getInstance(context, RepositoriesApi.class);
|
||||
|
||||
Intent intent = new Intent(context, RepoDetailActivity.class);
|
||||
intent.putExtra("repoFullName", userRepositories.getFullName());
|
||||
assert repositoryData != null;
|
||||
Integer count = repositoryData.checkRepository(currentActiveAccountId, repo.getOwner(), repo.getName());
|
||||
|
||||
tinyDb.putString("repoFullName", userRepositories.getFullName());
|
||||
//tinyDb.putBoolean("resumeIssues", true);
|
||||
tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked());
|
||||
tinyDb.putString("repoBranch", userRepositories.getDefault_branch());
|
||||
if(count == 0) {
|
||||
long id = repositoryData.insertRepository(currentActiveAccountId, repo.getOwner(), repo.getName());
|
||||
repo.setRepositoryId((int) id);
|
||||
}
|
||||
else {
|
||||
Repository data = repositoryData.getRepository(currentActiveAccountId, repo.getOwner(), repo.getName());
|
||||
repo.setRepositoryId(data.getRepositoryId());
|
||||
}
|
||||
|
||||
if(userRepositories.getPrivateFlag()) {
|
||||
tinyDb.putString("repoType", context.getResources().getString(R.string.strPrivate));
|
||||
}
|
||||
else {
|
||||
tinyDb.putString("repoType", context.getResources().getString(R.string.strPublic));
|
||||
}
|
||||
|
||||
String[] parts = userRepositories.getFullName().split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
|
||||
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
||||
RepositoriesApi repositoryData = BaseApi.getInstance(context, RepositoriesApi.class);
|
||||
|
||||
//RepositoriesRepository.deleteRepositoriesByAccount(currentActiveAccountId);
|
||||
assert repositoryData != null;
|
||||
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
|
||||
if(count == 0) {
|
||||
|
||||
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
tinyDb.putLong("repositoryId", id);
|
||||
}
|
||||
else {
|
||||
|
||||
Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
tinyDb.putLong("repositoryId", data.getRepositoryId());
|
||||
}
|
||||
|
||||
//store if user is watching this repo
|
||||
{
|
||||
|
||||
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
||||
|
||||
Call<WatchInfo> call;
|
||||
|
||||
call = RetrofitClient.getApiInterface(context).checkRepoWatchStatus(token, repoOwner, repoName);
|
||||
|
||||
call.enqueue(new Callback<WatchInfo>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<WatchInfo> call, @NonNull retrofit2.Response<WatchInfo> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
|
||||
assert response.body() != null;
|
||||
tinyDb.putBoolean("repoWatch", response.body().getSubscribed());
|
||||
|
||||
} else {
|
||||
|
||||
tinyDb.putBoolean("repoWatch", false);
|
||||
|
||||
if(response.code() != 404) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericApiStatusError));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<WatchInfo> call, @NonNull Throwable t) {
|
||||
|
||||
tinyDb.putBoolean("repoWatch", false);
|
||||
Toasty.error(context, context.getString(R.string.genericApiStatusError));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
context.startActivity(intent);
|
||||
});
|
||||
context.startActivity(intent);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@ -189,7 +124,7 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||
|
||||
Locale locale = context.getResources().getConfiguration().locale;
|
||||
String timeFormat = tinyDb.getString("dateFormat");
|
||||
String timeFormat = tinyDb.getString("dateFormat", "pretty");
|
||||
holder.userRepositories = currentItem;
|
||||
holder.orgName.setText(currentItem.getFullName().split("/")[0]);
|
||||
holder.repoName.setText(currentItem.getFullName().split("/")[1]);
|
||||
|
@ -15,6 +15,7 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
import org.gitnex.tea4j.models.GitTag;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.Markdown;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
@ -30,7 +31,6 @@ public class TagsAdapter extends RecyclerView.Adapter<TagsAdapter.TagsViewHolder
|
||||
private final Context context;
|
||||
private final String repo;
|
||||
private final String owner;
|
||||
private Context ctx;
|
||||
|
||||
private OnLoadMoreListener loadMoreListener;
|
||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
||||
@ -103,7 +103,7 @@ public class TagsAdapter extends RecyclerView.Adapter<TagsAdapter.TagsViewHolder
|
||||
}
|
||||
});
|
||||
|
||||
if(!TinyDB.getInstance(ctx).getBoolean("isRepoAdmin")) {
|
||||
if(!((RepoDetailActivity) context).repository.getPermissions().canPush()) {
|
||||
holder.options.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
|
@ -16,9 +16,9 @@ import org.gitnex.tea4j.models.OrgPermissions;
|
||||
import org.gitnex.tea4j.models.Teams;
|
||||
import org.gitnex.tea4j.models.UserInfo;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.activities.OrganizationTeamInfoActivity;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
@ -36,6 +36,7 @@ public class TeamsByOrgAdapter extends RecyclerView.Adapter<TeamsByOrgAdapter.Or
|
||||
private final Context context;
|
||||
private final List<Teams> teamListFull;
|
||||
private final OrgPermissions permissions;
|
||||
private final String orgName;
|
||||
|
||||
static class OrgTeamsViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
@ -48,6 +49,7 @@ public class TeamsByOrgAdapter extends RecyclerView.Adapter<TeamsByOrgAdapter.Or
|
||||
|
||||
private final List<UserInfo> userInfos;
|
||||
private final TeamMembersByOrgPreviewAdapter adapter;
|
||||
private String orgName;
|
||||
|
||||
private OrgTeamsViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
@ -70,16 +72,18 @@ public class TeamsByOrgAdapter extends RecyclerView.Adapter<TeamsByOrgAdapter.Or
|
||||
Intent intent = new Intent(context, OrganizationTeamInfoActivity.class);
|
||||
intent.putExtra("team", team);
|
||||
intent.putExtra("permissions", permissions);
|
||||
intent.putExtra("orgName", orgName);
|
||||
context.startActivity(intent);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public TeamsByOrgAdapter(Context ctx, List<Teams> teamListMain, OrgPermissions permissions) {
|
||||
public TeamsByOrgAdapter(Context ctx, List<Teams> teamListMain, OrgPermissions permissions, String orgName) {
|
||||
this.context = ctx;
|
||||
this.teamList = teamListMain;
|
||||
this.permissions = permissions;
|
||||
teamListFull = new ArrayList<>(teamList);
|
||||
this.orgName = orgName;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@ -97,13 +101,14 @@ public class TeamsByOrgAdapter extends RecyclerView.Adapter<TeamsByOrgAdapter.Or
|
||||
holder.team = currentItem;
|
||||
holder.teamTitle.setText(currentItem.getName());
|
||||
holder.permissions = permissions;
|
||||
holder.orgName = orgName;
|
||||
|
||||
holder.membersPreviewFrame.setVisibility(View.GONE);
|
||||
holder.userInfos.clear();
|
||||
holder.adapter.notifyDataSetChanged();
|
||||
|
||||
RetrofitClient.getApiInterface(context)
|
||||
.getTeamMembersByOrg(Authorization.get(context), currentItem.getId())
|
||||
.getTeamMembersByOrg(((BaseActivity) context).getAccount().getAuthorization(), currentItem.getId())
|
||||
.enqueue(new Callback<List<UserInfo>>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<UserInfo>> call, @NonNull Response<List<UserInfo>> response) {
|
||||
@ -168,7 +173,7 @@ public class TeamsByOrgAdapter extends RecyclerView.Adapter<TeamsByOrgAdapter.Or
|
||||
@Override
|
||||
protected void publishResults(CharSequence constraint, FilterResults results) {
|
||||
teamList.clear();
|
||||
teamList.addAll((List) results.values);
|
||||
teamList.addAll((List<Teams>) results.values);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
};
|
||||
|
@ -4,6 +4,7 @@ import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@ -14,6 +15,8 @@ import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.content.res.AppCompatResources;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.AddNewAccountActivity;
|
||||
import org.mian.gitnex.activities.LoginActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.database.api.BaseApi;
|
||||
import org.mian.gitnex.database.api.UserAccountsApi;
|
||||
@ -23,6 +26,7 @@ import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import io.mikael.urlbuilder.UrlBuilder;
|
||||
|
||||
/**
|
||||
@ -33,7 +37,6 @@ public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapte
|
||||
|
||||
private final List<UserAccount> userAccountsList;
|
||||
private final Context context;
|
||||
private TinyDB tinyDB;
|
||||
private final Dialog dialog;
|
||||
|
||||
class UserAccountsViewHolder extends RecyclerView.ViewHolder {
|
||||
@ -79,6 +82,36 @@ public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapte
|
||||
assert userAccountsApi != null;
|
||||
UserAccount userAccount = userAccountsApi.getAccountByName(accountName);
|
||||
|
||||
if(!userAccount.isLoggedIn()) {
|
||||
UrlBuilder url = UrlBuilder.fromString(userAccount.getInstanceUrl())
|
||||
.withPath("/");
|
||||
|
||||
String host;
|
||||
if(url.scheme.equals("http")) {
|
||||
if(url.port == 80 || url.port == 0) {
|
||||
host = url.hostName;
|
||||
} else {
|
||||
host = url.hostName + ":" + url.port;
|
||||
}
|
||||
} else {
|
||||
if(url.port == 443 || url.port == 0) {
|
||||
host = url.hostName;
|
||||
} else {
|
||||
host = url.hostName + ":" + url.port;
|
||||
}
|
||||
}
|
||||
|
||||
Toasty.warning(context, context.getString(R.string.logInAgain));
|
||||
dialog.dismiss();
|
||||
|
||||
Intent i = new Intent(context, AddNewAccountActivity.class);
|
||||
i.putExtra("instanceUrl", host);
|
||||
i.putExtra("scheme", url.scheme);
|
||||
i.putExtra("token", userAccount.getToken());
|
||||
context.startActivity(i);
|
||||
return;
|
||||
}
|
||||
|
||||
if(AppUtil.switchToAccount(context, userAccount)) {
|
||||
|
||||
String url = UrlBuilder.fromString(userAccount.getInstanceUrl())
|
||||
@ -96,10 +129,10 @@ public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapte
|
||||
|
||||
}
|
||||
|
||||
public UserAccountsAdapter(Context ctx, List<UserAccount> userAccountsListMain, Dialog dialog) {
|
||||
public UserAccountsAdapter(Context ctx, Dialog dialog) {
|
||||
this.dialog = dialog;
|
||||
this.context = ctx;
|
||||
this.userAccountsList = userAccountsListMain;
|
||||
this.userAccountsList = Objects.requireNonNull(BaseApi.getInstance(context, UserAccountsApi.class)).usersAccounts();
|
||||
}
|
||||
|
||||
private void updateLayoutByPosition(int position) {
|
||||
@ -123,7 +156,7 @@ public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapte
|
||||
public void onBindViewHolder(@NonNull UserAccountsAdapter.UserAccountsViewHolder holder, int position) {
|
||||
|
||||
UserAccount currentItem = userAccountsList.get(position);
|
||||
tinyDB = TinyDB.getInstance(context);
|
||||
TinyDB tinyDB = TinyDB.getInstance(context);
|
||||
|
||||
String url = UrlBuilder.fromString(currentItem.getInstanceUrl())
|
||||
.withPath("/")
|
||||
@ -133,7 +166,11 @@ public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapte
|
||||
holder.accountName = currentItem.getAccountName();
|
||||
|
||||
holder.userId.setText(currentItem.getUserName());
|
||||
holder.accountUrl.setText(url);
|
||||
if(currentItem.isLoggedIn()) {
|
||||
holder.accountUrl.setText(url);
|
||||
} else {
|
||||
holder.accountUrl.setText(context.getString(R.string.notLoggedIn, url));
|
||||
}
|
||||
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||
|
||||
|
@ -52,7 +52,7 @@ public class UserAccountsNavAdapter extends RecyclerView.Adapter<UserAccountsNav
|
||||
userAccountAvatar = itemView.findViewById(R.id.userAccountAvatar);
|
||||
|
||||
itemView.setOnClickListener(item -> {
|
||||
customDialogUserAccountsList(userAccountsList);
|
||||
customDialogUserAccountsList();
|
||||
drawer.closeDrawers();
|
||||
});
|
||||
|
||||
@ -95,7 +95,7 @@ public class UserAccountsNavAdapter extends RecyclerView.Adapter<UserAccountsNav
|
||||
return userAccountsList.size();
|
||||
}
|
||||
|
||||
private void customDialogUserAccountsList(List<UserAccount> allAccountsList) {
|
||||
private void customDialogUserAccountsList() {
|
||||
|
||||
Dialog dialog = new Dialog(context, R.style.ThemeOverlay_MaterialComponents_Dialog_Alert);
|
||||
dialog.setContentView(R.layout.custom_user_accounts_dialog);
|
||||
@ -113,7 +113,7 @@ public class UserAccountsNavAdapter extends RecyclerView.Adapter<UserAccountsNav
|
||||
|
||||
});
|
||||
|
||||
UserAccountsAdapter arrayAdapter = new UserAccountsAdapter(context, allAccountsList, dialog);
|
||||
UserAccountsAdapter arrayAdapter = new UserAccountsAdapter(context, dialog);
|
||||
listView.setLayoutManager(new LinearLayoutManager(context));
|
||||
listView.setAdapter(arrayAdapter);
|
||||
dialog.show();
|
||||
|
@ -12,12 +12,12 @@ import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import org.gitnex.tea4j.models.UserInfo;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.activities.ProfileActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
@ -34,12 +34,14 @@ public class UserSearchForTeamMemberAdapter extends RecyclerView.Adapter<UserSea
|
||||
|
||||
private final List<UserInfo> usersSearchList;
|
||||
private final Context context;
|
||||
private static int teamId;
|
||||
private final int teamId;
|
||||
private final String orgName;
|
||||
|
||||
public UserSearchForTeamMemberAdapter(List<UserInfo> dataList, Context ctx, int teamId) {
|
||||
public UserSearchForTeamMemberAdapter(List<UserInfo> dataList, Context ctx, int teamId, String orgName) {
|
||||
this.context = ctx;
|
||||
this.usersSearchList = dataList;
|
||||
UserSearchForTeamMemberAdapter.teamId = teamId;
|
||||
this.teamId = teamId;
|
||||
this.orgName = orgName;
|
||||
}
|
||||
|
||||
class UserSearchViewHolder extends RecyclerView.ViewHolder {
|
||||
@ -122,15 +124,11 @@ public class UserSearchForTeamMemberAdapter extends RecyclerView.Adapter<UserSea
|
||||
|
||||
if(getItemCount() > 0) {
|
||||
|
||||
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String loginUid = ((BaseActivity) context).getAccount().getAccount().getUserName();
|
||||
|
||||
Call<UserInfo> call = RetrofitClient
|
||||
.getApiInterface(context)
|
||||
.checkTeamMember(Authorization.get(context), teamId, currentItem.getLogin());
|
||||
.checkTeamMember(((BaseActivity) context).getAccount().getAuthorization(), teamId, currentItem.getLogin());
|
||||
|
||||
call.enqueue(new Callback<UserInfo>() {
|
||||
|
||||
@ -139,7 +137,7 @@ public class UserSearchForTeamMemberAdapter extends RecyclerView.Adapter<UserSea
|
||||
|
||||
if(response.code() == 200) {
|
||||
|
||||
if(!currentItem.getLogin().equals(loginUid) && !currentItem.getLogin().equals(repoOwner)) {
|
||||
if(!currentItem.getLogin().equals(loginUid)) {
|
||||
holder.addMemberButtonRemove.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
@ -149,7 +147,7 @@ public class UserSearchForTeamMemberAdapter extends RecyclerView.Adapter<UserSea
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
|
||||
if(!currentItem.getLogin().equals(loginUid) && !currentItem.getLogin().equals(repoOwner)) {
|
||||
if(!currentItem.getLogin().equals(loginUid)) {
|
||||
holder.addMemberButtonAdd.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
|
@ -2,6 +2,7 @@ package org.mian.gitnex.adapters.profile;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@ -11,6 +12,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import org.gitnex.tea4j.models.UserOrganizations;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.OrganizationDetailActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
@ -89,6 +91,13 @@ public class OrganizationsAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
orgName = itemView.findViewById(R.id.orgName);
|
||||
orgDescription = itemView.findViewById(R.id.orgDescription);
|
||||
image = itemView.findViewById(R.id.imageAvatar);
|
||||
|
||||
itemView.setOnClickListener(v -> {
|
||||
Context context = v.getContext();
|
||||
Intent intent = new Intent(context, OrganizationDetailActivity.class);
|
||||
intent.putExtra("orgName", userOrganizations.getUsername());
|
||||
context.startActivity(intent);
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
|
@ -2,6 +2,7 @@ package org.mian.gitnex.adapters.profile;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@ -15,12 +16,17 @@ import com.amulyakhare.textdrawable.TextDrawable;
|
||||
import com.amulyakhare.textdrawable.util.ColorGenerator;
|
||||
import org.gitnex.tea4j.models.UserRepositories;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.database.api.BaseApi;
|
||||
import org.mian.gitnex.database.api.RepositoriesApi;
|
||||
import org.mian.gitnex.database.models.Repository;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.ClickListener;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
@ -105,6 +111,30 @@ public class RepositoriesAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||
avatar = itemView.findViewById(R.id.imageAvatar);
|
||||
repoStars = itemView.findViewById(R.id.repoStars);
|
||||
repoLastUpdated = itemView.findViewById(R.id.repoLastUpdated);
|
||||
|
||||
itemView.setOnClickListener(v -> {
|
||||
Context context = v.getContext();
|
||||
RepositoryContext repo = new RepositoryContext(userRepositories, context);
|
||||
Intent intent = repo.getIntent(context, RepoDetailActivity.class);
|
||||
|
||||
int currentActiveAccountId = TinyDB.getInstance(context).getInt("currentActiveAccountId");
|
||||
RepositoriesApi repositoryData = BaseApi.getInstance(context, RepositoriesApi.class);
|
||||
|
||||
assert repositoryData != null;
|
||||
Integer count = repositoryData.checkRepository(currentActiveAccountId, repo.getOwner(), repo.getName());
|
||||
|
||||
if(count == 0) {
|
||||
long id = repositoryData.insertRepository(currentActiveAccountId, repo.getOwner(), repo.getName());
|
||||
repo.setRepositoryId((int) id);
|
||||
}
|
||||
else {
|
||||
Repository data = repositoryData.getRepository(currentActiveAccountId, repo.getOwner(), repo.getName());
|
||||
repo.setRepositoryId(data.getRepositoryId());
|
||||
}
|
||||
|
||||
context.startActivity(intent);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@ -115,7 +145,7 @@ public class RepositoriesAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||
|
||||
Locale locale = context.getResources().getConfiguration().locale;
|
||||
String timeFormat = tinyDb.getString("dateFormat");
|
||||
String timeFormat = tinyDb.getString("dateFormat", "pretty");
|
||||
|
||||
orgName.setText(userRepositories.getFullName().split("/")[0]);
|
||||
repoName.setText(userRepositories.getFullName().split("/")[1]);
|
||||
|
@ -2,6 +2,7 @@ package org.mian.gitnex.adapters.profile;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@ -15,12 +16,17 @@ import com.amulyakhare.textdrawable.TextDrawable;
|
||||
import com.amulyakhare.textdrawable.util.ColorGenerator;
|
||||
import org.gitnex.tea4j.models.UserRepositories;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.database.api.BaseApi;
|
||||
import org.mian.gitnex.database.api.RepositoriesApi;
|
||||
import org.mian.gitnex.database.models.Repository;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.ClickListener;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
@ -105,6 +111,29 @@ public class StarredRepositoriesAdapter extends RecyclerView.Adapter<RecyclerVie
|
||||
avatar = itemView.findViewById(R.id.imageAvatar);
|
||||
repoStars = itemView.findViewById(R.id.repoStars);
|
||||
repoLastUpdated = itemView.findViewById(R.id.repoLastUpdated);
|
||||
|
||||
itemView.setOnClickListener(v -> {
|
||||
Context context = v.getContext();
|
||||
RepositoryContext repo = new RepositoryContext(userRepositories, context);
|
||||
Intent intent = repo.getIntent(context, RepoDetailActivity.class);
|
||||
|
||||
int currentActiveAccountId = TinyDB.getInstance(context).getInt("currentActiveAccountId");
|
||||
RepositoriesApi repositoryData = BaseApi.getInstance(context, RepositoriesApi.class);
|
||||
|
||||
assert repositoryData != null;
|
||||
Integer count = repositoryData.checkRepository(currentActiveAccountId, repo.getOwner(), repo.getName());
|
||||
|
||||
if(count == 0) {
|
||||
long id = repositoryData.insertRepository(currentActiveAccountId, repo.getOwner(), repo.getName());
|
||||
repo.setRepositoryId((int) id);
|
||||
}
|
||||
else {
|
||||
Repository data = repositoryData.getRepository(currentActiveAccountId, repo.getOwner(), repo.getName());
|
||||
repo.setRepositoryId(data.getRepositoryId());
|
||||
}
|
||||
|
||||
context.startActivity(intent);
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@ -115,7 +144,7 @@ public class StarredRepositoriesAdapter extends RecyclerView.Adapter<RecyclerVie
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||
|
||||
Locale locale = context.getResources().getConfiguration().locale;
|
||||
String timeFormat = tinyDb.getString("dateFormat");
|
||||
String timeFormat = tinyDb.getString("dateFormat", "pretty");
|
||||
|
||||
orgName.setText(userRepositories.getFullName().split("/")[0]);
|
||||
repoName.setText(userRepositories.getFullName().split("/")[1]);
|
||||
|
@ -4,6 +4,8 @@ import android.content.Context;
|
||||
import android.util.Log;
|
||||
import org.gitnex.tea4j.ApiInterface;
|
||||
import org.gitnex.tea4j.WebInterface;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.FilesData;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
@ -52,7 +54,7 @@ public class RetrofitClient {
|
||||
|
||||
if(cacheEnabled) {
|
||||
|
||||
int cacheSize = FilesData.returnOnlyNumber(tinyDB.getString("cacheSizeStr")) * 1024 * 1024;
|
||||
int cacheSize = FilesData.returnOnlyNumber(tinyDB.getString("cacheSizeStr", context.getString(R.string.cacheSizeDataSelectionSelectedText))) * 1024 * 1024;
|
||||
Cache cache = new Cache(new File(context.getCacheDir(), "responses"), cacheSize);
|
||||
|
||||
okHttpClient.cache(cache).addInterceptor(chain -> {
|
||||
@ -85,13 +87,12 @@ public class RetrofitClient {
|
||||
}
|
||||
|
||||
public static ApiInterface getApiInterface(Context context) {
|
||||
|
||||
return getApiInterface(context, TinyDB.getInstance(context).getString("instanceUrl"));
|
||||
return getApiInterface(context, ((BaseActivity) context).getAccount().getAccount().getInstanceUrl());
|
||||
}
|
||||
|
||||
public static WebInterface getWebInterface(Context context) {
|
||||
|
||||
String instanceUrl = TinyDB.getInstance(context).getString("instanceUrl");
|
||||
String instanceUrl = ((BaseActivity) context).getAccount().getAccount().getInstanceUrl();
|
||||
instanceUrl = instanceUrl.substring(0, instanceUrl.lastIndexOf("api/v1/"));
|
||||
|
||||
return getWebInterface(context, instanceUrl);
|
||||
|
@ -14,10 +14,12 @@ import org.acra.config.LimiterConfigurationBuilder;
|
||||
import org.acra.config.MailSenderConfigurationBuilder;
|
||||
import org.acra.data.StringFormat;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.database.models.UserAccount;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Constants;
|
||||
import org.mian.gitnex.helpers.FontsOverride;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.contexts.AccountContext;
|
||||
import org.mian.gitnex.notifications.Notifications;
|
||||
|
||||
/**
|
||||
@ -36,6 +38,7 @@ import org.mian.gitnex.notifications.Notifications;
|
||||
public class MainApplication extends Application {
|
||||
|
||||
private TinyDB tinyDB;
|
||||
public AccountContext currentAccount;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
@ -45,9 +48,9 @@ public class MainApplication extends Application {
|
||||
Context appCtx = getApplicationContext();
|
||||
tinyDB = TinyDB.getInstance(appCtx);
|
||||
|
||||
tinyDB.putBoolean("biometricLifeCycle", false);
|
||||
currentAccount = AccountContext.fromId(tinyDB.getInt("currentActiveAccountId", 0), appCtx);
|
||||
|
||||
setDefaults();
|
||||
tinyDB.putBoolean("biometricLifeCycle", false);
|
||||
|
||||
switch(tinyDB.getInt("customFontId", -1)) {
|
||||
|
||||
@ -83,7 +86,7 @@ public class MainApplication extends Application {
|
||||
|
||||
tinyDB = TinyDB.getInstance(context);
|
||||
|
||||
if(tinyDB.getBoolean("crashReportingEnabled")) {
|
||||
if(tinyDB.getBoolean("crashReportingEnabled", true)) {
|
||||
|
||||
CoreConfigurationBuilder ACRABuilder = new CoreConfigurationBuilder(this);
|
||||
|
||||
@ -96,78 +99,13 @@ public class MainApplication extends Application {
|
||||
}
|
||||
}
|
||||
|
||||
private void setDefaults() {
|
||||
|
||||
// enabling counter badges by default
|
||||
if(tinyDB.getString("enableCounterBadgesInit").isEmpty()) {
|
||||
tinyDB.putBoolean("enableCounterBadges", true);
|
||||
tinyDB.putString("enableCounterBadgesInit", "yes");
|
||||
public boolean switchToAccount(UserAccount userAccount, boolean tmp) {
|
||||
if(!tmp || tinyDB.getInt("currentActiveAccountId") != userAccount.getAccountId()) {
|
||||
currentAccount = new AccountContext(userAccount);
|
||||
if(!tmp) tinyDB.putInt("currentActiveAccountId", userAccount.getAccountId());
|
||||
return true;
|
||||
}
|
||||
|
||||
// enable crash reports by default
|
||||
if(tinyDB.getString("crashReportingEnabledInit").isEmpty()) {
|
||||
tinyDB.putBoolean("crashReportingEnabled", true);
|
||||
tinyDB.putString("crashReportingEnabledInit", "yes");
|
||||
}
|
||||
|
||||
// default cache setter
|
||||
if(tinyDB.getString("cacheSizeStr").isEmpty()) {
|
||||
tinyDB.putString("cacheSizeStr", getResources().getString(R.string.cacheSizeDataSelectionSelectedText));
|
||||
}
|
||||
if(tinyDB.getString("cacheSizeImagesStr").isEmpty()) {
|
||||
tinyDB.putString("cacheSizeImagesStr", getResources().getString(R.string.cacheSizeImagesSelectionSelectedText));
|
||||
}
|
||||
|
||||
// enable comment drafts by default
|
||||
if(tinyDB.getString("draftsCommentsDeletionEnabledInit").isEmpty()) {
|
||||
tinyDB.putBoolean("draftsCommentsDeletionEnabled", true);
|
||||
tinyDB.putString("draftsCommentsDeletionEnabledInit", "yes");
|
||||
}
|
||||
|
||||
// setting default polling delay
|
||||
if(tinyDB.getInt("pollingDelayMinutes", 0) <= 0) {
|
||||
tinyDB.putInt("pollingDelayMinutes", Constants.defaultPollingDelay);
|
||||
}
|
||||
|
||||
// disable biometric by default
|
||||
if(tinyDB.getString("biometricStatusInit").isEmpty()) {
|
||||
tinyDB.putBoolean("biometricStatus", false);
|
||||
tinyDB.putString("biometricStatusInit", "yes");
|
||||
}
|
||||
|
||||
// set default date format
|
||||
if(tinyDB.getString("dateFormat").isEmpty()) {
|
||||
tinyDB.putString("dateFormat", "pretty");
|
||||
}
|
||||
|
||||
if(tinyDB.getString("codeBlockStr").isEmpty()) {
|
||||
tinyDB.putInt("codeBlockColor", ResourcesCompat.getColor(getResources(), R.color.colorLightGreen, null));
|
||||
tinyDB.putInt("codeBlockBackground", ResourcesCompat.getColor(getResources(), R.color.black, null));
|
||||
}
|
||||
|
||||
if(tinyDB.getString("enableCounterIssueBadgeInit").isEmpty()) {
|
||||
tinyDB.putBoolean("enableCounterIssueBadge", true);
|
||||
}
|
||||
|
||||
if(tinyDB.getString("homeScreenStr").isEmpty()) {
|
||||
tinyDB.putString("homeScreenStr", "yes");
|
||||
tinyDB.putInt("homeScreenId", 0);
|
||||
}
|
||||
|
||||
if(tinyDB.getString("localeStr").isEmpty()) {
|
||||
tinyDB.putString("localeStr", getString(R.string.settingsLanguageSystem));
|
||||
tinyDB.putInt("langId", 0);
|
||||
}
|
||||
|
||||
if(tinyDB.getInt("darkThemeTimeHour", 100) == 100) {
|
||||
tinyDB.putInt("lightThemeTimeHour", 6);
|
||||
tinyDB.putInt("lightThemeTimeMinute", 0);
|
||||
tinyDB.putInt("darkThemeTimeHour", 18);
|
||||
tinyDB.putInt("darkThemeTimeMinute", 0);
|
||||
}
|
||||
|
||||
if(tinyDB.getString("timeStr").isEmpty()) {
|
||||
tinyDB.putString("timeStr", getString(R.string.settingsDateTimeHeaderDefault));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package org.mian.gitnex.database.api;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.room.Query;
|
||||
import org.mian.gitnex.database.dao.UserAccountsDao;
|
||||
import org.mian.gitnex.database.models.UserAccount;
|
||||
import java.util.List;
|
||||
@ -27,6 +28,7 @@ public class UserAccountsApi extends BaseApi {
|
||||
userAccount.setUserName(userName);
|
||||
userAccount.setToken(token);
|
||||
userAccount.setServerVersion(serverVersion);
|
||||
userAccount.setLoggedIn(true);
|
||||
|
||||
return userAccountsDao.createAccount(userAccount);
|
||||
|
||||
@ -44,6 +46,10 @@ public class UserAccountsApi extends BaseApi {
|
||||
executorService.execute(() -> userAccountsDao.updateAccountTokenByAccountName(accountName, token));
|
||||
}
|
||||
|
||||
public void updateUsername(final int accountId, final String newName) {
|
||||
executorService.execute(() -> userAccountsDao.updateUserName(newName, accountId));
|
||||
}
|
||||
|
||||
public UserAccount getAccountByName(String accountName) {
|
||||
return userAccountsDao.getAccountByName(accountName);
|
||||
}
|
||||
@ -64,12 +70,28 @@ public class UserAccountsApi extends BaseApi {
|
||||
return userAccountsDao.getAllAccounts();
|
||||
}
|
||||
|
||||
public LiveData<List<UserAccount>> getAllLoggedInAccounts() {
|
||||
return userAccountsDao.getAllLoggedInAccounts();
|
||||
}
|
||||
|
||||
public List<UserAccount> usersAccounts() {
|
||||
return userAccountsDao.userAccounts();
|
||||
}
|
||||
|
||||
public List<UserAccount> loggedInUserAccounts() {
|
||||
return userAccountsDao.loggedInUserAccounts();
|
||||
}
|
||||
|
||||
public void deleteAccount(final int accountId) {
|
||||
executorService.execute(() -> userAccountsDao.deleteAccount(accountId));
|
||||
}
|
||||
|
||||
public void logout(int accountId) {
|
||||
userAccountsDao.logout(accountId);
|
||||
}
|
||||
|
||||
public void login(int accountId) {
|
||||
executorService.execute(() -> userAccountsDao.login(accountId));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -20,10 +20,16 @@ public interface UserAccountsDao {
|
||||
@Query("SELECT * FROM UserAccounts ORDER BY accountId ASC")
|
||||
LiveData<List<UserAccount>> getAllAccounts();
|
||||
|
||||
@Query("SELECT * FROM UserAccounts WHERE isLoggedIn = 1 ORDER BY accountId ASC")
|
||||
LiveData<List<UserAccount>> getAllLoggedInAccounts();
|
||||
|
||||
@Query("SELECT * FROM UserAccounts ORDER BY accountId ASC")
|
||||
List<UserAccount> userAccounts();
|
||||
|
||||
@Query("SELECT COUNT(accountId) FROM UserAccounts")
|
||||
@Query("SELECT * FROM UserAccounts WHERE isLoggedIn = 1 ORDER BY accountId ASC")
|
||||
List<UserAccount> loggedInUserAccounts();
|
||||
|
||||
@Query("SELECT COUNT(accountId) FROM UserAccounts WHERE isLoggedIn = 1")
|
||||
Integer getCount();
|
||||
|
||||
@Query("SELECT COUNT(accountId) FROM UserAccounts WHERE accountName = :accountName LIMIT 1")
|
||||
@ -56,6 +62,12 @@ public interface UserAccountsDao {
|
||||
@Query("UPDATE UserAccounts SET instanceUrl = :instanceUrl, token = :token, userName = :userName, serverVersion = :serverVersion WHERE accountId = :accountId")
|
||||
void updateAll(String instanceUrl, String token, String userName, String serverVersion, int accountId);
|
||||
|
||||
@Query("UPDATE UserAccounts SET isLoggedIn = 0 WHERE accountId = :accountId")
|
||||
void logout(int accountId);
|
||||
|
||||
@Query("UPDATE UserAccounts SET isLoggedIn = 1 WHERE accountId = :accountId")
|
||||
void login(int accountId);
|
||||
|
||||
@Query("DELETE FROM UserAccounts WHERE accountId = :accountId")
|
||||
void deleteAccount(int accountId);
|
||||
|
||||
|
@ -19,7 +19,7 @@ import org.mian.gitnex.database.models.UserAccount;
|
||||
*/
|
||||
|
||||
@Database(entities = {Draft.class, Repository.class, UserAccount.class},
|
||||
version = 3, exportSchema = false)
|
||||
version = 4, exportSchema = false)
|
||||
public abstract class GitnexDatabase extends RoomDatabase {
|
||||
|
||||
private static final String DB_NAME = "gitnex";
|
||||
@ -44,6 +44,14 @@ public abstract class GitnexDatabase extends RoomDatabase {
|
||||
}
|
||||
};
|
||||
|
||||
private static final Migration MIGRATION_3_4 = new Migration(3, 4) {
|
||||
|
||||
@Override
|
||||
public void migrate(@NonNull SupportSQLiteDatabase database) {
|
||||
database.execSQL("ALTER TABLE 'userAccounts' ADD COLUMN 'isLoggedIn' INTEGER NOT NULL DEFAULT 1");
|
||||
}
|
||||
};
|
||||
|
||||
public static GitnexDatabase getDatabaseInstance(Context context) {
|
||||
|
||||
if (gitnexDatabase == null) {
|
||||
@ -53,7 +61,7 @@ public abstract class GitnexDatabase extends RoomDatabase {
|
||||
gitnexDatabase = Room.databaseBuilder(context, GitnexDatabase.class, DB_NAME)
|
||||
// .fallbackToDestructiveMigration()
|
||||
.allowMainThreadQueries()
|
||||
.addMigrations(MIGRATION_1_2, MIGRATION_2_3)
|
||||
.addMigrations(MIGRATION_1_2, MIGRATION_2_3, MIGRATION_3_4)
|
||||
.build();
|
||||
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ public class UserAccount implements Serializable {
|
||||
private String token;
|
||||
@Nullable
|
||||
private String serverVersion;
|
||||
private boolean isLoggedIn;
|
||||
|
||||
public int getAccountId() {
|
||||
return accountId;
|
||||
@ -72,4 +73,13 @@ public class UserAccount implements Serializable {
|
||||
public void setServerVersion(@Nullable String serverVersion) {
|
||||
this.serverVersion = serverVersion;
|
||||
}
|
||||
|
||||
public boolean isLoggedIn() {
|
||||
return isLoggedIn;
|
||||
}
|
||||
|
||||
public void setLoggedIn(boolean loggedIn) {
|
||||
isLoggedIn = loggedIn;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,9 +11,8 @@ import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import org.mian.gitnex.activities.AdminCronTasksActivity;
|
||||
import org.mian.gitnex.activities.AdminGetUsersActivity;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.databinding.FragmentAdministrationBinding;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
@ -21,19 +20,15 @@ import org.mian.gitnex.helpers.Version;
|
||||
|
||||
public class AdministrationFragment extends Fragment {
|
||||
|
||||
private Context ctx;
|
||||
private TinyDB tinyDB;
|
||||
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
|
||||
ctx = getContext();
|
||||
tinyDB = TinyDB.getInstance(ctx);
|
||||
Context ctx = getContext();
|
||||
FragmentAdministrationBinding fragmentAdministrationBinding = FragmentAdministrationBinding.inflate(inflater, container, false);
|
||||
|
||||
fragmentAdministrationBinding.adminUsers.setOnClickListener(v1 -> startActivity(new Intent(getContext(), AdminGetUsersActivity.class)));
|
||||
|
||||
// if gitea version is greater/equal(1.13.0) than user installed version (installed.higherOrEqual(compareVer))
|
||||
if(new Version(tinyDB.getString("giteaVersion")).higherOrEqual("1.13.0")) {
|
||||
if(((BaseActivity) requireActivity()).getAccount().requiresVersion("1.13.0")) {
|
||||
|
||||
fragmentAdministrationBinding.adminCron.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ public class BottomSheetAdminUsersFragment extends BottomSheetDialogFragment {
|
||||
bmListener = (BottomSheetListener) context;
|
||||
}
|
||||
catch (ClassCastException e) {
|
||||
throw new ClassCastException(context.toString() + " must implement BottomSheetListener");
|
||||
throw new ClassCastException(context + " must implement BottomSheetListener");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,8 +9,8 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||
import org.mian.gitnex.databinding.BottomSheetFileViewerBinding;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import org.mian.gitnex.structs.BottomSheetListener;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
@ -24,9 +24,10 @@ public class BottomSheetFileViewerFragment extends BottomSheetDialogFragment {
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
|
||||
RepositoryContext repository = RepositoryContext.fromBundle(requireArguments());
|
||||
BottomSheetFileViewerBinding bottomSheetFileViewerBinding = BottomSheetFileViewerBinding.inflate(inflater, container, false);
|
||||
|
||||
if(!TinyDB.getInstance(requireContext()).getBoolean("canPush")) {
|
||||
if(!repository.getPermissions().canPush()) {
|
||||
bottomSheetFileViewerBinding.deleteFile.setVisibility(View.GONE);
|
||||
bottomSheetFileViewerBinding.editFile.setVisibility(View.GONE);
|
||||
}
|
||||
@ -57,12 +58,10 @@ public class BottomSheetFileViewerFragment extends BottomSheetDialogFragment {
|
||||
super.onAttach(context);
|
||||
|
||||
try {
|
||||
|
||||
bmListener = (BottomSheetListener) context;
|
||||
}
|
||||
catch (ClassCastException e) {
|
||||
|
||||
throw new ClassCastException(context.toString() + " must implement BottomSheetListener");
|
||||
throw new ClassCastException(context + " must implement BottomSheetListener");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@ import android.view.ViewGroup;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.databinding.BottomSheetIssuesFilterBinding;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
@ -26,9 +27,8 @@ public class BottomSheetIssuesFilterFragment extends BottomSheetDialogFragment {
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
|
||||
BottomSheetIssuesFilterBinding bottomSheetIssuesFilterBinding = BottomSheetIssuesFilterBinding.inflate(inflater, container, false);
|
||||
TinyDB tinyDb = TinyDB.getInstance(getContext());
|
||||
|
||||
if(new Version(tinyDb.getString("giteaVersion")).higherOrEqual("1.14.0")) {
|
||||
if(((BaseActivity) requireActivity()).getAccount().requiresVersion("1.14.0")) {
|
||||
bottomSheetIssuesFilterBinding.filterByMilestone.setVisibility(View.VISIBLE);
|
||||
bottomSheetIssuesFilterBinding.filterByMilestone.setOnClickListener(v1 -> {
|
||||
bmListener.onButtonClicked("filterByMilestone");
|
||||
@ -58,7 +58,7 @@ public class BottomSheetIssuesFilterFragment extends BottomSheetDialogFragment {
|
||||
bmListener = (BottomSheetListener) context;
|
||||
}
|
||||
catch(ClassCastException e) {
|
||||
throw new ClassCastException(context.toString() + " must implement BottomSheetListener");
|
||||
throw new ClassCastException(context + " must implement BottomSheetListener");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.mian.gitnex.fragments;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@ -9,7 +8,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||
import org.mian.gitnex.databinding.BottomSheetNotificationsFilterBinding;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.structs.BottomSheetListener;
|
||||
|
||||
/**
|
||||
* Author opyale
|
||||
@ -17,57 +16,28 @@ import org.mian.gitnex.helpers.TinyDB;
|
||||
|
||||
public class BottomSheetNotificationsFilterFragment extends BottomSheetDialogFragment {
|
||||
|
||||
private TinyDB tinyDB;
|
||||
private Runnable onDismissedListener;
|
||||
|
||||
@Override
|
||||
public void onAttach(@NonNull Context context) {
|
||||
|
||||
super.onAttach(context);
|
||||
|
||||
this.tinyDB = TinyDB.getInstance(context);
|
||||
|
||||
}
|
||||
private BottomSheetListener listener;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
BottomSheetNotificationsFilterBinding binding = BottomSheetNotificationsFilterBinding.inflate(inflater, container, false);
|
||||
|
||||
BottomSheetNotificationsFilterBinding bottomSheetNotificationsFilterBinding = BottomSheetNotificationsFilterBinding.inflate(inflater, container, false);
|
||||
|
||||
bottomSheetNotificationsFilterBinding.readNotifications.setOnClickListener(v1 -> {
|
||||
|
||||
tinyDB.putString("notificationsFilterState", "read");
|
||||
binding.readNotifications.setOnClickListener(v1 -> {
|
||||
listener.onButtonClicked("read");
|
||||
dismiss();
|
||||
|
||||
});
|
||||
|
||||
bottomSheetNotificationsFilterBinding.unreadNotifications.setOnClickListener(v12 -> {
|
||||
|
||||
tinyDB.putString("notificationsFilterState", "unread");
|
||||
binding.unreadNotifications.setOnClickListener(v12 -> {
|
||||
listener.onButtonClicked("unread");
|
||||
dismiss();
|
||||
|
||||
});
|
||||
|
||||
return bottomSheetNotificationsFilterBinding.getRoot();
|
||||
|
||||
return binding.getRoot();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dismiss() {
|
||||
|
||||
if(onDismissedListener != null) {
|
||||
|
||||
onDismissedListener.run();
|
||||
}
|
||||
|
||||
super.dismiss();
|
||||
|
||||
}
|
||||
|
||||
public void setOnDismissedListener(Runnable onDismissedListener) {
|
||||
|
||||
this.onDismissedListener = onDismissedListener;
|
||||
public void setOnClickListener(BottomSheetListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,10 +10,10 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||
import org.gitnex.tea4j.models.NotificationThread;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.BottomSheetNotificationsBinding;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.SimpleCallback;
|
||||
|
||||
/**
|
||||
@ -56,7 +56,7 @@ public class BottomSheetNotificationsFragment extends BottomSheetDialogFragment
|
||||
|
||||
markPinned.setOnClickListener(v12 ->
|
||||
RetrofitClient.getApiInterface(context)
|
||||
.markNotificationThreadAsRead(Authorization.get(context), notificationThread.getId(), "pinned")
|
||||
.markNotificationThreadAsRead(((BaseActivity) context).getAccount().getAuthorization(), notificationThread.getId(), "pinned")
|
||||
.enqueue((SimpleCallback<Void>) (call, voidResponse) -> {
|
||||
|
||||
// reload without any checks, because Gitea returns a 205 and Java expects this to be empty
|
||||
@ -72,7 +72,7 @@ public class BottomSheetNotificationsFragment extends BottomSheetDialogFragment
|
||||
|
||||
markRead.setOnClickListener(v1 ->
|
||||
RetrofitClient.getApiInterface(context)
|
||||
.markNotificationThreadAsRead(Authorization.get(context), notificationThread.getId(), "read")
|
||||
.markNotificationThreadAsRead(((BaseActivity) context).getAccount().getAuthorization(), notificationThread.getId(), "read")
|
||||
.enqueue((SimpleCallback<Void>) (call, voidResponse) -> {
|
||||
|
||||
// reload without any checks, because Gitea returns a 205 and Java expects this to be empty
|
||||
@ -90,7 +90,7 @@ public class BottomSheetNotificationsFragment extends BottomSheetDialogFragment
|
||||
|
||||
markUnread.setOnClickListener(v13 ->
|
||||
RetrofitClient.getApiInterface(context)
|
||||
.markNotificationThreadAsRead(Authorization.get(context), notificationThread.getId(), "unread")
|
||||
.markNotificationThreadAsRead(((BaseActivity) context).getAccount().getAuthorization(), notificationThread.getId(), "unread")
|
||||
.enqueue((SimpleCallback<Void>) (call, voidResponse) -> {
|
||||
|
||||
// reload without any checks, because Gitea returns a 205 and Java expects this to be empty
|
||||
|
@ -9,16 +9,8 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||
import org.gitnex.tea4j.models.OrgPermissions;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.BottomSheetOrganizationBinding;
|
||||
import org.mian.gitnex.structs.BottomSheetListener;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
|
@ -17,12 +17,15 @@ import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||
import com.vdurmont.emoji.EmojiParser;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.actions.ActionResult;
|
||||
import org.mian.gitnex.actions.IssueActions;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.activities.IssueDetailActivity;
|
||||
import org.mian.gitnex.activities.MainActivity;
|
||||
import org.mian.gitnex.database.api.BaseApi;
|
||||
import org.mian.gitnex.database.api.DraftsApi;
|
||||
@ -30,6 +33,7 @@ import org.mian.gitnex.databinding.BottomSheetReplyLayoutBinding;
|
||||
import org.mian.gitnex.helpers.Constants;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.contexts.IssueContext;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
@ -44,9 +48,8 @@ public class BottomSheetReplyFragment extends BottomSheetDialogFragment {
|
||||
private TinyDB tinyDB;
|
||||
private DraftsApi draftsApi;
|
||||
|
||||
private int repositoryId;
|
||||
private int currentActiveAccountId;
|
||||
private int issueNumber;
|
||||
private IssueContext issue;
|
||||
private long draftId;
|
||||
|
||||
private Runnable onInteractedListener;
|
||||
@ -60,9 +63,8 @@ public class BottomSheetReplyFragment extends BottomSheetDialogFragment {
|
||||
tinyDB = TinyDB.getInstance(context);
|
||||
draftsApi = BaseApi.getInstance(context, DraftsApi.class);
|
||||
|
||||
repositoryId = (int) tinyDB.getLong("repositoryId", 0);
|
||||
currentActiveAccountId = tinyDB.getInt("currentActiveAccountId");
|
||||
issueNumber = Integer.parseInt(tinyDB.getString("issueNumber"));
|
||||
currentActiveAccountId = ((BaseActivity) requireActivity()).getAccount().getAccount().getAccountId();
|
||||
issue = IssueContext.fromBundle(requireArguments());
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
@ -95,9 +97,9 @@ public class BottomSheetReplyFragment extends BottomSheetDialogFragment {
|
||||
draftId = Long.parseLong(arguments.getString("draftId"));
|
||||
}
|
||||
|
||||
if(!tinyDB.getString("issueTitle").isEmpty()) {
|
||||
if(issue.getIssue() != null && !issue.getIssue().getTitle().isEmpty()) {
|
||||
|
||||
toolbarTitle.setText(EmojiParser.parseToUnicode(tinyDB.getString("issueTitle")));
|
||||
toolbarTitle.setText(EmojiParser.parseToUnicode(issue.getIssue().getTitle()));
|
||||
}
|
||||
else if(arguments.getString("draftTitle") != null) {
|
||||
|
||||
@ -179,20 +181,21 @@ public class BottomSheetReplyFragment extends BottomSheetDialogFragment {
|
||||
if(mode == Mode.SEND) {
|
||||
|
||||
IssueActions
|
||||
.reply(getContext(), comment.getText().toString(), issueNumber)
|
||||
.reply(getContext(), comment.getText().toString(), issue)
|
||||
.accept((status, result) -> {
|
||||
|
||||
if(status == ActionResult.Status.SUCCESS) {
|
||||
|
||||
Toasty.success(getContext(), getString(R.string.commentSuccess));
|
||||
|
||||
if(draftId != 0 && tinyDB.getBoolean("draftsCommentsDeletionEnabled")) {
|
||||
draftsApi.deleteSingleDraft((int) draftId);
|
||||
FragmentActivity activity = requireActivity();
|
||||
if(activity instanceof IssueDetailActivity) {
|
||||
((IssueDetailActivity) activity).commentPosted = true;
|
||||
}
|
||||
|
||||
tinyDB.putBoolean("commentPosted", true);
|
||||
tinyDB.putBoolean("resumeIssues", true);
|
||||
tinyDB.putBoolean("resumePullRequests", true);
|
||||
Toasty.success(getContext(), getString(R.string.commentSuccess));
|
||||
|
||||
if(draftId != 0 && tinyDB.getBoolean("draftsCommentsDeletionEnabled", true)) {
|
||||
draftsApi.deleteSingleDraft((int) draftId);
|
||||
}
|
||||
|
||||
if(onInteractedListener != null) {
|
||||
onInteractedListener.run();
|
||||
@ -209,17 +212,20 @@ public class BottomSheetReplyFragment extends BottomSheetDialogFragment {
|
||||
} else {
|
||||
|
||||
IssueActions
|
||||
.edit(getContext(), comment.getText().toString(), arguments.getInt("commentId"))
|
||||
.edit(getContext(), comment.getText().toString(), arguments.getInt("commentId"), issue)
|
||||
.accept((status, result) -> {
|
||||
|
||||
FragmentActivity activity = requireActivity();
|
||||
if(activity instanceof IssueDetailActivity) {
|
||||
((IssueDetailActivity) activity).commentEdited = true;
|
||||
}
|
||||
|
||||
if(status == ActionResult.Status.SUCCESS) {
|
||||
|
||||
if(draftId != 0 && tinyDB.getBoolean("draftsCommentsDeletionEnabled")) {
|
||||
if(draftId != 0 && tinyDB.getBoolean("draftsCommentsDeletionEnabled", true)) {
|
||||
draftsApi.deleteSingleDraft((int) draftId);
|
||||
}
|
||||
|
||||
tinyDB.putBoolean("commentEdited", true);
|
||||
|
||||
if(onInteractedListener != null) {
|
||||
onInteractedListener.run();
|
||||
}
|
||||
@ -263,11 +269,11 @@ public class BottomSheetReplyFragment extends BottomSheetDialogFragment {
|
||||
else {
|
||||
|
||||
String draftType;
|
||||
if(tinyDB.getString("issueType").equalsIgnoreCase("Issue")) {
|
||||
if(issue.getIssueType().equalsIgnoreCase("Issue")) {
|
||||
|
||||
draftType = Constants.draftTypeIssue;
|
||||
}
|
||||
else if(tinyDB.getString("issueType").equalsIgnoreCase("Pull")) {
|
||||
else if(issue.getIssueType().equalsIgnoreCase("Pull")) {
|
||||
|
||||
draftType = Constants.draftTypePull;
|
||||
}
|
||||
@ -278,7 +284,7 @@ public class BottomSheetReplyFragment extends BottomSheetDialogFragment {
|
||||
|
||||
if(draftId == 0) {
|
||||
|
||||
draftId = draftsApi.insertDraft(repositoryId, currentActiveAccountId, issueNumber, text, draftType, "TODO", tinyDB.getString("issueType"));
|
||||
draftId = draftsApi.insertDraft(issue.getRepository().getRepositoryId(), currentActiveAccountId, issue.getIssueIndex(), text, draftType, "TODO", issue.getIssueType());
|
||||
}
|
||||
else {
|
||||
|
||||
@ -290,9 +296,10 @@ public class BottomSheetReplyFragment extends BottomSheetDialogFragment {
|
||||
}
|
||||
}
|
||||
|
||||
public static BottomSheetReplyFragment newInstance(Bundle bundle) {
|
||||
public static BottomSheetReplyFragment newInstance(Bundle bundle, IssueContext issue) {
|
||||
|
||||
BottomSheetReplyFragment fragment = new BottomSheetReplyFragment();
|
||||
bundle.putSerializable(IssueContext.INTENT_EXTRA, issue);
|
||||
fragment.setArguments(bundle);
|
||||
|
||||
return fragment;
|
||||
|
@ -11,7 +11,7 @@ import androidx.annotation.Nullable;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||
import org.mian.gitnex.actions.RepositoryActions;
|
||||
import org.mian.gitnex.databinding.BottomSheetRepoBinding;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import org.mian.gitnex.structs.BottomSheetListener;
|
||||
|
||||
/**
|
||||
@ -21,16 +21,19 @@ import org.mian.gitnex.structs.BottomSheetListener;
|
||||
public class BottomSheetRepoFragment extends BottomSheetDialogFragment {
|
||||
|
||||
private BottomSheetListener bmListener;
|
||||
private final RepositoryContext repository;
|
||||
|
||||
@Nullable
|
||||
public BottomSheetRepoFragment(RepositoryContext repository) {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
|
||||
BottomSheetRepoBinding bottomSheetRepoBinding = BottomSheetRepoBinding.inflate(inflater, container, false);
|
||||
|
||||
final TinyDB tinyDb = TinyDB.getInstance(getContext());
|
||||
|
||||
TextView createLabel = bottomSheetRepoBinding.createLabel;
|
||||
TextView createLabel = bottomSheetRepoBinding.createLabel;
|
||||
TextView createIssue = bottomSheetRepoBinding.createNewIssue;
|
||||
TextView createMilestone = bottomSheetRepoBinding.createNewMilestone;
|
||||
TextView addCollaborator = bottomSheetRepoBinding.addCollaborator;
|
||||
@ -47,7 +50,7 @@ public class BottomSheetRepoFragment extends BottomSheetDialogFragment {
|
||||
TextView repoSettings = bottomSheetRepoBinding.repoSettings;
|
||||
TextView createPullRequest = bottomSheetRepoBinding.createPullRequest;
|
||||
|
||||
boolean canPush = tinyDb.getBoolean("canPush");
|
||||
boolean canPush = repository.getPermissions().canPush();
|
||||
if(!canPush) {
|
||||
createMilestone.setVisibility(View.GONE);
|
||||
createLabel.setVisibility(View.GONE);
|
||||
@ -55,7 +58,7 @@ public class BottomSheetRepoFragment extends BottomSheetDialogFragment {
|
||||
newFile.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
boolean archived = tinyDb.getBoolean("isArchived");
|
||||
boolean archived = repository.getRepository().isArchived();
|
||||
if(archived) {
|
||||
createIssue.setVisibility(View.GONE);
|
||||
createPullRequest.setVisibility(View.GONE);
|
||||
@ -72,7 +75,7 @@ public class BottomSheetRepoFragment extends BottomSheetDialogFragment {
|
||||
dismiss();
|
||||
});
|
||||
|
||||
if(tinyDb.getBoolean("hasIssues") && !archived) {
|
||||
if(repository.getRepository().getHas_issues() && !archived) {
|
||||
|
||||
createIssue.setVisibility(View.VISIBLE);
|
||||
createIssue.setOnClickListener(v12 -> {
|
||||
@ -86,7 +89,7 @@ public class BottomSheetRepoFragment extends BottomSheetDialogFragment {
|
||||
createIssue.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if(tinyDb.getBoolean("hasPullRequests") && !archived) {
|
||||
if(repository.getRepository().isHas_pull_requests() && !archived) {
|
||||
|
||||
createPullRequest.setVisibility(View.VISIBLE);
|
||||
createPullRequest.setOnClickListener(vPr -> {
|
||||
@ -106,7 +109,7 @@ public class BottomSheetRepoFragment extends BottomSheetDialogFragment {
|
||||
dismiss();
|
||||
});
|
||||
|
||||
if (tinyDb.getBoolean("isRepoAdmin")) {
|
||||
if (repository.getPermissions().isAdmin()) {
|
||||
|
||||
repoSettings.setOnClickListener(repoSettingsView -> {
|
||||
|
||||
@ -157,50 +160,48 @@ public class BottomSheetRepoFragment extends BottomSheetDialogFragment {
|
||||
dismiss();
|
||||
});
|
||||
|
||||
if(tinyDb.getInt("repositoryStarStatus") == 204) { // star a repo
|
||||
if(repository.isStarred()) {
|
||||
|
||||
starRepository.setVisibility(View.GONE);
|
||||
unStarRepository.setOnClickListener(v18 -> {
|
||||
|
||||
RepositoryActions.unStarRepository(getContext());
|
||||
tinyDb.putInt("repositoryStarStatus", 404);
|
||||
RepositoryActions.unStarRepository(getContext(), repository);
|
||||
bmListener.onButtonClicked("unstar");
|
||||
dismiss();
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
else if(tinyDb.getInt("repositoryStarStatus") == 404) {
|
||||
} else {
|
||||
|
||||
unStarRepository.setVisibility(View.GONE);
|
||||
starRepository.setOnClickListener(v19 -> {
|
||||
|
||||
RepositoryActions.starRepository(getContext());
|
||||
tinyDb.putInt("repositoryStarStatus", 204);
|
||||
RepositoryActions.starRepository(getContext(), repository);
|
||||
bmListener.onButtonClicked("star");
|
||||
dismiss();
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
if(tinyDb.getBoolean("repositoryWatchStatus")) { // watch a repo
|
||||
if(repository.isWatched()) {
|
||||
|
||||
watchRepository.setVisibility(View.GONE);
|
||||
unWatchRepository.setOnClickListener(v110 -> {
|
||||
|
||||
RepositoryActions.unWatchRepository(getContext());
|
||||
tinyDb.putBoolean("repositoryWatchStatus", false);
|
||||
RepositoryActions.unWatchRepository(getContext(), repository);
|
||||
bmListener.onButtonClicked("unwatch");
|
||||
dismiss();
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
unWatchRepository.setVisibility(View.GONE);
|
||||
watchRepository.setOnClickListener(v111 -> {
|
||||
|
||||
RepositoryActions.watchRepository(getContext());
|
||||
tinyDb.putBoolean("repositoryWatchStatus", true);
|
||||
RepositoryActions.watchRepository(getContext(), repository);
|
||||
bmListener.onButtonClicked("watch");
|
||||
dismiss();
|
||||
|
||||
});
|
||||
@ -218,7 +219,7 @@ public class BottomSheetRepoFragment extends BottomSheetDialogFragment {
|
||||
bmListener = (BottomSheetListener) context;
|
||||
}
|
||||
catch (ClassCastException e) {
|
||||
throw new ClassCastException(context.toString() + " must implement BottomSheetListener");
|
||||
throw new ClassCastException(context + " must implement BottomSheetListener");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,13 +17,14 @@ import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.actions.IssueActions;
|
||||
import org.mian.gitnex.actions.PullRequestActions;
|
||||
import org.mian.gitnex.activities.DiffActivity;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.activities.EditIssueActivity;
|
||||
import org.mian.gitnex.activities.IssueDetailActivity;
|
||||
import org.mian.gitnex.activities.MergePullRequestActivity;
|
||||
import org.mian.gitnex.databinding.BottomSheetSingleIssueBinding;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import org.mian.gitnex.helpers.contexts.IssueContext;
|
||||
import org.mian.gitnex.structs.BottomSheetListener;
|
||||
import org.mian.gitnex.views.ReactionSpinner;
|
||||
import java.util.Objects;
|
||||
@ -35,9 +36,11 @@ import java.util.Objects;
|
||||
public class BottomSheetSingleIssueFragment extends BottomSheetDialogFragment {
|
||||
|
||||
private BottomSheetListener bmListener;
|
||||
private final IssueContext issue;
|
||||
private final String issueCreator;
|
||||
|
||||
public BottomSheetSingleIssueFragment(String username) {
|
||||
public BottomSheetSingleIssueFragment(IssueContext issue, String username) {
|
||||
this.issue = issue;
|
||||
issueCreator = username;
|
||||
}
|
||||
|
||||
@ -48,21 +51,16 @@ public class BottomSheetSingleIssueFragment extends BottomSheetDialogFragment {
|
||||
BottomSheetSingleIssueBinding binding = BottomSheetSingleIssueBinding.inflate(inflater, container, false);
|
||||
|
||||
final Context ctx = getContext();
|
||||
final TinyDB tinyDB = TinyDB.getInstance(ctx);
|
||||
|
||||
boolean userIsCreator = issueCreator.equals(tinyDB.getString("loginUid"));
|
||||
boolean isRepoAdmin = tinyDB.getBoolean("isRepoAdmin");
|
||||
boolean canPush = tinyDB.getBoolean("canPush");
|
||||
boolean archived = tinyDB.getBoolean("isArchived");
|
||||
|
||||
String repoFullName = tinyDB.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
boolean userIsCreator = issueCreator.equals(((BaseActivity) requireActivity()).getAccount().getAccount().getUserName());
|
||||
boolean isRepoAdmin = issue.getRepository().getPermissions().isAdmin();
|
||||
boolean canPush = issue.getRepository().getPermissions().canPush();
|
||||
boolean archived = issue.getRepository().getRepository().isArchived();
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
|
||||
bundle.putString("repoOwner", parts[0]);
|
||||
bundle.putString("repoName", parts[1]);
|
||||
bundle.putInt("issueId", Integer.parseInt(tinyDB.getString("issueNumber")));
|
||||
bundle.putString("repoOwner", issue.getRepository().getOwner());
|
||||
bundle.putString("repoName", issue.getRepository().getName());
|
||||
bundle.putInt("issueId", issue.getIssueIndex());
|
||||
|
||||
TextView loadReactions = new TextView(ctx);
|
||||
loadReactions.setText(Objects.requireNonNull(ctx).getString(R.string.genericWaitFor));
|
||||
@ -73,7 +71,7 @@ public class BottomSheetSingleIssueFragment extends BottomSheetDialogFragment {
|
||||
ReactionSpinner reactionSpinner = new ReactionSpinner(ctx, bundle);
|
||||
reactionSpinner.setOnInteractedListener(() -> {
|
||||
|
||||
tinyDB.putBoolean("singleIssueUpdate", true);
|
||||
((IssueDetailActivity) requireActivity()).singleIssueUpdate = true;
|
||||
|
||||
bmListener.onButtonClicked("onResume");
|
||||
dismiss();
|
||||
@ -84,14 +82,14 @@ public class BottomSheetSingleIssueFragment extends BottomSheetDialogFragment {
|
||||
binding.commentReactionButtons.addView(reactionSpinner);
|
||||
});
|
||||
|
||||
if(tinyDB.getString("issueType").equalsIgnoreCase("Pull")) {
|
||||
if(issue.getIssueType().equalsIgnoreCase("Pull")) {
|
||||
|
||||
binding.editIssue.setText(R.string.editPrText);
|
||||
binding.copyIssueUrl.setText(R.string.copyPrUrlText);
|
||||
binding.shareIssue.setText(R.string.sharePr);
|
||||
|
||||
boolean canPushPullSource = tinyDB.getBoolean("canPushPullSource");
|
||||
if(tinyDB.getBoolean("prMerged") || tinyDB.getString("repoPrState").equals("closed")) {
|
||||
boolean canPushPullSource = issue.getPullRequest().getHead().getRepo().getPermissions().isPush();
|
||||
if(issue.getPullRequest().isMerged() || issue.getIssue().getState().equals("closed")) {
|
||||
binding.updatePullRequest.setVisibility(View.GONE);
|
||||
binding.mergePullRequest.setVisibility(View.GONE);
|
||||
if(canPushPullSource) {
|
||||
@ -114,7 +112,7 @@ public class BottomSheetSingleIssueFragment extends BottomSheetDialogFragment {
|
||||
if(!userIsCreator && !canPush) {
|
||||
binding.editIssue.setVisibility(View.GONE);
|
||||
}
|
||||
if(canPush && !tinyDB.getString("prMergeable").equals("false")) {
|
||||
if(canPush && !issue.getPullRequest().isMergeable()) {
|
||||
binding.mergePullRequest.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
@ -123,18 +121,8 @@ public class BottomSheetSingleIssueFragment extends BottomSheetDialogFragment {
|
||||
binding.deletePrHeadBranch.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if(new Version(tinyDB.getString("giteaVersion")).higherOrEqual("1.13.0")) {
|
||||
binding.openFilesDiff.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else if(tinyDB.getString("repoType").equals("public")) {
|
||||
binding.openFilesDiff.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
binding.openFilesDiff.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
binding.openFilesDiff.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
if(!userIsCreator && !canPush) {
|
||||
binding.editIssue.setVisibility(View.GONE);
|
||||
}
|
||||
@ -144,35 +132,35 @@ public class BottomSheetSingleIssueFragment extends BottomSheetDialogFragment {
|
||||
}
|
||||
|
||||
binding.updatePullRequest.setOnClickListener(v -> {
|
||||
if(new Version(tinyDB.getString("giteaVersion")).higherOrEqual("1.16.0")) {
|
||||
AlertDialogs.selectPullUpdateStrategy(requireContext(), parts[0], parts[1], tinyDB.getString("issueNumber"));
|
||||
}
|
||||
else {
|
||||
PullRequestActions.updatePr(requireContext(), parts[0], parts[1], tinyDB.getString("issueNumber"), null);
|
||||
if(((BaseActivity) requireActivity()).getAccount().requiresVersion("1.16.0")) {
|
||||
AlertDialogs.selectPullUpdateStrategy(requireContext(), issue.getRepository().getOwner(), issue.getRepository().getName(),
|
||||
String.valueOf(issue.getIssueIndex()));
|
||||
} else {
|
||||
PullRequestActions.updatePr(requireContext(), issue.getRepository().getOwner(), issue.getRepository().getName(),
|
||||
String.valueOf(issue.getIssueIndex()), null);
|
||||
}
|
||||
dismiss();
|
||||
});
|
||||
|
||||
binding.mergePullRequest.setOnClickListener(v13 -> {
|
||||
startActivity(new Intent(ctx, MergePullRequestActivity.class));
|
||||
dismiss();
|
||||
});
|
||||
|
||||
binding.openFilesDiff.setOnClickListener(v14 -> {
|
||||
startActivity(new Intent(ctx, DiffActivity.class));
|
||||
startActivity(issue.getIntent(ctx, MergePullRequestActivity.class));
|
||||
dismiss();
|
||||
});
|
||||
|
||||
binding.deletePrHeadBranch.setOnClickListener(v -> {
|
||||
|
||||
PullRequestActions.deleteHeadBranch(ctx, parts[0], parts[1], tinyDB.getString("prHeadBranch"), true);
|
||||
PullRequestActions.deleteHeadBranch(ctx, issue.getRepository().getOwner(), issue.getRepository().getName(), issue.getPullRequest().getHead().getRef(), true);
|
||||
dismiss();
|
||||
});
|
||||
|
||||
|
||||
binding.openFilesDiff.setOnClickListener(v14 -> {
|
||||
startActivity(issue.getIntent(ctx, DiffActivity.class));
|
||||
dismiss();
|
||||
});
|
||||
|
||||
binding.editIssue.setOnClickListener(v15 -> {
|
||||
startActivity(new Intent(ctx, EditIssueActivity.class));
|
||||
((IssueDetailActivity) requireActivity()).editIssueLauncher.launch(issue.getIntent(ctx, EditIssueActivity.class));
|
||||
dismiss();
|
||||
});
|
||||
|
||||
@ -190,9 +178,9 @@ public class BottomSheetSingleIssueFragment extends BottomSheetDialogFragment {
|
||||
|
||||
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
|
||||
sharingIntent.setType("text/plain");
|
||||
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, getResources().getString(R.string.hash) + tinyDB.getString("issueNumber") + " " + tinyDB.getString("issueTitle"));
|
||||
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, tinyDB.getString("singleIssueHtmlUrl"));
|
||||
startActivity(Intent.createChooser(sharingIntent, getResources().getString(R.string.hash) + tinyDB.getString("issueNumber") + " " + tinyDB.getString("issueTitle")));
|
||||
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, getResources().getString(R.string.hash) + issue.getIssueIndex() + " " + issue.getIssue().getTitle());
|
||||
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, issue.getIssue().getHtml_url());
|
||||
startActivity(Intent.createChooser(sharingIntent, getResources().getString(R.string.hash) + issue.getIssueIndex() + " " + issue.getIssue().getTitle()));
|
||||
|
||||
dismiss();
|
||||
});
|
||||
@ -201,7 +189,7 @@ public class BottomSheetSingleIssueFragment extends BottomSheetDialogFragment {
|
||||
|
||||
// copy to clipboard
|
||||
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(ctx).getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipData clip = ClipData.newPlainText("issueUrl", tinyDB.getString("singleIssueHtmlUrl"));
|
||||
ClipData clip = ClipData.newPlainText("issueUrl", issue.getIssue().getHtml_url());
|
||||
assert clipboard != null;
|
||||
clipboard.setPrimaryClip(clip);
|
||||
|
||||
@ -210,22 +198,22 @@ public class BottomSheetSingleIssueFragment extends BottomSheetDialogFragment {
|
||||
dismiss();
|
||||
});
|
||||
|
||||
if(tinyDB.getString("issueState").equals("open")) { // close issue
|
||||
if(issue.getIssue().getState().equals("open")) { // close issue
|
||||
if(!userIsCreator && !canPush) {
|
||||
binding.closeIssue.setVisibility(View.GONE);
|
||||
binding.dividerCloseReopenIssue.setVisibility(View.GONE);
|
||||
}
|
||||
else if(tinyDB.getString("issueType").equalsIgnoreCase("Pull")) {
|
||||
else if(issue.getIssueType().equalsIgnoreCase("Pull")) {
|
||||
binding.closeIssue.setText(R.string.closePr);
|
||||
}
|
||||
binding.closeIssue.setOnClickListener(closeSingleIssue -> {
|
||||
IssueActions.closeReopenIssue(ctx, Integer.parseInt(tinyDB.getString("issueNumber")), "closed");
|
||||
IssueActions.closeReopenIssue(ctx, "closed", issue);
|
||||
dismiss();
|
||||
});
|
||||
}
|
||||
else if(tinyDB.getString("issueState").equals("closed")) {
|
||||
else if(issue.getIssue().getState().equals("closed")) {
|
||||
if(userIsCreator || canPush) {
|
||||
if(tinyDB.getString("issueType").equalsIgnoreCase("Pull")) {
|
||||
if(issue.getIssueType().equalsIgnoreCase("Pull")) {
|
||||
binding.closeIssue.setText(R.string.reopenPr);
|
||||
}
|
||||
else {
|
||||
@ -237,28 +225,26 @@ public class BottomSheetSingleIssueFragment extends BottomSheetDialogFragment {
|
||||
binding.dividerCloseReopenIssue.setVisibility(View.GONE);
|
||||
}
|
||||
binding.closeIssue.setOnClickListener(closeSingleIssue -> {
|
||||
IssueActions.closeReopenIssue(ctx, Integer.parseInt(tinyDB.getString("issueNumber")), "open");
|
||||
IssueActions.closeReopenIssue(ctx, "open", issue);
|
||||
dismiss();
|
||||
});
|
||||
}
|
||||
|
||||
binding.subscribeIssue.setOnClickListener(subscribeToIssue -> {
|
||||
|
||||
IssueActions.subscribe(ctx);
|
||||
IssueActions.subscribe(ctx, issue);
|
||||
issue.setSubscribed(true);
|
||||
dismiss();
|
||||
});
|
||||
|
||||
binding.unsubscribeIssue.setOnClickListener(unsubscribeToIssue -> {
|
||||
|
||||
IssueActions.unsubscribe(ctx);
|
||||
IssueActions.unsubscribe(ctx, issue);
|
||||
issue.setSubscribed(false);
|
||||
dismiss();
|
||||
});
|
||||
|
||||
if(new Version(tinyDB.getString("giteaVersion")).less("1.12.0")) {
|
||||
binding.subscribeIssue.setVisibility(View.GONE);
|
||||
binding.unsubscribeIssue.setVisibility(View.GONE);
|
||||
}
|
||||
else if(tinyDB.getBoolean("issueSubscribed")) {
|
||||
if(issue.isSubscribed()) {
|
||||
binding.subscribeIssue.setVisibility(View.GONE);
|
||||
binding.unsubscribeIssue.setVisibility(View.VISIBLE);
|
||||
}
|
||||
@ -293,7 +279,7 @@ public class BottomSheetSingleIssueFragment extends BottomSheetDialogFragment {
|
||||
}
|
||||
catch(ClassCastException e) {
|
||||
|
||||
throw new ClassCastException(context.toString() + " must implement BottomSheetListener");
|
||||
throw new ClassCastException(context + " must implement BottomSheetListener");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.mian.gitnex.fragments;
|
||||
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@ -14,9 +13,10 @@ import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import org.gitnex.tea4j.models.Collaborators;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.adapters.CollaboratorsAdapter;
|
||||
import org.mian.gitnex.databinding.FragmentCollaboratorsBinding;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import org.mian.gitnex.viewmodels.CollaboratorsViewModel;
|
||||
import java.util.List;
|
||||
|
||||
@ -26,35 +26,28 @@ import java.util.List;
|
||||
|
||||
public class CollaboratorsFragment extends Fragment {
|
||||
|
||||
public static boolean refreshCollaborators = false;
|
||||
|
||||
private ProgressBar mProgressBar;
|
||||
private CollaboratorsAdapter adapter;
|
||||
private GridView mGridView;
|
||||
private TextView noDataCollaborators;
|
||||
private static String repoNameF = "param2";
|
||||
private static String repoOwnerF = "param1";
|
||||
|
||||
private String repoName;
|
||||
private String repoOwner;
|
||||
private RepositoryContext repository;
|
||||
|
||||
public CollaboratorsFragment() {
|
||||
}
|
||||
|
||||
public static CollaboratorsFragment newInstance(String param1, String param2) {
|
||||
public static CollaboratorsFragment newInstance(RepositoryContext repository) {
|
||||
CollaboratorsFragment fragment = new CollaboratorsFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putString(repoOwnerF, param1);
|
||||
args.putString(repoNameF, param2);
|
||||
fragment.setArguments(args);
|
||||
fragment.setArguments(repository.getBundle());
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (getArguments() != null) {
|
||||
repoName = getArguments().getString(repoNameF);
|
||||
repoOwner = getArguments().getString(repoOwnerF);
|
||||
}
|
||||
repository = RepositoryContext.fromBundle(requireArguments());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -67,7 +60,7 @@ public class CollaboratorsFragment extends Fragment {
|
||||
mProgressBar = fragmentCollaboratorsBinding.progressBar;
|
||||
mGridView = fragmentCollaboratorsBinding.gridView;
|
||||
|
||||
fetchDataAsync(Authorization.get(getContext()), repoOwner, repoName);
|
||||
fetchDataAsync(((BaseActivity) requireActivity()).getAccount().getAuthorization(), repository.getOwner(), repository.getName());
|
||||
return fragmentCollaboratorsBinding.getRoot();
|
||||
|
||||
}
|
||||
@ -95,4 +88,14 @@ public class CollaboratorsFragment extends Fragment {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
|
||||
super.onResume();
|
||||
if(refreshCollaborators) {
|
||||
fetchDataAsync(((BaseActivity) requireActivity()).getAccount().getAuthorization(), repository.getOwner(), repository.getName());
|
||||
refreshCollaborators = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ import com.vdurmont.emoji.EmojiParser;
|
||||
import org.gitnex.tea4j.models.Commits;
|
||||
import org.gitnex.tea4j.models.FileDiffView;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.activities.ProfileActivity;
|
||||
import org.mian.gitnex.adapters.DiffFilesAdapter;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
@ -23,6 +24,7 @@ import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.CustomCommitHeaderBinding;
|
||||
import org.mian.gitnex.databinding.FragmentCommitDetailsBinding;
|
||||
import org.mian.gitnex.helpers.*;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@ -56,10 +58,9 @@ public class CommitDetailFragment extends Fragment {
|
||||
|
||||
binding = FragmentCommitDetailsBinding.inflate(getLayoutInflater(), container, false);
|
||||
|
||||
String repoFullName = TinyDB.getInstance(requireContext()).getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
repoOwner = parts[0];
|
||||
repoName = parts[1];
|
||||
RepositoryContext repository = RepositoryContext.fromIntent(requireActivity().getIntent());
|
||||
repoOwner = repository.getOwner();
|
||||
repoName = repository.getName();
|
||||
sha = requireActivity().getIntent().getStringExtra("sha");
|
||||
binding.toolbarTitle.setText(sha.substring(0, Math.min(sha.length(), 10)));
|
||||
|
||||
@ -78,8 +79,8 @@ public class CommitDetailFragment extends Fragment {
|
||||
|
||||
private void getDiff() {
|
||||
Call<ResponseBody> call = new Version(TinyDB.getInstance(requireContext()).getString("giteaVersion")).higherOrEqual("1.16.0") ?
|
||||
RetrofitClient.getApiInterface(requireContext()).getCommitDiff(Authorization.get(requireContext()), repoOwner, repoName, sha) :
|
||||
RetrofitClient.getWebInterface(requireContext()).getCommitDiff(Authorization.getWeb(requireContext()), repoOwner, repoName, sha);
|
||||
RetrofitClient.getApiInterface(requireContext()).getCommitDiff(((BaseActivity) requireActivity()).getAccount().getAuthorization(), repoOwner, repoName, sha) :
|
||||
RetrofitClient.getWebInterface(requireContext()).getCommitDiff(((BaseActivity) requireActivity()).getAccount().getWebAuthorization(), repoOwner, repoName, sha);
|
||||
|
||||
call.enqueue(new Callback<ResponseBody>() {
|
||||
|
||||
@ -130,7 +131,7 @@ public class CommitDetailFragment extends Fragment {
|
||||
|
||||
private void getCommit() {
|
||||
|
||||
RetrofitClient.getApiInterface(requireContext()).getCommit(Authorization.get(requireContext()), repoOwner, repoName, sha)
|
||||
RetrofitClient.getApiInterface(requireContext()).getCommit(((BaseActivity) requireActivity()).getAccount().getAuthorization(), repoOwner, repoName, sha)
|
||||
.enqueue(new Callback<Commits>() {
|
||||
|
||||
@Override
|
||||
|
@ -6,19 +6,15 @@ import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import org.gitnex.tea4j.models.FileDiffView;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.adapters.DiffFilesAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.FragmentDiffFilesBinding;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.ParseDiff;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import org.mian.gitnex.helpers.*;
|
||||
import org.mian.gitnex.helpers.contexts.IssueContext;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import okhttp3.ResponseBody;
|
||||
@ -33,7 +29,6 @@ public class DiffFilesFragment extends Fragment {
|
||||
|
||||
private FragmentDiffFilesBinding binding;
|
||||
private Context ctx;
|
||||
private TinyDB tinyDB;
|
||||
|
||||
public DiffFilesFragment() {}
|
||||
|
||||
@ -46,14 +41,7 @@ public class DiffFilesFragment extends Fragment {
|
||||
|
||||
binding = FragmentDiffFilesBinding.inflate(inflater, container, false);
|
||||
ctx = requireContext();
|
||||
tinyDB = TinyDB.getInstance(ctx);
|
||||
|
||||
String repoFullName = tinyDB.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
|
||||
String pullIndex = tinyDB.getString("issueNumber");
|
||||
IssueContext issue = IssueContext.fromIntent(requireActivity().getIntent());
|
||||
|
||||
binding.progressBar.setVisibility(View.VISIBLE);
|
||||
binding.toolbarTitle.setText(R.string.processingText);
|
||||
@ -61,10 +49,10 @@ public class DiffFilesFragment extends Fragment {
|
||||
|
||||
binding.diffFiles.setOnItemClickListener((parent, view, position, id) -> requireActivity().getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
.replace(R.id.fragment_container, DiffFragment.newInstance((FileDiffView) parent.getItemAtPosition(position), "pull"))
|
||||
.replace(R.id.fragment_container, DiffFragment.newInstance((FileDiffView) parent.getItemAtPosition(position), issue))
|
||||
.commit());
|
||||
|
||||
getPullDiffFiles(repoOwner, repoName, pullIndex);
|
||||
getPullDiffFiles(issue.getRepository().getOwner(), issue.getRepository().getName(), String.valueOf(issue.getIssueIndex()));
|
||||
|
||||
return binding.getRoot();
|
||||
|
||||
@ -74,14 +62,18 @@ public class DiffFilesFragment extends Fragment {
|
||||
|
||||
Thread thread = new Thread(() -> {
|
||||
|
||||
Call<ResponseBody> call = new Version(tinyDB.getString("giteaVersion")).higherOrEqual("1.13.0") ?
|
||||
RetrofitClient.getApiInterface(ctx).getPullDiffContent(Authorization.get(ctx), owner, repo, pullIndex) :
|
||||
RetrofitClient.getWebInterface(ctx).getPullDiffContent(Authorization.getWeb(ctx), owner, repo, pullIndex);
|
||||
Call<ResponseBody> call = ((BaseActivity) ctx).getAccount().requiresVersion("1.13.0") ?
|
||||
RetrofitClient.getApiInterface(ctx).getPullDiffContent(((BaseActivity) requireActivity()).getAccount().getAuthorization(), owner, repo, pullIndex) :
|
||||
RetrofitClient.getWebInterface(ctx).getPullDiffContent(((BaseActivity) requireActivity()).getAccount().getWebAuthorization(), owner, repo, pullIndex);
|
||||
|
||||
try {
|
||||
|
||||
Response<ResponseBody> response = call.execute();
|
||||
assert response.body() != null;
|
||||
if(response.body() == null) {
|
||||
Toasty.error(requireContext(), getString(R.string.genericError));
|
||||
requireActivity().finish();
|
||||
return;
|
||||
}
|
||||
|
||||
switch(response.code()) {
|
||||
|
||||
|
@ -11,6 +11,7 @@ import org.gitnex.tea4j.models.FileDiffView;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.DiffAdapter;
|
||||
import org.mian.gitnex.databinding.FragmentDiffBinding;
|
||||
import org.mian.gitnex.helpers.contexts.IssueContext;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
@ -24,6 +25,7 @@ public class DiffFragment extends Fragment {
|
||||
private Context ctx;
|
||||
|
||||
private FileDiffView fileDiffView;
|
||||
private IssueContext issue;
|
||||
private String type;
|
||||
|
||||
public DiffFragment() {}
|
||||
@ -32,6 +34,20 @@ public class DiffFragment extends Fragment {
|
||||
this.fileDiffView = fileDiffView;
|
||||
}
|
||||
|
||||
public void setIssue(IssueContext issue) {
|
||||
|
||||
this.issue = issue;
|
||||
}
|
||||
|
||||
public static DiffFragment newInstance(FileDiffView fileDiffView, IssueContext issue) {
|
||||
|
||||
DiffFragment fragment = new DiffFragment();
|
||||
fragment.setFileDiffView(fileDiffView);
|
||||
fragment.setIssue(issue);
|
||||
return fragment;
|
||||
|
||||
}
|
||||
|
||||
public static DiffFragment newInstance(FileDiffView fileDiffView, String type) {
|
||||
|
||||
DiffFragment fragment = new DiffFragment();
|
||||
@ -55,7 +71,7 @@ public class DiffFragment extends Fragment {
|
||||
|
||||
binding.toolbarTitle.setText(fileDiffView.getFileName());
|
||||
binding.diff.setDivider(null);
|
||||
binding.diff.setAdapter(new DiffAdapter(ctx, getChildFragmentManager(), Arrays.asList(fileDiffView.toString().split("\\R")), type));
|
||||
binding.diff.setAdapter(new DiffAdapter(ctx, getChildFragmentManager(), Arrays.asList(fileDiffView.toString().split("\\R")), issue, type));
|
||||
|
||||
return binding.getRoot();
|
||||
|
||||
|
@ -16,10 +16,10 @@ import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import org.gitnex.tea4j.models.Issues;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.adapters.ExploreIssuesAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.FragmentSearchIssuesBinding;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.Constants;
|
||||
import org.mian.gitnex.helpers.SnackBar;
|
||||
import java.util.ArrayList;
|
||||
@ -100,7 +100,7 @@ public class ExploreIssuesFragment extends Fragment {
|
||||
private void loadInitial(String searchKeyword, int resultLimit) {
|
||||
|
||||
Call<List<Issues>> call = RetrofitClient
|
||||
.getApiInterface(context).queryIssues(Authorization.get(getContext()), searchKeyword, "issues", "open", resultLimit, 1);
|
||||
.getApiInterface(context).queryIssues(((BaseActivity) requireActivity()).getAccount().getAuthorization(), searchKeyword, "issues", "open", resultLimit, 1);
|
||||
call.enqueue(new Callback<List<Issues>>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Issues>> call, @NonNull Response<List<Issues>> response) {
|
||||
@ -138,7 +138,7 @@ public class ExploreIssuesFragment extends Fragment {
|
||||
|
||||
viewBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
Call<List<Issues>> call = RetrofitClient.getApiInterface(context)
|
||||
.queryIssues(Authorization.get(getContext()), searchKeyword, "issues", "open", resultLimit, page);
|
||||
.queryIssues(((BaseActivity) requireActivity()).getAccount().getAuthorization(), searchKeyword, "issues", "open", resultLimit, page);
|
||||
call.enqueue(new Callback<List<Issues>>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Issues>> call, @NonNull Response<List<Issues>> response) {
|
||||
|
@ -15,13 +15,12 @@ import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import org.gitnex.tea4j.models.Organization;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.adapters.ExplorePublicOrganizationsAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.FragmentOrganizationsBinding;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.Constants;
|
||||
import org.mian.gitnex.helpers.SnackBar;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
@ -49,10 +48,6 @@ public class ExplorePublicOrganizationsFragment extends Fragment {
|
||||
fragmentPublicOrgBinding = FragmentOrganizationsBinding.inflate(inflater, container, false);
|
||||
context = getContext();
|
||||
|
||||
TinyDB tinyDb = TinyDB.getInstance(getContext());
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
resultLimit = Constants.getCurrentResultLimit(context);
|
||||
|
||||
fragmentPublicOrgBinding.addNewOrganization.setVisibility(View.GONE);
|
||||
@ -60,7 +55,7 @@ public class ExplorePublicOrganizationsFragment extends Fragment {
|
||||
|
||||
fragmentPublicOrgBinding.pullToRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
fragmentPublicOrgBinding.pullToRefresh.setRefreshing(false);
|
||||
loadInitial(instanceToken, resultLimit);
|
||||
loadInitial(((BaseActivity) requireActivity()).getAccount().getAuthorization(), resultLimit);
|
||||
adapter.notifyDataChanged();
|
||||
}, 200));
|
||||
|
||||
@ -68,7 +63,7 @@ public class ExplorePublicOrganizationsFragment extends Fragment {
|
||||
adapter.setLoadMoreListener(() -> fragmentPublicOrgBinding.recyclerView.post(() -> {
|
||||
if(organizationsList.size() == resultLimit || pageSize == resultLimit) {
|
||||
int page = (organizationsList.size() + resultLimit) / resultLimit;
|
||||
loadMore(Authorization.get(getContext()), page, resultLimit);
|
||||
loadMore(((BaseActivity) requireActivity()).getAccount().getAuthorization(), page, resultLimit);
|
||||
}
|
||||
}));
|
||||
|
||||
@ -78,7 +73,7 @@ public class ExplorePublicOrganizationsFragment extends Fragment {
|
||||
fragmentPublicOrgBinding.recyclerView.setLayoutManager(new LinearLayoutManager(context));
|
||||
fragmentPublicOrgBinding.recyclerView.setAdapter(adapter);
|
||||
|
||||
loadInitial(Authorization.get(getContext()), resultLimit);
|
||||
loadInitial(((BaseActivity) requireActivity()).getAccount().getAuthorization(), resultLimit);
|
||||
|
||||
return fragmentPublicOrgBinding.getRoot();
|
||||
}
|
||||
|
@ -24,14 +24,13 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import org.gitnex.tea4j.models.ExploreRepositories;
|
||||
import org.gitnex.tea4j.models.UserRepositories;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.adapters.ExploreRepositoriesAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.CustomExploreRepositoriesDialogBinding;
|
||||
import org.mian.gitnex.databinding.FragmentExploreRepoBinding;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.Constants;
|
||||
import org.mian.gitnex.helpers.SnackBar;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@ -49,7 +48,6 @@ public class ExploreRepositoriesFragment extends Fragment {
|
||||
|
||||
private FragmentExploreRepoBinding viewBinding;
|
||||
private Context context;
|
||||
private TinyDB tinyDb;
|
||||
|
||||
private int pageSize;
|
||||
private final boolean repoTypeInclude = true;
|
||||
@ -63,6 +61,11 @@ public class ExploreRepositoriesFragment extends Fragment {
|
||||
private Dialog dialogFilterOptions;
|
||||
private CustomExploreRepositoriesDialogBinding filterBinding;
|
||||
|
||||
private boolean includeTopic = false;
|
||||
private boolean includeDescription = false;
|
||||
private boolean includeTemplate = false;
|
||||
private boolean onlyArchived = false;
|
||||
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
|
||||
@ -70,16 +73,9 @@ public class ExploreRepositoriesFragment extends Fragment {
|
||||
setHasOptionsMenu(true);
|
||||
|
||||
context = getContext();
|
||||
tinyDb = TinyDB.getInstance(getContext());
|
||||
|
||||
dataList = new ArrayList<>();
|
||||
adapter = new ExploreRepositoriesAdapter(dataList, context);
|
||||
|
||||
tinyDb.putBoolean("exploreRepoIncludeTopic", false);
|
||||
tinyDb.putBoolean("exploreRepoIncludeDescription", false);
|
||||
tinyDb.putBoolean("exploreRepoIncludeTemplate", false);
|
||||
tinyDb.putBoolean("exploreRepoOnlyArchived", false);
|
||||
|
||||
resultLimit = Constants.getCurrentResultLimit(context);
|
||||
|
||||
viewBinding.searchKeyword.setOnEditorActionListener((v1, actionId, event) -> {
|
||||
@ -89,12 +85,12 @@ public class ExploreRepositoriesFragment extends Fragment {
|
||||
imm.hideSoftInputFromWindow(viewBinding.searchKeyword.getWindowToken(), 0);
|
||||
|
||||
viewBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
loadInitial(String.valueOf(viewBinding.searchKeyword.getText()), tinyDb.getBoolean("exploreRepoIncludeTopic"), tinyDb.getBoolean("exploreRepoIncludeDescription"), tinyDb.getBoolean("exploreRepoIncludeTemplate"), tinyDb.getBoolean("exploreRepoOnlyArchived"), resultLimit);
|
||||
loadInitial(String.valueOf(viewBinding.searchKeyword.getText()), resultLimit);
|
||||
|
||||
adapter.setLoadMoreListener(() -> viewBinding.recyclerViewReposSearch.post(() -> {
|
||||
if(dataList.size() == resultLimit || pageSize == resultLimit) {
|
||||
int page = (dataList.size() + resultLimit) / resultLimit;
|
||||
loadMore(String.valueOf(viewBinding.searchKeyword.getText()), tinyDb.getBoolean("exploreRepoIncludeTopic"), tinyDb.getBoolean("exploreRepoIncludeDescription"), tinyDb.getBoolean("exploreRepoIncludeTemplate"), tinyDb.getBoolean("exploreRepoOnlyArchived"), resultLimit, page);
|
||||
loadMore(String.valueOf(viewBinding.searchKeyword.getText()), resultLimit, page);
|
||||
}
|
||||
}));
|
||||
}
|
||||
@ -104,14 +100,14 @@ public class ExploreRepositoriesFragment extends Fragment {
|
||||
|
||||
viewBinding.pullToRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
viewBinding.pullToRefresh.setRefreshing(false);
|
||||
loadInitial("", tinyDb.getBoolean("exploreRepoIncludeTopic"), tinyDb.getBoolean("exploreRepoIncludeDescription"), tinyDb.getBoolean("exploreRepoIncludeTemplate"), tinyDb.getBoolean("exploreRepoOnlyArchived"), resultLimit);
|
||||
loadInitial("", resultLimit);
|
||||
adapter.notifyDataChanged();
|
||||
}, 200));
|
||||
|
||||
adapter.setLoadMoreListener(() -> viewBinding.recyclerViewReposSearch.post(() -> {
|
||||
if(dataList.size() == resultLimit || pageSize == resultLimit) {
|
||||
int page = (dataList.size() + resultLimit) / resultLimit;
|
||||
loadMore(String.valueOf(viewBinding.searchKeyword.getText()), tinyDb.getBoolean("exploreRepoIncludeTopic"), tinyDb.getBoolean("exploreRepoIncludeDescription"), tinyDb.getBoolean("exploreRepoIncludeTemplate"), tinyDb.getBoolean("exploreRepoOnlyArchived"), resultLimit, page);
|
||||
loadMore(String.valueOf(viewBinding.searchKeyword.getText()), resultLimit, page);
|
||||
}
|
||||
}));
|
||||
|
||||
@ -121,15 +117,15 @@ public class ExploreRepositoriesFragment extends Fragment {
|
||||
viewBinding.recyclerViewReposSearch.setLayoutManager(new LinearLayoutManager(context));
|
||||
viewBinding.recyclerViewReposSearch.setAdapter(adapter);
|
||||
|
||||
loadInitial("", tinyDb.getBoolean("exploreRepoIncludeTopic"), tinyDb.getBoolean("exploreRepoIncludeDescription"), tinyDb.getBoolean("exploreRepoIncludeTemplate"), tinyDb.getBoolean("exploreRepoOnlyArchived"), resultLimit);
|
||||
loadInitial("", resultLimit);
|
||||
|
||||
return viewBinding.getRoot();
|
||||
}
|
||||
|
||||
private void loadInitial(String searchKeyword, boolean exploreRepoIncludeTopic, boolean exploreRepoIncludeDescription, boolean exploreRepoIncludeTemplate, boolean exploreRepoOnlyArchived, int resultLimit) {
|
||||
private void loadInitial(String searchKeyword, int resultLimit) {
|
||||
|
||||
Call<ExploreRepositories> call = RetrofitClient
|
||||
.getApiInterface(context).queryRepos(Authorization.get(getContext()), searchKeyword, repoTypeInclude, sort, order, exploreRepoIncludeTopic, exploreRepoIncludeDescription, exploreRepoIncludeTemplate, exploreRepoOnlyArchived, resultLimit, 1);
|
||||
.getApiInterface(context).queryRepos(((BaseActivity) requireActivity()).getAccount().getAuthorization(), searchKeyword, repoTypeInclude, sort, order, includeTopic, includeDescription, includeTemplate, onlyArchived, resultLimit, 1);
|
||||
call.enqueue(new Callback<ExploreRepositories>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<ExploreRepositories> call, @NonNull Response<ExploreRepositories> response) {
|
||||
@ -163,11 +159,11 @@ public class ExploreRepositoriesFragment extends Fragment {
|
||||
});
|
||||
}
|
||||
|
||||
private void loadMore(String searchKeyword, boolean exploreRepoIncludeTopic, boolean exploreRepoIncludeDescription, boolean exploreRepoIncludeTemplate, boolean exploreRepoOnlyArchived, int resultLimit, int page) {
|
||||
private void loadMore(String searchKeyword, int resultLimit, int page) {
|
||||
|
||||
viewBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
Call<ExploreRepositories> call = RetrofitClient.getApiInterface(context)
|
||||
.queryRepos(Authorization.get(getContext()), searchKeyword, repoTypeInclude, sort, order, exploreRepoIncludeTopic, exploreRepoIncludeDescription, exploreRepoIncludeTemplate, exploreRepoOnlyArchived, resultLimit, page);
|
||||
.queryRepos(((BaseActivity) requireActivity()).getAccount().getAuthorization(), searchKeyword, repoTypeInclude, sort, order, includeTopic, includeDescription, includeTemplate, onlyArchived, resultLimit, page);
|
||||
call.enqueue(new Callback<ExploreRepositories>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<ExploreRepositories> call, @NonNull Response<ExploreRepositories> response) {
|
||||
@ -225,30 +221,20 @@ public class ExploreRepositoriesFragment extends Fragment {
|
||||
View view = filterBinding.getRoot();
|
||||
dialogFilterOptions.setContentView(view);
|
||||
|
||||
filterBinding.includeTopic.setOnClickListener(includeTopic -> {
|
||||
tinyDb.putBoolean("exploreRepoIncludeTopic", filterBinding.includeTopic.isChecked());
|
||||
});
|
||||
filterBinding.includeTopic.setOnClickListener(includeTopic -> this.includeTopic = filterBinding.includeTopic.isChecked());
|
||||
|
||||
filterBinding.includeDesc.setOnClickListener(includeDesc -> {
|
||||
tinyDb.putBoolean("exploreRepoIncludeDescription", filterBinding.includeDesc.isChecked());
|
||||
});
|
||||
filterBinding.includeDesc.setOnClickListener(includeDesc -> this.includeDescription = filterBinding.includeDesc.isChecked());
|
||||
|
||||
filterBinding.includeTemplate.setOnClickListener(includeTemplate -> {
|
||||
tinyDb.putBoolean("exploreRepoIncludeTemplate", filterBinding.includeTemplate.isChecked());
|
||||
});
|
||||
filterBinding.includeTemplate.setOnClickListener(includeTemplate -> this.includeTemplate = filterBinding.includeTemplate.isChecked());
|
||||
|
||||
filterBinding.onlyArchived.setOnClickListener(onlyArchived -> {
|
||||
tinyDb.putBoolean("exploreRepoOnlyArchived", filterBinding.onlyArchived.isChecked());
|
||||
});
|
||||
filterBinding.onlyArchived.setOnClickListener(onlyArchived -> this.onlyArchived = filterBinding.onlyArchived.isChecked());
|
||||
|
||||
filterBinding.includeTopic.setChecked(tinyDb.getBoolean("exploreRepoIncludeTopic"));
|
||||
filterBinding.includeDesc.setChecked(tinyDb.getBoolean("exploreRepoIncludeDescription"));
|
||||
filterBinding.includeTemplate.setChecked(tinyDb.getBoolean("exploreRepoIncludeTemplate"));
|
||||
filterBinding.onlyArchived.setChecked(tinyDb.getBoolean("exploreRepoOnlyArchived"));
|
||||
filterBinding.includeTopic.setChecked(includeTopic);
|
||||
filterBinding.includeDesc.setChecked(includeDescription);
|
||||
filterBinding.includeTemplate.setChecked(includeTemplate);
|
||||
filterBinding.onlyArchived.setChecked(onlyArchived);
|
||||
|
||||
filterBinding.cancel.setOnClickListener(editProperties -> {
|
||||
dialogFilterOptions.dismiss();
|
||||
});
|
||||
filterBinding.cancel.setOnClickListener(editProperties -> dialogFilterOptions.dismiss());
|
||||
|
||||
dialogFilterOptions.show();
|
||||
}
|
||||
|
@ -17,10 +17,10 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import org.gitnex.tea4j.models.UserInfo;
|
||||
import org.gitnex.tea4j.models.UserSearch;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.adapters.UsersAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.FragmentExploreUsersBinding;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.Constants;
|
||||
import org.mian.gitnex.helpers.SnackBar;
|
||||
import java.util.ArrayList;
|
||||
@ -63,12 +63,12 @@ public class ExploreUsersFragment extends Fragment {
|
||||
imm.hideSoftInputFromWindow(viewBinding.searchKeyword.getWindowToken(), 0);
|
||||
|
||||
viewBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
loadInitial(Authorization.get(context), String.valueOf(viewBinding.searchKeyword.getText()), resultLimit);
|
||||
loadInitial(((BaseActivity) requireActivity()).getAccount().getAuthorization(), String.valueOf(viewBinding.searchKeyword.getText()), resultLimit);
|
||||
|
||||
adapter.setLoadMoreListener(() -> viewBinding.recyclerViewExploreUsers.post(() -> {
|
||||
if(usersList.size() == resultLimit || pageSize == resultLimit) {
|
||||
int page = (usersList.size() + resultLimit) / resultLimit;
|
||||
loadMore(Authorization.get(context), String.valueOf(viewBinding.searchKeyword.getText()), resultLimit, page);
|
||||
loadMore(((BaseActivity) requireActivity()).getAccount().getAuthorization(), String.valueOf(viewBinding.searchKeyword.getText()), resultLimit, page);
|
||||
}
|
||||
}));
|
||||
}
|
||||
@ -78,14 +78,14 @@ public class ExploreUsersFragment extends Fragment {
|
||||
|
||||
viewBinding.pullToRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
viewBinding.pullToRefresh.setRefreshing(false);
|
||||
loadInitial(Authorization.get(context), "", resultLimit);
|
||||
loadInitial(((BaseActivity) requireActivity()).getAccount().getAuthorization(), "", resultLimit);
|
||||
adapter.notifyDataChanged();
|
||||
}, 200));
|
||||
|
||||
adapter.setLoadMoreListener(() -> viewBinding.recyclerViewExploreUsers.post(() -> {
|
||||
if(usersList.size() == resultLimit || pageSize == resultLimit) {
|
||||
int page = (usersList.size() + resultLimit) / resultLimit;
|
||||
loadMore(Authorization.get(context), "", resultLimit, page);
|
||||
loadMore(((BaseActivity) requireActivity()).getAccount().getAuthorization(), "", resultLimit, page);
|
||||
}
|
||||
}));
|
||||
|
||||
@ -95,7 +95,7 @@ public class ExploreUsersFragment extends Fragment {
|
||||
viewBinding.recyclerViewExploreUsers.setLayoutManager(new LinearLayoutManager(context));
|
||||
viewBinding.recyclerViewExploreUsers.setAdapter(adapter);
|
||||
|
||||
loadInitial(Authorization.get(context), "", resultLimit);
|
||||
loadInitial(((BaseActivity) requireActivity()).getAccount().getAuthorization(), "", resultLimit);
|
||||
|
||||
return viewBinding.getRoot();
|
||||
}
|
||||
|
@ -19,30 +19,24 @@ import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import org.gitnex.tea4j.models.Files;
|
||||
import org.gitnex.tea4j.models.UserRepositories;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.activities.FileViewActivity;
|
||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||
import org.mian.gitnex.adapters.FilesAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.database.api.BaseApi;
|
||||
import org.mian.gitnex.database.api.RepositoriesApi;
|
||||
import org.mian.gitnex.database.api.UserAccountsApi;
|
||||
import org.mian.gitnex.database.models.Repository;
|
||||
import org.mian.gitnex.database.models.UserAccount;
|
||||
import org.mian.gitnex.databinding.FragmentFilesBinding;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.Path;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import org.mian.gitnex.viewmodels.FilesViewModel;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import moe.feng.common.view.breadcrumbs.DefaultBreadcrumbsCallback;
|
||||
import moe.feng.common.view.breadcrumbs.model.BreadcrumbItem;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
@ -52,13 +46,7 @@ public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapter
|
||||
|
||||
private FragmentFilesBinding binding;
|
||||
|
||||
private static final String repoNameF = "param2";
|
||||
private static final String repoOwnerF = "param1";
|
||||
private static final String repoRefF = "param3";
|
||||
|
||||
private String repoName;
|
||||
private String repoOwner;
|
||||
private String ref;
|
||||
private RepositoryContext repository;
|
||||
|
||||
private final Path path = new Path();
|
||||
|
||||
@ -66,30 +54,18 @@ public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapter
|
||||
|
||||
public FilesFragment() {}
|
||||
|
||||
public static FilesFragment newInstance(String param1, String param2, String param3) {
|
||||
public static FilesFragment newInstance(RepositoryContext repository) {
|
||||
|
||||
FilesFragment fragment = new FilesFragment();
|
||||
|
||||
Bundle args = new Bundle();
|
||||
args.putString(repoOwnerF, param1);
|
||||
args.putString(repoNameF, param2);
|
||||
args.putString(repoRefF, param3);
|
||||
|
||||
fragment.setArguments(args);
|
||||
fragment.setArguments(repository.getBundle());
|
||||
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
repository = RepositoryContext.fromBundle(requireArguments());
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
if(getArguments() != null) {
|
||||
repoName = getArguments().getString(repoNameF);
|
||||
repoOwner = getArguments().getString(repoOwnerF);
|
||||
ref = getArguments().getString(repoRefF);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -105,7 +81,7 @@ public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapter
|
||||
binding.recyclerView.setAdapter(filesAdapter);
|
||||
binding.recyclerView.addItemDecoration(new DividerItemDecoration(binding.recyclerView.getContext(), DividerItemDecoration.VERTICAL));
|
||||
|
||||
binding.breadcrumbsView.setItems(new ArrayList<>(Collections.singletonList(BreadcrumbItem.createSimpleItem(getResources().getString(R.string.filesBreadcrumbRoot) + getResources().getString(R.string.colonDivider) + ref))));
|
||||
binding.breadcrumbsView.setItems(new ArrayList<>(Collections.singletonList(BreadcrumbItem.createSimpleItem(getResources().getString(R.string.filesBreadcrumbRoot) + getResources().getString(R.string.colonDivider) + repository.getBranchRef()))));
|
||||
// noinspection unchecked
|
||||
binding.breadcrumbsView.setCallback(new DefaultBreadcrumbsCallback<BreadcrumbItem>() {
|
||||
|
||||
@ -129,16 +105,16 @@ public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapter
|
||||
|
||||
@Override
|
||||
public void handleOnBackPressed() {
|
||||
if(path.size() == 0 || RepoDetailActivity.mViewPager.getCurrentItem() != 1) {
|
||||
if(path.size() == 0 || ((RepoDetailActivity) requireActivity()).mViewPager.getCurrentItem() != 1) {
|
||||
requireActivity().finish();
|
||||
return;
|
||||
}
|
||||
path.remove(path.size() - 1);
|
||||
binding.breadcrumbsView.removeLastItem();
|
||||
if(path.size() == 0) {
|
||||
fetchDataAsync(Authorization.get(getContext()), repoOwner, repoName, ref);
|
||||
fetchDataAsync(((BaseActivity) requireActivity()).getAccount().getAuthorization(), repository.getOwner(), repository.getName(), repository.getBranchRef());
|
||||
} else {
|
||||
fetchDataAsyncSub(Authorization.get(getContext()), repoOwner, repoName, path.toString(), ref);
|
||||
fetchDataAsyncSub(((BaseActivity) requireActivity()).getAccount().getAuthorization(), repository.getOwner(), repository.getName(), path.toString(), repository.getBranchRef());
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -150,11 +126,10 @@ public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapter
|
||||
|
||||
((RepoDetailActivity) requireActivity()).setFragmentRefreshListenerFiles(repoBranch -> {
|
||||
|
||||
repository.setBranchRef(repoBranch);
|
||||
path.clear();
|
||||
ref = repoBranch;
|
||||
binding.breadcrumbsView.setItems(new ArrayList<>(Collections.singletonList(BreadcrumbItem.createSimpleItem(getResources().getString(R.string.filesBreadcrumbRoot) + getResources().getString(R.string.colonDivider) + ref))));
|
||||
binding.breadcrumbsView.setItems(new ArrayList<>(Collections.singletonList(BreadcrumbItem.createSimpleItem(getResources().getString(R.string.filesBreadcrumbRoot) + getResources().getString(R.string.colonDivider) + repository.getBranchRef()))));
|
||||
refresh();
|
||||
|
||||
});
|
||||
|
||||
|
||||
@ -184,7 +159,7 @@ public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapter
|
||||
|
||||
case "file":
|
||||
case "symlink":
|
||||
Intent intent = new Intent(getContext(), FileViewActivity.class);
|
||||
Intent intent = repository.getIntent(getContext(), FileViewActivity.class);
|
||||
intent.putExtra("file", file);
|
||||
|
||||
requireContext().startActivity(intent);
|
||||
@ -199,7 +174,7 @@ public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapter
|
||||
String host = url.getHost();
|
||||
|
||||
UserAccountsApi userAccountsApi = BaseApi.getInstance(requireContext(), UserAccountsApi.class);
|
||||
List<UserAccount> userAccounts = userAccountsApi.usersAccounts();
|
||||
List<UserAccount> userAccounts = userAccountsApi.loggedInUserAccounts();
|
||||
UserAccount account = null;
|
||||
|
||||
for(UserAccount userAccount : userAccounts) {
|
||||
@ -208,16 +183,14 @@ public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapter
|
||||
account = userAccount;
|
||||
// if scheme is wrong fix it
|
||||
if (!url.getScheme().equals(instanceUri.getScheme())) {
|
||||
url = AppUtil.changeScheme(url,instanceUri.getScheme());
|
||||
url = AppUtil.changeScheme(url, instanceUri.getScheme());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(account != null) {
|
||||
TinyDB tinyDB = TinyDB.getInstance(requireContext());
|
||||
int oldId = tinyDB.getInt("currentActiveAccountId");
|
||||
AppUtil.switchToAccount(requireContext(), account);
|
||||
AppUtil.switchToAccount(requireContext(), account, true);
|
||||
List<String> splittedUrl = url.getPathSegments();
|
||||
if(splittedUrl.size() < 2) {
|
||||
AppUtil.openUrlInBrowser(requireContext(), url.toString());
|
||||
@ -228,62 +201,7 @@ public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapter
|
||||
repo = repo.substring(0, repo.length() - 4);
|
||||
}
|
||||
|
||||
Call<UserRepositories> call = RetrofitClient
|
||||
.getApiInterface(requireContext(), account.getInstanceUrl())
|
||||
.getUserRepository(Authorization.get(requireContext()), owner, repo);
|
||||
|
||||
Uri finalUrl = url;
|
||||
call.enqueue(new Callback<UserRepositories>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<UserRepositories> call, @NonNull retrofit2.Response<UserRepositories> response) {
|
||||
|
||||
UserRepositories repoInfo = response.body();
|
||||
|
||||
if (response.code() == 200) {
|
||||
|
||||
assert repoInfo != null;
|
||||
|
||||
Intent repoIntent = new Intent(requireContext(), RepoDetailActivity.class);
|
||||
repoIntent.putExtra("repoFullName", repoInfo.getFullName());
|
||||
repoIntent.putExtra("goToSection", "yes");
|
||||
repoIntent.putExtra("goToSectionType", "repo");
|
||||
repoIntent.putExtra("switchAccountBackOnFinish", true);
|
||||
repoIntent.putExtra("oldAccountId", oldId);
|
||||
|
||||
tinyDB.putString("repoFullName", repoInfo.getFullName());
|
||||
if(repoInfo.getPrivateFlag()) {
|
||||
tinyDB.putString("repoType", getResources().getString(R.string.strPrivate));
|
||||
}
|
||||
else {
|
||||
tinyDB.putString("repoType", getResources().getString(R.string.strPublic));
|
||||
}
|
||||
tinyDB.putBoolean("isRepoAdmin", repoInfo.getPermissions().isAdmin());
|
||||
tinyDB.putString("repoBranch", repoInfo.getDefault_branch());
|
||||
|
||||
int currentActiveAccountId = tinyDB.getInt("currentActiveAccountId");
|
||||
|
||||
RepositoriesApi repositoryData = BaseApi.getInstance(requireContext(), RepositoriesApi.class);
|
||||
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
if(count == 0) {
|
||||
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
tinyDB.putLong("repositoryId", id);
|
||||
} else {
|
||||
Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
tinyDB.putLong("repositoryId", data.getRepositoryId());
|
||||
}
|
||||
|
||||
startActivity(repoIntent);
|
||||
} else {
|
||||
AppUtil.openUrlInBrowser(requireContext(), finalUrl.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<UserRepositories> call, @NonNull Throwable t) {
|
||||
AppUtil.openUrlInBrowser(requireContext(), finalUrl.toString());
|
||||
}
|
||||
});
|
||||
startActivity(new RepositoryContext(owner, repo, requireContext()).getIntent(requireContext(), RepoDetailActivity.class));
|
||||
} else {
|
||||
AppUtil.openUrlInBrowser(requireContext(), url.toString());
|
||||
}
|
||||
@ -293,9 +211,9 @@ public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapter
|
||||
|
||||
public void refresh() {
|
||||
if(path.size() > 0) {
|
||||
fetchDataAsyncSub(Authorization.get(getContext()), repoOwner, repoName, path.toString(), ref);
|
||||
fetchDataAsyncSub(((BaseActivity) requireActivity()).getAccount().getAuthorization(), repository.getOwner(), repository.getName(), path.toString(), repository.getBranchRef());
|
||||
} else {
|
||||
fetchDataAsync(Authorization.get(getContext()), repoOwner, repoName, ref);
|
||||
fetchDataAsync(((BaseActivity) requireActivity()).getAccount().getAuthorization(), repository.getOwner(), repository.getName(), repository.getBranchRef());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,15 +19,14 @@ import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import org.gitnex.tea4j.models.Issues;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||
import org.mian.gitnex.adapters.IssuesAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.FragmentIssuesBinding;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.Constants;
|
||||
import org.mian.gitnex.helpers.SnackBar;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
@ -40,6 +39,8 @@ import retrofit2.Response;
|
||||
|
||||
public class IssuesFragment extends Fragment {
|
||||
|
||||
public static boolean resumeIssues = false;
|
||||
|
||||
private FragmentIssuesBinding fragmentIssuesBinding;
|
||||
private Context context;
|
||||
|
||||
@ -52,6 +53,14 @@ public class IssuesFragment extends Fragment {
|
||||
private int resultLimit = Constants.resultLimitOldGiteaInstances;
|
||||
private final String requestType = Constants.issuesRequestType;
|
||||
|
||||
private RepositoryContext repository;
|
||||
|
||||
public static IssuesFragment newInstance(RepositoryContext repository) {
|
||||
IssuesFragment f = new IssuesFragment();
|
||||
f.setArguments(repository.getBundle());
|
||||
return f;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
@ -60,16 +69,10 @@ public class IssuesFragment extends Fragment {
|
||||
setHasOptionsMenu(true);
|
||||
context = getContext();
|
||||
|
||||
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
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 instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
repository = RepositoryContext.fromBundle(requireArguments());
|
||||
|
||||
// if gitea is 1.12 or higher use the new limit
|
||||
if(new Version(tinyDb.getString("giteaVersion")).higherOrEqual("1.12.0")) {
|
||||
if(((BaseActivity) requireActivity()).getAccount().requiresVersion("1.12.0")) {
|
||||
resultLimit = Constants.resultLimitNewGiteaInstances;
|
||||
}
|
||||
|
||||
@ -77,7 +80,7 @@ public class IssuesFragment extends Fragment {
|
||||
|
||||
fragmentIssuesBinding.pullToRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
fragmentIssuesBinding.pullToRefresh.setRefreshing(false);
|
||||
loadInitial(instanceToken, repoOwner, repoName, resultLimit, requestType, tinyDb.getString("repoIssuesState"), "");
|
||||
loadInitial(((BaseActivity) requireActivity()).getAccount().getAuthorization(), repository.getOwner(), repository.getName(), resultLimit, requestType, repository.getIssueState().toString(), "");
|
||||
adapter.notifyDataChanged();
|
||||
}, 200));
|
||||
|
||||
@ -85,7 +88,7 @@ public class IssuesFragment extends Fragment {
|
||||
adapter.setLoadMoreListener(() -> fragmentIssuesBinding.recyclerView.post(() -> {
|
||||
if(issuesList.size() == resultLimit || pageSize == resultLimit) {
|
||||
int page = (issuesList.size() + resultLimit) / resultLimit;
|
||||
loadMore(Authorization.get(context), repoOwner, repoName, page, resultLimit, requestType, tinyDb.getString("repoIssuesState"), "");
|
||||
loadMore(((BaseActivity) requireActivity()).getAccount().getAuthorization(), repository.getOwner(), repository.getName(), page, resultLimit, requestType, repository.getIssueState().toString(), "");
|
||||
}
|
||||
}));
|
||||
|
||||
@ -111,16 +114,14 @@ public class IssuesFragment extends Fragment {
|
||||
|
||||
if(issuesList.size() == resultLimit || pageSize == resultLimit) {
|
||||
int page = (issuesList.size() + resultLimit) / resultLimit;
|
||||
loadMore(Authorization.get(context), repoOwner, repoName, page, resultLimit, requestType, tinyDb.getString("repoIssuesState"), "");
|
||||
loadMore(((BaseActivity) requireActivity()).getAccount().getAuthorization(), repository.getOwner(), repository.getName(), page, resultLimit, requestType, repository.getIssueState().toString(), repository.getIssueMilestoneFilterName());
|
||||
}
|
||||
}));
|
||||
|
||||
tinyDb.putString("repoIssuesState", issueState);
|
||||
|
||||
fragmentIssuesBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
fragmentIssuesBinding.noDataIssues.setVisibility(View.GONE);
|
||||
|
||||
loadInitial(Authorization.get(context), repoOwner, repoName, resultLimit, requestType, issueState, "");
|
||||
loadInitial(((BaseActivity) requireActivity()).getAccount().getAuthorization(), repository.getOwner(), repository.getName(), resultLimit, requestType, issueState, repository.getIssueMilestoneFilterName());
|
||||
fragmentIssuesBinding.recyclerView.setAdapter(adapter);
|
||||
});
|
||||
|
||||
@ -133,38 +134,28 @@ public class IssuesFragment extends Fragment {
|
||||
|
||||
if(issuesList.size() == resultLimit || pageSize == resultLimit) {
|
||||
int page = (issuesList.size() + resultLimit) / resultLimit;
|
||||
loadMore(Authorization.get(context), repoOwner, repoName, page, resultLimit, requestType, tinyDb.getString("repoIssuesState"), tinyDb.getString("issueMilestoneFilterId"));
|
||||
loadMore(((BaseActivity) requireActivity()).getAccount().getAuthorization(), repository.getOwner(), repository.getName(), page, resultLimit, requestType, repository.getIssueState().toString(), repository.getIssueMilestoneFilterName());
|
||||
}
|
||||
}));
|
||||
|
||||
tinyDb.putString("issueMilestoneFilterId", filterIssueByMilestone);
|
||||
|
||||
fragmentIssuesBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
fragmentIssuesBinding.noDataIssues.setVisibility(View.GONE);
|
||||
|
||||
loadInitial(Authorization.get(context), repoOwner, repoName, resultLimit, requestType, tinyDb.getString("repoIssuesState"), filterIssueByMilestone);
|
||||
loadInitial(((BaseActivity) requireActivity()).getAccount().getAuthorization(), repository.getOwner(), repository.getName(), resultLimit, requestType, repository.getIssueState().toString(), filterIssueByMilestone);
|
||||
fragmentIssuesBinding.recyclerView.setAdapter(adapter);
|
||||
});
|
||||
|
||||
loadInitial(Authorization.get(context), repoOwner, repoName, resultLimit, requestType, tinyDb.getString("repoIssuesState"), tinyDb.getString("issueMilestoneFilterId"));
|
||||
loadInitial(((BaseActivity) requireActivity()).getAccount().getAuthorization(), repository.getOwner(), repository.getName(), resultLimit, requestType, repository.getIssueState().toString(), repository.getIssueMilestoneFilterName());
|
||||
|
||||
return fragmentIssuesBinding.getRoot();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
|
||||
super.onResume();
|
||||
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
|
||||
if(tinyDb.getBoolean("resumeIssues")) {
|
||||
loadInitial(Authorization.get(context), repoOwner, repoName, resultLimit, requestType, tinyDb.getString("repoIssuesState"), tinyDb.getString("issueMilestoneFilterId"));
|
||||
tinyDb.putBoolean("resumeIssues", false);
|
||||
if(resumeIssues) {
|
||||
loadInitial(((BaseActivity) requireActivity()).getAccount().getAuthorization(), repository.getOwner(), repository.getName(), resultLimit, requestType, repository.getIssueState().toString(), repository.getIssueMilestoneFilterName());
|
||||
resumeIssues = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -251,9 +242,7 @@ public class IssuesFragment extends Fragment {
|
||||
inflater.inflate(R.menu.filter_menu, menu);
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
|
||||
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
|
||||
if(tinyDb.getString("repoIssuesState").equals("closed")) {
|
||||
if(repository.getIssueState().toString().equals("closed")) {
|
||||
menu.getItem(1).setIcon(R.drawable.ic_filter_closed);
|
||||
}
|
||||
else {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user