Increasing performance, fixing bugs and adding syntax highlighting. (#755)
Merge branch 'performance-highlight-refactor' of https://codeberg.org/opyale/GitNex into performance-highlight-refactor Fixing theme recognition. Merge branch 'master' into performance-highlight-refactor Merge commit 'refs/pull/755/head' of codeberg.org:gitnex/GitNex into performance-highlight-refactor Add new field issueType to db Improving theme recognition. Fixing alignment of menu button. Fixing cut off text. Merge commit 'refs/pull/755/head' of codeberg.org:gitnex/GitNex into performance-highlight-refactor Fixing crash. Refactoring activities. Improving drafts. Calculating density for avatars. Improving drafts. Calculating density for avatars. Increasing size of avatar. Decreasing size of avatar. Restoring DeepLinksActivity Merge branch 'master' of https://codeberg.org/gitnex/GitNex into performance-highlight-refactor Conflicts: app/src/main/java/org/mian/gitnex/adapters/IssueCommentsAdapter.java Initial commit. Co-authored-by: M M Arif <mmarif@swatian.com> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/755 Reviewed-by: M M Arif <mmarif@noreply.codeberg.org>
This commit is contained in:
parent
0f5858f292
commit
a3bd5c2af2
@ -74,6 +74,7 @@ Thanks to all the open source libraries, contributors and donators.
|
||||
- Okhttp
|
||||
- Picasso
|
||||
- Markwon
|
||||
- Prism4j
|
||||
- Prettytime
|
||||
- Amulyakhare/textdrawable
|
||||
- Vdurmont/emoji-java
|
||||
|
@ -55,7 +55,7 @@ dependencies {
|
||||
def lifecycle_version = '2.3.0-beta01'
|
||||
def markwon_version = '4.6.0'
|
||||
def work_version = "2.4.0"
|
||||
def acra = "5.5.0"
|
||||
def acra = "5.7.0"
|
||||
|
||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||
implementation 'androidx.appcompat:appcompat:1.3.0-alpha02'
|
||||
@ -90,8 +90,11 @@ dependencies {
|
||||
implementation "io.noties.markwon:recycler-table:$markwon_version"
|
||||
implementation "io.noties.markwon:simple-ext:$markwon_version"
|
||||
implementation "io.noties.markwon:syntax-highlight:$markwon_version"
|
||||
implementation "io.noties.markwon:image-picasso:$markwon_version"
|
||||
implementation "io.noties:prism4j:2.0.0"
|
||||
annotationProcessor "io.noties:prism4j-bundler:2.0.0"
|
||||
implementation "com.caverock:androidsvg:1.4"
|
||||
implementation "pl.droidsonroids.gif:android-gif-drawable:1.2.19"
|
||||
implementation "pl.droidsonroids.gif:android-gif-drawable:1.2.21"
|
||||
implementation "com.github.HamidrezaAmz:BreadcrumbsView:0.2.9"
|
||||
implementation "commons-io:commons-io:20030203.000550"
|
||||
implementation 'org.apache.commons:commons-lang3:3.11'
|
||||
@ -103,7 +106,7 @@ dependencies {
|
||||
implementation "androidx.room:room-runtime:2.2.5"
|
||||
annotationProcessor "androidx.room:room-compiler:2.2.5"
|
||||
implementation "androidx.work:work-runtime:$work_version"
|
||||
implementation "com.eightbitlab:blurview:1.6.3"
|
||||
implementation "com.eightbitlab:blurview:1.6.4"
|
||||
implementation "io.mikael:urlbuilder:2.0.9"
|
||||
|
||||
}
|
||||
|
@ -74,9 +74,6 @@
|
||||
<activity
|
||||
android:name=".activities.CreateMilestoneActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|uiMode|keyboard|keyboardHidden|navigation" />
|
||||
<activity
|
||||
android:name=".activities.ReplyToIssueActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|uiMode|keyboard|keyboardHidden|navigation" />
|
||||
<activity
|
||||
android:name=".activities.IssueDetailActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|uiMode|keyboard|keyboardHidden|navigation"
|
||||
|
@ -24,12 +24,11 @@ import retrofit2.Callback;
|
||||
|
||||
public class AssigneesActions {
|
||||
|
||||
public static void getCurrentIssueAssignees(Context ctx, String instanceUrl, String loginUid, String instanceToken, String repoOwner, String repoName, int issueIndex, List<String> currentAssignees) {
|
||||
public static void getCurrentIssueAssignees(Context ctx, String repoOwner, String repoName, int issueIndex, List<String> currentAssignees) {
|
||||
|
||||
Call<Issues> callSingleIssueLabels = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.getIssueByIndex(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, issueIndex);
|
||||
.getApiInterface(ctx)
|
||||
.getIssueByIndex(Authorization.get(ctx), repoOwner, repoName, issueIndex);
|
||||
|
||||
callSingleIssueLabels.enqueue(new Callback<Issues>() {
|
||||
|
||||
@ -63,14 +62,13 @@ public class AssigneesActions {
|
||||
});
|
||||
}
|
||||
|
||||
public static void getRepositoryAssignees(Context ctx, String instanceUrl, String instanceToken, String repoOwner, String repoName, List<Collaborators> assigneesList, Dialog dialogAssignees, AssigneesListAdapter assigneesAdapter, CustomAssigneesSelectionDialogBinding assigneesBinding) {
|
||||
public static void getRepositoryAssignees(Context ctx, String repoOwner, String repoName, List<Collaborators> assigneesList, Dialog dialogAssignees, AssigneesListAdapter assigneesAdapter, CustomAssigneesSelectionDialogBinding assigneesBinding) {
|
||||
|
||||
TinyDB tinyDB = new TinyDB(ctx);
|
||||
TinyDB tinyDB = TinyDB.getInstance(ctx);
|
||||
|
||||
Call<List<Collaborators>> call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.getCollaborators(instanceToken, repoOwner, repoName);
|
||||
.getApiInterface(ctx)
|
||||
.getCollaborators(Authorization.get(ctx), repoOwner, repoName);
|
||||
|
||||
call.enqueue(new Callback<List<Collaborators>>() {
|
||||
|
||||
|
@ -25,21 +25,16 @@ public class CollaboratorActions {
|
||||
|
||||
public static void deleteCollaborator(final Context context, final String searchKeyword, String userName) {
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(context);
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
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];
|
||||
|
||||
Call<Collaborators> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl, context)
|
||||
.getApiInterface()
|
||||
.deleteCollaborator(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName, userName);
|
||||
Call<Collaborators> call = RetrofitClient
|
||||
.getApiInterface(context)
|
||||
.deleteCollaborator(Authorization.get(context), repoOwner, repoName, userName);
|
||||
|
||||
call.enqueue(new Callback<Collaborators>() {
|
||||
|
||||
@ -54,7 +49,7 @@ public class CollaboratorActions {
|
||||
//Log.i("addCollaboratorSearch", addCollaboratorSearch.getText().toString());
|
||||
//tinyDb.putBoolean("updateDataSet", true);
|
||||
//AddCollaboratorToRepositoryActivity usersSearchData = new AddCollaboratorToRepositoryActivity();
|
||||
//usersSearchData.loadUserSearchList(instanceUrl, instanceToken, searchKeyword, context);
|
||||
//usersSearchData.loadUserSearchList(instanceToken, searchKeyword, context);
|
||||
|
||||
}
|
||||
}
|
||||
@ -94,22 +89,18 @@ public class CollaboratorActions {
|
||||
|
||||
public static void addCollaborator(final Context context, String permission, String userName) {
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(context);
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
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];
|
||||
|
||||
Permission permissionString = new Permission(permission);
|
||||
Call<Permission> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl, context)
|
||||
.getApiInterface()
|
||||
.addCollaborator(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName, userName, permissionString);
|
||||
Call<Permission> call = RetrofitClient
|
||||
.getApiInterface(context)
|
||||
.addCollaborator(Authorization.get(context), repoOwner, repoName, userName, permissionString);
|
||||
|
||||
call.enqueue(new Callback<Permission>() {
|
||||
|
||||
@ -122,7 +113,7 @@ public class CollaboratorActions {
|
||||
Toasty.success(context, context.getString(R.string.addCollaboratorToastText));
|
||||
((AddCollaboratorToRepositoryActivity)context).finish();
|
||||
//AddCollaboratorToRepositoryActivity usersSearchData = new AddCollaboratorToRepositoryActivity();
|
||||
//usersSearchData.loadUserSearchList(instanceUrl, instanceToken, searchKeyword, context);
|
||||
//usersSearchData.loadUserSearchList(instanceToken, searchKeyword, context);
|
||||
|
||||
}
|
||||
}
|
||||
@ -164,11 +155,7 @@ public class CollaboratorActions {
|
||||
public static ActionResult<List<Collaborators>> getCollaborators(Context context) {
|
||||
|
||||
ActionResult<List<Collaborators>> actionResult = new ActionResult<>();
|
||||
TinyDB tinyDb = new TinyDB(context);
|
||||
|
||||
String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
String loginUid = tinyDb.getString("loginUid");
|
||||
String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
@ -176,9 +163,8 @@ public class CollaboratorActions {
|
||||
String repoName = parts[1];
|
||||
|
||||
Call<List<Collaborators>> call = RetrofitClient
|
||||
.getInstance(instanceUrl, context)
|
||||
.getApiInterface()
|
||||
.getCollaborators(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName);
|
||||
.getApiInterface(context)
|
||||
.getCollaborators(Authorization.get(context), repoOwner, repoName);
|
||||
|
||||
call.enqueue(new Callback<List<Collaborators>>() {
|
||||
|
||||
|
@ -5,7 +5,6 @@ import androidx.annotation.NonNull;
|
||||
import com.google.gson.JsonElement;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.database.api.DraftsApi;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
@ -15,6 +14,7 @@ import org.mian.gitnex.models.Issues;
|
||||
import org.mian.gitnex.models.UpdateIssueState;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
@ -22,85 +22,72 @@ import retrofit2.Callback;
|
||||
|
||||
public class IssueActions {
|
||||
|
||||
public static void editIssueComment(final Context ctx, final int commentId, final String commentBody, long draftIdOnCreate) {
|
||||
public static ActionResult<Response<?>> edit(Context context, String comment, int commentId) {
|
||||
|
||||
ActionResult<Response<?>> actionResult = new ActionResult<>();
|
||||
|
||||
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(ctx);
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
|
||||
IssueComments commentBodyJson = new IssueComments(commentBody);
|
||||
Call<IssueComments> call;
|
||||
String repoOwner = parts[0];
|
||||
String repoName = parts[1];
|
||||
|
||||
call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().patchIssueComment(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, commentId, commentBodyJson);
|
||||
Call<IssueComments> call = RetrofitClient
|
||||
.getApiInterface(context)
|
||||
.patchIssueComment(Authorization.get(context), repoOwner, repoName, commentId, new IssueComments(comment));
|
||||
|
||||
call.enqueue(new Callback<IssueComments>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<IssueComments> call, @NonNull retrofit2.Response<IssueComments> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if(response.code() == 200) {
|
||||
switch(response.code()) {
|
||||
|
||||
tinyDb.putBoolean("commentEdited", true);
|
||||
Toasty.info(ctx, ctx.getString(R.string.editCommentUpdatedText));
|
||||
case 200:
|
||||
actionResult.finish(ActionResult.Status.SUCCESS);
|
||||
break;
|
||||
|
||||
DraftsApi draftsApi = new DraftsApi(ctx);
|
||||
draftsApi.deleteSingleDraft((int) draftIdOnCreate);
|
||||
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.alertDialogTokenRevokedCopyNegativeButton), context.getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx, ctx.getResources().getString(R.string.alertDialogTokenRevokedTitle), ctx.getResources().getString(R.string.alertDialogTokenRevokedMessage), ctx.getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton), ctx.getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
||||
default:
|
||||
actionResult.finish(ActionResult.Status.FAILED, response);
|
||||
break;
|
||||
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
||||
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
|
||||
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<IssueComments> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getResources().getString(R.string.genericServerResponseError));
|
||||
actionResult.finish(ActionResult.Status.FAILED);
|
||||
}
|
||||
});
|
||||
|
||||
return actionResult;
|
||||
|
||||
}
|
||||
|
||||
public static void closeReopenIssue(final Context ctx, final int issueIndex, final String issueState) {
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(ctx);
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
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];
|
||||
|
||||
UpdateIssueState issueStatJson = new UpdateIssueState(issueState);
|
||||
Call<JsonElement> call;
|
||||
|
||||
call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().closeReopenIssue(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, issueIndex, issueStatJson);
|
||||
call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.closeReopenIssue(Authorization.get(ctx), repoOwner, repoName, issueIndex, issueStatJson);
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
|
||||
@ -162,20 +149,23 @@ public class IssueActions {
|
||||
|
||||
public static void subscribe(final Context ctx) {
|
||||
|
||||
final TinyDB tinyDB = new TinyDB(ctx);
|
||||
final TinyDB tinyDB = TinyDB.getInstance(ctx);
|
||||
|
||||
final String instanceUrl = tinyDB.getString("instanceUrl");
|
||||
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"));
|
||||
|
||||
Call<Void> call;
|
||||
|
||||
call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().addIssueSubscriber(token, repoFullName[0], repoFullName[1], issueNr, userLogin);
|
||||
call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.addIssueSubscriber(token, repoFullName[0], repoFullName[1], issueNr, userLogin);
|
||||
|
||||
call.enqueue(new Callback<Void>() {
|
||||
|
||||
@ -222,9 +212,8 @@ public class IssueActions {
|
||||
|
||||
public static void unsubscribe(final Context ctx) {
|
||||
|
||||
final TinyDB tinyDB = new TinyDB(ctx);
|
||||
final TinyDB tinyDB = TinyDB.getInstance(ctx);
|
||||
|
||||
final String instanceUrl = tinyDB.getString("instanceUrl");
|
||||
String[] repoFullName = tinyDB.getString("repoFullName").split("/");
|
||||
if(repoFullName.length != 2) {
|
||||
return;
|
||||
@ -235,7 +224,7 @@ public class IssueActions {
|
||||
|
||||
Call<Void> call;
|
||||
|
||||
call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().delIssueSubscriber(token, repoFullName[0], repoFullName[1], issueNr, userLogin);
|
||||
call = RetrofitClient.getApiInterface(ctx).delIssueSubscriber(token, repoFullName[0], repoFullName[1], issueNr, userLogin);
|
||||
|
||||
call.enqueue(new Callback<Void>() {
|
||||
|
||||
@ -282,11 +271,8 @@ public class IssueActions {
|
||||
public static ActionResult<ActionResult.None> reply(Context context, String comment, int issueIndex) {
|
||||
|
||||
ActionResult<ActionResult.None> actionResult = new ActionResult<>();
|
||||
TinyDB tinyDb = new TinyDB(context);
|
||||
|
||||
String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
String loginUid = tinyDb.getString("loginUid");
|
||||
String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
@ -296,9 +282,8 @@ public class IssueActions {
|
||||
Issues issueComment = new Issues(comment);
|
||||
|
||||
Call<Issues> call = RetrofitClient
|
||||
.getInstance(instanceUrl, context)
|
||||
.getApiInterface()
|
||||
.replyCommentToIssue(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName, issueIndex, issueComment);
|
||||
.getApiInterface(context)
|
||||
.replyCommentToIssue(Authorization.get(context), repoOwner, repoName, issueIndex, issueComment);
|
||||
|
||||
call.enqueue(new Callback<Issues>() {
|
||||
|
||||
|
@ -22,12 +22,11 @@ import retrofit2.Callback;
|
||||
|
||||
public class LabelsActions {
|
||||
|
||||
public static void getCurrentIssueLabels(Context ctx, String instanceUrl, String loginUid, String instanceToken, String repoOwner, String repoName, int issueIndex, List<Integer> currentLabelsIds) {
|
||||
public static void getCurrentIssueLabels(Context ctx, String repoOwner, String repoName, int issueIndex, List<Integer> currentLabelsIds) {
|
||||
|
||||
Call<List<Labels>> callSingleIssueLabels = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.getIssueLabels(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, issueIndex);
|
||||
.getApiInterface(ctx)
|
||||
.getIssueLabels(Authorization.get(ctx), repoOwner, repoName, issueIndex);
|
||||
|
||||
callSingleIssueLabels.enqueue(new Callback<List<Labels>>() {
|
||||
|
||||
@ -60,12 +59,11 @@ public class LabelsActions {
|
||||
});
|
||||
}
|
||||
|
||||
public static void getRepositoryLabels(Context ctx, String instanceUrl, String instanceToken, String repoOwner, String repoName, List<Labels> labelsList, Dialog dialogLabels, LabelsListAdapter labelsAdapter, CustomLabelsSelectionDialogBinding labelsBinding) {
|
||||
public static void getRepositoryLabels(Context ctx, String repoOwner, String repoName, List<Labels> labelsList, Dialog dialogLabels, LabelsListAdapter labelsAdapter, CustomLabelsSelectionDialogBinding labelsBinding) {
|
||||
|
||||
Call<List<Labels>> call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.getlabels(instanceToken, repoOwner, repoName);
|
||||
.getApiInterface(ctx)
|
||||
.getlabels(Authorization.get(ctx), repoOwner, repoName);
|
||||
|
||||
call.enqueue(new Callback<List<Labels>>() {
|
||||
|
||||
|
@ -23,9 +23,8 @@ public class MilestoneActions {
|
||||
|
||||
public static void closeMilestone(final Context ctx, int milestoneId_) {
|
||||
|
||||
final TinyDB tinyDB = new TinyDB(ctx);
|
||||
final TinyDB tinyDB = TinyDB.getInstance(ctx);
|
||||
|
||||
final String instanceUrl = tinyDB.getString("instanceUrl");
|
||||
String repoFullName = tinyDB.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
final String repoOwner = parts[0];
|
||||
@ -37,8 +36,7 @@ public class MilestoneActions {
|
||||
Call<JsonElement> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.getApiInterface(ctx)
|
||||
.closeReopenMilestone(token, repoOwner, repoName, milestoneId_, milestoneStateJson);
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
@ -81,9 +79,8 @@ public class MilestoneActions {
|
||||
|
||||
public static void openMilestone(final Context ctx, int milestoneId_) {
|
||||
|
||||
final TinyDB tinyDB = new TinyDB(ctx);
|
||||
final TinyDB tinyDB = TinyDB.getInstance(ctx);
|
||||
|
||||
final String instanceUrl = tinyDB.getString("instanceUrl");
|
||||
String repoFullName = tinyDB.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
final String repoOwner = parts[0];
|
||||
@ -95,8 +92,7 @@ public class MilestoneActions {
|
||||
Call<JsonElement> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.getApiInterface(ctx)
|
||||
.closeReopenMilestone(token, repoOwner, repoName, milestoneId_, milestoneStateJson);
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
|
@ -20,24 +20,22 @@ public class NotificationsActions {
|
||||
|
||||
private TinyDB tinyDB;
|
||||
private Context context;
|
||||
private String instanceUrl;
|
||||
private String instanceToken;
|
||||
|
||||
public NotificationsActions(Context context) {
|
||||
|
||||
this.context = context;
|
||||
this.tinyDB = new TinyDB(context);
|
||||
this.tinyDB = TinyDB.getInstance(context);
|
||||
|
||||
String loginUid = tinyDB.getString("loginUid");
|
||||
|
||||
instanceUrl = tinyDB.getString("instanceUrl");
|
||||
instanceToken = "token " + tinyDB.getString(loginUid + "-token");
|
||||
|
||||
}
|
||||
|
||||
public void setNotificationStatus(NotificationThread notificationThread, NotificationStatus notificationStatus) throws IOException {
|
||||
|
||||
Call<ResponseBody> call = RetrofitClient.getInstance(instanceUrl, context).getApiInterface()
|
||||
Call<ResponseBody> call = RetrofitClient.getApiInterface(context)
|
||||
.markNotificationThreadAsRead(instanceToken, notificationThread.getId(), notificationStatus.name());
|
||||
|
||||
if(!call.execute().isSuccessful()) {
|
||||
@ -48,7 +46,7 @@ public class NotificationsActions {
|
||||
|
||||
public boolean setAllNotificationsRead(Date date) throws IOException {
|
||||
|
||||
Call<ResponseBody> call = RetrofitClient.getInstance(instanceUrl, context).getApiInterface()
|
||||
Call<ResponseBody> call = RetrofitClient.getApiInterface(context)
|
||||
.markNotificationThreadsAsRead(instanceToken, AppUtil.getTimestampFromDate(context, date), true,
|
||||
new String[]{"unread", "pinned"}, "read");
|
||||
|
||||
|
@ -21,10 +21,8 @@ public class RepositoryActions {
|
||||
|
||||
public static void starRepository(final Context context) {
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(context);
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
final TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
final String repoOwner = parts[0];
|
||||
@ -33,9 +31,8 @@ public class RepositoryActions {
|
||||
Call<JsonElement> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl, context)
|
||||
.getApiInterface()
|
||||
.starRepository(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName);
|
||||
.getApiInterface(context)
|
||||
.starRepository(Authorization.get(context), repoOwner, repoName);
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
|
||||
@ -86,10 +83,8 @@ public class RepositoryActions {
|
||||
|
||||
public static void unStarRepository(final Context context) {
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(context);
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
final TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
final String repoOwner = parts[0];
|
||||
@ -98,9 +93,8 @@ public class RepositoryActions {
|
||||
Call<JsonElement> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl, context)
|
||||
.getApiInterface()
|
||||
.unStarRepository(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName);
|
||||
.getApiInterface(context)
|
||||
.unStarRepository(Authorization.get(context), repoOwner, repoName);
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
|
||||
@ -151,10 +145,8 @@ public class RepositoryActions {
|
||||
|
||||
public static void watchRepository(final Context context) {
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(context);
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
final TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
final String repoOwner = parts[0];
|
||||
@ -163,9 +155,8 @@ public class RepositoryActions {
|
||||
Call<JsonElement> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl, context)
|
||||
.getApiInterface()
|
||||
.watchRepository(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName);
|
||||
.getApiInterface(context)
|
||||
.watchRepository(Authorization.get(context), repoOwner, repoName);
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
|
||||
@ -216,10 +207,8 @@ public class RepositoryActions {
|
||||
|
||||
public static void unWatchRepository(final Context context) {
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(context);
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
final TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
final String repoOwner = parts[0];
|
||||
@ -228,9 +217,8 @@ public class RepositoryActions {
|
||||
Call<JsonElement> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl, context)
|
||||
.getApiInterface()
|
||||
.unWatchRepository(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName);
|
||||
.getApiInterface(context)
|
||||
.unWatchRepository(Authorization.get(context), repoOwner, repoName);
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
|
||||
|
@ -21,17 +21,13 @@ public class TeamActions {
|
||||
|
||||
public static void removeTeamMember(final Context context, String userName, int teamId) {
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(context);
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
final TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
|
||||
Call<JsonElement> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl, context)
|
||||
.getApiInterface()
|
||||
.removeTeamMember(Authorization.returnAuthentication(context, loginUid, instanceToken), teamId, userName);
|
||||
.getApiInterface(context)
|
||||
.removeTeamMember(Authorization.get(context), teamId, userName);
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
|
||||
@ -87,17 +83,11 @@ public class TeamActions {
|
||||
|
||||
public static void addTeamMember(final Context context, String userName, int teamId) {
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(context);
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
final TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
|
||||
Call<JsonElement> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl, context)
|
||||
.getApiInterface()
|
||||
.addTeamMember(Authorization.returnAuthentication(context, loginUid, instanceToken), teamId, userName);
|
||||
Call<JsonElement> call = RetrofitClient
|
||||
.getApiInterface(context)
|
||||
.addTeamMember(Authorization.get(context), teamId, userName);
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
|
||||
|
@ -17,7 +17,6 @@ import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.UserSearchAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.models.UserInfo;
|
||||
import org.mian.gitnex.models.UserSearch;
|
||||
import java.util.List;
|
||||
@ -32,8 +31,6 @@ import retrofit2.Response;
|
||||
public class AddCollaboratorToRepositoryActivity extends BaseActivity {
|
||||
|
||||
private View.OnClickListener onClickListener;
|
||||
final Context ctx = this;
|
||||
private Context appCtx;
|
||||
private TextView addCollaboratorSearch;
|
||||
private TextView noData;
|
||||
private ProgressBar mProgressBar;
|
||||
@ -49,17 +46,9 @@ public class AddCollaboratorToRepositoryActivity extends BaseActivity {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
ImageView closeActivity = findViewById(R.id.close);
|
||||
addCollaboratorSearch = findViewById(R.id.addCollaboratorSearch);
|
||||
mRecyclerView = findViewById(R.id.recyclerViewUserSearch);
|
||||
@ -80,7 +69,7 @@ public class AddCollaboratorToRepositoryActivity extends BaseActivity {
|
||||
if(!addCollaboratorSearch.getText().toString().equals("")) {
|
||||
|
||||
mProgressBar.setVisibility(View.VISIBLE);
|
||||
loadUserSearchList(instanceUrl, instanceToken, addCollaboratorSearch.getText().toString(), loginUid);
|
||||
loadUserSearchList(addCollaboratorSearch.getText().toString());
|
||||
}
|
||||
}
|
||||
|
||||
@ -90,12 +79,11 @@ public class AddCollaboratorToRepositoryActivity extends BaseActivity {
|
||||
|
||||
}
|
||||
|
||||
public void loadUserSearchList(String instanceUrl, String token, String searchKeyword, String loginUid) {
|
||||
public void loadUserSearchList(String searchKeyword) {
|
||||
|
||||
Call<UserSearch> call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.getUserBySearch(Authorization.returnAuthentication(ctx, loginUid, token), searchKeyword, 10);
|
||||
.getApiInterface(appCtx)
|
||||
.getUserBySearch(Authorization.get(ctx), searchKeyword, 10);
|
||||
|
||||
call.enqueue(new Callback<UserSearch>() {
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Bundle;
|
||||
@ -15,7 +14,6 @@ import org.mian.gitnex.database.api.UserAccountsApi;
|
||||
import org.mian.gitnex.databinding.ActivityAddNewAccountBinding;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
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;
|
||||
@ -32,10 +30,6 @@ import retrofit2.Callback;
|
||||
|
||||
public class AddNewAccountActivity extends BaseActivity {
|
||||
|
||||
final Context ctx = this;
|
||||
private Context appCtx;
|
||||
private TinyDB tinyDB;
|
||||
|
||||
private View.OnClickListener onClickListener;
|
||||
private ActivityAddNewAccountBinding viewBinding;
|
||||
|
||||
@ -52,8 +46,6 @@ public class AddNewAccountActivity extends BaseActivity {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
tinyDB = new TinyDB(appCtx);
|
||||
|
||||
viewBinding = ActivityAddNewAccountBinding.inflate(getLayoutInflater());
|
||||
View view = viewBinding.getRoot();
|
||||
@ -131,7 +123,7 @@ public class AddNewAccountActivity extends BaseActivity {
|
||||
|
||||
Call<GiteaVersion> callVersion;
|
||||
|
||||
callVersion = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().getGiteaVersionWithToken("token " + loginToken);
|
||||
callVersion = RetrofitClient.getApiInterface(ctx).getGiteaVersionWithToken("token " + loginToken);
|
||||
|
||||
callVersion.enqueue(new Callback<GiteaVersion>() {
|
||||
|
||||
@ -205,7 +197,7 @@ public class AddNewAccountActivity extends BaseActivity {
|
||||
|
||||
private void setupNewAccountWithToken(String instanceUrl, final String loginToken) {
|
||||
|
||||
Call<UserInfo> call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().getUserInfo("token " + loginToken);
|
||||
Call<UserInfo> call = RetrofitClient.getApiInterface(ctx).getUserInfo("token " + loginToken);
|
||||
|
||||
call.enqueue(new Callback<UserInfo>() {
|
||||
|
||||
|
@ -18,7 +18,6 @@ import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.UserSearchForTeamMemberAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.models.UserInfo;
|
||||
import org.mian.gitnex.models.UserSearch;
|
||||
import java.util.ArrayList;
|
||||
@ -35,8 +34,6 @@ import retrofit2.Response;
|
||||
public class AddNewTeamMemberActivity extends BaseActivity {
|
||||
|
||||
private View.OnClickListener onClickListener;
|
||||
final Context ctx = this;
|
||||
private Context appCtx;
|
||||
private TextView addNewTeamMember;
|
||||
private TextView noData;
|
||||
private ProgressBar mProgressBar;
|
||||
@ -56,17 +53,9 @@ public class AddNewTeamMemberActivity extends BaseActivity {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
ImageView closeActivity = findViewById(R.id.close);
|
||||
addNewTeamMember = findViewById(R.id.addNewTeamMember);
|
||||
mRecyclerView = findViewById(R.id.recyclerViewUserSearch);
|
||||
@ -105,7 +94,7 @@ public class AddNewTeamMemberActivity extends BaseActivity {
|
||||
if(!addNewTeamMember.getText().toString().equals("") && addNewTeamMember.getText().toString().length() > 1) {
|
||||
|
||||
adapter = new UserSearchForTeamMemberAdapter(dataList, ctx, Integer.parseInt(teamId));
|
||||
loadUserSearchList(instanceUrl, instanceToken, addNewTeamMember.getText().toString(), loginUid, teamId);
|
||||
loadUserSearchList(addNewTeamMember.getText().toString(), teamId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,9 +110,9 @@ public class AddNewTeamMemberActivity extends BaseActivity {
|
||||
|
||||
}
|
||||
|
||||
public void loadUserSearchList(String instanceUrl, String token, String searchKeyword, String loginUid, String teamId) {
|
||||
public void loadUserSearchList(String searchKeyword, String teamId) {
|
||||
|
||||
Call<UserSearch> call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().getUserBySearch(Authorization.returnAuthentication(ctx, loginUid, token), searchKeyword, 10);
|
||||
Call<UserSearch> call = RetrofitClient.getApiInterface(ctx).getUserBySearch(Authorization.get(ctx), searchKeyword, 10);
|
||||
|
||||
mProgressBar.setVisibility(View.VISIBLE);
|
||||
|
||||
|
@ -24,7 +24,6 @@ import org.mian.gitnex.adapters.AdminGetUsersAdapter;
|
||||
import org.mian.gitnex.fragments.BottomSheetAdminUsersFragment;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.viewmodels.AdminGetUsersViewModel;
|
||||
|
||||
/**
|
||||
@ -34,8 +33,6 @@ import org.mian.gitnex.viewmodels.AdminGetUsersViewModel;
|
||||
public class AdminGetUsersActivity extends BaseActivity implements BottomSheetAdminUsersFragment.BottomSheetListener {
|
||||
|
||||
private View.OnClickListener onClickListener;
|
||||
final Context ctx = this;
|
||||
private Context appCtx;
|
||||
private AdminGetUsersAdapter adapter;
|
||||
private RecyclerView mRecyclerView;
|
||||
private TextView noDataUsers;
|
||||
@ -50,12 +47,6 @@ public class AdminGetUsersActivity extends BaseActivity implements BottomSheetAd
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
ImageView closeActivity = findViewById(R.id.close);
|
||||
noDataUsers = findViewById(R.id.noDataUsers);
|
||||
@ -79,19 +70,19 @@ public class AdminGetUsersActivity extends BaseActivity implements BottomSheetAd
|
||||
swipeRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
|
||||
swipeRefresh.setRefreshing(false);
|
||||
AdminGetUsersViewModel.loadUsersList(ctx, instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken));
|
||||
AdminGetUsersViewModel.loadUsersList(ctx, Authorization.get(ctx));
|
||||
|
||||
}, 500));
|
||||
|
||||
fetchDataAsync(ctx, instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken));
|
||||
fetchDataAsync(ctx, Authorization.get(ctx));
|
||||
|
||||
}
|
||||
|
||||
private void fetchDataAsync(Context ctx, String instanceUrl, String instanceToken) {
|
||||
private void fetchDataAsync(Context ctx, String instanceToken) {
|
||||
|
||||
AdminGetUsersViewModel usersModel = new ViewModelProvider(this).get(AdminGetUsersViewModel.class);
|
||||
|
||||
usersModel.getUsersList(ctx, instanceUrl, instanceToken).observe(this, usersListMain -> {
|
||||
usersModel.getUsersList(ctx, instanceToken).observe(this, usersListMain -> {
|
||||
|
||||
adapter = new AdminGetUsersAdapter(ctx, usersListMain);
|
||||
if(adapter.getItemCount() > 0) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
@ -25,6 +26,7 @@ import static org.acra.ReportField.STACK_TRACE;
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
@SuppressLint("NonConstantResourceId")
|
||||
@AcraNotification(resIcon = R.drawable.gitnex_transparent,
|
||||
resTitle = R.string.crashTitle,
|
||||
resChannelName = R.string.setCrashReports,
|
||||
@ -33,120 +35,127 @@ import static org.acra.ReportField.STACK_TRACE;
|
||||
|
||||
public abstract class BaseActivity extends AppCompatActivity {
|
||||
|
||||
protected TinyDB tinyDB;
|
||||
|
||||
protected Context ctx = this;
|
||||
protected Context appCtx;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
Context appCtx = getApplicationContext();
|
||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
||||
this.appCtx = getApplicationContext();
|
||||
this.tinyDB = TinyDB.getInstance(appCtx);
|
||||
|
||||
switch(tinyDb.getInt("themeId")) {
|
||||
switch(tinyDB.getInt("themeId")) {
|
||||
|
||||
case 1:
|
||||
|
||||
tinyDB.putString("currentTheme", "light");
|
||||
setTheme(R.style.AppThemeLight);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
|
||||
if(TimeHelper.timeBetweenHours(18, 6)) { // 6pm to 6am
|
||||
|
||||
tinyDB.putString("currentTheme", "dark");
|
||||
setTheme(R.style.AppTheme);
|
||||
}
|
||||
else {
|
||||
|
||||
} else {
|
||||
tinyDB.putString("currentTheme", "light");
|
||||
setTheme(R.style.AppThemeLight);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
|
||||
case 3:
|
||||
tinyDB.putString("currentTheme", "light");
|
||||
setTheme(R.style.AppThemeRetro);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
|
||||
if(TimeHelper.timeBetweenHours(18, 6)) { // 6pm to 6am
|
||||
|
||||
tinyDB.putString("currentTheme", "dark");
|
||||
setTheme(R.style.AppTheme);
|
||||
}
|
||||
else {
|
||||
|
||||
} else {
|
||||
tinyDB.putString("currentTheme", "light");
|
||||
setTheme(R.style.AppThemeRetro);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
||||
default:
|
||||
tinyDB.putString("currentTheme", "dark");
|
||||
setTheme(R.style.AppTheme);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
String appLocale = tinyDb.getString("locale");
|
||||
String appLocale = tinyDB.getString("locale");
|
||||
AppUtil.setAppLocale(getResources(), appLocale);
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(getLayoutResourceId());
|
||||
|
||||
switch(tinyDb.getInt("customFontId", -1)) {
|
||||
// FIXME Performance nightmare
|
||||
switch(tinyDB.getInt("customFontId", -1)) {
|
||||
|
||||
case 0:
|
||||
|
||||
FontsOverride.setDefaultFont(this, "DEFAULT", "fonts/roboto.ttf");
|
||||
FontsOverride.setDefaultFont(this, "MONOSPACE", "fonts/roboto.ttf");
|
||||
FontsOverride.setDefaultFont(this, "SERIF", "fonts/roboto.ttf");
|
||||
FontsOverride.setDefaultFont(this, "SANS_SERIF", "fonts/roboto.ttf");
|
||||
break;
|
||||
case 2:
|
||||
|
||||
case 2:
|
||||
FontsOverride.setDefaultFont(this, "DEFAULT", "fonts/sourcecodeproregular.ttf");
|
||||
FontsOverride.setDefaultFont(this, "MONOSPACE", "fonts/sourcecodeproregular.ttf");
|
||||
FontsOverride.setDefaultFont(this, "SERIF", "fonts/sourcecodeproregular.ttf");
|
||||
FontsOverride.setDefaultFont(this, "SANS_SERIF", "fonts/sourcecodeproregular.ttf");
|
||||
break;
|
||||
default:
|
||||
|
||||
default:
|
||||
FontsOverride.setDefaultFont(this, "DEFAULT", "fonts/manroperegular.ttf");
|
||||
FontsOverride.setDefaultFont(this, "MONOSPACE", "fonts/manroperegular.ttf");
|
||||
FontsOverride.setDefaultFont(this, "SERIF", "fonts/manroperegular.ttf");
|
||||
FontsOverride.setDefaultFont(this, "SANS_SERIF", "fonts/manroperegular.ttf");
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if(tinyDb.getInt("pollingDelayMinutes") == 0) {
|
||||
if(tinyDB.getInt("pollingDelayMinutes") == 0) {
|
||||
|
||||
tinyDb.putInt("pollingDelayMinutes", 15);
|
||||
tinyDB.putInt("pollingDelayMinutes", 15);
|
||||
}
|
||||
|
||||
// FIXME Performance nightmare
|
||||
NotificationsMaster.hireWorker(appCtx);
|
||||
|
||||
// enabling counter badges by default
|
||||
if(tinyDb.getString("enableCounterBadgesInit").isEmpty()) {
|
||||
if(tinyDB.getString("enableCounterBadgesInit").isEmpty()) {
|
||||
|
||||
tinyDb.putBoolean("enableCounterBadges", true);
|
||||
tinyDb.putString("enableCounterBadgesInit", "yes");
|
||||
tinyDB.putBoolean("enableCounterBadges", true);
|
||||
tinyDB.putString("enableCounterBadgesInit", "yes");
|
||||
}
|
||||
|
||||
// enable crash reports by default
|
||||
if(tinyDb.getString("crashReportingEnabledInit").isEmpty()) {
|
||||
if(tinyDB.getString("crashReportingEnabledInit").isEmpty()) {
|
||||
|
||||
tinyDb.putBoolean("crashReportingEnabled", true);
|
||||
tinyDb.putString("crashReportingEnabledInit", "yes");
|
||||
tinyDB.putBoolean("crashReportingEnabled", true);
|
||||
tinyDB.putString("crashReportingEnabledInit", "yes");
|
||||
}
|
||||
|
||||
// default cache setter
|
||||
if(tinyDb.getString("cacheSizeStr").isEmpty()) {
|
||||
if(tinyDB.getString("cacheSizeStr").isEmpty()) {
|
||||
|
||||
tinyDb.putString("cacheSizeStr", getResources().getString(R.string.cacheSizeDataSelectionSelectedText));
|
||||
tinyDB.putString("cacheSizeStr", getResources().getString(R.string.cacheSizeDataSelectionSelectedText));
|
||||
}
|
||||
if(tinyDb.getString("cacheSizeImagesStr").isEmpty()) {
|
||||
if(tinyDB.getString("cacheSizeImagesStr").isEmpty()) {
|
||||
|
||||
tinyDb.putString("cacheSizeImagesStr", getResources().getString(R.string.cacheSizeImagesSelectionSelectedText));
|
||||
tinyDB.putString("cacheSizeImagesStr", getResources().getString(R.string.cacheSizeImagesSelectionSelectedText));
|
||||
}
|
||||
|
||||
// enable comment drafts by default
|
||||
if(tinyDb.getString("draftsCommentsDeletionEnabledInit").isEmpty()) {
|
||||
if(tinyDB.getString("draftsCommentsDeletionEnabledInit").isEmpty()) {
|
||||
|
||||
tinyDb.putBoolean("draftsCommentsDeletionEnabled", true);
|
||||
tinyDb.putString("draftsCommentsDeletionEnabledInit", "yes");
|
||||
tinyDB.putBoolean("draftsCommentsDeletionEnabled", true);
|
||||
tinyDB.putString("draftsCommentsDeletionEnabledInit", "yes");
|
||||
}
|
||||
|
||||
if (tinyDb.getBoolean("crashReportingEnabled")) {
|
||||
// FIXME Performance nightmare
|
||||
if (tinyDB.getBoolean("crashReportingEnabled")) {
|
||||
|
||||
CoreConfigurationBuilder ACRABuilder = new CoreConfigurationBuilder(this);
|
||||
ACRABuilder.setBuildConfigClass(BuildConfig.class).setReportFormat(StringFormat.KEY_VALUE_LIST);
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
@ -21,13 +20,11 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.CommitsAdapter;
|
||||
import org.mian.gitnex.clients.AppApiService;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.StaticGlobalVariables;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import org.mian.gitnex.interfaces.ApiInterface;
|
||||
import org.mian.gitnex.models.Commits;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -41,8 +38,6 @@ import retrofit2.Response;
|
||||
|
||||
public class CommitsActivity extends BaseActivity {
|
||||
|
||||
final Context ctx = this;
|
||||
private Context appCtx;
|
||||
private View.OnClickListener onClickListener;
|
||||
private TextView noData;
|
||||
private ProgressBar progressBar;
|
||||
@ -53,7 +48,6 @@ public class CommitsActivity extends BaseActivity {
|
||||
private RecyclerView recyclerView;
|
||||
private List<Commits> commitsList;
|
||||
private CommitsAdapter adapter;
|
||||
private ApiInterface api;
|
||||
private ProgressBar progressLoadMore;
|
||||
|
||||
@Override
|
||||
@ -66,15 +60,10 @@ public class CommitsActivity extends BaseActivity {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String repoFullName = tinyDB.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
@ -95,7 +84,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(new Version(tinyDB.getString("giteaVersion")).higherOrEqual("1.12")) {
|
||||
|
||||
resultLimit = StaticGlobalVariables.resultLimitNewGiteaInstances;
|
||||
}
|
||||
@ -106,7 +95,7 @@ public class CommitsActivity extends BaseActivity {
|
||||
swipeRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
|
||||
swipeRefresh.setRefreshing(false);
|
||||
loadInitial(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, branchName, resultLimit);
|
||||
loadInitial(Authorization.get(ctx), repoOwner, repoName, branchName, resultLimit);
|
||||
adapter.notifyDataChanged();
|
||||
}, 200));
|
||||
|
||||
@ -116,7 +105,7 @@ public class CommitsActivity extends BaseActivity {
|
||||
if(commitsList.size() == resultLimit || pageSize == resultLimit) {
|
||||
|
||||
int page = (commitsList.size() + resultLimit) / resultLimit;
|
||||
loadMore(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, page, branchName, resultLimit);
|
||||
loadMore(Authorization.get(ctx), repoOwner, repoName, page, branchName, resultLimit);
|
||||
}
|
||||
}));
|
||||
|
||||
@ -124,13 +113,12 @@ public class CommitsActivity extends BaseActivity {
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(ctx));
|
||||
recyclerView.setAdapter(adapter);
|
||||
|
||||
api = AppApiService.createService(ApiInterface.class, instanceUrl, ctx);
|
||||
loadInitial(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, branchName, resultLimit);
|
||||
loadInitial(Authorization.get(ctx), repoOwner, repoName, branchName, resultLimit);
|
||||
}
|
||||
|
||||
private void loadInitial(String token, String repoOwner, String repoName, String branchName, int resultLimit) {
|
||||
|
||||
Call<List<Commits>> call = api.getRepositoryCommits(token, repoOwner, repoName, 1, branchName, resultLimit);
|
||||
Call<List<Commits>> call = RetrofitClient.getApiInterface(ctx).getRepositoryCommits(token, repoOwner, repoName, 1, branchName, resultLimit);
|
||||
|
||||
call.enqueue(new Callback<List<Commits>>() {
|
||||
|
||||
@ -180,7 +168,7 @@ public class CommitsActivity extends BaseActivity {
|
||||
|
||||
progressLoadMore.setVisibility(View.VISIBLE);
|
||||
|
||||
Call<List<Commits>> call = api.getRepositoryCommits(token, repoOwner, repoName, page, branchName, resultLimit);
|
||||
Call<List<Commits>> call = RetrofitClient.getApiInterface(ctx).getRepositoryCommits(token, repoOwner, repoName, page, branchName, resultLimit);
|
||||
|
||||
call.enqueue(new Callback<List<Commits>>() {
|
||||
|
||||
|
@ -20,7 +20,6 @@ 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.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.models.Branches;
|
||||
import org.mian.gitnex.models.DeleteFile;
|
||||
@ -49,13 +48,9 @@ public class CreateFileActivity extends BaseActivity {
|
||||
private String filePath;
|
||||
private String fileSha;
|
||||
private int fileAction = 0; // 0 = create, 1 = delete, 2 = edit
|
||||
final Context ctx = this;
|
||||
private Context appCtx;
|
||||
private TinyDB tinyDb;
|
||||
|
||||
List<Branches> branchesList = new ArrayList<>();
|
||||
|
||||
private String instanceUrl;
|
||||
private String loginUid;
|
||||
private String repoOwner;
|
||||
private String repoName;
|
||||
@ -73,20 +68,17 @@ public class CreateFileActivity extends BaseActivity {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
tinyDb = new TinyDB(appCtx);
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
instanceUrl = tinyDb.getString("instanceUrl");
|
||||
loginUid = tinyDb.getString("loginUid");
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
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");
|
||||
instanceToken = "token " + tinyDB.getString(loginUid + "-token");
|
||||
|
||||
closeActivity = findViewById(R.id.close);
|
||||
newFileName = findViewById(R.id.newFileName);
|
||||
@ -157,7 +149,7 @@ public class CreateFileActivity extends BaseActivity {
|
||||
closeActivity.setOnClickListener(onClickListener);
|
||||
|
||||
newFileBranchesSpinner = findViewById(R.id.newFileBranchesSpinner);
|
||||
getBranches(instanceUrl, instanceToken, repoOwner, repoName, loginUid);
|
||||
getBranches(instanceToken, repoOwner, repoName, loginUid);
|
||||
|
||||
disableProcessButton();
|
||||
|
||||
@ -224,17 +216,17 @@ public class CreateFileActivity extends BaseActivity {
|
||||
|
||||
if(fileAction == 1) {
|
||||
|
||||
deleteFile(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, filePath,
|
||||
deleteFile(Authorization.get(ctx), repoOwner, repoName, filePath,
|
||||
newFileBranchName_, newFileCommitMessage_, selectedBranch, fileSha);
|
||||
}
|
||||
else if(fileAction == 2) {
|
||||
|
||||
editFile(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, filePath,
|
||||
editFile(Authorization.get(ctx), repoOwner, repoName, filePath,
|
||||
appUtil.encodeBase64(newFileContent_), newFileBranchName_, newFileCommitMessage_, selectedBranch, fileSha);
|
||||
}
|
||||
else {
|
||||
|
||||
createNewFile(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, newFileName_,
|
||||
createNewFile(Authorization.get(ctx), repoOwner, repoName, newFileName_,
|
||||
appUtil.encodeBase64(newFileContent_), newFileBranchName_, newFileCommitMessage_, selectedBranch);
|
||||
}
|
||||
|
||||
@ -242,7 +234,7 @@ public class CreateFileActivity extends BaseActivity {
|
||||
|
||||
}
|
||||
|
||||
private void createNewFile(final String instanceUrl, final String token, String repoOwner, String repoName, String fileName, String fileContent, String fileBranchName, String fileCommitMessage, String currentBranch) {
|
||||
private void createNewFile(final String token, String repoOwner, String repoName, String fileName, String fileContent, String fileBranchName, String fileCommitMessage, String currentBranch) {
|
||||
|
||||
NewFile createNewFileJsonStr;
|
||||
if(currentBranch.equals("No branch")) {
|
||||
@ -255,8 +247,7 @@ public class CreateFileActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
Call<JsonElement> call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.getApiInterface(ctx)
|
||||
.createNewFile(token, repoOwner, repoName, fileName, createNewFileJsonStr);
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
@ -303,7 +294,7 @@ public class CreateFileActivity extends BaseActivity {
|
||||
|
||||
}
|
||||
|
||||
private void deleteFile(final String instanceUrl, final String token, String repoOwner, String repoName, String fileName, String fileBranchName, String fileCommitMessage, String currentBranch, String fileSha) {
|
||||
private void deleteFile(final String token, String repoOwner, String repoName, String fileName, String fileBranchName, String fileCommitMessage, String currentBranch, String fileSha) {
|
||||
|
||||
String branchName;
|
||||
DeleteFile deleteFileJsonStr;
|
||||
@ -320,8 +311,7 @@ public class CreateFileActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
Call<JsonElement> call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.getApiInterface(ctx)
|
||||
.deleteFile(token, repoOwner, repoName, fileName, deleteFileJsonStr);
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
@ -371,7 +361,7 @@ public class CreateFileActivity extends BaseActivity {
|
||||
|
||||
}
|
||||
|
||||
private void editFile(final String instanceUrl, final String token, String repoOwner, String repoName, String fileName, String fileContent, String fileBranchName, String fileCommitMessage, String currentBranch, String fileSha) {
|
||||
private void editFile(final String token, String repoOwner, String repoName, String fileName, String fileContent, String fileBranchName, String fileCommitMessage, String currentBranch, String fileSha) {
|
||||
|
||||
String branchName;
|
||||
EditFile editFileJsonStr;
|
||||
@ -388,8 +378,7 @@ public class CreateFileActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
Call<JsonElement> call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.getApiInterface(ctx)
|
||||
.editFile(token, repoOwner, repoName, fileName, editFileJsonStr);
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
@ -404,7 +393,7 @@ public class CreateFileActivity extends BaseActivity {
|
||||
getIntent().removeExtra("filePath");
|
||||
getIntent().removeExtra("fileSha");
|
||||
getIntent().removeExtra("fileContents");
|
||||
tinyDb.putBoolean("fileModified", true);
|
||||
tinyDB.putBoolean("fileModified", true);
|
||||
finish();
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
@ -440,12 +429,11 @@ public class CreateFileActivity extends BaseActivity {
|
||||
|
||||
}
|
||||
|
||||
private void getBranches(String instanceUrl, String instanceToken, String repoOwner, String repoName, String loginUid) {
|
||||
private void getBranches(String instanceToken, String repoOwner, String repoName, String loginUid) {
|
||||
|
||||
Call<List<Branches>> call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.getBranches(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName);
|
||||
.getApiInterface(ctx)
|
||||
.getBranches(Authorization.get(ctx), repoOwner, repoName);
|
||||
|
||||
call.enqueue(new Callback<List<Branches>>() {
|
||||
|
||||
|
@ -51,9 +51,6 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
||||
private CustomLabelsSelectionDialogBinding labelsBinding;
|
||||
private CustomAssigneesSelectionDialogBinding assigneesBinding;
|
||||
private View.OnClickListener onClickListener;
|
||||
final Context ctx = this;
|
||||
private Context appCtx;
|
||||
private TinyDB tinyDb;
|
||||
private int resultLimit = StaticGlobalVariables.resultLimitOldGiteaInstances;
|
||||
private Dialog dialogLabels;
|
||||
private Dialog dialogAssignees;
|
||||
@ -61,9 +58,7 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
||||
private String assigneesSetter;
|
||||
private int milestoneId;
|
||||
|
||||
private String instanceUrl;
|
||||
private String loginUid;
|
||||
private String instanceToken;
|
||||
private String repoOwner;
|
||||
private String repoName;
|
||||
|
||||
@ -86,8 +81,6 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
tinyDb = new TinyDB(appCtx);
|
||||
|
||||
viewBinding = ActivityCreateIssueBinding.inflate(getLayoutInflater());
|
||||
View view = viewBinding.getRoot();
|
||||
@ -97,17 +90,14 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
instanceUrl = tinyDb.getString("instanceUrl");
|
||||
loginUid = tinyDb.getString("loginUid");
|
||||
final String loginFullName = tinyDb.getString("userFullname");
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
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");
|
||||
|
||||
// require gitea 1.12 or higher
|
||||
if(new Version(tinyDb.getString("giteaVersion")).higherOrEqual("1.12.0")) {
|
||||
if(new Version(tinyDB.getString("giteaVersion")).higherOrEqual("1.12.0")) {
|
||||
|
||||
resultLimit = StaticGlobalVariables.resultLimitNewGiteaInstances;
|
||||
}
|
||||
@ -137,7 +127,7 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
||||
viewBinding.newIssueLabels.setOnClickListener(this);
|
||||
viewBinding.newIssueDueDate.setOnClickListener(this);
|
||||
|
||||
getMilestones(instanceUrl, instanceToken, repoOwner, repoName, loginUid, resultLimit);
|
||||
getMilestones(repoOwner, repoName, resultLimit);
|
||||
|
||||
disableProcessButton();
|
||||
|
||||
@ -194,7 +184,7 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
||||
assigneesBinding.cancel.setOnClickListener(assigneesBinding_ -> dialogAssignees.dismiss());
|
||||
|
||||
dialogAssignees.show();
|
||||
AssigneesActions.getRepositoryAssignees(ctx, instanceUrl, instanceToken, repoOwner, repoName, assigneesList, dialogAssignees, assigneesAdapter, assigneesBinding);
|
||||
AssigneesActions.getRepositoryAssignees(ctx, repoOwner, repoName, assigneesList, dialogAssignees, assigneesAdapter, assigneesBinding);
|
||||
}
|
||||
|
||||
private void showLabels() {
|
||||
@ -214,7 +204,7 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
||||
labelsBinding.cancel.setOnClickListener(labelsBinding_ -> dialogLabels.dismiss());
|
||||
|
||||
dialogLabels.show();
|
||||
LabelsActions.getRepositoryLabels(ctx, instanceUrl, instanceToken, repoOwner, repoName, labelsList, dialogLabels, labelsAdapter, labelsBinding);
|
||||
LabelsActions.getRepositoryLabels(ctx, repoOwner, repoName, labelsList, dialogLabels, labelsAdapter, labelsBinding);
|
||||
}
|
||||
|
||||
private void processNewIssue() {
|
||||
@ -247,19 +237,18 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
||||
}
|
||||
|
||||
disableProcessButton();
|
||||
createNewIssueFunc(instanceUrl, instanceToken, repoOwner, repoName, loginUid, newIssueDescriptionForm, newIssueDueDateForm, milestoneId, newIssueTitleForm);
|
||||
createNewIssueFunc(repoOwner, repoName, loginUid, newIssueDescriptionForm, newIssueDueDateForm, milestoneId, newIssueTitleForm);
|
||||
}
|
||||
|
||||
private void createNewIssueFunc(final String instanceUrl, final String instanceToken, String repoOwner, String repoName, String loginUid, String newIssueDescriptionForm, String newIssueDueDateForm, int newIssueMilestoneIdForm, String newIssueTitleForm) {
|
||||
private void createNewIssueFunc(String repoOwner, String repoName, String loginUid, String newIssueDescriptionForm, String newIssueDueDateForm, int newIssueMilestoneIdForm, String newIssueTitleForm) {
|
||||
|
||||
CreateIssue createNewIssueJson = new CreateIssue(loginUid, newIssueDescriptionForm, false, newIssueDueDateForm, newIssueMilestoneIdForm, newIssueTitleForm, assigneesListData, labelsIds);
|
||||
|
||||
Call<JsonElement> call3;
|
||||
|
||||
call3 = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.createNewIssue(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, createNewIssueJson);
|
||||
.getApiInterface(ctx)
|
||||
.createNewIssue(Authorization.get(ctx), repoOwner, repoName, createNewIssueJson);
|
||||
|
||||
call3.enqueue(new Callback<JsonElement>() {
|
||||
|
||||
@ -268,7 +257,7 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
||||
|
||||
if(response2.code() == 201) {
|
||||
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||
tinyDb.putBoolean("resumeIssues", true);
|
||||
|
||||
Toasty.success(ctx, getString(R.string.issueCreated));
|
||||
@ -306,13 +295,12 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
||||
onClickListener = view -> finish();
|
||||
}
|
||||
|
||||
private void getMilestones(String instanceUrl, String instanceToken, String repoOwner, String repoName, String loginUid, int resultLimit) {
|
||||
private void getMilestones(String repoOwner, String repoName, int resultLimit) {
|
||||
|
||||
String msState = "open";
|
||||
Call<List<Milestones>> call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.getMilestones(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, 1, resultLimit, msState);
|
||||
.getApiInterface(ctx)
|
||||
.getMilestones(Authorization.get(ctx), repoOwner, repoName, 1, resultLimit, msState);
|
||||
|
||||
call.enqueue(new Callback<List<Milestones>>() {
|
||||
|
||||
|
@ -10,11 +10,9 @@ import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.ColorInt;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import com.pes.androidmaterialcolorpickerdialog.ColorPicker;
|
||||
import com.pes.androidmaterialcolorpickerdialog.ColorPickerCallback;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
@ -39,8 +37,6 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
private TextView colorPicker;
|
||||
private EditText labelName;
|
||||
private Button createLabelButton;
|
||||
final Context ctx = this;
|
||||
private Context appCtx;
|
||||
|
||||
@Override
|
||||
protected int getLayoutResourceId(){
|
||||
@ -51,22 +47,20 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
||||
final TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
if(getIntent().getStringExtra("labelAction") != null && Objects.requireNonNull(getIntent().getStringExtra("labelAction")).equals("delete")) {
|
||||
|
||||
deleteLabel(instanceUrl, instanceToken, repoOwner, repoName, Integer.parseInt(Objects.requireNonNull(getIntent().getStringExtra("labelId"))), loginUid);
|
||||
deleteLabel(instanceToken, repoOwner, repoName, Integer.parseInt(Objects.requireNonNull(getIntent().getStringExtra("labelId"))), loginUid);
|
||||
finish();
|
||||
return;
|
||||
|
||||
@ -129,14 +123,13 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
|
||||
private void processUpdateLabel() {
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
||||
final TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
AppUtil appUtil = new AppUtil();
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
@ -171,7 +164,7 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
disableProcessButton();
|
||||
patchLabel(instanceUrl, instanceToken, repoOwner, repoName, updateLabelName, updateLabelColor, Integer.parseInt(
|
||||
patchLabel(instanceToken, repoOwner, repoName, updateLabelName, updateLabelColor, Integer.parseInt(
|
||||
Objects.requireNonNull(getIntent().getStringExtra("labelId"))), loginUid);
|
||||
|
||||
}
|
||||
@ -180,12 +173,11 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
AppUtil appUtil = new AppUtil();
|
||||
TinyDB tinyDb = new TinyDB(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];
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
@ -220,20 +212,19 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
disableProcessButton();
|
||||
createNewLabel(instanceUrl, instanceToken, repoOwner, repoName, newLabelName, newLabelColor, loginUid);
|
||||
createNewLabel(instanceToken, repoOwner, repoName, newLabelName, newLabelColor, loginUid);
|
||||
}
|
||||
|
||||
private void createNewLabel(final String instanceUrl, final String instanceToken, String repoOwner, String repoName, String newLabelName, String newLabelColor, String loginUid) {
|
||||
private void createNewLabel(final String instanceToken, String repoOwner, String repoName, String newLabelName, String newLabelColor, String loginUid) {
|
||||
|
||||
CreateLabel createLabelFunc = new CreateLabel(newLabelName, newLabelColor);
|
||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
||||
final TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||
|
||||
Call<CreateLabel> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.createLabel(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, createLabelFunc);
|
||||
.getApiInterface(ctx)
|
||||
.createLabel(Authorization.get(ctx), repoOwner, repoName, createLabelFunc);
|
||||
|
||||
call.enqueue(new Callback<CreateLabel>() {
|
||||
|
||||
@ -274,17 +265,16 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
|
||||
}
|
||||
|
||||
private void patchLabel(final String instanceUrl, final String instanceToken, String repoOwner, String repoName, String updateLabelName, String updateLabelColor, int labelId, String loginUid) {
|
||||
private void patchLabel(final String instanceToken, String repoOwner, String repoName, String updateLabelName, String updateLabelColor, int labelId, String loginUid) {
|
||||
|
||||
CreateLabel createLabelFunc = new CreateLabel(updateLabelName, updateLabelColor);
|
||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
||||
final TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||
|
||||
Call<CreateLabel> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.patchLabel(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, labelId, createLabelFunc);
|
||||
.getApiInterface(appCtx)
|
||||
.patchLabel(Authorization.get(ctx), repoOwner, repoName, labelId, createLabelFunc);
|
||||
|
||||
call.enqueue(new Callback<CreateLabel>() {
|
||||
|
||||
@ -347,14 +337,13 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
};
|
||||
}
|
||||
|
||||
private void deleteLabel(final String instanceUrl, final String instanceToken, final String repoOwner, final String repoName, int labelId, String loginUid) {
|
||||
private void deleteLabel(final String instanceToken, final String repoOwner, final String repoName, int labelId, String loginUid) {
|
||||
|
||||
Call<Labels> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.deleteLabel(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, labelId);
|
||||
.getApiInterface(appCtx)
|
||||
.deleteLabel(Authorization.get(ctx), repoOwner, repoName, labelId);
|
||||
|
||||
call.enqueue(new Callback<Labels>() {
|
||||
|
||||
@ -366,7 +355,7 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
if(response.code() == 204) {
|
||||
|
||||
Toasty.success(ctx, getString(R.string.labelDeleteText));
|
||||
LabelsViewModel.loadLabelsList(instanceUrl, instanceToken, repoOwner, repoName, ctx);
|
||||
LabelsViewModel.loadLabelsList(instanceToken, repoOwner, repoName, ctx);
|
||||
getIntent().removeExtra("labelAction");
|
||||
getIntent().removeExtra("labelId");
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.DatePicker;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import androidx.annotation.NonNull;
|
||||
@ -37,8 +36,6 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
||||
private EditText milestoneTitle;
|
||||
private EditText milestoneDescription;
|
||||
private Button createNewMilestoneButton;
|
||||
final Context ctx = this;
|
||||
private Context appCtx;
|
||||
|
||||
@Override
|
||||
protected int getLayoutResourceId(){
|
||||
@ -50,7 +47,6 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
@ -98,14 +94,11 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
AppUtil appUtil = new AppUtil();
|
||||
TinyDB tinyDb = new TinyDB(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];
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
String newMilestoneTitle = milestoneTitle.getText().toString();
|
||||
String newMilestoneDescription = milestoneDescription.getText().toString();
|
||||
@ -146,18 +139,17 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
||||
}
|
||||
|
||||
disableProcessButton();
|
||||
createNewMilestone(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, newMilestoneTitle, newMilestoneDescription, finalMilestoneDueDate);
|
||||
createNewMilestone(Authorization.get(ctx), repoOwner, repoName, newMilestoneTitle, newMilestoneDescription, finalMilestoneDueDate);
|
||||
}
|
||||
|
||||
private void createNewMilestone(final String instanceUrl, final String token, String repoOwner, String repoName, String newMilestoneTitle, String newMilestoneDescription, String newMilestoneDueDate) {
|
||||
private void createNewMilestone(final String token, String repoOwner, String repoName, String newMilestoneTitle, String newMilestoneDescription, String newMilestoneDueDate) {
|
||||
|
||||
Milestones createMilestone = new Milestones(newMilestoneDescription, newMilestoneTitle, newMilestoneDueDate);
|
||||
|
||||
Call<Milestones> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.getApiInterface(appCtx)
|
||||
.createMilestone(token, repoOwner, repoName, createMilestone);
|
||||
|
||||
call.enqueue(new Callback<Milestones>() {
|
||||
@ -169,7 +161,7 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
||||
|
||||
if(response.code() == 201) {
|
||||
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||
tinyDb.putBoolean("milestoneCreated", true);
|
||||
Toasty.success(ctx, getString(R.string.milestoneCreated));
|
||||
enableProcessButton();
|
||||
|
@ -33,8 +33,6 @@ public class CreateNewUserActivity extends BaseActivity {
|
||||
private EditText userEmail;
|
||||
private EditText userPassword;
|
||||
private Button createUserButton;
|
||||
final Context ctx = this;
|
||||
private Context appCtx;
|
||||
|
||||
@Override
|
||||
protected int getLayoutResourceId(){
|
||||
@ -45,7 +43,6 @@ public class CreateNewUserActivity extends BaseActivity {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
@ -79,10 +76,7 @@ public class CreateNewUserActivity extends BaseActivity {
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
AppUtil appUtil = new AppUtil();
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||
|
||||
String newFullName = fullName.getText().toString().trim();
|
||||
String newUserName = userUserName.getText().toString().trim();
|
||||
@ -120,18 +114,17 @@ public class CreateNewUserActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
disableProcessButton();
|
||||
createNewUser(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), newFullName, newUserName, newUserEmail, newUserPassword);
|
||||
createNewUser(Authorization.get(ctx), newFullName, newUserName, newUserEmail, newUserPassword);
|
||||
}
|
||||
|
||||
private void createNewUser(final String instanceUrl, final String instanceToken, String newFullName, String newUserName, String newUserEmail, String newUserPassword) {
|
||||
private void createNewUser(final String instanceToken, String newFullName, String newUserName, String newUserEmail, String newUserPassword) {
|
||||
|
||||
UserInfo createUser = new UserInfo(newUserEmail, newFullName, newUserName, newUserPassword, newUserName, 0, true);
|
||||
|
||||
Call<UserInfo> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.getApiInterface(appCtx)
|
||||
.createNewUser(instanceToken, createUser);
|
||||
|
||||
call.enqueue(new Callback<UserInfo>() {
|
||||
|
@ -34,8 +34,6 @@ public class CreateOrganizationActivity extends BaseActivity {
|
||||
|
||||
private EditText orgName;
|
||||
private EditText orgDesc;
|
||||
final Context ctx = this;
|
||||
private Context appCtx;
|
||||
|
||||
@Override
|
||||
protected int getLayoutResourceId(){
|
||||
@ -47,7 +45,6 @@ public class CreateOrganizationActivity extends BaseActivity {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
@ -99,10 +96,7 @@ public class CreateOrganizationActivity extends BaseActivity {
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
AppUtil appUtil = new AppUtil();
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||
|
||||
String newOrgName = orgName.getText().toString();
|
||||
String newOrgDesc = orgDesc.getText().toString();
|
||||
@ -133,18 +127,17 @@ public class CreateOrganizationActivity extends BaseActivity {
|
||||
else {
|
||||
|
||||
disableProcessButton();
|
||||
createNewOrganization(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), newOrgName, newOrgDesc);
|
||||
createNewOrganization(Authorization.get(ctx), newOrgName, newOrgDesc);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void createNewOrganization(final String instanceUrl, final String token, String orgName, String orgDesc) {
|
||||
private void createNewOrganization(final String token, String orgName, String orgDesc) {
|
||||
|
||||
UserOrganizations createOrganization = new UserOrganizations(orgName, null, orgDesc, null, null);
|
||||
|
||||
Call<UserOrganizations> call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.getApiInterface(appCtx)
|
||||
.createNewOrganization(token, createOrganization);
|
||||
|
||||
call.enqueue(new Callback<UserOrganizations>() {
|
||||
@ -154,7 +147,7 @@ public class CreateOrganizationActivity extends BaseActivity {
|
||||
|
||||
if(response.code() == 201) {
|
||||
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||
tinyDb.putBoolean("orgCreated", true);
|
||||
enableProcessButton();
|
||||
Toasty.success(ctx, getString(R.string.orgCreated));
|
||||
|
@ -3,7 +3,6 @@ package org.mian.gitnex.activities;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.DatePickerDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Bundle;
|
||||
@ -22,7 +21,6 @@ import org.mian.gitnex.databinding.CustomLabelsSelectionDialogBinding;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.StaticGlobalVariables;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import org.mian.gitnex.models.Branches;
|
||||
@ -43,9 +41,6 @@ import retrofit2.Callback;
|
||||
public class CreatePullRequestActivity extends BaseActivity implements LabelsListAdapter.LabelsListAdapterListener {
|
||||
|
||||
private View.OnClickListener onClickListener;
|
||||
private Context ctx = this;
|
||||
private Context appCtx;
|
||||
private TinyDB tinyDb;
|
||||
private ActivityCreatePrBinding viewBinding;
|
||||
private CustomLabelsSelectionDialogBinding labelsBinding;
|
||||
private int resultLimit = StaticGlobalVariables.resultLimitOldGiteaInstances;
|
||||
@ -55,7 +50,6 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
||||
private List<String> assignees = new ArrayList<>();
|
||||
private int milestoneId;
|
||||
|
||||
private String instanceUrl;
|
||||
private String loginUid;
|
||||
private String instanceToken;
|
||||
private String repoOwner;
|
||||
@ -80,23 +74,20 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
tinyDb = new TinyDB(appCtx);
|
||||
|
||||
viewBinding = ActivityCreatePrBinding.inflate(getLayoutInflater());
|
||||
View view = viewBinding.getRoot();
|
||||
setContentView(view);
|
||||
|
||||
instanceUrl = tinyDb.getString("instanceUrl");
|
||||
loginUid = tinyDb.getString("loginUid");
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
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");
|
||||
instanceToken = "token " + tinyDB.getString(loginUid + "-token");
|
||||
|
||||
// require gitea 1.12 or higher
|
||||
if(new Version(tinyDb.getString("giteaVersion")).higherOrEqual("1.12.0")) {
|
||||
if(new Version(tinyDB.getString("giteaVersion")).higherOrEqual("1.12.0")) {
|
||||
|
||||
resultLimit = StaticGlobalVariables.resultLimitNewGiteaInstances;
|
||||
}
|
||||
@ -125,8 +116,8 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
||||
|
||||
disableProcessButton();
|
||||
|
||||
getMilestones(instanceUrl, instanceToken, repoOwner, repoName, loginUid, resultLimit);
|
||||
getBranches(instanceUrl, instanceToken, repoOwner, repoName, loginUid);
|
||||
getMilestones(repoOwner, repoName, resultLimit);
|
||||
getBranches(repoOwner, repoName);
|
||||
|
||||
viewBinding.prLabels.setOnClickListener(prLabels -> showLabels());
|
||||
|
||||
@ -184,8 +175,7 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
||||
CreatePullRequest createPullRequest = new CreatePullRequest(prTitle, prDescription, loginUid, mergeInto, pullFrom, milestoneId, dueDate, assignees, labelsIds);
|
||||
|
||||
Call<ResponseBody> transferCall = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.getApiInterface(appCtx)
|
||||
.createPullRequest(instanceToken, repoOwner, repoName, createPullRequest);
|
||||
|
||||
transferCall.enqueue(new Callback<ResponseBody>() {
|
||||
@ -256,15 +246,14 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
||||
labelsBinding.cancel.setOnClickListener(editProperties -> dialogLabels.dismiss());
|
||||
|
||||
dialogLabels.show();
|
||||
LabelsActions.getRepositoryLabels(ctx, instanceUrl, instanceToken, repoOwner, repoName, labelsList, dialogLabels, labelsAdapter, labelsBinding);
|
||||
LabelsActions.getRepositoryLabels(ctx, repoOwner, repoName, labelsList, dialogLabels, labelsAdapter, labelsBinding);
|
||||
}
|
||||
|
||||
private void getBranches(String instanceUrl, String instanceToken, String repoOwner, String repoName, String loginUid) {
|
||||
private void getBranches(String repoOwner, String repoName) {
|
||||
|
||||
Call<List<Branches>> call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.getBranches(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName);
|
||||
.getApiInterface(ctx)
|
||||
.getBranches(Authorization.get(ctx), repoOwner, repoName);
|
||||
|
||||
call.enqueue(new Callback<List<Branches>>() {
|
||||
|
||||
@ -308,13 +297,12 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
||||
|
||||
}
|
||||
|
||||
private void getMilestones(String instanceUrl, String instanceToken, String repoOwner, String repoName, String loginUid, int resultLimit) {
|
||||
private void getMilestones(String repoOwner, String repoName, int resultLimit) {
|
||||
|
||||
String msState = "open";
|
||||
Call<List<Milestones>> call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.getMilestones(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, 1, resultLimit, msState);
|
||||
.getApiInterface(appCtx)
|
||||
.getMilestones(Authorization.get(ctx), repoOwner, repoName, 1, resultLimit, msState);
|
||||
|
||||
call.enqueue(new Callback<List<Milestones>>() {
|
||||
|
||||
|
@ -19,7 +19,6 @@ 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.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.models.Branches;
|
||||
import org.mian.gitnex.models.Releases;
|
||||
@ -43,14 +42,8 @@ public class CreateReleaseActivity extends BaseActivity {
|
||||
private CheckBox releaseType;
|
||||
private CheckBox releaseDraft;
|
||||
private Button createNewRelease;
|
||||
final Context ctx = this;
|
||||
private Context appCtx;
|
||||
private TinyDB tinyDb;
|
||||
private String selectedBranch;
|
||||
|
||||
private String instanceUrl;
|
||||
private String loginUid;
|
||||
private String instanceToken;
|
||||
private String repoOwner;
|
||||
private String repoName;
|
||||
|
||||
@ -66,17 +59,12 @@ public class CreateReleaseActivity extends BaseActivity {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
tinyDb = new TinyDB(appCtx);
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
instanceUrl = tinyDb.getString("instanceUrl");
|
||||
loginUid = tinyDb.getString("loginUid");
|
||||
instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String repoFullName = tinyDB.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
repoOwner = parts[0];
|
||||
repoName = parts[1];
|
||||
@ -107,7 +95,7 @@ public class CreateReleaseActivity extends BaseActivity {
|
||||
closeActivity.setOnClickListener(onClickListener);
|
||||
|
||||
releaseBranch = findViewById(R.id.releaseBranch);
|
||||
getBranches(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName);
|
||||
getBranches(Authorization.get(ctx), repoOwner, repoName);
|
||||
|
||||
createNewRelease = findViewById(R.id.createNewRelease);
|
||||
disableProcessButton();
|
||||
@ -161,18 +149,17 @@ public class CreateReleaseActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
disableProcessButton();
|
||||
createNewReleaseFunc(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, newReleaseTagName, newReleaseTitle, newReleaseContent, selectedBranch, newReleaseType, newReleaseDraft);
|
||||
createNewReleaseFunc(Authorization.get(ctx), repoOwner, repoName, newReleaseTagName, newReleaseTitle, newReleaseContent, selectedBranch, newReleaseType, newReleaseDraft);
|
||||
}
|
||||
|
||||
private void createNewReleaseFunc(final String instanceUrl, final String token, String repoOwner, String repoName, String newReleaseTagName, String newReleaseTitle, String newReleaseContent, String selectedBranch, boolean newReleaseType, boolean newReleaseDraft) {
|
||||
private void createNewReleaseFunc(final String token, String repoOwner, String repoName, String newReleaseTagName, String newReleaseTitle, String newReleaseContent, String selectedBranch, boolean newReleaseType, boolean newReleaseDraft) {
|
||||
|
||||
Releases createReleaseJson = new Releases(newReleaseContent, newReleaseDraft, newReleaseTitle, newReleaseType, newReleaseTagName, selectedBranch);
|
||||
|
||||
Call<Releases> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.getApiInterface(ctx)
|
||||
.createNewRelease(token, repoOwner, repoName, createReleaseJson);
|
||||
|
||||
call.enqueue(new Callback<Releases>() {
|
||||
@ -182,7 +169,7 @@ public class CreateReleaseActivity extends BaseActivity {
|
||||
|
||||
if (response.code() == 201) {
|
||||
|
||||
tinyDb.putBoolean("updateReleases", true);
|
||||
tinyDB.putBoolean("updateReleases", true);
|
||||
Toasty.success(ctx, getString(R.string.releaseCreatedText));
|
||||
enableProcessButton();
|
||||
finish();
|
||||
@ -222,11 +209,10 @@ public class CreateReleaseActivity extends BaseActivity {
|
||||
|
||||
}
|
||||
|
||||
private void getBranches(String instanceUrl, String instanceToken, final String repoOwner, final String repoName) {
|
||||
private void getBranches(String instanceToken, final String repoOwner, final String repoName) {
|
||||
|
||||
Call<List<Branches>> call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.getApiInterface(ctx)
|
||||
.getBranches(instanceToken, repoOwner, repoName);
|
||||
|
||||
call.enqueue(new Callback<List<Branches>>() {
|
||||
|
@ -43,14 +43,9 @@ public class CreateRepoActivity extends BaseActivity {
|
||||
private EditText repoName;
|
||||
private EditText repoDesc;
|
||||
private CheckBox repoAccess;
|
||||
final Context ctx = this;
|
||||
private Context appCtx;
|
||||
private TinyDB tinyDb;
|
||||
|
||||
private String instanceUrl;
|
||||
private String loginUid;
|
||||
private String userLogin;
|
||||
private String instanceToken;
|
||||
|
||||
private String selectedOwner;
|
||||
|
||||
@ -69,15 +64,11 @@ public class CreateRepoActivity extends BaseActivity {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
tinyDb = new TinyDB(appCtx);
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(ctx);
|
||||
|
||||
instanceUrl = tinyDb.getString("instanceUrl");
|
||||
loginUid = tinyDb.getString("loginUid");
|
||||
userLogin = tinyDb.getString("userLogin");
|
||||
instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
loginUid = tinyDB.getString("loginUid");
|
||||
userLogin = tinyDB.getString("userLogin");
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
@ -94,7 +85,7 @@ public class CreateRepoActivity extends BaseActivity {
|
||||
closeActivity.setOnClickListener(onClickListener);
|
||||
|
||||
spinner = findViewById(R.id.ownerSpinner);
|
||||
getOrganizations(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), userLogin);
|
||||
getOrganizations(Authorization.get(ctx), userLogin);
|
||||
|
||||
createRepo = findViewById(R.id.createNewRepoButton);
|
||||
disableProcessButton();
|
||||
@ -158,11 +149,11 @@ public class CreateRepoActivity extends BaseActivity {
|
||||
else {
|
||||
|
||||
disableProcessButton();
|
||||
createNewRepository(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), loginUid, newRepoName, newRepoDesc, selectedOwner, newRepoAccess);
|
||||
createNewRepository(Authorization.get(ctx), loginUid, newRepoName, newRepoDesc, selectedOwner, newRepoAccess);
|
||||
}
|
||||
}
|
||||
|
||||
private void createNewRepository(final String instanceUrl, final String token, String loginUid, String repoName, String repoDesc, String selectedOwner, boolean isPrivate) {
|
||||
private void createNewRepository(final String token, String loginUid, String repoName, String repoDesc, String selectedOwner, boolean isPrivate) {
|
||||
|
||||
OrganizationRepository createRepository = new OrganizationRepository(true, repoDesc, null, null, repoName, isPrivate, "Default");
|
||||
|
||||
@ -170,15 +161,13 @@ public class CreateRepoActivity extends BaseActivity {
|
||||
if(selectedOwner.equals(loginUid)) {
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.getApiInterface(ctx)
|
||||
.createNewUserRepository(token, createRepository);
|
||||
}
|
||||
else {
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.getApiInterface(ctx)
|
||||
.createNewUserOrgRepository(token, selectedOwner, createRepository);
|
||||
}
|
||||
|
||||
@ -189,7 +178,7 @@ public class CreateRepoActivity extends BaseActivity {
|
||||
|
||||
if(response.code() == 201) {
|
||||
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||
tinyDb.putBoolean("repoCreated", true);
|
||||
Toasty.success(ctx, getString(R.string.repoCreated));
|
||||
enableProcessButton();
|
||||
@ -224,11 +213,10 @@ public class CreateRepoActivity extends BaseActivity {
|
||||
});
|
||||
}
|
||||
|
||||
private void getOrganizations(String instanceUrl, String instanceToken, final String userLogin) {
|
||||
private void getOrganizations(String instanceToken, final String userLogin) {
|
||||
|
||||
Call<List<OrgOwner>> call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.getApiInterface(ctx)
|
||||
.getOrgOwners(instanceToken);
|
||||
|
||||
call.enqueue(new Callback<List<OrgOwner>>() {
|
||||
@ -249,9 +237,9 @@ public class CreateRepoActivity extends BaseActivity {
|
||||
|
||||
for(int i = 0; i < organizationsList_.size(); i++) {
|
||||
|
||||
if(!tinyDb.getString("organizationId").isEmpty()) {
|
||||
if(!tinyDB.getString("organizationId").isEmpty()) {
|
||||
|
||||
if(Integer.parseInt(tinyDb.getString("organizationId")) == organizationsList_.get(i).getId()) {
|
||||
if(Integer.parseInt(tinyDB.getString("organizationId")) == organizationsList_.get(i).getId()) {
|
||||
organizationId = i + 1;
|
||||
}
|
||||
}
|
||||
@ -267,7 +255,7 @@ public class CreateRepoActivity extends BaseActivity {
|
||||
|
||||
spinner.setOnItemClickListener ((parent, view, position, id) -> selectedOwner = organizationsList.get(position).getUsername());
|
||||
|
||||
if(tinyDb.getBoolean("organizationAction") & organizationId != 0) {
|
||||
if(tinyDB.getBoolean("organizationAction") & organizationId != 0) {
|
||||
|
||||
int selectOwnerById = organizationId;
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
@ -276,7 +264,7 @@ public class CreateRepoActivity extends BaseActivity {
|
||||
selectedOwner = organizationsList.get(selectOwnerById).getUsername();
|
||||
}, 500);
|
||||
|
||||
tinyDb.putBoolean("organizationAction", false);
|
||||
tinyDB.putBoolean("organizationAction", false);
|
||||
}
|
||||
|
||||
enableProcessButton();
|
||||
|
@ -31,8 +31,6 @@ import retrofit2.Callback;
|
||||
|
||||
public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClickListener {
|
||||
|
||||
final Context ctx = CreateTeamByOrgActivity.this;
|
||||
private Context appCtx;
|
||||
private View.OnClickListener onClickListener;
|
||||
private TextView teamName;
|
||||
private TextView teamDesc;
|
||||
@ -75,7 +73,6 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
@ -228,8 +225,7 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
||||
private void processCreateTeam() {
|
||||
|
||||
AppUtil appUtil = new AppUtil();
|
||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
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");;
|
||||
@ -286,19 +282,18 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
||||
newTeamAccessControls_.set(i, newTeamAccessControls_.get(i).trim());
|
||||
}
|
||||
|
||||
createNewTeamCall(instanceUrl, instanceToken, orgName, newTeamName, newTeamDesc, newTeamPermission, newTeamAccessControls_, loginUid);
|
||||
createNewTeamCall(instanceToken, orgName, newTeamName, newTeamDesc, newTeamPermission, newTeamAccessControls_, loginUid);
|
||||
}
|
||||
|
||||
private void createNewTeamCall(final String instanceUrl, final String instanceToken, String orgName, String newTeamName, String newTeamDesc, String newTeamPermission, List<String> newTeamAccessControls, String loginUid) {
|
||||
private void createNewTeamCall(final String instanceToken, String orgName, String newTeamName, String newTeamDesc, String newTeamPermission, List<String> newTeamAccessControls, String loginUid) {
|
||||
|
||||
Teams createNewTeamJson = new Teams(newTeamName, newTeamDesc, newTeamPermission, newTeamAccessControls);
|
||||
|
||||
Call<Teams> call3;
|
||||
|
||||
call3 = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.createTeamsByOrg(Authorization.returnAuthentication(ctx, loginUid, instanceToken), orgName, createNewTeamJson);
|
||||
.getApiInterface(ctx)
|
||||
.createTeamsByOrg(Authorization.get(ctx), orgName, createNewTeamJson);
|
||||
|
||||
call3.enqueue(new Callback<Teams>() {
|
||||
|
||||
@ -309,7 +304,7 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
||||
|
||||
if(response2.code() == 201) {
|
||||
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||
tinyDb.putBoolean("resumeTeams", true);
|
||||
|
||||
Toasty.success(ctx, getString(R.string.teamCreated));
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
@ -18,7 +17,6 @@ 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.PathsHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.UrlHelper;
|
||||
import org.mian.gitnex.models.GiteaVersion;
|
||||
@ -38,9 +36,6 @@ import retrofit2.Callback;
|
||||
public class DeepLinksActivity extends BaseActivity {
|
||||
|
||||
private ActivityDeeplinksBinding viewBinding;
|
||||
private Context ctx = this;
|
||||
private Context appCtx;
|
||||
private TinyDB tinyDb;
|
||||
private String currentInstance;
|
||||
private String instanceToken;
|
||||
private boolean noAccountFound = false;
|
||||
@ -59,8 +54,6 @@ public class DeepLinksActivity extends BaseActivity {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
tinyDb = new TinyDB(appCtx);
|
||||
|
||||
viewBinding = ActivityDeeplinksBinding.inflate(getLayoutInflater());
|
||||
View view = viewBinding.getRoot();
|
||||
@ -75,7 +68,7 @@ public class DeepLinksActivity extends BaseActivity {
|
||||
assert data != null;
|
||||
|
||||
// check for login
|
||||
if(!tinyDb.getBoolean("loggedInMode")) {
|
||||
if(!tinyDB.getBoolean("loggedInMode")) {
|
||||
|
||||
finish();
|
||||
ctx.startActivity(new Intent(ctx, LoginActivity.class));
|
||||
@ -123,15 +116,15 @@ public class DeepLinksActivity extends BaseActivity {
|
||||
|
||||
issueIntent.putExtra("issueNumber", data.getLastPathSegment());
|
||||
|
||||
tinyDb.putString("issueNumber", data.getLastPathSegment());
|
||||
tinyDb.putString("issueType", "Issue");
|
||||
tinyDB.putString("issueNumber", data.getLastPathSegment());
|
||||
tinyDB.putString("issueType", "Issue");
|
||||
|
||||
tinyDb.putString("repoFullName", restOfUrl[restOfUrl.length - 4] + "/" + restOfUrl[restOfUrl.length - 3]);
|
||||
tinyDB.putString("repoFullName", restOfUrl[restOfUrl.length - 4] + "/" + restOfUrl[restOfUrl.length - 3]);
|
||||
|
||||
final String repoOwner = restOfUrl[restOfUrl.length - 4];
|
||||
final String repoName = restOfUrl[restOfUrl.length - 3];
|
||||
|
||||
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
||||
int currentActiveAccountId = tinyDB.getInt("currentActiveAccountId");
|
||||
RepositoriesApi repositoryData = new RepositoriesApi(ctx);
|
||||
|
||||
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
@ -139,12 +132,12 @@ public class DeepLinksActivity extends BaseActivity {
|
||||
if(count == 0) {
|
||||
|
||||
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
tinyDb.putLong("repositoryId", id);
|
||||
tinyDB.putLong("repositoryId", id);
|
||||
}
|
||||
else {
|
||||
|
||||
Repository dataRepo = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
tinyDb.putLong("repositoryId", dataRepo.getRepositoryId());
|
||||
tinyDB.putLong("repositoryId", dataRepo.getRepositoryId());
|
||||
}
|
||||
|
||||
ctx.startActivity(issueIntent);
|
||||
@ -197,38 +190,38 @@ public class DeepLinksActivity extends BaseActivity {
|
||||
}
|
||||
else { // no action, show options
|
||||
|
||||
if(tinyDb.getInt("defaultScreenId") == 1) { // repos
|
||||
if(tinyDB.getInt("defaultScreenId") == 1) { // repos
|
||||
|
||||
mainIntent.putExtra("launchFragmentByLinkHandler", "repos");
|
||||
ctx.startActivity(mainIntent);
|
||||
finish();
|
||||
}
|
||||
else if(tinyDb.getInt("defaultScreenId") == 2) { // org
|
||||
else if(tinyDB.getInt("defaultScreenId") == 2) { // org
|
||||
|
||||
mainIntent.putExtra("launchFragmentByLinkHandler", "org");
|
||||
ctx.startActivity(mainIntent);
|
||||
finish();
|
||||
}
|
||||
else if(tinyDb.getInt("defaultScreenId") == 3) { // notifications
|
||||
else if(tinyDB.getInt("defaultScreenId") == 3) { // notifications
|
||||
|
||||
mainIntent.putExtra("launchFragmentByLinkHandler", "notification");
|
||||
ctx.startActivity(mainIntent);
|
||||
finish();
|
||||
}
|
||||
else if(tinyDb.getInt("defaultScreenId") == 4) { // explore
|
||||
else if(tinyDB.getInt("defaultScreenId") == 4) { // explore
|
||||
|
||||
mainIntent.putExtra("launchFragmentByLinkHandler", "explore");
|
||||
ctx.startActivity(mainIntent);
|
||||
finish();
|
||||
}
|
||||
else if(tinyDb.getInt("defaultScreenId") == 0) { // show options
|
||||
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);
|
||||
tinyDB.putInt("defaultScreenId", 1);
|
||||
mainIntent.putExtra("launchFragmentByLinkHandler", "repos");
|
||||
ctx.startActivity(mainIntent);
|
||||
finish();
|
||||
@ -236,7 +229,7 @@ public class DeepLinksActivity extends BaseActivity {
|
||||
|
||||
viewBinding.organization.setOnClickListener(organization -> {
|
||||
|
||||
tinyDb.putInt("defaultScreenId", 2);
|
||||
tinyDB.putInt("defaultScreenId", 2);
|
||||
mainIntent.putExtra("launchFragmentByLinkHandler", "org");
|
||||
ctx.startActivity(mainIntent);
|
||||
finish();
|
||||
@ -244,7 +237,7 @@ public class DeepLinksActivity extends BaseActivity {
|
||||
|
||||
viewBinding.notification.setOnClickListener(notification -> {
|
||||
|
||||
tinyDb.putInt("defaultScreenId", 3);
|
||||
tinyDB.putInt("defaultScreenId", 3);
|
||||
mainIntent.putExtra("launchFragmentByLinkHandler", "notification");
|
||||
ctx.startActivity(mainIntent);
|
||||
finish();
|
||||
@ -252,7 +245,7 @@ public class DeepLinksActivity extends BaseActivity {
|
||||
|
||||
viewBinding.explore.setOnClickListener(explore -> {
|
||||
|
||||
tinyDb.putInt("defaultScreenId", 4);
|
||||
tinyDB.putInt("defaultScreenId", 4);
|
||||
mainIntent.putExtra("launchFragmentByLinkHandler", "explore");
|
||||
ctx.startActivity(mainIntent);
|
||||
finish();
|
||||
@ -260,7 +253,7 @@ public class DeepLinksActivity extends BaseActivity {
|
||||
|
||||
viewBinding.launchApp2.setOnClickListener(launchApp2 -> {
|
||||
|
||||
tinyDb.putInt("defaultScreenId", 0);
|
||||
tinyDB.putInt("defaultScreenId", 0);
|
||||
ctx.startActivity(mainIntent);
|
||||
finish();
|
||||
});
|
||||
@ -290,7 +283,9 @@ public class DeepLinksActivity extends BaseActivity {
|
||||
.toUri();
|
||||
|
||||
Call<GiteaVersion> callVersion;
|
||||
callVersion = RetrofitClient.getInstance(String.valueOf(instanceUrl), ctx).getApiInterface().getGiteaVersion();
|
||||
callVersion = RetrofitClient
|
||||
.getApiInterface(ctx, instanceUrl.toString())
|
||||
.getGiteaVersion();
|
||||
|
||||
callVersion.enqueue(new Callback<GiteaVersion>() {
|
||||
|
||||
@ -346,8 +341,7 @@ public class DeepLinksActivity extends BaseActivity {
|
||||
private void getPullRequest(String url, String token, String repoOwner, String repoName, int index) {
|
||||
|
||||
Call<PullRequests> call = RetrofitClient
|
||||
.getInstance(url, ctx)
|
||||
.getApiInterface()
|
||||
.getApiInterface(ctx, url)
|
||||
.getPullRequestByIndex(token, repoOwner, repoName, index);
|
||||
|
||||
call.enqueue(new Callback<PullRequests>() {
|
||||
@ -367,28 +361,28 @@ public class DeepLinksActivity extends BaseActivity {
|
||||
if(prInfo.getHead() != null) {
|
||||
|
||||
issueIntent.putExtra("prHeadBranch", prInfo.getHead().getRef());
|
||||
tinyDb.putString("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());
|
||||
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.prDeletedFrok));
|
||||
tinyDB.putString("prIsFork", "true");
|
||||
tinyDB.putString("prForkFullName", ctx.getString(R.string.prDeletedFrok));
|
||||
}
|
||||
}
|
||||
|
||||
tinyDb.putString("issueNumber", String.valueOf(index));
|
||||
tinyDb.putString("prMergeable", String.valueOf(prInfo.isMergeable()));
|
||||
tinyDb.putString("issueType", "Pull");
|
||||
tinyDB.putString("issueNumber", String.valueOf(index));
|
||||
tinyDB.putString("prMergeable", String.valueOf(prInfo.isMergeable()));
|
||||
tinyDB.putString("issueType", "Pull");
|
||||
|
||||
tinyDb.putString("repoFullName", repoOwner + "/" + repoName);
|
||||
tinyDB.putString("repoFullName", repoOwner + "/" + repoName);
|
||||
|
||||
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
||||
int currentActiveAccountId = tinyDB.getInt("currentActiveAccountId");
|
||||
RepositoriesApi repositoryData = new RepositoriesApi(ctx);
|
||||
|
||||
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
@ -396,12 +390,12 @@ public class DeepLinksActivity extends BaseActivity {
|
||||
if(count == 0) {
|
||||
|
||||
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
tinyDb.putLong("repositoryId", id);
|
||||
tinyDB.putLong("repositoryId", id);
|
||||
}
|
||||
else {
|
||||
|
||||
Repository dataRepo = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
tinyDb.putLong("repositoryId", dataRepo.getRepositoryId());
|
||||
tinyDB.putLong("repositoryId", dataRepo.getRepositoryId());
|
||||
}
|
||||
|
||||
ctx.startActivity(issueIntent);
|
||||
@ -425,8 +419,7 @@ public class DeepLinksActivity extends BaseActivity {
|
||||
private void goToRepoSection(String url, String token, String repoOwner, String repoName, String type) {
|
||||
|
||||
Call<UserRepositories> call = RetrofitClient
|
||||
.getInstance(url, ctx)
|
||||
.getApiInterface()
|
||||
.getApiInterface(ctx, url)
|
||||
.getUserRepository(token, repoOwner, repoName);
|
||||
|
||||
call.enqueue(new Callback<UserRepositories>() {
|
||||
@ -444,19 +437,19 @@ public class DeepLinksActivity extends BaseActivity {
|
||||
repoIntent.putExtra("goToSection", "yes");
|
||||
repoIntent.putExtra("goToSectionType", type);
|
||||
|
||||
tinyDb.putString("repoFullName", repoInfo.getFullName());
|
||||
tinyDB.putString("repoFullName", repoInfo.getFullName());
|
||||
if(repoInfo.getPrivateFlag()) {
|
||||
|
||||
tinyDb.putString("repoType", getResources().getString(R.string.strPrivate));
|
||||
tinyDB.putString("repoType", getResources().getString(R.string.strPrivate));
|
||||
}
|
||||
else {
|
||||
|
||||
tinyDb.putString("repoType", getResources().getString(R.string.strPublic));
|
||||
tinyDB.putString("repoType", getResources().getString(R.string.strPublic));
|
||||
}
|
||||
tinyDb.putBoolean("isRepoAdmin", repoInfo.getPermissions().isAdmin());
|
||||
tinyDb.putString("repoBranch", repoInfo.getDefault_branch());
|
||||
tinyDB.putBoolean("isRepoAdmin", repoInfo.getPermissions().isAdmin());
|
||||
tinyDB.putString("repoBranch", repoInfo.getDefault_branch());
|
||||
|
||||
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
||||
int currentActiveAccountId = tinyDB.getInt("currentActiveAccountId");
|
||||
RepositoriesApi repositoryData = new RepositoriesApi(ctx);
|
||||
|
||||
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
@ -464,12 +457,12 @@ public class DeepLinksActivity extends BaseActivity {
|
||||
if(count == 0) {
|
||||
|
||||
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
tinyDb.putLong("repositoryId", id);
|
||||
tinyDB.putLong("repositoryId", id);
|
||||
}
|
||||
else {
|
||||
|
||||
Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
tinyDb.putLong("repositoryId", data.getRepositoryId());
|
||||
tinyDB.putLong("repositoryId", data.getRepositoryId());
|
||||
}
|
||||
|
||||
ctx.startActivity(repoIntent);
|
||||
|
@ -24,7 +24,6 @@ import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.StaticGlobalVariables;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import org.mian.gitnex.models.CreateIssue;
|
||||
@ -44,9 +43,6 @@ import retrofit2.Callback;
|
||||
|
||||
public class EditIssueActivity extends BaseActivity implements View.OnClickListener {
|
||||
|
||||
final Context ctx = this;
|
||||
private Context appCtx;
|
||||
private TinyDB tinyDb;
|
||||
private View.OnClickListener onClickListener;
|
||||
private int resultLimit = StaticGlobalVariables.resultLimitOldGiteaInstances;
|
||||
|
||||
@ -61,7 +57,6 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
||||
|
||||
List<Milestones> milestonesList = new ArrayList<>();
|
||||
|
||||
private String instanceUrl;
|
||||
private String loginUid;
|
||||
private String instanceToken;
|
||||
private String repoOwner;
|
||||
@ -78,19 +73,16 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
tinyDb = new TinyDB(appCtx);
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
instanceUrl = tinyDb.getString("instanceUrl");
|
||||
loginUid = tinyDb.getString("loginUid");
|
||||
instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
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"));
|
||||
issueIndex = Integer.parseInt(tinyDB.getString("issueNumber"));
|
||||
|
||||
ImageView closeActivity = findViewById(R.id.close);
|
||||
editIssueButton = findViewById(R.id.editIssueButton);
|
||||
@ -100,7 +92,7 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
||||
editIssueDueDate = findViewById(R.id.editIssueDueDate);
|
||||
|
||||
// if gitea is 1.12 or higher use the new limit
|
||||
if(new Version(tinyDb.getString("giteaVersion")).higherOrEqual("1.12.0")) {
|
||||
if(new Version(tinyDB.getString("giteaVersion")).higherOrEqual("1.12.0")) {
|
||||
|
||||
resultLimit = StaticGlobalVariables.resultLimitNewGiteaInstances;
|
||||
}
|
||||
@ -128,9 +120,9 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
||||
editIssueDueDate.setOnClickListener(this);
|
||||
editIssueButton.setOnClickListener(this);
|
||||
|
||||
if(!tinyDb.getString("issueNumber").isEmpty()) {
|
||||
if(!tinyDB.getString("issueNumber").isEmpty()) {
|
||||
|
||||
if(tinyDb.getString("issueType").equalsIgnoreCase("Pull")) {
|
||||
if(tinyDB.getString("issueType").equalsIgnoreCase("Pull")) {
|
||||
|
||||
toolbar_title.setText(getString(R.string.editPrNavHeader, String.valueOf(issueIndex)));
|
||||
}
|
||||
@ -141,7 +133,7 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
||||
}
|
||||
|
||||
disableProcessButton();
|
||||
getIssue(instanceUrl, instanceToken, loginUid, repoOwner, repoName, issueIndex, resultLimit);
|
||||
getIssue(instanceToken, loginUid, repoOwner, repoName, issueIndex, resultLimit);
|
||||
}
|
||||
|
||||
private void initCloseListener() {
|
||||
@ -179,17 +171,16 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
||||
}
|
||||
|
||||
disableProcessButton();
|
||||
editIssue(instanceUrl, instanceToken, repoOwner, repoName, issueIndex, loginUid, editIssueTitleForm, editIssueDescriptionForm, editIssueDueDateForm, milestoneId);
|
||||
editIssue(instanceToken, repoOwner, repoName, issueIndex, loginUid, editIssueTitleForm, editIssueDescriptionForm, editIssueDueDateForm, milestoneId);
|
||||
}
|
||||
|
||||
private void editIssue(String instanceUrl, String instanceToken, String repoOwner, String repoName, int issueIndex, String loginUid, String title, String description, String dueDate, int milestoneId) {
|
||||
private void editIssue(String instanceToken, String repoOwner, String repoName, int issueIndex, String loginUid, String title, String description, String dueDate, int milestoneId) {
|
||||
|
||||
CreateIssue issueData = new CreateIssue(title, description, dueDate, milestoneId);
|
||||
|
||||
Call<JsonElement> call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.patchIssue(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, issueIndex, issueData);
|
||||
.getApiInterface(ctx)
|
||||
.patchIssue(Authorization.get(ctx), repoOwner, repoName, issueIndex, issueData);
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
|
||||
@ -198,7 +189,7 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
||||
|
||||
if(response.code() == 201) {
|
||||
|
||||
if(tinyDb.getString("issueType").equalsIgnoreCase("Pull")) {
|
||||
if(tinyDB.getString("issueType").equalsIgnoreCase("Pull")) {
|
||||
|
||||
Toasty.success(ctx, getString(R.string.editPrSuccessMessage));
|
||||
}
|
||||
@ -207,8 +198,8 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
||||
Toasty.success(ctx, getString(R.string.editIssueSuccessMessage));
|
||||
}
|
||||
|
||||
tinyDb.putBoolean("issueEdited", true);
|
||||
tinyDb.putBoolean("resumeIssues", true);
|
||||
tinyDB.putBoolean("issueEdited", true);
|
||||
tinyDB.putBoolean("resumeIssues", true);
|
||||
finish();
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
@ -257,12 +248,11 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
||||
|
||||
}
|
||||
|
||||
private void getIssue(final String instanceUrl, final String instanceToken, final String loginUid, final String repoOwner, final String repoName, int issueIndex, int resultLimit) {
|
||||
private void getIssue(final String instanceToken, final String loginUid, final String repoOwner, final String repoName, int issueIndex, int resultLimit) {
|
||||
|
||||
Call<Issues> call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.getIssueByIndex(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, issueIndex);
|
||||
.getApiInterface(ctx)
|
||||
.getIssueByIndex(Authorization.get(ctx), repoOwner, repoName, issueIndex);
|
||||
|
||||
call.enqueue(new Callback<Issues>() {
|
||||
|
||||
@ -285,9 +275,8 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
||||
if(response.body().getId() > 0) {
|
||||
|
||||
Call<List<Milestones>> call_ = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.getMilestones(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, 1, resultLimit, msState);
|
||||
.getApiInterface(ctx)
|
||||
.getMilestones(Authorization.get(ctx), repoOwner, repoName, 1, resultLimit, msState);
|
||||
|
||||
int checkMilestoneId = currentMilestoneId;
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
@ -14,7 +13,6 @@ import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.FilesDiffAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.ParseDiff;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
@ -36,8 +34,6 @@ public class FileDiffActivity extends BaseActivity {
|
||||
private TextView toolbarTitle;
|
||||
private ListView mListView;
|
||||
private ProgressBar mProgressBar;
|
||||
final Context ctx = this;
|
||||
private Context appCtx;
|
||||
|
||||
@Override
|
||||
protected int getLayoutResourceId() {
|
||||
@ -49,12 +45,11 @@ public class FileDiffActivity extends BaseActivity {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
||||
final TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
final String repoOwner = parts[0];
|
||||
@ -77,29 +72,21 @@ public class FileDiffActivity extends BaseActivity {
|
||||
|
||||
String pullIndex = tinyDb.getString("issueNumber");
|
||||
|
||||
boolean apiCall = true;
|
||||
String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
boolean apiCall = !new Version(tinyDb.getString("giteaVersion")).less("1.13.0");
|
||||
getPullDiffContent(repoOwner, repoName, pullIndex, instanceToken, apiCall);
|
||||
|
||||
// fallback for old gitea instances
|
||||
if(new Version(tinyDb.getString("giteaVersion")).less("1.13.0")) {
|
||||
|
||||
apiCall = false;
|
||||
instanceUrl = instanceUrl.substring(0, instanceUrl.lastIndexOf("api/v1/"));
|
||||
}
|
||||
|
||||
getPullDiffContent(instanceUrl, repoOwner, repoName, pullIndex, instanceToken, apiCall);
|
||||
}
|
||||
|
||||
private void getPullDiffContent(String instanceUrl, String owner, String repo, String pullIndex, String token, boolean apiCall) {
|
||||
private void getPullDiffContent(String owner, String repo, String pullIndex, String token, boolean apiCall) {
|
||||
|
||||
Call<ResponseBody> call;
|
||||
if(apiCall) {
|
||||
|
||||
call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().getPullDiffContent(token, owner, repo, pullIndex);
|
||||
call = RetrofitClient.getApiInterface(ctx).getPullDiffContent(token, owner, repo, pullIndex);
|
||||
}
|
||||
else {
|
||||
|
||||
call = RetrofitClient.getInstance(instanceUrl, ctx).getWebInterface().getPullDiffContent(owner, repo, pullIndex);
|
||||
call = RetrofitClient.getWebInterface(ctx).getPullDiffContent(owner, repo, pullIndex);
|
||||
}
|
||||
|
||||
call.enqueue(new Callback<ResponseBody>() {
|
||||
|
@ -1,7 +1,6 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Typeface;
|
||||
@ -9,7 +8,6 @@ import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.text.Spanned;
|
||||
import android.text.method.ScrollingMovementMethod;
|
||||
import android.util.Base64;
|
||||
import android.util.Log;
|
||||
@ -28,7 +26,6 @@ import androidx.activity.result.ActivityResultLauncher;
|
||||
import androidx.activity.result.contract.ActivityResultContracts;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import com.github.barteksc.pdfviewer.PDFView;
|
||||
import com.github.barteksc.pdfviewer.util.FitPolicy;
|
||||
import com.github.chrisbanes.photoview.PhotoView;
|
||||
@ -38,7 +35,7 @@ import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.fragments.BottomSheetFileViewerFragment;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Markdown;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.highlightjs.HighlightJsView;
|
||||
import org.mian.gitnex.helpers.highlightjs.models.Theme;
|
||||
@ -48,24 +45,7 @@ import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Objects;
|
||||
import io.noties.markwon.AbstractMarkwonPlugin;
|
||||
import io.noties.markwon.Markwon;
|
||||
import io.noties.markwon.core.CorePlugin;
|
||||
import io.noties.markwon.core.MarkwonTheme;
|
||||
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
||||
import io.noties.markwon.ext.tables.TablePlugin;
|
||||
import io.noties.markwon.ext.tasklist.TaskListPlugin;
|
||||
import io.noties.markwon.html.HtmlPlugin;
|
||||
import io.noties.markwon.image.DefaultMediaDecoder;
|
||||
import io.noties.markwon.image.ImageItem;
|
||||
import io.noties.markwon.image.ImagesPlugin;
|
||||
import io.noties.markwon.image.SchemeHandler;
|
||||
import io.noties.markwon.image.gif.GifMediaDecoder;
|
||||
import io.noties.markwon.image.svg.SvgMediaDecoder;
|
||||
import io.noties.markwon.linkify.LinkifyPlugin;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
@ -80,8 +60,6 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
||||
private LinearLayout singleFileContentsFrame;
|
||||
private HighlightJsView singleCodeContents;
|
||||
private PhotoView imageView;
|
||||
final Context ctx = this;
|
||||
private Context appCtx;
|
||||
private ProgressBar mProgressBar;
|
||||
private byte[] imageData;
|
||||
private PDFView pdfView;
|
||||
@ -91,7 +69,6 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
||||
private String singleFileName;
|
||||
private String fileSha;
|
||||
private AppUtil appUtil;
|
||||
private TinyDB tinyDb;
|
||||
|
||||
@Override
|
||||
protected int getLayoutResourceId() {
|
||||
@ -103,23 +80,20 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
appUtil = new AppUtil();
|
||||
tinyDb = new TinyDB(appCtx);
|
||||
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String repoBranch = tinyDb.getString("repoBranch");
|
||||
String repoFullName = tinyDB.getString("repoFullName");
|
||||
String repoBranch = tinyDB.getString("repoBranch");
|
||||
String[] parts = repoFullName.split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
final String loginUid = tinyDB.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDB.getString(loginUid + "-token");
|
||||
|
||||
tinyDb.putBoolean("enableMarkdownInFileView", false);
|
||||
tinyDB.putBoolean("enableMarkdownInFileView", false);
|
||||
|
||||
ImageView closeActivity = findViewById(R.id.close);
|
||||
singleFileContents = findViewById(R.id.singleFileContents);
|
||||
@ -138,7 +112,7 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
||||
initCloseListener();
|
||||
closeActivity.setOnClickListener(onClickListener);
|
||||
|
||||
tinyDb.putString("downloadFileContents", "");
|
||||
tinyDB.putString("downloadFileContents", "");
|
||||
|
||||
try {
|
||||
|
||||
@ -153,7 +127,7 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
||||
|
||||
toolbar_title.setText(singleFileName);
|
||||
|
||||
getSingleFileContents(instanceUrl, instanceToken, repoOwner, repoName, singleFileName, repoBranch);
|
||||
getSingleFileContents(instanceToken, repoOwner, repoName, singleFileName, repoBranch);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -161,26 +135,25 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
||||
|
||||
super.onResume();
|
||||
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String repoBranch = tinyDb.getString("repoBranch");
|
||||
String repoFullName = tinyDB.getString("repoFullName");
|
||||
String repoBranch = tinyDB.getString("repoBranch");
|
||||
String[] parts = repoFullName.split("/");
|
||||
String repoOwner = parts[0];
|
||||
String repoName = parts[1];
|
||||
String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
String loginUid = tinyDb.getString("loginUid");
|
||||
String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
String loginUid = tinyDB.getString("loginUid");
|
||||
String instanceToken = "token " + tinyDB.getString(loginUid + "-token");
|
||||
|
||||
if(tinyDb.getBoolean("fileModified")) {
|
||||
if(tinyDB.getBoolean("fileModified")) {
|
||||
|
||||
getSingleFileContents(instanceUrl, instanceToken, repoOwner, repoName, singleFileName, repoBranch);
|
||||
tinyDb.putBoolean("fileModified", false);
|
||||
getSingleFileContents(instanceToken, repoOwner, repoName, singleFileName, repoBranch);
|
||||
tinyDB.putBoolean("fileModified", false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void getSingleFileContents(String instanceUrl, String token, final String owner, String repo, final String filename, String ref) {
|
||||
private void getSingleFileContents(String token, final String owner, String repo, final String filename, String ref) {
|
||||
|
||||
Call<Files> call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().getSingleFileContents(token, owner, repo, filename, ref);
|
||||
Call<Files> call = RetrofitClient.getApiInterface(ctx).getSingleFileContents(token, owner, repo, filename, ref);
|
||||
|
||||
call.enqueue(new Callback<Files>() {
|
||||
|
||||
@ -199,8 +172,8 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
||||
fileSha = response.body().getSha();
|
||||
|
||||
// download file meta
|
||||
tinyDb.putString("downloadFileName", filename);
|
||||
tinyDb.putString("downloadFileContents", response.body().getContent());
|
||||
tinyDB.putString("downloadFileName", filename);
|
||||
tinyDB.putString("downloadFileContents", response.body().getContent());
|
||||
|
||||
if(appUtil.imageExtension(fileExtension)) { // file is image
|
||||
|
||||
@ -220,7 +193,7 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
||||
pdfViewFrame.setVisibility(View.GONE);
|
||||
singleCodeContents.setVisibility(View.VISIBLE);
|
||||
|
||||
switch(tinyDb.getInt("fileviewerSourceCodeThemeId")) {
|
||||
switch(tinyDB.getInt("fileviewerSourceCodeThemeId")) {
|
||||
|
||||
case 1:
|
||||
|
||||
@ -256,7 +229,7 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
||||
singleCodeContents.setVisibility(View.GONE);
|
||||
pdfViewFrame.setVisibility(View.VISIBLE);
|
||||
|
||||
pdfNightMode = tinyDb.getBoolean("enablePdfMode");
|
||||
pdfNightMode = tinyDB.getBoolean("enablePdfMode");
|
||||
|
||||
decodedPdf = Base64.decode(response.body().getContent(), Base64.DEFAULT);
|
||||
pdfView.fromBytes(decodedPdf).enableSwipe(true).swipeHorizontal(false).enableDoubletap(true).defaultPage(0).enableAnnotationRendering(false).password(null).scrollHandle(null).enableAntialiasing(true).spacing(0).autoSpacing(true).pageFitPolicy(FitPolicy.WIDTH).fitEachPage(true).pageSnap(false).pageFling(true).nightMode(pdfNightMode).load();
|
||||
@ -351,70 +324,22 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
||||
}
|
||||
else if(id == R.id.markdown) {
|
||||
|
||||
final Markwon markwon = Markwon.builder(Objects.requireNonNull(ctx)).usePlugin(CorePlugin.create())
|
||||
.usePlugin(ImagesPlugin.create(plugin -> {
|
||||
plugin.addSchemeHandler(new SchemeHandler() {
|
||||
new Markdown(ctx, appUtil.decodeBase64(tinyDB.getString("downloadFileContents")), singleFileContents);
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ImageItem handle(@NonNull String raw, @NonNull Uri uri) {
|
||||
|
||||
final int resourceId = ctx.getResources().getIdentifier(
|
||||
raw.substring("drawable://".length()),
|
||||
"drawable",
|
||||
ctx.getPackageName());
|
||||
|
||||
final Drawable drawable = ContextCompat.getDrawable(ctx, resourceId);
|
||||
|
||||
assert drawable != null;
|
||||
return ImageItem.withResult(drawable);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Collection<String> supportedSchemes() {
|
||||
|
||||
return Collections.singleton("drawable");
|
||||
}
|
||||
});
|
||||
plugin.placeholderProvider(drawable -> null);
|
||||
plugin.addMediaDecoder(GifMediaDecoder.create(false));
|
||||
plugin.addMediaDecoder(SvgMediaDecoder.create(ctx.getResources()));
|
||||
plugin.addMediaDecoder(SvgMediaDecoder.create());
|
||||
plugin.defaultMediaDecoder(DefaultMediaDecoder.create(ctx.getResources()));
|
||||
plugin.defaultMediaDecoder(DefaultMediaDecoder.create());
|
||||
}))
|
||||
.usePlugin(new AbstractMarkwonPlugin() {
|
||||
@Override
|
||||
public void configureTheme(@NonNull MarkwonTheme.Builder builder) {
|
||||
|
||||
builder.codeTextColor(tinyDb.getInt("codeBlockColor")).codeBackgroundColor(tinyDb.getInt("codeBlockBackground"))
|
||||
.linkColor(getResources().getColor(R.color.lightBlue));
|
||||
}
|
||||
})
|
||||
.usePlugin(TablePlugin.create(ctx))
|
||||
.usePlugin(TaskListPlugin.create(ctx))
|
||||
.usePlugin(HtmlPlugin.create())
|
||||
.usePlugin(StrikethroughPlugin.create())
|
||||
.usePlugin(LinkifyPlugin.create())
|
||||
.build();
|
||||
|
||||
if(!tinyDb.getBoolean("enableMarkdownInFileView")) {
|
||||
if(!tinyDB.getBoolean("enableMarkdownInFileView")) {
|
||||
|
||||
singleCodeContents.setVisibility(View.GONE);
|
||||
singleFileContentsFrame.setVisibility(View.VISIBLE);
|
||||
singleFileContents.setVisibility(View.VISIBLE);
|
||||
Spanned bodyWithMD = markwon.toMarkdown(appUtil.decodeBase64(tinyDb.getString("downloadFileContents")));
|
||||
markwon.setParsedMarkdown(singleFileContents, bodyWithMD);
|
||||
tinyDb.putBoolean("enableMarkdownInFileView", true);
|
||||
tinyDB.putBoolean("enableMarkdownInFileView", true);
|
||||
}
|
||||
else {
|
||||
|
||||
singleCodeContents.setVisibility(View.VISIBLE);
|
||||
singleFileContentsFrame.setVisibility(View.GONE);
|
||||
singleFileContents.setVisibility(View.GONE);
|
||||
singleCodeContents.setSource(appUtil.decodeBase64(tinyDb.getString("downloadFileContents")));
|
||||
tinyDb.putBoolean("enableMarkdownInFileView", false);
|
||||
singleCodeContents.setSource(appUtil.decodeBase64(tinyDB.getString("downloadFileContents")));
|
||||
tinyDB.putBoolean("enableMarkdownInFileView", false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -435,7 +360,7 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
||||
if("deleteFile".equals(text)) {
|
||||
|
||||
String fileExtension = FileUtils.getExtension(singleFileName);
|
||||
String data = appUtil.decodeBase64(tinyDb.getString("downloadFileContents"));
|
||||
String data = appUtil.decodeBase64(tinyDB.getString("downloadFileContents"));
|
||||
Intent intent = new Intent(ctx, CreateFileActivity.class);
|
||||
intent.putExtra("fileAction", 1);
|
||||
intent.putExtra("filePath", singleFileName);
|
||||
@ -456,7 +381,7 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
||||
if("editFile".equals(text)) {
|
||||
|
||||
String fileExtension = FileUtils.getExtension(singleFileName);
|
||||
String data = appUtil.decodeBase64(tinyDb.getString("downloadFileContents"));
|
||||
String data = appUtil.decodeBase64(tinyDB.getString("downloadFileContents"));
|
||||
Intent intent = new Intent(ctx, CreateFileActivity.class);
|
||||
intent.putExtra("fileAction", 2);
|
||||
intent.putExtra("filePath", singleFileName);
|
||||
@ -478,9 +403,9 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
||||
|
||||
private void requestFileDownload() {
|
||||
|
||||
if(!tinyDb.getString("downloadFileContents").isEmpty()) {
|
||||
if(!tinyDB.getString("downloadFileContents").isEmpty()) {
|
||||
|
||||
File outputFileName = new File(tinyDb.getString("downloadFileName"));
|
||||
File outputFileName = new File(tinyDB.getString("downloadFileName"));
|
||||
|
||||
Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
|
||||
|
||||
@ -514,7 +439,7 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
||||
assert uri != null;
|
||||
OutputStream outputStream = getContentResolver().openOutputStream(uri);
|
||||
|
||||
byte[] dataAsBytes = Base64.decode(tinyDb.getString("downloadFileContents"), 0);
|
||||
byte[] dataAsBytes = Base64.decode(tinyDB.getString("downloadFileContents"), 0);
|
||||
|
||||
assert outputStream != null;
|
||||
outputStream.write(dataAsBytes);
|
||||
|
@ -1,19 +1,15 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.text.Html;
|
||||
import android.text.Spanned;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
@ -26,7 +22,6 @@ import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.ScrollView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
@ -52,11 +47,11 @@ import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.ClickListener;
|
||||
import org.mian.gitnex.helpers.ColorInverter;
|
||||
import org.mian.gitnex.helpers.LabelWidthCalculator;
|
||||
import org.mian.gitnex.helpers.Markdown;
|
||||
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.UserMentions;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import org.mian.gitnex.models.Collaborators;
|
||||
import org.mian.gitnex.models.Issues;
|
||||
@ -67,27 +62,11 @@ import org.mian.gitnex.viewmodels.IssueCommentsViewModel;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import io.noties.markwon.AbstractMarkwonPlugin;
|
||||
import io.noties.markwon.Markwon;
|
||||
import io.noties.markwon.core.CorePlugin;
|
||||
import io.noties.markwon.core.MarkwonTheme;
|
||||
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
||||
import io.noties.markwon.ext.tables.TablePlugin;
|
||||
import io.noties.markwon.ext.tasklist.TaskListPlugin;
|
||||
import io.noties.markwon.html.HtmlPlugin;
|
||||
import io.noties.markwon.image.DefaultMediaDecoder;
|
||||
import io.noties.markwon.image.ImageItem;
|
||||
import io.noties.markwon.image.ImagesPlugin;
|
||||
import io.noties.markwon.image.SchemeHandler;
|
||||
import io.noties.markwon.image.gif.GifMediaDecoder;
|
||||
import io.noties.markwon.image.svg.SvgMediaDecoder;
|
||||
import io.noties.markwon.linkify.LinkifyPlugin;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
@ -99,13 +78,7 @@ import retrofit2.Response;
|
||||
public class IssueDetailActivity extends BaseActivity implements LabelsListAdapter.LabelsListAdapterListener, AssigneesListAdapter.AssigneesListAdapterListener, BottomSheetSingleIssueFragment.BottomSheetListener {
|
||||
|
||||
private IssueCommentsAdapter adapter;
|
||||
final Context ctx = this;
|
||||
private Context appCtx;
|
||||
private TinyDB tinyDb;
|
||||
|
||||
private String instanceUrl;
|
||||
private String loginUid;
|
||||
private String instanceToken;
|
||||
private String repoOwner;
|
||||
private String repoName;
|
||||
private int issueIndex;
|
||||
@ -137,21 +110,16 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
tinyDb = new TinyDB(appCtx);
|
||||
|
||||
viewBinding = ActivityIssueDetailBinding.inflate(getLayoutInflater());
|
||||
View view = viewBinding.getRoot();
|
||||
setContentView(view);
|
||||
|
||||
instanceUrl = tinyDb.getString("instanceUrl");
|
||||
loginUid = tinyDb.getString("loginUid");
|
||||
instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String repoFullName = tinyDB.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
repoOwner = parts[0];
|
||||
repoName = parts[1];
|
||||
issueIndex = Integer.parseInt(tinyDb.getString("issueNumber"));
|
||||
issueIndex = Integer.parseInt(tinyDB.getString("issueNumber"));
|
||||
|
||||
setSupportActionBar(viewBinding.toolbar);
|
||||
Objects.requireNonNull(getSupportActionBar()).setTitle(repoName);
|
||||
@ -164,12 +132,18 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(viewBinding.recyclerView.getContext(), DividerItemDecoration.VERTICAL);
|
||||
viewBinding.recyclerView.addItemDecoration(dividerItemDecoration);
|
||||
|
||||
viewBinding.addNewComment.setOnClickListener(v -> BottomSheetReplyFragment.newInstance(new Bundle()).show(getSupportFragmentManager(), "replyBottomSheet"));
|
||||
viewBinding.addNewComment.setOnClickListener(v -> {
|
||||
|
||||
BottomSheetReplyFragment bottomSheetReplyFragment = BottomSheetReplyFragment.newInstance(new Bundle());
|
||||
bottomSheetReplyFragment.setOnInteractedListener(this::onResume);
|
||||
bottomSheetReplyFragment.show(getSupportFragmentManager(), "replyBottomSheet");
|
||||
|
||||
});
|
||||
|
||||
labelsAdapter = new LabelsListAdapter(labelsList, IssueDetailActivity.this, currentLabelsIds);
|
||||
assigneesAdapter = new AssigneesListAdapter(ctx, assigneesList, IssueDetailActivity.this, currentAssignees);
|
||||
LabelsActions.getCurrentIssueLabels(ctx, instanceUrl, loginUid, instanceToken, repoOwner, repoName, issueIndex, currentLabelsIds);
|
||||
AssigneesActions.getCurrentIssueAssignees(ctx, instanceUrl, loginUid, instanceToken, repoOwner, repoName, issueIndex, currentAssignees);
|
||||
LabelsActions.getCurrentIssueLabels(ctx, repoOwner, repoName, issueIndex, currentLabelsIds);
|
||||
AssigneesActions.getCurrentIssueAssignees(ctx, repoOwner, repoName, issueIndex, currentAssignees);
|
||||
|
||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
|
||||
@ -198,14 +172,14 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
|
||||
viewBinding.pullToRefresh.setRefreshing(false);
|
||||
IssueCommentsViewModel
|
||||
.loadIssueComments(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, issueIndex,
|
||||
.loadIssueComments(Authorization.get(ctx), repoOwner, repoName, issueIndex,
|
||||
ctx);
|
||||
|
||||
}, 500));
|
||||
|
||||
Typeface myTypeface;
|
||||
|
||||
switch(tinyDb.getInt("customFontId", -1)) {
|
||||
switch(tinyDB.getInt("customFontId", -1)) {
|
||||
|
||||
case 1:
|
||||
myTypeface = Typeface.createFromAsset(Objects.requireNonNull(ctx).getAssets(), "fonts/manroperegular.ttf");
|
||||
@ -224,8 +198,8 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
viewBinding.toolbarTitle.setTypeface(myTypeface);
|
||||
viewBinding.toolbarTitle.setText(repoName);
|
||||
|
||||
getSingleIssue(instanceUrl, instanceToken, repoOwner, repoName, issueIndex, loginUid);
|
||||
fetchDataAsync(instanceUrl, instanceToken, repoOwner, repoName, issueIndex, loginUid);
|
||||
getSingleIssue(repoOwner, repoName, issueIndex);
|
||||
fetchDataAsync(repoOwner, repoName, issueIndex);
|
||||
|
||||
}
|
||||
|
||||
@ -295,7 +269,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
});
|
||||
|
||||
dialogAssignees.show();
|
||||
AssigneesActions.getRepositoryAssignees(ctx, instanceUrl, instanceToken, repoOwner, repoName, assigneesList, dialogAssignees, assigneesAdapter, assigneesBinding);
|
||||
AssigneesActions.getRepositoryAssignees(ctx, repoOwner, repoName, assigneesList, dialogAssignees, assigneesAdapter, assigneesBinding);
|
||||
}
|
||||
|
||||
public void showLabels() {
|
||||
@ -332,7 +306,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
});
|
||||
|
||||
dialogLabels.show();
|
||||
LabelsActions.getRepositoryLabels(ctx, instanceUrl, instanceToken, repoOwner, repoName, labelsList, dialogLabels, labelsAdapter, labelsBinding);
|
||||
LabelsActions.getRepositoryLabels(ctx, repoOwner, repoName, labelsList, dialogLabels, labelsAdapter, labelsBinding);
|
||||
}
|
||||
|
||||
private void updateIssueAssignees() {
|
||||
@ -342,9 +316,8 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
Call<JsonElement> call3;
|
||||
|
||||
call3 = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.patchIssueAssignees(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, issueIndex, updateAssigneeJson);
|
||||
.getApiInterface(ctx)
|
||||
.patchIssueAssignees(Authorization.get(ctx), repoOwner, repoName, issueIndex, updateAssigneeJson);
|
||||
|
||||
call3.enqueue(new Callback<JsonElement>() {
|
||||
|
||||
@ -359,9 +332,9 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
|
||||
viewBinding.frameAssignees.removeAllViews();
|
||||
viewBinding.frameLabels.removeAllViews();
|
||||
getSingleIssue(instanceUrl, instanceToken, repoOwner, repoName, issueIndex, loginUid);
|
||||
getSingleIssue(repoOwner, repoName, issueIndex);
|
||||
currentAssignees.clear();
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> AssigneesActions.getCurrentIssueAssignees(ctx, instanceUrl, loginUid, instanceToken, repoOwner, repoName, issueIndex, currentAssignees), 1000);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> AssigneesActions.getCurrentIssueAssignees(ctx, repoOwner, repoName, issueIndex, currentAssignees), 1000);
|
||||
}
|
||||
else if(response2.code() == 401) {
|
||||
|
||||
@ -398,9 +371,8 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
Labels patchIssueLabels = new Labels(labelsIds);
|
||||
|
||||
Call<JsonElement> call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.updateIssueLabels(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, issueIndex, patchIssueLabels);
|
||||
.getApiInterface(ctx)
|
||||
.updateIssueLabels(Authorization.get(ctx), repoOwner, repoName, issueIndex, patchIssueLabels);
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
|
||||
@ -414,9 +386,9 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
|
||||
viewBinding.frameAssignees.removeAllViews();
|
||||
viewBinding.frameLabels.removeAllViews();
|
||||
getSingleIssue(instanceUrl, instanceToken, repoOwner, repoName, issueIndex, loginUid);
|
||||
getSingleIssue(repoOwner, repoName, issueIndex);
|
||||
currentLabelsIds.clear();
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> LabelsActions.getCurrentIssueLabels(ctx, instanceUrl, loginUid, instanceToken, repoOwner, repoName, issueIndex, currentLabelsIds), 1000);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> LabelsActions.getCurrentIssueLabels(ctx, repoOwner, repoName, issueIndex, currentLabelsIds), 1000);
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
@ -483,61 +455,61 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
|
||||
super.onResume();
|
||||
|
||||
if(tinyDb.getBoolean("commentPosted")) {
|
||||
if(tinyDB.getBoolean("commentPosted")) {
|
||||
|
||||
viewBinding.scrollViewComments.post(() -> {
|
||||
|
||||
IssueCommentsViewModel
|
||||
.loadIssueComments(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, issueIndex,
|
||||
.loadIssueComments(Authorization.get(ctx), repoOwner, repoName, issueIndex,
|
||||
ctx);
|
||||
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> viewBinding.scrollViewComments.fullScroll(ScrollView.FOCUS_DOWN), 1000);
|
||||
|
||||
tinyDb.putBoolean("commentPosted", false);
|
||||
tinyDB.putBoolean("commentPosted", false);
|
||||
});
|
||||
}
|
||||
|
||||
if(tinyDb.getBoolean("commentEdited")) {
|
||||
if(tinyDB.getBoolean("commentEdited")) {
|
||||
|
||||
viewBinding.scrollViewComments.post(() -> {
|
||||
|
||||
IssueCommentsViewModel
|
||||
.loadIssueComments(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, issueIndex,
|
||||
.loadIssueComments(Authorization.get(ctx), repoOwner, repoName, issueIndex,
|
||||
ctx);
|
||||
tinyDb.putBoolean("commentEdited", false);
|
||||
tinyDB.putBoolean("commentEdited", false);
|
||||
});
|
||||
}
|
||||
|
||||
if(tinyDb.getBoolean("singleIssueUpdate")) {
|
||||
if(tinyDB.getBoolean("singleIssueUpdate")) {
|
||||
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
|
||||
viewBinding.frameAssignees.removeAllViews();
|
||||
viewBinding.frameLabels.removeAllViews();
|
||||
getSingleIssue(instanceUrl, instanceToken, repoOwner, repoName, issueIndex, loginUid);
|
||||
tinyDb.putBoolean("singleIssueUpdate", false);
|
||||
getSingleIssue(repoOwner, repoName, issueIndex);
|
||||
tinyDB.putBoolean("singleIssueUpdate", false);
|
||||
|
||||
}, 500);
|
||||
}
|
||||
|
||||
if(tinyDb.getBoolean("issueEdited")) {
|
||||
if(tinyDB.getBoolean("issueEdited")) {
|
||||
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
|
||||
viewBinding.frameAssignees.removeAllViews();
|
||||
viewBinding.frameLabels.removeAllViews();
|
||||
getSingleIssue(instanceUrl, instanceToken, repoOwner, repoName, issueIndex, loginUid);
|
||||
tinyDb.putBoolean("issueEdited", false);
|
||||
getSingleIssue(repoOwner, repoName, issueIndex);
|
||||
tinyDB.putBoolean("issueEdited", false);
|
||||
|
||||
}, 500);
|
||||
}
|
||||
}
|
||||
|
||||
private void fetchDataAsync(String instanceUrl, String instanceToken, String owner, String repo, int index, String loginUid) {
|
||||
private void fetchDataAsync(String owner, String repo, int index) {
|
||||
|
||||
IssueCommentsViewModel issueCommentsModel = new ViewModelProvider(this).get(IssueCommentsViewModel.class);
|
||||
|
||||
issueCommentsModel.getIssueCommentList(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), owner, repo, index, ctx)
|
||||
issueCommentsModel.getIssueCommentList(Authorization.get(ctx), owner, repo, index, ctx)
|
||||
.observe(this, issueCommentsMain -> {
|
||||
|
||||
assert issueCommentsMain != null;
|
||||
@ -547,16 +519,17 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
viewBinding.divider.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
adapter = new IssueCommentsAdapter(ctx, getSupportFragmentManager(), issueCommentsMain);
|
||||
adapter = new IssueCommentsAdapter(ctx, issueCommentsMain, getSupportFragmentManager(), this::onResume);
|
||||
viewBinding.recyclerView.setAdapter(adapter);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
private void getSingleIssue(String instanceUrl, String instanceToken, String repoOwner, String repoName, int issueIndex, String loginUid) {
|
||||
private void getSingleIssue(String repoOwner, String repoName, int issueIndex) {
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
||||
Call<Issues> call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface()
|
||||
.getIssueByIndex(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, issueIndex);
|
||||
final TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||
Call<Issues> call = RetrofitClient.getApiInterface(ctx)
|
||||
.getIssueByIndex(Authorization.get(ctx), repoOwner, repoName, issueIndex);
|
||||
|
||||
call.enqueue(new Callback<Issues>() {
|
||||
|
||||
@ -590,49 +563,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
viewBinding.issuePrState.setImageResource(R.drawable.ic_issue_closed_red);
|
||||
}
|
||||
|
||||
final Markwon markwon = Markwon.builder(Objects.requireNonNull(ctx)).usePlugin(CorePlugin.create())
|
||||
.usePlugin(ImagesPlugin.create(plugin -> {
|
||||
plugin.addSchemeHandler(new SchemeHandler() {
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ImageItem handle(@NonNull String raw, @NonNull Uri uri) {
|
||||
|
||||
final int resourceId = ctx.getResources()
|
||||
.getIdentifier(raw.substring("drawable://".length()), "drawable", ctx.getPackageName());
|
||||
|
||||
final Drawable drawable = ContextCompat.getDrawable(ctx, resourceId);
|
||||
|
||||
assert drawable != null;
|
||||
return ImageItem.withResult(drawable);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Collection<String> supportedSchemes() {
|
||||
|
||||
return Collections.singleton("drawable");
|
||||
}
|
||||
});
|
||||
plugin.placeholderProvider(drawable -> null);
|
||||
plugin.addMediaDecoder(GifMediaDecoder.create(false));
|
||||
plugin.addMediaDecoder(SvgMediaDecoder.create(ctx.getResources()));
|
||||
plugin.addMediaDecoder(SvgMediaDecoder.create());
|
||||
plugin.defaultMediaDecoder(DefaultMediaDecoder.create(ctx.getResources()));
|
||||
plugin.defaultMediaDecoder(DefaultMediaDecoder.create());
|
||||
|
||||
})).usePlugin(new AbstractMarkwonPlugin() {
|
||||
|
||||
@Override
|
||||
public void configureTheme(@NonNull MarkwonTheme.Builder builder) {
|
||||
|
||||
builder.codeTextColor(tinyDb.getInt("codeBlockColor")).codeBackgroundColor(tinyDb.getInt("codeBlockBackground"))
|
||||
.linkColor(getResources().getColor(R.color.lightBlue));
|
||||
}
|
||||
}).usePlugin(TablePlugin.create(ctx)).usePlugin(TaskListPlugin.create(ctx)).usePlugin(HtmlPlugin.create())
|
||||
.usePlugin(StrikethroughPlugin.create()).usePlugin(LinkifyPlugin.create()).build();
|
||||
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||
final String locale = tinyDb.getString("locale");
|
||||
final String timeFormat = tinyDb.getString("dateFormat");
|
||||
tinyDb.putString("issueState", singleIssue.getState());
|
||||
@ -645,8 +576,8 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
.getString(R.string.hash) + singleIssue.getNumber() + "</font>";
|
||||
viewBinding.issueTitle.setText(Html.fromHtml(issueNumber_ + " " + singleIssue.getTitle()));
|
||||
String cleanIssueDescription = singleIssue.getBody().trim();
|
||||
Spanned bodyWithMD = markwon.toMarkdown(EmojiParser.parseToUnicode(cleanIssueDescription));
|
||||
markwon.setParsedMarkdown(viewBinding.issueDescription, UserMentions.UserMentionsFunc(ctx, bodyWithMD, cleanIssueDescription));
|
||||
|
||||
new Markdown(ctx, EmojiParser.parseToUnicode(cleanIssueDescription), viewBinding.issueDescription);
|
||||
|
||||
RelativeLayout.LayoutParams paramsDesc = (RelativeLayout.LayoutParams) viewBinding.issueDescription.getLayoutParams();
|
||||
|
||||
@ -845,8 +776,8 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
|
||||
if(new Version(tinyDb.getString("giteaVersion")).higherOrEqual("1.12.0")) {
|
||||
|
||||
Call<WatchInfo> call2 = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface()
|
||||
.checkIssueWatchStatus(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, issueIndex);
|
||||
Call<WatchInfo> call2 = RetrofitClient.getApiInterface(appCtx)
|
||||
.checkIssueWatchStatus(Authorization.get(ctx), repoOwner, repoName, issueIndex);
|
||||
|
||||
call2.enqueue(new Callback<WatchInfo>() {
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
@ -46,10 +45,6 @@ public class LoginActivity extends BaseActivity {
|
||||
|
||||
private enum LoginType {BASIC, TOKEN}
|
||||
|
||||
private Context appCtx;
|
||||
private Context ctx = this;
|
||||
private TinyDB tinyDB;
|
||||
|
||||
private Button loginButton;
|
||||
private EditText instanceUrlET, loginUidET, loginPassword, otpCode, loginTokenCode;
|
||||
private AutoCompleteTextView protocolSpinner;
|
||||
@ -67,9 +62,7 @@ public class LoginActivity extends BaseActivity {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
|
||||
tinyDB = new TinyDB(appCtx);
|
||||
NetworkObserver networkMonitor = new NetworkObserver(ctx);
|
||||
|
||||
loginButton = findViewById(R.id.login_button);
|
||||
@ -210,7 +203,7 @@ public class LoginActivity extends BaseActivity {
|
||||
int loginOTP = (otpCode.length() > 0) ? Integer.parseInt(otpCode.getText().toString().trim()) : 0;
|
||||
tinyDB.putString("loginUid", loginUid);
|
||||
|
||||
versionCheck(instanceUrl.toString(), loginUid, loginPass, loginOTP, loginToken, loginType);
|
||||
versionCheck(loginUid, loginPass, loginOTP, loginToken, loginType);
|
||||
|
||||
}
|
||||
else {
|
||||
@ -222,7 +215,7 @@ public class LoginActivity extends BaseActivity {
|
||||
return;
|
||||
}
|
||||
|
||||
versionCheck(instanceUrl.toString(), loginUid, loginPass, 123, loginToken, loginType);
|
||||
versionCheck(loginUid, loginPass, 123, loginToken, loginType);
|
||||
}
|
||||
|
||||
}
|
||||
@ -234,22 +227,22 @@ public class LoginActivity extends BaseActivity {
|
||||
}
|
||||
}
|
||||
|
||||
private void versionCheck(final String instanceUrl, final String loginUid, final String loginPass, final int loginOTP, final String loginToken,
|
||||
private void versionCheck(final String loginUid, final String loginPass, final int loginOTP, final String loginToken,
|
||||
final LoginType loginType) {
|
||||
|
||||
Call<GiteaVersion> callVersion;
|
||||
|
||||
if(!loginToken.equals("")) {
|
||||
|
||||
callVersion = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().getGiteaVersionWithToken("token " + loginToken);
|
||||
callVersion = RetrofitClient.getApiInterface(appCtx).getGiteaVersionWithToken("token " + loginToken);
|
||||
}
|
||||
else {
|
||||
|
||||
String credential = Credentials.basic(loginUid, loginPass, StandardCharsets.UTF_8);
|
||||
|
||||
callVersion =
|
||||
(loginOTP != 0) ? RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().getGiteaVersionWithOTP(credential, loginOTP) :
|
||||
RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().getGiteaVersionWithBasic(credential);
|
||||
(loginOTP != 0) ? RetrofitClient.getApiInterface(appCtx).getGiteaVersionWithOTP(credential, loginOTP) :
|
||||
RetrofitClient.getApiInterface(appCtx).getGiteaVersionWithBasic(credential);
|
||||
}
|
||||
|
||||
callVersion.enqueue(new Callback<GiteaVersion>() {
|
||||
@ -287,7 +280,7 @@ public class LoginActivity extends BaseActivity {
|
||||
alertDialogBuilder.setPositiveButton(getString(R.string.textContinue), (dialog, which) -> {
|
||||
|
||||
dialog.dismiss();
|
||||
login(loginType, instanceUrl, loginUid, loginPass, loginOTP, loginToken);
|
||||
login(loginType, loginUid, loginPass, loginOTP, loginToken);
|
||||
});
|
||||
|
||||
alertDialogBuilder.create().show();
|
||||
@ -295,34 +288,34 @@ public class LoginActivity extends BaseActivity {
|
||||
}
|
||||
else if(gitea_version.lessOrEqual(getString(R.string.versionHigh))) {
|
||||
|
||||
login(loginType, instanceUrl, loginUid, loginPass, loginOTP, loginToken);
|
||||
login(loginType, loginUid, loginPass, loginOTP, loginToken);
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.warning(ctx, getResources().getString(R.string.versionUnsupportedNew));
|
||||
login(loginType, instanceUrl, loginUid, loginPass, loginOTP, loginToken);
|
||||
login(loginType, loginUid, loginPass, loginOTP, loginToken);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else if(responseVersion.code() == 403) {
|
||||
|
||||
login(loginType, instanceUrl, loginUid, loginPass, loginOTP, loginToken);
|
||||
login(loginType, loginUid, loginPass, loginOTP, loginToken);
|
||||
}
|
||||
}
|
||||
|
||||
private void login(LoginType loginType, String instanceUrl, String loginUid, String loginPass, int loginOTP, String loginToken) {
|
||||
private void login(LoginType loginType, String loginUid, String loginPass, int loginOTP, String loginToken) {
|
||||
|
||||
// ToDo: before store/create token: get UserInfo to check DB/AccountManager if there already exist a token
|
||||
// the setup methods then can better handle all different cases
|
||||
|
||||
if(loginType == LoginType.BASIC) {
|
||||
|
||||
setup(instanceUrl, loginUid, loginPass, loginOTP);
|
||||
setup(loginUid, loginPass, loginOTP);
|
||||
}
|
||||
else if(loginType == LoginType.TOKEN) { // Token
|
||||
|
||||
setupUsingExistingToken(instanceUrl, loginToken);
|
||||
setupUsingExistingToken(loginToken);
|
||||
}
|
||||
}
|
||||
|
||||
@ -336,9 +329,9 @@ public class LoginActivity extends BaseActivity {
|
||||
});
|
||||
}
|
||||
|
||||
private void setupUsingExistingToken(String instanceUrl, final String loginToken) {
|
||||
private void setupUsingExistingToken(final String loginToken) {
|
||||
|
||||
Call<UserInfo> call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().getUserInfo("token " + loginToken);
|
||||
Call<UserInfo> call = RetrofitClient.getApiInterface(appCtx).getUserInfo("token " + loginToken);
|
||||
|
||||
call.enqueue(new Callback<UserInfo>() {
|
||||
|
||||
@ -358,14 +351,14 @@ public class LoginActivity extends BaseActivity {
|
||||
tinyDB.putString("userLogin", userDetails.getUsername());
|
||||
|
||||
// insert new account to db if does not exist
|
||||
String accountName = userDetails.getUsername() + "@" + instanceUrl;
|
||||
String accountName = userDetails.getUsername() + "@" + TinyDB.getInstance(ctx).getString("instanceUrl");
|
||||
UserAccountsApi userAccountsApi = new UserAccountsApi(ctx);
|
||||
int checkAccount = userAccountsApi.getCount(accountName);
|
||||
long accountId;
|
||||
|
||||
if(checkAccount == 0) {
|
||||
|
||||
accountId = userAccountsApi.insertNewAccount(accountName, instanceUrl, userDetails.getUsername(), loginToken, "");
|
||||
accountId = userAccountsApi.insertNewAccount(accountName, TinyDB.getInstance(ctx).getString("instanceUrl"), userDetails.getUsername(), loginToken, "");
|
||||
tinyDB.putInt("currentActiveAccountId", (int) accountId);
|
||||
}
|
||||
else {
|
||||
@ -402,7 +395,7 @@ public class LoginActivity extends BaseActivity {
|
||||
|
||||
}
|
||||
|
||||
private void setup(final String instanceUrl, final String loginUid, final String loginPass, final int loginOTP) {
|
||||
private void setup(final String loginUid, final String loginPass, final int loginOTP) {
|
||||
|
||||
final String credential = Credentials.basic(loginUid, loginPass, StandardCharsets.UTF_8);
|
||||
final String tokenName = "gitnex-app-" + device_id;
|
||||
@ -410,11 +403,11 @@ public class LoginActivity extends BaseActivity {
|
||||
Call<List<UserTokens>> call;
|
||||
if(loginOTP != 0) {
|
||||
|
||||
call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().getUserTokensWithOTP(credential, loginOTP, loginUid);
|
||||
call = RetrofitClient.getApiInterface(appCtx).getUserTokensWithOTP(credential, loginOTP, loginUid);
|
||||
}
|
||||
else {
|
||||
|
||||
call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().getUserTokens(credential, loginUid);
|
||||
call = RetrofitClient.getApiInterface(appCtx).getUserTokens(credential, loginUid);
|
||||
}
|
||||
|
||||
call.enqueue(new Callback<List<UserTokens>>() {
|
||||
@ -438,12 +431,12 @@ public class LoginActivity extends BaseActivity {
|
||||
Call<Void> delcall;
|
||||
if(loginOTP != 0) {
|
||||
|
||||
delcall = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface()
|
||||
delcall = RetrofitClient.getApiInterface(ctx)
|
||||
.deleteTokenWithOTP(credential, loginOTP, loginUid, t.getId());
|
||||
}
|
||||
else {
|
||||
|
||||
delcall = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().deleteToken(credential, loginUid, t.getId());
|
||||
delcall = RetrofitClient.getApiInterface(ctx).deleteToken(credential, loginUid, t.getId());
|
||||
}
|
||||
|
||||
delcall.enqueue(new Callback<Void>() {
|
||||
@ -453,7 +446,7 @@ public class LoginActivity extends BaseActivity {
|
||||
|
||||
if(response.code() == 204) {
|
||||
|
||||
setupToken(instanceUrl, loginUid, loginPass, loginOTP, tokenName);
|
||||
setupToken(loginUid, loginPass, loginOTP, tokenName);
|
||||
}
|
||||
else {
|
||||
|
||||
@ -474,7 +467,7 @@ public class LoginActivity extends BaseActivity {
|
||||
}
|
||||
}
|
||||
|
||||
setupToken(instanceUrl, loginUid, loginPass, loginOTP, tokenName);
|
||||
setupToken(loginUid, loginPass, loginOTP, tokenName);
|
||||
}
|
||||
else {
|
||||
|
||||
@ -494,7 +487,7 @@ public class LoginActivity extends BaseActivity {
|
||||
|
||||
}
|
||||
|
||||
private void setupToken(final String instanceUrl, final String loginUid, final String loginPass, final int loginOTP, final String tokenName) {
|
||||
private void setupToken(final String loginUid, final String loginPass, final int loginOTP, final String tokenName) {
|
||||
|
||||
final String credential = Credentials.basic(loginUid, loginPass, StandardCharsets.UTF_8);
|
||||
|
||||
@ -503,12 +496,13 @@ public class LoginActivity extends BaseActivity {
|
||||
|
||||
if(loginOTP != 0) {
|
||||
|
||||
callCreateToken = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface()
|
||||
callCreateToken = RetrofitClient.getApiInterface(ctx)
|
||||
.createNewTokenWithOTP(credential, loginOTP, loginUid, createUserToken);
|
||||
}
|
||||
else {
|
||||
|
||||
callCreateToken = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().createNewToken(credential, loginUid, createUserToken);
|
||||
callCreateToken = RetrofitClient.getApiInterface(ctx)
|
||||
.createNewToken(credential, loginUid, createUserToken);
|
||||
}
|
||||
|
||||
callCreateToken.enqueue(new Callback<UserTokens>() {
|
||||
@ -523,7 +517,7 @@ public class LoginActivity extends BaseActivity {
|
||||
|
||||
if(!newToken.getSha1().equals("")) {
|
||||
|
||||
Call<UserInfo> call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface()
|
||||
Call<UserInfo> call = RetrofitClient.getApiInterface(ctx)
|
||||
.getUserInfo("token " + newToken.getSha1());
|
||||
|
||||
call.enqueue(new Callback<UserInfo>() {
|
||||
@ -545,7 +539,7 @@ public class LoginActivity extends BaseActivity {
|
||||
tinyDB.putString(loginUid + "-token-last-eight", newToken.getToken_last_eight());
|
||||
|
||||
// insert new account to db if does not exist
|
||||
String accountName = userDetails.getUsername() + "@" + instanceUrl;
|
||||
String accountName = userDetails.getUsername() + "@" + TinyDB.getInstance(ctx).getString("instanceUrl");
|
||||
UserAccountsApi userAccountsApi = new UserAccountsApi(ctx);
|
||||
int checkAccount = userAccountsApi.getCount(accountName);
|
||||
long accountId;
|
||||
@ -553,7 +547,7 @@ public class LoginActivity extends BaseActivity {
|
||||
if(checkAccount == 0) {
|
||||
|
||||
accountId = userAccountsApi
|
||||
.insertNewAccount(accountName, instanceUrl, userDetails.getUsername(), newToken.getSha1(), "");
|
||||
.insertNewAccount(accountName, TinyDB.getInstance(ctx).getString("instanceUrl"), userDetails.getUsername(), newToken.getSha1(), "");
|
||||
tinyDB.putInt("currentActiveAccountId", (int) accountId);
|
||||
}
|
||||
else {
|
||||
|
@ -77,12 +77,8 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
private ImageView userAvatarBackground;
|
||||
private ViewGroup navHeaderFrame;
|
||||
private TextView toolbarTitle;
|
||||
final Context ctx = this;
|
||||
private Context appCtx;
|
||||
private static TinyDB tinyDb;
|
||||
private Typeface myTypeface;
|
||||
|
||||
private String instanceUrl;
|
||||
private String loginUid;
|
||||
private String instanceToken;
|
||||
|
||||
@ -100,49 +96,46 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
|
||||
tinyDb = new TinyDB(appCtx);
|
||||
tinyDb.putBoolean("noConnection", false);
|
||||
tinyDB.putBoolean("noConnection", false);
|
||||
|
||||
Intent mainIntent = getIntent();
|
||||
String launchFragment = mainIntent.getStringExtra("launchFragment");
|
||||
|
||||
instanceUrl = tinyDb.getString("instanceUrl");
|
||||
loginUid = tinyDb.getString("loginUid");
|
||||
instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
loginUid = tinyDB.getString("loginUid");
|
||||
instanceToken = "token " + tinyDB.getString(loginUid + "-token");
|
||||
|
||||
if(tinyDb.getString("dateFormat").isEmpty()) {
|
||||
if(tinyDB.getString("dateFormat").isEmpty()) {
|
||||
|
||||
tinyDb.putString("dateFormat", "pretty");
|
||||
tinyDB.putString("dateFormat", "pretty");
|
||||
}
|
||||
|
||||
if(tinyDb.getString("codeBlockStr").isEmpty()) {
|
||||
if(tinyDB.getString("codeBlockStr").isEmpty()) {
|
||||
|
||||
tinyDb.putInt("codeBlockColor", getResources().getColor(R.color.colorLightGreen));
|
||||
tinyDb.putInt("codeBlockBackground", getResources().getColor(R.color.black));
|
||||
tinyDB.putInt("codeBlockColor", getResources().getColor(R.color.colorLightGreen));
|
||||
tinyDB.putInt("codeBlockBackground", getResources().getColor(R.color.black));
|
||||
}
|
||||
|
||||
if(tinyDb.getString("enableCounterIssueBadgeInit").isEmpty()) {
|
||||
if(tinyDB.getString("enableCounterIssueBadgeInit").isEmpty()) {
|
||||
|
||||
tinyDb.putBoolean("enableCounterIssueBadge", true);
|
||||
tinyDB.putBoolean("enableCounterIssueBadge", true);
|
||||
}
|
||||
|
||||
if(tinyDb.getString("homeScreenStr").isEmpty()) {
|
||||
if(tinyDB.getString("homeScreenStr").isEmpty()) {
|
||||
|
||||
tinyDb.putString("homeScreenStr", "yes");
|
||||
tinyDb.putInt("homeScreenId", 0);
|
||||
tinyDB.putString("homeScreenStr", "yes");
|
||||
tinyDB.putInt("homeScreenId", 0);
|
||||
}
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
if(!tinyDb.getBoolean("loggedInMode")) {
|
||||
if(!tinyDB.getBoolean("loggedInMode")) {
|
||||
|
||||
logout(this, ctx);
|
||||
return;
|
||||
}
|
||||
|
||||
if(tinyDb.getInt("currentActiveAccountId") <= 0) {
|
||||
if(tinyDB.getInt("currentActiveAccountId") <= 0) {
|
||||
|
||||
AlertDialogs.forceLogoutDialog(ctx, getResources().getString(R.string.forceLogoutDialogHeader), getResources().getString(R.string.forceLogoutDialogDescription), getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
||||
}
|
||||
@ -150,7 +143,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
toolbarTitle = toolbar.findViewById(R.id.toolbar_title);
|
||||
|
||||
switch(tinyDb.getInt("customFontId", -1)) {
|
||||
switch(tinyDB.getInt("customFontId", -1)) {
|
||||
|
||||
case 0:
|
||||
|
||||
@ -213,7 +206,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleUserAccounts));
|
||||
}
|
||||
|
||||
getNotificationsCount(instanceUrl, instanceToken);
|
||||
getNotificationsCount(instanceToken);
|
||||
|
||||
drawer = findViewById(R.id.drawer_layout);
|
||||
NavigationView navigationView = findViewById(R.id.nav_view);
|
||||
@ -231,21 +224,21 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
@Override
|
||||
public void onDrawerOpened(@NonNull View drawerView) {
|
||||
|
||||
getNotificationsCount(instanceUrl, instanceToken);
|
||||
getNotificationsCount(instanceToken);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDrawerSlide(@NonNull View drawerView, float slideOffset) {
|
||||
|
||||
if(tinyDb.getBoolean("noConnection")) {
|
||||
if(tinyDB.getBoolean("noConnection")) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
tinyDb.putBoolean("noConnection", false);
|
||||
tinyDB.putBoolean("noConnection", false);
|
||||
}
|
||||
|
||||
String userEmailNav = tinyDb.getString("userEmail");
|
||||
String userFullNameNav = tinyDb.getString("userFullname");
|
||||
String userAvatarNav = tinyDb.getString("userAvatar");
|
||||
String userEmailNav = tinyDB.getString("userEmail");
|
||||
String userFullNameNav = tinyDB.getString("userFullname");
|
||||
String userAvatarNav = tinyDB.getString("userAvatar");
|
||||
|
||||
blurView = hView.findViewById(R.id.blurView);
|
||||
userEmail = hView.findViewById(R.id.userEmail);
|
||||
@ -326,9 +319,9 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
drawer.closeDrawers();
|
||||
});
|
||||
|
||||
String currentVersion = tinyDb.getString("giteaVersion");
|
||||
String currentVersion = tinyDB.getString("giteaVersion");
|
||||
|
||||
navigationView.getMenu().findItem(R.id.nav_administration).setVisible(tinyDb.getBoolean("userIsAdmin"));
|
||||
navigationView.getMenu().findItem(R.id.nav_administration).setVisible(tinyDB.getBoolean("userIsAdmin"));
|
||||
navigationView.getMenu().findItem(R.id.nav_notifications).setVisible(new Version(currentVersion).higherOrEqual("1.12.3"));
|
||||
}
|
||||
|
||||
@ -397,15 +390,15 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
|
||||
if(savedInstanceState == null) {
|
||||
|
||||
if(!new Version(tinyDb.getString("giteaVersion")).higherOrEqual("1.12.3")) {
|
||||
if(!new Version(tinyDB.getString("giteaVersion")).higherOrEqual("1.12.3")) {
|
||||
|
||||
if(tinyDb.getInt("homeScreenId") == 7) {
|
||||
if(tinyDB.getInt("homeScreenId") == 7) {
|
||||
|
||||
tinyDb.putInt("homeScreenId", 0);
|
||||
tinyDB.putInt("homeScreenId", 0);
|
||||
}
|
||||
}
|
||||
|
||||
switch(tinyDb.getInt("homeScreenId")) {
|
||||
switch(tinyDB.getInt("homeScreenId")) {
|
||||
|
||||
case 1:
|
||||
|
||||
@ -460,18 +453,18 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
|
||||
if(!connToInternet) {
|
||||
|
||||
if(!tinyDb.getBoolean("noConnection")) {
|
||||
if(!tinyDB.getBoolean("noConnection")) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
}
|
||||
|
||||
tinyDb.putBoolean("noConnection", true);
|
||||
tinyDB.putBoolean("noConnection", true);
|
||||
}
|
||||
else {
|
||||
|
||||
loadUserInfo(instanceUrl, instanceToken, loginUid);
|
||||
giteaVersion(instanceUrl);
|
||||
tinyDb.putBoolean("noConnection", false);
|
||||
loadUserInfo(instanceToken, loginUid);
|
||||
giteaVersion();
|
||||
tinyDB.putBoolean("noConnection", false);
|
||||
}
|
||||
|
||||
// Changelog popup
|
||||
@ -487,10 +480,10 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
Log.e("changelogDialog", Objects.requireNonNull(e.getMessage()));
|
||||
}
|
||||
|
||||
if(versionCode > tinyDb.getInt("versionCode")) {
|
||||
if(versionCode > tinyDB.getInt("versionCode")) {
|
||||
|
||||
tinyDb.putInt("versionCode", versionCode);
|
||||
tinyDb.putBoolean("versionFlag", true);
|
||||
tinyDB.putInt("versionCode", versionCode);
|
||||
tinyDB.putBoolean("versionFlag", true);
|
||||
|
||||
ChangeLog changelogDialog = new ChangeLog(this);
|
||||
changelogDialog.showDialog();
|
||||
@ -505,7 +498,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
@Override
|
||||
public void onButtonClicked(String text) {
|
||||
|
||||
TinyDB tinyDb = new TinyDB(ctx);
|
||||
TinyDB tinyDb = TinyDB.getInstance(ctx);
|
||||
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
||||
|
||||
if("deleteDrafts".equals(text)) {
|
||||
@ -625,9 +618,11 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
|
||||
public static void logout(Activity activity, Context ctx) {
|
||||
|
||||
tinyDb.putBoolean("loggedInMode", false);
|
||||
tinyDb.remove("basicAuthPassword");
|
||||
tinyDb.putBoolean("basicAuthFlag", false);
|
||||
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));
|
||||
@ -648,13 +643,13 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
private void giteaVersion(final String instanceUrl) {
|
||||
private void giteaVersion() {
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
||||
final TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||
|
||||
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
||||
|
||||
Call<GiteaVersion> callVersion = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().getGiteaVersionWithToken(token);
|
||||
Call<GiteaVersion> callVersion = RetrofitClient.getApiInterface(ctx).getGiteaVersionWithToken(token);
|
||||
|
||||
callVersion.enqueue(new Callback<GiteaVersion>() {
|
||||
|
||||
@ -678,11 +673,11 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
});
|
||||
}
|
||||
|
||||
private void loadUserInfo(String instanceUrl, String token, String loginUid) {
|
||||
private void loadUserInfo(String token, String loginUid) {
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
||||
final TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||
|
||||
Call<UserInfo> call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().getUserInfo(Authorization.returnAuthentication(ctx, loginUid, token));
|
||||
Call<UserInfo> call = RetrofitClient.getApiInterface(ctx).getUserInfo(Authorization.get(ctx));
|
||||
|
||||
call.enqueue(new Callback<UserInfo>() {
|
||||
|
||||
@ -747,9 +742,9 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
|
||||
}
|
||||
|
||||
private void getNotificationsCount(String instanceUrl, String token) {
|
||||
private void getNotificationsCount(String token) {
|
||||
|
||||
Call<NotificationCount> call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().checkUnreadNotifications(token);
|
||||
Call<NotificationCount> call = RetrofitClient.getApiInterface(ctx).checkUnreadNotifications(token);
|
||||
|
||||
call.enqueue(new Callback<NotificationCount>() {
|
||||
|
||||
|
@ -15,7 +15,6 @@ import org.mian.gitnex.databinding.ActivityMergePullRequestBinding;
|
||||
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.models.MergePullRequest;
|
||||
@ -33,13 +32,7 @@ import retrofit2.Callback;
|
||||
public class MergePullRequestActivity extends BaseActivity {
|
||||
|
||||
private View.OnClickListener onClickListener;
|
||||
final Context ctx = this;
|
||||
private Context appCtx;
|
||||
private TinyDB tinyDb;
|
||||
|
||||
private String instanceUrl;
|
||||
private String loginUid;
|
||||
private String instanceToken;
|
||||
private String repoOwner;
|
||||
private String repoName;
|
||||
private int prIndex;
|
||||
@ -59,21 +52,16 @@ public class MergePullRequestActivity extends BaseActivity {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
tinyDb = new TinyDB(appCtx);
|
||||
|
||||
viewBinding = ActivityMergePullRequestBinding.inflate(getLayoutInflater());
|
||||
View view = viewBinding.getRoot();
|
||||
setContentView(view);
|
||||
|
||||
instanceUrl = tinyDb.getString("instanceUrl");
|
||||
loginUid = tinyDb.getString("loginUid");
|
||||
instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String repoFullName = tinyDB.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
repoOwner = parts[0];
|
||||
repoName = parts[1];
|
||||
prIndex = Integer.parseInt(tinyDb.getString("issueNumber"));
|
||||
prIndex = Integer.parseInt(tinyDB.getString("issueNumber"));
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
@ -85,22 +73,22 @@ public class MergePullRequestActivity extends BaseActivity {
|
||||
|
||||
setMergeAdapter();
|
||||
|
||||
if(!tinyDb.getString("issueTitle").isEmpty()) {
|
||||
if(!tinyDB.getString("issueTitle").isEmpty()) {
|
||||
|
||||
viewBinding.toolbarTitle.setText(tinyDb.getString("issueTitle"));
|
||||
viewBinding.mergeTitle.setText(tinyDb.getString("issueTitle") + " (#" + tinyDb.getString("issueNumber") + ")");
|
||||
viewBinding.toolbarTitle.setText(tinyDB.getString("issueTitle"));
|
||||
viewBinding.mergeTitle.setText(tinyDB.getString("issueTitle") + " (#" + tinyDB.getString("issueNumber") + ")");
|
||||
}
|
||||
|
||||
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(new Version(tinyDB.getString("giteaVersion")).higherOrEqual("1.12.0")) {
|
||||
|
||||
viewBinding.deleteBranch.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
if(tinyDb.getString("prMergeable").equals("false")) {
|
||||
if(tinyDB.getString("prMergeable").equals("false")) {
|
||||
|
||||
disableProcessButton();
|
||||
viewBinding.mergeInfoDisabledMessage.setVisibility(View.VISIBLE);
|
||||
@ -110,7 +98,7 @@ public class MergePullRequestActivity extends BaseActivity {
|
||||
viewBinding.mergeInfoDisabledMessage.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if(tinyDb.getString("prIsFork").equals("true")) {
|
||||
if(tinyDB.getString("prIsFork").equals("true")) {
|
||||
|
||||
viewBinding.deleteBranchForkInfo.setVisibility(View.VISIBLE);
|
||||
}
|
||||
@ -138,7 +126,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(new Version(tinyDB.getString("giteaVersion")).higher("1.11.4")) {
|
||||
|
||||
mergeList.add(new MergePullRequestSpinner("squash", getResources().getString(R.string.mergeOptionSquash)));
|
||||
}
|
||||
@ -189,7 +177,7 @@ public class MergePullRequestActivity extends BaseActivity {
|
||||
|
||||
MergePullRequest mergePR = new MergePullRequest(Do, mergePRDT, mergeTitle);
|
||||
|
||||
Call<ResponseBody> call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().mergePullRequest(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, prIndex, mergePR);
|
||||
Call<ResponseBody> call = RetrofitClient.getApiInterface(ctx).mergePullRequest(Authorization.get(ctx), repoOwner, repoName, prIndex, mergePR);
|
||||
|
||||
call.enqueue(new Callback<ResponseBody>() {
|
||||
|
||||
@ -200,9 +188,9 @@ public class MergePullRequestActivity extends BaseActivity {
|
||||
|
||||
if(deleteBranch) {
|
||||
|
||||
if(tinyDb.getString("prIsFork").equals("true")) {
|
||||
if(tinyDB.getString("prIsFork").equals("true")) {
|
||||
|
||||
String repoFullName = tinyDb.getString("prForkFullName");
|
||||
String repoFullName = tinyDB.getString("prForkFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
@ -210,13 +198,13 @@ public class MergePullRequestActivity extends BaseActivity {
|
||||
deleteBranchFunction(repoOwner, repoName);
|
||||
|
||||
Toasty.success(ctx, getString(R.string.mergePRSuccessMsg));
|
||||
tinyDb.putBoolean("prMerged", true);
|
||||
tinyDb.putBoolean("resumePullRequests", true);
|
||||
tinyDB.putBoolean("prMerged", true);
|
||||
tinyDB.putBoolean("resumePullRequests", true);
|
||||
finish();
|
||||
}
|
||||
else {
|
||||
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String repoFullName = tinyDB.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
@ -224,8 +212,8 @@ public class MergePullRequestActivity extends BaseActivity {
|
||||
deleteBranchFunction(repoOwner, repoName);
|
||||
|
||||
Toasty.success(ctx, getString(R.string.mergePRSuccessMsg));
|
||||
tinyDb.putBoolean("prMerged", true);
|
||||
tinyDb.putBoolean("resumePullRequests", true);
|
||||
tinyDB.putBoolean("prMerged", true);
|
||||
tinyDB.putBoolean("resumePullRequests", true);
|
||||
finish();
|
||||
}
|
||||
|
||||
@ -233,8 +221,8 @@ public class MergePullRequestActivity extends BaseActivity {
|
||||
else {
|
||||
|
||||
Toasty.success(ctx, getString(R.string.mergePRSuccessMsg));
|
||||
tinyDb.putBoolean("prMerged", true);
|
||||
tinyDb.putBoolean("resumePullRequests", true);
|
||||
tinyDB.putBoolean("prMerged", true);
|
||||
tinyDB.putBoolean("resumePullRequests", true);
|
||||
finish();
|
||||
}
|
||||
|
||||
@ -275,12 +263,11 @@ public class MergePullRequestActivity extends BaseActivity {
|
||||
|
||||
private void deleteBranchFunction(String repoOwner, String repoName) {
|
||||
|
||||
String branchName = tinyDb.getString("prHeadBranch");
|
||||
String branchName = tinyDB.getString("prHeadBranch");
|
||||
|
||||
Call<JsonElement> call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.deleteBranch(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, branchName);
|
||||
.getApiInterface(ctx)
|
||||
.deleteBranch(Authorization.get(ctx), repoOwner, repoName, branchName);
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
|
||||
|
@ -25,8 +25,9 @@ public class OpenRepoInBrowserActivity extends AppCompatActivity {
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
appCtx = getApplicationContext();
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||
|
||||
try {
|
||||
|
||||
|
@ -25,7 +25,6 @@ import org.mian.gitnex.fragments.MembersByOrgFragment;
|
||||
import org.mian.gitnex.fragments.OrganizationInfoFragment;
|
||||
import org.mian.gitnex.fragments.RepositoriesByOrgFragment;
|
||||
import org.mian.gitnex.fragments.TeamsByOrgFragment;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import java.util.Objects;
|
||||
import io.mikael.urlbuilder.UrlBuilder;
|
||||
@ -36,10 +35,6 @@ import io.mikael.urlbuilder.UrlBuilder;
|
||||
|
||||
public class OrganizationDetailActivity extends BaseActivity implements BottomSheetOrganizationFragment.BottomSheetListener {
|
||||
|
||||
final Context ctx = this;
|
||||
private Context appCtx;
|
||||
private TinyDB tinyDb;
|
||||
|
||||
@Override
|
||||
protected int getLayoutResourceId(){
|
||||
return R.layout.activity_org_detail;
|
||||
@ -49,11 +44,8 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
tinyDb = new TinyDB(appCtx);
|
||||
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
String orgName = tinyDb.getString("orgName");
|
||||
String orgName = tinyDB.getString("orgName");
|
||||
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
TextView toolbarTitle = toolbar.findViewById(R.id.toolbar_title);
|
||||
@ -71,7 +63,7 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
||||
|
||||
Typeface myTypeface;
|
||||
|
||||
switch(tinyDb.getInt("customFontId", -1)) {
|
||||
switch(tinyDB.getInt("customFontId", -1)) {
|
||||
|
||||
case 0:
|
||||
|
||||
@ -150,7 +142,7 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
||||
switch (text) {
|
||||
case "repository":
|
||||
|
||||
tinyDb.putBoolean("organizationAction", true);
|
||||
tinyDB.putBoolean("organizationAction", true);
|
||||
startActivity(new Intent(OrganizationDetailActivity.this, CreateRepoActivity.class));
|
||||
break;
|
||||
case "team":
|
||||
@ -159,11 +151,11 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
||||
break;
|
||||
case "copyOrgUrl":
|
||||
|
||||
String url = UrlBuilder.fromString(tinyDb.getString("instanceUrl"))
|
||||
String url = UrlBuilder.fromString(tinyDB.getString("instanceUrl"))
|
||||
.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 + tinyDB.getString("orgName"));
|
||||
assert clipboard != null;
|
||||
clipboard.setPrimaryClip(clip);
|
||||
Toasty.info(ctx, ctx.getString(R.string.copyIssueUrlToastMsg));
|
||||
@ -188,7 +180,7 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
||||
}
|
||||
else {
|
||||
|
||||
orgName = tinyDb.getString("orgName");
|
||||
orgName = tinyDB.getString("orgName");
|
||||
}
|
||||
|
||||
Fragment fragment = null;
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
@ -15,7 +14,6 @@ import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.TeamMembersByOrgAdapter;
|
||||
import org.mian.gitnex.fragments.BottomSheetOrganizationFragment;
|
||||
import org.mian.gitnex.fragments.BottomSheetOrganizationTeamsFragment;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
@ -34,9 +32,6 @@ public class OrganizationTeamMembersActivity extends BaseActivity implements Bot
|
||||
private GridView mGridView;
|
||||
private ProgressBar progressBar;
|
||||
|
||||
final Context ctx = this;
|
||||
private Context appCtx;
|
||||
|
||||
private String teamId;
|
||||
|
||||
@Override
|
||||
@ -48,15 +43,10 @@ public class OrganizationTeamMembersActivity extends BaseActivity implements Bot
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
ImageView closeActivity = findViewById(R.id.close);
|
||||
TextView toolbarTitle = findViewById(R.id.toolbar_title);
|
||||
noDataMembers = findViewById(R.id.noDataMembers);
|
||||
@ -85,30 +75,27 @@ public class OrganizationTeamMembersActivity extends BaseActivity implements Bot
|
||||
}
|
||||
|
||||
assert teamId != null;
|
||||
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), Integer.parseInt(teamId));
|
||||
fetchDataAsync(Authorization.get(ctx), Integer.parseInt(teamId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
|
||||
super.onResume();
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||
|
||||
if(tinyDb.getBoolean("teamActionFlag")) {
|
||||
|
||||
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), Integer.parseInt(teamId));
|
||||
fetchDataAsync(Authorization.get(ctx), Integer.parseInt(teamId));
|
||||
tinyDb.putBoolean("teamActionFlag", false);
|
||||
}
|
||||
}
|
||||
|
||||
private void fetchDataAsync(String instanceUrl, String instanceToken, int teamId) {
|
||||
private void fetchDataAsync(String instanceToken, int teamId) {
|
||||
|
||||
TeamMembersByOrgViewModel teamMembersModel = new ViewModelProvider(this).get(TeamMembersByOrgViewModel.class);
|
||||
|
||||
teamMembersModel.getMembersByOrgList(instanceUrl, instanceToken, teamId, ctx).observe(this, teamMembersListMain -> {
|
||||
teamMembersModel.getMembersByOrgList(instanceToken, teamId, ctx).observe(this, teamMembersListMain -> {
|
||||
|
||||
adapter = new TeamMembersByOrgAdapter(ctx, teamMembersListMain);
|
||||
|
||||
|
@ -33,8 +33,6 @@ public class ProfileEmailActivity extends BaseActivity {
|
||||
|
||||
private View.OnClickListener onClickListener;
|
||||
private EditText userEmail;
|
||||
final Context ctx = this;
|
||||
private Context appCtx;
|
||||
private Button addEmailButton;
|
||||
|
||||
@Override
|
||||
@ -46,7 +44,6 @@ public class ProfileEmailActivity extends BaseActivity {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
@ -78,10 +75,6 @@ public class ProfileEmailActivity extends BaseActivity {
|
||||
private void processAddNewEmail() {
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
String newUserEmail = userEmail.getText().toString().trim();
|
||||
|
||||
@ -105,19 +98,18 @@ public class ProfileEmailActivity extends BaseActivity {
|
||||
List<String> newEmailList = new ArrayList<>(Arrays.asList(newUserEmail.split(",")));
|
||||
|
||||
disableProcessButton();
|
||||
addNewEmail(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), newEmailList);
|
||||
addNewEmail(Authorization.get(ctx), newEmailList);
|
||||
}
|
||||
|
||||
private void addNewEmail(final String instanceUrl, final String token, List<String> newUserEmail) {
|
||||
private void addNewEmail(final String token, List<String> newUserEmail) {
|
||||
|
||||
AddEmail addEmailFunc = new AddEmail(newUserEmail);
|
||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
||||
final TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||
|
||||
Call<JsonElement> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.getApiInterface(appCtx)
|
||||
.addNewEmail(token, addEmailFunc);
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
|
@ -1,349 +0,0 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.actions.IssueActions;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.database.api.DraftsApi;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.StaticGlobalVariables;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.models.Issues;
|
||||
import java.util.Objects;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
public class ReplyToIssueActivity extends BaseActivity {
|
||||
|
||||
public ImageView closeActivity;
|
||||
private View.OnClickListener onClickListener;
|
||||
|
||||
final Context ctx = this;
|
||||
private Context appCtx;
|
||||
|
||||
private TextView draftSaved;
|
||||
private EditText addComment;
|
||||
private Button replyButton;
|
||||
private String TAG = StaticGlobalVariables.replyToIssueActivity;
|
||||
private long draftIdOnCreate;
|
||||
|
||||
@Override
|
||||
protected int getLayoutResourceId(){
|
||||
return R.layout.activity_reply_to_issue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
|
||||
draftSaved = findViewById(R.id.draftSaved);
|
||||
addComment = findViewById(R.id.addComment);
|
||||
addComment.setShowSoftInputOnFocus(true);
|
||||
|
||||
closeActivity = findViewById(R.id.close);
|
||||
TextView toolbar_title = findViewById(R.id.toolbar_title);
|
||||
|
||||
addComment.requestFocus();
|
||||
assert imm != null;
|
||||
imm.showSoftInput(addComment, InputMethodManager.SHOW_IMPLICIT);
|
||||
|
||||
if(!tinyDb.getString("issueTitle").isEmpty()) {
|
||||
|
||||
toolbar_title.setText(tinyDb.getString("issueTitle"));
|
||||
}
|
||||
|
||||
initCloseListener();
|
||||
closeActivity.setOnClickListener(onClickListener);
|
||||
|
||||
if(getIntent().getStringExtra("draftId") != null) {
|
||||
|
||||
draftIdOnCreate = Long.parseLong(Objects.requireNonNull(getIntent().getStringExtra("draftId")));
|
||||
}
|
||||
else {
|
||||
|
||||
if(getIntent().getStringExtra("commentBody") != null) {
|
||||
|
||||
draftIdOnCreate = returnDraftId(getIntent().getStringExtra("commentBody"));
|
||||
}
|
||||
else {
|
||||
|
||||
draftIdOnCreate = returnDraftId("");
|
||||
}
|
||||
}
|
||||
|
||||
replyButton = findViewById(R.id.replyButton);
|
||||
|
||||
if(getIntent().getStringExtra("commentBody") != null) {
|
||||
|
||||
addComment.setText(getIntent().getStringExtra("commentBody"));
|
||||
|
||||
if(getIntent().getBooleanExtra("cursorToEnd", false)) {
|
||||
|
||||
addComment.setSelection(addComment.length());
|
||||
}
|
||||
}
|
||||
|
||||
if(getIntent().getStringExtra("draftTitle") != null) {
|
||||
|
||||
toolbar_title.setText(getIntent().getStringExtra("draftTitle"));
|
||||
}
|
||||
|
||||
if(getIntent().getStringExtra("commentAction") != null && Objects.equals(getIntent().getStringExtra("commentAction"), "edit") && !Objects.equals(getIntent().getStringExtra("commentId"), "new")) {
|
||||
|
||||
final String commentId = getIntent().getStringExtra("commentId");
|
||||
|
||||
toolbar_title.setText(getResources().getString(R.string.editCommentTitle));
|
||||
replyButton.setText(getResources().getString(R.string.editCommentButtonText));
|
||||
|
||||
addComment.addTextChangedListener(new TextWatcher() {
|
||||
|
||||
public void afterTextChanged(Editable s) {
|
||||
}
|
||||
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
}
|
||||
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
|
||||
saveDraft(addComment.getText().toString(), commentId, draftIdOnCreate);
|
||||
draftSaved.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
replyButton.setOnClickListener(v -> {
|
||||
|
||||
disableProcessButton();
|
||||
assert commentId != null;
|
||||
IssueActions.editIssueComment(ctx, Integer.parseInt(commentId), addComment.getText().toString(), draftIdOnCreate);
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
addComment.addTextChangedListener(new TextWatcher() {
|
||||
|
||||
public void afterTextChanged(Editable s) {
|
||||
}
|
||||
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
}
|
||||
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
|
||||
saveDraft(addComment.getText().toString(), "new", draftIdOnCreate);
|
||||
draftSaved.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
if(!connToInternet) {
|
||||
|
||||
disableProcessButton();
|
||||
}
|
||||
else {
|
||||
|
||||
replyButton.setOnClickListener(replyToIssue);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void saveDraft(String draftText, String commentId, long draftIdOnCreate) {
|
||||
|
||||
TinyDB tinyDb = new TinyDB(getApplicationContext());
|
||||
|
||||
int repositoryId = (int) tinyDb.getLong("repositoryId", 0);
|
||||
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
||||
int issueNumber = Integer.parseInt(tinyDb.getString("issueNumber"));
|
||||
|
||||
DraftsApi draftsApi = new DraftsApi(appCtx);
|
||||
|
||||
if(draftIdOnCreate == 0) {
|
||||
|
||||
draftsApi.insertDraft(repositoryId, currentActiveAccountId, issueNumber, draftText, StaticGlobalVariables.draftTypeComment, commentId);
|
||||
}
|
||||
else {
|
||||
|
||||
DraftsApi.updateDraft(draftText, (int) draftIdOnCreate, commentId); //updateDraftByIssueIdAsyncTask(draftText, issueNumber, repositoryId, commentId);
|
||||
}
|
||||
}
|
||||
|
||||
private long returnDraftId(String draftText) {
|
||||
|
||||
TinyDB tinyDb = new TinyDB(getApplicationContext());
|
||||
|
||||
int repositoryId = (int) tinyDb.getLong("repositoryId", 0);
|
||||
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
||||
int issueNumber = Integer.parseInt(tinyDb.getString("issueNumber"));
|
||||
|
||||
DraftsApi draftsApi = new DraftsApi(appCtx);
|
||||
|
||||
return draftsApi.insertDraft(repositoryId, currentActiveAccountId, issueNumber, draftText, StaticGlobalVariables.draftTypeComment, "");
|
||||
|
||||
}
|
||||
|
||||
private void initCloseListener() {
|
||||
|
||||
onClickListener = view -> finish();
|
||||
}
|
||||
|
||||
private final View.OnClickListener replyToIssue = v -> processNewCommentReply();
|
||||
|
||||
private void processNewCommentReply() {
|
||||
|
||||
String newReplyDT = addComment.getText().toString();
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
if(!connToInternet) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
return;
|
||||
}
|
||||
|
||||
if(newReplyDT.equals("")) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.commentEmptyError));
|
||||
}
|
||||
else {
|
||||
|
||||
disableProcessButton();
|
||||
replyComment(newReplyDT);
|
||||
}
|
||||
}
|
||||
|
||||
private void replyComment(String newReplyDT) {
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
||||
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
final int issueIndex = Integer.parseInt(tinyDb.getString("issueNumber"));
|
||||
|
||||
Issues issueComment = new Issues(newReplyDT);
|
||||
|
||||
Call<Issues> call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.replyCommentToIssue(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, issueIndex, issueComment);
|
||||
|
||||
call.enqueue(new Callback<Issues>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Issues> call, @NonNull retrofit2.Response<Issues> response) {
|
||||
|
||||
if(response.code() == 201) {
|
||||
|
||||
Toasty.success(ctx, getString(R.string.commentSuccess));
|
||||
tinyDb.putBoolean("commentPosted", true);
|
||||
tinyDb.putBoolean("resumeIssues", true);
|
||||
tinyDb.putBoolean("resumePullRequests", true);
|
||||
|
||||
// delete draft comment
|
||||
if(tinyDb.getBoolean("draftsCommentsDeletionEnabled")) {
|
||||
|
||||
DraftsApi draftsApi = new DraftsApi(appCtx);
|
||||
draftsApi.deleteSingleDraft((int) draftIdOnCreate);
|
||||
}
|
||||
|
||||
finish();
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
enableProcessButton();
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle),
|
||||
getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
||||
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
||||
}
|
||||
else {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, getString(R.string.commentError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Issues> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e(TAG, t.toString());
|
||||
enableProcessButton();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.reply_to_issue, menu);
|
||||
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
|
||||
int id = item.getItemId();
|
||||
|
||||
if(id == R.id.replyToIssueMenu) {
|
||||
|
||||
Intent fragmentIntent = new Intent(ReplyToIssueActivity.this, MainActivity.class);
|
||||
fragmentIntent.putExtra("launchFragment", "drafts");
|
||||
ReplyToIssueActivity.this.startActivity(fragmentIntent);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
private void disableProcessButton() {
|
||||
|
||||
replyButton.setEnabled(false);
|
||||
}
|
||||
|
||||
private void enableProcessButton() {
|
||||
|
||||
replyButton.setEnabled(true);
|
||||
}
|
||||
|
||||
}
|
@ -42,7 +42,6 @@ import org.mian.gitnex.fragments.PullRequestsFragment;
|
||||
import org.mian.gitnex.fragments.ReleasesFragment;
|
||||
import org.mian.gitnex.fragments.RepoInfoFragment;
|
||||
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.models.Branches;
|
||||
@ -71,12 +70,6 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
||||
private FragmentRefreshListenerMilestone fragmentRefreshListenerMilestone;
|
||||
private FragmentRefreshListenerFiles fragmentRefreshListenerFiles;
|
||||
|
||||
private final Context ctx = this;
|
||||
private Context appCtx;
|
||||
|
||||
private TinyDB tinyDB;
|
||||
|
||||
private String instanceUrl;
|
||||
private String loginUid;
|
||||
private String instanceToken;
|
||||
|
||||
@ -96,9 +89,6 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
|
||||
tinyDB = new TinyDB(appCtx);
|
||||
|
||||
String[] repoNameParts = tinyDB.getString("repoFullName").split("/");
|
||||
repositoryOwner = repoNameParts[0];
|
||||
@ -113,7 +103,6 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
||||
Objects.requireNonNull(getSupportActionBar()).setTitle(repositoryName);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
instanceUrl = tinyDB.getString("instanceUrl");
|
||||
loginUid = tinyDB.getString("loginUid");
|
||||
instanceToken = "token " + tinyDB.getString(loginUid + "-token");
|
||||
|
||||
@ -198,7 +187,7 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
||||
textViewBadgePull.setVisibility(View.GONE);
|
||||
textViewBadgeRelease.setVisibility(View.GONE);
|
||||
|
||||
getRepoInfo(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repositoryOwner, repositoryName);
|
||||
getRepoInfo(Authorization.get(ctx), repositoryOwner, repositoryName);
|
||||
ColorStateList textColor = tabLayout.getTabTextColors();
|
||||
|
||||
// Issue count
|
||||
@ -254,8 +243,8 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
||||
}
|
||||
}
|
||||
|
||||
checkRepositoryStarStatus(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repositoryOwner, repositoryName);
|
||||
checkRepositoryWatchStatus(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repositoryOwner, repositoryName);
|
||||
checkRepositoryStarStatus(Authorization.get(ctx), repositoryOwner, repositoryName);
|
||||
checkRepositoryWatchStatus(Authorization.get(ctx), repositoryOwner, repositoryName);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -265,7 +254,7 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
||||
|
||||
if(tinyDB.getBoolean("enableCounterIssueBadge")) {
|
||||
|
||||
getRepoInfo(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repositoryOwner, repositoryName);
|
||||
getRepoInfo(Authorization.get(ctx), repositoryOwner, repositoryName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -434,8 +423,8 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
||||
|
||||
private void chooseBranch() {
|
||||
|
||||
Call<List<Branches>> call = RetrofitClient.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
Call<List<Branches>> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.getBranches(instanceToken, repositoryOwner, repositoryName);
|
||||
|
||||
call.enqueue(new Callback<List<Branches>>() {
|
||||
@ -547,9 +536,9 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
||||
}
|
||||
}
|
||||
|
||||
private void getRepoInfo(String instanceUrl, String token, final String owner, String repo) {
|
||||
private void getRepoInfo(String token, final String owner, String repo) {
|
||||
|
||||
Call<UserRepositories> call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().getUserRepository(token, owner, repo);
|
||||
Call<UserRepositories> call = RetrofitClient.getApiInterface(ctx).getUserRepository(token, owner, repo);
|
||||
call.enqueue(new Callback<UserRepositories>() {
|
||||
|
||||
@Override
|
||||
@ -599,9 +588,9 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
||||
|
||||
}
|
||||
|
||||
private void checkRepositoryStarStatus(String instanceUrl, String instanceToken, final String owner, String repo) {
|
||||
private void checkRepositoryStarStatus(String instanceToken, final String owner, String repo) {
|
||||
|
||||
Call<JsonElement> call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().checkRepoStarStatus(instanceToken, owner, repo);
|
||||
Call<JsonElement> call = RetrofitClient.getApiInterface(ctx).checkRepoStarStatus(instanceToken, owner, repo);
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
|
||||
@Override
|
||||
@ -619,11 +608,11 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
||||
|
||||
}
|
||||
|
||||
private void checkRepositoryWatchStatus(String instanceUrl, String instanceToken, final String owner, String repo) {
|
||||
private void checkRepositoryWatchStatus(String instanceToken, final String owner, String repo) {
|
||||
|
||||
Call<WatchInfo> call;
|
||||
|
||||
call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().checkRepoWatchStatus(instanceToken, owner, repo);
|
||||
call = RetrofitClient.getApiInterface(ctx).checkRepoWatchStatus(instanceToken, owner, repo);
|
||||
call.enqueue(new Callback<WatchInfo>() {
|
||||
|
||||
@Override
|
||||
|
@ -1,7 +1,6 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
@ -42,8 +41,6 @@ import retrofit2.Response;
|
||||
|
||||
public class RepoForksActivity extends BaseActivity {
|
||||
|
||||
final Context ctx = this;
|
||||
private Context appCtx;
|
||||
private View.OnClickListener onClickListener;
|
||||
private TextView noData;
|
||||
private ProgressBar progressBar;
|
||||
@ -67,14 +64,11 @@ public class RepoForksActivity extends BaseActivity {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||
|
||||
String repoFullNameForForks = getIntent().getStringExtra("repoFullNameForForks");
|
||||
assert repoFullNameForForks != null;
|
||||
@ -111,7 +105,7 @@ public class RepoForksActivity extends BaseActivity {
|
||||
swipeRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
|
||||
swipeRefresh.setRefreshing(false);
|
||||
loadInitial(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, pageSize, resultLimit);
|
||||
loadInitial(Authorization.get(ctx), repoOwner, repoName, pageSize, resultLimit);
|
||||
adapter.notifyDataChanged();
|
||||
|
||||
}, 200));
|
||||
@ -122,7 +116,7 @@ public class RepoForksActivity extends BaseActivity {
|
||||
if(forksList.size() == resultLimit || pageSize == resultLimit) {
|
||||
|
||||
int page = (forksList.size() + resultLimit) / resultLimit;
|
||||
loadMore(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, page, resultLimit);
|
||||
loadMore(Authorization.get(ctx), repoOwner, repoName, page, resultLimit);
|
||||
}
|
||||
}));
|
||||
|
||||
@ -130,14 +124,13 @@ public class RepoForksActivity extends BaseActivity {
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(ctx));
|
||||
recyclerView.setAdapter(adapter);
|
||||
|
||||
loadInitial(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, pageSize, resultLimit);
|
||||
loadInitial(Authorization.get(ctx), repoOwner, repoName, pageSize, resultLimit);
|
||||
}
|
||||
|
||||
private void loadInitial(String instanceUrl, String instanceToken, String repoOwner, String repoName, int pageSize, int resultLimit) {
|
||||
private void loadInitial(String instanceToken, String repoOwner, String repoName, int pageSize, int resultLimit) {
|
||||
|
||||
Call<List<UserRepositories>> call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.getApiInterface(ctx)
|
||||
.getRepositoryForks(instanceToken, repoOwner, repoName, pageSize, resultLimit);
|
||||
|
||||
call.enqueue(new Callback<List<UserRepositories>>() {
|
||||
@ -180,13 +173,12 @@ public class RepoForksActivity extends BaseActivity {
|
||||
|
||||
}
|
||||
|
||||
private void loadMore(String instanceUrl, String instanceToken, String repoOwner, String repoName, int page, int resultLimit) {
|
||||
private void loadMore(String instanceToken, String repoOwner, String repoName, int page, int resultLimit) {
|
||||
|
||||
progressLoadMore.setVisibility(View.VISIBLE);
|
||||
|
||||
Call<List<UserRepositories>> call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.getApiInterface(ctx)
|
||||
.getRepositoryForks(instanceToken, repoOwner, repoName, page, resultLimit);
|
||||
|
||||
call.enqueue(new Callback<List<UserRepositories>>() {
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.GridView;
|
||||
@ -11,7 +10,6 @@ import androidx.lifecycle.ViewModelProvider;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.RepoStargazersAdapter;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.viewmodels.RepoStargazersViewModel;
|
||||
|
||||
/**
|
||||
@ -26,9 +24,6 @@ public class RepoStargazersActivity extends BaseActivity {
|
||||
private GridView mGridView;
|
||||
private ProgressBar mProgressBar;
|
||||
|
||||
final Context ctx = this;
|
||||
private Context appCtx;
|
||||
|
||||
@Override
|
||||
protected int getLayoutResourceId(){
|
||||
return R.layout.activity_repo_stargazers;
|
||||
@ -38,12 +33,6 @@ public class RepoStargazersActivity extends BaseActivity {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
ImageView closeActivity = findViewById(R.id.close);
|
||||
TextView toolbarTitle = findViewById(R.id.toolbar_title);
|
||||
@ -61,14 +50,14 @@ public class RepoStargazersActivity extends BaseActivity {
|
||||
|
||||
toolbarTitle.setText(R.string.repoStargazersInMenu);
|
||||
|
||||
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName);
|
||||
fetchDataAsync(Authorization.get(ctx), repoOwner, repoName);
|
||||
}
|
||||
|
||||
private void fetchDataAsync(String instanceUrl, String instanceToken, String repoOwner, String repoName) {
|
||||
private void fetchDataAsync(String instanceToken, String repoOwner, String repoName) {
|
||||
|
||||
RepoStargazersViewModel repoStargazersModel = new ViewModelProvider(this).get(RepoStargazersViewModel.class);
|
||||
|
||||
repoStargazersModel.getRepoStargazers(instanceUrl, instanceToken, repoOwner, repoName, ctx).observe(this, stargazersListMain -> {
|
||||
repoStargazersModel.getRepoStargazers(instanceToken, repoOwner, repoName, ctx).observe(this, stargazersListMain -> {
|
||||
|
||||
adapter = new RepoStargazersAdapter(ctx, stargazersListMain);
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.GridView;
|
||||
@ -11,7 +10,6 @@ import androidx.lifecycle.ViewModelProvider;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.RepoWatchersAdapter;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.viewmodels.RepoWatchersViewModel;
|
||||
|
||||
/**
|
||||
@ -26,9 +24,6 @@ public class RepoWatchersActivity extends BaseActivity {
|
||||
private GridView mGridView;
|
||||
private ProgressBar mProgressBar;
|
||||
|
||||
final Context ctx = this;
|
||||
private Context appCtx;
|
||||
|
||||
@Override
|
||||
protected int getLayoutResourceId(){
|
||||
return R.layout.activity_repo_watchers;
|
||||
@ -38,12 +33,6 @@ public class RepoWatchersActivity extends BaseActivity {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
ImageView closeActivity = findViewById(R.id.close);
|
||||
TextView toolbarTitle = findViewById(R.id.toolbar_title);
|
||||
@ -61,14 +50,14 @@ public class RepoWatchersActivity extends BaseActivity {
|
||||
|
||||
toolbarTitle.setText(R.string.repoWatchersInMenu);
|
||||
|
||||
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName);
|
||||
fetchDataAsync(Authorization.get(ctx), repoOwner, repoName);
|
||||
}
|
||||
|
||||
private void fetchDataAsync(String instanceUrl, String instanceToken, String repoOwner, String repoName) {
|
||||
private void fetchDataAsync(String instanceToken, String repoOwner, String repoName) {
|
||||
|
||||
RepoWatchersViewModel repoWatchersModel = new ViewModelProvider(this).get(RepoWatchersViewModel.class);
|
||||
|
||||
repoWatchersModel.getRepoWatchers(instanceUrl, instanceToken, repoOwner, repoName, ctx).observe(this, watchersListMain -> {
|
||||
repoWatchersModel.getRepoWatchers(instanceToken, repoOwner, repoName, ctx).observe(this, watchersListMain -> {
|
||||
|
||||
adapter = new RepoWatchersAdapter(ctx, watchersListMain);
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
@ -18,7 +17,6 @@ import org.mian.gitnex.databinding.ActivityRepositorySettingsBinding;
|
||||
import org.mian.gitnex.databinding.CustomRepositoryDeleteDialogBinding;
|
||||
import org.mian.gitnex.databinding.CustomRepositoryEditPropertiesDialogBinding;
|
||||
import org.mian.gitnex.databinding.CustomRepositoryTransferDialogBinding;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import org.mian.gitnex.models.RepositoryTransfer;
|
||||
@ -40,11 +38,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
||||
private Dialog dialogDeleteRepository;
|
||||
private Dialog dialogTransferRepository;
|
||||
private View.OnClickListener onClickListener;
|
||||
private Context ctx = this;
|
||||
private Context appCtx;
|
||||
private TinyDB tinyDb;
|
||||
|
||||
private String instanceUrl;
|
||||
private String loginUid;
|
||||
private String instanceToken;
|
||||
|
||||
@ -60,20 +54,17 @@ public class RepositorySettingsActivity extends BaseActivity {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
tinyDb = new TinyDB(appCtx);
|
||||
|
||||
viewBinding = ActivityRepositorySettingsBinding.inflate(getLayoutInflater());
|
||||
View view = viewBinding.getRoot();
|
||||
setContentView(view);
|
||||
|
||||
instanceUrl = tinyDb.getString("instanceUrl");
|
||||
loginUid = tinyDb.getString("loginUid");
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
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");
|
||||
instanceToken = "token " + tinyDB.getString(loginUid + "-token");
|
||||
|
||||
ImageView closeActivity = findViewById(R.id.close);
|
||||
|
||||
@ -81,7 +72,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(new Version(tinyDB.getString("giteaVersion")).higherOrEqual("1.12.0")) {
|
||||
|
||||
viewBinding.transferOwnerFrame.setVisibility(View.VISIBLE);
|
||||
}
|
||||
@ -136,8 +127,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
||||
RepositoryTransfer repositoryTransfer = new RepositoryTransfer(newOwner);
|
||||
|
||||
Call<JsonElement> transferCall = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.getApiInterface(ctx)
|
||||
.transferRepository(instanceToken, repositoryOwner, repositoryName, repositoryTransfer);
|
||||
|
||||
transferCall.enqueue(new Callback<JsonElement>() {
|
||||
@ -154,7 +144,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
||||
Toasty.success(ctx, getString(R.string.repoTransferSuccess));
|
||||
|
||||
finish();
|
||||
RepositoriesApi.deleteRepository((int) tinyDb.getLong("repositoryId", 0));
|
||||
RepositoriesApi.deleteRepository((int) tinyDB.getLong("repositoryId", 0));
|
||||
Intent intent = new Intent(RepositorySettingsActivity.this, MainActivity.class);
|
||||
RepositorySettingsActivity.this.startActivity(intent);
|
||||
}
|
||||
@ -217,8 +207,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
||||
private void deleteRepository() {
|
||||
|
||||
Call<JsonElement> deleteCall = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.getApiInterface(ctx)
|
||||
.deleteRepository(instanceToken, repositoryOwner, repositoryName);
|
||||
|
||||
deleteCall.enqueue(new Callback<JsonElement>() {
|
||||
@ -235,7 +224,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
||||
Toasty.success(ctx, getString(R.string.repoDeletionSuccess));
|
||||
|
||||
finish();
|
||||
RepositoriesApi.deleteRepository((int) tinyDb.getLong("repositoryId", 0));
|
||||
RepositoriesApi.deleteRepository((int) tinyDB.getLong("repositoryId", 0));
|
||||
Intent intent = new Intent(RepositorySettingsActivity.this, MainActivity.class);
|
||||
RepositorySettingsActivity.this.startActivity(intent);
|
||||
}
|
||||
@ -275,8 +264,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
||||
propBinding.cancel.setOnClickListener(editProperties -> dialogProp.dismiss());
|
||||
|
||||
Call<UserRepositories> call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.getApiInterface(ctx)
|
||||
.getUserRepository(instanceToken, repositoryOwner, repositoryName);
|
||||
|
||||
call.enqueue(new Callback<UserRepositories>() {
|
||||
@ -376,8 +364,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
Call<UserRepositories> propsCall = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.getApiInterface(ctx)
|
||||
.updateRepositoryProperties(instanceToken, repositoryOwner, repositoryName, repoProps);
|
||||
|
||||
propsCall.enqueue(new Callback<UserRepositories>() {
|
||||
@ -390,8 +377,8 @@ public class RepositorySettingsActivity extends BaseActivity {
|
||||
|
||||
if (response.code() == 200) {
|
||||
|
||||
tinyDb.putBoolean("hasIssues", repoEnableIssues);
|
||||
tinyDb.putBoolean("hasPullRequests", repoEnablePr);
|
||||
tinyDB.putBoolean("hasIssues", repoEnableIssues);
|
||||
tinyDB.putBoolean("hasPullRequests", repoEnablePr);
|
||||
|
||||
dialogProp.dismiss();
|
||||
Toasty.success(ctx, getString(R.string.repoPropertiesSaveSuccess));
|
||||
@ -399,7 +386,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
||||
if(!repositoryName.equals(repoName)) {
|
||||
|
||||
finish();
|
||||
RepositoriesApi.updateRepositoryOwnerAndName(repositoryOwner, repoName, (int) tinyDb.getLong("repositoryId", 0));
|
||||
RepositoriesApi.updateRepositoryOwnerAndName(repositoryOwner, repoName, (int) tinyDB.getLong("repositoryId", 0));
|
||||
Intent intent = new Intent(RepositorySettingsActivity.this, MainActivity.class);
|
||||
RepositorySettingsActivity.this.startActivity(intent);
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
@ -9,11 +8,7 @@ import android.widget.TextView;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import com.google.android.material.switchmaterial.SwitchMaterial;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
@ -21,15 +16,11 @@ import java.util.List;
|
||||
|
||||
public class SettingsAppearanceActivity extends BaseActivity {
|
||||
|
||||
private Context appCtx;
|
||||
private View.OnClickListener onClickListener;
|
||||
|
||||
private static final String[] timeList = {"Pretty", "Normal"};
|
||||
private static int timeSelectedChoice = 0;
|
||||
|
||||
private List<String> codeBlockList;
|
||||
private static int codeBlockSelectedChoice = 0;
|
||||
|
||||
private static final String[] customFontList = {"Roboto", "Manrope", "Source Code Pro"};
|
||||
private static int customFontSelectedChoice = 0;
|
||||
|
||||
@ -46,19 +37,14 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
||||
|
||||
ImageView closeActivity = findViewById(R.id.close);
|
||||
|
||||
final TextView tvDateTimeSelected = findViewById(R.id.tvDateTimeSelected); // setter for time
|
||||
final TextView codeBlockSelected = findViewById(R.id.codeBlockSelected); // setter for code block
|
||||
final TextView customFontSelected = findViewById(R.id.customFontSelected); // setter for custom font
|
||||
final TextView themeSelected = findViewById(R.id.themeSelected); // setter for theme
|
||||
|
||||
LinearLayout timeFrame = findViewById(R.id.timeFrame);
|
||||
LinearLayout codeBlockFrame = findViewById(R.id.codeBlockFrame);
|
||||
LinearLayout customFontFrame = findViewById(R.id.customFontFrame);
|
||||
LinearLayout themeFrame = findViewById(R.id.themeSelectionFrame);
|
||||
|
||||
@ -67,124 +53,42 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
||||
initCloseListener();
|
||||
closeActivity.setOnClickListener(onClickListener);
|
||||
|
||||
// code block
|
||||
String[] codeBlockList_ = {getResources().getString(R.string.codeBlockGreenOnBlack), getResources().getString(R.string.codeBlockWhiteOnBlack),
|
||||
getResources().getString(R.string.codeBlockGreyOnBlack), getResources().getString(R.string.codeBlockWhiteOnGrey),
|
||||
getResources().getString(R.string.codeBlockDarkOnWhite)};
|
||||
if(!tinyDB.getString("timeStr").isEmpty()) {
|
||||
|
||||
codeBlockList = new ArrayList<>(Arrays.asList(codeBlockList_));
|
||||
String[] codeBlockArray = new String[codeBlockList.size()];
|
||||
codeBlockList.toArray(codeBlockArray);
|
||||
|
||||
if(codeBlockSelectedChoice == 0) {
|
||||
|
||||
codeBlockSelectedChoice = tinyDb.getInt("codeBlockId");
|
||||
codeBlockSelected.setText(getResources().getString(R.string.codeBlockGreenOnBlack));
|
||||
tvDateTimeSelected.setText(tinyDB.getString("timeStr"));
|
||||
}
|
||||
|
||||
if(codeBlockSelectedChoice == 1) {
|
||||
if(!tinyDB.getString("customFontStr").isEmpty()) {
|
||||
|
||||
codeBlockSelected.setText(getResources().getString(R.string.codeBlockWhiteOnBlack));
|
||||
}
|
||||
else if(codeBlockSelectedChoice == 2) {
|
||||
|
||||
codeBlockSelected.setText(getResources().getString(R.string.codeBlockGreyOnBlack));
|
||||
}
|
||||
else if(codeBlockSelectedChoice == 3) {
|
||||
|
||||
codeBlockSelected.setText(getResources().getString(R.string.codeBlockWhiteOnGrey));
|
||||
}
|
||||
else if(codeBlockSelectedChoice == 4) {
|
||||
|
||||
codeBlockSelected.setText(getResources().getString(R.string.codeBlockDarkOnWhite));
|
||||
customFontSelected.setText(tinyDB.getString("customFontStr"));
|
||||
}
|
||||
|
||||
codeBlockFrame.setOnClickListener(codeBlock -> {
|
||||
if(!tinyDB.getString("themeStr").isEmpty()) {
|
||||
|
||||
AlertDialog.Builder cBuilder = new AlertDialog.Builder(SettingsAppearanceActivity.this);
|
||||
|
||||
cBuilder.setTitle(R.string.settingsCodeBlockSelectorDialogTitle);
|
||||
cBuilder.setCancelable(codeBlockSelectedChoice != -1);
|
||||
|
||||
cBuilder.setSingleChoiceItems(codeBlockList_, codeBlockSelectedChoice, (dialogInterfaceCodeBlock, i) -> {
|
||||
|
||||
codeBlockSelectedChoice = i;
|
||||
codeBlockSelected.setText(codeBlockList_[i]);
|
||||
tinyDb.putInt("codeBlockId", i);
|
||||
|
||||
switch(i) {
|
||||
case 1: // white on black
|
||||
|
||||
tinyDb.putInt("codeBlockColor", getResources().getColor(R.color.colorWhite));
|
||||
tinyDb.putInt("codeBlockBackground", getResources().getColor(R.color.black));
|
||||
break;
|
||||
case 2: // grey on black
|
||||
|
||||
tinyDb.putInt("codeBlockColor", getResources().getColor(R.color.colorAccent));
|
||||
tinyDb.putInt("codeBlockBackground", getResources().getColor(R.color.black));
|
||||
break;
|
||||
case 3: // white on grey
|
||||
|
||||
tinyDb.putInt("codeBlockColor", getResources().getColor(R.color.colorWhite));
|
||||
tinyDb.putInt("codeBlockBackground", getResources().getColor(R.color.colorAccent));
|
||||
break;
|
||||
case 4: // dark on white
|
||||
|
||||
tinyDb.putInt("codeBlockColor", getResources().getColor(R.color.colorPrimary));
|
||||
tinyDb.putInt("codeBlockBackground", getResources().getColor(R.color.colorWhite));
|
||||
break;
|
||||
default: // green on black
|
||||
|
||||
tinyDb.putInt("codeBlockColor", getResources().getColor(R.color.colorLightGreen));
|
||||
tinyDb.putInt("codeBlockBackground", getResources().getColor(R.color.black));
|
||||
break;
|
||||
}
|
||||
|
||||
dialogInterfaceCodeBlock.dismiss();
|
||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||
});
|
||||
|
||||
AlertDialog cDialog = cBuilder.create();
|
||||
cDialog.show();
|
||||
});
|
||||
// code block
|
||||
|
||||
if(!tinyDb.getString("timeStr").isEmpty()) {
|
||||
|
||||
tvDateTimeSelected.setText(tinyDb.getString("timeStr"));
|
||||
}
|
||||
|
||||
if(!tinyDb.getString("customFontStr").isEmpty()) {
|
||||
|
||||
customFontSelected.setText(tinyDb.getString("customFontStr"));
|
||||
}
|
||||
|
||||
if(!tinyDb.getString("themeStr").isEmpty()) {
|
||||
|
||||
themeSelected.setText(tinyDb.getString("themeStr"));
|
||||
themeSelected.setText(tinyDB.getString("themeStr"));
|
||||
}
|
||||
|
||||
if(timeSelectedChoice == 0) {
|
||||
|
||||
timeSelectedChoice = tinyDb.getInt("timeId");
|
||||
timeSelectedChoice = tinyDB.getInt("timeId");
|
||||
}
|
||||
|
||||
if(customFontSelectedChoice == 0) {
|
||||
|
||||
customFontSelectedChoice = tinyDb.getInt("customFontId", 1);
|
||||
customFontSelectedChoice = tinyDB.getInt("customFontId", 1);
|
||||
}
|
||||
|
||||
if(themeSelectedChoice == 0) {
|
||||
|
||||
themeSelectedChoice = tinyDb.getInt("themeId");
|
||||
themeSelectedChoice = tinyDB.getInt("themeId");
|
||||
}
|
||||
|
||||
counterBadgesSwitch.setChecked(tinyDb.getBoolean("enableCounterBadges"));
|
||||
counterBadgesSwitch.setChecked(tinyDB.getBoolean("enableCounterBadges"));
|
||||
|
||||
// counter badge switcher
|
||||
counterBadgesSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
|
||||
tinyDb.putBoolean("enableCounterBadges", isChecked);
|
||||
tinyDB.putBoolean("enableCounterBadges", isChecked);
|
||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||
});
|
||||
|
||||
@ -200,10 +104,10 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
||||
|
||||
themeSelectedChoice = i;
|
||||
themeSelected.setText(themeList[i]);
|
||||
tinyDb.putString("themeStr", themeList[i]);
|
||||
tinyDb.putInt("themeId", i);
|
||||
tinyDB.putString("themeStr", themeList[i]);
|
||||
tinyDB.putInt("themeId", i);
|
||||
|
||||
tinyDb.putBoolean("refreshParent", true);
|
||||
tinyDB.putBoolean("refreshParent", true);
|
||||
this.recreate();
|
||||
this.overridePendingTransition(0, 0);
|
||||
dialogInterfaceTheme.dismiss();
|
||||
@ -226,10 +130,10 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
||||
|
||||
customFontSelectedChoice = i;
|
||||
customFontSelected.setText(customFontList[i]);
|
||||
tinyDb.putString("customFontStr", customFontList[i]);
|
||||
tinyDb.putInt("customFontId", i);
|
||||
tinyDB.putString("customFontStr", customFontList[i]);
|
||||
tinyDB.putInt("customFontId", i);
|
||||
|
||||
tinyDb.putBoolean("refreshParent", true);
|
||||
tinyDB.putBoolean("refreshParent", true);
|
||||
this.recreate();
|
||||
this.overridePendingTransition(0, 0);
|
||||
dialogInterfaceCustomFont.dismiss();
|
||||
@ -252,16 +156,16 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
||||
|
||||
timeSelectedChoice = i;
|
||||
tvDateTimeSelected.setText(timeList[i]);
|
||||
tinyDb.putString("timeStr", timeList[i]);
|
||||
tinyDb.putInt("timeId", i);
|
||||
tinyDB.putString("timeStr", timeList[i]);
|
||||
tinyDB.putInt("timeId", i);
|
||||
|
||||
if("Normal".equals(timeList[i])) {
|
||||
|
||||
tinyDb.putString("dateFormat", "normal");
|
||||
tinyDB.putString("dateFormat", "normal");
|
||||
}
|
||||
else {
|
||||
|
||||
tinyDb.putString("dateFormat", "pretty");
|
||||
tinyDB.putString("dateFormat", "pretty");
|
||||
}
|
||||
|
||||
dialogInterfaceTime.dismiss();
|
||||
|
@ -1,12 +1,10 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import com.google.android.material.switchmaterial.SwitchMaterial;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
|
||||
/**
|
||||
@ -15,7 +13,6 @@ import org.mian.gitnex.helpers.Toasty;
|
||||
|
||||
public class SettingsDraftsActivity extends BaseActivity {
|
||||
|
||||
private Context appCtx;
|
||||
private View.OnClickListener onClickListener;
|
||||
|
||||
@Override
|
||||
@ -28,9 +25,6 @@ public class SettingsDraftsActivity extends BaseActivity {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
|
||||
ImageView closeActivity = findViewById(R.id.close);
|
||||
|
||||
@ -39,12 +33,12 @@ public class SettingsDraftsActivity extends BaseActivity {
|
||||
|
||||
SwitchMaterial commentsDeletionSwitch = findViewById(R.id.commentsDeletionSwitch);
|
||||
|
||||
commentsDeletionSwitch.setChecked(tinyDb.getBoolean("draftsCommentsDeletionEnabled"));
|
||||
commentsDeletionSwitch.setChecked(tinyDB.getBoolean("draftsCommentsDeletionEnabled"));
|
||||
|
||||
// delete comments on submit switcher
|
||||
commentsDeletionSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
|
||||
tinyDb.putBoolean("draftsCommentsDeletionEnabled", isChecked);
|
||||
tinyDB.putBoolean("draftsCommentsDeletionEnabled", isChecked);
|
||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||
});
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
@ -9,7 +8,6 @@ import android.widget.TextView;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import com.google.android.material.switchmaterial.SwitchMaterial;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
|
||||
/**
|
||||
@ -18,7 +16,6 @@ import org.mian.gitnex.helpers.Toasty;
|
||||
|
||||
public class SettingsFileViewerActivity extends BaseActivity {
|
||||
|
||||
private Context appCtx;
|
||||
private View.OnClickListener onClickListener;
|
||||
|
||||
private static final String[] fileViewerSourceCodeThemesList = {"Sublime", "Arduino Light", "Github", "Far ", "Ir Black", "Android Studio"};
|
||||
@ -34,9 +31,6 @@ public class SettingsFileViewerActivity extends BaseActivity {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
||||
|
||||
ImageView closeActivity = findViewById(R.id.close);
|
||||
|
||||
@ -49,15 +43,15 @@ public class SettingsFileViewerActivity extends BaseActivity {
|
||||
|
||||
SwitchMaterial pdfModeSwitch = findViewById(R.id.switchPdfMode);
|
||||
|
||||
if(!tinyDb.getString("fileviewerSourceCodeThemeStr").isEmpty()) {
|
||||
fileViewerSourceCodeThemesSelected.setText(tinyDb.getString("fileviewerSourceCodeThemeStr"));
|
||||
if(!tinyDB.getString("fileviewerSourceCodeThemeStr").isEmpty()) {
|
||||
fileViewerSourceCodeThemesSelected.setText(tinyDB.getString("fileviewerSourceCodeThemeStr"));
|
||||
}
|
||||
|
||||
if(fileViewerSourceCodeThemesSelectedChoice == 0) {
|
||||
fileViewerSourceCodeThemesSelectedChoice = tinyDb.getInt("fileviewerThemeId");
|
||||
fileViewerSourceCodeThemesSelectedChoice = tinyDB.getInt("fileviewerThemeId");
|
||||
}
|
||||
|
||||
pdfModeSwitch.setChecked(tinyDb.getBoolean("enablePdfMode"));
|
||||
pdfModeSwitch.setChecked(tinyDB.getBoolean("enablePdfMode"));
|
||||
|
||||
// fileviewer srouce code theme selection dialog
|
||||
sourceCodeThemeFrame.setOnClickListener(view -> {
|
||||
@ -71,8 +65,8 @@ public class SettingsFileViewerActivity extends BaseActivity {
|
||||
|
||||
fileViewerSourceCodeThemesSelectedChoice = i;
|
||||
fileViewerSourceCodeThemesSelected.setText(fileViewerSourceCodeThemesList[i]);
|
||||
tinyDb.putString("fileviewerSourceCodeThemeStr", fileViewerSourceCodeThemesList[i]);
|
||||
tinyDb.putInt("fileviewerSourceCodeThemeId", i);
|
||||
tinyDB.putString("fileviewerSourceCodeThemeStr", fileViewerSourceCodeThemesList[i]);
|
||||
tinyDB.putInt("fileviewerSourceCodeThemeId", i);
|
||||
|
||||
dialogInterfaceTheme.dismiss();
|
||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||
@ -86,8 +80,8 @@ public class SettingsFileViewerActivity extends BaseActivity {
|
||||
// pdf night mode switcher
|
||||
pdfModeSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
|
||||
tinyDb.putBoolean("enablePdfMode", isChecked);
|
||||
tinyDb.putString("enablePdfModeInit", "yes");
|
||||
tinyDB.putBoolean("enablePdfMode", isChecked);
|
||||
tinyDB.putString("enablePdfModeInit", "yes");
|
||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||
});
|
||||
}
|
||||
|
@ -1,12 +1,10 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.databinding.ActivitySettingsGeneralBinding;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import java.util.ArrayList;
|
||||
@ -20,7 +18,6 @@ import java.util.List;
|
||||
public class SettingsGeneralActivity extends BaseActivity {
|
||||
|
||||
private ActivitySettingsGeneralBinding viewBinding;
|
||||
private Context appCtx;
|
||||
private View.OnClickListener onClickListener;
|
||||
|
||||
private List<String> homeScreenList;
|
||||
@ -39,14 +36,11 @@ public class SettingsGeneralActivity extends BaseActivity {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
|
||||
viewBinding = ActivitySettingsGeneralBinding.inflate(getLayoutInflater());
|
||||
View view = viewBinding.getRoot();
|
||||
setContentView(view);
|
||||
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
|
||||
initCloseListener();
|
||||
viewBinding.close.setOnClickListener(onClickListener);
|
||||
|
||||
@ -59,7 +53,7 @@ public class SettingsGeneralActivity extends BaseActivity {
|
||||
getResources().getString(R.string.pageTitleRepositories), getResources().getString(R.string.pageTitleProfile), getResources().getString(R.string.pageTitleExplore),
|
||||
getResources().getString(R.string.titleDrafts), getResources().getString(R.string.pageTitleNotifications)};
|
||||
|
||||
if(new Version(tinyDb.getString("giteaVersion")).higherOrEqual("1.12.3")) {
|
||||
if(new Version(tinyDB.getString("giteaVersion")).higherOrEqual("1.12.3")) {
|
||||
|
||||
homeDefaultScreen_ = homeDefaultScreenNew;
|
||||
}
|
||||
@ -70,7 +64,7 @@ public class SettingsGeneralActivity extends BaseActivity {
|
||||
|
||||
if(homeScreenSelectedChoice == 0) {
|
||||
|
||||
homeScreenSelectedChoice = tinyDb.getInt("homeScreenId");
|
||||
homeScreenSelectedChoice = tinyDB.getInt("homeScreenId");
|
||||
viewBinding.homeScreenSelected.setText(getResources().getString(R.string.pageTitleMyRepos));
|
||||
}
|
||||
|
||||
@ -114,7 +108,7 @@ public class SettingsGeneralActivity extends BaseActivity {
|
||||
|
||||
homeScreenSelectedChoice = i;
|
||||
viewBinding.homeScreenSelected.setText(homeScreenArray[i]);
|
||||
tinyDb.putInt("homeScreenId", i);
|
||||
tinyDB.putInt("homeScreenId", i);
|
||||
|
||||
dialogInterfaceHomeScreen.dismiss();
|
||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||
@ -134,7 +128,7 @@ public class SettingsGeneralActivity extends BaseActivity {
|
||||
|
||||
if(defaultLinkHandlerScreenSelectedChoice == 0) {
|
||||
|
||||
defaultLinkHandlerScreenSelectedChoice = tinyDb.getInt("defaultScreenId");
|
||||
defaultLinkHandlerScreenSelectedChoice = tinyDB.getInt("defaultScreenId");
|
||||
viewBinding.generalDeepLinkSelected.setText(getResources().getString(R.string.generalDeepLinkSelectedText));
|
||||
}
|
||||
|
||||
@ -166,7 +160,7 @@ public class SettingsGeneralActivity extends BaseActivity {
|
||||
|
||||
defaultLinkHandlerScreenSelectedChoice = i;
|
||||
viewBinding.generalDeepLinkSelected.setText(linksArray[i]);
|
||||
tinyDb.putInt("defaultScreenId", i);
|
||||
tinyDB.putInt("defaultScreenId", i);
|
||||
|
||||
dialogInterfaceHomeScreen.dismiss();
|
||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||
|
@ -1,12 +1,10 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import com.google.android.material.switchmaterial.SwitchMaterial;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
|
||||
/**
|
||||
@ -15,7 +13,6 @@ import org.mian.gitnex.helpers.Toasty;
|
||||
|
||||
public class SettingsReportsActivity extends BaseActivity {
|
||||
|
||||
private Context appCtx;
|
||||
private View.OnClickListener onClickListener;
|
||||
|
||||
@Override
|
||||
@ -28,9 +25,6 @@ public class SettingsReportsActivity extends BaseActivity {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
|
||||
ImageView closeActivity = findViewById(R.id.close);
|
||||
|
||||
@ -39,12 +33,12 @@ public class SettingsReportsActivity extends BaseActivity {
|
||||
|
||||
SwitchMaterial crashReportsSwitch = findViewById(R.id.crashReportsSwitch);
|
||||
|
||||
crashReportsSwitch.setChecked(tinyDb.getBoolean("crashReportingEnabled"));
|
||||
crashReportsSwitch.setChecked(tinyDB.getBoolean("crashReportingEnabled"));
|
||||
|
||||
// crash reports switcher
|
||||
crashReportsSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
|
||||
tinyDb.putBoolean("crashReportingEnabled", isChecked);
|
||||
tinyDB.putBoolean("crashReportingEnabled", isChecked);
|
||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||
});
|
||||
}
|
||||
|
@ -12,7 +12,6 @@ import android.widget.TextView;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import org.mian.gitnex.helpers.ssl.MemorizingTrustManager;
|
||||
@ -26,9 +25,6 @@ import java.io.IOException;
|
||||
|
||||
public class SettingsSecurityActivity extends BaseActivity {
|
||||
|
||||
private Context appCtx;
|
||||
private Context ctx = this;
|
||||
|
||||
private View.OnClickListener onClickListener;
|
||||
|
||||
private static String[] cacheSizeDataList = {"50 MB", "100 MB", "250 MB", "500 MB", "1 GB"};
|
||||
@ -51,10 +47,8 @@ public class SettingsSecurityActivity extends BaseActivity {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
String currentVersion = tinyDb.getString("giteaVersion");
|
||||
String currentVersion = tinyDB.getString("giteaVersion");
|
||||
|
||||
ImageView closeActivity = findViewById(R.id.close);
|
||||
|
||||
@ -72,24 +66,24 @@ public class SettingsSecurityActivity extends BaseActivity {
|
||||
LinearLayout cacheSizeImagesFrame = findViewById(R.id.cacheSizeImagesSelectionFrame);
|
||||
LinearLayout clearCacheFrame = findViewById(R.id.clearCacheSelectionFrame);
|
||||
|
||||
if(!tinyDb.getString("cacheSizeStr").isEmpty()) {
|
||||
if(!tinyDB.getString("cacheSizeStr").isEmpty()) {
|
||||
|
||||
cacheSizeDataSelected.setText(tinyDb.getString("cacheSizeStr"));
|
||||
cacheSizeDataSelected.setText(tinyDB.getString("cacheSizeStr"));
|
||||
}
|
||||
|
||||
if(!tinyDb.getString("cacheSizeImagesStr").isEmpty()) {
|
||||
if(!tinyDB.getString("cacheSizeImagesStr").isEmpty()) {
|
||||
|
||||
cacheSizeImagesSelected.setText(tinyDb.getString("cacheSizeImagesStr"));
|
||||
cacheSizeImagesSelected.setText(tinyDB.getString("cacheSizeImagesStr"));
|
||||
}
|
||||
|
||||
if(cacheSizeDataSelectedChoice == 0) {
|
||||
|
||||
cacheSizeDataSelectedChoice = tinyDb.getInt("cacheSizeId");
|
||||
cacheSizeDataSelectedChoice = tinyDB.getInt("cacheSizeId");
|
||||
}
|
||||
|
||||
if(cacheSizeImagesSelectedChoice == 0) {
|
||||
|
||||
cacheSizeImagesSelectedChoice = tinyDb.getInt("cacheSizeImagesId");
|
||||
cacheSizeImagesSelectedChoice = tinyDB.getInt("cacheSizeImagesId");
|
||||
}
|
||||
|
||||
if(new Version(currentVersion).less("1.12.3")) {
|
||||
@ -97,7 +91,7 @@ public class SettingsSecurityActivity extends BaseActivity {
|
||||
pollingDelayFrame.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
pollingDelaySelected.setText(String.format(getString(R.string.pollingDelaySelectedText), tinyDb.getInt("pollingDelayMinutes", DEFAULT_POLLING_DELAY)));
|
||||
pollingDelaySelected.setText(String.format(getString(R.string.pollingDelaySelectedText), tinyDB.getInt("pollingDelayMinutes", DEFAULT_POLLING_DELAY)));
|
||||
|
||||
// clear cache setter
|
||||
File cacheDir = appCtx.getCacheDir();
|
||||
@ -142,8 +136,8 @@ public class SettingsSecurityActivity extends BaseActivity {
|
||||
|
||||
cacheSizeImagesSelectedChoice = i;
|
||||
cacheSizeImagesSelected.setText(cacheSizeImagesList[i]);
|
||||
tinyDb.putString("cacheSizeImagesStr", cacheSizeImagesList[i]);
|
||||
tinyDb.putInt("cacheSizeImagesId", i);
|
||||
tinyDB.putString("cacheSizeImagesStr", cacheSizeImagesList[i]);
|
||||
tinyDB.putInt("cacheSizeImagesId", i);
|
||||
|
||||
dialogInterfaceTheme.dismiss();
|
||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||
@ -165,8 +159,8 @@ public class SettingsSecurityActivity extends BaseActivity {
|
||||
|
||||
cacheSizeDataSelectedChoice = i;
|
||||
cacheSizeDataSelected.setText(cacheSizeDataList[i]);
|
||||
tinyDb.putString("cacheSizeStr", cacheSizeDataList[i]);
|
||||
tinyDb.putInt("cacheSizeId", i);
|
||||
tinyDB.putString("cacheSizeStr", cacheSizeDataList[i]);
|
||||
tinyDB.putInt("cacheSizeId", i);
|
||||
|
||||
dialogInterfaceTheme.dismiss();
|
||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||
@ -187,9 +181,9 @@ public class SettingsSecurityActivity extends BaseActivity {
|
||||
|
||||
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);
|
||||
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);
|
||||
@ -206,7 +200,7 @@ public class SettingsSecurityActivity extends BaseActivity {
|
||||
NumberPicker numberPicker = new NumberPicker(ctx);
|
||||
numberPicker.setMinValue(MINIMUM_POLLING_DELAY);
|
||||
numberPicker.setMaxValue(MAXIMUM_POLLING_DELAY);
|
||||
numberPicker.setValue(tinyDb.getInt("pollingDelayMinutes", DEFAULT_POLLING_DELAY));
|
||||
numberPicker.setValue(tinyDB.getInt("pollingDelayMinutes", DEFAULT_POLLING_DELAY));
|
||||
numberPicker.setWrapSelectorWheel(true);
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
|
||||
@ -216,7 +210,7 @@ public class SettingsSecurityActivity extends BaseActivity {
|
||||
builder.setCancelable(true);
|
||||
builder.setPositiveButton(getString(R.string.okButton), (dialog, which) -> {
|
||||
|
||||
tinyDb.putInt("pollingDelayMinutes", numberPicker.getValue());
|
||||
tinyDB.putInt("pollingDelayMinutes", numberPicker.getValue());
|
||||
|
||||
NotificationsMaster.fireWorker(ctx);
|
||||
NotificationsMaster.hireWorker(ctx);
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
@ -10,7 +9,6 @@ import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
|
||||
/**
|
||||
@ -19,7 +17,6 @@ import org.mian.gitnex.helpers.Toasty;
|
||||
|
||||
public class SettingsTranslationActivity extends BaseActivity {
|
||||
|
||||
private Context appCtx;
|
||||
private View.OnClickListener onClickListener;
|
||||
|
||||
private static String[] langList = {"English", "Arabic", "Chinese", "Czech", "Finnish", "French", "German", "Italian", "Latvian", "Persian",
|
||||
@ -36,9 +33,6 @@ public class SettingsTranslationActivity extends BaseActivity {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
|
||||
ImageView closeActivity = findViewById(R.id.close);
|
||||
|
||||
@ -60,14 +54,14 @@ public class SettingsTranslationActivity extends BaseActivity {
|
||||
|
||||
});
|
||||
|
||||
if(!tinyDb.getString("localeStr").isEmpty()) {
|
||||
if(!tinyDB.getString("localeStr").isEmpty()) {
|
||||
|
||||
tvLanguageSelected.setText(tinyDb.getString("localeStr"));
|
||||
tvLanguageSelected.setText(tinyDB.getString("localeStr"));
|
||||
}
|
||||
|
||||
if(langSelectedChoice == 0) {
|
||||
|
||||
langSelectedChoice = tinyDb.getInt("langId");
|
||||
langSelectedChoice = tinyDB.getInt("langId");
|
||||
}
|
||||
|
||||
// language dialog
|
||||
@ -82,81 +76,81 @@ public class SettingsTranslationActivity extends BaseActivity {
|
||||
|
||||
langSelectedChoice = i;
|
||||
tvLanguageSelected.setText(langList[i]);
|
||||
tinyDb.putString("localeStr", langList[i]);
|
||||
tinyDb.putInt("langId", i);
|
||||
tinyDB.putString("localeStr", langList[i]);
|
||||
tinyDB.putInt("langId", i);
|
||||
|
||||
switch(langList[i]) {
|
||||
case "Arabic":
|
||||
|
||||
tinyDb.putString("locale", "ar");
|
||||
tinyDB.putString("locale", "ar");
|
||||
break;
|
||||
case "Chinese":
|
||||
|
||||
tinyDb.putString("locale", "zh");
|
||||
tinyDB.putString("locale", "zh");
|
||||
break;
|
||||
case "Czech":
|
||||
|
||||
tinyDb.putString("locale", "cs");
|
||||
tinyDB.putString("locale", "cs");
|
||||
break;
|
||||
case "Finnish":
|
||||
|
||||
tinyDb.putString("locale", "fi");
|
||||
tinyDB.putString("locale", "fi");
|
||||
break;
|
||||
case "French":
|
||||
|
||||
tinyDb.putString("locale", "fr");
|
||||
tinyDB.putString("locale", "fr");
|
||||
break;
|
||||
case "German":
|
||||
|
||||
tinyDb.putString("locale", "de");
|
||||
tinyDB.putString("locale", "de");
|
||||
break;
|
||||
case "Italian":
|
||||
|
||||
tinyDb.putString("locale", "it");
|
||||
tinyDB.putString("locale", "it");
|
||||
break;
|
||||
case "Latvian":
|
||||
|
||||
tinyDb.putString("locale", "lv");
|
||||
tinyDB.putString("locale", "lv");
|
||||
break;
|
||||
case "Persian":
|
||||
|
||||
tinyDb.putString("locale", "fa");
|
||||
tinyDB.putString("locale", "fa");
|
||||
break;
|
||||
case "Polish":
|
||||
|
||||
tinyDb.putString("locale", "pl");
|
||||
tinyDB.putString("locale", "pl");
|
||||
break;
|
||||
case "Portuguese/Brazilian":
|
||||
|
||||
tinyDb.putString("locale", "pt");
|
||||
tinyDB.putString("locale", "pt");
|
||||
break;
|
||||
case "Russian":
|
||||
|
||||
tinyDb.putString("locale", "ru");
|
||||
tinyDB.putString("locale", "ru");
|
||||
break;
|
||||
case "Serbian":
|
||||
|
||||
tinyDb.putString("locale", "sr");
|
||||
tinyDB.putString("locale", "sr");
|
||||
break;
|
||||
case "Spanish":
|
||||
|
||||
tinyDb.putString("locale", "es");
|
||||
tinyDB.putString("locale", "es");
|
||||
break;
|
||||
case "Turkish":
|
||||
|
||||
tinyDb.putString("locale", "tr");
|
||||
tinyDB.putString("locale", "tr");
|
||||
break;
|
||||
case "Ukrainian":
|
||||
|
||||
tinyDb.putString("locale", "uk");
|
||||
tinyDB.putString("locale", "uk");
|
||||
break;
|
||||
default:
|
||||
|
||||
tinyDb.putString("locale", "en");
|
||||
tinyDB.putString("locale", "en");
|
||||
break;
|
||||
}
|
||||
|
||||
tinyDb.putBoolean("refreshParent", true);
|
||||
tinyDB.putBoolean("refreshParent", true);
|
||||
this.recreate();
|
||||
this.overridePendingTransition(0, 0);
|
||||
dialogInterface.dismiss();
|
||||
|
@ -112,7 +112,7 @@ public class CommitsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
||||
@SuppressLint("SetTextI18n")
|
||||
void bindData(Commits commitsModel) {
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(ctx);
|
||||
final TinyDB tinyDb = TinyDB.getInstance(ctx);
|
||||
final String locale = tinyDb.getString("locale");
|
||||
final String timeFormat = tinyDb.getString("dateFormat");
|
||||
|
||||
|
@ -2,6 +2,7 @@ package org.mian.gitnex.adapters;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.Html;
|
||||
import android.text.Spanned;
|
||||
@ -14,9 +15,11 @@ import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.IssueDetailActivity;
|
||||
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 java.util.List;
|
||||
@ -28,21 +31,16 @@ import java.util.List;
|
||||
public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsViewHolder> {
|
||||
|
||||
private List<DraftWithRepository> draftsList;
|
||||
private FragmentManager fragmentManager;
|
||||
private Context mCtx;
|
||||
private final FragmentManager fragmentManager;
|
||||
private final Context mCtx;
|
||||
|
||||
class DraftsViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private TextView draftText;
|
||||
private TextView repoInfo;
|
||||
private TextView repoId;
|
||||
private TextView draftId;
|
||||
private TextView issueNumber;
|
||||
private TextView issueType;
|
||||
private TextView repoOwner;
|
||||
private TextView repoName;
|
||||
private TextView commentId;
|
||||
private ImageView editCommentStatus;
|
||||
private DraftWithRepository draftWithRepository;
|
||||
|
||||
private final TextView draftText;
|
||||
private final TextView repoInfo;
|
||||
private final ImageView editCommentStatus;
|
||||
|
||||
private DraftsViewHolder(View itemView) {
|
||||
|
||||
@ -50,19 +48,12 @@ public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsView
|
||||
|
||||
draftText = itemView.findViewById(R.id.draftText);
|
||||
repoInfo = itemView.findViewById(R.id.repoInfo);
|
||||
repoId = itemView.findViewById(R.id.repoId);
|
||||
draftId = itemView.findViewById(R.id.draftId);
|
||||
issueNumber = itemView.findViewById(R.id.issueNumber);
|
||||
issueType = itemView.findViewById(R.id.issueType);
|
||||
repoOwner = itemView.findViewById(R.id.repoOwner);
|
||||
repoName = itemView.findViewById(R.id.repoName);
|
||||
commentId = itemView.findViewById(R.id.commentId);
|
||||
ImageView deleteDraft = itemView.findViewById(R.id.deleteDraft);
|
||||
editCommentStatus = itemView.findViewById(R.id.editCommentStatus);
|
||||
|
||||
deleteDraft.setOnClickListener(itemDelete -> {
|
||||
|
||||
int getDraftId = Integer.parseInt(draftId.getText().toString());
|
||||
int getDraftId = draftWithRepository.getDraftId();
|
||||
deleteDraft(getAdapterPosition());
|
||||
DraftsApi draftsApi = new DraftsApi(mCtx);
|
||||
draftsApi.deleteSingleDraft(getDraftId);
|
||||
@ -73,23 +64,26 @@ public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsView
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
|
||||
bundle.putString("commentBody", draftText.getText().toString());
|
||||
bundle.putString("issueNumber", issueNumber.getText().toString());
|
||||
bundle.putString("repositoryId", repoId.getText().toString());
|
||||
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", commentId.getText().toString());
|
||||
bundle.putString("draftId", draftId.getText().toString());
|
||||
bundle.putString("commentId", draftWithRepository.getCommentId());
|
||||
bundle.putString("draftId", String.valueOf(draftWithRepository.getDraftId()));
|
||||
|
||||
if(!commentId.getText().toString().isEmpty()) {
|
||||
if(!draftWithRepository.getCommentId().isEmpty()) {
|
||||
bundle.putString("commentAction", "edit");
|
||||
}
|
||||
|
||||
TinyDB tinyDb = new TinyDB(mCtx);
|
||||
tinyDb.putString("issueNumber", issueNumber.getText().toString());
|
||||
tinyDb.putLong("repositoryId", Long.parseLong(repoId.getText().toString()));
|
||||
//tinyDb.putString("issueType", issueType.getText().toString());
|
||||
TinyDB tinyDb = TinyDB.getInstance(mCtx);
|
||||
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.newInstance(bundle).show(fragmentManager, "replyBottomSheet");
|
||||
BottomSheetReplyFragment bottomSheetReplyFragment = BottomSheetReplyFragment.newInstance(bundle);
|
||||
bottomSheetReplyFragment.setOnInteractedListener(() -> mCtx.startActivity(new Intent(mCtx, IssueDetailActivity.class)));
|
||||
bottomSheetReplyFragment.show(fragmentManager, "replyBottomSheet");
|
||||
|
||||
});
|
||||
|
||||
@ -125,18 +119,13 @@ public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsView
|
||||
|
||||
DraftWithRepository currentItem = draftsList.get(position);
|
||||
|
||||
holder.repoId.setText(String.valueOf(currentItem.getRepositoryId()));
|
||||
holder.draftId.setText(String.valueOf(currentItem.getDraftId()));
|
||||
holder.issueNumber.setText(String.valueOf(currentItem.getIssueId()));
|
||||
holder.issueType.setText(currentItem.getDraftType());
|
||||
holder.repoOwner.setText(currentItem.getRepositoryOwner());
|
||||
holder.repoName.setText(currentItem.getRepositoryName());
|
||||
holder.draftText.setText(currentItem.getDraftText());
|
||||
holder.commentId.setText(currentItem.getCommentId());
|
||||
|
||||
String issueNumber = "<font color='" + mCtx.getResources().getColor(R.color.lightGray) + "'>" + mCtx.getResources().getString(R.string.hash) + currentItem.getIssueId() + "</font>";
|
||||
Spanned headTitle = Html.fromHtml(issueNumber + " " + currentItem.getRepositoryOwner() + " / " + currentItem.getRepositoryName());
|
||||
|
||||
holder.repoInfo.setText(headTitle);
|
||||
holder.draftWithRepository = currentItem;
|
||||
|
||||
new Markdown(mCtx, currentItem.getDraftText(), holder.draftText);
|
||||
|
||||
if(!currentItem.getCommentId().equalsIgnoreCase("new")) {
|
||||
holder.editCommentStatus.setVisibility(View.VISIBLE);
|
||||
@ -144,7 +133,6 @@ public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsView
|
||||
else {
|
||||
holder.editCommentStatus.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -157,6 +145,4 @@ public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsView
|
||||
draftsList = list;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
|
||||
Intent intent = new Intent(context, RepoDetailActivity.class);
|
||||
intent.putExtra("repoFullName", repoFullName.getText().toString());
|
||||
|
||||
TinyDB tinyDb = new TinyDB(context);
|
||||
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
tinyDb.putString("repoFullName", repoFullName.getText().toString());
|
||||
tinyDb.putBoolean("resumeIssues", true);
|
||||
tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked());
|
||||
@ -128,14 +128,13 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
|
||||
//store if user is watching this repo
|
||||
{
|
||||
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
||||
|
||||
WatchInfo watch = new WatchInfo();
|
||||
|
||||
Call<WatchInfo> call;
|
||||
|
||||
call = RetrofitClient.getInstance(instanceUrl, context).getApiInterface().checkRepoWatchStatus(token, repoOwner, repoName);
|
||||
call = RetrofitClient.getApiInterface(context).checkRepoWatchStatus(token, repoOwner, repoName);
|
||||
|
||||
call.enqueue(new Callback<WatchInfo>() {
|
||||
|
||||
|
@ -36,9 +36,9 @@ public class FilesDiffAdapter extends BaseAdapter {
|
||||
private static int COLOR_SELECTED;
|
||||
private static int COLOR_FONT;
|
||||
|
||||
private Context context;
|
||||
private FragmentManager fragmentManager;
|
||||
private List<FileDiffView> fileDiffViews;
|
||||
private final Context context;
|
||||
private final FragmentManager fragmentManager;
|
||||
private final List<FileDiffView> fileDiffViews;
|
||||
|
||||
public FilesDiffAdapter(Context context, FragmentManager fragmentManager, List<FileDiffView> fileDiffViews) {
|
||||
|
||||
@ -185,7 +185,6 @@ public class FilesDiffAdapter extends BaseAdapter {
|
||||
|
||||
});
|
||||
|
||||
|
||||
diffTextView.setOnLongClickListener(v -> {
|
||||
|
||||
if(((DiffTextView) v).getCurrentBackgroundColor() == COLOR_SELECTED) {
|
||||
|
@ -5,17 +5,13 @@ import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.text.Spanned;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
@ -26,33 +22,16 @@ import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.fragments.BottomSheetReplyFragment;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.ClickListener;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Markdown;
|
||||
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.UserMentions;
|
||||
import org.mian.gitnex.models.IssueComments;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import io.noties.markwon.AbstractMarkwonPlugin;
|
||||
import io.noties.markwon.Markwon;
|
||||
import io.noties.markwon.core.CorePlugin;
|
||||
import io.noties.markwon.core.MarkwonTheme;
|
||||
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
||||
import io.noties.markwon.ext.tables.TablePlugin;
|
||||
import io.noties.markwon.ext.tasklist.TaskListPlugin;
|
||||
import io.noties.markwon.html.HtmlPlugin;
|
||||
import io.noties.markwon.image.DefaultMediaDecoder;
|
||||
import io.noties.markwon.image.ImageItem;
|
||||
import io.noties.markwon.image.ImagesPlugin;
|
||||
import io.noties.markwon.image.SchemeHandler;
|
||||
import io.noties.markwon.image.gif.GifMediaDecoder;
|
||||
import io.noties.markwon.image.svg.SvgMediaDecoder;
|
||||
import io.noties.markwon.linkify.LinkifyPlugin;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
@ -62,94 +41,91 @@ import retrofit2.Callback;
|
||||
|
||||
public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdapter.IssueCommentViewHolder> {
|
||||
|
||||
private List<IssueComments> issuesComments;
|
||||
private FragmentManager fragmentManager;
|
||||
private Context mCtx;
|
||||
private final Context ctx;
|
||||
private final List<IssueComments> issuesComments;
|
||||
private final FragmentManager fragmentManager;
|
||||
private final BottomSheetReplyFragment.OnInteractedListener onInteractedListener;
|
||||
|
||||
public IssueCommentsAdapter(Context mCtx, FragmentManager fragmentManager, List<IssueComments> issuesCommentsMain) {
|
||||
public IssueCommentsAdapter(Context ctx, List<IssueComments> issuesCommentsMain, FragmentManager fragmentManager, BottomSheetReplyFragment.OnInteractedListener onInteractedListener) {
|
||||
|
||||
this.mCtx = mCtx;
|
||||
this.fragmentManager = fragmentManager;
|
||||
this.ctx = ctx;
|
||||
this.issuesComments = issuesCommentsMain;
|
||||
this.fragmentManager = fragmentManager;
|
||||
this.onInteractedListener = onInteractedListener;
|
||||
|
||||
}
|
||||
|
||||
class IssueCommentViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private TextView issueNumber;
|
||||
private TextView commendId;
|
||||
private ImageView issueCommenterAvatar;
|
||||
private TextView issueComment;
|
||||
private TextView issueCommentDate;
|
||||
private TextView commendBodyRaw;
|
||||
private TextView commentModified;
|
||||
private TextView commenterUsername;
|
||||
private TextView htmlUrl;
|
||||
private IssueComments issueComment;
|
||||
|
||||
private IssueCommentViewHolder(View itemView) {
|
||||
private final ImageView avatar;
|
||||
private final TextView author;
|
||||
private final TextView information;
|
||||
private final TextView comment;
|
||||
|
||||
super(itemView);
|
||||
private IssueCommentViewHolder(View view) {
|
||||
|
||||
issueNumber = itemView.findViewById(R.id.issueNumber);
|
||||
commendId = itemView.findViewById(R.id.commendId);
|
||||
issueCommenterAvatar = itemView.findViewById(R.id.issueCommenterAvatar);
|
||||
issueComment = itemView.findViewById(R.id.issueComment);
|
||||
issueCommentDate = itemView.findViewById(R.id.issueCommentDate);
|
||||
ImageView commentsOptionsMenu = itemView.findViewById(R.id.commentsOptionsMenu);
|
||||
commendBodyRaw = itemView.findViewById(R.id.commendBodyRaw);
|
||||
commentModified = itemView.findViewById(R.id.commentModified);
|
||||
commenterUsername = itemView.findViewById(R.id.commenterUsername);
|
||||
htmlUrl = itemView.findViewById(R.id.htmlUrl);
|
||||
super(view);
|
||||
|
||||
commentsOptionsMenu.setOnClickListener(v -> {
|
||||
avatar = view.findViewById(R.id.avatar);
|
||||
author = view.findViewById(R.id.author);
|
||||
information = view.findViewById(R.id.information);
|
||||
ImageView menu = view.findViewById(R.id.menu);
|
||||
comment = view.findViewById(R.id.comment);
|
||||
|
||||
menu.setOnClickListener(v -> {
|
||||
|
||||
final Context ctx = v.getContext();
|
||||
final TinyDB tinyDb = new TinyDB(ctx);
|
||||
final TinyDB tinyDb = TinyDB.getInstance(ctx);
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
|
||||
@SuppressLint("InflateParams") View view = LayoutInflater.from(ctx).inflate(R.layout.bottom_sheet_issue_comments, null);
|
||||
@SuppressLint("InflateParams") View vw = LayoutInflater.from(ctx).inflate(R.layout.bottom_sheet_issue_comments, null);
|
||||
|
||||
TextView commentMenuEdit = view.findViewById(R.id.commentMenuEdit);
|
||||
TextView commentShare = view.findViewById(R.id.issueCommentShare);
|
||||
TextView commentMenuQuote = view.findViewById(R.id.commentMenuQuote);
|
||||
TextView commentMenuCopy = view.findViewById(R.id.commentMenuCopy);
|
||||
TextView commentMenuDelete = view.findViewById(R.id.commentMenuDelete);
|
||||
TextView issueCommentCopyUrl = view.findViewById(R.id.issueCommentCopyUrl);
|
||||
TextView commentMenuEdit = vw.findViewById(R.id.commentMenuEdit);
|
||||
TextView commentShare = vw.findViewById(R.id.issueCommentShare);
|
||||
TextView commentMenuQuote = vw.findViewById(R.id.commentMenuQuote);
|
||||
TextView commentMenuCopy = vw.findViewById(R.id.commentMenuCopy);
|
||||
TextView commentMenuDelete = vw.findViewById(R.id.commentMenuDelete);
|
||||
TextView issueCommentCopyUrl = vw.findViewById(R.id.issueCommentCopyUrl);
|
||||
|
||||
if(!loginUid.contentEquals(commenterUsername.getText())) {
|
||||
if(!loginUid.contentEquals(issueComment.getUser().getUsername())) {
|
||||
commentMenuEdit.setVisibility(View.GONE);
|
||||
commentMenuDelete.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if(issueComment.getText().toString().isEmpty()) {
|
||||
if(issueComment.getBody().isEmpty()) {
|
||||
commentMenuCopy.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
BottomSheetDialog dialog = new BottomSheetDialog(ctx);
|
||||
dialog.setContentView(view);
|
||||
dialog.setContentView(vw);
|
||||
dialog.show();
|
||||
|
||||
commentMenuEdit.setOnClickListener(ediComment -> {
|
||||
commentMenuEdit.setOnClickListener(v1 -> {
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("commentId", commendId.getText().toString());
|
||||
bundle.putInt("commentId", issueComment.getId());
|
||||
bundle.putString("commentAction", "edit");
|
||||
bundle.putString("commentBody", commendBodyRaw.getText().toString());
|
||||
bundle.putString("commentBody", issueComment.getBody());
|
||||
|
||||
BottomSheetReplyFragment bottomSheetReplyFragment = BottomSheetReplyFragment.newInstance(bundle);
|
||||
bottomSheetReplyFragment.setOnInteractedListener(onInteractedListener);
|
||||
bottomSheetReplyFragment.show(fragmentManager, "replyBottomSheet");
|
||||
|
||||
BottomSheetReplyFragment.newInstance(bundle).show(fragmentManager, "replyBottomSheet");
|
||||
dialog.dismiss();
|
||||
|
||||
});
|
||||
|
||||
commentShare.setOnClickListener(ediComment -> {
|
||||
commentShare.setOnClickListener(v1 -> {
|
||||
|
||||
// get comment Url
|
||||
CharSequence commentUrl = htmlUrl.getText();
|
||||
CharSequence commentUrl = issueComment.getHtml_url();
|
||||
|
||||
// share issue comment
|
||||
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
|
||||
sharingIntent.setType("text/plain");
|
||||
String intentHeader = tinyDb.getString("issueNumber") + ctx.getResources().getString(R.string.hash) + "issuecomment-" + commendId.getText() + " " + tinyDb.getString("issueTitle");
|
||||
String intentHeader = tinyDb.getString("issueNumber") + ctx.getResources().getString(R.string.hash) + "issuecomment-" + issueComment.getId() + " " + tinyDb.getString("issueTitle");
|
||||
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, intentHeader);
|
||||
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, commentUrl);
|
||||
ctx.startActivity(Intent.createChooser(sharingIntent, intentHeader));
|
||||
@ -158,10 +134,10 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
||||
|
||||
});
|
||||
|
||||
issueCommentCopyUrl.setOnClickListener(ediComment -> {
|
||||
issueCommentCopyUrl.setOnClickListener(v1 -> {
|
||||
|
||||
// comment Url
|
||||
CharSequence commentUrl = htmlUrl.getText();
|
||||
CharSequence commentUrl = issueComment.getHtml_url();
|
||||
|
||||
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(ctx).getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
assert clipboard != null;
|
||||
@ -177,14 +153,14 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
||||
commentMenuQuote.setOnClickListener(v1 -> {
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
String commenterName = commenterUsername.getText().toString();
|
||||
String commenterName = issueComment.getUser().getUsername();
|
||||
|
||||
if(!commenterName.equals(tinyDb.getString("userLogin"))) {
|
||||
|
||||
stringBuilder.append("@").append(commenterName).append("\n\n");
|
||||
}
|
||||
|
||||
String[] lines = commendBodyRaw.getText().toString().split("\\R");
|
||||
String[] lines = issueComment.getBody().split("\\R");
|
||||
|
||||
for(String line : lines) {
|
||||
|
||||
@ -202,12 +178,12 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
||||
|
||||
});
|
||||
|
||||
commentMenuCopy.setOnClickListener(view1 -> {
|
||||
commentMenuCopy.setOnClickListener(v1 -> {
|
||||
|
||||
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(ctx).getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
assert clipboard != null;
|
||||
|
||||
ClipData clip = ClipData.newPlainText("Comment on issue #" + issueNumber.getText().toString(), issueComment.getText().toString());
|
||||
ClipData clip = ClipData.newPlainText("Comment on issue #" + tinyDb.getString("issueNumber"), issueComment.getBody());
|
||||
clipboard.setPrimaryClip(clip);
|
||||
|
||||
dialog.dismiss();
|
||||
@ -215,9 +191,9 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
||||
|
||||
});
|
||||
|
||||
commentMenuDelete.setOnClickListener(deleteComment -> {
|
||||
commentMenuDelete.setOnClickListener(v1 -> {
|
||||
|
||||
deleteIssueComment(ctx, Integer.parseInt(commendId.getText().toString()), getAdapterPosition());
|
||||
deleteIssueComment(ctx, issueComment.getId(), getAdapterPosition());
|
||||
dialog.dismiss();
|
||||
|
||||
});
|
||||
@ -238,22 +214,20 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
||||
|
||||
private void deleteIssueComment(final Context ctx, final int commentId, int position) {
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(ctx);
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final TinyDB tinyDb = TinyDB.getInstance(ctx);
|
||||
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;
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
Call<JsonElement> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.deleteComment(instanceToken, repoOwner, repoName, commentId);
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
@ -261,47 +235,40 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
|
||||
|
||||
if(response.code() == 204) {
|
||||
switch(response.code()) {
|
||||
|
||||
updateAdapter(position);
|
||||
Toasty.success(ctx, ctx.getResources().getString(R.string.deleteCommentSuccess));
|
||||
case 204:
|
||||
updateAdapter(position);
|
||||
Toasty.success(ctx, ctx.getResources().getString(R.string.deleteCommentSuccess));
|
||||
break;
|
||||
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx, ctx.getResources().getString(R.string.alertDialogTokenRevokedTitle),
|
||||
case 401:
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx, ctx.getResources().getString(R.string.alertDialogTokenRevokedTitle),
|
||||
ctx.getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||
ctx.getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
||||
ctx.getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
||||
break;
|
||||
|
||||
case 403:
|
||||
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
||||
break;
|
||||
|
||||
case 404:
|
||||
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
||||
break;
|
||||
|
||||
default:
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
||||
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
|
||||
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getResources().getString(R.string.genericServerResponseError));
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@ -312,109 +279,40 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
||||
return new IssueCommentsAdapter.IssueCommentViewHolder(v);
|
||||
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull IssueCommentsAdapter.IssueCommentViewHolder holder, int position) {
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(mCtx);
|
||||
final String locale = tinyDb.getString("locale");
|
||||
final String timeFormat = tinyDb.getString("dateFormat");
|
||||
IssueComments issueComment = issuesComments.get(position);
|
||||
|
||||
IssueComments currentItem = issuesComments.get(position);
|
||||
holder.issueComment = issueComment;
|
||||
holder.author.setText(issueComment.getUser().getUsername());
|
||||
|
||||
holder.htmlUrl.setText(currentItem.getHtml_url());
|
||||
holder.commenterUsername.setText(currentItem.getUser().getUsername());
|
||||
holder.commendId.setText(String.valueOf(currentItem.getId()));
|
||||
holder.commendBodyRaw.setText(currentItem.getBody());
|
||||
PicassoService.getInstance(ctx).get()
|
||||
.load(issueComment.getUser().getAvatar_url())
|
||||
.placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(4, 0))
|
||||
.resize(AppUtil.getPixelsFromDensity(ctx, 35), AppUtil.getPixelsFromDensity(ctx, 35))
|
||||
.centerCrop()
|
||||
.into(holder.avatar);
|
||||
|
||||
if(!currentItem.getUser().getFull_name().equals("")) {
|
||||
holder.issueCommenterAvatar.setOnClickListener(new ClickListener(mCtx.getResources().getString(R.string.issueCommenter) + currentItem.getUser().getFull_name(), mCtx));
|
||||
}
|
||||
else {
|
||||
holder.issueCommenterAvatar.setOnClickListener(new ClickListener(mCtx.getResources().getString(R.string.issueCommenter) + currentItem.getUser().getLogin(), mCtx));
|
||||
new Markdown(ctx, EmojiParser.parseToUnicode(issueComment.getBody()), holder.comment);
|
||||
|
||||
StringBuilder informationBuilder = new StringBuilder(TimeHelper.formatTime(issueComment.getCreated_at(), Locale.getDefault(), "pretty", ctx));
|
||||
|
||||
if(!issueComment.getCreated_at().equals(issueComment.getUpdated_at())) {
|
||||
|
||||
informationBuilder.append(ctx.getString(R.string.colorfulBulletSpan))
|
||||
.append(ctx.getString(R.string.modifiedText));
|
||||
}
|
||||
|
||||
PicassoService.getInstance(mCtx).get().load(currentItem.getUser().getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(holder.issueCommenterAvatar);
|
||||
holder.information.setText(informationBuilder.toString());
|
||||
|
||||
String cleanIssueComments = currentItem.getBody().trim();
|
||||
|
||||
final Markwon markwon = Markwon.builder(Objects.requireNonNull(mCtx)).usePlugin(CorePlugin.create()).usePlugin(ImagesPlugin.create(new ImagesPlugin.ImagesConfigure() {
|
||||
|
||||
@Override
|
||||
public void configureImages(@NonNull ImagesPlugin plugin) {
|
||||
|
||||
plugin.addSchemeHandler(new SchemeHandler() {
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ImageItem handle(@NonNull String raw, @NonNull Uri uri) {
|
||||
|
||||
final int resourceId = mCtx.getResources().getIdentifier(raw.substring("drawable://".length()), "drawable", mCtx.getPackageName());
|
||||
|
||||
final Drawable drawable = ContextCompat.getDrawable(mCtx, resourceId);
|
||||
|
||||
assert drawable != null;
|
||||
return ImageItem.withResult(drawable);
|
||||
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Collection<String> supportedSchemes() {
|
||||
|
||||
return Collections.singleton("drawable");
|
||||
}
|
||||
});
|
||||
plugin.placeholderProvider(drawable -> null);
|
||||
plugin.addMediaDecoder(GifMediaDecoder.create(false));
|
||||
plugin.addMediaDecoder(SvgMediaDecoder.create(mCtx.getResources()));
|
||||
plugin.addMediaDecoder(SvgMediaDecoder.create());
|
||||
plugin.defaultMediaDecoder(DefaultMediaDecoder.create(mCtx.getResources()));
|
||||
plugin.defaultMediaDecoder(DefaultMediaDecoder.create());
|
||||
|
||||
}
|
||||
})).usePlugin(new AbstractMarkwonPlugin() {
|
||||
|
||||
@Override
|
||||
public void configureTheme(@NonNull MarkwonTheme.Builder builder) {
|
||||
|
||||
builder.codeTextColor(tinyDb.getInt("codeBlockColor")).codeBackgroundColor(tinyDb.getInt("codeBlockBackground")).linkColor(mCtx.getResources().getColor(R.color.lightBlue));
|
||||
}
|
||||
|
||||
}).usePlugin(TablePlugin.create(mCtx)).usePlugin(TaskListPlugin.create(mCtx)).usePlugin(HtmlPlugin.create()).usePlugin(StrikethroughPlugin.create()).usePlugin(LinkifyPlugin.create()).build();
|
||||
|
||||
Spanned bodyWithMD = markwon.toMarkdown(EmojiParser.parseToUnicode(cleanIssueComments));
|
||||
markwon.setParsedMarkdown(holder.issueComment, UserMentions.UserMentionsFunc(mCtx, bodyWithMD, cleanIssueComments));
|
||||
|
||||
String edited;
|
||||
|
||||
if(!currentItem.getUpdated_at().equals(currentItem.getCreated_at())) {
|
||||
|
||||
edited = mCtx.getResources().getString(R.string.colorfulBulletSpan) + mCtx.getResources().getString(R.string.modifiedText);
|
||||
holder.commentModified.setVisibility(View.VISIBLE);
|
||||
holder.commentModified.setText(edited);
|
||||
holder.commentModified.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(currentItem.getUpdated_at()), mCtx));
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
holder.commentModified.setVisibility(View.INVISIBLE);
|
||||
|
||||
}
|
||||
|
||||
holder.issueCommentDate.setText(TimeHelper.formatTime(currentItem.getCreated_at(), new Locale(locale), timeFormat, mCtx));
|
||||
|
||||
if(timeFormat.equals("pretty")) {
|
||||
holder.issueCommentDate.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(currentItem.getCreated_at()), mCtx));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
|
||||
return issuesComments.size();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
Intent intent = new Intent(context, IssueDetailActivity.class);
|
||||
intent.putExtra("issueNumber", issueNumber.getText());
|
||||
|
||||
TinyDB tinyDb = new TinyDB(context);
|
||||
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
tinyDb.putString("issueNumber", issueNumber.getText().toString());
|
||||
tinyDb.putString("issueType", "Issue");
|
||||
context.startActivity(intent);
|
||||
@ -136,7 +136,7 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
Intent intent = new Intent(context, IssueDetailActivity.class);
|
||||
intent.putExtra("issueNumber", issueNumber.getText());
|
||||
|
||||
TinyDB tinyDb = new TinyDB(context);
|
||||
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
tinyDb.putString("issueNumber", issueNumber.getText().toString());
|
||||
tinyDb.putString("issueType", "Issue");
|
||||
context.startActivity(intent);
|
||||
@ -148,7 +148,7 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
@SuppressLint("SetTextI18n")
|
||||
void bindData(Issues issuesModel) {
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(context);
|
||||
final TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
final String locale = tinyDb.getString("locale");
|
||||
final String timeFormat = tinyDb.getString("dateFormat");
|
||||
|
||||
|
@ -2,9 +2,6 @@ package org.mian.gitnex.adapters;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.text.Spanned;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@ -19,6 +16,7 @@ import com.vdurmont.emoji.EmojiParser;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.actions.MilestoneActions;
|
||||
import org.mian.gitnex.helpers.ClickListener;
|
||||
import org.mian.gitnex.helpers.Markdown;
|
||||
import org.mian.gitnex.helpers.StaticGlobalVariables;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
@ -26,27 +24,9 @@ import org.mian.gitnex.models.Milestones;
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import io.noties.markwon.AbstractMarkwonPlugin;
|
||||
import io.noties.markwon.Markwon;
|
||||
import io.noties.markwon.core.CorePlugin;
|
||||
import io.noties.markwon.core.MarkwonTheme;
|
||||
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
||||
import io.noties.markwon.ext.tables.TablePlugin;
|
||||
import io.noties.markwon.ext.tasklist.TaskListPlugin;
|
||||
import io.noties.markwon.html.HtmlPlugin;
|
||||
import io.noties.markwon.image.DefaultMediaDecoder;
|
||||
import io.noties.markwon.image.ImageItem;
|
||||
import io.noties.markwon.image.ImagesPlugin;
|
||||
import io.noties.markwon.image.SchemeHandler;
|
||||
import io.noties.markwon.image.gif.GifMediaDecoder;
|
||||
import io.noties.markwon.image.svg.SvgMediaDecoder;
|
||||
import io.noties.markwon.linkify.LinkifyPlugin;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
@ -177,71 +157,18 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
@SuppressLint("SetTextI18n")
|
||||
void bindData(Milestones dataModel) {
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(context);
|
||||
final TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
final String locale = tinyDb.getString("locale");
|
||||
final String timeFormat = tinyDb.getString("dateFormat");
|
||||
|
||||
milestoneId.setText(String.valueOf(dataModel.getId()));
|
||||
milestoneStatus.setText(dataModel.getState());
|
||||
|
||||
Markwon markwon = Markwon.builder(Objects.requireNonNull(context)).usePlugin(CorePlugin.create()).usePlugin(ImagesPlugin.create(plugin -> {
|
||||
plugin.addSchemeHandler(new SchemeHandler() {
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ImageItem handle(@NonNull String raw, @NonNull Uri uri) {
|
||||
|
||||
final int resourceId = context.getResources().getIdentifier(
|
||||
raw.substring("drawable://".length()),
|
||||
"drawable",
|
||||
context.getPackageName());
|
||||
|
||||
final Drawable drawable = context.getDrawable(resourceId);
|
||||
|
||||
assert drawable != null;
|
||||
return ImageItem.withResult(drawable);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Collection<String> supportedSchemes() {
|
||||
return Collections.singleton("drawable");
|
||||
}
|
||||
});
|
||||
|
||||
plugin.placeholderProvider(drawable -> null);
|
||||
plugin.addMediaDecoder(GifMediaDecoder.create(false));
|
||||
plugin.addMediaDecoder(SvgMediaDecoder.create(context.getResources()));
|
||||
plugin.addMediaDecoder(SvgMediaDecoder.create());
|
||||
plugin.defaultMediaDecoder(DefaultMediaDecoder.create(context.getResources()));
|
||||
plugin.defaultMediaDecoder(DefaultMediaDecoder.create());
|
||||
|
||||
}))
|
||||
|
||||
.usePlugin(new AbstractMarkwonPlugin() {
|
||||
@Override
|
||||
public void configureTheme(@NonNull MarkwonTheme.Builder builder) {
|
||||
builder
|
||||
.codeTextColor(tinyDb.getInt("codeBlockColor"))
|
||||
.codeBackgroundColor(tinyDb.getInt("codeBlockBackground"))
|
||||
.linkColor(context.getResources().getColor(R.color.lightBlue));
|
||||
}
|
||||
})
|
||||
.usePlugin(TablePlugin.create(context))
|
||||
.usePlugin(TaskListPlugin.create(context))
|
||||
.usePlugin(HtmlPlugin.create())
|
||||
.usePlugin(StrikethroughPlugin.create())
|
||||
.usePlugin(LinkifyPlugin.create())
|
||||
.build();
|
||||
|
||||
Spanned msTitle_ = markwon.toMarkdown(dataModel.getTitle());
|
||||
markwon.setParsedMarkdown(msTitle, msTitle_);
|
||||
new Markdown(context, dataModel.getTitle(), msTitle);
|
||||
|
||||
if(!dataModel.getDescription().equals("")) {
|
||||
|
||||
CharSequence bodyWithMD = markwon.toMarkdown(EmojiParser.parseToUnicode(dataModel.getDescription()));
|
||||
msDescription.setText(bodyWithMD);
|
||||
|
||||
new Markdown(context, EmojiParser.parseToUnicode(dataModel.getDescription()), msDescription);
|
||||
}
|
||||
else {
|
||||
|
||||
|
@ -92,7 +92,7 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
|
||||
Intent intent = new Intent(context, RepoDetailActivity.class);
|
||||
intent.putExtra("repoFullName", repoFullName.getText().toString());
|
||||
|
||||
TinyDB tinyDb = new TinyDB(context);
|
||||
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
tinyDb.putString("repoFullName", repoFullName.getText().toString());
|
||||
tinyDb.putString("repoType", repoType.getText().toString());
|
||||
//tinyDb.putBoolean("resumeIssues", true);
|
||||
@ -125,14 +125,13 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
|
||||
//store if user is watching this repo
|
||||
{
|
||||
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
||||
|
||||
WatchInfo watch = new WatchInfo();
|
||||
|
||||
Call<WatchInfo> call;
|
||||
|
||||
call = RetrofitClient.getInstance(instanceUrl, context).getApiInterface().checkRepoWatchStatus(token, repoOwner, repoName);
|
||||
call = RetrofitClient.getApiInterface(context).checkRepoWatchStatus(token, repoOwner, repoName);
|
||||
|
||||
call.enqueue(new Callback<WatchInfo>() {
|
||||
|
||||
|
@ -31,7 +31,7 @@ public class NotificationsAdapter extends RecyclerView.Adapter<NotificationsAdap
|
||||
|
||||
public NotificationsAdapter(Context context, List<NotificationThread> notificationThreads, OnMoreClickedListener onMoreClickedListener, OnNotificationClickedListener onNotificationClickedListener) {
|
||||
|
||||
this.tinyDb = new TinyDB(context);
|
||||
this.tinyDb = TinyDB.getInstance(context);
|
||||
this.context = context;
|
||||
this.notificationThreads = notificationThreads;
|
||||
this.onMoreClickedListener = onMoreClickedListener;
|
||||
|
@ -53,7 +53,7 @@ public class OrganizationsListAdapter extends RecyclerView.Adapter<Organizations
|
||||
Intent intent = new Intent(context, OrganizationDetailActivity.class);
|
||||
intent.putExtra("orgName", mTextView1.getText().toString());
|
||||
|
||||
TinyDB tinyDb = new TinyDB(context);
|
||||
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
tinyDb.putString("orgName", mTextView1.getText().toString());
|
||||
tinyDb.putString("organizationId", organizationId.getText().toString());
|
||||
tinyDb.putBoolean("organizationAction", true);
|
||||
|
@ -130,7 +130,7 @@ public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||
intent.putExtra("prMergeable", prMergeable.getText());
|
||||
intent.putExtra("prHeadBranch", prHeadBranch.getText());
|
||||
|
||||
TinyDB tinyDb = new TinyDB(context);
|
||||
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
tinyDb.putString("issueNumber", prNumber.getText().toString());
|
||||
tinyDb.putString("prMergeable", prMergeable.getText().toString());
|
||||
tinyDb.putString("prHeadBranch", prHeadBranch.getText().toString());
|
||||
@ -149,7 +149,7 @@ public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||
intent.putExtra("prMergeable", prMergeable.getText());
|
||||
intent.putExtra("prHeadBranch", prHeadBranch.getText());
|
||||
|
||||
TinyDB tinyDb = new TinyDB(context);
|
||||
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
tinyDb.putString("issueNumber", prNumber.getText().toString());
|
||||
tinyDb.putString("prMergeable", prMergeable.getText().toString());
|
||||
tinyDb.putString("prHeadBranch", prHeadBranch.getText().toString());
|
||||
@ -165,7 +165,7 @@ public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||
@SuppressLint("SetTextI18n")
|
||||
void bindData(PullRequests prModel) {
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(context);
|
||||
final TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
final String locale = tinyDb.getString("locale");
|
||||
final String timeFormat = tinyDb.getString("dateFormat");
|
||||
|
||||
|
@ -1,10 +1,7 @@
|
||||
package org.mian.gitnex.adapters;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.text.Html;
|
||||
import android.text.Spanned;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@ -16,34 +13,16 @@ import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.vdurmont.emoji.EmojiParser;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.helpers.ClickListener;
|
||||
import org.mian.gitnex.helpers.Markdown;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.models.Releases;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import io.noties.markwon.AbstractMarkwonPlugin;
|
||||
import io.noties.markwon.Markwon;
|
||||
import io.noties.markwon.core.CorePlugin;
|
||||
import io.noties.markwon.core.MarkwonTheme;
|
||||
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
||||
import io.noties.markwon.ext.tables.TablePlugin;
|
||||
import io.noties.markwon.ext.tasklist.TaskListPlugin;
|
||||
import io.noties.markwon.html.HtmlPlugin;
|
||||
import io.noties.markwon.image.DefaultMediaDecoder;
|
||||
import io.noties.markwon.image.ImageItem;
|
||||
import io.noties.markwon.image.ImagesPlugin;
|
||||
import io.noties.markwon.image.SchemeHandler;
|
||||
import io.noties.markwon.image.gif.GifMediaDecoder;
|
||||
import io.noties.markwon.image.svg.SvgMediaDecoder;
|
||||
import io.noties.markwon.linkify.LinkifyPlugin;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
@ -111,7 +90,7 @@ public class ReleasesAdapter extends RecyclerView.Adapter<ReleasesAdapter.Releas
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ReleasesAdapter.ReleasesViewHolder holder, int position) {
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(mCtx);
|
||||
final TinyDB tinyDb = TinyDB.getInstance(mCtx);
|
||||
final String locale = tinyDb.getString("locale");
|
||||
final String timeFormat = tinyDb.getString("dateFormat");
|
||||
|
||||
@ -149,58 +128,8 @@ public class ReleasesAdapter extends RecyclerView.Adapter<ReleasesAdapter.Releas
|
||||
holder.releaseDate.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(currentItem.getPublished_at()), mCtx));
|
||||
}
|
||||
|
||||
final Markwon markwon = Markwon.builder(Objects.requireNonNull(mCtx))
|
||||
.usePlugin(CorePlugin.create())
|
||||
.usePlugin(ImagesPlugin.create(plugin -> {
|
||||
plugin.addSchemeHandler(new SchemeHandler() {
|
||||
@NonNull
|
||||
@Override
|
||||
public ImageItem handle(@NonNull String raw, @NonNull Uri uri) {
|
||||
|
||||
final int resourceId = mCtx.getResources().getIdentifier(
|
||||
raw.substring("drawable://".length()),
|
||||
"drawable",
|
||||
mCtx.getPackageName());
|
||||
|
||||
final Drawable drawable = mCtx.getDrawable(resourceId);
|
||||
|
||||
assert drawable != null;
|
||||
return ImageItem.withResult(drawable);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Collection<String> supportedSchemes() {
|
||||
return Collections.singleton("drawable");
|
||||
}
|
||||
});
|
||||
plugin.placeholderProvider(drawable -> null);
|
||||
plugin.addMediaDecoder(GifMediaDecoder.create(false));
|
||||
plugin.addMediaDecoder(SvgMediaDecoder.create(mCtx.getResources()));
|
||||
plugin.addMediaDecoder(SvgMediaDecoder.create());
|
||||
plugin.defaultMediaDecoder(DefaultMediaDecoder.create(mCtx.getResources()));
|
||||
plugin.defaultMediaDecoder(DefaultMediaDecoder.create());
|
||||
}))
|
||||
.usePlugin(new AbstractMarkwonPlugin() {
|
||||
@Override
|
||||
public void configureTheme(@NonNull MarkwonTheme.Builder builder) {
|
||||
builder
|
||||
.codeTextColor(tinyDb.getInt("codeBlockColor"))
|
||||
.codeBackgroundColor(tinyDb.getInt("codeBlockBackground"))
|
||||
.linkColor(mCtx.getResources().getColor(R.color.lightBlue));
|
||||
}
|
||||
})
|
||||
.usePlugin(TablePlugin.create(mCtx))
|
||||
.usePlugin(TaskListPlugin.create(mCtx))
|
||||
.usePlugin(HtmlPlugin.create())
|
||||
.usePlugin(StrikethroughPlugin.create())
|
||||
.usePlugin(LinkifyPlugin.create())
|
||||
.build();
|
||||
|
||||
Spanned bodyWithMD = markwon.toMarkdown(EmojiParser.parseToUnicode(currentItem.getBody()));
|
||||
|
||||
if(!currentItem.getBody().equals("")) {
|
||||
markwon.setParsedMarkdown(holder.releaseBodyContent, bodyWithMD);
|
||||
new Markdown(mCtx, currentItem.getBody(), holder.releaseBodyContent);
|
||||
}
|
||||
else {
|
||||
holder.releaseBodyContent.setText(R.string.noReleaseBodyContent);
|
||||
|
@ -211,7 +211,7 @@ public class RepoForksAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
||||
Intent intent = new Intent(context, RepoDetailActivity.class);
|
||||
intent.putExtra("repoFullName", repoFullName.getText().toString());
|
||||
|
||||
TinyDB tinyDb = new TinyDB(context);
|
||||
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
tinyDb.putString("repoFullName", repoFullName.getText().toString());
|
||||
tinyDb.putString("repoType", repoType_.getText().toString());
|
||||
//tinyDb.putBoolean("resumeIssues", true);
|
||||
@ -244,14 +244,13 @@ public class RepoForksAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
||||
//store if user is watching this repo
|
||||
{
|
||||
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
||||
|
||||
WatchInfo watch = new WatchInfo();
|
||||
|
||||
Call<WatchInfo> call;
|
||||
|
||||
call = RetrofitClient.getInstance(instanceUrl, context).getApiInterface().checkRepoWatchStatus(token, repoOwner, repoName);
|
||||
call = RetrofitClient.getApiInterface(context).checkRepoWatchStatus(token, repoOwner, repoName);
|
||||
|
||||
call.enqueue(new Callback<WatchInfo>() {
|
||||
|
||||
|
@ -81,7 +81,7 @@ public class RepoStargazersAdapter extends BaseAdapter {
|
||||
UserInfo currentItem = stargazersList.get(position);
|
||||
PicassoService.getInstance(mCtx).get().load(currentItem.getAvatar()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(180, 180).centerCrop().into(viewHolder.memberAvatar);
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(mCtx);
|
||||
final TinyDB tinyDb = TinyDB.getInstance(mCtx);
|
||||
Typeface myTypeface;
|
||||
|
||||
switch(tinyDb.getInt("customFontId", -1)) {
|
||||
|
@ -81,7 +81,7 @@ public class RepoWatchersAdapter extends BaseAdapter {
|
||||
UserInfo currentItem = watchersList.get(position);
|
||||
PicassoService.getInstance(mCtx).get().load(currentItem.getAvatar()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(180, 180).centerCrop().into(viewHolder.memberAvatar);
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(mCtx);
|
||||
final TinyDB tinyDb = TinyDB.getInstance(mCtx);
|
||||
Typeface myTypeface;
|
||||
|
||||
switch(tinyDb.getInt("customFontId", -1)) {
|
||||
|
@ -23,9 +23,9 @@ import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
|
||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||
import org.mian.gitnex.activities.RepoForksActivity;
|
||||
import org.mian.gitnex.activities.RepoStargazersActivity;
|
||||
import org.mian.gitnex.activities.RepoWatchersActivity;
|
||||
import org.mian.gitnex.activities.RepoForksActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.database.api.RepositoriesApi;
|
||||
@ -94,7 +94,7 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
||||
Intent intent = new Intent(context, RepoDetailActivity.class);
|
||||
intent.putExtra("repoFullName", repoFullName.getText().toString());
|
||||
|
||||
TinyDB tinyDb = new TinyDB(context);
|
||||
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
tinyDb.putString("repoFullName", repoFullName.getText().toString());
|
||||
tinyDb.putString("repoType", repoType_.getText().toString());
|
||||
//tinyDb.putBoolean("resumeIssues", true);
|
||||
@ -127,14 +127,13 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
||||
//store if user is watching this repo
|
||||
{
|
||||
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
||||
|
||||
WatchInfo watch = new WatchInfo();
|
||||
|
||||
Call<WatchInfo> call;
|
||||
|
||||
call = RetrofitClient.getInstance(instanceUrl, context).getApiInterface().checkRepoWatchStatus(token, repoOwner, repoName);
|
||||
call = RetrofitClient.getApiInterface(context).checkRepoWatchStatus(token, repoOwner, repoName);
|
||||
|
||||
call.enqueue(new Callback<WatchInfo>() {
|
||||
|
||||
|
@ -23,9 +23,9 @@ import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
|
||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||
import org.mian.gitnex.activities.RepoForksActivity;
|
||||
import org.mian.gitnex.activities.RepoStargazersActivity;
|
||||
import org.mian.gitnex.activities.RepoWatchersActivity;
|
||||
import org.mian.gitnex.activities.RepoForksActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.database.api.RepositoriesApi;
|
||||
@ -91,7 +91,7 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
||||
Intent intent = new Intent(context, RepoDetailActivity.class);
|
||||
intent.putExtra("repoFullName", fullName.getText().toString());
|
||||
|
||||
TinyDB tinyDb = new TinyDB(context);
|
||||
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
tinyDb.putString("repoFullName", fullName.getText().toString());
|
||||
tinyDb.putString("repoType", repoType.getText().toString());
|
||||
//tinyDb.putBoolean("resumeIssues", true);
|
||||
@ -124,12 +124,11 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
||||
//store if user is watching this repo
|
||||
{
|
||||
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
||||
|
||||
Call<WatchInfo> call;
|
||||
|
||||
call = RetrofitClient.getInstance(instanceUrl, context).getApiInterface().checkRepoWatchStatus(token, repoOwner, repoName);
|
||||
call = RetrofitClient.getApiInterface(context).checkRepoWatchStatus(token, repoOwner, repoName);
|
||||
|
||||
call.enqueue(new Callback<WatchInfo>() {
|
||||
|
||||
|
@ -40,7 +40,7 @@ public class SearchIssuesAdapter extends RecyclerView.Adapter<SearchIssuesAdapte
|
||||
|
||||
this.mCtx = mCtx;
|
||||
this.searchedList = dataList;
|
||||
this.tinyDb = new TinyDB(mCtx);
|
||||
this.tinyDb = TinyDB.getInstance(mCtx);
|
||||
}
|
||||
|
||||
class SearchViewHolder extends RecyclerView.ViewHolder {
|
||||
|
@ -23,9 +23,9 @@ import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
|
||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||
import org.mian.gitnex.activities.RepoForksActivity;
|
||||
import org.mian.gitnex.activities.RepoStargazersActivity;
|
||||
import org.mian.gitnex.activities.RepoWatchersActivity;
|
||||
import org.mian.gitnex.activities.RepoForksActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.database.api.RepositoriesApi;
|
||||
@ -91,7 +91,7 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
||||
Intent intent = new Intent(context, RepoDetailActivity.class);
|
||||
intent.putExtra("repoFullName", fullName.getText().toString());
|
||||
|
||||
TinyDB tinyDb = new TinyDB(context);
|
||||
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
tinyDb.putString("repoFullName", fullName.getText().toString());
|
||||
tinyDb.putString("repoType", repoType.getText().toString());
|
||||
//tinyDb.putBoolean("resumeIssues", true);
|
||||
@ -124,14 +124,13 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
||||
//store if user is watching this repo
|
||||
{
|
||||
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
||||
|
||||
WatchInfo watch = new WatchInfo();
|
||||
|
||||
Call<WatchInfo> call;
|
||||
|
||||
call = RetrofitClient.getInstance(instanceUrl, context).getApiInterface().checkRepoWatchStatus(token, repoOwner, repoName);
|
||||
call = RetrofitClient.getApiInterface(context).checkRepoWatchStatus(token, repoOwner, repoName);
|
||||
|
||||
call.enqueue(new Callback<WatchInfo>() {
|
||||
|
||||
|
@ -82,7 +82,7 @@ public class TeamMembersByOrgAdapter extends BaseAdapter {
|
||||
UserInfo currentItem = teamMembersList.get(position);
|
||||
PicassoService.getInstance(mCtx).get().load(currentItem.getAvatar()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(180, 180).centerCrop().into(viewHolder.memberAvatar);
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(mCtx);
|
||||
final TinyDB tinyDb = TinyDB.getInstance(mCtx);
|
||||
Typeface myTypeface;
|
||||
|
||||
switch(tinyDb.getInt("customFontId", -1)) {
|
||||
|
@ -125,7 +125,7 @@ public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapte
|
||||
public void onBindViewHolder(@NonNull UserAccountsAdapter.UserAccountsViewHolder holder, int position) {
|
||||
|
||||
UserAccount currentItem = userAccountsList.get(position);
|
||||
tinyDB = new TinyDB(mCtx);
|
||||
tinyDB = TinyDB.getInstance(mCtx);
|
||||
|
||||
String url = UrlBuilder.fromString(currentItem.getInstanceUrl())
|
||||
.withPath("/")
|
||||
|
@ -31,7 +31,7 @@ public class UserAccountsListDialogAdapter extends ArrayAdapter<UserAccount> {
|
||||
|
||||
super(mCtx, resource, userAccounts);
|
||||
|
||||
tinyDB = new TinyDB(mCtx);
|
||||
tinyDB = TinyDB.getInstance(mCtx);
|
||||
this.userAccounts = userAccounts;
|
||||
this.mCtx = mCtx;
|
||||
|
||||
|
@ -96,7 +96,7 @@ public class UserAccountsNavAdapter extends RecyclerView.Adapter<UserAccountsNav
|
||||
|
||||
private void customDialogUserAccountsList(List<UserAccount> allAccountsList) {
|
||||
|
||||
TinyDB tinyDB = new TinyDB(mCtx);
|
||||
TinyDB tinyDB = TinyDB.getInstance(mCtx);
|
||||
Dialog dialog = new Dialog(mCtx, R.style.ThemeOverlay_MaterialComponents_Dialog_Alert);
|
||||
dialog.setContentView(R.layout.custom_user_accounts_dialog);
|
||||
|
||||
|
@ -146,19 +146,16 @@ public class UserSearchAdapter extends RecyclerView.Adapter<UserSearchAdapter.Us
|
||||
|
||||
if(getItemCount() > 0) {
|
||||
|
||||
TinyDB tinyDb = new TinyDB(mCtx);
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
TinyDB tinyDb = TinyDB.getInstance(mCtx);
|
||||
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 instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
Call<Collaborators> call = RetrofitClient
|
||||
.getInstance(instanceUrl, mCtx)
|
||||
.getApiInterface()
|
||||
.checkRepoCollaborator(Authorization.returnAuthentication(mCtx, loginUid, instanceToken), repoOwner, repoName, currentItem.getUsername());
|
||||
.getApiInterface(mCtx)
|
||||
.checkRepoCollaborator(Authorization.get(mCtx), repoOwner, repoName, currentItem.getUsername());
|
||||
|
||||
call.enqueue(new Callback<Collaborators>() {
|
||||
|
||||
|
@ -116,8 +116,7 @@ public class UserSearchForTeamMemberAdapter extends RecyclerView.Adapter<UserSea
|
||||
|
||||
if(getItemCount() > 0) {
|
||||
|
||||
TinyDB tinyDb = new TinyDB(mCtx);
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
TinyDB tinyDb = TinyDB.getInstance(mCtx);
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
@ -125,9 +124,8 @@ public class UserSearchForTeamMemberAdapter extends RecyclerView.Adapter<UserSea
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
Call<UserInfo> call = RetrofitClient
|
||||
.getInstance(instanceUrl, mCtx)
|
||||
.getApiInterface()
|
||||
.checkTeamMember(Authorization.returnAuthentication(mCtx, loginUid, instanceToken), teamId, currentItem.getLogin());
|
||||
.getApiInterface(mCtx)
|
||||
.checkTeamMember(Authorization.get(mCtx), teamId, currentItem.getLogin());
|
||||
|
||||
call.enqueue(new Callback<UserInfo>() {
|
||||
|
||||
|
@ -1,79 +0,0 @@
|
||||
package org.mian.gitnex.clients;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.FilesData;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.ssl.MemorizingTrustManager;
|
||||
import java.io.File;
|
||||
import java.security.SecureRandom;
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
import okhttp3.Cache;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.logging.HttpLoggingInterceptor;
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
public class AppApiService {
|
||||
|
||||
public static <S> S createService(Class<S> serviceClass, String instanceURL, Context ctx) {
|
||||
|
||||
TinyDB tinyDb = new TinyDB(ctx);
|
||||
final boolean connToInternet = AppUtil.hasNetworkConnection(ctx);
|
||||
File httpCacheDirectory = new File(ctx.getCacheDir(), "responses");
|
||||
int cacheSize = FilesData.returnOnlyNumber(tinyDb.getString("cacheSizeStr")) * 1024 * 1024;
|
||||
Cache cache = new Cache(httpCacheDirectory, cacheSize);
|
||||
|
||||
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
|
||||
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
|
||||
|
||||
try {
|
||||
|
||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
|
||||
MemorizingTrustManager memorizingTrustManager = new MemorizingTrustManager(ctx);
|
||||
sslContext.init(null, new X509TrustManager[]{memorizingTrustManager}, new SecureRandom());
|
||||
|
||||
OkHttpClient okHttpClient = new OkHttpClient.Builder()
|
||||
.cache(cache)
|
||||
//.addInterceptor(logging)
|
||||
.sslSocketFactory(sslContext.getSocketFactory(), memorizingTrustManager)
|
||||
.hostnameVerifier(memorizingTrustManager.wrapHostnameVerifier(HttpsURLConnection.getDefaultHostnameVerifier()))
|
||||
.addInterceptor(chain -> {
|
||||
|
||||
Request request = chain.request();
|
||||
if(connToInternet) {
|
||||
request = request.newBuilder().header("Cache-Control", "public, max-age=" + 60).build();
|
||||
}
|
||||
else {
|
||||
request = request.newBuilder().header("Cache-Control", "public, only-if-cached, max-stale=" + 60 * 60 * 24 * 30).build();
|
||||
}
|
||||
return chain.proceed(request);
|
||||
|
||||
}).build();
|
||||
|
||||
Retrofit.Builder builder = new Retrofit.Builder()
|
||||
.baseUrl(instanceURL)
|
||||
.client(okHttpClient)
|
||||
.addConverterFactory(GsonConverterFactory.create());
|
||||
|
||||
Retrofit retrofit = builder.build();
|
||||
return retrofit.create(serviceClass);
|
||||
|
||||
}
|
||||
catch(Exception e) {
|
||||
Log.e("onFailure", e.toString());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -2,7 +2,6 @@ package org.mian.gitnex.clients;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.FilesData;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.ssl.MemorizingTrustManager;
|
||||
@ -10,13 +9,14 @@ import org.mian.gitnex.interfaces.ApiInterface;
|
||||
import org.mian.gitnex.interfaces.WebInterface;
|
||||
import java.io.File;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
import okhttp3.Cache;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.logging.HttpLoggingInterceptor;
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
import retrofit2.converter.scalars.ScalarsConverterFactory;
|
||||
@ -27,64 +27,91 @@ import retrofit2.converter.scalars.ScalarsConverterFactory;
|
||||
|
||||
public class RetrofitClient {
|
||||
|
||||
private Retrofit retrofit;
|
||||
private static final Map<String, ApiInterface> apiInterfaces = new HashMap<>();
|
||||
private static final Map<String, WebInterface> webInterfaces = new HashMap<>();
|
||||
|
||||
private RetrofitClient(String instanceUrl, Context ctx) {
|
||||
private static Retrofit createRetrofit(Context context, String instanceUrl) {
|
||||
|
||||
TinyDB tinyDb = new TinyDB(ctx);
|
||||
final boolean connToInternet = AppUtil.hasNetworkConnection(ctx);
|
||||
int cacheSize = FilesData.returnOnlyNumber(tinyDb.getString("cacheSizeStr")) * 1024 * 1024;
|
||||
File httpCacheDirectory = new File(ctx.getCacheDir(), "responses");
|
||||
Cache cache = new Cache(httpCacheDirectory, cacheSize);
|
||||
TinyDB tinyDB = TinyDB.getInstance(context);
|
||||
|
||||
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
|
||||
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
|
||||
int cacheSize = FilesData.returnOnlyNumber(tinyDB.getString("cacheSizeStr")) * 1024 * 1024;
|
||||
Cache cache = new Cache(new File(context.getCacheDir(), "responses"), cacheSize);
|
||||
|
||||
try {
|
||||
|
||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
|
||||
MemorizingTrustManager memorizingTrustManager = new MemorizingTrustManager(ctx);
|
||||
sslContext.init(null, new X509TrustManager[]{memorizingTrustManager}, new SecureRandom());
|
||||
MemorizingTrustManager memorizingTrustManager = new MemorizingTrustManager(context);
|
||||
sslContext.init(null, new X509TrustManager[]{ memorizingTrustManager }, new SecureRandom());
|
||||
|
||||
OkHttpClient.Builder okHttpClient = new OkHttpClient.Builder().cache(cache)
|
||||
//.addInterceptor(logging)
|
||||
.sslSocketFactory(sslContext.getSocketFactory(), memorizingTrustManager).hostnameVerifier(memorizingTrustManager.wrapHostnameVerifier(HttpsURLConnection.getDefaultHostnameVerifier())).addInterceptor(chain -> {
|
||||
.sslSocketFactory(sslContext.getSocketFactory(), memorizingTrustManager)
|
||||
.hostnameVerifier(memorizingTrustManager.wrapHostnameVerifier(HttpsURLConnection.getDefaultHostnameVerifier()))
|
||||
.addInterceptor(chain -> {
|
||||
|
||||
Request request = chain.request();
|
||||
if(connToInternet) {
|
||||
request = request.newBuilder().header("Cache-Control", "public, max-age=" + 60).build();
|
||||
}
|
||||
else {
|
||||
request = request.newBuilder().header("Cache-Control", "public, only-if-cached, max-stale=" + 60 * 60 * 24 * 30).build();
|
||||
}
|
||||
return chain.proceed(request);
|
||||
});
|
||||
Request request = chain.request()
|
||||
.newBuilder()
|
||||
.header("Cache-Control", "public, max-age=" + 60)
|
||||
.build();
|
||||
|
||||
Retrofit.Builder builder = new Retrofit.Builder().baseUrl(instanceUrl).client(okHttpClient.build()).addConverterFactory(ScalarsConverterFactory.create()).addConverterFactory(GsonConverterFactory.create());
|
||||
return chain.proceed(request);
|
||||
|
||||
retrofit = builder.build();
|
||||
});
|
||||
|
||||
return new Retrofit.Builder()
|
||||
.baseUrl(instanceUrl)
|
||||
.client(okHttpClient.build())
|
||||
.addConverterFactory(ScalarsConverterFactory.create())
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
.build();
|
||||
|
||||
} catch(Exception e) {
|
||||
|
||||
}
|
||||
catch(Exception e) {
|
||||
Log.e("onFailure", e.toString());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static synchronized RetrofitClient getInstance(String instanceUrl, Context ctx) {
|
||||
public static synchronized ApiInterface getApiInterface(Context context) {
|
||||
|
||||
return new RetrofitClient(instanceUrl, ctx);
|
||||
return getApiInterface(context, TinyDB.getInstance(context).getString("instanceUrl"));
|
||||
}
|
||||
|
||||
public ApiInterface getApiInterface() {
|
||||
public static synchronized WebInterface getWebInterface(Context context) {
|
||||
|
||||
String instanceUrl = TinyDB.getInstance(context).getString("instanceUrl");
|
||||
instanceUrl = instanceUrl.substring(0, instanceUrl.lastIndexOf("api/v1/"));
|
||||
|
||||
return getWebInterface(context, instanceUrl);
|
||||
|
||||
return retrofit.create(ApiInterface.class);
|
||||
}
|
||||
|
||||
public WebInterface getWebInterface() {
|
||||
public static synchronized ApiInterface getApiInterface(Context context, String url) {
|
||||
if(!apiInterfaces.containsKey(url)) {
|
||||
|
||||
return retrofit.create(WebInterface.class);
|
||||
ApiInterface apiInterface = createRetrofit(context, url)
|
||||
.create(ApiInterface.class);
|
||||
|
||||
apiInterfaces.put(url, apiInterface);
|
||||
return apiInterface;
|
||||
|
||||
}
|
||||
|
||||
return apiInterfaces.get(url);
|
||||
}
|
||||
|
||||
public static synchronized WebInterface getWebInterface(Context context, String url) {
|
||||
if(!webInterfaces.containsKey(url)) {
|
||||
|
||||
WebInterface webInterface = createRetrofit(context, url)
|
||||
.create(WebInterface.class);
|
||||
|
||||
webInterfaces.put(url, webInterface);
|
||||
return webInterface;
|
||||
|
||||
}
|
||||
|
||||
return webInterfaces.get(url);
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ public class DraftsApi {
|
||||
draftsDao = db.draftsDao();
|
||||
}
|
||||
|
||||
public long insertDraft(int repositoryId, int draftAccountId, int issueId, String draftText, String draftType, String commentId) {
|
||||
public long insertDraft(int repositoryId, int draftAccountId, int issueId, String draftText, String draftType, String commentId, String issueType) {
|
||||
|
||||
Draft draft = new Draft();
|
||||
draft.setDraftRepositoryId(repositoryId);
|
||||
@ -35,7 +35,8 @@ public class DraftsApi {
|
||||
draft.setIssueId(issueId);
|
||||
draft.setDraftText(draftText);
|
||||
draft.setDraftType(draftType);
|
||||
draft.setCommentId(draftType);
|
||||
draft.setCommentId(commentId);
|
||||
draft.setIssueType(issueType);
|
||||
|
||||
return insertDraftAsyncTask(draft);
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ import org.mian.gitnex.database.models.UserAccount;
|
||||
*/
|
||||
|
||||
@Database(entities = {Draft.class, Repository.class, UserAccount.class},
|
||||
version = 2, exportSchema = false)
|
||||
version = 3, exportSchema = false)
|
||||
public abstract class GitnexDatabase extends RoomDatabase {
|
||||
|
||||
private static GitnexDatabase gitnexDatabase;
|
||||
@ -27,10 +27,11 @@ public abstract class GitnexDatabase extends RoomDatabase {
|
||||
public static GitnexDatabase getDatabaseInstance(Context context) {
|
||||
|
||||
if (gitnexDatabase == null) {
|
||||
|
||||
String DB_NAME = "gitnex";
|
||||
gitnexDatabase = Room.databaseBuilder(context, GitnexDatabase.class, DB_NAME)
|
||||
//.fallbackToDestructiveMigration()
|
||||
.addMigrations(MIGRATION_1_2)
|
||||
.addMigrations(MIGRATION_1_2, MIGRATION_2_3)
|
||||
.build();
|
||||
}
|
||||
|
||||
@ -49,7 +50,14 @@ public abstract class GitnexDatabase extends RoomDatabase {
|
||||
|
||||
//database.execSQL("DROP TABLE Drafts");
|
||||
database.execSQL("ALTER TABLE 'Drafts' ADD COLUMN 'commentId' TEXT");
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
private static final Migration MIGRATION_2_3 = new Migration(2, 3) {
|
||||
@Override
|
||||
public void migrate(@NonNull SupportSQLiteDatabase database) {
|
||||
|
||||
database.execSQL("ALTER TABLE 'Drafts' ADD COLUMN 'issueType' TEXT");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -26,6 +26,8 @@ public class Draft implements Serializable {
|
||||
private String draftType;
|
||||
@Nullable
|
||||
private String commentId;
|
||||
@Nullable
|
||||
private String issueType;
|
||||
|
||||
public int getDraftId() {
|
||||
|
||||
@ -99,4 +101,15 @@ public class Draft implements Serializable {
|
||||
this.commentId = commentId;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getIssueType() {
|
||||
|
||||
return issueType;
|
||||
}
|
||||
|
||||
public void setIssueType(@Nullable String issueType) {
|
||||
|
||||
this.issueType = issueType;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ public class DraftWithRepository {
|
||||
private String draftText;
|
||||
private String draftType;
|
||||
private String commentId;
|
||||
private String issueType;
|
||||
|
||||
public int getRepositoryId() {
|
||||
|
||||
@ -130,4 +131,14 @@ public class DraftWithRepository {
|
||||
this.commentId = commentId;
|
||||
}
|
||||
|
||||
public String getIssueType() {
|
||||
|
||||
return issueType;
|
||||
}
|
||||
|
||||
public void setIssueType(String issueType) {
|
||||
|
||||
this.issueType = issueType;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ public class AboutFragment extends Fragment {
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
|
||||
FragmentAboutBinding viewBinding = FragmentAboutBinding.inflate(inflater, container, false);
|
||||
TinyDB tinyDb = new TinyDB(getContext());
|
||||
TinyDB tinyDb = TinyDB.getInstance(getContext());
|
||||
|
||||
viewBinding.appVersion.setText(AppUtil.getAppVersion(requireContext()));
|
||||
viewBinding.userServerVersion.setText(tinyDb.getString("giteaVersion"));
|
||||
|
@ -11,7 +11,6 @@ import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.AdminGetUsersActivity;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
@ -23,8 +22,6 @@ public class AdministrationFragment extends Fragment {
|
||||
|
||||
View v = inflater.inflate(R.layout.fragment_administration, container, false);
|
||||
|
||||
TinyDB tinyDb = new TinyDB(getContext());
|
||||
|
||||
TextView adminUsers = v.findViewById(R.id.adminUsers);
|
||||
|
||||
adminUsers.setOnClickListener(v1 -> startActivity(new Intent(getContext(), AdminGetUsersActivity.class)));
|
||||
|
@ -24,7 +24,7 @@ public class BottomSheetNotificationsFilterFragment extends BottomSheetDialogFra
|
||||
@Override
|
||||
public void onAttach(@NonNull Context context) {
|
||||
|
||||
this.tinyDB = new TinyDB(context);
|
||||
this.tinyDB = TinyDB.getInstance(context);
|
||||
super.onAttach(context);
|
||||
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ import android.widget.ImageButton;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||
import org.mian.gitnex.R;
|
||||
@ -34,6 +35,9 @@ import java.util.Objects;
|
||||
|
||||
public class BottomSheetReplyFragment extends BottomSheetDialogFragment {
|
||||
|
||||
private enum Mode { EDIT, SEND }
|
||||
private Mode mode = Mode.SEND;
|
||||
|
||||
private TinyDB tinyDB;
|
||||
private DraftsApi draftsApi;
|
||||
|
||||
@ -42,12 +46,13 @@ public class BottomSheetReplyFragment extends BottomSheetDialogFragment {
|
||||
private int issueNumber;
|
||||
private long draftId;
|
||||
|
||||
private OnInteractedListener onInteractedListener;
|
||||
private TextView draftsHint;
|
||||
|
||||
@Override
|
||||
public void onAttach(@NonNull Context context) {
|
||||
|
||||
tinyDB = new TinyDB(context);
|
||||
tinyDB = TinyDB.getInstance(context);
|
||||
draftsApi = new DraftsApi(context);
|
||||
|
||||
repositoryId = (int) tinyDB.getLong("repositoryId", 0);
|
||||
@ -67,7 +72,7 @@ public class BottomSheetReplyFragment extends BottomSheetDialogFragment {
|
||||
|
||||
draftsHint = view.findViewById(R.id.drafts_hint);
|
||||
|
||||
EditText commentContent = view.findViewById(R.id.comment);
|
||||
EditText comment = view.findViewById(R.id.comment);
|
||||
TextView toolbarTitle = view.findViewById(R.id.toolbar_title);
|
||||
ImageButton close = view.findViewById(R.id.close);
|
||||
ImageButton drafts = view.findViewById(R.id.drafts);
|
||||
@ -75,9 +80,12 @@ public class BottomSheetReplyFragment extends BottomSheetDialogFragment {
|
||||
|
||||
send.setEnabled(false);
|
||||
|
||||
if(Objects.equals(arguments.getString("commentAction"), "edit")) {
|
||||
if(Objects.equals(arguments.getString("commentAction"), "edit") &&
|
||||
arguments.getString("draftId") == null) {
|
||||
|
||||
send.setImageDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.ic_save));
|
||||
mode = Mode.EDIT;
|
||||
|
||||
send.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if(arguments.getString("draftId") != null) {
|
||||
@ -99,16 +107,16 @@ public class BottomSheetReplyFragment extends BottomSheetDialogFragment {
|
||||
send.setEnabled(true);
|
||||
send.setAlpha(1f);
|
||||
|
||||
commentContent.setText(arguments.getString("commentBody"));
|
||||
comment.setText(arguments.getString("commentBody"));
|
||||
|
||||
if(arguments.getBoolean("cursorToEnd", false)) {
|
||||
|
||||
commentContent.setSelection(commentContent.length());
|
||||
comment.setSelection(comment.length());
|
||||
}
|
||||
}
|
||||
|
||||
commentContent.requestFocus();
|
||||
commentContent.setOnTouchListener((v, event) -> {
|
||||
comment.requestFocus();
|
||||
comment.setOnTouchListener((v, event) -> {
|
||||
|
||||
BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.from((View) view.getParent());
|
||||
|
||||
@ -127,12 +135,12 @@ public class BottomSheetReplyFragment extends BottomSheetDialogFragment {
|
||||
|
||||
});
|
||||
|
||||
commentContent.addTextChangedListener(new TextWatcher() {
|
||||
comment.addTextChangedListener(new TextWatcher() {
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
String text = commentContent.getText().toString();
|
||||
String text = comment.getText().toString();
|
||||
|
||||
if(text.isEmpty()) {
|
||||
|
||||
@ -150,6 +158,7 @@ public class BottomSheetReplyFragment extends BottomSheetDialogFragment {
|
||||
|
||||
@Override public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
|
||||
@Override public void onTextChanged(CharSequence s, int start, int before, int count) {}
|
||||
|
||||
});
|
||||
|
||||
close.setOnClickListener(v -> dismiss());
|
||||
@ -161,33 +170,69 @@ public class BottomSheetReplyFragment extends BottomSheetDialogFragment {
|
||||
startActivity(intent);
|
||||
|
||||
dismiss();
|
||||
|
||||
});
|
||||
|
||||
send.setOnClickListener(v -> IssueActions
|
||||
.reply(getContext(), commentContent.getText().toString(), issueNumber)
|
||||
.accept((status, result) -> {
|
||||
send.setOnClickListener(v -> {
|
||||
|
||||
if(status == ActionResult.Status.SUCCESS) {
|
||||
if(mode == Mode.SEND) {
|
||||
|
||||
Toasty.success(getContext(), getString(R.string.commentSuccess));
|
||||
IssueActions
|
||||
.reply(getContext(), comment.getText().toString(), issueNumber)
|
||||
.accept((status, result) -> {
|
||||
|
||||
tinyDB.putBoolean("commentPosted", true);
|
||||
tinyDB.putBoolean("resumeIssues", true);
|
||||
tinyDB.putBoolean("resumePullRequests", true);
|
||||
if(status == ActionResult.Status.SUCCESS) {
|
||||
|
||||
if(draftId != 0 && tinyDB.getBoolean("draftsCommentsDeletionEnabled")) {
|
||||
Toasty.success(getContext(), getString(R.string.commentSuccess));
|
||||
|
||||
draftsApi.deleteSingleDraft((int) draftId);
|
||||
}
|
||||
if(draftId != 0 && tinyDB.getBoolean("draftsCommentsDeletionEnabled")) {
|
||||
draftsApi.deleteSingleDraft((int) draftId);
|
||||
}
|
||||
|
||||
dismiss();
|
||||
}
|
||||
else {
|
||||
tinyDB.putBoolean("commentPosted", true);
|
||||
tinyDB.putBoolean("resumeIssues", true);
|
||||
tinyDB.putBoolean("resumePullRequests", true);
|
||||
|
||||
Toasty.error(getContext(), getString(R.string.commentError));
|
||||
dismiss();
|
||||
}
|
||||
}));
|
||||
if(onInteractedListener != null) {
|
||||
onInteractedListener.onInteracted();
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(getContext(), getString(R.string.commentError));
|
||||
}
|
||||
|
||||
dismiss();
|
||||
|
||||
});
|
||||
} else {
|
||||
|
||||
IssueActions
|
||||
.edit(getContext(), comment.getText().toString(), arguments.getInt("commentId"))
|
||||
.accept((status, result) -> {
|
||||
|
||||
if(status == ActionResult.Status.SUCCESS) {
|
||||
|
||||
if(draftId != 0 && tinyDB.getBoolean("draftsCommentsDeletionEnabled")) {
|
||||
draftsApi.deleteSingleDraft((int) draftId);
|
||||
}
|
||||
|
||||
tinyDB.putBoolean("commentEdited", true);
|
||||
|
||||
if(onInteractedListener != null) {
|
||||
onInteractedListener.onInteracted();
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(getContext(), getString(R.string.genericError));
|
||||
}
|
||||
|
||||
dismiss();
|
||||
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return view;
|
||||
}
|
||||
@ -216,9 +261,26 @@ public class BottomSheetReplyFragment extends BottomSheetDialogFragment {
|
||||
}
|
||||
else {
|
||||
|
||||
String draftType;
|
||||
if(tinyDB.getString("issueType").equalsIgnoreCase("Issue")) {
|
||||
|
||||
draftType = StaticGlobalVariables.draftTypeIssue;
|
||||
}
|
||||
else if(tinyDB.getString("issueType").equalsIgnoreCase("Pull")) {
|
||||
|
||||
draftType = StaticGlobalVariables.draftTypePull;
|
||||
}
|
||||
else {
|
||||
|
||||
draftType = "";
|
||||
}
|
||||
|
||||
if(draftId == 0) {
|
||||
draftId = draftsApi.insertDraft(repositoryId, currentActiveAccountId, issueNumber, text, StaticGlobalVariables.draftTypeComment, "TODO");
|
||||
} else {
|
||||
|
||||
draftId = draftsApi.insertDraft(repositoryId, currentActiveAccountId, issueNumber, text, draftType, "TODO", tinyDB.getString("issueType"));
|
||||
}
|
||||
else {
|
||||
|
||||
DraftsApi.updateDraft(text, (int) draftId, "TODO");
|
||||
}
|
||||
|
||||
@ -234,4 +296,12 @@ public class BottomSheetReplyFragment extends BottomSheetDialogFragment {
|
||||
|
||||
return fragment;
|
||||
}
|
||||
|
||||
public void setOnInteractedListener(OnInteractedListener onInteractedListener) {
|
||||
|
||||
this.onInteractedListener = onInteractedListener;
|
||||
}
|
||||
|
||||
public interface OnInteractedListener { void onInteracted(); }
|
||||
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ public class BottomSheetRepoFragment extends BottomSheetDialogFragment {
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View v = inflater.inflate(R.layout.bottom_sheet_repo, container, false);
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(getContext());
|
||||
final TinyDB tinyDb = TinyDB.getInstance(getContext());
|
||||
|
||||
TextView createLabel = v.findViewById(R.id.createLabel);
|
||||
TextView createIssue = v.findViewById(R.id.createNewIssue);
|
||||
|
@ -37,7 +37,7 @@ public class BottomSheetSingleIssueFragment extends BottomSheetDialogFragment {
|
||||
View v = inflater.inflate(R.layout.bottom_sheet_single_issue, container, false);
|
||||
|
||||
final Context ctx = getContext();
|
||||
final TinyDB tinyDB = new TinyDB(ctx);
|
||||
final TinyDB tinyDB = TinyDB.getInstance(ctx);
|
||||
|
||||
TextView editIssue = v.findViewById(R.id.editIssue);
|
||||
TextView editLabels = v.findViewById(R.id.editLabels);
|
||||
|
@ -16,7 +16,6 @@ import androidx.lifecycle.ViewModelProvider;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.CollaboratorsAdapter;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.models.Collaborators;
|
||||
import org.mian.gitnex.viewmodels.CollaboratorsViewModel;
|
||||
import java.util.List;
|
||||
@ -65,18 +64,12 @@ public class CollaboratorsFragment extends Fragment {
|
||||
Bundle savedInstanceState) {
|
||||
|
||||
View v = inflater.inflate(R.layout.fragment_collaborators, container, false);
|
||||
TinyDB tinyDb = new TinyDB(getContext());
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
noDataCollaborators = v.findViewById(R.id.noDataCollaborators);
|
||||
|
||||
mProgressBar = v.findViewById(R.id.progress_bar);
|
||||
|
||||
mGridView = v.findViewById(R.id.gridView);
|
||||
|
||||
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName);
|
||||
|
||||
fetchDataAsync(Authorization.get(getContext()), repoOwner, repoName);
|
||||
return v;
|
||||
}
|
||||
|
||||
@ -96,11 +89,11 @@ public class CollaboratorsFragment extends Fragment {
|
||||
void onFragmentInteraction(Uri uri);
|
||||
}
|
||||
|
||||
private void fetchDataAsync(String instanceUrl, String instanceToken, String owner, String repo) {
|
||||
private void fetchDataAsync(String instanceToken, String owner, String repo) {
|
||||
|
||||
CollaboratorsViewModel collaboratorsModel = new ViewModelProvider(this).get(CollaboratorsViewModel.class);
|
||||
|
||||
collaboratorsModel.getCollaboratorsList(instanceUrl, instanceToken, owner, repo, getContext()).observe(getViewLifecycleOwner(), new Observer<List<Collaborators>>() {
|
||||
collaboratorsModel.getCollaboratorsList(instanceToken, owner, repo, getContext()).observe(getViewLifecycleOwner(), new Observer<List<Collaborators>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<Collaborators> collaboratorsListMain) {
|
||||
adapter = new CollaboratorsAdapter(getContext(), collaboratorsListMain);
|
||||
|
@ -54,7 +54,7 @@ public class DraftsFragment extends Fragment {
|
||||
|
||||
((MainActivity) requireActivity()).setActionBarTitle(getResources().getString(R.string.titleDrafts));
|
||||
|
||||
TinyDB tinyDb = new TinyDB(ctx);
|
||||
TinyDB tinyDb = TinyDB.getInstance(ctx);
|
||||
|
||||
draftsList_ = new ArrayList<>();
|
||||
draftsApi = new DraftsApi(ctx);
|
||||
|
@ -36,7 +36,7 @@ public class ExploreFragment extends Fragment {
|
||||
|
||||
View v = inflater.inflate(R.layout.fragment_explore, container,false);
|
||||
ctx = getContext();
|
||||
tinyDB = new TinyDB(ctx);
|
||||
tinyDB = TinyDB.getInstance(ctx);
|
||||
|
||||
((MainActivity) requireActivity()).setActionBarTitle(getResources().getString(R.string.navExplore));
|
||||
|
||||
|
@ -58,10 +58,6 @@ public class ExploreRepositoriesFragment extends Fragment {
|
||||
private List<UserRepositories> dataList;
|
||||
private ExploreRepositoriesAdapter adapter;
|
||||
|
||||
private String instanceUrl;
|
||||
private String loginUid;
|
||||
private String instanceToken;
|
||||
|
||||
private Dialog dialogFilterOptions;
|
||||
private CustomExploreRepositoriesDialogBinding filterBinding;
|
||||
|
||||
@ -72,11 +68,7 @@ public class ExploreRepositoriesFragment extends Fragment {
|
||||
setHasOptionsMenu(true);
|
||||
|
||||
ctx = getContext();
|
||||
tinyDb = new TinyDB(getContext());
|
||||
|
||||
instanceUrl = tinyDb.getString("instanceUrl");
|
||||
loginUid = tinyDb.getString("loginUid");
|
||||
instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
tinyDb = TinyDB.getInstance(getContext());
|
||||
|
||||
dataList = new ArrayList<>();
|
||||
adapter = new ExploreRepositoriesAdapter(dataList, ctx);
|
||||
@ -183,7 +175,7 @@ public class ExploreRepositoriesFragment extends Fragment {
|
||||
viewBinding.loadingMoreView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
Call<ExploreRepositories> call = RetrofitClient.getInstance(instanceUrl, getContext()).getApiInterface().queryRepos(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), searchKeyword, repoTypeInclude, sort, order, exploreRepoIncludeTopic, exploreRepoIncludeDescription, exploreRepoIncludeTemplate, exploreRepoOnlyArchived, limit, pageCurrentIndex);
|
||||
Call<ExploreRepositories> call = RetrofitClient.getApiInterface(ctx).queryRepos(Authorization.get(getContext()), searchKeyword, repoTypeInclude, sort, order, exploreRepoIncludeTopic, exploreRepoIncludeDescription, exploreRepoIncludeTemplate, exploreRepoOnlyArchived, limit, pageCurrentIndex);
|
||||
|
||||
call.enqueue(new Callback<ExploreRepositories>() {
|
||||
|
||||
|
@ -26,7 +26,6 @@ import org.mian.gitnex.activities.RepoDetailActivity;
|
||||
import org.mian.gitnex.adapters.FilesAdapter;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.viewmodels.FilesViewModel;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@ -89,11 +88,6 @@ public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapter
|
||||
View v = inflater.inflate(R.layout.fragment_files, container, false);
|
||||
setHasOptionsMenu(true);
|
||||
|
||||
TinyDB tinyDb = new TinyDB(getContext());
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
noDataFiles = v.findViewById(R.id.noDataFiles);
|
||||
filesFrame = v.findViewById(R.id.filesFrame);
|
||||
|
||||
@ -115,11 +109,11 @@ public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapter
|
||||
fileStructure.setText("");
|
||||
ref = repoBranch;
|
||||
mBreadcrumbsView.setItems(new ArrayList<>(Collections.singletonList(BreadcrumbItem.createSimpleItem(getResources().getString(R.string.filesBreadcrumbRoot) + getResources().getString(R.string.colonDivider) + ref))));
|
||||
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, repoBranch);
|
||||
fetchDataAsync(Authorization.get(getContext()), repoOwner, repoName, repoBranch);
|
||||
|
||||
});
|
||||
|
||||
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, ref);
|
||||
fetchDataAsync(Authorization.get(getContext()), repoOwner, repoName, ref);
|
||||
|
||||
return v;
|
||||
}
|
||||
@ -133,11 +127,6 @@ public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapter
|
||||
@Override
|
||||
public void onClickDir(String dirName) {
|
||||
|
||||
TinyDB tinyDb = new TinyDB(getContext());
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
StringBuilder breadcrumbBuilder = new StringBuilder();
|
||||
|
||||
breadcrumbBuilder.append(fileStructure.getText().toString()).append("/").append(dirName);
|
||||
@ -158,7 +147,7 @@ public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapter
|
||||
|
||||
if(position == 0) {
|
||||
|
||||
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, ref);
|
||||
fetchDataAsync(Authorization.get(getContext()), repoOwner, repoName, ref);
|
||||
fileStructure.setText("");
|
||||
return;
|
||||
}
|
||||
@ -169,7 +158,7 @@ public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapter
|
||||
|
||||
String currentIndex = (result + item.getSelectedItem()).substring(1);
|
||||
|
||||
fetchDataAsyncSub(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, currentIndex, ref);
|
||||
fetchDataAsyncSub(Authorization.get(getContext()), repoOwner, repoName, currentIndex, ref);
|
||||
|
||||
}
|
||||
|
||||
@ -179,7 +168,7 @@ public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapter
|
||||
}
|
||||
});
|
||||
|
||||
fetchDataAsyncSub(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, finalDirName_, ref);
|
||||
fetchDataAsyncSub(Authorization.get(getContext()), repoOwner, repoName, finalDirName_, ref);
|
||||
|
||||
}
|
||||
|
||||
@ -200,14 +189,14 @@ public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapter
|
||||
requireContext().startActivity(intent);
|
||||
}
|
||||
|
||||
private void fetchDataAsync(String instanceUrl, String instanceToken, String owner, String repo, String ref) {
|
||||
private void fetchDataAsync(String instanceToken, String owner, String repo, String ref) {
|
||||
|
||||
mRecyclerView.setVisibility(View.GONE);
|
||||
mProgressBar.setVisibility(View.VISIBLE);
|
||||
|
||||
FilesViewModel filesModel = new ViewModelProvider(this).get(FilesViewModel.class);
|
||||
|
||||
filesModel.getFilesList(instanceUrl, instanceToken, owner, repo, ref, getContext(), mProgressBar, noDataFiles).observe(getViewLifecycleOwner(), filesListMain -> {
|
||||
filesModel.getFilesList(instanceToken, owner, repo, ref, getContext(), mProgressBar, noDataFiles).observe(getViewLifecycleOwner(), filesListMain -> {
|
||||
|
||||
adapter = new FilesAdapter(getContext(), filesListMain, FilesFragment.this);
|
||||
mBreadcrumbsView.removeItemAfter(1);
|
||||
@ -231,14 +220,14 @@ public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapter
|
||||
|
||||
}
|
||||
|
||||
private void fetchDataAsyncSub(String instanceUrl, String instanceToken, String owner, String repo, String filesDir, String ref) {
|
||||
private void fetchDataAsyncSub(String instanceToken, String owner, String repo, String filesDir, String ref) {
|
||||
|
||||
mRecyclerView.setVisibility(View.GONE);
|
||||
mProgressBar.setVisibility(View.VISIBLE);
|
||||
|
||||
FilesViewModel filesModel2 = new ViewModelProvider(this).get(FilesViewModel.class);
|
||||
|
||||
filesModel2.getFilesList2(instanceUrl, instanceToken, owner, repo, filesDir, ref, getContext(), mProgressBar, noDataFiles).observe(this, filesListMain2 -> {
|
||||
filesModel2.getFilesList2(instanceToken, owner, repo, filesDir, ref, getContext(), mProgressBar, noDataFiles).observe(this, filesListMain2 -> {
|
||||
|
||||
adapter = new FilesAdapter(getContext(), filesListMain2, FilesFragment.this);
|
||||
|
||||
|
@ -23,13 +23,12 @@ import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||
import org.mian.gitnex.adapters.IssuesAdapter;
|
||||
import org.mian.gitnex.clients.AppApiService;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.StaticGlobalVariables;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import org.mian.gitnex.interfaces.ApiInterface;
|
||||
import org.mian.gitnex.models.Issues;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -47,7 +46,6 @@ public class IssuesFragment extends Fragment {
|
||||
private RecyclerView recyclerView;
|
||||
private List<Issues> issuesList;
|
||||
private IssuesAdapter adapter;
|
||||
private ApiInterface api;
|
||||
private Context context;
|
||||
private int pageSize = StaticGlobalVariables.issuesPageInit;
|
||||
private ProgressBar mProgressBar;
|
||||
@ -65,12 +63,11 @@ public class IssuesFragment extends Fragment {
|
||||
setHasOptionsMenu(true);
|
||||
context = getContext();
|
||||
|
||||
TinyDB tinyDb = new TinyDB(getContext());
|
||||
TinyDB tinyDb = TinyDB.getInstance(getContext());
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
@ -102,7 +99,7 @@ public class IssuesFragment extends Fragment {
|
||||
if(issuesList.size() == resultLimit || pageSize == resultLimit) {
|
||||
|
||||
int page = (issuesList.size() + resultLimit) / resultLimit;
|
||||
loadMore(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, page, resultLimit, requestType, tinyDb.getString("repoIssuesState"));
|
||||
loadMore(Authorization.get(getContext()), repoOwner, repoName, page, resultLimit, requestType, tinyDb.getString("repoIssuesState"));
|
||||
|
||||
}
|
||||
|
||||
@ -129,7 +126,7 @@ public class IssuesFragment extends Fragment {
|
||||
if(issuesList.size() == resultLimit || pageSize == resultLimit) {
|
||||
|
||||
int page = (issuesList.size() + resultLimit) / resultLimit;
|
||||
loadMore(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, page, resultLimit, requestType, tinyDb.getString("repoIssuesState"));
|
||||
loadMore(Authorization.get(getContext()), repoOwner, repoName, page, resultLimit, requestType, tinyDb.getString("repoIssuesState"));
|
||||
|
||||
}
|
||||
|
||||
@ -140,13 +137,12 @@ public class IssuesFragment extends Fragment {
|
||||
mProgressBar.setVisibility(View.VISIBLE);
|
||||
noDataIssues.setVisibility(View.GONE);
|
||||
|
||||
loadInitial(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, resultLimit, requestType, issueState);
|
||||
loadInitial(Authorization.get(getContext()), repoOwner, repoName, resultLimit, requestType, issueState);
|
||||
recyclerView.setAdapter(adapter);
|
||||
|
||||
});
|
||||
|
||||
api = AppApiService.createService(ApiInterface.class, instanceUrl, getContext());
|
||||
loadInitial(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, resultLimit, requestType, tinyDb.getString("repoIssuesState"));
|
||||
loadInitial(Authorization.get(getContext()), repoOwner, repoName, resultLimit, requestType, tinyDb.getString("repoIssuesState"));
|
||||
|
||||
return v;
|
||||
|
||||
@ -156,17 +152,16 @@ public class IssuesFragment extends Fragment {
|
||||
public void onResume() {
|
||||
|
||||
super.onResume();
|
||||
TinyDB tinyDb = new TinyDB(getContext());
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
TinyDB tinyDb = TinyDB.getInstance(getContext());
|
||||
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
if(tinyDb.getBoolean("resumeIssues")) {
|
||||
|
||||
loadInitial(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, resultLimit, requestType, tinyDb.getString("repoIssuesState"));
|
||||
loadInitial(Authorization.get(getContext()), repoOwner, repoName, resultLimit, requestType, tinyDb.getString("repoIssuesState"));
|
||||
tinyDb.putBoolean("resumeIssues", false);
|
||||
|
||||
}
|
||||
@ -175,7 +170,7 @@ public class IssuesFragment extends Fragment {
|
||||
|
||||
private void loadInitial(String token, String repoOwner, String repoName, int resultLimit, String requestType, String issueState) {
|
||||
|
||||
Call<List<Issues>> call = api.getIssues(token, repoOwner, repoName, 1, resultLimit, requestType, issueState);
|
||||
Call<List<Issues>> call = RetrofitClient.getApiInterface(context).getIssues(token, repoOwner, repoName, 1, resultLimit, requestType, issueState);
|
||||
|
||||
call.enqueue(new Callback<List<Issues>>() {
|
||||
|
||||
@ -230,7 +225,7 @@ public class IssuesFragment extends Fragment {
|
||||
|
||||
progressLoadMore.setVisibility(View.VISIBLE);
|
||||
|
||||
Call<List<Issues>> call = api.getIssues(token, repoOwner, repoName, page, resultLimit, requestType, issueState);
|
||||
Call<List<Issues>> call = RetrofitClient.getApiInterface(context).getIssues(token, repoOwner, repoName, page, resultLimit, requestType, issueState);
|
||||
|
||||
call.enqueue(new Callback<List<Issues>>() {
|
||||
|
||||
@ -285,7 +280,7 @@ public class IssuesFragment extends Fragment {
|
||||
inflater.inflate(R.menu.filter_menu, menu);
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
|
||||
TinyDB tinyDb = new TinyDB(context);
|
||||
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
|
||||
if(tinyDb.getString("repoIssuesState").equals("closed")) {
|
||||
menu.getItem(1).setIcon(R.drawable.ic_filter_closed);
|
||||
|
@ -71,10 +71,6 @@ public class LabelsFragment extends Fragment {
|
||||
final View v = inflater.inflate(R.layout.fragment_labels, container, false);
|
||||
setHasOptionsMenu(true);
|
||||
|
||||
TinyDB tinyDb = new TinyDB(getContext());
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
final SwipeRefreshLayout swipeRefresh = v.findViewById(R.id.pullToRefresh);
|
||||
noData = v.findViewById(R.id.noData);
|
||||
|
||||
@ -91,11 +87,11 @@ public class LabelsFragment extends Fragment {
|
||||
swipeRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
|
||||
swipeRefresh.setRefreshing(false);
|
||||
LabelsViewModel.loadLabelsList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, getContext());
|
||||
LabelsViewModel.loadLabelsList(Authorization.get(getContext()), repoOwner, repoName, getContext());
|
||||
|
||||
}, 200));
|
||||
|
||||
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName);
|
||||
fetchDataAsync(Authorization.get(getContext()), repoOwner, repoName);
|
||||
|
||||
return v;
|
||||
|
||||
@ -104,17 +100,15 @@ public class LabelsFragment extends Fragment {
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
final TinyDB tinyDb = new TinyDB(getContext());
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final TinyDB tinyDb = TinyDB.getInstance(getContext());
|
||||
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
if(tinyDb.getBoolean("labelsRefresh")) {
|
||||
LabelsViewModel.loadLabelsList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, getContext());
|
||||
LabelsViewModel.loadLabelsList(Authorization.get(getContext()), repoOwner, repoName, getContext());
|
||||
tinyDb.putBoolean("labelsRefresh", false);
|
||||
}
|
||||
}
|
||||
@ -135,11 +129,11 @@ public class LabelsFragment extends Fragment {
|
||||
void onFragmentInteraction(Uri uri);
|
||||
}
|
||||
|
||||
private void fetchDataAsync(String instanceUrl, String instanceToken, String owner, String repo) {
|
||||
private void fetchDataAsync(String instanceToken, String owner, String repo) {
|
||||
|
||||
LabelsViewModel labelsModel = new ViewModelProvider(this).get(LabelsViewModel.class);
|
||||
|
||||
labelsModel.getLabelsList(instanceUrl, instanceToken, owner, repo, getContext()).observe(getViewLifecycleOwner(), new Observer<List<Labels>>() {
|
||||
labelsModel.getLabelsList(instanceToken, owner, repo, getContext()).observe(getViewLifecycleOwner(), new Observer<List<Labels>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<Labels> labelsListMain) {
|
||||
adapter = new LabelsAdapter(getContext(), labelsListMain);
|
||||
|
@ -68,8 +68,7 @@ public class MembersByOrgFragment extends Fragment {
|
||||
View v = inflater.inflate(R.layout.fragment_members_by_org, container, false);
|
||||
setHasOptionsMenu(true);
|
||||
|
||||
TinyDB tinyDb = new TinyDB(getContext());
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
TinyDB tinyDb = TinyDB.getInstance(getContext());
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
noDataMembers = v.findViewById(R.id.noDataMembers);
|
||||
@ -77,16 +76,16 @@ public class MembersByOrgFragment extends Fragment {
|
||||
progressBar = v.findViewById(R.id.progressBar);
|
||||
mGridView = v.findViewById(R.id.gridView);
|
||||
|
||||
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), orgName);
|
||||
fetchDataAsync(Authorization.get(getContext()), orgName);
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
private void fetchDataAsync(String instanceUrl, String instanceToken, String owner) {
|
||||
private void fetchDataAsync(String instanceToken, String owner) {
|
||||
|
||||
MembersByOrgViewModel membersModel= new ViewModelProvider(this).get(MembersByOrgViewModel.class);
|
||||
|
||||
membersModel.getMembersList(instanceUrl, instanceToken, owner, getContext()).observe(getViewLifecycleOwner(), new Observer<List<UserInfo>>() {
|
||||
membersModel.getMembersList(instanceToken, owner, getContext()).observe(getViewLifecycleOwner(), new Observer<List<UserInfo>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<UserInfo> membersListMain) {
|
||||
adapter = new MembersByOrgAdapter(getContext(), membersListMain);
|
||||
|
@ -18,13 +18,12 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||
import org.mian.gitnex.adapters.MilestonesAdapter;
|
||||
import org.mian.gitnex.clients.AppApiService;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.FragmentMilestonesBinding;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.StaticGlobalVariables;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import org.mian.gitnex.interfaces.ApiInterface;
|
||||
import org.mian.gitnex.models.Milestones;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -43,7 +42,6 @@ public class MilestonesFragment extends Fragment {
|
||||
private Menu menu;
|
||||
private List<Milestones> dataList;
|
||||
private MilestonesAdapter adapter;
|
||||
private ApiInterface api;
|
||||
private Context ctx;
|
||||
private int pageSize = StaticGlobalVariables.milestonesPageInit;
|
||||
private String TAG = StaticGlobalVariables.tagMilestonesFragment;
|
||||
@ -56,12 +54,11 @@ public class MilestonesFragment extends Fragment {
|
||||
setHasOptionsMenu(true);
|
||||
ctx = getContext();
|
||||
|
||||
TinyDB tinyDb = new TinyDB(getContext());
|
||||
TinyDB tinyDb = TinyDB.getInstance(getContext());
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
@ -83,7 +80,7 @@ public class MilestonesFragment extends Fragment {
|
||||
if(dataList.size() == resultLimit || pageSize == resultLimit) {
|
||||
|
||||
int page = (dataList.size() + resultLimit) / resultLimit;
|
||||
loadMore(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, page, resultLimit, tinyDb.getString("milestoneState"));
|
||||
loadMore(Authorization.get(getContext()), repoOwner, repoName, page, resultLimit, tinyDb.getString("milestoneState"));
|
||||
|
||||
}
|
||||
|
||||
@ -99,7 +96,7 @@ public class MilestonesFragment extends Fragment {
|
||||
|
||||
dataList.clear();
|
||||
viewBinding.pullToRefresh.setRefreshing(false);
|
||||
loadInitial(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, resultLimit, tinyDb.getString("milestoneState"));
|
||||
loadInitial(Authorization.get(getContext()), repoOwner, repoName, resultLimit, tinyDb.getString("milestoneState"));
|
||||
adapter.updateList(dataList);
|
||||
|
||||
}, 50));
|
||||
@ -124,7 +121,7 @@ public class MilestonesFragment extends Fragment {
|
||||
if(dataList.size() == resultLimit || pageSize == resultLimit) {
|
||||
|
||||
int page = (dataList.size() + resultLimit) / resultLimit;
|
||||
loadMore(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, page, resultLimit, milestoneState);
|
||||
loadMore(Authorization.get(getContext()), repoOwner, repoName, page, resultLimit, milestoneState);
|
||||
|
||||
}
|
||||
|
||||
@ -137,13 +134,12 @@ public class MilestonesFragment extends Fragment {
|
||||
viewBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
viewBinding.noDataMilestone.setVisibility(View.GONE);
|
||||
|
||||
loadInitial(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, resultLimit, milestoneState);
|
||||
loadInitial(Authorization.get(getContext()), repoOwner, repoName, resultLimit, milestoneState);
|
||||
viewBinding.recyclerView.setAdapter(adapter);
|
||||
|
||||
});
|
||||
|
||||
api = AppApiService.createService(ApiInterface.class, instanceUrl, ctx);
|
||||
loadInitial(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, resultLimit, tinyDb.getString("milestoneState"));
|
||||
loadInitial(Authorization.get(getContext()), repoOwner, repoName, resultLimit, tinyDb.getString("milestoneState"));
|
||||
|
||||
return viewBinding.getRoot();
|
||||
|
||||
@ -153,7 +149,7 @@ public class MilestonesFragment extends Fragment {
|
||||
public void onResume() {
|
||||
|
||||
super.onResume();
|
||||
TinyDB tinyDb = new TinyDB(getContext());
|
||||
TinyDB tinyDb = TinyDB.getInstance(getContext());
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
@ -163,7 +159,7 @@ public class MilestonesFragment extends Fragment {
|
||||
|
||||
if(tinyDb.getBoolean("milestoneCreated")) {
|
||||
|
||||
loadInitial(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, resultLimit, tinyDb.getString("milestoneState"));
|
||||
loadInitial(Authorization.get(getContext()), repoOwner, repoName, resultLimit, tinyDb.getString("milestoneState"));
|
||||
tinyDb.putBoolean("milestoneCreated", false);
|
||||
|
||||
}
|
||||
@ -172,7 +168,7 @@ public class MilestonesFragment extends Fragment {
|
||||
|
||||
private void loadInitial(String token, String repoOwner, String repoName, int resultLimit, String milestoneState) {
|
||||
|
||||
Call<List<Milestones>> call = api.getMilestones(token, repoOwner, repoName, 1, resultLimit, milestoneState);
|
||||
Call<List<Milestones>> call = RetrofitClient.getApiInterface(ctx).getMilestones(token, repoOwner, repoName, 1, resultLimit, milestoneState);
|
||||
|
||||
call.enqueue(new Callback<List<Milestones>>() {
|
||||
|
||||
@ -221,7 +217,7 @@ public class MilestonesFragment extends Fragment {
|
||||
|
||||
viewBinding.progressLoadMore.setVisibility(View.VISIBLE);
|
||||
|
||||
Call<List<Milestones>> call = api.getMilestones(token, repoOwner, repoName, page, resultLimit, milestoneState);
|
||||
Call<List<Milestones>> call = RetrofitClient.getApiInterface(ctx).getMilestones(token, repoOwner, repoName, page, resultLimit, milestoneState);
|
||||
|
||||
call.enqueue(new Callback<List<Milestones>>() {
|
||||
|
||||
@ -278,7 +274,7 @@ public class MilestonesFragment extends Fragment {
|
||||
inflater.inflate(R.menu.filter_menu_milestone, menu);
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
|
||||
TinyDB tinyDb = new TinyDB(ctx);
|
||||
TinyDB tinyDb = TinyDB.getInstance(ctx);
|
||||
|
||||
if(tinyDb.getString("milestoneState").equals("closed")) {
|
||||
menu.getItem(1).setIcon(R.drawable.ic_filter_closed);
|
||||
|
@ -26,7 +26,6 @@ import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.CreateRepoActivity;
|
||||
import org.mian.gitnex.activities.MainActivity;
|
||||
import org.mian.gitnex.adapters.MyReposListAdapter;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.viewmodels.MyRepositoriesViewModel;
|
||||
@ -78,15 +77,10 @@ public class MyRepositoriesFragment extends Fragment {
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(requireContext());
|
||||
|
||||
final View v = inflater.inflate(R.layout.fragment_my_repositories, container, false);
|
||||
setHasOptionsMenu(true);
|
||||
|
||||
TinyDB tinyDb = new TinyDB(getContext());
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
TinyDB tinyDb = TinyDB.getInstance(getContext());
|
||||
final String userLogin = tinyDb.getString("userLogin");
|
||||
tinyDb.putBoolean("isRepoAdmin", true);
|
||||
|
||||
@ -132,11 +126,11 @@ public class MyRepositoriesFragment extends Fragment {
|
||||
swipeRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
|
||||
swipeRefresh.setRefreshing(false);
|
||||
MyRepositoriesViewModel.loadMyReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), userLogin, getContext(), pageSize, resultLimit);
|
||||
MyRepositoriesViewModel.loadMyReposList(Authorization.get(getContext()), userLogin, getContext(), pageSize, resultLimit);
|
||||
|
||||
}, 50));
|
||||
|
||||
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), userLogin, pageSize, resultLimit);
|
||||
fetchDataAsync(Authorization.get(getContext()), userLogin, pageSize, resultLimit);
|
||||
|
||||
return v;
|
||||
|
||||
@ -145,24 +139,21 @@ public class MyRepositoriesFragment extends Fragment {
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
TinyDB tinyDb = new TinyDB(getContext());
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
TinyDB tinyDb = TinyDB.getInstance(getContext());
|
||||
final String userLogin = tinyDb.getString("userLogin");
|
||||
|
||||
if(tinyDb.getBoolean("repoCreated")) {
|
||||
MyRepositoriesViewModel.loadMyReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), userLogin, getContext(), pageSize, resultLimit);
|
||||
MyRepositoriesViewModel.loadMyReposList(Authorization.get(getContext()), userLogin, getContext(), pageSize, resultLimit);
|
||||
tinyDb.putBoolean("repoCreated", false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void fetchDataAsync(String instanceUrl, String instanceToken, String userLogin, int pageSize, int resultLimit) {
|
||||
private void fetchDataAsync(String instanceToken, String userLogin, int pageSize, int resultLimit) {
|
||||
|
||||
MyRepositoriesViewModel myRepoModel = new ViewModelProvider(this).get(MyRepositoriesViewModel.class);
|
||||
|
||||
myRepoModel.getCurrentUserRepositories(instanceUrl, instanceToken, userLogin, getContext(), pageSize, resultLimit).observe(getViewLifecycleOwner(),
|
||||
myRepoModel.getCurrentUserRepositories(instanceToken, userLogin, getContext(), pageSize, resultLimit).observe(getViewLifecycleOwner(),
|
||||
myReposListMain -> {
|
||||
|
||||
adapter = new MyReposListAdapter(getContext(), myReposListMain);
|
||||
@ -183,8 +174,6 @@ public class MyRepositoriesFragment extends Fragment {
|
||||
@Override
|
||||
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(requireContext());
|
||||
|
||||
inflater.inflate(R.menu.search_menu, menu);
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
|
||||
|
@ -80,7 +80,7 @@ public class NotificationsFragment extends Fragment implements NotificationsAdap
|
||||
|
||||
activity = requireActivity();
|
||||
context = getContext();
|
||||
tinyDB = new TinyDB(context);
|
||||
tinyDB = TinyDB.getInstance(context);
|
||||
|
||||
pageResultLimit = StaticGlobalVariables.getCurrentResultLimit(context);
|
||||
tinyDB.putString("notificationsFilterState", currentFilterMode);
|
||||
@ -193,7 +193,6 @@ public class NotificationsFragment extends Fragment implements NotificationsAdap
|
||||
loadingMoreView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
String instanceUrl = tinyDB.getString("instanceUrl");
|
||||
String loginUid = tinyDB.getString("loginUid");
|
||||
String instanceToken = "token " + tinyDB.getString(loginUid + "-token");
|
||||
|
||||
@ -201,8 +200,8 @@ public class NotificationsFragment extends Fragment implements NotificationsAdap
|
||||
new String[]{"pinned", "read"} :
|
||||
new String[]{"pinned", "unread"};
|
||||
|
||||
Call<List<NotificationThread>> call = RetrofitClient.getInstance(instanceUrl, context)
|
||||
.getApiInterface()
|
||||
Call<List<NotificationThread>> call = RetrofitClient
|
||||
.getApiInterface(context)
|
||||
.getNotificationThreads(instanceToken, false, filter,
|
||||
StaticGlobalVariables.defaultOldestTimestamp, "",
|
||||
pageCurrentIndex, pageResultLimit);
|
||||
|
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