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
|
- Okhttp
|
||||||
- Picasso
|
- Picasso
|
||||||
- Markwon
|
- Markwon
|
||||||
|
- Prism4j
|
||||||
- Prettytime
|
- Prettytime
|
||||||
- Amulyakhare/textdrawable
|
- Amulyakhare/textdrawable
|
||||||
- Vdurmont/emoji-java
|
- Vdurmont/emoji-java
|
||||||
|
@ -55,7 +55,7 @@ dependencies {
|
|||||||
def lifecycle_version = '2.3.0-beta01'
|
def lifecycle_version = '2.3.0-beta01'
|
||||||
def markwon_version = '4.6.0'
|
def markwon_version = '4.6.0'
|
||||||
def work_version = "2.4.0"
|
def work_version = "2.4.0"
|
||||||
def acra = "5.5.0"
|
def acra = "5.7.0"
|
||||||
|
|
||||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||||
implementation 'androidx.appcompat:appcompat:1.3.0-alpha02'
|
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:recycler-table:$markwon_version"
|
||||||
implementation "io.noties.markwon:simple-ext:$markwon_version"
|
implementation "io.noties.markwon:simple-ext:$markwon_version"
|
||||||
implementation "io.noties.markwon:syntax-highlight:$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 "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 "com.github.HamidrezaAmz:BreadcrumbsView:0.2.9"
|
||||||
implementation "commons-io:commons-io:20030203.000550"
|
implementation "commons-io:commons-io:20030203.000550"
|
||||||
implementation 'org.apache.commons:commons-lang3:3.11'
|
implementation 'org.apache.commons:commons-lang3:3.11'
|
||||||
@ -103,7 +106,7 @@ dependencies {
|
|||||||
implementation "androidx.room:room-runtime:2.2.5"
|
implementation "androidx.room:room-runtime:2.2.5"
|
||||||
annotationProcessor "androidx.room:room-compiler:2.2.5"
|
annotationProcessor "androidx.room:room-compiler:2.2.5"
|
||||||
implementation "androidx.work:work-runtime:$work_version"
|
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"
|
implementation "io.mikael:urlbuilder:2.0.9"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -74,9 +74,6 @@
|
|||||||
<activity
|
<activity
|
||||||
android:name=".activities.CreateMilestoneActivity"
|
android:name=".activities.CreateMilestoneActivity"
|
||||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|uiMode|keyboard|keyboardHidden|navigation" />
|
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
|
<activity
|
||||||
android:name=".activities.IssueDetailActivity"
|
android:name=".activities.IssueDetailActivity"
|
||||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|uiMode|keyboard|keyboardHidden|navigation"
|
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|uiMode|keyboard|keyboardHidden|navigation"
|
||||||
|
@ -24,12 +24,11 @@ import retrofit2.Callback;
|
|||||||
|
|
||||||
public class AssigneesActions {
|
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
|
Call<Issues> callSingleIssueLabels = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
.getIssueByIndex(Authorization.get(ctx), repoOwner, repoName, issueIndex);
|
||||||
.getIssueByIndex(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, issueIndex);
|
|
||||||
|
|
||||||
callSingleIssueLabels.enqueue(new Callback<Issues>() {
|
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
|
Call<List<Collaborators>> call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
.getCollaborators(Authorization.get(ctx), repoOwner, repoName);
|
||||||
.getCollaborators(instanceToken, repoOwner, repoName);
|
|
||||||
|
|
||||||
call.enqueue(new Callback<List<Collaborators>>() {
|
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) {
|
public static void deleteCollaborator(final Context context, final String searchKeyword, String userName) {
|
||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(context);
|
final TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
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("/");
|
String[] parts = repoFullName.split("/");
|
||||||
final String repoOwner = parts[0];
|
final String repoOwner = parts[0];
|
||||||
final String repoName = parts[1];
|
final String repoName = parts[1];
|
||||||
|
|
||||||
Call<Collaborators> call;
|
Call<Collaborators> call = RetrofitClient
|
||||||
|
.getApiInterface(context)
|
||||||
call = RetrofitClient
|
.deleteCollaborator(Authorization.get(context), repoOwner, repoName, userName);
|
||||||
.getInstance(instanceUrl, context)
|
|
||||||
.getApiInterface()
|
|
||||||
.deleteCollaborator(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName, userName);
|
|
||||||
|
|
||||||
call.enqueue(new Callback<Collaborators>() {
|
call.enqueue(new Callback<Collaborators>() {
|
||||||
|
|
||||||
@ -54,7 +49,7 @@ public class CollaboratorActions {
|
|||||||
//Log.i("addCollaboratorSearch", addCollaboratorSearch.getText().toString());
|
//Log.i("addCollaboratorSearch", addCollaboratorSearch.getText().toString());
|
||||||
//tinyDb.putBoolean("updateDataSet", true);
|
//tinyDb.putBoolean("updateDataSet", true);
|
||||||
//AddCollaboratorToRepositoryActivity usersSearchData = new AddCollaboratorToRepositoryActivity();
|
//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) {
|
public static void addCollaborator(final Context context, String permission, String userName) {
|
||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(context);
|
final TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
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("/");
|
String[] parts = repoFullName.split("/");
|
||||||
final String repoOwner = parts[0];
|
final String repoOwner = parts[0];
|
||||||
final String repoName = parts[1];
|
final String repoName = parts[1];
|
||||||
|
|
||||||
Permission permissionString = new Permission(permission);
|
Permission permissionString = new Permission(permission);
|
||||||
Call<Permission> call;
|
|
||||||
|
|
||||||
call = RetrofitClient
|
Call<Permission> call = RetrofitClient
|
||||||
.getInstance(instanceUrl, context)
|
.getApiInterface(context)
|
||||||
.getApiInterface()
|
.addCollaborator(Authorization.get(context), repoOwner, repoName, userName, permissionString);
|
||||||
.addCollaborator(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName, userName, permissionString);
|
|
||||||
|
|
||||||
call.enqueue(new Callback<Permission>() {
|
call.enqueue(new Callback<Permission>() {
|
||||||
|
|
||||||
@ -122,7 +113,7 @@ public class CollaboratorActions {
|
|||||||
Toasty.success(context, context.getString(R.string.addCollaboratorToastText));
|
Toasty.success(context, context.getString(R.string.addCollaboratorToastText));
|
||||||
((AddCollaboratorToRepositoryActivity)context).finish();
|
((AddCollaboratorToRepositoryActivity)context).finish();
|
||||||
//AddCollaboratorToRepositoryActivity usersSearchData = new AddCollaboratorToRepositoryActivity();
|
//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) {
|
public static ActionResult<List<Collaborators>> getCollaborators(Context context) {
|
||||||
|
|
||||||
ActionResult<List<Collaborators>> actionResult = new ActionResult<>();
|
ActionResult<List<Collaborators>> actionResult = new ActionResult<>();
|
||||||
TinyDB tinyDb = new TinyDB(context);
|
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
|
|
||||||
String instanceUrl = tinyDb.getString("instanceUrl");
|
|
||||||
String loginUid = tinyDb.getString("loginUid");
|
|
||||||
String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
|
||||||
|
|
||||||
String repoFullName = tinyDb.getString("repoFullName");
|
String repoFullName = tinyDb.getString("repoFullName");
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
@ -176,9 +163,8 @@ public class CollaboratorActions {
|
|||||||
String repoName = parts[1];
|
String repoName = parts[1];
|
||||||
|
|
||||||
Call<List<Collaborators>> call = RetrofitClient
|
Call<List<Collaborators>> call = RetrofitClient
|
||||||
.getInstance(instanceUrl, context)
|
.getApiInterface(context)
|
||||||
.getApiInterface()
|
.getCollaborators(Authorization.get(context), repoOwner, repoName);
|
||||||
.getCollaborators(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName);
|
|
||||||
|
|
||||||
call.enqueue(new Callback<List<Collaborators>>() {
|
call.enqueue(new Callback<List<Collaborators>>() {
|
||||||
|
|
||||||
|
@ -5,7 +5,6 @@ import androidx.annotation.NonNull;
|
|||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.database.api.DraftsApi;
|
|
||||||
import org.mian.gitnex.helpers.AlertDialogs;
|
import org.mian.gitnex.helpers.AlertDialogs;
|
||||||
import org.mian.gitnex.helpers.Authorization;
|
import org.mian.gitnex.helpers.Authorization;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
import org.mian.gitnex.helpers.TinyDB;
|
||||||
@ -15,6 +14,7 @@ import org.mian.gitnex.models.Issues;
|
|||||||
import org.mian.gitnex.models.UpdateIssueState;
|
import org.mian.gitnex.models.UpdateIssueState;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
|
import retrofit2.Response;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Author M M Arif
|
* Author M M Arif
|
||||||
@ -22,85 +22,72 @@ import retrofit2.Callback;
|
|||||||
|
|
||||||
public class IssueActions {
|
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 repoFullName = tinyDb.getString("repoFullName");
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
final String repoOwner = parts[0];
|
|
||||||
final String repoName = parts[1];
|
|
||||||
|
|
||||||
IssueComments commentBodyJson = new IssueComments(commentBody);
|
String repoOwner = parts[0];
|
||||||
Call<IssueComments> call;
|
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>() {
|
call.enqueue(new Callback<IssueComments>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<IssueComments> call, @NonNull retrofit2.Response<IssueComments> response) {
|
public void onResponse(@NonNull Call<IssueComments> call, @NonNull retrofit2.Response<IssueComments> response) {
|
||||||
|
|
||||||
if(response.isSuccessful()) {
|
switch(response.code()) {
|
||||||
if(response.code() == 200) {
|
|
||||||
|
|
||||||
tinyDb.putBoolean("commentEdited", true);
|
case 200:
|
||||||
Toasty.info(ctx, ctx.getString(R.string.editCommentUpdatedText));
|
actionResult.finish(ActionResult.Status.SUCCESS);
|
||||||
|
break;
|
||||||
|
|
||||||
DraftsApi draftsApi = new DraftsApi(ctx);
|
case 401:
|
||||||
draftsApi.deleteSingleDraft((int) draftIdOnCreate);
|
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;
|
||||||
|
|
||||||
}
|
default:
|
||||||
}
|
actionResult.finish(ActionResult.Status.FAILED, response);
|
||||||
else if(response.code() == 401) {
|
break;
|
||||||
|
|
||||||
AlertDialogs.authorizationTokenRevokedDialog(ctx, ctx.getResources().getString(R.string.alertDialogTokenRevokedTitle), ctx.getResources().getString(R.string.alertDialogTokenRevokedMessage), ctx.getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton), ctx.getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else 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
|
@Override
|
||||||
public void onFailure(@NonNull Call<IssueComments> call, @NonNull Throwable t) {
|
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) {
|
public static void closeReopenIssue(final Context ctx, final int issueIndex, final String issueState) {
|
||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(ctx);
|
final TinyDB tinyDb = TinyDB.getInstance(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 repoFullName = tinyDb.getString("repoFullName");
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
|
|
||||||
final String repoOwner = parts[0];
|
final String repoOwner = parts[0];
|
||||||
final String repoName = parts[1];
|
final String repoName = parts[1];
|
||||||
|
|
||||||
UpdateIssueState issueStatJson = new UpdateIssueState(issueState);
|
UpdateIssueState issueStatJson = new UpdateIssueState(issueState);
|
||||||
Call<JsonElement> call;
|
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>() {
|
call.enqueue(new Callback<JsonElement>() {
|
||||||
|
|
||||||
@ -162,20 +149,23 @@ public class IssueActions {
|
|||||||
|
|
||||||
public static void subscribe(final Context ctx) {
|
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("/");
|
String[] repoFullName = tinyDB.getString("repoFullName").split("/");
|
||||||
|
|
||||||
if(repoFullName.length != 2) {
|
if(repoFullName.length != 2) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final String userLogin = tinyDB.getString("userLogin");
|
final String userLogin = tinyDB.getString("userLogin");
|
||||||
final String token = "token " + tinyDB.getString(tinyDB.getString("loginUid") + "-token");
|
final String token = "token " + tinyDB.getString(tinyDB.getString("loginUid") + "-token");
|
||||||
final int issueNr = Integer.parseInt(tinyDB.getString("issueNumber"));
|
final int issueNr = Integer.parseInt(tinyDB.getString("issueNumber"));
|
||||||
|
|
||||||
Call<Void> call;
|
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>() {
|
call.enqueue(new Callback<Void>() {
|
||||||
|
|
||||||
@ -222,9 +212,8 @@ public class IssueActions {
|
|||||||
|
|
||||||
public static void unsubscribe(final Context ctx) {
|
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("/");
|
String[] repoFullName = tinyDB.getString("repoFullName").split("/");
|
||||||
if(repoFullName.length != 2) {
|
if(repoFullName.length != 2) {
|
||||||
return;
|
return;
|
||||||
@ -235,7 +224,7 @@ public class IssueActions {
|
|||||||
|
|
||||||
Call<Void> call;
|
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>() {
|
call.enqueue(new Callback<Void>() {
|
||||||
|
|
||||||
@ -282,11 +271,8 @@ public class IssueActions {
|
|||||||
public static ActionResult<ActionResult.None> reply(Context context, String comment, int issueIndex) {
|
public static ActionResult<ActionResult.None> reply(Context context, String comment, int issueIndex) {
|
||||||
|
|
||||||
ActionResult<ActionResult.None> actionResult = new ActionResult<>();
|
ActionResult<ActionResult.None> actionResult = new ActionResult<>();
|
||||||
TinyDB tinyDb = new TinyDB(context);
|
|
||||||
|
|
||||||
String instanceUrl = tinyDb.getString("instanceUrl");
|
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
String loginUid = tinyDb.getString("loginUid");
|
|
||||||
String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
|
||||||
|
|
||||||
String repoFullName = tinyDb.getString("repoFullName");
|
String repoFullName = tinyDb.getString("repoFullName");
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
@ -296,9 +282,8 @@ public class IssueActions {
|
|||||||
Issues issueComment = new Issues(comment);
|
Issues issueComment = new Issues(comment);
|
||||||
|
|
||||||
Call<Issues> call = RetrofitClient
|
Call<Issues> call = RetrofitClient
|
||||||
.getInstance(instanceUrl, context)
|
.getApiInterface(context)
|
||||||
.getApiInterface()
|
.replyCommentToIssue(Authorization.get(context), repoOwner, repoName, issueIndex, issueComment);
|
||||||
.replyCommentToIssue(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName, issueIndex, issueComment);
|
|
||||||
|
|
||||||
call.enqueue(new Callback<Issues>() {
|
call.enqueue(new Callback<Issues>() {
|
||||||
|
|
||||||
|
@ -22,12 +22,11 @@ import retrofit2.Callback;
|
|||||||
|
|
||||||
public class LabelsActions {
|
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
|
Call<List<Labels>> callSingleIssueLabels = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
.getIssueLabels(Authorization.get(ctx), repoOwner, repoName, issueIndex);
|
||||||
.getIssueLabels(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, issueIndex);
|
|
||||||
|
|
||||||
callSingleIssueLabels.enqueue(new Callback<List<Labels>>() {
|
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
|
Call<List<Labels>> call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
.getlabels(Authorization.get(ctx), repoOwner, repoName);
|
||||||
.getlabels(instanceToken, repoOwner, repoName);
|
|
||||||
|
|
||||||
call.enqueue(new Callback<List<Labels>>() {
|
call.enqueue(new Callback<List<Labels>>() {
|
||||||
|
|
||||||
|
@ -23,9 +23,8 @@ public class MilestoneActions {
|
|||||||
|
|
||||||
public static void closeMilestone(final Context ctx, int milestoneId_) {
|
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 repoFullName = tinyDB.getString("repoFullName");
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
final String repoOwner = parts[0];
|
final String repoOwner = parts[0];
|
||||||
@ -37,8 +36,7 @@ public class MilestoneActions {
|
|||||||
Call<JsonElement> call;
|
Call<JsonElement> call;
|
||||||
|
|
||||||
call = RetrofitClient
|
call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
|
||||||
.closeReopenMilestone(token, repoOwner, repoName, milestoneId_, milestoneStateJson);
|
.closeReopenMilestone(token, repoOwner, repoName, milestoneId_, milestoneStateJson);
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonElement>() {
|
call.enqueue(new Callback<JsonElement>() {
|
||||||
@ -81,9 +79,8 @@ public class MilestoneActions {
|
|||||||
|
|
||||||
public static void openMilestone(final Context ctx, int milestoneId_) {
|
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 repoFullName = tinyDB.getString("repoFullName");
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
final String repoOwner = parts[0];
|
final String repoOwner = parts[0];
|
||||||
@ -95,8 +92,7 @@ public class MilestoneActions {
|
|||||||
Call<JsonElement> call;
|
Call<JsonElement> call;
|
||||||
|
|
||||||
call = RetrofitClient
|
call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
|
||||||
.closeReopenMilestone(token, repoOwner, repoName, milestoneId_, milestoneStateJson);
|
.closeReopenMilestone(token, repoOwner, repoName, milestoneId_, milestoneStateJson);
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonElement>() {
|
call.enqueue(new Callback<JsonElement>() {
|
||||||
|
@ -20,24 +20,22 @@ public class NotificationsActions {
|
|||||||
|
|
||||||
private TinyDB tinyDB;
|
private TinyDB tinyDB;
|
||||||
private Context context;
|
private Context context;
|
||||||
private String instanceUrl;
|
|
||||||
private String instanceToken;
|
private String instanceToken;
|
||||||
|
|
||||||
public NotificationsActions(Context context) {
|
public NotificationsActions(Context context) {
|
||||||
|
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.tinyDB = new TinyDB(context);
|
this.tinyDB = TinyDB.getInstance(context);
|
||||||
|
|
||||||
String loginUid = tinyDB.getString("loginUid");
|
String loginUid = tinyDB.getString("loginUid");
|
||||||
|
|
||||||
instanceUrl = tinyDB.getString("instanceUrl");
|
|
||||||
instanceToken = "token " + tinyDB.getString(loginUid + "-token");
|
instanceToken = "token " + tinyDB.getString(loginUid + "-token");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNotificationStatus(NotificationThread notificationThread, NotificationStatus notificationStatus) throws IOException {
|
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());
|
.markNotificationThreadAsRead(instanceToken, notificationThread.getId(), notificationStatus.name());
|
||||||
|
|
||||||
if(!call.execute().isSuccessful()) {
|
if(!call.execute().isSuccessful()) {
|
||||||
@ -48,7 +46,7 @@ public class NotificationsActions {
|
|||||||
|
|
||||||
public boolean setAllNotificationsRead(Date date) throws IOException {
|
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,
|
.markNotificationThreadsAsRead(instanceToken, AppUtil.getTimestampFromDate(context, date), true,
|
||||||
new String[]{"unread", "pinned"}, "read");
|
new String[]{"unread", "pinned"}, "read");
|
||||||
|
|
||||||
|
@ -21,10 +21,8 @@ public class RepositoryActions {
|
|||||||
|
|
||||||
public static void starRepository(final Context context) {
|
public static void starRepository(final Context context) {
|
||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(context);
|
final TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
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("/");
|
String[] parts = repoFullName.split("/");
|
||||||
final String repoOwner = parts[0];
|
final String repoOwner = parts[0];
|
||||||
@ -33,9 +31,8 @@ public class RepositoryActions {
|
|||||||
Call<JsonElement> call;
|
Call<JsonElement> call;
|
||||||
|
|
||||||
call = RetrofitClient
|
call = RetrofitClient
|
||||||
.getInstance(instanceUrl, context)
|
.getApiInterface(context)
|
||||||
.getApiInterface()
|
.starRepository(Authorization.get(context), repoOwner, repoName);
|
||||||
.starRepository(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName);
|
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonElement>() {
|
call.enqueue(new Callback<JsonElement>() {
|
||||||
|
|
||||||
@ -86,10 +83,8 @@ public class RepositoryActions {
|
|||||||
|
|
||||||
public static void unStarRepository(final Context context) {
|
public static void unStarRepository(final Context context) {
|
||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(context);
|
final TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
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("/");
|
String[] parts = repoFullName.split("/");
|
||||||
final String repoOwner = parts[0];
|
final String repoOwner = parts[0];
|
||||||
@ -98,9 +93,8 @@ public class RepositoryActions {
|
|||||||
Call<JsonElement> call;
|
Call<JsonElement> call;
|
||||||
|
|
||||||
call = RetrofitClient
|
call = RetrofitClient
|
||||||
.getInstance(instanceUrl, context)
|
.getApiInterface(context)
|
||||||
.getApiInterface()
|
.unStarRepository(Authorization.get(context), repoOwner, repoName);
|
||||||
.unStarRepository(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName);
|
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonElement>() {
|
call.enqueue(new Callback<JsonElement>() {
|
||||||
|
|
||||||
@ -151,10 +145,8 @@ public class RepositoryActions {
|
|||||||
|
|
||||||
public static void watchRepository(final Context context) {
|
public static void watchRepository(final Context context) {
|
||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(context);
|
final TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
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("/");
|
String[] parts = repoFullName.split("/");
|
||||||
final String repoOwner = parts[0];
|
final String repoOwner = parts[0];
|
||||||
@ -163,9 +155,8 @@ public class RepositoryActions {
|
|||||||
Call<JsonElement> call;
|
Call<JsonElement> call;
|
||||||
|
|
||||||
call = RetrofitClient
|
call = RetrofitClient
|
||||||
.getInstance(instanceUrl, context)
|
.getApiInterface(context)
|
||||||
.getApiInterface()
|
.watchRepository(Authorization.get(context), repoOwner, repoName);
|
||||||
.watchRepository(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName);
|
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonElement>() {
|
call.enqueue(new Callback<JsonElement>() {
|
||||||
|
|
||||||
@ -216,10 +207,8 @@ public class RepositoryActions {
|
|||||||
|
|
||||||
public static void unWatchRepository(final Context context) {
|
public static void unWatchRepository(final Context context) {
|
||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(context);
|
final TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
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("/");
|
String[] parts = repoFullName.split("/");
|
||||||
final String repoOwner = parts[0];
|
final String repoOwner = parts[0];
|
||||||
@ -228,9 +217,8 @@ public class RepositoryActions {
|
|||||||
Call<JsonElement> call;
|
Call<JsonElement> call;
|
||||||
|
|
||||||
call = RetrofitClient
|
call = RetrofitClient
|
||||||
.getInstance(instanceUrl, context)
|
.getApiInterface(context)
|
||||||
.getApiInterface()
|
.unWatchRepository(Authorization.get(context), repoOwner, repoName);
|
||||||
.unWatchRepository(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName);
|
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonElement>() {
|
call.enqueue(new Callback<JsonElement>() {
|
||||||
|
|
||||||
|
@ -21,17 +21,13 @@ public class TeamActions {
|
|||||||
|
|
||||||
public static void removeTeamMember(final Context context, String userName, int teamId) {
|
public static void removeTeamMember(final Context context, String userName, int teamId) {
|
||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(context);
|
final TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
|
||||||
final String loginUid = tinyDb.getString("loginUid");
|
|
||||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
|
||||||
|
|
||||||
Call<JsonElement> call;
|
Call<JsonElement> call;
|
||||||
|
|
||||||
call = RetrofitClient
|
call = RetrofitClient
|
||||||
.getInstance(instanceUrl, context)
|
.getApiInterface(context)
|
||||||
.getApiInterface()
|
.removeTeamMember(Authorization.get(context), teamId, userName);
|
||||||
.removeTeamMember(Authorization.returnAuthentication(context, loginUid, instanceToken), teamId, userName);
|
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonElement>() {
|
call.enqueue(new Callback<JsonElement>() {
|
||||||
|
|
||||||
@ -87,17 +83,11 @@ public class TeamActions {
|
|||||||
|
|
||||||
public static void addTeamMember(final Context context, String userName, int teamId) {
|
public static void addTeamMember(final Context context, String userName, int teamId) {
|
||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(context);
|
final TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
|
||||||
final String loginUid = tinyDb.getString("loginUid");
|
|
||||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
|
||||||
|
|
||||||
Call<JsonElement> call;
|
Call<JsonElement> call = RetrofitClient
|
||||||
|
.getApiInterface(context)
|
||||||
call = RetrofitClient
|
.addTeamMember(Authorization.get(context), teamId, userName);
|
||||||
.getInstance(instanceUrl, context)
|
|
||||||
.getApiInterface()
|
|
||||||
.addTeamMember(Authorization.returnAuthentication(context, loginUid, instanceToken), teamId, userName);
|
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonElement>() {
|
call.enqueue(new Callback<JsonElement>() {
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@ import org.mian.gitnex.R;
|
|||||||
import org.mian.gitnex.adapters.UserSearchAdapter;
|
import org.mian.gitnex.adapters.UserSearchAdapter;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.helpers.Authorization;
|
import org.mian.gitnex.helpers.Authorization;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
|
||||||
import org.mian.gitnex.models.UserInfo;
|
import org.mian.gitnex.models.UserInfo;
|
||||||
import org.mian.gitnex.models.UserSearch;
|
import org.mian.gitnex.models.UserSearch;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -32,8 +31,6 @@ import retrofit2.Response;
|
|||||||
public class AddCollaboratorToRepositoryActivity extends BaseActivity {
|
public class AddCollaboratorToRepositoryActivity extends BaseActivity {
|
||||||
|
|
||||||
private View.OnClickListener onClickListener;
|
private View.OnClickListener onClickListener;
|
||||||
final Context ctx = this;
|
|
||||||
private Context appCtx;
|
|
||||||
private TextView addCollaboratorSearch;
|
private TextView addCollaboratorSearch;
|
||||||
private TextView noData;
|
private TextView noData;
|
||||||
private ProgressBar mProgressBar;
|
private ProgressBar mProgressBar;
|
||||||
@ -49,17 +46,9 @@ public class AddCollaboratorToRepositoryActivity extends BaseActivity {
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
|
|
||||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
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);
|
ImageView closeActivity = findViewById(R.id.close);
|
||||||
addCollaboratorSearch = findViewById(R.id.addCollaboratorSearch);
|
addCollaboratorSearch = findViewById(R.id.addCollaboratorSearch);
|
||||||
mRecyclerView = findViewById(R.id.recyclerViewUserSearch);
|
mRecyclerView = findViewById(R.id.recyclerViewUserSearch);
|
||||||
@ -80,7 +69,7 @@ public class AddCollaboratorToRepositoryActivity extends BaseActivity {
|
|||||||
if(!addCollaboratorSearch.getText().toString().equals("")) {
|
if(!addCollaboratorSearch.getText().toString().equals("")) {
|
||||||
|
|
||||||
mProgressBar.setVisibility(View.VISIBLE);
|
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
|
Call<UserSearch> call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(appCtx)
|
||||||
.getApiInterface()
|
.getUserBySearch(Authorization.get(ctx), searchKeyword, 10);
|
||||||
.getUserBySearch(Authorization.returnAuthentication(ctx, loginUid, token), searchKeyword, 10);
|
|
||||||
|
|
||||||
call.enqueue(new Callback<UserSearch>() {
|
call.enqueue(new Callback<UserSearch>() {
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package org.mian.gitnex.activities;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.os.Bundle;
|
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.databinding.ActivityAddNewAccountBinding;
|
||||||
import org.mian.gitnex.helpers.AppUtil;
|
import org.mian.gitnex.helpers.AppUtil;
|
||||||
import org.mian.gitnex.helpers.PathsHelper;
|
import org.mian.gitnex.helpers.PathsHelper;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
import org.mian.gitnex.helpers.UrlHelper;
|
import org.mian.gitnex.helpers.UrlHelper;
|
||||||
import org.mian.gitnex.helpers.Version;
|
import org.mian.gitnex.helpers.Version;
|
||||||
@ -32,10 +30,6 @@ import retrofit2.Callback;
|
|||||||
|
|
||||||
public class AddNewAccountActivity extends BaseActivity {
|
public class AddNewAccountActivity extends BaseActivity {
|
||||||
|
|
||||||
final Context ctx = this;
|
|
||||||
private Context appCtx;
|
|
||||||
private TinyDB tinyDB;
|
|
||||||
|
|
||||||
private View.OnClickListener onClickListener;
|
private View.OnClickListener onClickListener;
|
||||||
private ActivityAddNewAccountBinding viewBinding;
|
private ActivityAddNewAccountBinding viewBinding;
|
||||||
|
|
||||||
@ -52,8 +46,6 @@ public class AddNewAccountActivity extends BaseActivity {
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
tinyDB = new TinyDB(appCtx);
|
|
||||||
|
|
||||||
viewBinding = ActivityAddNewAccountBinding.inflate(getLayoutInflater());
|
viewBinding = ActivityAddNewAccountBinding.inflate(getLayoutInflater());
|
||||||
View view = viewBinding.getRoot();
|
View view = viewBinding.getRoot();
|
||||||
@ -131,7 +123,7 @@ public class AddNewAccountActivity extends BaseActivity {
|
|||||||
|
|
||||||
Call<GiteaVersion> callVersion;
|
Call<GiteaVersion> callVersion;
|
||||||
|
|
||||||
callVersion = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().getGiteaVersionWithToken("token " + loginToken);
|
callVersion = RetrofitClient.getApiInterface(ctx).getGiteaVersionWithToken("token " + loginToken);
|
||||||
|
|
||||||
callVersion.enqueue(new Callback<GiteaVersion>() {
|
callVersion.enqueue(new Callback<GiteaVersion>() {
|
||||||
|
|
||||||
@ -205,7 +197,7 @@ public class AddNewAccountActivity extends BaseActivity {
|
|||||||
|
|
||||||
private void setupNewAccountWithToken(String instanceUrl, final String loginToken) {
|
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>() {
|
call.enqueue(new Callback<UserInfo>() {
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@ import org.mian.gitnex.R;
|
|||||||
import org.mian.gitnex.adapters.UserSearchForTeamMemberAdapter;
|
import org.mian.gitnex.adapters.UserSearchForTeamMemberAdapter;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.helpers.Authorization;
|
import org.mian.gitnex.helpers.Authorization;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
|
||||||
import org.mian.gitnex.models.UserInfo;
|
import org.mian.gitnex.models.UserInfo;
|
||||||
import org.mian.gitnex.models.UserSearch;
|
import org.mian.gitnex.models.UserSearch;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -35,8 +34,6 @@ import retrofit2.Response;
|
|||||||
public class AddNewTeamMemberActivity extends BaseActivity {
|
public class AddNewTeamMemberActivity extends BaseActivity {
|
||||||
|
|
||||||
private View.OnClickListener onClickListener;
|
private View.OnClickListener onClickListener;
|
||||||
final Context ctx = this;
|
|
||||||
private Context appCtx;
|
|
||||||
private TextView addNewTeamMember;
|
private TextView addNewTeamMember;
|
||||||
private TextView noData;
|
private TextView noData;
|
||||||
private ProgressBar mProgressBar;
|
private ProgressBar mProgressBar;
|
||||||
@ -56,17 +53,9 @@ public class AddNewTeamMemberActivity extends BaseActivity {
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
|
|
||||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
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);
|
ImageView closeActivity = findViewById(R.id.close);
|
||||||
addNewTeamMember = findViewById(R.id.addNewTeamMember);
|
addNewTeamMember = findViewById(R.id.addNewTeamMember);
|
||||||
mRecyclerView = findViewById(R.id.recyclerViewUserSearch);
|
mRecyclerView = findViewById(R.id.recyclerViewUserSearch);
|
||||||
@ -105,7 +94,7 @@ public class AddNewTeamMemberActivity extends BaseActivity {
|
|||||||
if(!addNewTeamMember.getText().toString().equals("") && addNewTeamMember.getText().toString().length() > 1) {
|
if(!addNewTeamMember.getText().toString().equals("") && addNewTeamMember.getText().toString().length() > 1) {
|
||||||
|
|
||||||
adapter = new UserSearchForTeamMemberAdapter(dataList, ctx, Integer.parseInt(teamId));
|
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);
|
mProgressBar.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
@ -24,7 +24,6 @@ import org.mian.gitnex.adapters.AdminGetUsersAdapter;
|
|||||||
import org.mian.gitnex.fragments.BottomSheetAdminUsersFragment;
|
import org.mian.gitnex.fragments.BottomSheetAdminUsersFragment;
|
||||||
import org.mian.gitnex.helpers.AppUtil;
|
import org.mian.gitnex.helpers.AppUtil;
|
||||||
import org.mian.gitnex.helpers.Authorization;
|
import org.mian.gitnex.helpers.Authorization;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
|
||||||
import org.mian.gitnex.viewmodels.AdminGetUsersViewModel;
|
import org.mian.gitnex.viewmodels.AdminGetUsersViewModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -34,8 +33,6 @@ import org.mian.gitnex.viewmodels.AdminGetUsersViewModel;
|
|||||||
public class AdminGetUsersActivity extends BaseActivity implements BottomSheetAdminUsersFragment.BottomSheetListener {
|
public class AdminGetUsersActivity extends BaseActivity implements BottomSheetAdminUsersFragment.BottomSheetListener {
|
||||||
|
|
||||||
private View.OnClickListener onClickListener;
|
private View.OnClickListener onClickListener;
|
||||||
final Context ctx = this;
|
|
||||||
private Context appCtx;
|
|
||||||
private AdminGetUsersAdapter adapter;
|
private AdminGetUsersAdapter adapter;
|
||||||
private RecyclerView mRecyclerView;
|
private RecyclerView mRecyclerView;
|
||||||
private TextView noDataUsers;
|
private TextView noDataUsers;
|
||||||
@ -50,12 +47,6 @@ public class AdminGetUsersActivity extends BaseActivity implements BottomSheetAd
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(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);
|
ImageView closeActivity = findViewById(R.id.close);
|
||||||
noDataUsers = findViewById(R.id.noDataUsers);
|
noDataUsers = findViewById(R.id.noDataUsers);
|
||||||
@ -79,19 +70,19 @@ public class AdminGetUsersActivity extends BaseActivity implements BottomSheetAd
|
|||||||
swipeRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
swipeRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||||
|
|
||||||
swipeRefresh.setRefreshing(false);
|
swipeRefresh.setRefreshing(false);
|
||||||
AdminGetUsersViewModel.loadUsersList(ctx, instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken));
|
AdminGetUsersViewModel.loadUsersList(ctx, Authorization.get(ctx));
|
||||||
|
|
||||||
}, 500));
|
}, 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);
|
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);
|
adapter = new AdminGetUsersAdapter(ctx, usersListMain);
|
||||||
if(adapter.getItemCount() > 0) {
|
if(adapter.getItemCount() > 0) {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.mian.gitnex.activities;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
@ -25,6 +26,7 @@ import static org.acra.ReportField.STACK_TRACE;
|
|||||||
* Author M M Arif
|
* Author M M Arif
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@SuppressLint("NonConstantResourceId")
|
||||||
@AcraNotification(resIcon = R.drawable.gitnex_transparent,
|
@AcraNotification(resIcon = R.drawable.gitnex_transparent,
|
||||||
resTitle = R.string.crashTitle,
|
resTitle = R.string.crashTitle,
|
||||||
resChannelName = R.string.setCrashReports,
|
resChannelName = R.string.setCrashReports,
|
||||||
@ -33,120 +35,127 @@ import static org.acra.ReportField.STACK_TRACE;
|
|||||||
|
|
||||||
public abstract class BaseActivity extends AppCompatActivity {
|
public abstract class BaseActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
protected TinyDB tinyDB;
|
||||||
|
|
||||||
|
protected Context ctx = this;
|
||||||
|
protected Context appCtx;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
Context appCtx = getApplicationContext();
|
this.appCtx = getApplicationContext();
|
||||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
this.tinyDB = TinyDB.getInstance(appCtx);
|
||||||
|
|
||||||
switch(tinyDb.getInt("themeId")) {
|
switch(tinyDB.getInt("themeId")) {
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
|
tinyDB.putString("currentTheme", "light");
|
||||||
setTheme(R.style.AppThemeLight);
|
setTheme(R.style.AppThemeLight);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
|
|
||||||
if(TimeHelper.timeBetweenHours(18, 6)) { // 6pm to 6am
|
if(TimeHelper.timeBetweenHours(18, 6)) { // 6pm to 6am
|
||||||
|
tinyDB.putString("currentTheme", "dark");
|
||||||
setTheme(R.style.AppTheme);
|
setTheme(R.style.AppTheme);
|
||||||
}
|
} else {
|
||||||
else {
|
tinyDB.putString("currentTheme", "light");
|
||||||
|
|
||||||
setTheme(R.style.AppThemeLight);
|
setTheme(R.style.AppThemeLight);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 3:
|
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
tinyDB.putString("currentTheme", "light");
|
||||||
setTheme(R.style.AppThemeRetro);
|
setTheme(R.style.AppThemeRetro);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
|
|
||||||
if(TimeHelper.timeBetweenHours(18, 6)) { // 6pm to 6am
|
if(TimeHelper.timeBetweenHours(18, 6)) { // 6pm to 6am
|
||||||
|
tinyDB.putString("currentTheme", "dark");
|
||||||
setTheme(R.style.AppTheme);
|
setTheme(R.style.AppTheme);
|
||||||
}
|
} else {
|
||||||
else {
|
tinyDB.putString("currentTheme", "light");
|
||||||
|
|
||||||
setTheme(R.style.AppThemeRetro);
|
setTheme(R.style.AppThemeRetro);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
|
|
||||||
|
default:
|
||||||
|
tinyDB.putString("currentTheme", "dark");
|
||||||
setTheme(R.style.AppTheme);
|
setTheme(R.style.AppTheme);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String appLocale = tinyDb.getString("locale");
|
String appLocale = tinyDB.getString("locale");
|
||||||
AppUtil.setAppLocale(getResources(), appLocale);
|
AppUtil.setAppLocale(getResources(), appLocale);
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(getLayoutResourceId());
|
setContentView(getLayoutResourceId());
|
||||||
|
|
||||||
switch(tinyDb.getInt("customFontId", -1)) {
|
// FIXME Performance nightmare
|
||||||
|
switch(tinyDB.getInt("customFontId", -1)) {
|
||||||
|
|
||||||
case 0:
|
case 0:
|
||||||
|
|
||||||
FontsOverride.setDefaultFont(this, "DEFAULT", "fonts/roboto.ttf");
|
FontsOverride.setDefaultFont(this, "DEFAULT", "fonts/roboto.ttf");
|
||||||
FontsOverride.setDefaultFont(this, "MONOSPACE", "fonts/roboto.ttf");
|
FontsOverride.setDefaultFont(this, "MONOSPACE", "fonts/roboto.ttf");
|
||||||
FontsOverride.setDefaultFont(this, "SERIF", "fonts/roboto.ttf");
|
FontsOverride.setDefaultFont(this, "SERIF", "fonts/roboto.ttf");
|
||||||
FontsOverride.setDefaultFont(this, "SANS_SERIF", "fonts/roboto.ttf");
|
FontsOverride.setDefaultFont(this, "SANS_SERIF", "fonts/roboto.ttf");
|
||||||
break;
|
break;
|
||||||
case 2:
|
|
||||||
|
|
||||||
|
case 2:
|
||||||
FontsOverride.setDefaultFont(this, "DEFAULT", "fonts/sourcecodeproregular.ttf");
|
FontsOverride.setDefaultFont(this, "DEFAULT", "fonts/sourcecodeproregular.ttf");
|
||||||
FontsOverride.setDefaultFont(this, "MONOSPACE", "fonts/sourcecodeproregular.ttf");
|
FontsOverride.setDefaultFont(this, "MONOSPACE", "fonts/sourcecodeproregular.ttf");
|
||||||
FontsOverride.setDefaultFont(this, "SERIF", "fonts/sourcecodeproregular.ttf");
|
FontsOverride.setDefaultFont(this, "SERIF", "fonts/sourcecodeproregular.ttf");
|
||||||
FontsOverride.setDefaultFont(this, "SANS_SERIF", "fonts/sourcecodeproregular.ttf");
|
FontsOverride.setDefaultFont(this, "SANS_SERIF", "fonts/sourcecodeproregular.ttf");
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
|
|
||||||
|
default:
|
||||||
FontsOverride.setDefaultFont(this, "DEFAULT", "fonts/manroperegular.ttf");
|
FontsOverride.setDefaultFont(this, "DEFAULT", "fonts/manroperegular.ttf");
|
||||||
FontsOverride.setDefaultFont(this, "MONOSPACE", "fonts/manroperegular.ttf");
|
FontsOverride.setDefaultFont(this, "MONOSPACE", "fonts/manroperegular.ttf");
|
||||||
FontsOverride.setDefaultFont(this, "SERIF", "fonts/manroperegular.ttf");
|
FontsOverride.setDefaultFont(this, "SERIF", "fonts/manroperegular.ttf");
|
||||||
FontsOverride.setDefaultFont(this, "SANS_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);
|
NotificationsMaster.hireWorker(appCtx);
|
||||||
|
|
||||||
// enabling counter badges by default
|
// enabling counter badges by default
|
||||||
if(tinyDb.getString("enableCounterBadgesInit").isEmpty()) {
|
if(tinyDB.getString("enableCounterBadgesInit").isEmpty()) {
|
||||||
|
|
||||||
tinyDb.putBoolean("enableCounterBadges", true);
|
tinyDB.putBoolean("enableCounterBadges", true);
|
||||||
tinyDb.putString("enableCounterBadgesInit", "yes");
|
tinyDB.putString("enableCounterBadgesInit", "yes");
|
||||||
}
|
}
|
||||||
|
|
||||||
// enable crash reports by default
|
// enable crash reports by default
|
||||||
if(tinyDb.getString("crashReportingEnabledInit").isEmpty()) {
|
if(tinyDB.getString("crashReportingEnabledInit").isEmpty()) {
|
||||||
|
|
||||||
tinyDb.putBoolean("crashReportingEnabled", true);
|
tinyDB.putBoolean("crashReportingEnabled", true);
|
||||||
tinyDb.putString("crashReportingEnabledInit", "yes");
|
tinyDB.putString("crashReportingEnabledInit", "yes");
|
||||||
}
|
}
|
||||||
|
|
||||||
// default cache setter
|
// 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
|
// enable comment drafts by default
|
||||||
if(tinyDb.getString("draftsCommentsDeletionEnabledInit").isEmpty()) {
|
if(tinyDB.getString("draftsCommentsDeletionEnabledInit").isEmpty()) {
|
||||||
|
|
||||||
tinyDb.putBoolean("draftsCommentsDeletionEnabled", true);
|
tinyDB.putBoolean("draftsCommentsDeletionEnabled", true);
|
||||||
tinyDb.putString("draftsCommentsDeletionEnabledInit", "yes");
|
tinyDB.putString("draftsCommentsDeletionEnabledInit", "yes");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tinyDb.getBoolean("crashReportingEnabled")) {
|
// FIXME Performance nightmare
|
||||||
|
if (tinyDB.getBoolean("crashReportingEnabled")) {
|
||||||
|
|
||||||
CoreConfigurationBuilder ACRABuilder = new CoreConfigurationBuilder(this);
|
CoreConfigurationBuilder ACRABuilder = new CoreConfigurationBuilder(this);
|
||||||
ACRABuilder.setBuildConfigClass(BuildConfig.class).setReportFormat(StringFormat.KEY_VALUE_LIST);
|
ACRABuilder.setBuildConfigClass(BuildConfig.class).setReportFormat(StringFormat.KEY_VALUE_LIST);
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package org.mian.gitnex.activities;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
@ -21,13 +20,11 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.adapters.CommitsAdapter;
|
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.Authorization;
|
||||||
import org.mian.gitnex.helpers.StaticGlobalVariables;
|
import org.mian.gitnex.helpers.StaticGlobalVariables;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
import org.mian.gitnex.helpers.Version;
|
import org.mian.gitnex.helpers.Version;
|
||||||
import org.mian.gitnex.interfaces.ApiInterface;
|
|
||||||
import org.mian.gitnex.models.Commits;
|
import org.mian.gitnex.models.Commits;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -41,8 +38,6 @@ import retrofit2.Response;
|
|||||||
|
|
||||||
public class CommitsActivity extends BaseActivity {
|
public class CommitsActivity extends BaseActivity {
|
||||||
|
|
||||||
final Context ctx = this;
|
|
||||||
private Context appCtx;
|
|
||||||
private View.OnClickListener onClickListener;
|
private View.OnClickListener onClickListener;
|
||||||
private TextView noData;
|
private TextView noData;
|
||||||
private ProgressBar progressBar;
|
private ProgressBar progressBar;
|
||||||
@ -53,7 +48,6 @@ public class CommitsActivity extends BaseActivity {
|
|||||||
private RecyclerView recyclerView;
|
private RecyclerView recyclerView;
|
||||||
private List<Commits> commitsList;
|
private List<Commits> commitsList;
|
||||||
private CommitsAdapter adapter;
|
private CommitsAdapter adapter;
|
||||||
private ApiInterface api;
|
|
||||||
private ProgressBar progressLoadMore;
|
private ProgressBar progressLoadMore;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -66,15 +60,10 @@ public class CommitsActivity extends BaseActivity {
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(appCtx);
|
String repoFullName = tinyDB.getString("repoFullName");
|
||||||
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("/");
|
String[] parts = repoFullName.split("/");
|
||||||
final String repoOwner = parts[0];
|
final String repoOwner = parts[0];
|
||||||
final String repoName = parts[1];
|
final String repoName = parts[1];
|
||||||
@ -95,7 +84,7 @@ public class CommitsActivity extends BaseActivity {
|
|||||||
closeActivity.setOnClickListener(onClickListener);
|
closeActivity.setOnClickListener(onClickListener);
|
||||||
|
|
||||||
// if gitea is 1.12 or higher use the new limit (resultLimitNewGiteaInstances)
|
// 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;
|
resultLimit = StaticGlobalVariables.resultLimitNewGiteaInstances;
|
||||||
}
|
}
|
||||||
@ -106,7 +95,7 @@ public class CommitsActivity extends BaseActivity {
|
|||||||
swipeRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
swipeRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||||
|
|
||||||
swipeRefresh.setRefreshing(false);
|
swipeRefresh.setRefreshing(false);
|
||||||
loadInitial(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, branchName, resultLimit);
|
loadInitial(Authorization.get(ctx), repoOwner, repoName, branchName, resultLimit);
|
||||||
adapter.notifyDataChanged();
|
adapter.notifyDataChanged();
|
||||||
}, 200));
|
}, 200));
|
||||||
|
|
||||||
@ -116,7 +105,7 @@ public class CommitsActivity extends BaseActivity {
|
|||||||
if(commitsList.size() == resultLimit || pageSize == resultLimit) {
|
if(commitsList.size() == resultLimit || pageSize == resultLimit) {
|
||||||
|
|
||||||
int page = (commitsList.size() + resultLimit) / 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.setLayoutManager(new LinearLayoutManager(ctx));
|
||||||
recyclerView.setAdapter(adapter);
|
recyclerView.setAdapter(adapter);
|
||||||
|
|
||||||
api = AppApiService.createService(ApiInterface.class, instanceUrl, ctx);
|
loadInitial(Authorization.get(ctx), repoOwner, repoName, branchName, resultLimit);
|
||||||
loadInitial(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, branchName, resultLimit);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadInitial(String token, String repoOwner, String repoName, String branchName, int 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>>() {
|
call.enqueue(new Callback<List<Commits>>() {
|
||||||
|
|
||||||
@ -180,7 +168,7 @@ public class CommitsActivity extends BaseActivity {
|
|||||||
|
|
||||||
progressLoadMore.setVisibility(View.VISIBLE);
|
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>>() {
|
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.AlertDialogs;
|
||||||
import org.mian.gitnex.helpers.AppUtil;
|
import org.mian.gitnex.helpers.AppUtil;
|
||||||
import org.mian.gitnex.helpers.Authorization;
|
import org.mian.gitnex.helpers.Authorization;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
import org.mian.gitnex.models.Branches;
|
import org.mian.gitnex.models.Branches;
|
||||||
import org.mian.gitnex.models.DeleteFile;
|
import org.mian.gitnex.models.DeleteFile;
|
||||||
@ -49,13 +48,9 @@ public class CreateFileActivity extends BaseActivity {
|
|||||||
private String filePath;
|
private String filePath;
|
||||||
private String fileSha;
|
private String fileSha;
|
||||||
private int fileAction = 0; // 0 = create, 1 = delete, 2 = edit
|
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<>();
|
List<Branches> branchesList = new ArrayList<>();
|
||||||
|
|
||||||
private String instanceUrl;
|
|
||||||
private String loginUid;
|
private String loginUid;
|
||||||
private String repoOwner;
|
private String repoOwner;
|
||||||
private String repoName;
|
private String repoName;
|
||||||
@ -73,20 +68,17 @@ public class CreateFileActivity extends BaseActivity {
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
tinyDb = new TinyDB(appCtx);
|
|
||||||
|
|
||||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||||
|
|
||||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
|
|
||||||
instanceUrl = tinyDb.getString("instanceUrl");
|
loginUid = tinyDB.getString("loginUid");
|
||||||
loginUid = tinyDb.getString("loginUid");
|
String repoFullName = tinyDB.getString("repoFullName");
|
||||||
String repoFullName = tinyDb.getString("repoFullName");
|
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
repoOwner = parts[0];
|
repoOwner = parts[0];
|
||||||
repoName = parts[1];
|
repoName = parts[1];
|
||||||
instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
instanceToken = "token " + tinyDB.getString(loginUid + "-token");
|
||||||
|
|
||||||
closeActivity = findViewById(R.id.close);
|
closeActivity = findViewById(R.id.close);
|
||||||
newFileName = findViewById(R.id.newFileName);
|
newFileName = findViewById(R.id.newFileName);
|
||||||
@ -157,7 +149,7 @@ public class CreateFileActivity extends BaseActivity {
|
|||||||
closeActivity.setOnClickListener(onClickListener);
|
closeActivity.setOnClickListener(onClickListener);
|
||||||
|
|
||||||
newFileBranchesSpinner = findViewById(R.id.newFileBranchesSpinner);
|
newFileBranchesSpinner = findViewById(R.id.newFileBranchesSpinner);
|
||||||
getBranches(instanceUrl, instanceToken, repoOwner, repoName, loginUid);
|
getBranches(instanceToken, repoOwner, repoName, loginUid);
|
||||||
|
|
||||||
disableProcessButton();
|
disableProcessButton();
|
||||||
|
|
||||||
@ -224,17 +216,17 @@ public class CreateFileActivity extends BaseActivity {
|
|||||||
|
|
||||||
if(fileAction == 1) {
|
if(fileAction == 1) {
|
||||||
|
|
||||||
deleteFile(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, filePath,
|
deleteFile(Authorization.get(ctx), repoOwner, repoName, filePath,
|
||||||
newFileBranchName_, newFileCommitMessage_, selectedBranch, fileSha);
|
newFileBranchName_, newFileCommitMessage_, selectedBranch, fileSha);
|
||||||
}
|
}
|
||||||
else if(fileAction == 2) {
|
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);
|
appUtil.encodeBase64(newFileContent_), newFileBranchName_, newFileCommitMessage_, selectedBranch, fileSha);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
createNewFile(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, newFileName_,
|
createNewFile(Authorization.get(ctx), repoOwner, repoName, newFileName_,
|
||||||
appUtil.encodeBase64(newFileContent_), newFileBranchName_, newFileCommitMessage_, selectedBranch);
|
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;
|
NewFile createNewFileJsonStr;
|
||||||
if(currentBranch.equals("No branch")) {
|
if(currentBranch.equals("No branch")) {
|
||||||
@ -255,8 +247,7 @@ public class CreateFileActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Call<JsonElement> call = RetrofitClient
|
Call<JsonElement> call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
|
||||||
.createNewFile(token, repoOwner, repoName, fileName, createNewFileJsonStr);
|
.createNewFile(token, repoOwner, repoName, fileName, createNewFileJsonStr);
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonElement>() {
|
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;
|
String branchName;
|
||||||
DeleteFile deleteFileJsonStr;
|
DeleteFile deleteFileJsonStr;
|
||||||
@ -320,8 +311,7 @@ public class CreateFileActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Call<JsonElement> call = RetrofitClient
|
Call<JsonElement> call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
|
||||||
.deleteFile(token, repoOwner, repoName, fileName, deleteFileJsonStr);
|
.deleteFile(token, repoOwner, repoName, fileName, deleteFileJsonStr);
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonElement>() {
|
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;
|
String branchName;
|
||||||
EditFile editFileJsonStr;
|
EditFile editFileJsonStr;
|
||||||
@ -388,8 +378,7 @@ public class CreateFileActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Call<JsonElement> call = RetrofitClient
|
Call<JsonElement> call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
|
||||||
.editFile(token, repoOwner, repoName, fileName, editFileJsonStr);
|
.editFile(token, repoOwner, repoName, fileName, editFileJsonStr);
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonElement>() {
|
call.enqueue(new Callback<JsonElement>() {
|
||||||
@ -404,7 +393,7 @@ public class CreateFileActivity extends BaseActivity {
|
|||||||
getIntent().removeExtra("filePath");
|
getIntent().removeExtra("filePath");
|
||||||
getIntent().removeExtra("fileSha");
|
getIntent().removeExtra("fileSha");
|
||||||
getIntent().removeExtra("fileContents");
|
getIntent().removeExtra("fileContents");
|
||||||
tinyDb.putBoolean("fileModified", true);
|
tinyDB.putBoolean("fileModified", true);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
else if(response.code() == 401) {
|
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
|
Call<List<Branches>> call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
.getBranches(Authorization.get(ctx), repoOwner, repoName);
|
||||||
.getBranches(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName);
|
|
||||||
|
|
||||||
call.enqueue(new Callback<List<Branches>>() {
|
call.enqueue(new Callback<List<Branches>>() {
|
||||||
|
|
||||||
|
@ -51,9 +51,6 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||||||
private CustomLabelsSelectionDialogBinding labelsBinding;
|
private CustomLabelsSelectionDialogBinding labelsBinding;
|
||||||
private CustomAssigneesSelectionDialogBinding assigneesBinding;
|
private CustomAssigneesSelectionDialogBinding assigneesBinding;
|
||||||
private View.OnClickListener onClickListener;
|
private View.OnClickListener onClickListener;
|
||||||
final Context ctx = this;
|
|
||||||
private Context appCtx;
|
|
||||||
private TinyDB tinyDb;
|
|
||||||
private int resultLimit = StaticGlobalVariables.resultLimitOldGiteaInstances;
|
private int resultLimit = StaticGlobalVariables.resultLimitOldGiteaInstances;
|
||||||
private Dialog dialogLabels;
|
private Dialog dialogLabels;
|
||||||
private Dialog dialogAssignees;
|
private Dialog dialogAssignees;
|
||||||
@ -61,9 +58,7 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||||||
private String assigneesSetter;
|
private String assigneesSetter;
|
||||||
private int milestoneId;
|
private int milestoneId;
|
||||||
|
|
||||||
private String instanceUrl;
|
|
||||||
private String loginUid;
|
private String loginUid;
|
||||||
private String instanceToken;
|
|
||||||
private String repoOwner;
|
private String repoOwner;
|
||||||
private String repoName;
|
private String repoName;
|
||||||
|
|
||||||
@ -86,8 +81,6 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
tinyDb = new TinyDB(appCtx);
|
|
||||||
|
|
||||||
viewBinding = ActivityCreateIssueBinding.inflate(getLayoutInflater());
|
viewBinding = ActivityCreateIssueBinding.inflate(getLayoutInflater());
|
||||||
View view = viewBinding.getRoot();
|
View view = viewBinding.getRoot();
|
||||||
@ -97,17 +90,14 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||||||
|
|
||||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
|
|
||||||
instanceUrl = tinyDb.getString("instanceUrl");
|
loginUid = tinyDB.getString("loginUid");
|
||||||
loginUid = tinyDb.getString("loginUid");
|
String repoFullName = tinyDB.getString("repoFullName");
|
||||||
final String loginFullName = tinyDb.getString("userFullname");
|
|
||||||
String repoFullName = tinyDb.getString("repoFullName");
|
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
repoOwner = parts[0];
|
repoOwner = parts[0];
|
||||||
repoName = parts[1];
|
repoName = parts[1];
|
||||||
instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
|
||||||
|
|
||||||
// require gitea 1.12 or higher
|
// 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;
|
resultLimit = StaticGlobalVariables.resultLimitNewGiteaInstances;
|
||||||
}
|
}
|
||||||
@ -137,7 +127,7 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||||||
viewBinding.newIssueLabels.setOnClickListener(this);
|
viewBinding.newIssueLabels.setOnClickListener(this);
|
||||||
viewBinding.newIssueDueDate.setOnClickListener(this);
|
viewBinding.newIssueDueDate.setOnClickListener(this);
|
||||||
|
|
||||||
getMilestones(instanceUrl, instanceToken, repoOwner, repoName, loginUid, resultLimit);
|
getMilestones(repoOwner, repoName, resultLimit);
|
||||||
|
|
||||||
disableProcessButton();
|
disableProcessButton();
|
||||||
|
|
||||||
@ -194,7 +184,7 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||||||
assigneesBinding.cancel.setOnClickListener(assigneesBinding_ -> dialogAssignees.dismiss());
|
assigneesBinding.cancel.setOnClickListener(assigneesBinding_ -> dialogAssignees.dismiss());
|
||||||
|
|
||||||
dialogAssignees.show();
|
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() {
|
private void showLabels() {
|
||||||
@ -214,7 +204,7 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||||||
labelsBinding.cancel.setOnClickListener(labelsBinding_ -> dialogLabels.dismiss());
|
labelsBinding.cancel.setOnClickListener(labelsBinding_ -> dialogLabels.dismiss());
|
||||||
|
|
||||||
dialogLabels.show();
|
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() {
|
private void processNewIssue() {
|
||||||
@ -247,19 +237,18 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||||||
}
|
}
|
||||||
|
|
||||||
disableProcessButton();
|
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);
|
CreateIssue createNewIssueJson = new CreateIssue(loginUid, newIssueDescriptionForm, false, newIssueDueDateForm, newIssueMilestoneIdForm, newIssueTitleForm, assigneesListData, labelsIds);
|
||||||
|
|
||||||
Call<JsonElement> call3;
|
Call<JsonElement> call3;
|
||||||
|
|
||||||
call3 = RetrofitClient
|
call3 = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
.createNewIssue(Authorization.get(ctx), repoOwner, repoName, createNewIssueJson);
|
||||||
.createNewIssue(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, createNewIssueJson);
|
|
||||||
|
|
||||||
call3.enqueue(new Callback<JsonElement>() {
|
call3.enqueue(new Callback<JsonElement>() {
|
||||||
|
|
||||||
@ -268,7 +257,7 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||||||
|
|
||||||
if(response2.code() == 201) {
|
if(response2.code() == 201) {
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(appCtx);
|
TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||||
tinyDb.putBoolean("resumeIssues", true);
|
tinyDb.putBoolean("resumeIssues", true);
|
||||||
|
|
||||||
Toasty.success(ctx, getString(R.string.issueCreated));
|
Toasty.success(ctx, getString(R.string.issueCreated));
|
||||||
@ -306,13 +295,12 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||||||
onClickListener = view -> finish();
|
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";
|
String msState = "open";
|
||||||
Call<List<Milestones>> call = RetrofitClient
|
Call<List<Milestones>> call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
.getMilestones(Authorization.get(ctx), repoOwner, repoName, 1, resultLimit, msState);
|
||||||
.getMilestones(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, 1, resultLimit, msState);
|
|
||||||
|
|
||||||
call.enqueue(new Callback<List<Milestones>>() {
|
call.enqueue(new Callback<List<Milestones>>() {
|
||||||
|
|
||||||
|
@ -10,11 +10,9 @@ import android.widget.Button;
|
|||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import androidx.annotation.ColorInt;
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
import com.pes.androidmaterialcolorpickerdialog.ColorPicker;
|
import com.pes.androidmaterialcolorpickerdialog.ColorPicker;
|
||||||
import com.pes.androidmaterialcolorpickerdialog.ColorPickerCallback;
|
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.helpers.AlertDialogs;
|
import org.mian.gitnex.helpers.AlertDialogs;
|
||||||
@ -39,8 +37,6 @@ public class CreateLabelActivity extends BaseActivity {
|
|||||||
private TextView colorPicker;
|
private TextView colorPicker;
|
||||||
private EditText labelName;
|
private EditText labelName;
|
||||||
private Button createLabelButton;
|
private Button createLabelButton;
|
||||||
final Context ctx = this;
|
|
||||||
private Context appCtx;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getLayoutResourceId(){
|
protected int getLayoutResourceId(){
|
||||||
@ -51,22 +47,20 @@ public class CreateLabelActivity extends BaseActivity {
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
|
|
||||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
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 repoFullName = tinyDb.getString("repoFullName");
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
final String repoOwner = parts[0];
|
final String repoOwner = parts[0];
|
||||||
final String repoName = parts[1];
|
final String repoName = parts[1];
|
||||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
|
||||||
final String loginUid = tinyDb.getString("loginUid");
|
final String loginUid = tinyDb.getString("loginUid");
|
||||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||||
|
|
||||||
if(getIntent().getStringExtra("labelAction") != null && Objects.requireNonNull(getIntent().getStringExtra("labelAction")).equals("delete")) {
|
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();
|
finish();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -129,14 +123,13 @@ public class CreateLabelActivity extends BaseActivity {
|
|||||||
|
|
||||||
private void processUpdateLabel() {
|
private void processUpdateLabel() {
|
||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
final TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||||
AppUtil appUtil = new AppUtil();
|
AppUtil appUtil = new AppUtil();
|
||||||
String repoFullName = tinyDb.getString("repoFullName");
|
String repoFullName = tinyDb.getString("repoFullName");
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
final String repoOwner = parts[0];
|
final String repoOwner = parts[0];
|
||||||
final String repoName = parts[1];
|
final String repoName = parts[1];
|
||||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
|
||||||
final String loginUid = tinyDb.getString("loginUid");
|
final String loginUid = tinyDb.getString("loginUid");
|
||||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||||
|
|
||||||
@ -171,7 +164,7 @@ public class CreateLabelActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
disableProcessButton();
|
disableProcessButton();
|
||||||
patchLabel(instanceUrl, instanceToken, repoOwner, repoName, updateLabelName, updateLabelColor, Integer.parseInt(
|
patchLabel(instanceToken, repoOwner, repoName, updateLabelName, updateLabelColor, Integer.parseInt(
|
||||||
Objects.requireNonNull(getIntent().getStringExtra("labelId"))), loginUid);
|
Objects.requireNonNull(getIntent().getStringExtra("labelId"))), loginUid);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -180,12 +173,11 @@ public class CreateLabelActivity extends BaseActivity {
|
|||||||
|
|
||||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||||
AppUtil appUtil = new AppUtil();
|
AppUtil appUtil = new AppUtil();
|
||||||
TinyDB tinyDb = new TinyDB(appCtx);
|
TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||||
String repoFullName = tinyDb.getString("repoFullName");
|
String repoFullName = tinyDb.getString("repoFullName");
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
final String repoOwner = parts[0];
|
final String repoOwner = parts[0];
|
||||||
final String repoName = parts[1];
|
final String repoName = parts[1];
|
||||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
|
||||||
final String loginUid = tinyDb.getString("loginUid");
|
final String loginUid = tinyDb.getString("loginUid");
|
||||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||||
|
|
||||||
@ -220,20 +212,19 @@ public class CreateLabelActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
disableProcessButton();
|
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);
|
CreateLabel createLabelFunc = new CreateLabel(newLabelName, newLabelColor);
|
||||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
final TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||||
|
|
||||||
Call<CreateLabel> call;
|
Call<CreateLabel> call;
|
||||||
|
|
||||||
call = RetrofitClient
|
call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
.createLabel(Authorization.get(ctx), repoOwner, repoName, createLabelFunc);
|
||||||
.createLabel(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, createLabelFunc);
|
|
||||||
|
|
||||||
call.enqueue(new Callback<CreateLabel>() {
|
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);
|
CreateLabel createLabelFunc = new CreateLabel(updateLabelName, updateLabelColor);
|
||||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
final TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||||
|
|
||||||
Call<CreateLabel> call;
|
Call<CreateLabel> call;
|
||||||
|
|
||||||
call = RetrofitClient
|
call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(appCtx)
|
||||||
.getApiInterface()
|
.patchLabel(Authorization.get(ctx), repoOwner, repoName, labelId, createLabelFunc);
|
||||||
.patchLabel(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, labelId, createLabelFunc);
|
|
||||||
|
|
||||||
call.enqueue(new Callback<CreateLabel>() {
|
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<Labels> call;
|
||||||
|
|
||||||
call = RetrofitClient
|
call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(appCtx)
|
||||||
.getApiInterface()
|
.deleteLabel(Authorization.get(ctx), repoOwner, repoName, labelId);
|
||||||
.deleteLabel(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, labelId);
|
|
||||||
|
|
||||||
call.enqueue(new Callback<Labels>() {
|
call.enqueue(new Callback<Labels>() {
|
||||||
|
|
||||||
@ -366,7 +355,7 @@ public class CreateLabelActivity extends BaseActivity {
|
|||||||
if(response.code() == 204) {
|
if(response.code() == 204) {
|
||||||
|
|
||||||
Toasty.success(ctx, getString(R.string.labelDeleteText));
|
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("labelAction");
|
||||||
getIntent().removeExtra("labelId");
|
getIntent().removeExtra("labelId");
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ import android.view.MotionEvent;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.DatePicker;
|
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
@ -37,8 +36,6 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
|||||||
private EditText milestoneTitle;
|
private EditText milestoneTitle;
|
||||||
private EditText milestoneDescription;
|
private EditText milestoneDescription;
|
||||||
private Button createNewMilestoneButton;
|
private Button createNewMilestoneButton;
|
||||||
final Context ctx = this;
|
|
||||||
private Context appCtx;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getLayoutResourceId(){
|
protected int getLayoutResourceId(){
|
||||||
@ -50,7 +47,6 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
|
|
||||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||||
|
|
||||||
@ -98,14 +94,11 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
|||||||
|
|
||||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||||
AppUtil appUtil = new AppUtil();
|
AppUtil appUtil = new AppUtil();
|
||||||
TinyDB tinyDb = new TinyDB(appCtx);
|
TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||||
String repoFullName = tinyDb.getString("repoFullName");
|
String repoFullName = tinyDb.getString("repoFullName");
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
final String repoOwner = parts[0];
|
final String repoOwner = parts[0];
|
||||||
final String repoName = parts[1];
|
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 newMilestoneTitle = milestoneTitle.getText().toString();
|
||||||
String newMilestoneDescription = milestoneDescription.getText().toString();
|
String newMilestoneDescription = milestoneDescription.getText().toString();
|
||||||
@ -146,18 +139,17 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
|||||||
}
|
}
|
||||||
|
|
||||||
disableProcessButton();
|
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);
|
Milestones createMilestone = new Milestones(newMilestoneDescription, newMilestoneTitle, newMilestoneDueDate);
|
||||||
|
|
||||||
Call<Milestones> call;
|
Call<Milestones> call;
|
||||||
|
|
||||||
call = RetrofitClient
|
call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(appCtx)
|
||||||
.getApiInterface()
|
|
||||||
.createMilestone(token, repoOwner, repoName, createMilestone);
|
.createMilestone(token, repoOwner, repoName, createMilestone);
|
||||||
|
|
||||||
call.enqueue(new Callback<Milestones>() {
|
call.enqueue(new Callback<Milestones>() {
|
||||||
@ -169,7 +161,7 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
|||||||
|
|
||||||
if(response.code() == 201) {
|
if(response.code() == 201) {
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(appCtx);
|
TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||||
tinyDb.putBoolean("milestoneCreated", true);
|
tinyDb.putBoolean("milestoneCreated", true);
|
||||||
Toasty.success(ctx, getString(R.string.milestoneCreated));
|
Toasty.success(ctx, getString(R.string.milestoneCreated));
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
|
@ -33,8 +33,6 @@ public class CreateNewUserActivity extends BaseActivity {
|
|||||||
private EditText userEmail;
|
private EditText userEmail;
|
||||||
private EditText userPassword;
|
private EditText userPassword;
|
||||||
private Button createUserButton;
|
private Button createUserButton;
|
||||||
final Context ctx = this;
|
|
||||||
private Context appCtx;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getLayoutResourceId(){
|
protected int getLayoutResourceId(){
|
||||||
@ -45,7 +43,6 @@ public class CreateNewUserActivity extends BaseActivity {
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
|
|
||||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||||
|
|
||||||
@ -79,10 +76,7 @@ public class CreateNewUserActivity extends BaseActivity {
|
|||||||
|
|
||||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||||
AppUtil appUtil = new AppUtil();
|
AppUtil appUtil = new AppUtil();
|
||||||
TinyDB tinyDb = new TinyDB(appCtx);
|
TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
|
||||||
final String loginUid = tinyDb.getString("loginUid");
|
|
||||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
|
||||||
|
|
||||||
String newFullName = fullName.getText().toString().trim();
|
String newFullName = fullName.getText().toString().trim();
|
||||||
String newUserName = userUserName.getText().toString().trim();
|
String newUserName = userUserName.getText().toString().trim();
|
||||||
@ -120,18 +114,17 @@ public class CreateNewUserActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
disableProcessButton();
|
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);
|
UserInfo createUser = new UserInfo(newUserEmail, newFullName, newUserName, newUserPassword, newUserName, 0, true);
|
||||||
|
|
||||||
Call<UserInfo> call;
|
Call<UserInfo> call;
|
||||||
|
|
||||||
call = RetrofitClient
|
call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(appCtx)
|
||||||
.getApiInterface()
|
|
||||||
.createNewUser(instanceToken, createUser);
|
.createNewUser(instanceToken, createUser);
|
||||||
|
|
||||||
call.enqueue(new Callback<UserInfo>() {
|
call.enqueue(new Callback<UserInfo>() {
|
||||||
|
@ -34,8 +34,6 @@ public class CreateOrganizationActivity extends BaseActivity {
|
|||||||
|
|
||||||
private EditText orgName;
|
private EditText orgName;
|
||||||
private EditText orgDesc;
|
private EditText orgDesc;
|
||||||
final Context ctx = this;
|
|
||||||
private Context appCtx;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getLayoutResourceId(){
|
protected int getLayoutResourceId(){
|
||||||
@ -47,7 +45,6 @@ public class CreateOrganizationActivity extends BaseActivity {
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
|
|
||||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||||
|
|
||||||
@ -99,10 +96,7 @@ public class CreateOrganizationActivity extends BaseActivity {
|
|||||||
|
|
||||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||||
AppUtil appUtil = new AppUtil();
|
AppUtil appUtil = new AppUtil();
|
||||||
TinyDB tinyDb = new TinyDB(appCtx);
|
TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
|
||||||
final String loginUid = tinyDb.getString("loginUid");
|
|
||||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
|
||||||
|
|
||||||
String newOrgName = orgName.getText().toString();
|
String newOrgName = orgName.getText().toString();
|
||||||
String newOrgDesc = orgDesc.getText().toString();
|
String newOrgDesc = orgDesc.getText().toString();
|
||||||
@ -133,18 +127,17 @@ public class CreateOrganizationActivity extends BaseActivity {
|
|||||||
else {
|
else {
|
||||||
|
|
||||||
disableProcessButton();
|
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);
|
UserOrganizations createOrganization = new UserOrganizations(orgName, null, orgDesc, null, null);
|
||||||
|
|
||||||
Call<UserOrganizations> call = RetrofitClient
|
Call<UserOrganizations> call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(appCtx)
|
||||||
.getApiInterface()
|
|
||||||
.createNewOrganization(token, createOrganization);
|
.createNewOrganization(token, createOrganization);
|
||||||
|
|
||||||
call.enqueue(new Callback<UserOrganizations>() {
|
call.enqueue(new Callback<UserOrganizations>() {
|
||||||
@ -154,7 +147,7 @@ public class CreateOrganizationActivity extends BaseActivity {
|
|||||||
|
|
||||||
if(response.code() == 201) {
|
if(response.code() == 201) {
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(appCtx);
|
TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||||
tinyDb.putBoolean("orgCreated", true);
|
tinyDb.putBoolean("orgCreated", true);
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
Toasty.success(ctx, getString(R.string.orgCreated));
|
Toasty.success(ctx, getString(R.string.orgCreated));
|
||||||
|
@ -3,7 +3,6 @@ package org.mian.gitnex.activities;
|
|||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.DatePickerDialog;
|
import android.app.DatePickerDialog;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.os.Bundle;
|
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.AppUtil;
|
||||||
import org.mian.gitnex.helpers.Authorization;
|
import org.mian.gitnex.helpers.Authorization;
|
||||||
import org.mian.gitnex.helpers.StaticGlobalVariables;
|
import org.mian.gitnex.helpers.StaticGlobalVariables;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
import org.mian.gitnex.helpers.Version;
|
import org.mian.gitnex.helpers.Version;
|
||||||
import org.mian.gitnex.models.Branches;
|
import org.mian.gitnex.models.Branches;
|
||||||
@ -43,9 +41,6 @@ import retrofit2.Callback;
|
|||||||
public class CreatePullRequestActivity extends BaseActivity implements LabelsListAdapter.LabelsListAdapterListener {
|
public class CreatePullRequestActivity extends BaseActivity implements LabelsListAdapter.LabelsListAdapterListener {
|
||||||
|
|
||||||
private View.OnClickListener onClickListener;
|
private View.OnClickListener onClickListener;
|
||||||
private Context ctx = this;
|
|
||||||
private Context appCtx;
|
|
||||||
private TinyDB tinyDb;
|
|
||||||
private ActivityCreatePrBinding viewBinding;
|
private ActivityCreatePrBinding viewBinding;
|
||||||
private CustomLabelsSelectionDialogBinding labelsBinding;
|
private CustomLabelsSelectionDialogBinding labelsBinding;
|
||||||
private int resultLimit = StaticGlobalVariables.resultLimitOldGiteaInstances;
|
private int resultLimit = StaticGlobalVariables.resultLimitOldGiteaInstances;
|
||||||
@ -55,7 +50,6 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
|||||||
private List<String> assignees = new ArrayList<>();
|
private List<String> assignees = new ArrayList<>();
|
||||||
private int milestoneId;
|
private int milestoneId;
|
||||||
|
|
||||||
private String instanceUrl;
|
|
||||||
private String loginUid;
|
private String loginUid;
|
||||||
private String instanceToken;
|
private String instanceToken;
|
||||||
private String repoOwner;
|
private String repoOwner;
|
||||||
@ -80,23 +74,20 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
tinyDb = new TinyDB(appCtx);
|
|
||||||
|
|
||||||
viewBinding = ActivityCreatePrBinding.inflate(getLayoutInflater());
|
viewBinding = ActivityCreatePrBinding.inflate(getLayoutInflater());
|
||||||
View view = viewBinding.getRoot();
|
View view = viewBinding.getRoot();
|
||||||
setContentView(view);
|
setContentView(view);
|
||||||
|
|
||||||
instanceUrl = tinyDb.getString("instanceUrl");
|
loginUid = tinyDB.getString("loginUid");
|
||||||
loginUid = tinyDb.getString("loginUid");
|
String repoFullName = tinyDB.getString("repoFullName");
|
||||||
String repoFullName = tinyDb.getString("repoFullName");
|
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
repoOwner = parts[0];
|
repoOwner = parts[0];
|
||||||
repoName = parts[1];
|
repoName = parts[1];
|
||||||
instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
instanceToken = "token " + tinyDB.getString(loginUid + "-token");
|
||||||
|
|
||||||
// require gitea 1.12 or higher
|
// 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;
|
resultLimit = StaticGlobalVariables.resultLimitNewGiteaInstances;
|
||||||
}
|
}
|
||||||
@ -125,8 +116,8 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
|||||||
|
|
||||||
disableProcessButton();
|
disableProcessButton();
|
||||||
|
|
||||||
getMilestones(instanceUrl, instanceToken, repoOwner, repoName, loginUid, resultLimit);
|
getMilestones(repoOwner, repoName, resultLimit);
|
||||||
getBranches(instanceUrl, instanceToken, repoOwner, repoName, loginUid);
|
getBranches(repoOwner, repoName);
|
||||||
|
|
||||||
viewBinding.prLabels.setOnClickListener(prLabels -> showLabels());
|
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);
|
CreatePullRequest createPullRequest = new CreatePullRequest(prTitle, prDescription, loginUid, mergeInto, pullFrom, milestoneId, dueDate, assignees, labelsIds);
|
||||||
|
|
||||||
Call<ResponseBody> transferCall = RetrofitClient
|
Call<ResponseBody> transferCall = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(appCtx)
|
||||||
.getApiInterface()
|
|
||||||
.createPullRequest(instanceToken, repoOwner, repoName, createPullRequest);
|
.createPullRequest(instanceToken, repoOwner, repoName, createPullRequest);
|
||||||
|
|
||||||
transferCall.enqueue(new Callback<ResponseBody>() {
|
transferCall.enqueue(new Callback<ResponseBody>() {
|
||||||
@ -256,15 +246,14 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
|||||||
labelsBinding.cancel.setOnClickListener(editProperties -> dialogLabels.dismiss());
|
labelsBinding.cancel.setOnClickListener(editProperties -> dialogLabels.dismiss());
|
||||||
|
|
||||||
dialogLabels.show();
|
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
|
Call<List<Branches>> call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
.getBranches(Authorization.get(ctx), repoOwner, repoName);
|
||||||
.getBranches(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName);
|
|
||||||
|
|
||||||
call.enqueue(new Callback<List<Branches>>() {
|
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";
|
String msState = "open";
|
||||||
Call<List<Milestones>> call = RetrofitClient
|
Call<List<Milestones>> call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(appCtx)
|
||||||
.getApiInterface()
|
.getMilestones(Authorization.get(ctx), repoOwner, repoName, 1, resultLimit, msState);
|
||||||
.getMilestones(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, 1, resultLimit, msState);
|
|
||||||
|
|
||||||
call.enqueue(new Callback<List<Milestones>>() {
|
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.AlertDialogs;
|
||||||
import org.mian.gitnex.helpers.AppUtil;
|
import org.mian.gitnex.helpers.AppUtil;
|
||||||
import org.mian.gitnex.helpers.Authorization;
|
import org.mian.gitnex.helpers.Authorization;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
import org.mian.gitnex.models.Branches;
|
import org.mian.gitnex.models.Branches;
|
||||||
import org.mian.gitnex.models.Releases;
|
import org.mian.gitnex.models.Releases;
|
||||||
@ -43,14 +42,8 @@ public class CreateReleaseActivity extends BaseActivity {
|
|||||||
private CheckBox releaseType;
|
private CheckBox releaseType;
|
||||||
private CheckBox releaseDraft;
|
private CheckBox releaseDraft;
|
||||||
private Button createNewRelease;
|
private Button createNewRelease;
|
||||||
final Context ctx = this;
|
|
||||||
private Context appCtx;
|
|
||||||
private TinyDB tinyDb;
|
|
||||||
private String selectedBranch;
|
private String selectedBranch;
|
||||||
|
|
||||||
private String instanceUrl;
|
|
||||||
private String loginUid;
|
|
||||||
private String instanceToken;
|
|
||||||
private String repoOwner;
|
private String repoOwner;
|
||||||
private String repoName;
|
private String repoName;
|
||||||
|
|
||||||
@ -66,17 +59,12 @@ public class CreateReleaseActivity extends BaseActivity {
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
tinyDb = new TinyDB(appCtx);
|
|
||||||
|
|
||||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||||
|
|
||||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
|
|
||||||
instanceUrl = tinyDb.getString("instanceUrl");
|
String repoFullName = tinyDB.getString("repoFullName");
|
||||||
loginUid = tinyDb.getString("loginUid");
|
|
||||||
instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
|
||||||
String repoFullName = tinyDb.getString("repoFullName");
|
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
repoOwner = parts[0];
|
repoOwner = parts[0];
|
||||||
repoName = parts[1];
|
repoName = parts[1];
|
||||||
@ -107,7 +95,7 @@ public class CreateReleaseActivity extends BaseActivity {
|
|||||||
closeActivity.setOnClickListener(onClickListener);
|
closeActivity.setOnClickListener(onClickListener);
|
||||||
|
|
||||||
releaseBranch = findViewById(R.id.releaseBranch);
|
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);
|
createNewRelease = findViewById(R.id.createNewRelease);
|
||||||
disableProcessButton();
|
disableProcessButton();
|
||||||
@ -161,18 +149,17 @@ public class CreateReleaseActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
disableProcessButton();
|
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);
|
Releases createReleaseJson = new Releases(newReleaseContent, newReleaseDraft, newReleaseTitle, newReleaseType, newReleaseTagName, selectedBranch);
|
||||||
|
|
||||||
Call<Releases> call;
|
Call<Releases> call;
|
||||||
|
|
||||||
call = RetrofitClient
|
call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
|
||||||
.createNewRelease(token, repoOwner, repoName, createReleaseJson);
|
.createNewRelease(token, repoOwner, repoName, createReleaseJson);
|
||||||
|
|
||||||
call.enqueue(new Callback<Releases>() {
|
call.enqueue(new Callback<Releases>() {
|
||||||
@ -182,7 +169,7 @@ public class CreateReleaseActivity extends BaseActivity {
|
|||||||
|
|
||||||
if (response.code() == 201) {
|
if (response.code() == 201) {
|
||||||
|
|
||||||
tinyDb.putBoolean("updateReleases", true);
|
tinyDB.putBoolean("updateReleases", true);
|
||||||
Toasty.success(ctx, getString(R.string.releaseCreatedText));
|
Toasty.success(ctx, getString(R.string.releaseCreatedText));
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
finish();
|
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
|
Call<List<Branches>> call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
|
||||||
.getBranches(instanceToken, repoOwner, repoName);
|
.getBranches(instanceToken, repoOwner, repoName);
|
||||||
|
|
||||||
call.enqueue(new Callback<List<Branches>>() {
|
call.enqueue(new Callback<List<Branches>>() {
|
||||||
|
@ -43,14 +43,9 @@ public class CreateRepoActivity extends BaseActivity {
|
|||||||
private EditText repoName;
|
private EditText repoName;
|
||||||
private EditText repoDesc;
|
private EditText repoDesc;
|
||||||
private CheckBox repoAccess;
|
private CheckBox repoAccess;
|
||||||
final Context ctx = this;
|
|
||||||
private Context appCtx;
|
|
||||||
private TinyDB tinyDb;
|
|
||||||
|
|
||||||
private String instanceUrl;
|
|
||||||
private String loginUid;
|
private String loginUid;
|
||||||
private String userLogin;
|
private String userLogin;
|
||||||
private String instanceToken;
|
|
||||||
|
|
||||||
private String selectedOwner;
|
private String selectedOwner;
|
||||||
|
|
||||||
@ -69,15 +64,11 @@ public class CreateRepoActivity extends BaseActivity {
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
tinyDb = new TinyDB(appCtx);
|
|
||||||
|
|
||||||
boolean connToInternet = AppUtil.hasNetworkConnection(ctx);
|
boolean connToInternet = AppUtil.hasNetworkConnection(ctx);
|
||||||
|
|
||||||
instanceUrl = tinyDb.getString("instanceUrl");
|
loginUid = tinyDB.getString("loginUid");
|
||||||
loginUid = tinyDb.getString("loginUid");
|
userLogin = tinyDB.getString("userLogin");
|
||||||
userLogin = tinyDb.getString("userLogin");
|
|
||||||
instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
|
||||||
|
|
||||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
|
|
||||||
@ -94,7 +85,7 @@ public class CreateRepoActivity extends BaseActivity {
|
|||||||
closeActivity.setOnClickListener(onClickListener);
|
closeActivity.setOnClickListener(onClickListener);
|
||||||
|
|
||||||
spinner = findViewById(R.id.ownerSpinner);
|
spinner = findViewById(R.id.ownerSpinner);
|
||||||
getOrganizations(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), userLogin);
|
getOrganizations(Authorization.get(ctx), userLogin);
|
||||||
|
|
||||||
createRepo = findViewById(R.id.createNewRepoButton);
|
createRepo = findViewById(R.id.createNewRepoButton);
|
||||||
disableProcessButton();
|
disableProcessButton();
|
||||||
@ -158,11 +149,11 @@ public class CreateRepoActivity extends BaseActivity {
|
|||||||
else {
|
else {
|
||||||
|
|
||||||
disableProcessButton();
|
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");
|
OrganizationRepository createRepository = new OrganizationRepository(true, repoDesc, null, null, repoName, isPrivate, "Default");
|
||||||
|
|
||||||
@ -170,15 +161,13 @@ public class CreateRepoActivity extends BaseActivity {
|
|||||||
if(selectedOwner.equals(loginUid)) {
|
if(selectedOwner.equals(loginUid)) {
|
||||||
|
|
||||||
call = RetrofitClient
|
call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
|
||||||
.createNewUserRepository(token, createRepository);
|
.createNewUserRepository(token, createRepository);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
call = RetrofitClient
|
call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
|
||||||
.createNewUserOrgRepository(token, selectedOwner, createRepository);
|
.createNewUserOrgRepository(token, selectedOwner, createRepository);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,7 +178,7 @@ public class CreateRepoActivity extends BaseActivity {
|
|||||||
|
|
||||||
if(response.code() == 201) {
|
if(response.code() == 201) {
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(appCtx);
|
TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||||
tinyDb.putBoolean("repoCreated", true);
|
tinyDb.putBoolean("repoCreated", true);
|
||||||
Toasty.success(ctx, getString(R.string.repoCreated));
|
Toasty.success(ctx, getString(R.string.repoCreated));
|
||||||
enableProcessButton();
|
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
|
Call<List<OrgOwner>> call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
|
||||||
.getOrgOwners(instanceToken);
|
.getOrgOwners(instanceToken);
|
||||||
|
|
||||||
call.enqueue(new Callback<List<OrgOwner>>() {
|
call.enqueue(new Callback<List<OrgOwner>>() {
|
||||||
@ -249,9 +237,9 @@ public class CreateRepoActivity extends BaseActivity {
|
|||||||
|
|
||||||
for(int i = 0; i < organizationsList_.size(); i++) {
|
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;
|
organizationId = i + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -267,7 +255,7 @@ public class CreateRepoActivity extends BaseActivity {
|
|||||||
|
|
||||||
spinner.setOnItemClickListener ((parent, view, position, id) -> selectedOwner = organizationsList.get(position).getUsername());
|
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;
|
int selectOwnerById = organizationId;
|
||||||
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||||
@ -276,7 +264,7 @@ public class CreateRepoActivity extends BaseActivity {
|
|||||||
selectedOwner = organizationsList.get(selectOwnerById).getUsername();
|
selectedOwner = organizationsList.get(selectOwnerById).getUsername();
|
||||||
}, 500);
|
}, 500);
|
||||||
|
|
||||||
tinyDb.putBoolean("organizationAction", false);
|
tinyDB.putBoolean("organizationAction", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
|
@ -31,8 +31,6 @@ import retrofit2.Callback;
|
|||||||
|
|
||||||
public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClickListener {
|
public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClickListener {
|
||||||
|
|
||||||
final Context ctx = CreateTeamByOrgActivity.this;
|
|
||||||
private Context appCtx;
|
|
||||||
private View.OnClickListener onClickListener;
|
private View.OnClickListener onClickListener;
|
||||||
private TextView teamName;
|
private TextView teamName;
|
||||||
private TextView teamDesc;
|
private TextView teamDesc;
|
||||||
@ -75,7 +73,6 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
|
|
||||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||||
|
|
||||||
@ -228,8 +225,7 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
|||||||
private void processCreateTeam() {
|
private void processCreateTeam() {
|
||||||
|
|
||||||
AppUtil appUtil = new AppUtil();
|
AppUtil appUtil = new AppUtil();
|
||||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
final TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
|
||||||
final String loginUid = tinyDb.getString("loginUid");
|
final String loginUid = tinyDb.getString("loginUid");
|
||||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||||
final String orgName = tinyDb.getString("orgName");;
|
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());
|
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);
|
Teams createNewTeamJson = new Teams(newTeamName, newTeamDesc, newTeamPermission, newTeamAccessControls);
|
||||||
|
|
||||||
Call<Teams> call3;
|
Call<Teams> call3;
|
||||||
|
|
||||||
call3 = RetrofitClient
|
call3 = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
.createTeamsByOrg(Authorization.get(ctx), orgName, createNewTeamJson);
|
||||||
.createTeamsByOrg(Authorization.returnAuthentication(ctx, loginUid, instanceToken), orgName, createNewTeamJson);
|
|
||||||
|
|
||||||
call3.enqueue(new Callback<Teams>() {
|
call3.enqueue(new Callback<Teams>() {
|
||||||
|
|
||||||
@ -309,7 +304,7 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
|||||||
|
|
||||||
if(response2.code() == 201) {
|
if(response2.code() == 201) {
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(appCtx);
|
TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||||
tinyDb.putBoolean("resumeTeams", true);
|
tinyDb.putBoolean("resumeTeams", true);
|
||||||
|
|
||||||
Toasty.success(ctx, getString(R.string.teamCreated));
|
Toasty.success(ctx, getString(R.string.teamCreated));
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package org.mian.gitnex.activities;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
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.database.models.UserAccount;
|
||||||
import org.mian.gitnex.databinding.ActivityDeeplinksBinding;
|
import org.mian.gitnex.databinding.ActivityDeeplinksBinding;
|
||||||
import org.mian.gitnex.helpers.PathsHelper;
|
import org.mian.gitnex.helpers.PathsHelper;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
import org.mian.gitnex.helpers.UrlHelper;
|
import org.mian.gitnex.helpers.UrlHelper;
|
||||||
import org.mian.gitnex.models.GiteaVersion;
|
import org.mian.gitnex.models.GiteaVersion;
|
||||||
@ -38,9 +36,6 @@ import retrofit2.Callback;
|
|||||||
public class DeepLinksActivity extends BaseActivity {
|
public class DeepLinksActivity extends BaseActivity {
|
||||||
|
|
||||||
private ActivityDeeplinksBinding viewBinding;
|
private ActivityDeeplinksBinding viewBinding;
|
||||||
private Context ctx = this;
|
|
||||||
private Context appCtx;
|
|
||||||
private TinyDB tinyDb;
|
|
||||||
private String currentInstance;
|
private String currentInstance;
|
||||||
private String instanceToken;
|
private String instanceToken;
|
||||||
private boolean noAccountFound = false;
|
private boolean noAccountFound = false;
|
||||||
@ -59,8 +54,6 @@ public class DeepLinksActivity extends BaseActivity {
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
tinyDb = new TinyDB(appCtx);
|
|
||||||
|
|
||||||
viewBinding = ActivityDeeplinksBinding.inflate(getLayoutInflater());
|
viewBinding = ActivityDeeplinksBinding.inflate(getLayoutInflater());
|
||||||
View view = viewBinding.getRoot();
|
View view = viewBinding.getRoot();
|
||||||
@ -75,7 +68,7 @@ public class DeepLinksActivity extends BaseActivity {
|
|||||||
assert data != null;
|
assert data != null;
|
||||||
|
|
||||||
// check for login
|
// check for login
|
||||||
if(!tinyDb.getBoolean("loggedInMode")) {
|
if(!tinyDB.getBoolean("loggedInMode")) {
|
||||||
|
|
||||||
finish();
|
finish();
|
||||||
ctx.startActivity(new Intent(ctx, LoginActivity.class));
|
ctx.startActivity(new Intent(ctx, LoginActivity.class));
|
||||||
@ -123,15 +116,15 @@ public class DeepLinksActivity extends BaseActivity {
|
|||||||
|
|
||||||
issueIntent.putExtra("issueNumber", data.getLastPathSegment());
|
issueIntent.putExtra("issueNumber", data.getLastPathSegment());
|
||||||
|
|
||||||
tinyDb.putString("issueNumber", data.getLastPathSegment());
|
tinyDB.putString("issueNumber", data.getLastPathSegment());
|
||||||
tinyDb.putString("issueType", "Issue");
|
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 repoOwner = restOfUrl[restOfUrl.length - 4];
|
||||||
final String repoName = restOfUrl[restOfUrl.length - 3];
|
final String repoName = restOfUrl[restOfUrl.length - 3];
|
||||||
|
|
||||||
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
int currentActiveAccountId = tinyDB.getInt("currentActiveAccountId");
|
||||||
RepositoriesApi repositoryData = new RepositoriesApi(ctx);
|
RepositoriesApi repositoryData = new RepositoriesApi(ctx);
|
||||||
|
|
||||||
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
||||||
@ -139,12 +132,12 @@ public class DeepLinksActivity extends BaseActivity {
|
|||||||
if(count == 0) {
|
if(count == 0) {
|
||||||
|
|
||||||
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
|
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
|
||||||
tinyDb.putLong("repositoryId", id);
|
tinyDB.putLong("repositoryId", id);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
Repository dataRepo = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
|
Repository dataRepo = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
|
||||||
tinyDb.putLong("repositoryId", dataRepo.getRepositoryId());
|
tinyDB.putLong("repositoryId", dataRepo.getRepositoryId());
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.startActivity(issueIntent);
|
ctx.startActivity(issueIntent);
|
||||||
@ -197,38 +190,38 @@ public class DeepLinksActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
else { // no action, show options
|
else { // no action, show options
|
||||||
|
|
||||||
if(tinyDb.getInt("defaultScreenId") == 1) { // repos
|
if(tinyDB.getInt("defaultScreenId") == 1) { // repos
|
||||||
|
|
||||||
mainIntent.putExtra("launchFragmentByLinkHandler", "repos");
|
mainIntent.putExtra("launchFragmentByLinkHandler", "repos");
|
||||||
ctx.startActivity(mainIntent);
|
ctx.startActivity(mainIntent);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
else if(tinyDb.getInt("defaultScreenId") == 2) { // org
|
else if(tinyDB.getInt("defaultScreenId") == 2) { // org
|
||||||
|
|
||||||
mainIntent.putExtra("launchFragmentByLinkHandler", "org");
|
mainIntent.putExtra("launchFragmentByLinkHandler", "org");
|
||||||
ctx.startActivity(mainIntent);
|
ctx.startActivity(mainIntent);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
else if(tinyDb.getInt("defaultScreenId") == 3) { // notifications
|
else if(tinyDB.getInt("defaultScreenId") == 3) { // notifications
|
||||||
|
|
||||||
mainIntent.putExtra("launchFragmentByLinkHandler", "notification");
|
mainIntent.putExtra("launchFragmentByLinkHandler", "notification");
|
||||||
ctx.startActivity(mainIntent);
|
ctx.startActivity(mainIntent);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
else if(tinyDb.getInt("defaultScreenId") == 4) { // explore
|
else if(tinyDB.getInt("defaultScreenId") == 4) { // explore
|
||||||
|
|
||||||
mainIntent.putExtra("launchFragmentByLinkHandler", "explore");
|
mainIntent.putExtra("launchFragmentByLinkHandler", "explore");
|
||||||
ctx.startActivity(mainIntent);
|
ctx.startActivity(mainIntent);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
else if(tinyDb.getInt("defaultScreenId") == 0) { // show options
|
else if(tinyDB.getInt("defaultScreenId") == 0) { // show options
|
||||||
|
|
||||||
viewBinding.noActionFrame.setVisibility(View.VISIBLE);
|
viewBinding.noActionFrame.setVisibility(View.VISIBLE);
|
||||||
viewBinding.addNewAccountFrame.setVisibility(View.GONE);
|
viewBinding.addNewAccountFrame.setVisibility(View.GONE);
|
||||||
|
|
||||||
viewBinding.repository.setOnClickListener(repository -> {
|
viewBinding.repository.setOnClickListener(repository -> {
|
||||||
|
|
||||||
tinyDb.putInt("defaultScreenId", 1);
|
tinyDB.putInt("defaultScreenId", 1);
|
||||||
mainIntent.putExtra("launchFragmentByLinkHandler", "repos");
|
mainIntent.putExtra("launchFragmentByLinkHandler", "repos");
|
||||||
ctx.startActivity(mainIntent);
|
ctx.startActivity(mainIntent);
|
||||||
finish();
|
finish();
|
||||||
@ -236,7 +229,7 @@ public class DeepLinksActivity extends BaseActivity {
|
|||||||
|
|
||||||
viewBinding.organization.setOnClickListener(organization -> {
|
viewBinding.organization.setOnClickListener(organization -> {
|
||||||
|
|
||||||
tinyDb.putInt("defaultScreenId", 2);
|
tinyDB.putInt("defaultScreenId", 2);
|
||||||
mainIntent.putExtra("launchFragmentByLinkHandler", "org");
|
mainIntent.putExtra("launchFragmentByLinkHandler", "org");
|
||||||
ctx.startActivity(mainIntent);
|
ctx.startActivity(mainIntent);
|
||||||
finish();
|
finish();
|
||||||
@ -244,7 +237,7 @@ public class DeepLinksActivity extends BaseActivity {
|
|||||||
|
|
||||||
viewBinding.notification.setOnClickListener(notification -> {
|
viewBinding.notification.setOnClickListener(notification -> {
|
||||||
|
|
||||||
tinyDb.putInt("defaultScreenId", 3);
|
tinyDB.putInt("defaultScreenId", 3);
|
||||||
mainIntent.putExtra("launchFragmentByLinkHandler", "notification");
|
mainIntent.putExtra("launchFragmentByLinkHandler", "notification");
|
||||||
ctx.startActivity(mainIntent);
|
ctx.startActivity(mainIntent);
|
||||||
finish();
|
finish();
|
||||||
@ -252,7 +245,7 @@ public class DeepLinksActivity extends BaseActivity {
|
|||||||
|
|
||||||
viewBinding.explore.setOnClickListener(explore -> {
|
viewBinding.explore.setOnClickListener(explore -> {
|
||||||
|
|
||||||
tinyDb.putInt("defaultScreenId", 4);
|
tinyDB.putInt("defaultScreenId", 4);
|
||||||
mainIntent.putExtra("launchFragmentByLinkHandler", "explore");
|
mainIntent.putExtra("launchFragmentByLinkHandler", "explore");
|
||||||
ctx.startActivity(mainIntent);
|
ctx.startActivity(mainIntent);
|
||||||
finish();
|
finish();
|
||||||
@ -260,7 +253,7 @@ public class DeepLinksActivity extends BaseActivity {
|
|||||||
|
|
||||||
viewBinding.launchApp2.setOnClickListener(launchApp2 -> {
|
viewBinding.launchApp2.setOnClickListener(launchApp2 -> {
|
||||||
|
|
||||||
tinyDb.putInt("defaultScreenId", 0);
|
tinyDB.putInt("defaultScreenId", 0);
|
||||||
ctx.startActivity(mainIntent);
|
ctx.startActivity(mainIntent);
|
||||||
finish();
|
finish();
|
||||||
});
|
});
|
||||||
@ -290,7 +283,9 @@ public class DeepLinksActivity extends BaseActivity {
|
|||||||
.toUri();
|
.toUri();
|
||||||
|
|
||||||
Call<GiteaVersion> callVersion;
|
Call<GiteaVersion> callVersion;
|
||||||
callVersion = RetrofitClient.getInstance(String.valueOf(instanceUrl), ctx).getApiInterface().getGiteaVersion();
|
callVersion = RetrofitClient
|
||||||
|
.getApiInterface(ctx, instanceUrl.toString())
|
||||||
|
.getGiteaVersion();
|
||||||
|
|
||||||
callVersion.enqueue(new Callback<GiteaVersion>() {
|
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) {
|
private void getPullRequest(String url, String token, String repoOwner, String repoName, int index) {
|
||||||
|
|
||||||
Call<PullRequests> call = RetrofitClient
|
Call<PullRequests> call = RetrofitClient
|
||||||
.getInstance(url, ctx)
|
.getApiInterface(ctx, url)
|
||||||
.getApiInterface()
|
|
||||||
.getPullRequestByIndex(token, repoOwner, repoName, index);
|
.getPullRequestByIndex(token, repoOwner, repoName, index);
|
||||||
|
|
||||||
call.enqueue(new Callback<PullRequests>() {
|
call.enqueue(new Callback<PullRequests>() {
|
||||||
@ -367,28 +361,28 @@ public class DeepLinksActivity extends BaseActivity {
|
|||||||
if(prInfo.getHead() != null) {
|
if(prInfo.getHead() != null) {
|
||||||
|
|
||||||
issueIntent.putExtra("prHeadBranch", prInfo.getHead().getRef());
|
issueIntent.putExtra("prHeadBranch", prInfo.getHead().getRef());
|
||||||
tinyDb.putString("prHeadBranch", prInfo.getHead().getRef());
|
tinyDB.putString("prHeadBranch", prInfo.getHead().getRef());
|
||||||
|
|
||||||
if(prInfo.getHead().getRepo() != null) {
|
if(prInfo.getHead().getRepo() != null) {
|
||||||
|
|
||||||
tinyDb.putString("prIsFork", String.valueOf(prInfo.getHead().getRepo().isFork()));
|
tinyDB.putString("prIsFork", String.valueOf(prInfo.getHead().getRepo().isFork()));
|
||||||
tinyDb.putString("prForkFullName", prInfo.getHead().getRepo().getFull_name());
|
tinyDB.putString("prForkFullName", prInfo.getHead().getRepo().getFull_name());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
// pull was done from a deleted fork
|
// pull was done from a deleted fork
|
||||||
tinyDb.putString("prIsFork", "true");
|
tinyDB.putString("prIsFork", "true");
|
||||||
tinyDb.putString("prForkFullName", ctx.getString(R.string.prDeletedFrok));
|
tinyDB.putString("prForkFullName", ctx.getString(R.string.prDeletedFrok));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tinyDb.putString("issueNumber", String.valueOf(index));
|
tinyDB.putString("issueNumber", String.valueOf(index));
|
||||||
tinyDb.putString("prMergeable", String.valueOf(prInfo.isMergeable()));
|
tinyDB.putString("prMergeable", String.valueOf(prInfo.isMergeable()));
|
||||||
tinyDb.putString("issueType", "Pull");
|
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);
|
RepositoriesApi repositoryData = new RepositoriesApi(ctx);
|
||||||
|
|
||||||
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
||||||
@ -396,12 +390,12 @@ public class DeepLinksActivity extends BaseActivity {
|
|||||||
if(count == 0) {
|
if(count == 0) {
|
||||||
|
|
||||||
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
|
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
|
||||||
tinyDb.putLong("repositoryId", id);
|
tinyDB.putLong("repositoryId", id);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
Repository dataRepo = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
|
Repository dataRepo = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
|
||||||
tinyDb.putLong("repositoryId", dataRepo.getRepositoryId());
|
tinyDB.putLong("repositoryId", dataRepo.getRepositoryId());
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.startActivity(issueIntent);
|
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) {
|
private void goToRepoSection(String url, String token, String repoOwner, String repoName, String type) {
|
||||||
|
|
||||||
Call<UserRepositories> call = RetrofitClient
|
Call<UserRepositories> call = RetrofitClient
|
||||||
.getInstance(url, ctx)
|
.getApiInterface(ctx, url)
|
||||||
.getApiInterface()
|
|
||||||
.getUserRepository(token, repoOwner, repoName);
|
.getUserRepository(token, repoOwner, repoName);
|
||||||
|
|
||||||
call.enqueue(new Callback<UserRepositories>() {
|
call.enqueue(new Callback<UserRepositories>() {
|
||||||
@ -444,19 +437,19 @@ public class DeepLinksActivity extends BaseActivity {
|
|||||||
repoIntent.putExtra("goToSection", "yes");
|
repoIntent.putExtra("goToSection", "yes");
|
||||||
repoIntent.putExtra("goToSectionType", type);
|
repoIntent.putExtra("goToSectionType", type);
|
||||||
|
|
||||||
tinyDb.putString("repoFullName", repoInfo.getFullName());
|
tinyDB.putString("repoFullName", repoInfo.getFullName());
|
||||||
if(repoInfo.getPrivateFlag()) {
|
if(repoInfo.getPrivateFlag()) {
|
||||||
|
|
||||||
tinyDb.putString("repoType", getResources().getString(R.string.strPrivate));
|
tinyDB.putString("repoType", getResources().getString(R.string.strPrivate));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
tinyDb.putString("repoType", getResources().getString(R.string.strPublic));
|
tinyDB.putString("repoType", getResources().getString(R.string.strPublic));
|
||||||
}
|
}
|
||||||
tinyDb.putBoolean("isRepoAdmin", repoInfo.getPermissions().isAdmin());
|
tinyDB.putBoolean("isRepoAdmin", repoInfo.getPermissions().isAdmin());
|
||||||
tinyDb.putString("repoBranch", repoInfo.getDefault_branch());
|
tinyDB.putString("repoBranch", repoInfo.getDefault_branch());
|
||||||
|
|
||||||
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
int currentActiveAccountId = tinyDB.getInt("currentActiveAccountId");
|
||||||
RepositoriesApi repositoryData = new RepositoriesApi(ctx);
|
RepositoriesApi repositoryData = new RepositoriesApi(ctx);
|
||||||
|
|
||||||
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
||||||
@ -464,12 +457,12 @@ public class DeepLinksActivity extends BaseActivity {
|
|||||||
if(count == 0) {
|
if(count == 0) {
|
||||||
|
|
||||||
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
|
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
|
||||||
tinyDb.putLong("repositoryId", id);
|
tinyDB.putLong("repositoryId", id);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
|
Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
|
||||||
tinyDb.putLong("repositoryId", data.getRepositoryId());
|
tinyDB.putLong("repositoryId", data.getRepositoryId());
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.startActivity(repoIntent);
|
ctx.startActivity(repoIntent);
|
||||||
|
@ -24,7 +24,6 @@ import org.mian.gitnex.helpers.AlertDialogs;
|
|||||||
import org.mian.gitnex.helpers.AppUtil;
|
import org.mian.gitnex.helpers.AppUtil;
|
||||||
import org.mian.gitnex.helpers.Authorization;
|
import org.mian.gitnex.helpers.Authorization;
|
||||||
import org.mian.gitnex.helpers.StaticGlobalVariables;
|
import org.mian.gitnex.helpers.StaticGlobalVariables;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
import org.mian.gitnex.helpers.Version;
|
import org.mian.gitnex.helpers.Version;
|
||||||
import org.mian.gitnex.models.CreateIssue;
|
import org.mian.gitnex.models.CreateIssue;
|
||||||
@ -44,9 +43,6 @@ import retrofit2.Callback;
|
|||||||
|
|
||||||
public class EditIssueActivity extends BaseActivity implements View.OnClickListener {
|
public class EditIssueActivity extends BaseActivity implements View.OnClickListener {
|
||||||
|
|
||||||
final Context ctx = this;
|
|
||||||
private Context appCtx;
|
|
||||||
private TinyDB tinyDb;
|
|
||||||
private View.OnClickListener onClickListener;
|
private View.OnClickListener onClickListener;
|
||||||
private int resultLimit = StaticGlobalVariables.resultLimitOldGiteaInstances;
|
private int resultLimit = StaticGlobalVariables.resultLimitOldGiteaInstances;
|
||||||
|
|
||||||
@ -61,7 +57,6 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
|||||||
|
|
||||||
List<Milestones> milestonesList = new ArrayList<>();
|
List<Milestones> milestonesList = new ArrayList<>();
|
||||||
|
|
||||||
private String instanceUrl;
|
|
||||||
private String loginUid;
|
private String loginUid;
|
||||||
private String instanceToken;
|
private String instanceToken;
|
||||||
private String repoOwner;
|
private String repoOwner;
|
||||||
@ -78,19 +73,16 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
tinyDb = new TinyDB(appCtx);
|
|
||||||
|
|
||||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
|
|
||||||
instanceUrl = tinyDb.getString("instanceUrl");
|
loginUid = tinyDB.getString("loginUid");
|
||||||
loginUid = tinyDb.getString("loginUid");
|
instanceToken = "token " + tinyDB.getString(loginUid + "-token");
|
||||||
instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
String repoFullName = tinyDB.getString("repoFullName");
|
||||||
String repoFullName = tinyDb.getString("repoFullName");
|
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
repoOwner = parts[0];
|
repoOwner = parts[0];
|
||||||
repoName = parts[1];
|
repoName = parts[1];
|
||||||
issueIndex = Integer.parseInt(tinyDb.getString("issueNumber"));
|
issueIndex = Integer.parseInt(tinyDB.getString("issueNumber"));
|
||||||
|
|
||||||
ImageView closeActivity = findViewById(R.id.close);
|
ImageView closeActivity = findViewById(R.id.close);
|
||||||
editIssueButton = findViewById(R.id.editIssueButton);
|
editIssueButton = findViewById(R.id.editIssueButton);
|
||||||
@ -100,7 +92,7 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
|||||||
editIssueDueDate = findViewById(R.id.editIssueDueDate);
|
editIssueDueDate = findViewById(R.id.editIssueDueDate);
|
||||||
|
|
||||||
// if gitea is 1.12 or higher use the new limit
|
// 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;
|
resultLimit = StaticGlobalVariables.resultLimitNewGiteaInstances;
|
||||||
}
|
}
|
||||||
@ -128,9 +120,9 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
|||||||
editIssueDueDate.setOnClickListener(this);
|
editIssueDueDate.setOnClickListener(this);
|
||||||
editIssueButton.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)));
|
toolbar_title.setText(getString(R.string.editPrNavHeader, String.valueOf(issueIndex)));
|
||||||
}
|
}
|
||||||
@ -141,7 +133,7 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
|||||||
}
|
}
|
||||||
|
|
||||||
disableProcessButton();
|
disableProcessButton();
|
||||||
getIssue(instanceUrl, instanceToken, loginUid, repoOwner, repoName, issueIndex, resultLimit);
|
getIssue(instanceToken, loginUid, repoOwner, repoName, issueIndex, resultLimit);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initCloseListener() {
|
private void initCloseListener() {
|
||||||
@ -179,17 +171,16 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
|||||||
}
|
}
|
||||||
|
|
||||||
disableProcessButton();
|
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);
|
CreateIssue issueData = new CreateIssue(title, description, dueDate, milestoneId);
|
||||||
|
|
||||||
Call<JsonElement> call = RetrofitClient
|
Call<JsonElement> call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
.patchIssue(Authorization.get(ctx), repoOwner, repoName, issueIndex, issueData);
|
||||||
.patchIssue(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, issueIndex, issueData);
|
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonElement>() {
|
call.enqueue(new Callback<JsonElement>() {
|
||||||
|
|
||||||
@ -198,7 +189,7 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
|||||||
|
|
||||||
if(response.code() == 201) {
|
if(response.code() == 201) {
|
||||||
|
|
||||||
if(tinyDb.getString("issueType").equalsIgnoreCase("Pull")) {
|
if(tinyDB.getString("issueType").equalsIgnoreCase("Pull")) {
|
||||||
|
|
||||||
Toasty.success(ctx, getString(R.string.editPrSuccessMessage));
|
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));
|
Toasty.success(ctx, getString(R.string.editIssueSuccessMessage));
|
||||||
}
|
}
|
||||||
|
|
||||||
tinyDb.putBoolean("issueEdited", true);
|
tinyDB.putBoolean("issueEdited", true);
|
||||||
tinyDb.putBoolean("resumeIssues", true);
|
tinyDB.putBoolean("resumeIssues", true);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
else if(response.code() == 401) {
|
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
|
Call<Issues> call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
.getIssueByIndex(Authorization.get(ctx), repoOwner, repoName, issueIndex);
|
||||||
.getIssueByIndex(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, issueIndex);
|
|
||||||
|
|
||||||
call.enqueue(new Callback<Issues>() {
|
call.enqueue(new Callback<Issues>() {
|
||||||
|
|
||||||
@ -285,9 +275,8 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
|||||||
if(response.body().getId() > 0) {
|
if(response.body().getId() > 0) {
|
||||||
|
|
||||||
Call<List<Milestones>> call_ = RetrofitClient
|
Call<List<Milestones>> call_ = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
.getMilestones(Authorization.get(ctx), repoOwner, repoName, 1, resultLimit, msState);
|
||||||
.getMilestones(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, 1, resultLimit, msState);
|
|
||||||
|
|
||||||
int checkMilestoneId = currentMilestoneId;
|
int checkMilestoneId = currentMilestoneId;
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package org.mian.gitnex.activities;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -14,7 +13,6 @@ import org.mian.gitnex.R;
|
|||||||
import org.mian.gitnex.adapters.FilesDiffAdapter;
|
import org.mian.gitnex.adapters.FilesDiffAdapter;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.helpers.AlertDialogs;
|
import org.mian.gitnex.helpers.AlertDialogs;
|
||||||
import org.mian.gitnex.helpers.AppUtil;
|
|
||||||
import org.mian.gitnex.helpers.ParseDiff;
|
import org.mian.gitnex.helpers.ParseDiff;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
import org.mian.gitnex.helpers.TinyDB;
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
@ -36,8 +34,6 @@ public class FileDiffActivity extends BaseActivity {
|
|||||||
private TextView toolbarTitle;
|
private TextView toolbarTitle;
|
||||||
private ListView mListView;
|
private ListView mListView;
|
||||||
private ProgressBar mProgressBar;
|
private ProgressBar mProgressBar;
|
||||||
final Context ctx = this;
|
|
||||||
private Context appCtx;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getLayoutResourceId() {
|
protected int getLayoutResourceId() {
|
||||||
@ -49,12 +45,11 @@ public class FileDiffActivity extends BaseActivity {
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
|
|
||||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
final TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||||
String repoFullName = tinyDb.getString("repoFullName");
|
String repoFullName = tinyDb.getString("repoFullName");
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
final String repoOwner = parts[0];
|
final String repoOwner = parts[0];
|
||||||
@ -77,29 +72,21 @@ public class FileDiffActivity extends BaseActivity {
|
|||||||
|
|
||||||
String pullIndex = tinyDb.getString("issueNumber");
|
String pullIndex = tinyDb.getString("issueNumber");
|
||||||
|
|
||||||
boolean apiCall = true;
|
boolean apiCall = !new Version(tinyDb.getString("giteaVersion")).less("1.13.0");
|
||||||
String instanceUrl = tinyDb.getString("instanceUrl");
|
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;
|
Call<ResponseBody> call;
|
||||||
if(apiCall) {
|
if(apiCall) {
|
||||||
|
|
||||||
call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().getPullDiffContent(token, owner, repo, pullIndex);
|
call = RetrofitClient.getApiInterface(ctx).getPullDiffContent(token, owner, repo, pullIndex);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
call = RetrofitClient.getInstance(instanceUrl, ctx).getWebInterface().getPullDiffContent(owner, repo, pullIndex);
|
call = RetrofitClient.getWebInterface(ctx).getPullDiffContent(owner, repo, pullIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
call.enqueue(new Callback<ResponseBody>() {
|
call.enqueue(new Callback<ResponseBody>() {
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package org.mian.gitnex.activities;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
@ -9,7 +8,6 @@ import android.graphics.drawable.BitmapDrawable;
|
|||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.Spanned;
|
|
||||||
import android.text.method.ScrollingMovementMethod;
|
import android.text.method.ScrollingMovementMethod;
|
||||||
import android.util.Base64;
|
import android.util.Base64;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@ -28,7 +26,6 @@ import androidx.activity.result.ActivityResultLauncher;
|
|||||||
import androidx.activity.result.contract.ActivityResultContracts;
|
import androidx.activity.result.contract.ActivityResultContracts;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.widget.Toolbar;
|
import androidx.appcompat.widget.Toolbar;
|
||||||
import androidx.core.content.ContextCompat;
|
|
||||||
import com.github.barteksc.pdfviewer.PDFView;
|
import com.github.barteksc.pdfviewer.PDFView;
|
||||||
import com.github.barteksc.pdfviewer.util.FitPolicy;
|
import com.github.barteksc.pdfviewer.util.FitPolicy;
|
||||||
import com.github.chrisbanes.photoview.PhotoView;
|
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.fragments.BottomSheetFileViewerFragment;
|
||||||
import org.mian.gitnex.helpers.AlertDialogs;
|
import org.mian.gitnex.helpers.AlertDialogs;
|
||||||
import org.mian.gitnex.helpers.AppUtil;
|
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.Toasty;
|
||||||
import org.mian.gitnex.helpers.highlightjs.HighlightJsView;
|
import org.mian.gitnex.helpers.highlightjs.HighlightJsView;
|
||||||
import org.mian.gitnex.helpers.highlightjs.models.Theme;
|
import org.mian.gitnex.helpers.highlightjs.models.Theme;
|
||||||
@ -48,24 +45,7 @@ import java.io.IOException;
|
|||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Objects;
|
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.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
|
|
||||||
@ -80,8 +60,6 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
private LinearLayout singleFileContentsFrame;
|
private LinearLayout singleFileContentsFrame;
|
||||||
private HighlightJsView singleCodeContents;
|
private HighlightJsView singleCodeContents;
|
||||||
private PhotoView imageView;
|
private PhotoView imageView;
|
||||||
final Context ctx = this;
|
|
||||||
private Context appCtx;
|
|
||||||
private ProgressBar mProgressBar;
|
private ProgressBar mProgressBar;
|
||||||
private byte[] imageData;
|
private byte[] imageData;
|
||||||
private PDFView pdfView;
|
private PDFView pdfView;
|
||||||
@ -91,7 +69,6 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
private String singleFileName;
|
private String singleFileName;
|
||||||
private String fileSha;
|
private String fileSha;
|
||||||
private AppUtil appUtil;
|
private AppUtil appUtil;
|
||||||
private TinyDB tinyDb;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getLayoutResourceId() {
|
protected int getLayoutResourceId() {
|
||||||
@ -103,23 +80,20 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
appUtil = new AppUtil();
|
appUtil = new AppUtil();
|
||||||
tinyDb = new TinyDB(appCtx);
|
|
||||||
|
|
||||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
|
|
||||||
String repoFullName = tinyDb.getString("repoFullName");
|
String repoFullName = tinyDB.getString("repoFullName");
|
||||||
String repoBranch = tinyDb.getString("repoBranch");
|
String repoBranch = tinyDB.getString("repoBranch");
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
final String repoOwner = parts[0];
|
final String repoOwner = parts[0];
|
||||||
final String repoName = parts[1];
|
final String repoName = parts[1];
|
||||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
final String loginUid = tinyDB.getString("loginUid");
|
||||||
final String loginUid = tinyDb.getString("loginUid");
|
final String instanceToken = "token " + tinyDB.getString(loginUid + "-token");
|
||||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
|
||||||
|
|
||||||
tinyDb.putBoolean("enableMarkdownInFileView", false);
|
tinyDB.putBoolean("enableMarkdownInFileView", false);
|
||||||
|
|
||||||
ImageView closeActivity = findViewById(R.id.close);
|
ImageView closeActivity = findViewById(R.id.close);
|
||||||
singleFileContents = findViewById(R.id.singleFileContents);
|
singleFileContents = findViewById(R.id.singleFileContents);
|
||||||
@ -138,7 +112,7 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
initCloseListener();
|
initCloseListener();
|
||||||
closeActivity.setOnClickListener(onClickListener);
|
closeActivity.setOnClickListener(onClickListener);
|
||||||
|
|
||||||
tinyDb.putString("downloadFileContents", "");
|
tinyDB.putString("downloadFileContents", "");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
@ -153,7 +127,7 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
|
|
||||||
toolbar_title.setText(singleFileName);
|
toolbar_title.setText(singleFileName);
|
||||||
|
|
||||||
getSingleFileContents(instanceUrl, instanceToken, repoOwner, repoName, singleFileName, repoBranch);
|
getSingleFileContents(instanceToken, repoOwner, repoName, singleFileName, repoBranch);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -161,26 +135,25 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
|
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
String repoFullName = tinyDb.getString("repoFullName");
|
String repoFullName = tinyDB.getString("repoFullName");
|
||||||
String repoBranch = tinyDb.getString("repoBranch");
|
String repoBranch = tinyDB.getString("repoBranch");
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
String repoOwner = parts[0];
|
String repoOwner = parts[0];
|
||||||
String repoName = parts[1];
|
String repoName = parts[1];
|
||||||
String instanceUrl = tinyDb.getString("instanceUrl");
|
String loginUid = tinyDB.getString("loginUid");
|
||||||
String loginUid = tinyDb.getString("loginUid");
|
String instanceToken = "token " + tinyDB.getString(loginUid + "-token");
|
||||||
String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
|
||||||
|
|
||||||
if(tinyDb.getBoolean("fileModified")) {
|
if(tinyDB.getBoolean("fileModified")) {
|
||||||
|
|
||||||
getSingleFileContents(instanceUrl, instanceToken, repoOwner, repoName, singleFileName, repoBranch);
|
getSingleFileContents(instanceToken, repoOwner, repoName, singleFileName, repoBranch);
|
||||||
tinyDb.putBoolean("fileModified", false);
|
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>() {
|
call.enqueue(new Callback<Files>() {
|
||||||
|
|
||||||
@ -199,8 +172,8 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
fileSha = response.body().getSha();
|
fileSha = response.body().getSha();
|
||||||
|
|
||||||
// download file meta
|
// download file meta
|
||||||
tinyDb.putString("downloadFileName", filename);
|
tinyDB.putString("downloadFileName", filename);
|
||||||
tinyDb.putString("downloadFileContents", response.body().getContent());
|
tinyDB.putString("downloadFileContents", response.body().getContent());
|
||||||
|
|
||||||
if(appUtil.imageExtension(fileExtension)) { // file is image
|
if(appUtil.imageExtension(fileExtension)) { // file is image
|
||||||
|
|
||||||
@ -220,7 +193,7 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
pdfViewFrame.setVisibility(View.GONE);
|
pdfViewFrame.setVisibility(View.GONE);
|
||||||
singleCodeContents.setVisibility(View.VISIBLE);
|
singleCodeContents.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
switch(tinyDb.getInt("fileviewerSourceCodeThemeId")) {
|
switch(tinyDB.getInt("fileviewerSourceCodeThemeId")) {
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
|
|
||||||
@ -256,7 +229,7 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
singleCodeContents.setVisibility(View.GONE);
|
singleCodeContents.setVisibility(View.GONE);
|
||||||
pdfViewFrame.setVisibility(View.VISIBLE);
|
pdfViewFrame.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
pdfNightMode = tinyDb.getBoolean("enablePdfMode");
|
pdfNightMode = tinyDB.getBoolean("enablePdfMode");
|
||||||
|
|
||||||
decodedPdf = Base64.decode(response.body().getContent(), Base64.DEFAULT);
|
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();
|
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) {
|
else if(id == R.id.markdown) {
|
||||||
|
|
||||||
final Markwon markwon = Markwon.builder(Objects.requireNonNull(ctx)).usePlugin(CorePlugin.create())
|
new Markdown(ctx, appUtil.decodeBase64(tinyDB.getString("downloadFileContents")), singleFileContents);
|
||||||
.usePlugin(ImagesPlugin.create(plugin -> {
|
|
||||||
plugin.addSchemeHandler(new SchemeHandler() {
|
|
||||||
|
|
||||||
@NonNull
|
if(!tinyDB.getBoolean("enableMarkdownInFileView")) {
|
||||||
@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")) {
|
|
||||||
|
|
||||||
singleCodeContents.setVisibility(View.GONE);
|
singleCodeContents.setVisibility(View.GONE);
|
||||||
singleFileContentsFrame.setVisibility(View.VISIBLE);
|
singleFileContentsFrame.setVisibility(View.VISIBLE);
|
||||||
singleFileContents.setVisibility(View.VISIBLE);
|
singleFileContents.setVisibility(View.VISIBLE);
|
||||||
Spanned bodyWithMD = markwon.toMarkdown(appUtil.decodeBase64(tinyDb.getString("downloadFileContents")));
|
tinyDB.putBoolean("enableMarkdownInFileView", true);
|
||||||
markwon.setParsedMarkdown(singleFileContents, bodyWithMD);
|
|
||||||
tinyDb.putBoolean("enableMarkdownInFileView", true);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
singleCodeContents.setVisibility(View.VISIBLE);
|
singleCodeContents.setVisibility(View.VISIBLE);
|
||||||
singleFileContentsFrame.setVisibility(View.GONE);
|
singleFileContentsFrame.setVisibility(View.GONE);
|
||||||
singleFileContents.setVisibility(View.GONE);
|
singleFileContents.setVisibility(View.GONE);
|
||||||
singleCodeContents.setSource(appUtil.decodeBase64(tinyDb.getString("downloadFileContents")));
|
singleCodeContents.setSource(appUtil.decodeBase64(tinyDB.getString("downloadFileContents")));
|
||||||
tinyDb.putBoolean("enableMarkdownInFileView", false);
|
tinyDB.putBoolean("enableMarkdownInFileView", false);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -435,7 +360,7 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
if("deleteFile".equals(text)) {
|
if("deleteFile".equals(text)) {
|
||||||
|
|
||||||
String fileExtension = FileUtils.getExtension(singleFileName);
|
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 intent = new Intent(ctx, CreateFileActivity.class);
|
||||||
intent.putExtra("fileAction", 1);
|
intent.putExtra("fileAction", 1);
|
||||||
intent.putExtra("filePath", singleFileName);
|
intent.putExtra("filePath", singleFileName);
|
||||||
@ -456,7 +381,7 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
if("editFile".equals(text)) {
|
if("editFile".equals(text)) {
|
||||||
|
|
||||||
String fileExtension = FileUtils.getExtension(singleFileName);
|
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 intent = new Intent(ctx, CreateFileActivity.class);
|
||||||
intent.putExtra("fileAction", 2);
|
intent.putExtra("fileAction", 2);
|
||||||
intent.putExtra("filePath", singleFileName);
|
intent.putExtra("filePath", singleFileName);
|
||||||
@ -478,9 +403,9 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
|
|
||||||
private void requestFileDownload() {
|
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);
|
Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
|
||||||
|
|
||||||
@ -514,7 +439,7 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
assert uri != null;
|
assert uri != null;
|
||||||
OutputStream outputStream = getContentResolver().openOutputStream(uri);
|
OutputStream outputStream = getContentResolver().openOutputStream(uri);
|
||||||
|
|
||||||
byte[] dataAsBytes = Base64.decode(tinyDb.getString("downloadFileContents"), 0);
|
byte[] dataAsBytes = Base64.decode(tinyDB.getString("downloadFileContents"), 0);
|
||||||
|
|
||||||
assert outputStream != null;
|
assert outputStream != null;
|
||||||
outputStream.write(dataAsBytes);
|
outputStream.write(dataAsBytes);
|
||||||
|
@ -1,19 +1,15 @@
|
|||||||
package org.mian.gitnex.activities;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.text.Spanned;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@ -26,7 +22,6 @@ import android.widget.LinearLayout;
|
|||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.ScrollView;
|
import android.widget.ScrollView;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.core.content.ContextCompat;
|
|
||||||
import androidx.lifecycle.ViewModelProvider;
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
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.ClickListener;
|
||||||
import org.mian.gitnex.helpers.ColorInverter;
|
import org.mian.gitnex.helpers.ColorInverter;
|
||||||
import org.mian.gitnex.helpers.LabelWidthCalculator;
|
import org.mian.gitnex.helpers.LabelWidthCalculator;
|
||||||
|
import org.mian.gitnex.helpers.Markdown;
|
||||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||||
import org.mian.gitnex.helpers.TimeHelper;
|
import org.mian.gitnex.helpers.TimeHelper;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
import org.mian.gitnex.helpers.TinyDB;
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
import org.mian.gitnex.helpers.UserMentions;
|
|
||||||
import org.mian.gitnex.helpers.Version;
|
import org.mian.gitnex.helpers.Version;
|
||||||
import org.mian.gitnex.models.Collaborators;
|
import org.mian.gitnex.models.Collaborators;
|
||||||
import org.mian.gitnex.models.Issues;
|
import org.mian.gitnex.models.Issues;
|
||||||
@ -67,27 +62,11 @@ import org.mian.gitnex.viewmodels.IssueCommentsViewModel;
|
|||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Objects;
|
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.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
@ -99,13 +78,7 @@ import retrofit2.Response;
|
|||||||
public class IssueDetailActivity extends BaseActivity implements LabelsListAdapter.LabelsListAdapterListener, AssigneesListAdapter.AssigneesListAdapterListener, BottomSheetSingleIssueFragment.BottomSheetListener {
|
public class IssueDetailActivity extends BaseActivity implements LabelsListAdapter.LabelsListAdapterListener, AssigneesListAdapter.AssigneesListAdapterListener, BottomSheetSingleIssueFragment.BottomSheetListener {
|
||||||
|
|
||||||
private IssueCommentsAdapter adapter;
|
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 repoOwner;
|
||||||
private String repoName;
|
private String repoName;
|
||||||
private int issueIndex;
|
private int issueIndex;
|
||||||
@ -137,21 +110,16 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
tinyDb = new TinyDB(appCtx);
|
|
||||||
|
|
||||||
viewBinding = ActivityIssueDetailBinding.inflate(getLayoutInflater());
|
viewBinding = ActivityIssueDetailBinding.inflate(getLayoutInflater());
|
||||||
View view = viewBinding.getRoot();
|
View view = viewBinding.getRoot();
|
||||||
setContentView(view);
|
setContentView(view);
|
||||||
|
|
||||||
instanceUrl = tinyDb.getString("instanceUrl");
|
String repoFullName = tinyDB.getString("repoFullName");
|
||||||
loginUid = tinyDb.getString("loginUid");
|
|
||||||
instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
|
||||||
String repoFullName = tinyDb.getString("repoFullName");
|
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
repoOwner = parts[0];
|
repoOwner = parts[0];
|
||||||
repoName = parts[1];
|
repoName = parts[1];
|
||||||
issueIndex = Integer.parseInt(tinyDb.getString("issueNumber"));
|
issueIndex = Integer.parseInt(tinyDB.getString("issueNumber"));
|
||||||
|
|
||||||
setSupportActionBar(viewBinding.toolbar);
|
setSupportActionBar(viewBinding.toolbar);
|
||||||
Objects.requireNonNull(getSupportActionBar()).setTitle(repoName);
|
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);
|
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(viewBinding.recyclerView.getContext(), DividerItemDecoration.VERTICAL);
|
||||||
viewBinding.recyclerView.addItemDecoration(dividerItemDecoration);
|
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);
|
labelsAdapter = new LabelsListAdapter(labelsList, IssueDetailActivity.this, currentLabelsIds);
|
||||||
assigneesAdapter = new AssigneesListAdapter(ctx, assigneesList, IssueDetailActivity.this, currentAssignees);
|
assigneesAdapter = new AssigneesListAdapter(ctx, assigneesList, IssueDetailActivity.this, currentAssignees);
|
||||||
LabelsActions.getCurrentIssueLabels(ctx, instanceUrl, loginUid, instanceToken, repoOwner, repoName, issueIndex, currentLabelsIds);
|
LabelsActions.getCurrentIssueLabels(ctx, repoOwner, repoName, issueIndex, currentLabelsIds);
|
||||||
AssigneesActions.getCurrentIssueAssignees(ctx, instanceUrl, loginUid, instanceToken, repoOwner, repoName, issueIndex, currentAssignees);
|
AssigneesActions.getCurrentIssueAssignees(ctx, repoOwner, repoName, issueIndex, currentAssignees);
|
||||||
|
|
||||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
|
|
||||||
@ -198,14 +172,14 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||||||
|
|
||||||
viewBinding.pullToRefresh.setRefreshing(false);
|
viewBinding.pullToRefresh.setRefreshing(false);
|
||||||
IssueCommentsViewModel
|
IssueCommentsViewModel
|
||||||
.loadIssueComments(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, issueIndex,
|
.loadIssueComments(Authorization.get(ctx), repoOwner, repoName, issueIndex,
|
||||||
ctx);
|
ctx);
|
||||||
|
|
||||||
}, 500));
|
}, 500));
|
||||||
|
|
||||||
Typeface myTypeface;
|
Typeface myTypeface;
|
||||||
|
|
||||||
switch(tinyDb.getInt("customFontId", -1)) {
|
switch(tinyDB.getInt("customFontId", -1)) {
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
myTypeface = Typeface.createFromAsset(Objects.requireNonNull(ctx).getAssets(), "fonts/manroperegular.ttf");
|
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.setTypeface(myTypeface);
|
||||||
viewBinding.toolbarTitle.setText(repoName);
|
viewBinding.toolbarTitle.setText(repoName);
|
||||||
|
|
||||||
getSingleIssue(instanceUrl, instanceToken, repoOwner, repoName, issueIndex, loginUid);
|
getSingleIssue(repoOwner, repoName, issueIndex);
|
||||||
fetchDataAsync(instanceUrl, instanceToken, repoOwner, repoName, issueIndex, loginUid);
|
fetchDataAsync(repoOwner, repoName, issueIndex);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -295,7 +269,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||||||
});
|
});
|
||||||
|
|
||||||
dialogAssignees.show();
|
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() {
|
public void showLabels() {
|
||||||
@ -332,7 +306,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||||||
});
|
});
|
||||||
|
|
||||||
dialogLabels.show();
|
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() {
|
private void updateIssueAssignees() {
|
||||||
@ -342,9 +316,8 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||||||
Call<JsonElement> call3;
|
Call<JsonElement> call3;
|
||||||
|
|
||||||
call3 = RetrofitClient
|
call3 = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
.patchIssueAssignees(Authorization.get(ctx), repoOwner, repoName, issueIndex, updateAssigneeJson);
|
||||||
.patchIssueAssignees(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, issueIndex, updateAssigneeJson);
|
|
||||||
|
|
||||||
call3.enqueue(new Callback<JsonElement>() {
|
call3.enqueue(new Callback<JsonElement>() {
|
||||||
|
|
||||||
@ -359,9 +332,9 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||||||
|
|
||||||
viewBinding.frameAssignees.removeAllViews();
|
viewBinding.frameAssignees.removeAllViews();
|
||||||
viewBinding.frameLabels.removeAllViews();
|
viewBinding.frameLabels.removeAllViews();
|
||||||
getSingleIssue(instanceUrl, instanceToken, repoOwner, repoName, issueIndex, loginUid);
|
getSingleIssue(repoOwner, repoName, issueIndex);
|
||||||
currentAssignees.clear();
|
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) {
|
else if(response2.code() == 401) {
|
||||||
|
|
||||||
@ -398,9 +371,8 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||||||
Labels patchIssueLabels = new Labels(labelsIds);
|
Labels patchIssueLabels = new Labels(labelsIds);
|
||||||
|
|
||||||
Call<JsonElement> call = RetrofitClient
|
Call<JsonElement> call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
.updateIssueLabels(Authorization.get(ctx), repoOwner, repoName, issueIndex, patchIssueLabels);
|
||||||
.updateIssueLabels(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, issueIndex, patchIssueLabels);
|
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonElement>() {
|
call.enqueue(new Callback<JsonElement>() {
|
||||||
|
|
||||||
@ -414,9 +386,9 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||||||
|
|
||||||
viewBinding.frameAssignees.removeAllViews();
|
viewBinding.frameAssignees.removeAllViews();
|
||||||
viewBinding.frameLabels.removeAllViews();
|
viewBinding.frameLabels.removeAllViews();
|
||||||
getSingleIssue(instanceUrl, instanceToken, repoOwner, repoName, issueIndex, loginUid);
|
getSingleIssue(repoOwner, repoName, issueIndex);
|
||||||
currentLabelsIds.clear();
|
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) {
|
else if(response.code() == 401) {
|
||||||
|
|
||||||
@ -483,61 +455,61 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||||||
|
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
if(tinyDb.getBoolean("commentPosted")) {
|
if(tinyDB.getBoolean("commentPosted")) {
|
||||||
|
|
||||||
viewBinding.scrollViewComments.post(() -> {
|
viewBinding.scrollViewComments.post(() -> {
|
||||||
|
|
||||||
IssueCommentsViewModel
|
IssueCommentsViewModel
|
||||||
.loadIssueComments(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, issueIndex,
|
.loadIssueComments(Authorization.get(ctx), repoOwner, repoName, issueIndex,
|
||||||
ctx);
|
ctx);
|
||||||
|
|
||||||
new Handler(Looper.getMainLooper()).postDelayed(() -> viewBinding.scrollViewComments.fullScroll(ScrollView.FOCUS_DOWN), 1000);
|
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(() -> {
|
viewBinding.scrollViewComments.post(() -> {
|
||||||
|
|
||||||
IssueCommentsViewModel
|
IssueCommentsViewModel
|
||||||
.loadIssueComments(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, issueIndex,
|
.loadIssueComments(Authorization.get(ctx), repoOwner, repoName, issueIndex,
|
||||||
ctx);
|
ctx);
|
||||||
tinyDb.putBoolean("commentEdited", false);
|
tinyDB.putBoolean("commentEdited", false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tinyDb.getBoolean("singleIssueUpdate")) {
|
if(tinyDB.getBoolean("singleIssueUpdate")) {
|
||||||
|
|
||||||
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||||
|
|
||||||
viewBinding.frameAssignees.removeAllViews();
|
viewBinding.frameAssignees.removeAllViews();
|
||||||
viewBinding.frameLabels.removeAllViews();
|
viewBinding.frameLabels.removeAllViews();
|
||||||
getSingleIssue(instanceUrl, instanceToken, repoOwner, repoName, issueIndex, loginUid);
|
getSingleIssue(repoOwner, repoName, issueIndex);
|
||||||
tinyDb.putBoolean("singleIssueUpdate", false);
|
tinyDB.putBoolean("singleIssueUpdate", false);
|
||||||
|
|
||||||
}, 500);
|
}, 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tinyDb.getBoolean("issueEdited")) {
|
if(tinyDB.getBoolean("issueEdited")) {
|
||||||
|
|
||||||
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||||
|
|
||||||
viewBinding.frameAssignees.removeAllViews();
|
viewBinding.frameAssignees.removeAllViews();
|
||||||
viewBinding.frameLabels.removeAllViews();
|
viewBinding.frameLabels.removeAllViews();
|
||||||
getSingleIssue(instanceUrl, instanceToken, repoOwner, repoName, issueIndex, loginUid);
|
getSingleIssue(repoOwner, repoName, issueIndex);
|
||||||
tinyDb.putBoolean("issueEdited", false);
|
tinyDB.putBoolean("issueEdited", false);
|
||||||
|
|
||||||
}, 500);
|
}, 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);
|
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 -> {
|
.observe(this, issueCommentsMain -> {
|
||||||
|
|
||||||
assert issueCommentsMain != null;
|
assert issueCommentsMain != null;
|
||||||
@ -547,16 +519,17 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||||||
viewBinding.divider.setVisibility(View.VISIBLE);
|
viewBinding.divider.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
adapter = new IssueCommentsAdapter(ctx, getSupportFragmentManager(), issueCommentsMain);
|
adapter = new IssueCommentsAdapter(ctx, issueCommentsMain, getSupportFragmentManager(), this::onResume);
|
||||||
viewBinding.recyclerView.setAdapter(adapter);
|
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);
|
final TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||||
Call<Issues> call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface()
|
Call<Issues> call = RetrofitClient.getApiInterface(ctx)
|
||||||
.getIssueByIndex(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, issueIndex);
|
.getIssueByIndex(Authorization.get(ctx), repoOwner, repoName, issueIndex);
|
||||||
|
|
||||||
call.enqueue(new Callback<Issues>() {
|
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);
|
viewBinding.issuePrState.setImageResource(R.drawable.ic_issue_closed_red);
|
||||||
}
|
}
|
||||||
|
|
||||||
final Markwon markwon = Markwon.builder(Objects.requireNonNull(ctx)).usePlugin(CorePlugin.create())
|
TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||||
.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);
|
|
||||||
final String locale = tinyDb.getString("locale");
|
final String locale = tinyDb.getString("locale");
|
||||||
final String timeFormat = tinyDb.getString("dateFormat");
|
final String timeFormat = tinyDb.getString("dateFormat");
|
||||||
tinyDb.putString("issueState", singleIssue.getState());
|
tinyDb.putString("issueState", singleIssue.getState());
|
||||||
@ -645,8 +576,8 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||||||
.getString(R.string.hash) + singleIssue.getNumber() + "</font>";
|
.getString(R.string.hash) + singleIssue.getNumber() + "</font>";
|
||||||
viewBinding.issueTitle.setText(Html.fromHtml(issueNumber_ + " " + singleIssue.getTitle()));
|
viewBinding.issueTitle.setText(Html.fromHtml(issueNumber_ + " " + singleIssue.getTitle()));
|
||||||
String cleanIssueDescription = singleIssue.getBody().trim();
|
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();
|
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")) {
|
if(new Version(tinyDb.getString("giteaVersion")).higherOrEqual("1.12.0")) {
|
||||||
|
|
||||||
Call<WatchInfo> call2 = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface()
|
Call<WatchInfo> call2 = RetrofitClient.getApiInterface(appCtx)
|
||||||
.checkIssueWatchStatus(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, issueIndex);
|
.checkIssueWatchStatus(Authorization.get(ctx), repoOwner, repoName, issueIndex);
|
||||||
|
|
||||||
call2.enqueue(new Callback<WatchInfo>() {
|
call2.enqueue(new Callback<WatchInfo>() {
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package org.mian.gitnex.activities;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@ -46,10 +45,6 @@ public class LoginActivity extends BaseActivity {
|
|||||||
|
|
||||||
private enum LoginType {BASIC, TOKEN}
|
private enum LoginType {BASIC, TOKEN}
|
||||||
|
|
||||||
private Context appCtx;
|
|
||||||
private Context ctx = this;
|
|
||||||
private TinyDB tinyDB;
|
|
||||||
|
|
||||||
private Button loginButton;
|
private Button loginButton;
|
||||||
private EditText instanceUrlET, loginUidET, loginPassword, otpCode, loginTokenCode;
|
private EditText instanceUrlET, loginUidET, loginPassword, otpCode, loginTokenCode;
|
||||||
private AutoCompleteTextView protocolSpinner;
|
private AutoCompleteTextView protocolSpinner;
|
||||||
@ -67,9 +62,7 @@ public class LoginActivity extends BaseActivity {
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
|
|
||||||
tinyDB = new TinyDB(appCtx);
|
|
||||||
NetworkObserver networkMonitor = new NetworkObserver(ctx);
|
NetworkObserver networkMonitor = new NetworkObserver(ctx);
|
||||||
|
|
||||||
loginButton = findViewById(R.id.login_button);
|
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;
|
int loginOTP = (otpCode.length() > 0) ? Integer.parseInt(otpCode.getText().toString().trim()) : 0;
|
||||||
tinyDB.putString("loginUid", loginUid);
|
tinyDB.putString("loginUid", loginUid);
|
||||||
|
|
||||||
versionCheck(instanceUrl.toString(), loginUid, loginPass, loginOTP, loginToken, loginType);
|
versionCheck(loginUid, loginPass, loginOTP, loginToken, loginType);
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -222,7 +215,7 @@ public class LoginActivity extends BaseActivity {
|
|||||||
return;
|
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) {
|
final LoginType loginType) {
|
||||||
|
|
||||||
Call<GiteaVersion> callVersion;
|
Call<GiteaVersion> callVersion;
|
||||||
|
|
||||||
if(!loginToken.equals("")) {
|
if(!loginToken.equals("")) {
|
||||||
|
|
||||||
callVersion = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().getGiteaVersionWithToken("token " + loginToken);
|
callVersion = RetrofitClient.getApiInterface(appCtx).getGiteaVersionWithToken("token " + loginToken);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
String credential = Credentials.basic(loginUid, loginPass, StandardCharsets.UTF_8);
|
String credential = Credentials.basic(loginUid, loginPass, StandardCharsets.UTF_8);
|
||||||
|
|
||||||
callVersion =
|
callVersion =
|
||||||
(loginOTP != 0) ? RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().getGiteaVersionWithOTP(credential, loginOTP) :
|
(loginOTP != 0) ? RetrofitClient.getApiInterface(appCtx).getGiteaVersionWithOTP(credential, loginOTP) :
|
||||||
RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().getGiteaVersionWithBasic(credential);
|
RetrofitClient.getApiInterface(appCtx).getGiteaVersionWithBasic(credential);
|
||||||
}
|
}
|
||||||
|
|
||||||
callVersion.enqueue(new Callback<GiteaVersion>() {
|
callVersion.enqueue(new Callback<GiteaVersion>() {
|
||||||
@ -287,7 +280,7 @@ public class LoginActivity extends BaseActivity {
|
|||||||
alertDialogBuilder.setPositiveButton(getString(R.string.textContinue), (dialog, which) -> {
|
alertDialogBuilder.setPositiveButton(getString(R.string.textContinue), (dialog, which) -> {
|
||||||
|
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
login(loginType, instanceUrl, loginUid, loginPass, loginOTP, loginToken);
|
login(loginType, loginUid, loginPass, loginOTP, loginToken);
|
||||||
});
|
});
|
||||||
|
|
||||||
alertDialogBuilder.create().show();
|
alertDialogBuilder.create().show();
|
||||||
@ -295,34 +288,34 @@ public class LoginActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
else if(gitea_version.lessOrEqual(getString(R.string.versionHigh))) {
|
else if(gitea_version.lessOrEqual(getString(R.string.versionHigh))) {
|
||||||
|
|
||||||
login(loginType, instanceUrl, loginUid, loginPass, loginOTP, loginToken);
|
login(loginType, loginUid, loginPass, loginOTP, loginToken);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
Toasty.warning(ctx, getResources().getString(R.string.versionUnsupportedNew));
|
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) {
|
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
|
// 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
|
// the setup methods then can better handle all different cases
|
||||||
|
|
||||||
if(loginType == LoginType.BASIC) {
|
if(loginType == LoginType.BASIC) {
|
||||||
|
|
||||||
setup(instanceUrl, loginUid, loginPass, loginOTP);
|
setup(loginUid, loginPass, loginOTP);
|
||||||
}
|
}
|
||||||
else if(loginType == LoginType.TOKEN) { // Token
|
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>() {
|
call.enqueue(new Callback<UserInfo>() {
|
||||||
|
|
||||||
@ -358,14 +351,14 @@ public class LoginActivity extends BaseActivity {
|
|||||||
tinyDB.putString("userLogin", userDetails.getUsername());
|
tinyDB.putString("userLogin", userDetails.getUsername());
|
||||||
|
|
||||||
// insert new account to db if does not exist
|
// 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);
|
UserAccountsApi userAccountsApi = new UserAccountsApi(ctx);
|
||||||
int checkAccount = userAccountsApi.getCount(accountName);
|
int checkAccount = userAccountsApi.getCount(accountName);
|
||||||
long accountId;
|
long accountId;
|
||||||
|
|
||||||
if(checkAccount == 0) {
|
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);
|
tinyDB.putInt("currentActiveAccountId", (int) accountId);
|
||||||
}
|
}
|
||||||
else {
|
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 credential = Credentials.basic(loginUid, loginPass, StandardCharsets.UTF_8);
|
||||||
final String tokenName = "gitnex-app-" + device_id;
|
final String tokenName = "gitnex-app-" + device_id;
|
||||||
@ -410,11 +403,11 @@ public class LoginActivity extends BaseActivity {
|
|||||||
Call<List<UserTokens>> call;
|
Call<List<UserTokens>> call;
|
||||||
if(loginOTP != 0) {
|
if(loginOTP != 0) {
|
||||||
|
|
||||||
call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().getUserTokensWithOTP(credential, loginOTP, loginUid);
|
call = RetrofitClient.getApiInterface(appCtx).getUserTokensWithOTP(credential, loginOTP, loginUid);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().getUserTokens(credential, loginUid);
|
call = RetrofitClient.getApiInterface(appCtx).getUserTokens(credential, loginUid);
|
||||||
}
|
}
|
||||||
|
|
||||||
call.enqueue(new Callback<List<UserTokens>>() {
|
call.enqueue(new Callback<List<UserTokens>>() {
|
||||||
@ -438,12 +431,12 @@ public class LoginActivity extends BaseActivity {
|
|||||||
Call<Void> delcall;
|
Call<Void> delcall;
|
||||||
if(loginOTP != 0) {
|
if(loginOTP != 0) {
|
||||||
|
|
||||||
delcall = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface()
|
delcall = RetrofitClient.getApiInterface(ctx)
|
||||||
.deleteTokenWithOTP(credential, loginOTP, loginUid, t.getId());
|
.deleteTokenWithOTP(credential, loginOTP, loginUid, t.getId());
|
||||||
}
|
}
|
||||||
else {
|
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>() {
|
delcall.enqueue(new Callback<Void>() {
|
||||||
@ -453,7 +446,7 @@ public class LoginActivity extends BaseActivity {
|
|||||||
|
|
||||||
if(response.code() == 204) {
|
if(response.code() == 204) {
|
||||||
|
|
||||||
setupToken(instanceUrl, loginUid, loginPass, loginOTP, tokenName);
|
setupToken(loginUid, loginPass, loginOTP, tokenName);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
@ -474,7 +467,7 @@ public class LoginActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setupToken(instanceUrl, loginUid, loginPass, loginOTP, tokenName);
|
setupToken(loginUid, loginPass, loginOTP, tokenName);
|
||||||
}
|
}
|
||||||
else {
|
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);
|
final String credential = Credentials.basic(loginUid, loginPass, StandardCharsets.UTF_8);
|
||||||
|
|
||||||
@ -503,12 +496,13 @@ public class LoginActivity extends BaseActivity {
|
|||||||
|
|
||||||
if(loginOTP != 0) {
|
if(loginOTP != 0) {
|
||||||
|
|
||||||
callCreateToken = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface()
|
callCreateToken = RetrofitClient.getApiInterface(ctx)
|
||||||
.createNewTokenWithOTP(credential, loginOTP, loginUid, createUserToken);
|
.createNewTokenWithOTP(credential, loginOTP, loginUid, createUserToken);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
callCreateToken = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().createNewToken(credential, loginUid, createUserToken);
|
callCreateToken = RetrofitClient.getApiInterface(ctx)
|
||||||
|
.createNewToken(credential, loginUid, createUserToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
callCreateToken.enqueue(new Callback<UserTokens>() {
|
callCreateToken.enqueue(new Callback<UserTokens>() {
|
||||||
@ -523,7 +517,7 @@ public class LoginActivity extends BaseActivity {
|
|||||||
|
|
||||||
if(!newToken.getSha1().equals("")) {
|
if(!newToken.getSha1().equals("")) {
|
||||||
|
|
||||||
Call<UserInfo> call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface()
|
Call<UserInfo> call = RetrofitClient.getApiInterface(ctx)
|
||||||
.getUserInfo("token " + newToken.getSha1());
|
.getUserInfo("token " + newToken.getSha1());
|
||||||
|
|
||||||
call.enqueue(new Callback<UserInfo>() {
|
call.enqueue(new Callback<UserInfo>() {
|
||||||
@ -545,7 +539,7 @@ public class LoginActivity extends BaseActivity {
|
|||||||
tinyDB.putString(loginUid + "-token-last-eight", newToken.getToken_last_eight());
|
tinyDB.putString(loginUid + "-token-last-eight", newToken.getToken_last_eight());
|
||||||
|
|
||||||
// insert new account to db if does not exist
|
// 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);
|
UserAccountsApi userAccountsApi = new UserAccountsApi(ctx);
|
||||||
int checkAccount = userAccountsApi.getCount(accountName);
|
int checkAccount = userAccountsApi.getCount(accountName);
|
||||||
long accountId;
|
long accountId;
|
||||||
@ -553,7 +547,7 @@ public class LoginActivity extends BaseActivity {
|
|||||||
if(checkAccount == 0) {
|
if(checkAccount == 0) {
|
||||||
|
|
||||||
accountId = userAccountsApi
|
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);
|
tinyDB.putInt("currentActiveAccountId", (int) accountId);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -77,12 +77,8 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
private ImageView userAvatarBackground;
|
private ImageView userAvatarBackground;
|
||||||
private ViewGroup navHeaderFrame;
|
private ViewGroup navHeaderFrame;
|
||||||
private TextView toolbarTitle;
|
private TextView toolbarTitle;
|
||||||
final Context ctx = this;
|
|
||||||
private Context appCtx;
|
|
||||||
private static TinyDB tinyDb;
|
|
||||||
private Typeface myTypeface;
|
private Typeface myTypeface;
|
||||||
|
|
||||||
private String instanceUrl;
|
|
||||||
private String loginUid;
|
private String loginUid;
|
||||||
private String instanceToken;
|
private String instanceToken;
|
||||||
|
|
||||||
@ -100,49 +96,46 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
|
|
||||||
tinyDb = new TinyDB(appCtx);
|
tinyDB.putBoolean("noConnection", false);
|
||||||
tinyDb.putBoolean("noConnection", false);
|
|
||||||
|
|
||||||
Intent mainIntent = getIntent();
|
Intent mainIntent = getIntent();
|
||||||
String launchFragment = mainIntent.getStringExtra("launchFragment");
|
String launchFragment = mainIntent.getStringExtra("launchFragment");
|
||||||
|
|
||||||
instanceUrl = tinyDb.getString("instanceUrl");
|
loginUid = tinyDB.getString("loginUid");
|
||||||
loginUid = tinyDb.getString("loginUid");
|
instanceToken = "token " + tinyDB.getString(loginUid + "-token");
|
||||||
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("codeBlockColor", getResources().getColor(R.color.colorLightGreen));
|
||||||
tinyDb.putInt("codeBlockBackground", getResources().getColor(R.color.black));
|
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.putString("homeScreenStr", "yes");
|
||||||
tinyDb.putInt("homeScreenId", 0);
|
tinyDB.putInt("homeScreenId", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||||
|
|
||||||
if(!tinyDb.getBoolean("loggedInMode")) {
|
if(!tinyDB.getBoolean("loggedInMode")) {
|
||||||
|
|
||||||
logout(this, ctx);
|
logout(this, ctx);
|
||||||
return;
|
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));
|
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);
|
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||||
toolbarTitle = toolbar.findViewById(R.id.toolbar_title);
|
toolbarTitle = toolbar.findViewById(R.id.toolbar_title);
|
||||||
|
|
||||||
switch(tinyDb.getInt("customFontId", -1)) {
|
switch(tinyDB.getInt("customFontId", -1)) {
|
||||||
|
|
||||||
case 0:
|
case 0:
|
||||||
|
|
||||||
@ -213,7 +206,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleUserAccounts));
|
toolbarTitle.setText(getResources().getString(R.string.pageTitleUserAccounts));
|
||||||
}
|
}
|
||||||
|
|
||||||
getNotificationsCount(instanceUrl, instanceToken);
|
getNotificationsCount(instanceToken);
|
||||||
|
|
||||||
drawer = findViewById(R.id.drawer_layout);
|
drawer = findViewById(R.id.drawer_layout);
|
||||||
NavigationView navigationView = findViewById(R.id.nav_view);
|
NavigationView navigationView = findViewById(R.id.nav_view);
|
||||||
@ -231,21 +224,21 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
@Override
|
@Override
|
||||||
public void onDrawerOpened(@NonNull View drawerView) {
|
public void onDrawerOpened(@NonNull View drawerView) {
|
||||||
|
|
||||||
getNotificationsCount(instanceUrl, instanceToken);
|
getNotificationsCount(instanceToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDrawerSlide(@NonNull View drawerView, float slideOffset) {
|
public void onDrawerSlide(@NonNull View drawerView, float slideOffset) {
|
||||||
|
|
||||||
if(tinyDb.getBoolean("noConnection")) {
|
if(tinyDB.getBoolean("noConnection")) {
|
||||||
|
|
||||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||||
tinyDb.putBoolean("noConnection", false);
|
tinyDB.putBoolean("noConnection", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
String userEmailNav = tinyDb.getString("userEmail");
|
String userEmailNav = tinyDB.getString("userEmail");
|
||||||
String userFullNameNav = tinyDb.getString("userFullname");
|
String userFullNameNav = tinyDB.getString("userFullname");
|
||||||
String userAvatarNav = tinyDb.getString("userAvatar");
|
String userAvatarNav = tinyDB.getString("userAvatar");
|
||||||
|
|
||||||
blurView = hView.findViewById(R.id.blurView);
|
blurView = hView.findViewById(R.id.blurView);
|
||||||
userEmail = hView.findViewById(R.id.userEmail);
|
userEmail = hView.findViewById(R.id.userEmail);
|
||||||
@ -326,9 +319,9 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
drawer.closeDrawers();
|
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"));
|
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(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:
|
case 1:
|
||||||
|
|
||||||
@ -460,18 +453,18 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
|
|
||||||
if(!connToInternet) {
|
if(!connToInternet) {
|
||||||
|
|
||||||
if(!tinyDb.getBoolean("noConnection")) {
|
if(!tinyDB.getBoolean("noConnection")) {
|
||||||
|
|
||||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||||
}
|
}
|
||||||
|
|
||||||
tinyDb.putBoolean("noConnection", true);
|
tinyDB.putBoolean("noConnection", true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
loadUserInfo(instanceUrl, instanceToken, loginUid);
|
loadUserInfo(instanceToken, loginUid);
|
||||||
giteaVersion(instanceUrl);
|
giteaVersion();
|
||||||
tinyDb.putBoolean("noConnection", false);
|
tinyDB.putBoolean("noConnection", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Changelog popup
|
// Changelog popup
|
||||||
@ -487,10 +480,10 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
Log.e("changelogDialog", Objects.requireNonNull(e.getMessage()));
|
Log.e("changelogDialog", Objects.requireNonNull(e.getMessage()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(versionCode > tinyDb.getInt("versionCode")) {
|
if(versionCode > tinyDB.getInt("versionCode")) {
|
||||||
|
|
||||||
tinyDb.putInt("versionCode", versionCode);
|
tinyDB.putInt("versionCode", versionCode);
|
||||||
tinyDb.putBoolean("versionFlag", true);
|
tinyDB.putBoolean("versionFlag", true);
|
||||||
|
|
||||||
ChangeLog changelogDialog = new ChangeLog(this);
|
ChangeLog changelogDialog = new ChangeLog(this);
|
||||||
changelogDialog.showDialog();
|
changelogDialog.showDialog();
|
||||||
@ -505,7 +498,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
@Override
|
@Override
|
||||||
public void onButtonClicked(String text) {
|
public void onButtonClicked(String text) {
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(ctx);
|
TinyDB tinyDb = TinyDB.getInstance(ctx);
|
||||||
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
||||||
|
|
||||||
if("deleteDrafts".equals(text)) {
|
if("deleteDrafts".equals(text)) {
|
||||||
@ -625,9 +618,11 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
|
|
||||||
public static void logout(Activity activity, Context ctx) {
|
public static void logout(Activity activity, Context ctx) {
|
||||||
|
|
||||||
tinyDb.putBoolean("loggedInMode", false);
|
TinyDB tinyDB = TinyDB.getInstance(ctx);
|
||||||
tinyDb.remove("basicAuthPassword");
|
|
||||||
tinyDb.putBoolean("basicAuthFlag", false);
|
tinyDB.putBoolean("loggedInMode", false);
|
||||||
|
tinyDB.remove("basicAuthPassword");
|
||||||
|
tinyDB.putBoolean("basicAuthFlag", false);
|
||||||
//tinyDb.clear();
|
//tinyDb.clear();
|
||||||
activity.finish();
|
activity.finish();
|
||||||
ctx.startActivity(new Intent(ctx, LoginActivity.class));
|
ctx.startActivity(new Intent(ctx, LoginActivity.class));
|
||||||
@ -648,13 +643,13 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
return super.onOptionsItemSelected(item);
|
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");
|
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>() {
|
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>() {
|
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>() {
|
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.AlertDialogs;
|
||||||
import org.mian.gitnex.helpers.AppUtil;
|
import org.mian.gitnex.helpers.AppUtil;
|
||||||
import org.mian.gitnex.helpers.Authorization;
|
import org.mian.gitnex.helpers.Authorization;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
import org.mian.gitnex.helpers.Version;
|
import org.mian.gitnex.helpers.Version;
|
||||||
import org.mian.gitnex.models.MergePullRequest;
|
import org.mian.gitnex.models.MergePullRequest;
|
||||||
@ -33,13 +32,7 @@ import retrofit2.Callback;
|
|||||||
public class MergePullRequestActivity extends BaseActivity {
|
public class MergePullRequestActivity extends BaseActivity {
|
||||||
|
|
||||||
private View.OnClickListener onClickListener;
|
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 repoOwner;
|
||||||
private String repoName;
|
private String repoName;
|
||||||
private int prIndex;
|
private int prIndex;
|
||||||
@ -59,21 +52,16 @@ public class MergePullRequestActivity extends BaseActivity {
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
tinyDb = new TinyDB(appCtx);
|
|
||||||
|
|
||||||
viewBinding = ActivityMergePullRequestBinding.inflate(getLayoutInflater());
|
viewBinding = ActivityMergePullRequestBinding.inflate(getLayoutInflater());
|
||||||
View view = viewBinding.getRoot();
|
View view = viewBinding.getRoot();
|
||||||
setContentView(view);
|
setContentView(view);
|
||||||
|
|
||||||
instanceUrl = tinyDb.getString("instanceUrl");
|
String repoFullName = tinyDB.getString("repoFullName");
|
||||||
loginUid = tinyDb.getString("loginUid");
|
|
||||||
instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
|
||||||
String repoFullName = tinyDb.getString("repoFullName");
|
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
repoOwner = parts[0];
|
repoOwner = parts[0];
|
||||||
repoName = parts[1];
|
repoName = parts[1];
|
||||||
prIndex = Integer.parseInt(tinyDb.getString("issueNumber"));
|
prIndex = Integer.parseInt(tinyDB.getString("issueNumber"));
|
||||||
|
|
||||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||||
|
|
||||||
@ -85,22 +73,22 @@ public class MergePullRequestActivity extends BaseActivity {
|
|||||||
|
|
||||||
setMergeAdapter();
|
setMergeAdapter();
|
||||||
|
|
||||||
if(!tinyDb.getString("issueTitle").isEmpty()) {
|
if(!tinyDB.getString("issueTitle").isEmpty()) {
|
||||||
|
|
||||||
viewBinding.toolbarTitle.setText(tinyDb.getString("issueTitle"));
|
viewBinding.toolbarTitle.setText(tinyDB.getString("issueTitle"));
|
||||||
viewBinding.mergeTitle.setText(tinyDb.getString("issueTitle") + " (#" + tinyDb.getString("issueNumber") + ")");
|
viewBinding.mergeTitle.setText(tinyDB.getString("issueTitle") + " (#" + tinyDB.getString("issueNumber") + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
initCloseListener();
|
initCloseListener();
|
||||||
viewBinding.close.setOnClickListener(onClickListener);
|
viewBinding.close.setOnClickListener(onClickListener);
|
||||||
|
|
||||||
// if gitea version is greater/equal(1.12.0) than user installed version (installed.higherOrEqual(compareVer))
|
// 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);
|
viewBinding.deleteBranch.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tinyDb.getString("prMergeable").equals("false")) {
|
if(tinyDB.getString("prMergeable").equals("false")) {
|
||||||
|
|
||||||
disableProcessButton();
|
disableProcessButton();
|
||||||
viewBinding.mergeInfoDisabledMessage.setVisibility(View.VISIBLE);
|
viewBinding.mergeInfoDisabledMessage.setVisibility(View.VISIBLE);
|
||||||
@ -110,7 +98,7 @@ public class MergePullRequestActivity extends BaseActivity {
|
|||||||
viewBinding.mergeInfoDisabledMessage.setVisibility(View.GONE);
|
viewBinding.mergeInfoDisabledMessage.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tinyDb.getString("prIsFork").equals("true")) {
|
if(tinyDB.getString("prIsFork").equals("true")) {
|
||||||
|
|
||||||
viewBinding.deleteBranchForkInfo.setVisibility(View.VISIBLE);
|
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", getResources().getString(R.string.mergeOptionRebase)));
|
||||||
mergeList.add(new MergePullRequestSpinner("rebase-merge", getResources().getString(R.string.mergeOptionRebaseCommit)));
|
mergeList.add(new MergePullRequestSpinner("rebase-merge", getResources().getString(R.string.mergeOptionRebaseCommit)));
|
||||||
// squash merge works only on gitea > v1.11.4 due to a bug
|
// 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)));
|
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);
|
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>() {
|
call.enqueue(new Callback<ResponseBody>() {
|
||||||
|
|
||||||
@ -200,9 +188,9 @@ public class MergePullRequestActivity extends BaseActivity {
|
|||||||
|
|
||||||
if(deleteBranch) {
|
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("/");
|
String[] parts = repoFullName.split("/");
|
||||||
final String repoOwner = parts[0];
|
final String repoOwner = parts[0];
|
||||||
final String repoName = parts[1];
|
final String repoName = parts[1];
|
||||||
@ -210,13 +198,13 @@ public class MergePullRequestActivity extends BaseActivity {
|
|||||||
deleteBranchFunction(repoOwner, repoName);
|
deleteBranchFunction(repoOwner, repoName);
|
||||||
|
|
||||||
Toasty.success(ctx, getString(R.string.mergePRSuccessMsg));
|
Toasty.success(ctx, getString(R.string.mergePRSuccessMsg));
|
||||||
tinyDb.putBoolean("prMerged", true);
|
tinyDB.putBoolean("prMerged", true);
|
||||||
tinyDb.putBoolean("resumePullRequests", true);
|
tinyDB.putBoolean("resumePullRequests", true);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
String repoFullName = tinyDb.getString("repoFullName");
|
String repoFullName = tinyDB.getString("repoFullName");
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
final String repoOwner = parts[0];
|
final String repoOwner = parts[0];
|
||||||
final String repoName = parts[1];
|
final String repoName = parts[1];
|
||||||
@ -224,8 +212,8 @@ public class MergePullRequestActivity extends BaseActivity {
|
|||||||
deleteBranchFunction(repoOwner, repoName);
|
deleteBranchFunction(repoOwner, repoName);
|
||||||
|
|
||||||
Toasty.success(ctx, getString(R.string.mergePRSuccessMsg));
|
Toasty.success(ctx, getString(R.string.mergePRSuccessMsg));
|
||||||
tinyDb.putBoolean("prMerged", true);
|
tinyDB.putBoolean("prMerged", true);
|
||||||
tinyDb.putBoolean("resumePullRequests", true);
|
tinyDB.putBoolean("resumePullRequests", true);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -233,8 +221,8 @@ public class MergePullRequestActivity extends BaseActivity {
|
|||||||
else {
|
else {
|
||||||
|
|
||||||
Toasty.success(ctx, getString(R.string.mergePRSuccessMsg));
|
Toasty.success(ctx, getString(R.string.mergePRSuccessMsg));
|
||||||
tinyDb.putBoolean("prMerged", true);
|
tinyDB.putBoolean("prMerged", true);
|
||||||
tinyDb.putBoolean("resumePullRequests", true);
|
tinyDB.putBoolean("resumePullRequests", true);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,12 +263,11 @@ public class MergePullRequestActivity extends BaseActivity {
|
|||||||
|
|
||||||
private void deleteBranchFunction(String repoOwner, String repoName) {
|
private void deleteBranchFunction(String repoOwner, String repoName) {
|
||||||
|
|
||||||
String branchName = tinyDb.getString("prHeadBranch");
|
String branchName = tinyDB.getString("prHeadBranch");
|
||||||
|
|
||||||
Call<JsonElement> call = RetrofitClient
|
Call<JsonElement> call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
.deleteBranch(Authorization.get(ctx), repoOwner, repoName, branchName);
|
||||||
.deleteBranch(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, branchName);
|
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonElement>() {
|
call.enqueue(new Callback<JsonElement>() {
|
||||||
|
|
||||||
|
@ -25,8 +25,9 @@ public class OpenRepoInBrowserActivity extends AppCompatActivity {
|
|||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
appCtx = getApplicationContext();
|
appCtx = getApplicationContext();
|
||||||
TinyDB tinyDb = new TinyDB(appCtx);
|
TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
@ -25,7 +25,6 @@ import org.mian.gitnex.fragments.MembersByOrgFragment;
|
|||||||
import org.mian.gitnex.fragments.OrganizationInfoFragment;
|
import org.mian.gitnex.fragments.OrganizationInfoFragment;
|
||||||
import org.mian.gitnex.fragments.RepositoriesByOrgFragment;
|
import org.mian.gitnex.fragments.RepositoriesByOrgFragment;
|
||||||
import org.mian.gitnex.fragments.TeamsByOrgFragment;
|
import org.mian.gitnex.fragments.TeamsByOrgFragment;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import io.mikael.urlbuilder.UrlBuilder;
|
import io.mikael.urlbuilder.UrlBuilder;
|
||||||
@ -36,10 +35,6 @@ import io.mikael.urlbuilder.UrlBuilder;
|
|||||||
|
|
||||||
public class OrganizationDetailActivity extends BaseActivity implements BottomSheetOrganizationFragment.BottomSheetListener {
|
public class OrganizationDetailActivity extends BaseActivity implements BottomSheetOrganizationFragment.BottomSheetListener {
|
||||||
|
|
||||||
final Context ctx = this;
|
|
||||||
private Context appCtx;
|
|
||||||
private TinyDB tinyDb;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getLayoutResourceId(){
|
protected int getLayoutResourceId(){
|
||||||
return R.layout.activity_org_detail;
|
return R.layout.activity_org_detail;
|
||||||
@ -49,11 +44,8 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(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);
|
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||||
TextView toolbarTitle = toolbar.findViewById(R.id.toolbar_title);
|
TextView toolbarTitle = toolbar.findViewById(R.id.toolbar_title);
|
||||||
@ -71,7 +63,7 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
|||||||
|
|
||||||
Typeface myTypeface;
|
Typeface myTypeface;
|
||||||
|
|
||||||
switch(tinyDb.getInt("customFontId", -1)) {
|
switch(tinyDB.getInt("customFontId", -1)) {
|
||||||
|
|
||||||
case 0:
|
case 0:
|
||||||
|
|
||||||
@ -150,7 +142,7 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
|||||||
switch (text) {
|
switch (text) {
|
||||||
case "repository":
|
case "repository":
|
||||||
|
|
||||||
tinyDb.putBoolean("organizationAction", true);
|
tinyDB.putBoolean("organizationAction", true);
|
||||||
startActivity(new Intent(OrganizationDetailActivity.this, CreateRepoActivity.class));
|
startActivity(new Intent(OrganizationDetailActivity.this, CreateRepoActivity.class));
|
||||||
break;
|
break;
|
||||||
case "team":
|
case "team":
|
||||||
@ -159,11 +151,11 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
|||||||
break;
|
break;
|
||||||
case "copyOrgUrl":
|
case "copyOrgUrl":
|
||||||
|
|
||||||
String url = UrlBuilder.fromString(tinyDb.getString("instanceUrl"))
|
String url = UrlBuilder.fromString(tinyDB.getString("instanceUrl"))
|
||||||
.withPath("/")
|
.withPath("/")
|
||||||
.toString();
|
.toString();
|
||||||
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(ctx).getSystemService(Context.CLIPBOARD_SERVICE);
|
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;
|
assert clipboard != null;
|
||||||
clipboard.setPrimaryClip(clip);
|
clipboard.setPrimaryClip(clip);
|
||||||
Toasty.info(ctx, ctx.getString(R.string.copyIssueUrlToastMsg));
|
Toasty.info(ctx, ctx.getString(R.string.copyIssueUrlToastMsg));
|
||||||
@ -188,7 +180,7 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
orgName = tinyDb.getString("orgName");
|
orgName = tinyDB.getString("orgName");
|
||||||
}
|
}
|
||||||
|
|
||||||
Fragment fragment = null;
|
Fragment fragment = null;
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package org.mian.gitnex.activities;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
@ -15,7 +14,6 @@ import androidx.appcompat.widget.Toolbar;
|
|||||||
import androidx.lifecycle.ViewModelProvider;
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.adapters.TeamMembersByOrgAdapter;
|
import org.mian.gitnex.adapters.TeamMembersByOrgAdapter;
|
||||||
import org.mian.gitnex.fragments.BottomSheetOrganizationFragment;
|
|
||||||
import org.mian.gitnex.fragments.BottomSheetOrganizationTeamsFragment;
|
import org.mian.gitnex.fragments.BottomSheetOrganizationTeamsFragment;
|
||||||
import org.mian.gitnex.helpers.Authorization;
|
import org.mian.gitnex.helpers.Authorization;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
import org.mian.gitnex.helpers.TinyDB;
|
||||||
@ -34,9 +32,6 @@ public class OrganizationTeamMembersActivity extends BaseActivity implements Bot
|
|||||||
private GridView mGridView;
|
private GridView mGridView;
|
||||||
private ProgressBar progressBar;
|
private ProgressBar progressBar;
|
||||||
|
|
||||||
final Context ctx = this;
|
|
||||||
private Context appCtx;
|
|
||||||
|
|
||||||
private String teamId;
|
private String teamId;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -48,15 +43,10 @@ public class OrganizationTeamMembersActivity extends BaseActivity implements Bot
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||||
setSupportActionBar(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);
|
ImageView closeActivity = findViewById(R.id.close);
|
||||||
TextView toolbarTitle = findViewById(R.id.toolbar_title);
|
TextView toolbarTitle = findViewById(R.id.toolbar_title);
|
||||||
noDataMembers = findViewById(R.id.noDataMembers);
|
noDataMembers = findViewById(R.id.noDataMembers);
|
||||||
@ -85,30 +75,27 @@ public class OrganizationTeamMembersActivity extends BaseActivity implements Bot
|
|||||||
}
|
}
|
||||||
|
|
||||||
assert teamId != null;
|
assert teamId != null;
|
||||||
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), Integer.parseInt(teamId));
|
fetchDataAsync(Authorization.get(ctx), Integer.parseInt(teamId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
|
|
||||||
super.onResume();
|
super.onResume();
|
||||||
TinyDB tinyDb = new TinyDB(appCtx);
|
TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
|
||||||
final String loginUid = tinyDb.getString("loginUid");
|
|
||||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
|
||||||
|
|
||||||
if(tinyDb.getBoolean("teamActionFlag")) {
|
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);
|
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);
|
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);
|
adapter = new TeamMembersByOrgAdapter(ctx, teamMembersListMain);
|
||||||
|
|
||||||
|
@ -33,8 +33,6 @@ public class ProfileEmailActivity extends BaseActivity {
|
|||||||
|
|
||||||
private View.OnClickListener onClickListener;
|
private View.OnClickListener onClickListener;
|
||||||
private EditText userEmail;
|
private EditText userEmail;
|
||||||
final Context ctx = this;
|
|
||||||
private Context appCtx;
|
|
||||||
private Button addEmailButton;
|
private Button addEmailButton;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -46,7 +44,6 @@ public class ProfileEmailActivity extends BaseActivity {
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
|
|
||||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||||
|
|
||||||
@ -78,10 +75,6 @@ public class ProfileEmailActivity extends BaseActivity {
|
|||||||
private void processAddNewEmail() {
|
private void processAddNewEmail() {
|
||||||
|
|
||||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
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();
|
String newUserEmail = userEmail.getText().toString().trim();
|
||||||
|
|
||||||
@ -105,19 +98,18 @@ public class ProfileEmailActivity extends BaseActivity {
|
|||||||
List<String> newEmailList = new ArrayList<>(Arrays.asList(newUserEmail.split(",")));
|
List<String> newEmailList = new ArrayList<>(Arrays.asList(newUserEmail.split(",")));
|
||||||
|
|
||||||
disableProcessButton();
|
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);
|
AddEmail addEmailFunc = new AddEmail(newUserEmail);
|
||||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
final TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||||
|
|
||||||
Call<JsonElement> call;
|
Call<JsonElement> call;
|
||||||
|
|
||||||
call = RetrofitClient
|
call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(appCtx)
|
||||||
.getApiInterface()
|
|
||||||
.addNewEmail(token, addEmailFunc);
|
.addNewEmail(token, addEmailFunc);
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonElement>() {
|
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.ReleasesFragment;
|
||||||
import org.mian.gitnex.fragments.RepoInfoFragment;
|
import org.mian.gitnex.fragments.RepoInfoFragment;
|
||||||
import org.mian.gitnex.helpers.Authorization;
|
import org.mian.gitnex.helpers.Authorization;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
import org.mian.gitnex.helpers.Version;
|
import org.mian.gitnex.helpers.Version;
|
||||||
import org.mian.gitnex.models.Branches;
|
import org.mian.gitnex.models.Branches;
|
||||||
@ -71,12 +70,6 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
|||||||
private FragmentRefreshListenerMilestone fragmentRefreshListenerMilestone;
|
private FragmentRefreshListenerMilestone fragmentRefreshListenerMilestone;
|
||||||
private FragmentRefreshListenerFiles fragmentRefreshListenerFiles;
|
private FragmentRefreshListenerFiles fragmentRefreshListenerFiles;
|
||||||
|
|
||||||
private final Context ctx = this;
|
|
||||||
private Context appCtx;
|
|
||||||
|
|
||||||
private TinyDB tinyDB;
|
|
||||||
|
|
||||||
private String instanceUrl;
|
|
||||||
private String loginUid;
|
private String loginUid;
|
||||||
private String instanceToken;
|
private String instanceToken;
|
||||||
|
|
||||||
@ -96,9 +89,6 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
|
|
||||||
tinyDB = new TinyDB(appCtx);
|
|
||||||
|
|
||||||
String[] repoNameParts = tinyDB.getString("repoFullName").split("/");
|
String[] repoNameParts = tinyDB.getString("repoFullName").split("/");
|
||||||
repositoryOwner = repoNameParts[0];
|
repositoryOwner = repoNameParts[0];
|
||||||
@ -113,7 +103,6 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
|||||||
Objects.requireNonNull(getSupportActionBar()).setTitle(repositoryName);
|
Objects.requireNonNull(getSupportActionBar()).setTitle(repositoryName);
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
|
||||||
instanceUrl = tinyDB.getString("instanceUrl");
|
|
||||||
loginUid = tinyDB.getString("loginUid");
|
loginUid = tinyDB.getString("loginUid");
|
||||||
instanceToken = "token " + tinyDB.getString(loginUid + "-token");
|
instanceToken = "token " + tinyDB.getString(loginUid + "-token");
|
||||||
|
|
||||||
@ -198,7 +187,7 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
|||||||
textViewBadgePull.setVisibility(View.GONE);
|
textViewBadgePull.setVisibility(View.GONE);
|
||||||
textViewBadgeRelease.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();
|
ColorStateList textColor = tabLayout.getTabTextColors();
|
||||||
|
|
||||||
// Issue count
|
// Issue count
|
||||||
@ -254,8 +243,8 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
checkRepositoryStarStatus(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repositoryOwner, repositoryName);
|
checkRepositoryStarStatus(Authorization.get(ctx), repositoryOwner, repositoryName);
|
||||||
checkRepositoryWatchStatus(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repositoryOwner, repositoryName);
|
checkRepositoryWatchStatus(Authorization.get(ctx), repositoryOwner, repositoryName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -265,7 +254,7 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
|||||||
|
|
||||||
if(tinyDB.getBoolean("enableCounterIssueBadge")) {
|
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() {
|
private void chooseBranch() {
|
||||||
|
|
||||||
Call<List<Branches>> call = RetrofitClient.getInstance(instanceUrl, ctx)
|
Call<List<Branches>> call = RetrofitClient
|
||||||
.getApiInterface()
|
.getApiInterface(ctx)
|
||||||
.getBranches(instanceToken, repositoryOwner, repositoryName);
|
.getBranches(instanceToken, repositoryOwner, repositoryName);
|
||||||
|
|
||||||
call.enqueue(new Callback<List<Branches>>() {
|
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>() {
|
call.enqueue(new Callback<UserRepositories>() {
|
||||||
|
|
||||||
@Override
|
@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>() {
|
call.enqueue(new Callback<JsonElement>() {
|
||||||
|
|
||||||
@Override
|
@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<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>() {
|
call.enqueue(new Callback<WatchInfo>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package org.mian.gitnex.activities;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
@ -42,8 +41,6 @@ import retrofit2.Response;
|
|||||||
|
|
||||||
public class RepoForksActivity extends BaseActivity {
|
public class RepoForksActivity extends BaseActivity {
|
||||||
|
|
||||||
final Context ctx = this;
|
|
||||||
private Context appCtx;
|
|
||||||
private View.OnClickListener onClickListener;
|
private View.OnClickListener onClickListener;
|
||||||
private TextView noData;
|
private TextView noData;
|
||||||
private ProgressBar progressBar;
|
private ProgressBar progressBar;
|
||||||
@ -67,14 +64,11 @@ public class RepoForksActivity extends BaseActivity {
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(appCtx);
|
TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
|
||||||
final String loginUid = tinyDb.getString("loginUid");
|
|
||||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
|
||||||
|
|
||||||
String repoFullNameForForks = getIntent().getStringExtra("repoFullNameForForks");
|
String repoFullNameForForks = getIntent().getStringExtra("repoFullNameForForks");
|
||||||
assert repoFullNameForForks != null;
|
assert repoFullNameForForks != null;
|
||||||
@ -111,7 +105,7 @@ public class RepoForksActivity extends BaseActivity {
|
|||||||
swipeRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
swipeRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||||
|
|
||||||
swipeRefresh.setRefreshing(false);
|
swipeRefresh.setRefreshing(false);
|
||||||
loadInitial(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, pageSize, resultLimit);
|
loadInitial(Authorization.get(ctx), repoOwner, repoName, pageSize, resultLimit);
|
||||||
adapter.notifyDataChanged();
|
adapter.notifyDataChanged();
|
||||||
|
|
||||||
}, 200));
|
}, 200));
|
||||||
@ -122,7 +116,7 @@ public class RepoForksActivity extends BaseActivity {
|
|||||||
if(forksList.size() == resultLimit || pageSize == resultLimit) {
|
if(forksList.size() == resultLimit || pageSize == resultLimit) {
|
||||||
|
|
||||||
int page = (forksList.size() + resultLimit) / 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.setLayoutManager(new LinearLayoutManager(ctx));
|
||||||
recyclerView.setAdapter(adapter);
|
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
|
Call<List<UserRepositories>> call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
|
||||||
.getRepositoryForks(instanceToken, repoOwner, repoName, pageSize, resultLimit);
|
.getRepositoryForks(instanceToken, repoOwner, repoName, pageSize, resultLimit);
|
||||||
|
|
||||||
call.enqueue(new Callback<List<UserRepositories>>() {
|
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);
|
progressLoadMore.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
Call<List<UserRepositories>> call = RetrofitClient
|
Call<List<UserRepositories>> call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
|
||||||
.getRepositoryForks(instanceToken, repoOwner, repoName, page, resultLimit);
|
.getRepositoryForks(instanceToken, repoOwner, repoName, page, resultLimit);
|
||||||
|
|
||||||
call.enqueue(new Callback<List<UserRepositories>>() {
|
call.enqueue(new Callback<List<UserRepositories>>() {
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package org.mian.gitnex.activities;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.GridView;
|
import android.widget.GridView;
|
||||||
@ -11,7 +10,6 @@ import androidx.lifecycle.ViewModelProvider;
|
|||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.adapters.RepoStargazersAdapter;
|
import org.mian.gitnex.adapters.RepoStargazersAdapter;
|
||||||
import org.mian.gitnex.helpers.Authorization;
|
import org.mian.gitnex.helpers.Authorization;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
|
||||||
import org.mian.gitnex.viewmodels.RepoStargazersViewModel;
|
import org.mian.gitnex.viewmodels.RepoStargazersViewModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -26,9 +24,6 @@ public class RepoStargazersActivity extends BaseActivity {
|
|||||||
private GridView mGridView;
|
private GridView mGridView;
|
||||||
private ProgressBar mProgressBar;
|
private ProgressBar mProgressBar;
|
||||||
|
|
||||||
final Context ctx = this;
|
|
||||||
private Context appCtx;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getLayoutResourceId(){
|
protected int getLayoutResourceId(){
|
||||||
return R.layout.activity_repo_stargazers;
|
return R.layout.activity_repo_stargazers;
|
||||||
@ -38,12 +33,6 @@ public class RepoStargazersActivity extends BaseActivity {
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(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);
|
ImageView closeActivity = findViewById(R.id.close);
|
||||||
TextView toolbarTitle = findViewById(R.id.toolbar_title);
|
TextView toolbarTitle = findViewById(R.id.toolbar_title);
|
||||||
@ -61,14 +50,14 @@ public class RepoStargazersActivity extends BaseActivity {
|
|||||||
|
|
||||||
toolbarTitle.setText(R.string.repoStargazersInMenu);
|
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);
|
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);
|
adapter = new RepoStargazersAdapter(ctx, stargazersListMain);
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package org.mian.gitnex.activities;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.GridView;
|
import android.widget.GridView;
|
||||||
@ -11,7 +10,6 @@ import androidx.lifecycle.ViewModelProvider;
|
|||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.adapters.RepoWatchersAdapter;
|
import org.mian.gitnex.adapters.RepoWatchersAdapter;
|
||||||
import org.mian.gitnex.helpers.Authorization;
|
import org.mian.gitnex.helpers.Authorization;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
|
||||||
import org.mian.gitnex.viewmodels.RepoWatchersViewModel;
|
import org.mian.gitnex.viewmodels.RepoWatchersViewModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -26,9 +24,6 @@ public class RepoWatchersActivity extends BaseActivity {
|
|||||||
private GridView mGridView;
|
private GridView mGridView;
|
||||||
private ProgressBar mProgressBar;
|
private ProgressBar mProgressBar;
|
||||||
|
|
||||||
final Context ctx = this;
|
|
||||||
private Context appCtx;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getLayoutResourceId(){
|
protected int getLayoutResourceId(){
|
||||||
return R.layout.activity_repo_watchers;
|
return R.layout.activity_repo_watchers;
|
||||||
@ -38,12 +33,6 @@ public class RepoWatchersActivity extends BaseActivity {
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(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);
|
ImageView closeActivity = findViewById(R.id.close);
|
||||||
TextView toolbarTitle = findViewById(R.id.toolbar_title);
|
TextView toolbarTitle = findViewById(R.id.toolbar_title);
|
||||||
@ -61,14 +50,14 @@ public class RepoWatchersActivity extends BaseActivity {
|
|||||||
|
|
||||||
toolbarTitle.setText(R.string.repoWatchersInMenu);
|
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);
|
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);
|
adapter = new RepoWatchersAdapter(ctx, watchersListMain);
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package org.mian.gitnex.activities;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.drawable.ColorDrawable;
|
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.CustomRepositoryDeleteDialogBinding;
|
||||||
import org.mian.gitnex.databinding.CustomRepositoryEditPropertiesDialogBinding;
|
import org.mian.gitnex.databinding.CustomRepositoryEditPropertiesDialogBinding;
|
||||||
import org.mian.gitnex.databinding.CustomRepositoryTransferDialogBinding;
|
import org.mian.gitnex.databinding.CustomRepositoryTransferDialogBinding;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
import org.mian.gitnex.helpers.Version;
|
import org.mian.gitnex.helpers.Version;
|
||||||
import org.mian.gitnex.models.RepositoryTransfer;
|
import org.mian.gitnex.models.RepositoryTransfer;
|
||||||
@ -40,11 +38,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||||||
private Dialog dialogDeleteRepository;
|
private Dialog dialogDeleteRepository;
|
||||||
private Dialog dialogTransferRepository;
|
private Dialog dialogTransferRepository;
|
||||||
private View.OnClickListener onClickListener;
|
private View.OnClickListener onClickListener;
|
||||||
private Context ctx = this;
|
|
||||||
private Context appCtx;
|
|
||||||
private TinyDB tinyDb;
|
|
||||||
|
|
||||||
private String instanceUrl;
|
|
||||||
private String loginUid;
|
private String loginUid;
|
||||||
private String instanceToken;
|
private String instanceToken;
|
||||||
|
|
||||||
@ -60,20 +54,17 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
tinyDb = new TinyDB(appCtx);
|
|
||||||
|
|
||||||
viewBinding = ActivityRepositorySettingsBinding.inflate(getLayoutInflater());
|
viewBinding = ActivityRepositorySettingsBinding.inflate(getLayoutInflater());
|
||||||
View view = viewBinding.getRoot();
|
View view = viewBinding.getRoot();
|
||||||
setContentView(view);
|
setContentView(view);
|
||||||
|
|
||||||
instanceUrl = tinyDb.getString("instanceUrl");
|
loginUid = tinyDB.getString("loginUid");
|
||||||
loginUid = tinyDb.getString("loginUid");
|
String repoFullName = tinyDB.getString("repoFullName");
|
||||||
String repoFullName = tinyDb.getString("repoFullName");
|
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
repositoryOwner = parts[0];
|
repositoryOwner = parts[0];
|
||||||
repositoryName = parts[1];
|
repositoryName = parts[1];
|
||||||
instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
instanceToken = "token " + tinyDB.getString(loginUid + "-token");
|
||||||
|
|
||||||
ImageView closeActivity = findViewById(R.id.close);
|
ImageView closeActivity = findViewById(R.id.close);
|
||||||
|
|
||||||
@ -81,7 +72,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||||||
closeActivity.setOnClickListener(onClickListener);
|
closeActivity.setOnClickListener(onClickListener);
|
||||||
|
|
||||||
// require gitea 1.12 or higher
|
// 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);
|
viewBinding.transferOwnerFrame.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
@ -136,8 +127,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||||||
RepositoryTransfer repositoryTransfer = new RepositoryTransfer(newOwner);
|
RepositoryTransfer repositoryTransfer = new RepositoryTransfer(newOwner);
|
||||||
|
|
||||||
Call<JsonElement> transferCall = RetrofitClient
|
Call<JsonElement> transferCall = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
|
||||||
.transferRepository(instanceToken, repositoryOwner, repositoryName, repositoryTransfer);
|
.transferRepository(instanceToken, repositoryOwner, repositoryName, repositoryTransfer);
|
||||||
|
|
||||||
transferCall.enqueue(new Callback<JsonElement>() {
|
transferCall.enqueue(new Callback<JsonElement>() {
|
||||||
@ -154,7 +144,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||||||
Toasty.success(ctx, getString(R.string.repoTransferSuccess));
|
Toasty.success(ctx, getString(R.string.repoTransferSuccess));
|
||||||
|
|
||||||
finish();
|
finish();
|
||||||
RepositoriesApi.deleteRepository((int) tinyDb.getLong("repositoryId", 0));
|
RepositoriesApi.deleteRepository((int) tinyDB.getLong("repositoryId", 0));
|
||||||
Intent intent = new Intent(RepositorySettingsActivity.this, MainActivity.class);
|
Intent intent = new Intent(RepositorySettingsActivity.this, MainActivity.class);
|
||||||
RepositorySettingsActivity.this.startActivity(intent);
|
RepositorySettingsActivity.this.startActivity(intent);
|
||||||
}
|
}
|
||||||
@ -217,8 +207,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||||||
private void deleteRepository() {
|
private void deleteRepository() {
|
||||||
|
|
||||||
Call<JsonElement> deleteCall = RetrofitClient
|
Call<JsonElement> deleteCall = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
|
||||||
.deleteRepository(instanceToken, repositoryOwner, repositoryName);
|
.deleteRepository(instanceToken, repositoryOwner, repositoryName);
|
||||||
|
|
||||||
deleteCall.enqueue(new Callback<JsonElement>() {
|
deleteCall.enqueue(new Callback<JsonElement>() {
|
||||||
@ -235,7 +224,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||||||
Toasty.success(ctx, getString(R.string.repoDeletionSuccess));
|
Toasty.success(ctx, getString(R.string.repoDeletionSuccess));
|
||||||
|
|
||||||
finish();
|
finish();
|
||||||
RepositoriesApi.deleteRepository((int) tinyDb.getLong("repositoryId", 0));
|
RepositoriesApi.deleteRepository((int) tinyDB.getLong("repositoryId", 0));
|
||||||
Intent intent = new Intent(RepositorySettingsActivity.this, MainActivity.class);
|
Intent intent = new Intent(RepositorySettingsActivity.this, MainActivity.class);
|
||||||
RepositorySettingsActivity.this.startActivity(intent);
|
RepositorySettingsActivity.this.startActivity(intent);
|
||||||
}
|
}
|
||||||
@ -275,8 +264,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||||||
propBinding.cancel.setOnClickListener(editProperties -> dialogProp.dismiss());
|
propBinding.cancel.setOnClickListener(editProperties -> dialogProp.dismiss());
|
||||||
|
|
||||||
Call<UserRepositories> call = RetrofitClient
|
Call<UserRepositories> call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
|
||||||
.getUserRepository(instanceToken, repositoryOwner, repositoryName);
|
.getUserRepository(instanceToken, repositoryOwner, repositoryName);
|
||||||
|
|
||||||
call.enqueue(new Callback<UserRepositories>() {
|
call.enqueue(new Callback<UserRepositories>() {
|
||||||
@ -376,8 +364,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Call<UserRepositories> propsCall = RetrofitClient
|
Call<UserRepositories> propsCall = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
|
||||||
.updateRepositoryProperties(instanceToken, repositoryOwner, repositoryName, repoProps);
|
.updateRepositoryProperties(instanceToken, repositoryOwner, repositoryName, repoProps);
|
||||||
|
|
||||||
propsCall.enqueue(new Callback<UserRepositories>() {
|
propsCall.enqueue(new Callback<UserRepositories>() {
|
||||||
@ -390,8 +377,8 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||||||
|
|
||||||
if (response.code() == 200) {
|
if (response.code() == 200) {
|
||||||
|
|
||||||
tinyDb.putBoolean("hasIssues", repoEnableIssues);
|
tinyDB.putBoolean("hasIssues", repoEnableIssues);
|
||||||
tinyDb.putBoolean("hasPullRequests", repoEnablePr);
|
tinyDB.putBoolean("hasPullRequests", repoEnablePr);
|
||||||
|
|
||||||
dialogProp.dismiss();
|
dialogProp.dismiss();
|
||||||
Toasty.success(ctx, getString(R.string.repoPropertiesSaveSuccess));
|
Toasty.success(ctx, getString(R.string.repoPropertiesSaveSuccess));
|
||||||
@ -399,7 +386,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||||||
if(!repositoryName.equals(repoName)) {
|
if(!repositoryName.equals(repoName)) {
|
||||||
|
|
||||||
finish();
|
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);
|
Intent intent = new Intent(RepositorySettingsActivity.this, MainActivity.class);
|
||||||
RepositorySettingsActivity.this.startActivity(intent);
|
RepositorySettingsActivity.this.startActivity(intent);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package org.mian.gitnex.activities;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
@ -9,11 +8,7 @@ import android.widget.TextView;
|
|||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import com.google.android.material.switchmaterial.SwitchMaterial;
|
import com.google.android.material.switchmaterial.SwitchMaterial;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Author M M Arif
|
* Author M M Arif
|
||||||
@ -21,15 +16,11 @@ import java.util.List;
|
|||||||
|
|
||||||
public class SettingsAppearanceActivity extends BaseActivity {
|
public class SettingsAppearanceActivity extends BaseActivity {
|
||||||
|
|
||||||
private Context appCtx;
|
|
||||||
private View.OnClickListener onClickListener;
|
private View.OnClickListener onClickListener;
|
||||||
|
|
||||||
private static final String[] timeList = {"Pretty", "Normal"};
|
private static final String[] timeList = {"Pretty", "Normal"};
|
||||||
private static int timeSelectedChoice = 0;
|
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 final String[] customFontList = {"Roboto", "Manrope", "Source Code Pro"};
|
||||||
private static int customFontSelectedChoice = 0;
|
private static int customFontSelectedChoice = 0;
|
||||||
|
|
||||||
@ -46,19 +37,14 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
|
||||||
|
|
||||||
ImageView closeActivity = findViewById(R.id.close);
|
ImageView closeActivity = findViewById(R.id.close);
|
||||||
|
|
||||||
final TextView tvDateTimeSelected = findViewById(R.id.tvDateTimeSelected); // setter for time
|
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 customFontSelected = findViewById(R.id.customFontSelected); // setter for custom font
|
||||||
final TextView themeSelected = findViewById(R.id.themeSelected); // setter for theme
|
final TextView themeSelected = findViewById(R.id.themeSelected); // setter for theme
|
||||||
|
|
||||||
LinearLayout timeFrame = findViewById(R.id.timeFrame);
|
LinearLayout timeFrame = findViewById(R.id.timeFrame);
|
||||||
LinearLayout codeBlockFrame = findViewById(R.id.codeBlockFrame);
|
|
||||||
LinearLayout customFontFrame = findViewById(R.id.customFontFrame);
|
LinearLayout customFontFrame = findViewById(R.id.customFontFrame);
|
||||||
LinearLayout themeFrame = findViewById(R.id.themeSelectionFrame);
|
LinearLayout themeFrame = findViewById(R.id.themeSelectionFrame);
|
||||||
|
|
||||||
@ -67,124 +53,42 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
|||||||
initCloseListener();
|
initCloseListener();
|
||||||
closeActivity.setOnClickListener(onClickListener);
|
closeActivity.setOnClickListener(onClickListener);
|
||||||
|
|
||||||
// code block
|
if(!tinyDB.getString("timeStr").isEmpty()) {
|
||||||
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)};
|
|
||||||
|
|
||||||
codeBlockList = new ArrayList<>(Arrays.asList(codeBlockList_));
|
tvDateTimeSelected.setText(tinyDB.getString("timeStr"));
|
||||||
String[] codeBlockArray = new String[codeBlockList.size()];
|
|
||||||
codeBlockList.toArray(codeBlockArray);
|
|
||||||
|
|
||||||
if(codeBlockSelectedChoice == 0) {
|
|
||||||
|
|
||||||
codeBlockSelectedChoice = tinyDb.getInt("codeBlockId");
|
|
||||||
codeBlockSelected.setText(getResources().getString(R.string.codeBlockGreenOnBlack));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(codeBlockSelectedChoice == 1) {
|
if(!tinyDB.getString("customFontStr").isEmpty()) {
|
||||||
|
|
||||||
codeBlockSelected.setText(getResources().getString(R.string.codeBlockWhiteOnBlack));
|
customFontSelected.setText(tinyDB.getString("customFontStr"));
|
||||||
}
|
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
codeBlockFrame.setOnClickListener(codeBlock -> {
|
if(!tinyDB.getString("themeStr").isEmpty()) {
|
||||||
|
|
||||||
AlertDialog.Builder cBuilder = new AlertDialog.Builder(SettingsAppearanceActivity.this);
|
themeSelected.setText(tinyDB.getString("themeStr"));
|
||||||
|
|
||||||
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"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(timeSelectedChoice == 0) {
|
if(timeSelectedChoice == 0) {
|
||||||
|
|
||||||
timeSelectedChoice = tinyDb.getInt("timeId");
|
timeSelectedChoice = tinyDB.getInt("timeId");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(customFontSelectedChoice == 0) {
|
if(customFontSelectedChoice == 0) {
|
||||||
|
|
||||||
customFontSelectedChoice = tinyDb.getInt("customFontId", 1);
|
customFontSelectedChoice = tinyDB.getInt("customFontId", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(themeSelectedChoice == 0) {
|
if(themeSelectedChoice == 0) {
|
||||||
|
|
||||||
themeSelectedChoice = tinyDb.getInt("themeId");
|
themeSelectedChoice = tinyDB.getInt("themeId");
|
||||||
}
|
}
|
||||||
|
|
||||||
counterBadgesSwitch.setChecked(tinyDb.getBoolean("enableCounterBadges"));
|
counterBadgesSwitch.setChecked(tinyDB.getBoolean("enableCounterBadges"));
|
||||||
|
|
||||||
// counter badge switcher
|
// counter badge switcher
|
||||||
counterBadgesSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
counterBadgesSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||||
|
|
||||||
tinyDb.putBoolean("enableCounterBadges", isChecked);
|
tinyDB.putBoolean("enableCounterBadges", isChecked);
|
||||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -200,10 +104,10 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
|||||||
|
|
||||||
themeSelectedChoice = i;
|
themeSelectedChoice = i;
|
||||||
themeSelected.setText(themeList[i]);
|
themeSelected.setText(themeList[i]);
|
||||||
tinyDb.putString("themeStr", themeList[i]);
|
tinyDB.putString("themeStr", themeList[i]);
|
||||||
tinyDb.putInt("themeId", i);
|
tinyDB.putInt("themeId", i);
|
||||||
|
|
||||||
tinyDb.putBoolean("refreshParent", true);
|
tinyDB.putBoolean("refreshParent", true);
|
||||||
this.recreate();
|
this.recreate();
|
||||||
this.overridePendingTransition(0, 0);
|
this.overridePendingTransition(0, 0);
|
||||||
dialogInterfaceTheme.dismiss();
|
dialogInterfaceTheme.dismiss();
|
||||||
@ -226,10 +130,10 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
|||||||
|
|
||||||
customFontSelectedChoice = i;
|
customFontSelectedChoice = i;
|
||||||
customFontSelected.setText(customFontList[i]);
|
customFontSelected.setText(customFontList[i]);
|
||||||
tinyDb.putString("customFontStr", customFontList[i]);
|
tinyDB.putString("customFontStr", customFontList[i]);
|
||||||
tinyDb.putInt("customFontId", i);
|
tinyDB.putInt("customFontId", i);
|
||||||
|
|
||||||
tinyDb.putBoolean("refreshParent", true);
|
tinyDB.putBoolean("refreshParent", true);
|
||||||
this.recreate();
|
this.recreate();
|
||||||
this.overridePendingTransition(0, 0);
|
this.overridePendingTransition(0, 0);
|
||||||
dialogInterfaceCustomFont.dismiss();
|
dialogInterfaceCustomFont.dismiss();
|
||||||
@ -252,16 +156,16 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
|||||||
|
|
||||||
timeSelectedChoice = i;
|
timeSelectedChoice = i;
|
||||||
tvDateTimeSelected.setText(timeList[i]);
|
tvDateTimeSelected.setText(timeList[i]);
|
||||||
tinyDb.putString("timeStr", timeList[i]);
|
tinyDB.putString("timeStr", timeList[i]);
|
||||||
tinyDb.putInt("timeId", i);
|
tinyDB.putInt("timeId", i);
|
||||||
|
|
||||||
if("Normal".equals(timeList[i])) {
|
if("Normal".equals(timeList[i])) {
|
||||||
|
|
||||||
tinyDb.putString("dateFormat", "normal");
|
tinyDB.putString("dateFormat", "normal");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
tinyDb.putString("dateFormat", "pretty");
|
tinyDB.putString("dateFormat", "pretty");
|
||||||
}
|
}
|
||||||
|
|
||||||
dialogInterfaceTime.dismiss();
|
dialogInterfaceTime.dismiss();
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
package org.mian.gitnex.activities;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import com.google.android.material.switchmaterial.SwitchMaterial;
|
import com.google.android.material.switchmaterial.SwitchMaterial;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -15,7 +13,6 @@ import org.mian.gitnex.helpers.Toasty;
|
|||||||
|
|
||||||
public class SettingsDraftsActivity extends BaseActivity {
|
public class SettingsDraftsActivity extends BaseActivity {
|
||||||
|
|
||||||
private Context appCtx;
|
|
||||||
private View.OnClickListener onClickListener;
|
private View.OnClickListener onClickListener;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -28,9 +25,6 @@ public class SettingsDraftsActivity extends BaseActivity {
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(appCtx);
|
|
||||||
|
|
||||||
ImageView closeActivity = findViewById(R.id.close);
|
ImageView closeActivity = findViewById(R.id.close);
|
||||||
|
|
||||||
@ -39,12 +33,12 @@ public class SettingsDraftsActivity extends BaseActivity {
|
|||||||
|
|
||||||
SwitchMaterial commentsDeletionSwitch = findViewById(R.id.commentsDeletionSwitch);
|
SwitchMaterial commentsDeletionSwitch = findViewById(R.id.commentsDeletionSwitch);
|
||||||
|
|
||||||
commentsDeletionSwitch.setChecked(tinyDb.getBoolean("draftsCommentsDeletionEnabled"));
|
commentsDeletionSwitch.setChecked(tinyDB.getBoolean("draftsCommentsDeletionEnabled"));
|
||||||
|
|
||||||
// delete comments on submit switcher
|
// delete comments on submit switcher
|
||||||
commentsDeletionSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
commentsDeletionSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||||
|
|
||||||
tinyDb.putBoolean("draftsCommentsDeletionEnabled", isChecked);
|
tinyDB.putBoolean("draftsCommentsDeletionEnabled", isChecked);
|
||||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package org.mian.gitnex.activities;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
@ -9,7 +8,6 @@ import android.widget.TextView;
|
|||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import com.google.android.material.switchmaterial.SwitchMaterial;
|
import com.google.android.material.switchmaterial.SwitchMaterial;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -18,7 +16,6 @@ import org.mian.gitnex.helpers.Toasty;
|
|||||||
|
|
||||||
public class SettingsFileViewerActivity extends BaseActivity {
|
public class SettingsFileViewerActivity extends BaseActivity {
|
||||||
|
|
||||||
private Context appCtx;
|
|
||||||
private View.OnClickListener onClickListener;
|
private View.OnClickListener onClickListener;
|
||||||
|
|
||||||
private static final String[] fileViewerSourceCodeThemesList = {"Sublime", "Arduino Light", "Github", "Far ", "Ir Black", "Android Studio"};
|
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) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
|
||||||
|
|
||||||
ImageView closeActivity = findViewById(R.id.close);
|
ImageView closeActivity = findViewById(R.id.close);
|
||||||
|
|
||||||
@ -49,15 +43,15 @@ public class SettingsFileViewerActivity extends BaseActivity {
|
|||||||
|
|
||||||
SwitchMaterial pdfModeSwitch = findViewById(R.id.switchPdfMode);
|
SwitchMaterial pdfModeSwitch = findViewById(R.id.switchPdfMode);
|
||||||
|
|
||||||
if(!tinyDb.getString("fileviewerSourceCodeThemeStr").isEmpty()) {
|
if(!tinyDB.getString("fileviewerSourceCodeThemeStr").isEmpty()) {
|
||||||
fileViewerSourceCodeThemesSelected.setText(tinyDb.getString("fileviewerSourceCodeThemeStr"));
|
fileViewerSourceCodeThemesSelected.setText(tinyDB.getString("fileviewerSourceCodeThemeStr"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(fileViewerSourceCodeThemesSelectedChoice == 0) {
|
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
|
// fileviewer srouce code theme selection dialog
|
||||||
sourceCodeThemeFrame.setOnClickListener(view -> {
|
sourceCodeThemeFrame.setOnClickListener(view -> {
|
||||||
@ -71,8 +65,8 @@ public class SettingsFileViewerActivity extends BaseActivity {
|
|||||||
|
|
||||||
fileViewerSourceCodeThemesSelectedChoice = i;
|
fileViewerSourceCodeThemesSelectedChoice = i;
|
||||||
fileViewerSourceCodeThemesSelected.setText(fileViewerSourceCodeThemesList[i]);
|
fileViewerSourceCodeThemesSelected.setText(fileViewerSourceCodeThemesList[i]);
|
||||||
tinyDb.putString("fileviewerSourceCodeThemeStr", fileViewerSourceCodeThemesList[i]);
|
tinyDB.putString("fileviewerSourceCodeThemeStr", fileViewerSourceCodeThemesList[i]);
|
||||||
tinyDb.putInt("fileviewerSourceCodeThemeId", i);
|
tinyDB.putInt("fileviewerSourceCodeThemeId", i);
|
||||||
|
|
||||||
dialogInterfaceTheme.dismiss();
|
dialogInterfaceTheme.dismiss();
|
||||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||||
@ -86,8 +80,8 @@ public class SettingsFileViewerActivity extends BaseActivity {
|
|||||||
// pdf night mode switcher
|
// pdf night mode switcher
|
||||||
pdfModeSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
pdfModeSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||||
|
|
||||||
tinyDb.putBoolean("enablePdfMode", isChecked);
|
tinyDB.putBoolean("enablePdfMode", isChecked);
|
||||||
tinyDb.putString("enablePdfModeInit", "yes");
|
tinyDB.putString("enablePdfModeInit", "yes");
|
||||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
package org.mian.gitnex.activities;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.databinding.ActivitySettingsGeneralBinding;
|
import org.mian.gitnex.databinding.ActivitySettingsGeneralBinding;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
import org.mian.gitnex.helpers.Version;
|
import org.mian.gitnex.helpers.Version;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -20,7 +18,6 @@ import java.util.List;
|
|||||||
public class SettingsGeneralActivity extends BaseActivity {
|
public class SettingsGeneralActivity extends BaseActivity {
|
||||||
|
|
||||||
private ActivitySettingsGeneralBinding viewBinding;
|
private ActivitySettingsGeneralBinding viewBinding;
|
||||||
private Context appCtx;
|
|
||||||
private View.OnClickListener onClickListener;
|
private View.OnClickListener onClickListener;
|
||||||
|
|
||||||
private List<String> homeScreenList;
|
private List<String> homeScreenList;
|
||||||
@ -39,14 +36,11 @@ public class SettingsGeneralActivity extends BaseActivity {
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
|
|
||||||
viewBinding = ActivitySettingsGeneralBinding.inflate(getLayoutInflater());
|
viewBinding = ActivitySettingsGeneralBinding.inflate(getLayoutInflater());
|
||||||
View view = viewBinding.getRoot();
|
View view = viewBinding.getRoot();
|
||||||
setContentView(view);
|
setContentView(view);
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(appCtx);
|
|
||||||
|
|
||||||
initCloseListener();
|
initCloseListener();
|
||||||
viewBinding.close.setOnClickListener(onClickListener);
|
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.pageTitleRepositories), getResources().getString(R.string.pageTitleProfile), getResources().getString(R.string.pageTitleExplore),
|
||||||
getResources().getString(R.string.titleDrafts), getResources().getString(R.string.pageTitleNotifications)};
|
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;
|
homeDefaultScreen_ = homeDefaultScreenNew;
|
||||||
}
|
}
|
||||||
@ -70,7 +64,7 @@ public class SettingsGeneralActivity extends BaseActivity {
|
|||||||
|
|
||||||
if(homeScreenSelectedChoice == 0) {
|
if(homeScreenSelectedChoice == 0) {
|
||||||
|
|
||||||
homeScreenSelectedChoice = tinyDb.getInt("homeScreenId");
|
homeScreenSelectedChoice = tinyDB.getInt("homeScreenId");
|
||||||
viewBinding.homeScreenSelected.setText(getResources().getString(R.string.pageTitleMyRepos));
|
viewBinding.homeScreenSelected.setText(getResources().getString(R.string.pageTitleMyRepos));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,7 +108,7 @@ public class SettingsGeneralActivity extends BaseActivity {
|
|||||||
|
|
||||||
homeScreenSelectedChoice = i;
|
homeScreenSelectedChoice = i;
|
||||||
viewBinding.homeScreenSelected.setText(homeScreenArray[i]);
|
viewBinding.homeScreenSelected.setText(homeScreenArray[i]);
|
||||||
tinyDb.putInt("homeScreenId", i);
|
tinyDB.putInt("homeScreenId", i);
|
||||||
|
|
||||||
dialogInterfaceHomeScreen.dismiss();
|
dialogInterfaceHomeScreen.dismiss();
|
||||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||||
@ -134,7 +128,7 @@ public class SettingsGeneralActivity extends BaseActivity {
|
|||||||
|
|
||||||
if(defaultLinkHandlerScreenSelectedChoice == 0) {
|
if(defaultLinkHandlerScreenSelectedChoice == 0) {
|
||||||
|
|
||||||
defaultLinkHandlerScreenSelectedChoice = tinyDb.getInt("defaultScreenId");
|
defaultLinkHandlerScreenSelectedChoice = tinyDB.getInt("defaultScreenId");
|
||||||
viewBinding.generalDeepLinkSelected.setText(getResources().getString(R.string.generalDeepLinkSelectedText));
|
viewBinding.generalDeepLinkSelected.setText(getResources().getString(R.string.generalDeepLinkSelectedText));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,7 +160,7 @@ public class SettingsGeneralActivity extends BaseActivity {
|
|||||||
|
|
||||||
defaultLinkHandlerScreenSelectedChoice = i;
|
defaultLinkHandlerScreenSelectedChoice = i;
|
||||||
viewBinding.generalDeepLinkSelected.setText(linksArray[i]);
|
viewBinding.generalDeepLinkSelected.setText(linksArray[i]);
|
||||||
tinyDb.putInt("defaultScreenId", i);
|
tinyDB.putInt("defaultScreenId", i);
|
||||||
|
|
||||||
dialogInterfaceHomeScreen.dismiss();
|
dialogInterfaceHomeScreen.dismiss();
|
||||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
package org.mian.gitnex.activities;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import com.google.android.material.switchmaterial.SwitchMaterial;
|
import com.google.android.material.switchmaterial.SwitchMaterial;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -15,7 +13,6 @@ import org.mian.gitnex.helpers.Toasty;
|
|||||||
|
|
||||||
public class SettingsReportsActivity extends BaseActivity {
|
public class SettingsReportsActivity extends BaseActivity {
|
||||||
|
|
||||||
private Context appCtx;
|
|
||||||
private View.OnClickListener onClickListener;
|
private View.OnClickListener onClickListener;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -28,9 +25,6 @@ public class SettingsReportsActivity extends BaseActivity {
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(appCtx);
|
|
||||||
|
|
||||||
ImageView closeActivity = findViewById(R.id.close);
|
ImageView closeActivity = findViewById(R.id.close);
|
||||||
|
|
||||||
@ -39,12 +33,12 @@ public class SettingsReportsActivity extends BaseActivity {
|
|||||||
|
|
||||||
SwitchMaterial crashReportsSwitch = findViewById(R.id.crashReportsSwitch);
|
SwitchMaterial crashReportsSwitch = findViewById(R.id.crashReportsSwitch);
|
||||||
|
|
||||||
crashReportsSwitch.setChecked(tinyDb.getBoolean("crashReportingEnabled"));
|
crashReportsSwitch.setChecked(tinyDB.getBoolean("crashReportingEnabled"));
|
||||||
|
|
||||||
// crash reports switcher
|
// crash reports switcher
|
||||||
crashReportsSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
crashReportsSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||||
|
|
||||||
tinyDb.putBoolean("crashReportingEnabled", isChecked);
|
tinyDB.putBoolean("crashReportingEnabled", isChecked);
|
||||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,6 @@ import android.widget.TextView;
|
|||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
import org.mian.gitnex.helpers.Version;
|
import org.mian.gitnex.helpers.Version;
|
||||||
import org.mian.gitnex.helpers.ssl.MemorizingTrustManager;
|
import org.mian.gitnex.helpers.ssl.MemorizingTrustManager;
|
||||||
@ -26,9 +25,6 @@ import java.io.IOException;
|
|||||||
|
|
||||||
public class SettingsSecurityActivity extends BaseActivity {
|
public class SettingsSecurityActivity extends BaseActivity {
|
||||||
|
|
||||||
private Context appCtx;
|
|
||||||
private Context ctx = this;
|
|
||||||
|
|
||||||
private View.OnClickListener onClickListener;
|
private View.OnClickListener onClickListener;
|
||||||
|
|
||||||
private static String[] cacheSizeDataList = {"50 MB", "100 MB", "250 MB", "500 MB", "1 GB"};
|
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) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(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);
|
ImageView closeActivity = findViewById(R.id.close);
|
||||||
|
|
||||||
@ -72,24 +66,24 @@ public class SettingsSecurityActivity extends BaseActivity {
|
|||||||
LinearLayout cacheSizeImagesFrame = findViewById(R.id.cacheSizeImagesSelectionFrame);
|
LinearLayout cacheSizeImagesFrame = findViewById(R.id.cacheSizeImagesSelectionFrame);
|
||||||
LinearLayout clearCacheFrame = findViewById(R.id.clearCacheSelectionFrame);
|
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) {
|
if(cacheSizeDataSelectedChoice == 0) {
|
||||||
|
|
||||||
cacheSizeDataSelectedChoice = tinyDb.getInt("cacheSizeId");
|
cacheSizeDataSelectedChoice = tinyDB.getInt("cacheSizeId");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cacheSizeImagesSelectedChoice == 0) {
|
if(cacheSizeImagesSelectedChoice == 0) {
|
||||||
|
|
||||||
cacheSizeImagesSelectedChoice = tinyDb.getInt("cacheSizeImagesId");
|
cacheSizeImagesSelectedChoice = tinyDB.getInt("cacheSizeImagesId");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(new Version(currentVersion).less("1.12.3")) {
|
if(new Version(currentVersion).less("1.12.3")) {
|
||||||
@ -97,7 +91,7 @@ public class SettingsSecurityActivity extends BaseActivity {
|
|||||||
pollingDelayFrame.setVisibility(View.GONE);
|
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
|
// clear cache setter
|
||||||
File cacheDir = appCtx.getCacheDir();
|
File cacheDir = appCtx.getCacheDir();
|
||||||
@ -142,8 +136,8 @@ public class SettingsSecurityActivity extends BaseActivity {
|
|||||||
|
|
||||||
cacheSizeImagesSelectedChoice = i;
|
cacheSizeImagesSelectedChoice = i;
|
||||||
cacheSizeImagesSelected.setText(cacheSizeImagesList[i]);
|
cacheSizeImagesSelected.setText(cacheSizeImagesList[i]);
|
||||||
tinyDb.putString("cacheSizeImagesStr", cacheSizeImagesList[i]);
|
tinyDB.putString("cacheSizeImagesStr", cacheSizeImagesList[i]);
|
||||||
tinyDb.putInt("cacheSizeImagesId", i);
|
tinyDB.putInt("cacheSizeImagesId", i);
|
||||||
|
|
||||||
dialogInterfaceTheme.dismiss();
|
dialogInterfaceTheme.dismiss();
|
||||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||||
@ -165,8 +159,8 @@ public class SettingsSecurityActivity extends BaseActivity {
|
|||||||
|
|
||||||
cacheSizeDataSelectedChoice = i;
|
cacheSizeDataSelectedChoice = i;
|
||||||
cacheSizeDataSelected.setText(cacheSizeDataList[i]);
|
cacheSizeDataSelected.setText(cacheSizeDataList[i]);
|
||||||
tinyDb.putString("cacheSizeStr", cacheSizeDataList[i]);
|
tinyDB.putString("cacheSizeStr", cacheSizeDataList[i]);
|
||||||
tinyDb.putInt("cacheSizeId", i);
|
tinyDB.putInt("cacheSizeId", i);
|
||||||
|
|
||||||
dialogInterfaceTheme.dismiss();
|
dialogInterfaceTheme.dismiss();
|
||||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
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();
|
appCtx.getSharedPreferences(MemorizingTrustManager.KEYSTORE_NAME, Context.MODE_PRIVATE).edit().remove(MemorizingTrustManager.KEYSTORE_KEY).apply();
|
||||||
|
|
||||||
tinyDb.putBoolean("loggedInMode", false);
|
tinyDB.putBoolean("loggedInMode", false);
|
||||||
tinyDb.remove("basicAuthPassword");
|
tinyDB.remove("basicAuthPassword");
|
||||||
tinyDb.putBoolean("basicAuthFlag", false);
|
tinyDB.putBoolean("basicAuthFlag", false);
|
||||||
|
|
||||||
Intent loginActivityIntent = new Intent().setClass(appCtx, LoginActivity.class);
|
Intent loginActivityIntent = new Intent().setClass(appCtx, LoginActivity.class);
|
||||||
loginActivityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
loginActivityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
@ -206,7 +200,7 @@ public class SettingsSecurityActivity extends BaseActivity {
|
|||||||
NumberPicker numberPicker = new NumberPicker(ctx);
|
NumberPicker numberPicker = new NumberPicker(ctx);
|
||||||
numberPicker.setMinValue(MINIMUM_POLLING_DELAY);
|
numberPicker.setMinValue(MINIMUM_POLLING_DELAY);
|
||||||
numberPicker.setMaxValue(MAXIMUM_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);
|
numberPicker.setWrapSelectorWheel(true);
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
|
AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
|
||||||
@ -216,7 +210,7 @@ public class SettingsSecurityActivity extends BaseActivity {
|
|||||||
builder.setCancelable(true);
|
builder.setCancelable(true);
|
||||||
builder.setPositiveButton(getString(R.string.okButton), (dialog, which) -> {
|
builder.setPositiveButton(getString(R.string.okButton), (dialog, which) -> {
|
||||||
|
|
||||||
tinyDb.putInt("pollingDelayMinutes", numberPicker.getValue());
|
tinyDB.putInt("pollingDelayMinutes", numberPicker.getValue());
|
||||||
|
|
||||||
NotificationsMaster.fireWorker(ctx);
|
NotificationsMaster.fireWorker(ctx);
|
||||||
NotificationsMaster.hireWorker(ctx);
|
NotificationsMaster.hireWorker(ctx);
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package org.mian.gitnex.activities;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@ -10,7 +9,6 @@ import android.widget.LinearLayout;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -19,7 +17,6 @@ import org.mian.gitnex.helpers.Toasty;
|
|||||||
|
|
||||||
public class SettingsTranslationActivity extends BaseActivity {
|
public class SettingsTranslationActivity extends BaseActivity {
|
||||||
|
|
||||||
private Context appCtx;
|
|
||||||
private View.OnClickListener onClickListener;
|
private View.OnClickListener onClickListener;
|
||||||
|
|
||||||
private static String[] langList = {"English", "Arabic", "Chinese", "Czech", "Finnish", "French", "German", "Italian", "Latvian", "Persian",
|
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) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(appCtx);
|
|
||||||
|
|
||||||
ImageView closeActivity = findViewById(R.id.close);
|
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) {
|
if(langSelectedChoice == 0) {
|
||||||
|
|
||||||
langSelectedChoice = tinyDb.getInt("langId");
|
langSelectedChoice = tinyDB.getInt("langId");
|
||||||
}
|
}
|
||||||
|
|
||||||
// language dialog
|
// language dialog
|
||||||
@ -82,81 +76,81 @@ public class SettingsTranslationActivity extends BaseActivity {
|
|||||||
|
|
||||||
langSelectedChoice = i;
|
langSelectedChoice = i;
|
||||||
tvLanguageSelected.setText(langList[i]);
|
tvLanguageSelected.setText(langList[i]);
|
||||||
tinyDb.putString("localeStr", langList[i]);
|
tinyDB.putString("localeStr", langList[i]);
|
||||||
tinyDb.putInt("langId", i);
|
tinyDB.putInt("langId", i);
|
||||||
|
|
||||||
switch(langList[i]) {
|
switch(langList[i]) {
|
||||||
case "Arabic":
|
case "Arabic":
|
||||||
|
|
||||||
tinyDb.putString("locale", "ar");
|
tinyDB.putString("locale", "ar");
|
||||||
break;
|
break;
|
||||||
case "Chinese":
|
case "Chinese":
|
||||||
|
|
||||||
tinyDb.putString("locale", "zh");
|
tinyDB.putString("locale", "zh");
|
||||||
break;
|
break;
|
||||||
case "Czech":
|
case "Czech":
|
||||||
|
|
||||||
tinyDb.putString("locale", "cs");
|
tinyDB.putString("locale", "cs");
|
||||||
break;
|
break;
|
||||||
case "Finnish":
|
case "Finnish":
|
||||||
|
|
||||||
tinyDb.putString("locale", "fi");
|
tinyDB.putString("locale", "fi");
|
||||||
break;
|
break;
|
||||||
case "French":
|
case "French":
|
||||||
|
|
||||||
tinyDb.putString("locale", "fr");
|
tinyDB.putString("locale", "fr");
|
||||||
break;
|
break;
|
||||||
case "German":
|
case "German":
|
||||||
|
|
||||||
tinyDb.putString("locale", "de");
|
tinyDB.putString("locale", "de");
|
||||||
break;
|
break;
|
||||||
case "Italian":
|
case "Italian":
|
||||||
|
|
||||||
tinyDb.putString("locale", "it");
|
tinyDB.putString("locale", "it");
|
||||||
break;
|
break;
|
||||||
case "Latvian":
|
case "Latvian":
|
||||||
|
|
||||||
tinyDb.putString("locale", "lv");
|
tinyDB.putString("locale", "lv");
|
||||||
break;
|
break;
|
||||||
case "Persian":
|
case "Persian":
|
||||||
|
|
||||||
tinyDb.putString("locale", "fa");
|
tinyDB.putString("locale", "fa");
|
||||||
break;
|
break;
|
||||||
case "Polish":
|
case "Polish":
|
||||||
|
|
||||||
tinyDb.putString("locale", "pl");
|
tinyDB.putString("locale", "pl");
|
||||||
break;
|
break;
|
||||||
case "Portuguese/Brazilian":
|
case "Portuguese/Brazilian":
|
||||||
|
|
||||||
tinyDb.putString("locale", "pt");
|
tinyDB.putString("locale", "pt");
|
||||||
break;
|
break;
|
||||||
case "Russian":
|
case "Russian":
|
||||||
|
|
||||||
tinyDb.putString("locale", "ru");
|
tinyDB.putString("locale", "ru");
|
||||||
break;
|
break;
|
||||||
case "Serbian":
|
case "Serbian":
|
||||||
|
|
||||||
tinyDb.putString("locale", "sr");
|
tinyDB.putString("locale", "sr");
|
||||||
break;
|
break;
|
||||||
case "Spanish":
|
case "Spanish":
|
||||||
|
|
||||||
tinyDb.putString("locale", "es");
|
tinyDB.putString("locale", "es");
|
||||||
break;
|
break;
|
||||||
case "Turkish":
|
case "Turkish":
|
||||||
|
|
||||||
tinyDb.putString("locale", "tr");
|
tinyDB.putString("locale", "tr");
|
||||||
break;
|
break;
|
||||||
case "Ukrainian":
|
case "Ukrainian":
|
||||||
|
|
||||||
tinyDb.putString("locale", "uk");
|
tinyDB.putString("locale", "uk");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
||||||
tinyDb.putString("locale", "en");
|
tinyDB.putString("locale", "en");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
tinyDb.putBoolean("refreshParent", true);
|
tinyDB.putBoolean("refreshParent", true);
|
||||||
this.recreate();
|
this.recreate();
|
||||||
this.overridePendingTransition(0, 0);
|
this.overridePendingTransition(0, 0);
|
||||||
dialogInterface.dismiss();
|
dialogInterface.dismiss();
|
||||||
|
@ -112,7 +112,7 @@ public class CommitsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
|||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
void bindData(Commits commitsModel) {
|
void bindData(Commits commitsModel) {
|
||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(ctx);
|
final TinyDB tinyDb = TinyDB.getInstance(ctx);
|
||||||
final String locale = tinyDb.getString("locale");
|
final String locale = tinyDb.getString("locale");
|
||||||
final String timeFormat = tinyDb.getString("dateFormat");
|
final String timeFormat = tinyDb.getString("dateFormat");
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package org.mian.gitnex.adapters;
|
|||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.text.Spanned;
|
import android.text.Spanned;
|
||||||
@ -14,9 +15,11 @@ import androidx.annotation.NonNull;
|
|||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
|
import org.mian.gitnex.activities.IssueDetailActivity;
|
||||||
import org.mian.gitnex.database.api.DraftsApi;
|
import org.mian.gitnex.database.api.DraftsApi;
|
||||||
import org.mian.gitnex.database.models.DraftWithRepository;
|
import org.mian.gitnex.database.models.DraftWithRepository;
|
||||||
import org.mian.gitnex.fragments.BottomSheetReplyFragment;
|
import org.mian.gitnex.fragments.BottomSheetReplyFragment;
|
||||||
|
import org.mian.gitnex.helpers.Markdown;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
import org.mian.gitnex.helpers.TinyDB;
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -28,21 +31,16 @@ import java.util.List;
|
|||||||
public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsViewHolder> {
|
public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsViewHolder> {
|
||||||
|
|
||||||
private List<DraftWithRepository> draftsList;
|
private List<DraftWithRepository> draftsList;
|
||||||
private FragmentManager fragmentManager;
|
private final FragmentManager fragmentManager;
|
||||||
private Context mCtx;
|
private final Context mCtx;
|
||||||
|
|
||||||
class DraftsViewHolder extends RecyclerView.ViewHolder {
|
class DraftsViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
private TextView draftText;
|
private DraftWithRepository draftWithRepository;
|
||||||
private TextView repoInfo;
|
|
||||||
private TextView repoId;
|
private final TextView draftText;
|
||||||
private TextView draftId;
|
private final TextView repoInfo;
|
||||||
private TextView issueNumber;
|
private final ImageView editCommentStatus;
|
||||||
private TextView issueType;
|
|
||||||
private TextView repoOwner;
|
|
||||||
private TextView repoName;
|
|
||||||
private TextView commentId;
|
|
||||||
private ImageView editCommentStatus;
|
|
||||||
|
|
||||||
private DraftsViewHolder(View itemView) {
|
private DraftsViewHolder(View itemView) {
|
||||||
|
|
||||||
@ -50,19 +48,12 @@ public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsView
|
|||||||
|
|
||||||
draftText = itemView.findViewById(R.id.draftText);
|
draftText = itemView.findViewById(R.id.draftText);
|
||||||
repoInfo = itemView.findViewById(R.id.repoInfo);
|
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);
|
ImageView deleteDraft = itemView.findViewById(R.id.deleteDraft);
|
||||||
editCommentStatus = itemView.findViewById(R.id.editCommentStatus);
|
editCommentStatus = itemView.findViewById(R.id.editCommentStatus);
|
||||||
|
|
||||||
deleteDraft.setOnClickListener(itemDelete -> {
|
deleteDraft.setOnClickListener(itemDelete -> {
|
||||||
|
|
||||||
int getDraftId = Integer.parseInt(draftId.getText().toString());
|
int getDraftId = draftWithRepository.getDraftId();
|
||||||
deleteDraft(getAdapterPosition());
|
deleteDraft(getAdapterPosition());
|
||||||
DraftsApi draftsApi = new DraftsApi(mCtx);
|
DraftsApi draftsApi = new DraftsApi(mCtx);
|
||||||
draftsApi.deleteSingleDraft(getDraftId);
|
draftsApi.deleteSingleDraft(getDraftId);
|
||||||
@ -73,23 +64,26 @@ public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsView
|
|||||||
|
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
|
|
||||||
bundle.putString("commentBody", draftText.getText().toString());
|
bundle.putString("commentBody", draftWithRepository.getDraftText());
|
||||||
bundle.putString("issueNumber", issueNumber.getText().toString());
|
bundle.putString("issueNumber", String.valueOf(draftWithRepository.getIssueId()));
|
||||||
bundle.putString("repositoryId", repoId.getText().toString());
|
bundle.putString("repositoryId", String.valueOf(draftWithRepository.getRepositoryId()));
|
||||||
bundle.putString("draftTitle", repoInfo.getText().toString());
|
bundle.putString("draftTitle", repoInfo.getText().toString());
|
||||||
bundle.putString("commentId", commentId.getText().toString());
|
bundle.putString("commentId", draftWithRepository.getCommentId());
|
||||||
bundle.putString("draftId", draftId.getText().toString());
|
bundle.putString("draftId", String.valueOf(draftWithRepository.getDraftId()));
|
||||||
|
|
||||||
if(!commentId.getText().toString().isEmpty()) {
|
if(!draftWithRepository.getCommentId().isEmpty()) {
|
||||||
bundle.putString("commentAction", "edit");
|
bundle.putString("commentAction", "edit");
|
||||||
}
|
}
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(mCtx);
|
TinyDB tinyDb = TinyDB.getInstance(mCtx);
|
||||||
tinyDb.putString("issueNumber", issueNumber.getText().toString());
|
tinyDb.putString("issueNumber", String.valueOf(draftWithRepository.getIssueId()));
|
||||||
tinyDb.putLong("repositoryId", Long.parseLong(repoId.getText().toString()));
|
tinyDb.putLong("repositoryId", draftWithRepository.getRepositoryId());
|
||||||
//tinyDb.putString("issueType", issueType.getText().toString());
|
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);
|
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>";
|
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());
|
Spanned headTitle = Html.fromHtml(issueNumber + " " + currentItem.getRepositoryOwner() + " / " + currentItem.getRepositoryName());
|
||||||
|
|
||||||
holder.repoInfo.setText(headTitle);
|
holder.repoInfo.setText(headTitle);
|
||||||
|
holder.draftWithRepository = currentItem;
|
||||||
|
|
||||||
|
new Markdown(mCtx, currentItem.getDraftText(), holder.draftText);
|
||||||
|
|
||||||
if(!currentItem.getCommentId().equalsIgnoreCase("new")) {
|
if(!currentItem.getCommentId().equalsIgnoreCase("new")) {
|
||||||
holder.editCommentStatus.setVisibility(View.VISIBLE);
|
holder.editCommentStatus.setVisibility(View.VISIBLE);
|
||||||
@ -144,7 +133,6 @@ public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsView
|
|||||||
else {
|
else {
|
||||||
holder.editCommentStatus.setVisibility(View.GONE);
|
holder.editCommentStatus.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -157,6 +145,4 @@ public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsView
|
|||||||
draftsList = list;
|
draftsList = list;
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
|
|||||||
Intent intent = new Intent(context, RepoDetailActivity.class);
|
Intent intent = new Intent(context, RepoDetailActivity.class);
|
||||||
intent.putExtra("repoFullName", repoFullName.getText().toString());
|
intent.putExtra("repoFullName", repoFullName.getText().toString());
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(context);
|
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
tinyDb.putString("repoFullName", repoFullName.getText().toString());
|
tinyDb.putString("repoFullName", repoFullName.getText().toString());
|
||||||
tinyDb.putBoolean("resumeIssues", true);
|
tinyDb.putBoolean("resumeIssues", true);
|
||||||
tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked());
|
tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked());
|
||||||
@ -128,14 +128,13 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
|
|||||||
//store if user is watching this repo
|
//store if user is watching this repo
|
||||||
{
|
{
|
||||||
|
|
||||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
|
||||||
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
||||||
|
|
||||||
WatchInfo watch = new WatchInfo();
|
WatchInfo watch = new WatchInfo();
|
||||||
|
|
||||||
Call<WatchInfo> call;
|
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>() {
|
call.enqueue(new Callback<WatchInfo>() {
|
||||||
|
|
||||||
|
@ -36,9 +36,9 @@ public class FilesDiffAdapter extends BaseAdapter {
|
|||||||
private static int COLOR_SELECTED;
|
private static int COLOR_SELECTED;
|
||||||
private static int COLOR_FONT;
|
private static int COLOR_FONT;
|
||||||
|
|
||||||
private Context context;
|
private final Context context;
|
||||||
private FragmentManager fragmentManager;
|
private final FragmentManager fragmentManager;
|
||||||
private List<FileDiffView> fileDiffViews;
|
private final List<FileDiffView> fileDiffViews;
|
||||||
|
|
||||||
public FilesDiffAdapter(Context context, FragmentManager fragmentManager, List<FileDiffView> fileDiffViews) {
|
public FilesDiffAdapter(Context context, FragmentManager fragmentManager, List<FileDiffView> fileDiffViews) {
|
||||||
|
|
||||||
@ -185,7 +185,6 @@ public class FilesDiffAdapter extends BaseAdapter {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
diffTextView.setOnLongClickListener(v -> {
|
diffTextView.setOnLongClickListener(v -> {
|
||||||
|
|
||||||
if(((DiffTextView) v).getCurrentBackgroundColor() == COLOR_SELECTED) {
|
if(((DiffTextView) v).getCurrentBackgroundColor() == COLOR_SELECTED) {
|
||||||
|
@ -5,17 +5,13 @@ import android.content.ClipData;
|
|||||||
import android.content.ClipboardManager;
|
import android.content.ClipboardManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.Spanned;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.core.content.ContextCompat;
|
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
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.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.fragments.BottomSheetReplyFragment;
|
import org.mian.gitnex.fragments.BottomSheetReplyFragment;
|
||||||
import org.mian.gitnex.helpers.AlertDialogs;
|
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.RoundedTransformation;
|
||||||
import org.mian.gitnex.helpers.TimeHelper;
|
import org.mian.gitnex.helpers.TimeHelper;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
import org.mian.gitnex.helpers.TinyDB;
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
import org.mian.gitnex.helpers.UserMentions;
|
|
||||||
import org.mian.gitnex.models.IssueComments;
|
import org.mian.gitnex.models.IssueComments;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Objects;
|
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.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
|
|
||||||
@ -62,94 +41,91 @@ import retrofit2.Callback;
|
|||||||
|
|
||||||
public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdapter.IssueCommentViewHolder> {
|
public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdapter.IssueCommentViewHolder> {
|
||||||
|
|
||||||
private List<IssueComments> issuesComments;
|
private final Context ctx;
|
||||||
private FragmentManager fragmentManager;
|
private final List<IssueComments> issuesComments;
|
||||||
private Context mCtx;
|
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.ctx = ctx;
|
||||||
this.fragmentManager = fragmentManager;
|
|
||||||
this.issuesComments = issuesCommentsMain;
|
this.issuesComments = issuesCommentsMain;
|
||||||
|
this.fragmentManager = fragmentManager;
|
||||||
|
this.onInteractedListener = onInteractedListener;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class IssueCommentViewHolder extends RecyclerView.ViewHolder {
|
class IssueCommentViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
private TextView issueNumber;
|
private IssueComments issueComment;
|
||||||
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 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);
|
super(view);
|
||||||
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);
|
|
||||||
|
|
||||||
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 Context ctx = v.getContext();
|
||||||
final TinyDB tinyDb = new TinyDB(ctx);
|
final TinyDB tinyDb = TinyDB.getInstance(ctx);
|
||||||
final String loginUid = tinyDb.getString("loginUid");
|
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 commentMenuEdit = vw.findViewById(R.id.commentMenuEdit);
|
||||||
TextView commentShare = view.findViewById(R.id.issueCommentShare);
|
TextView commentShare = vw.findViewById(R.id.issueCommentShare);
|
||||||
TextView commentMenuQuote = view.findViewById(R.id.commentMenuQuote);
|
TextView commentMenuQuote = vw.findViewById(R.id.commentMenuQuote);
|
||||||
TextView commentMenuCopy = view.findViewById(R.id.commentMenuCopy);
|
TextView commentMenuCopy = vw.findViewById(R.id.commentMenuCopy);
|
||||||
TextView commentMenuDelete = view.findViewById(R.id.commentMenuDelete);
|
TextView commentMenuDelete = vw.findViewById(R.id.commentMenuDelete);
|
||||||
TextView issueCommentCopyUrl = view.findViewById(R.id.issueCommentCopyUrl);
|
TextView issueCommentCopyUrl = vw.findViewById(R.id.issueCommentCopyUrl);
|
||||||
|
|
||||||
if(!loginUid.contentEquals(commenterUsername.getText())) {
|
if(!loginUid.contentEquals(issueComment.getUser().getUsername())) {
|
||||||
commentMenuEdit.setVisibility(View.GONE);
|
commentMenuEdit.setVisibility(View.GONE);
|
||||||
commentMenuDelete.setVisibility(View.GONE);
|
commentMenuDelete.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(issueComment.getText().toString().isEmpty()) {
|
if(issueComment.getBody().isEmpty()) {
|
||||||
commentMenuCopy.setVisibility(View.GONE);
|
commentMenuCopy.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
BottomSheetDialog dialog = new BottomSheetDialog(ctx);
|
BottomSheetDialog dialog = new BottomSheetDialog(ctx);
|
||||||
dialog.setContentView(view);
|
dialog.setContentView(vw);
|
||||||
dialog.show();
|
dialog.show();
|
||||||
|
|
||||||
commentMenuEdit.setOnClickListener(ediComment -> {
|
commentMenuEdit.setOnClickListener(v1 -> {
|
||||||
|
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putString("commentId", commendId.getText().toString());
|
bundle.putInt("commentId", issueComment.getId());
|
||||||
bundle.putString("commentAction", "edit");
|
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();
|
dialog.dismiss();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
commentShare.setOnClickListener(ediComment -> {
|
commentShare.setOnClickListener(v1 -> {
|
||||||
|
|
||||||
// get comment Url
|
// get comment Url
|
||||||
CharSequence commentUrl = htmlUrl.getText();
|
CharSequence commentUrl = issueComment.getHtml_url();
|
||||||
|
|
||||||
// share issue comment
|
// share issue comment
|
||||||
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
|
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
|
||||||
sharingIntent.setType("text/plain");
|
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_SUBJECT, intentHeader);
|
||||||
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, commentUrl);
|
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, commentUrl);
|
||||||
ctx.startActivity(Intent.createChooser(sharingIntent, intentHeader));
|
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
|
// comment Url
|
||||||
CharSequence commentUrl = htmlUrl.getText();
|
CharSequence commentUrl = issueComment.getHtml_url();
|
||||||
|
|
||||||
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(ctx).getSystemService(Context.CLIPBOARD_SERVICE);
|
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(ctx).getSystemService(Context.CLIPBOARD_SERVICE);
|
||||||
assert clipboard != null;
|
assert clipboard != null;
|
||||||
@ -177,14 +153,14 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
|||||||
commentMenuQuote.setOnClickListener(v1 -> {
|
commentMenuQuote.setOnClickListener(v1 -> {
|
||||||
|
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
String commenterName = commenterUsername.getText().toString();
|
String commenterName = issueComment.getUser().getUsername();
|
||||||
|
|
||||||
if(!commenterName.equals(tinyDb.getString("userLogin"))) {
|
if(!commenterName.equals(tinyDb.getString("userLogin"))) {
|
||||||
|
|
||||||
stringBuilder.append("@").append(commenterName).append("\n\n");
|
stringBuilder.append("@").append(commenterName).append("\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] lines = commendBodyRaw.getText().toString().split("\\R");
|
String[] lines = issueComment.getBody().split("\\R");
|
||||||
|
|
||||||
for(String line : lines) {
|
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);
|
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(ctx).getSystemService(Context.CLIPBOARD_SERVICE);
|
||||||
assert clipboard != null;
|
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);
|
clipboard.setPrimaryClip(clip);
|
||||||
|
|
||||||
dialog.dismiss();
|
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();
|
dialog.dismiss();
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -238,22 +214,20 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
|||||||
|
|
||||||
private void deleteIssueComment(final Context ctx, final int commentId, int position) {
|
private void deleteIssueComment(final Context ctx, final int commentId, int position) {
|
||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(ctx);
|
final TinyDB tinyDb = TinyDB.getInstance(ctx);
|
||||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
|
||||||
final String loginUid = tinyDb.getString("loginUid");
|
final String loginUid = tinyDb.getString("loginUid");
|
||||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||||
String[] repoFullName = tinyDb.getString("repoFullName").split("/");
|
String[] repoFullName = tinyDb.getString("repoFullName").split("/");
|
||||||
|
|
||||||
if (repoFullName.length != 2) {
|
if (repoFullName.length != 2) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final String repoOwner = repoFullName[0];
|
final String repoOwner = repoFullName[0];
|
||||||
final String repoName = repoFullName[1];
|
final String repoName = repoFullName[1];
|
||||||
|
|
||||||
Call<JsonElement> call;
|
Call<JsonElement> call = RetrofitClient
|
||||||
|
.getApiInterface(ctx)
|
||||||
call = RetrofitClient
|
|
||||||
.getInstance(instanceUrl, ctx)
|
|
||||||
.getApiInterface()
|
|
||||||
.deleteComment(instanceToken, repoOwner, repoName, commentId);
|
.deleteComment(instanceToken, repoOwner, repoName, commentId);
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonElement>() {
|
call.enqueue(new Callback<JsonElement>() {
|
||||||
@ -261,47 +235,40 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
|||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
|
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
|
||||||
|
|
||||||
if(response.code() == 204) {
|
switch(response.code()) {
|
||||||
|
|
||||||
updateAdapter(position);
|
case 204:
|
||||||
Toasty.success(ctx, ctx.getResources().getString(R.string.deleteCommentSuccess));
|
updateAdapter(position);
|
||||||
|
Toasty.success(ctx, ctx.getResources().getString(R.string.deleteCommentSuccess));
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
case 401:
|
||||||
else if(response.code() == 401) {
|
AlertDialogs.authorizationTokenRevokedDialog(ctx, ctx.getResources().getString(R.string.alertDialogTokenRevokedTitle),
|
||||||
|
|
||||||
AlertDialogs.authorizationTokenRevokedDialog(ctx, ctx.getResources().getString(R.string.alertDialogTokenRevokedTitle),
|
|
||||||
ctx.getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
ctx.getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||||
ctx.getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
ctx.getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
||||||
ctx.getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
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
|
@Override
|
||||||
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
||||||
|
|
||||||
Toasty.error(ctx, ctx.getResources().getString(R.string.genericServerResponseError));
|
Toasty.error(ctx, ctx.getResources().getString(R.string.genericServerResponseError));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@ -312,109 +279,40 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
|||||||
return new IssueCommentsAdapter.IssueCommentViewHolder(v);
|
return new IssueCommentsAdapter.IssueCommentViewHolder(v);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull IssueCommentsAdapter.IssueCommentViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull IssueCommentsAdapter.IssueCommentViewHolder holder, int position) {
|
||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(mCtx);
|
IssueComments issueComment = issuesComments.get(position);
|
||||||
final String locale = tinyDb.getString("locale");
|
|
||||||
final String timeFormat = tinyDb.getString("dateFormat");
|
|
||||||
|
|
||||||
IssueComments currentItem = issuesComments.get(position);
|
holder.issueComment = issueComment;
|
||||||
|
holder.author.setText(issueComment.getUser().getUsername());
|
||||||
|
|
||||||
holder.htmlUrl.setText(currentItem.getHtml_url());
|
PicassoService.getInstance(ctx).get()
|
||||||
holder.commenterUsername.setText(currentItem.getUser().getUsername());
|
.load(issueComment.getUser().getAvatar_url())
|
||||||
holder.commendId.setText(String.valueOf(currentItem.getId()));
|
.placeholder(R.drawable.loader_animated)
|
||||||
holder.commendBodyRaw.setText(currentItem.getBody());
|
.transform(new RoundedTransformation(4, 0))
|
||||||
|
.resize(AppUtil.getPixelsFromDensity(ctx, 35), AppUtil.getPixelsFromDensity(ctx, 35))
|
||||||
|
.centerCrop()
|
||||||
|
.into(holder.avatar);
|
||||||
|
|
||||||
if(!currentItem.getUser().getFull_name().equals("")) {
|
new Markdown(ctx, EmojiParser.parseToUnicode(issueComment.getBody()), holder.comment);
|
||||||
holder.issueCommenterAvatar.setOnClickListener(new ClickListener(mCtx.getResources().getString(R.string.issueCommenter) + currentItem.getUser().getFull_name(), mCtx));
|
|
||||||
}
|
StringBuilder informationBuilder = new StringBuilder(TimeHelper.formatTime(issueComment.getCreated_at(), Locale.getDefault(), "pretty", ctx));
|
||||||
else {
|
|
||||||
holder.issueCommenterAvatar.setOnClickListener(new ClickListener(mCtx.getResources().getString(R.string.issueCommenter) + currentItem.getUser().getLogin(), mCtx));
|
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
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
|
|
||||||
return issuesComments.size();
|
return issuesComments.size();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -123,7 +123,7 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||||||
Intent intent = new Intent(context, IssueDetailActivity.class);
|
Intent intent = new Intent(context, IssueDetailActivity.class);
|
||||||
intent.putExtra("issueNumber", issueNumber.getText());
|
intent.putExtra("issueNumber", issueNumber.getText());
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(context);
|
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
tinyDb.putString("issueNumber", issueNumber.getText().toString());
|
tinyDb.putString("issueNumber", issueNumber.getText().toString());
|
||||||
tinyDb.putString("issueType", "Issue");
|
tinyDb.putString("issueType", "Issue");
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
@ -136,7 +136,7 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||||||
Intent intent = new Intent(context, IssueDetailActivity.class);
|
Intent intent = new Intent(context, IssueDetailActivity.class);
|
||||||
intent.putExtra("issueNumber", issueNumber.getText());
|
intent.putExtra("issueNumber", issueNumber.getText());
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(context);
|
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
tinyDb.putString("issueNumber", issueNumber.getText().toString());
|
tinyDb.putString("issueNumber", issueNumber.getText().toString());
|
||||||
tinyDb.putString("issueType", "Issue");
|
tinyDb.putString("issueType", "Issue");
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
@ -148,7 +148,7 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
void bindData(Issues issuesModel) {
|
void bindData(Issues issuesModel) {
|
||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(context);
|
final TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
final String locale = tinyDb.getString("locale");
|
final String locale = tinyDb.getString("locale");
|
||||||
final String timeFormat = tinyDb.getString("dateFormat");
|
final String timeFormat = tinyDb.getString("dateFormat");
|
||||||
|
|
||||||
|
@ -2,9 +2,6 @@ package org.mian.gitnex.adapters;
|
|||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.text.Spanned;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -19,6 +16,7 @@ import com.vdurmont.emoji.EmojiParser;
|
|||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.actions.MilestoneActions;
|
import org.mian.gitnex.actions.MilestoneActions;
|
||||||
import org.mian.gitnex.helpers.ClickListener;
|
import org.mian.gitnex.helpers.ClickListener;
|
||||||
|
import org.mian.gitnex.helpers.Markdown;
|
||||||
import org.mian.gitnex.helpers.StaticGlobalVariables;
|
import org.mian.gitnex.helpers.StaticGlobalVariables;
|
||||||
import org.mian.gitnex.helpers.TimeHelper;
|
import org.mian.gitnex.helpers.TimeHelper;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
import org.mian.gitnex.helpers.TinyDB;
|
||||||
@ -26,27 +24,9 @@ import org.mian.gitnex.models.Milestones;
|
|||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
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
|
* Author M M Arif
|
||||||
@ -177,71 +157,18 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
void bindData(Milestones dataModel) {
|
void bindData(Milestones dataModel) {
|
||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(context);
|
final TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
final String locale = tinyDb.getString("locale");
|
final String locale = tinyDb.getString("locale");
|
||||||
final String timeFormat = tinyDb.getString("dateFormat");
|
final String timeFormat = tinyDb.getString("dateFormat");
|
||||||
|
|
||||||
milestoneId.setText(String.valueOf(dataModel.getId()));
|
milestoneId.setText(String.valueOf(dataModel.getId()));
|
||||||
milestoneStatus.setText(dataModel.getState());
|
milestoneStatus.setText(dataModel.getState());
|
||||||
|
|
||||||
Markwon markwon = Markwon.builder(Objects.requireNonNull(context)).usePlugin(CorePlugin.create()).usePlugin(ImagesPlugin.create(plugin -> {
|
new Markdown(context, dataModel.getTitle(), msTitle);
|
||||||
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_);
|
|
||||||
|
|
||||||
if(!dataModel.getDescription().equals("")) {
|
if(!dataModel.getDescription().equals("")) {
|
||||||
|
|
||||||
CharSequence bodyWithMD = markwon.toMarkdown(EmojiParser.parseToUnicode(dataModel.getDescription()));
|
new Markdown(context, EmojiParser.parseToUnicode(dataModel.getDescription()), msDescription);
|
||||||
msDescription.setText(bodyWithMD);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
|
|||||||
Intent intent = new Intent(context, RepoDetailActivity.class);
|
Intent intent = new Intent(context, RepoDetailActivity.class);
|
||||||
intent.putExtra("repoFullName", repoFullName.getText().toString());
|
intent.putExtra("repoFullName", repoFullName.getText().toString());
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(context);
|
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
tinyDb.putString("repoFullName", repoFullName.getText().toString());
|
tinyDb.putString("repoFullName", repoFullName.getText().toString());
|
||||||
tinyDb.putString("repoType", repoType.getText().toString());
|
tinyDb.putString("repoType", repoType.getText().toString());
|
||||||
//tinyDb.putBoolean("resumeIssues", true);
|
//tinyDb.putBoolean("resumeIssues", true);
|
||||||
@ -125,14 +125,13 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
|
|||||||
//store if user is watching this repo
|
//store if user is watching this repo
|
||||||
{
|
{
|
||||||
|
|
||||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
|
||||||
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
||||||
|
|
||||||
WatchInfo watch = new WatchInfo();
|
WatchInfo watch = new WatchInfo();
|
||||||
|
|
||||||
Call<WatchInfo> call;
|
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>() {
|
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) {
|
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.context = context;
|
||||||
this.notificationThreads = notificationThreads;
|
this.notificationThreads = notificationThreads;
|
||||||
this.onMoreClickedListener = onMoreClickedListener;
|
this.onMoreClickedListener = onMoreClickedListener;
|
||||||
|
@ -53,7 +53,7 @@ public class OrganizationsListAdapter extends RecyclerView.Adapter<Organizations
|
|||||||
Intent intent = new Intent(context, OrganizationDetailActivity.class);
|
Intent intent = new Intent(context, OrganizationDetailActivity.class);
|
||||||
intent.putExtra("orgName", mTextView1.getText().toString());
|
intent.putExtra("orgName", mTextView1.getText().toString());
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(context);
|
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
tinyDb.putString("orgName", mTextView1.getText().toString());
|
tinyDb.putString("orgName", mTextView1.getText().toString());
|
||||||
tinyDb.putString("organizationId", organizationId.getText().toString());
|
tinyDb.putString("organizationId", organizationId.getText().toString());
|
||||||
tinyDb.putBoolean("organizationAction", true);
|
tinyDb.putBoolean("organizationAction", true);
|
||||||
|
@ -130,7 +130,7 @@ public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||||||
intent.putExtra("prMergeable", prMergeable.getText());
|
intent.putExtra("prMergeable", prMergeable.getText());
|
||||||
intent.putExtra("prHeadBranch", prHeadBranch.getText());
|
intent.putExtra("prHeadBranch", prHeadBranch.getText());
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(context);
|
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
tinyDb.putString("issueNumber", prNumber.getText().toString());
|
tinyDb.putString("issueNumber", prNumber.getText().toString());
|
||||||
tinyDb.putString("prMergeable", prMergeable.getText().toString());
|
tinyDb.putString("prMergeable", prMergeable.getText().toString());
|
||||||
tinyDb.putString("prHeadBranch", prHeadBranch.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("prMergeable", prMergeable.getText());
|
||||||
intent.putExtra("prHeadBranch", prHeadBranch.getText());
|
intent.putExtra("prHeadBranch", prHeadBranch.getText());
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(context);
|
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
tinyDb.putString("issueNumber", prNumber.getText().toString());
|
tinyDb.putString("issueNumber", prNumber.getText().toString());
|
||||||
tinyDb.putString("prMergeable", prMergeable.getText().toString());
|
tinyDb.putString("prMergeable", prMergeable.getText().toString());
|
||||||
tinyDb.putString("prHeadBranch", prHeadBranch.getText().toString());
|
tinyDb.putString("prHeadBranch", prHeadBranch.getText().toString());
|
||||||
@ -165,7 +165,7 @@ public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
void bindData(PullRequests prModel) {
|
void bindData(PullRequests prModel) {
|
||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(context);
|
final TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
final String locale = tinyDb.getString("locale");
|
final String locale = tinyDb.getString("locale");
|
||||||
final String timeFormat = tinyDb.getString("dateFormat");
|
final String timeFormat = tinyDb.getString("dateFormat");
|
||||||
|
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
package org.mian.gitnex.adapters;
|
package org.mian.gitnex.adapters;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.text.Spanned;
|
|
||||||
import android.text.method.LinkMovementMethod;
|
import android.text.method.LinkMovementMethod;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -16,34 +13,16 @@ import android.widget.TextView;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import com.vdurmont.emoji.EmojiParser;
|
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.clients.PicassoService;
|
import org.mian.gitnex.clients.PicassoService;
|
||||||
import org.mian.gitnex.helpers.ClickListener;
|
import org.mian.gitnex.helpers.ClickListener;
|
||||||
|
import org.mian.gitnex.helpers.Markdown;
|
||||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||||
import org.mian.gitnex.helpers.TimeHelper;
|
import org.mian.gitnex.helpers.TimeHelper;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
import org.mian.gitnex.helpers.TinyDB;
|
||||||
import org.mian.gitnex.models.Releases;
|
import org.mian.gitnex.models.Releases;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
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
|
* Author M M Arif
|
||||||
@ -111,7 +90,7 @@ public class ReleasesAdapter extends RecyclerView.Adapter<ReleasesAdapter.Releas
|
|||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull ReleasesAdapter.ReleasesViewHolder holder, int position) {
|
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 locale = tinyDb.getString("locale");
|
||||||
final String timeFormat = tinyDb.getString("dateFormat");
|
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));
|
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("")) {
|
if(!currentItem.getBody().equals("")) {
|
||||||
markwon.setParsedMarkdown(holder.releaseBodyContent, bodyWithMD);
|
new Markdown(mCtx, currentItem.getBody(), holder.releaseBodyContent);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
holder.releaseBodyContent.setText(R.string.noReleaseBodyContent);
|
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 intent = new Intent(context, RepoDetailActivity.class);
|
||||||
intent.putExtra("repoFullName", repoFullName.getText().toString());
|
intent.putExtra("repoFullName", repoFullName.getText().toString());
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(context);
|
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
tinyDb.putString("repoFullName", repoFullName.getText().toString());
|
tinyDb.putString("repoFullName", repoFullName.getText().toString());
|
||||||
tinyDb.putString("repoType", repoType_.getText().toString());
|
tinyDb.putString("repoType", repoType_.getText().toString());
|
||||||
//tinyDb.putBoolean("resumeIssues", true);
|
//tinyDb.putBoolean("resumeIssues", true);
|
||||||
@ -244,14 +244,13 @@ public class RepoForksAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||||||
//store if user is watching this repo
|
//store if user is watching this repo
|
||||||
{
|
{
|
||||||
|
|
||||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
|
||||||
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
||||||
|
|
||||||
WatchInfo watch = new WatchInfo();
|
WatchInfo watch = new WatchInfo();
|
||||||
|
|
||||||
Call<WatchInfo> call;
|
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>() {
|
call.enqueue(new Callback<WatchInfo>() {
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ public class RepoStargazersAdapter extends BaseAdapter {
|
|||||||
UserInfo currentItem = stargazersList.get(position);
|
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);
|
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;
|
Typeface myTypeface;
|
||||||
|
|
||||||
switch(tinyDb.getInt("customFontId", -1)) {
|
switch(tinyDb.getInt("customFontId", -1)) {
|
||||||
|
@ -81,7 +81,7 @@ public class RepoWatchersAdapter extends BaseAdapter {
|
|||||||
UserInfo currentItem = watchersList.get(position);
|
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);
|
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;
|
Typeface myTypeface;
|
||||||
|
|
||||||
switch(tinyDb.getInt("customFontId", -1)) {
|
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.R;
|
||||||
import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
|
import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
|
||||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||||
|
import org.mian.gitnex.activities.RepoForksActivity;
|
||||||
import org.mian.gitnex.activities.RepoStargazersActivity;
|
import org.mian.gitnex.activities.RepoStargazersActivity;
|
||||||
import org.mian.gitnex.activities.RepoWatchersActivity;
|
import org.mian.gitnex.activities.RepoWatchersActivity;
|
||||||
import org.mian.gitnex.activities.RepoForksActivity;
|
|
||||||
import org.mian.gitnex.clients.PicassoService;
|
import org.mian.gitnex.clients.PicassoService;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.database.api.RepositoriesApi;
|
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 intent = new Intent(context, RepoDetailActivity.class);
|
||||||
intent.putExtra("repoFullName", repoFullName.getText().toString());
|
intent.putExtra("repoFullName", repoFullName.getText().toString());
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(context);
|
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
tinyDb.putString("repoFullName", repoFullName.getText().toString());
|
tinyDb.putString("repoFullName", repoFullName.getText().toString());
|
||||||
tinyDb.putString("repoType", repoType_.getText().toString());
|
tinyDb.putString("repoType", repoType_.getText().toString());
|
||||||
//tinyDb.putBoolean("resumeIssues", true);
|
//tinyDb.putBoolean("resumeIssues", true);
|
||||||
@ -127,14 +127,13 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
|||||||
//store if user is watching this repo
|
//store if user is watching this repo
|
||||||
{
|
{
|
||||||
|
|
||||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
|
||||||
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
||||||
|
|
||||||
WatchInfo watch = new WatchInfo();
|
WatchInfo watch = new WatchInfo();
|
||||||
|
|
||||||
Call<WatchInfo> call;
|
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>() {
|
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.R;
|
||||||
import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
|
import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
|
||||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||||
|
import org.mian.gitnex.activities.RepoForksActivity;
|
||||||
import org.mian.gitnex.activities.RepoStargazersActivity;
|
import org.mian.gitnex.activities.RepoStargazersActivity;
|
||||||
import org.mian.gitnex.activities.RepoWatchersActivity;
|
import org.mian.gitnex.activities.RepoWatchersActivity;
|
||||||
import org.mian.gitnex.activities.RepoForksActivity;
|
|
||||||
import org.mian.gitnex.clients.PicassoService;
|
import org.mian.gitnex.clients.PicassoService;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.database.api.RepositoriesApi;
|
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 intent = new Intent(context, RepoDetailActivity.class);
|
||||||
intent.putExtra("repoFullName", fullName.getText().toString());
|
intent.putExtra("repoFullName", fullName.getText().toString());
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(context);
|
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
tinyDb.putString("repoFullName", fullName.getText().toString());
|
tinyDb.putString("repoFullName", fullName.getText().toString());
|
||||||
tinyDb.putString("repoType", repoType.getText().toString());
|
tinyDb.putString("repoType", repoType.getText().toString());
|
||||||
//tinyDb.putBoolean("resumeIssues", true);
|
//tinyDb.putBoolean("resumeIssues", true);
|
||||||
@ -124,12 +124,11 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
|||||||
//store if user is watching this repo
|
//store if user is watching this repo
|
||||||
{
|
{
|
||||||
|
|
||||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
|
||||||
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
||||||
|
|
||||||
Call<WatchInfo> call;
|
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>() {
|
call.enqueue(new Callback<WatchInfo>() {
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ public class SearchIssuesAdapter extends RecyclerView.Adapter<SearchIssuesAdapte
|
|||||||
|
|
||||||
this.mCtx = mCtx;
|
this.mCtx = mCtx;
|
||||||
this.searchedList = dataList;
|
this.searchedList = dataList;
|
||||||
this.tinyDb = new TinyDB(mCtx);
|
this.tinyDb = TinyDB.getInstance(mCtx);
|
||||||
}
|
}
|
||||||
|
|
||||||
class SearchViewHolder extends RecyclerView.ViewHolder {
|
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.R;
|
||||||
import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
|
import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
|
||||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||||
|
import org.mian.gitnex.activities.RepoForksActivity;
|
||||||
import org.mian.gitnex.activities.RepoStargazersActivity;
|
import org.mian.gitnex.activities.RepoStargazersActivity;
|
||||||
import org.mian.gitnex.activities.RepoWatchersActivity;
|
import org.mian.gitnex.activities.RepoWatchersActivity;
|
||||||
import org.mian.gitnex.activities.RepoForksActivity;
|
|
||||||
import org.mian.gitnex.clients.PicassoService;
|
import org.mian.gitnex.clients.PicassoService;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.database.api.RepositoriesApi;
|
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 intent = new Intent(context, RepoDetailActivity.class);
|
||||||
intent.putExtra("repoFullName", fullName.getText().toString());
|
intent.putExtra("repoFullName", fullName.getText().toString());
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(context);
|
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
tinyDb.putString("repoFullName", fullName.getText().toString());
|
tinyDb.putString("repoFullName", fullName.getText().toString());
|
||||||
tinyDb.putString("repoType", repoType.getText().toString());
|
tinyDb.putString("repoType", repoType.getText().toString());
|
||||||
//tinyDb.putBoolean("resumeIssues", true);
|
//tinyDb.putBoolean("resumeIssues", true);
|
||||||
@ -124,14 +124,13 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
|||||||
//store if user is watching this repo
|
//store if user is watching this repo
|
||||||
{
|
{
|
||||||
|
|
||||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
|
||||||
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
||||||
|
|
||||||
WatchInfo watch = new WatchInfo();
|
WatchInfo watch = new WatchInfo();
|
||||||
|
|
||||||
Call<WatchInfo> call;
|
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>() {
|
call.enqueue(new Callback<WatchInfo>() {
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ public class TeamMembersByOrgAdapter extends BaseAdapter {
|
|||||||
UserInfo currentItem = teamMembersList.get(position);
|
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);
|
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;
|
Typeface myTypeface;
|
||||||
|
|
||||||
switch(tinyDb.getInt("customFontId", -1)) {
|
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) {
|
public void onBindViewHolder(@NonNull UserAccountsAdapter.UserAccountsViewHolder holder, int position) {
|
||||||
|
|
||||||
UserAccount currentItem = userAccountsList.get(position);
|
UserAccount currentItem = userAccountsList.get(position);
|
||||||
tinyDB = new TinyDB(mCtx);
|
tinyDB = TinyDB.getInstance(mCtx);
|
||||||
|
|
||||||
String url = UrlBuilder.fromString(currentItem.getInstanceUrl())
|
String url = UrlBuilder.fromString(currentItem.getInstanceUrl())
|
||||||
.withPath("/")
|
.withPath("/")
|
||||||
|
@ -31,7 +31,7 @@ public class UserAccountsListDialogAdapter extends ArrayAdapter<UserAccount> {
|
|||||||
|
|
||||||
super(mCtx, resource, userAccounts);
|
super(mCtx, resource, userAccounts);
|
||||||
|
|
||||||
tinyDB = new TinyDB(mCtx);
|
tinyDB = TinyDB.getInstance(mCtx);
|
||||||
this.userAccounts = userAccounts;
|
this.userAccounts = userAccounts;
|
||||||
this.mCtx = mCtx;
|
this.mCtx = mCtx;
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ public class UserAccountsNavAdapter extends RecyclerView.Adapter<UserAccountsNav
|
|||||||
|
|
||||||
private void customDialogUserAccountsList(List<UserAccount> allAccountsList) {
|
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 dialog = new Dialog(mCtx, R.style.ThemeOverlay_MaterialComponents_Dialog_Alert);
|
||||||
dialog.setContentView(R.layout.custom_user_accounts_dialog);
|
dialog.setContentView(R.layout.custom_user_accounts_dialog);
|
||||||
|
|
||||||
|
@ -146,19 +146,16 @@ public class UserSearchAdapter extends RecyclerView.Adapter<UserSearchAdapter.Us
|
|||||||
|
|
||||||
if(getItemCount() > 0) {
|
if(getItemCount() > 0) {
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(mCtx);
|
TinyDB tinyDb = TinyDB.getInstance(mCtx);
|
||||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
|
||||||
final String loginUid = tinyDb.getString("loginUid");
|
final String loginUid = tinyDb.getString("loginUid");
|
||||||
String repoFullName = tinyDb.getString("repoFullName");
|
String repoFullName = tinyDb.getString("repoFullName");
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
final String repoOwner = parts[0];
|
final String repoOwner = parts[0];
|
||||||
final String repoName = parts[1];
|
final String repoName = parts[1];
|
||||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
|
||||||
|
|
||||||
Call<Collaborators> call = RetrofitClient
|
Call<Collaborators> call = RetrofitClient
|
||||||
.getInstance(instanceUrl, mCtx)
|
.getApiInterface(mCtx)
|
||||||
.getApiInterface()
|
.checkRepoCollaborator(Authorization.get(mCtx), repoOwner, repoName, currentItem.getUsername());
|
||||||
.checkRepoCollaborator(Authorization.returnAuthentication(mCtx, loginUid, instanceToken), repoOwner, repoName, currentItem.getUsername());
|
|
||||||
|
|
||||||
call.enqueue(new Callback<Collaborators>() {
|
call.enqueue(new Callback<Collaborators>() {
|
||||||
|
|
||||||
|
@ -116,8 +116,7 @@ public class UserSearchForTeamMemberAdapter extends RecyclerView.Adapter<UserSea
|
|||||||
|
|
||||||
if(getItemCount() > 0) {
|
if(getItemCount() > 0) {
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(mCtx);
|
TinyDB tinyDb = TinyDB.getInstance(mCtx);
|
||||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
|
||||||
final String loginUid = tinyDb.getString("loginUid");
|
final String loginUid = tinyDb.getString("loginUid");
|
||||||
String repoFullName = tinyDb.getString("repoFullName");
|
String repoFullName = tinyDb.getString("repoFullName");
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
@ -125,9 +124,8 @@ public class UserSearchForTeamMemberAdapter extends RecyclerView.Adapter<UserSea
|
|||||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||||
|
|
||||||
Call<UserInfo> call = RetrofitClient
|
Call<UserInfo> call = RetrofitClient
|
||||||
.getInstance(instanceUrl, mCtx)
|
.getApiInterface(mCtx)
|
||||||
.getApiInterface()
|
.checkTeamMember(Authorization.get(mCtx), teamId, currentItem.getLogin());
|
||||||
.checkTeamMember(Authorization.returnAuthentication(mCtx, loginUid, instanceToken), teamId, currentItem.getLogin());
|
|
||||||
|
|
||||||
call.enqueue(new Callback<UserInfo>() {
|
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.content.Context;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import org.mian.gitnex.helpers.AppUtil;
|
|
||||||
import org.mian.gitnex.helpers.FilesData;
|
import org.mian.gitnex.helpers.FilesData;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
import org.mian.gitnex.helpers.TinyDB;
|
||||||
import org.mian.gitnex.helpers.ssl.MemorizingTrustManager;
|
import org.mian.gitnex.helpers.ssl.MemorizingTrustManager;
|
||||||
@ -10,13 +9,14 @@ import org.mian.gitnex.interfaces.ApiInterface;
|
|||||||
import org.mian.gitnex.interfaces.WebInterface;
|
import org.mian.gitnex.interfaces.WebInterface;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import javax.net.ssl.HttpsURLConnection;
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
import javax.net.ssl.SSLContext;
|
import javax.net.ssl.SSLContext;
|
||||||
import javax.net.ssl.X509TrustManager;
|
import javax.net.ssl.X509TrustManager;
|
||||||
import okhttp3.Cache;
|
import okhttp3.Cache;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.logging.HttpLoggingInterceptor;
|
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
import retrofit2.converter.gson.GsonConverterFactory;
|
import retrofit2.converter.gson.GsonConverterFactory;
|
||||||
import retrofit2.converter.scalars.ScalarsConverterFactory;
|
import retrofit2.converter.scalars.ScalarsConverterFactory;
|
||||||
@ -27,64 +27,91 @@ import retrofit2.converter.scalars.ScalarsConverterFactory;
|
|||||||
|
|
||||||
public class RetrofitClient {
|
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);
|
TinyDB tinyDB = TinyDB.getInstance(context);
|
||||||
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);
|
|
||||||
|
|
||||||
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
|
int cacheSize = FilesData.returnOnlyNumber(tinyDB.getString("cacheSizeStr")) * 1024 * 1024;
|
||||||
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
|
Cache cache = new Cache(new File(context.getCacheDir(), "responses"), cacheSize);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||||
|
|
||||||
MemorizingTrustManager memorizingTrustManager = new MemorizingTrustManager(ctx);
|
MemorizingTrustManager memorizingTrustManager = new MemorizingTrustManager(context);
|
||||||
sslContext.init(null, new X509TrustManager[]{memorizingTrustManager}, new SecureRandom());
|
sslContext.init(null, new X509TrustManager[]{ memorizingTrustManager }, new SecureRandom());
|
||||||
|
|
||||||
OkHttpClient.Builder okHttpClient = new OkHttpClient.Builder().cache(cache)
|
OkHttpClient.Builder okHttpClient = new OkHttpClient.Builder().cache(cache)
|
||||||
//.addInterceptor(logging)
|
.sslSocketFactory(sslContext.getSocketFactory(), memorizingTrustManager)
|
||||||
.sslSocketFactory(sslContext.getSocketFactory(), memorizingTrustManager).hostnameVerifier(memorizingTrustManager.wrapHostnameVerifier(HttpsURLConnection.getDefaultHostnameVerifier())).addInterceptor(chain -> {
|
.hostnameVerifier(memorizingTrustManager.wrapHostnameVerifier(HttpsURLConnection.getDefaultHostnameVerifier()))
|
||||||
|
.addInterceptor(chain -> {
|
||||||
|
|
||||||
Request request = chain.request();
|
Request request = chain.request()
|
||||||
if(connToInternet) {
|
.newBuilder()
|
||||||
request = request.newBuilder().header("Cache-Control", "public, max-age=" + 60).build();
|
.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);
|
|
||||||
});
|
|
||||||
|
|
||||||
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());
|
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();
|
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 draft = new Draft();
|
||||||
draft.setDraftRepositoryId(repositoryId);
|
draft.setDraftRepositoryId(repositoryId);
|
||||||
@ -35,7 +35,8 @@ public class DraftsApi {
|
|||||||
draft.setIssueId(issueId);
|
draft.setIssueId(issueId);
|
||||||
draft.setDraftText(draftText);
|
draft.setDraftText(draftText);
|
||||||
draft.setDraftType(draftType);
|
draft.setDraftType(draftType);
|
||||||
draft.setCommentId(draftType);
|
draft.setCommentId(commentId);
|
||||||
|
draft.setIssueType(issueType);
|
||||||
|
|
||||||
return insertDraftAsyncTask(draft);
|
return insertDraftAsyncTask(draft);
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ import org.mian.gitnex.database.models.UserAccount;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
@Database(entities = {Draft.class, Repository.class, UserAccount.class},
|
@Database(entities = {Draft.class, Repository.class, UserAccount.class},
|
||||||
version = 2, exportSchema = false)
|
version = 3, exportSchema = false)
|
||||||
public abstract class GitnexDatabase extends RoomDatabase {
|
public abstract class GitnexDatabase extends RoomDatabase {
|
||||||
|
|
||||||
private static GitnexDatabase gitnexDatabase;
|
private static GitnexDatabase gitnexDatabase;
|
||||||
@ -27,10 +27,11 @@ public abstract class GitnexDatabase extends RoomDatabase {
|
|||||||
public static GitnexDatabase getDatabaseInstance(Context context) {
|
public static GitnexDatabase getDatabaseInstance(Context context) {
|
||||||
|
|
||||||
if (gitnexDatabase == null) {
|
if (gitnexDatabase == null) {
|
||||||
|
|
||||||
String DB_NAME = "gitnex";
|
String DB_NAME = "gitnex";
|
||||||
gitnexDatabase = Room.databaseBuilder(context, GitnexDatabase.class, DB_NAME)
|
gitnexDatabase = Room.databaseBuilder(context, GitnexDatabase.class, DB_NAME)
|
||||||
//.fallbackToDestructiveMigration()
|
//.fallbackToDestructiveMigration()
|
||||||
.addMigrations(MIGRATION_1_2)
|
.addMigrations(MIGRATION_1_2, MIGRATION_2_3)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,7 +50,14 @@ public abstract class GitnexDatabase extends RoomDatabase {
|
|||||||
|
|
||||||
//database.execSQL("DROP TABLE Drafts");
|
//database.execSQL("DROP TABLE Drafts");
|
||||||
database.execSQL("ALTER TABLE 'Drafts' ADD COLUMN 'commentId' TEXT");
|
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;
|
private String draftType;
|
||||||
@Nullable
|
@Nullable
|
||||||
private String commentId;
|
private String commentId;
|
||||||
|
@Nullable
|
||||||
|
private String issueType;
|
||||||
|
|
||||||
public int getDraftId() {
|
public int getDraftId() {
|
||||||
|
|
||||||
@ -99,4 +101,15 @@ public class Draft implements Serializable {
|
|||||||
this.commentId = commentId;
|
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 draftText;
|
||||||
private String draftType;
|
private String draftType;
|
||||||
private String commentId;
|
private String commentId;
|
||||||
|
private String issueType;
|
||||||
|
|
||||||
public int getRepositoryId() {
|
public int getRepositoryId() {
|
||||||
|
|
||||||
@ -130,4 +131,14 @@ public class DraftWithRepository {
|
|||||||
this.commentId = commentId;
|
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) {
|
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
|
||||||
FragmentAboutBinding viewBinding = FragmentAboutBinding.inflate(inflater, container, false);
|
FragmentAboutBinding viewBinding = FragmentAboutBinding.inflate(inflater, container, false);
|
||||||
TinyDB tinyDb = new TinyDB(getContext());
|
TinyDB tinyDb = TinyDB.getInstance(getContext());
|
||||||
|
|
||||||
viewBinding.appVersion.setText(AppUtil.getAppVersion(requireContext()));
|
viewBinding.appVersion.setText(AppUtil.getAppVersion(requireContext()));
|
||||||
viewBinding.userServerVersion.setText(tinyDb.getString("giteaVersion"));
|
viewBinding.userServerVersion.setText(tinyDb.getString("giteaVersion"));
|
||||||
|
@ -11,7 +11,6 @@ import androidx.annotation.Nullable;
|
|||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.activities.AdminGetUsersActivity;
|
import org.mian.gitnex.activities.AdminGetUsersActivity;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Author M M Arif
|
* Author M M Arif
|
||||||
@ -23,8 +22,6 @@ public class AdministrationFragment extends Fragment {
|
|||||||
|
|
||||||
View v = inflater.inflate(R.layout.fragment_administration, container, false);
|
View v = inflater.inflate(R.layout.fragment_administration, container, false);
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(getContext());
|
|
||||||
|
|
||||||
TextView adminUsers = v.findViewById(R.id.adminUsers);
|
TextView adminUsers = v.findViewById(R.id.adminUsers);
|
||||||
|
|
||||||
adminUsers.setOnClickListener(v1 -> startActivity(new Intent(getContext(), AdminGetUsersActivity.class)));
|
adminUsers.setOnClickListener(v1 -> startActivity(new Intent(getContext(), AdminGetUsersActivity.class)));
|
||||||
|
@ -24,7 +24,7 @@ public class BottomSheetNotificationsFilterFragment extends BottomSheetDialogFra
|
|||||||
@Override
|
@Override
|
||||||
public void onAttach(@NonNull Context context) {
|
public void onAttach(@NonNull Context context) {
|
||||||
|
|
||||||
this.tinyDB = new TinyDB(context);
|
this.tinyDB = TinyDB.getInstance(context);
|
||||||
super.onAttach(context);
|
super.onAttach(context);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ import android.widget.ImageButton;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.core.content.ContextCompat;
|
||||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
@ -34,6 +35,9 @@ import java.util.Objects;
|
|||||||
|
|
||||||
public class BottomSheetReplyFragment extends BottomSheetDialogFragment {
|
public class BottomSheetReplyFragment extends BottomSheetDialogFragment {
|
||||||
|
|
||||||
|
private enum Mode { EDIT, SEND }
|
||||||
|
private Mode mode = Mode.SEND;
|
||||||
|
|
||||||
private TinyDB tinyDB;
|
private TinyDB tinyDB;
|
||||||
private DraftsApi draftsApi;
|
private DraftsApi draftsApi;
|
||||||
|
|
||||||
@ -42,12 +46,13 @@ public class BottomSheetReplyFragment extends BottomSheetDialogFragment {
|
|||||||
private int issueNumber;
|
private int issueNumber;
|
||||||
private long draftId;
|
private long draftId;
|
||||||
|
|
||||||
|
private OnInteractedListener onInteractedListener;
|
||||||
private TextView draftsHint;
|
private TextView draftsHint;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAttach(@NonNull Context context) {
|
public void onAttach(@NonNull Context context) {
|
||||||
|
|
||||||
tinyDB = new TinyDB(context);
|
tinyDB = TinyDB.getInstance(context);
|
||||||
draftsApi = new DraftsApi(context);
|
draftsApi = new DraftsApi(context);
|
||||||
|
|
||||||
repositoryId = (int) tinyDB.getLong("repositoryId", 0);
|
repositoryId = (int) tinyDB.getLong("repositoryId", 0);
|
||||||
@ -67,7 +72,7 @@ public class BottomSheetReplyFragment extends BottomSheetDialogFragment {
|
|||||||
|
|
||||||
draftsHint = view.findViewById(R.id.drafts_hint);
|
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);
|
TextView toolbarTitle = view.findViewById(R.id.toolbar_title);
|
||||||
ImageButton close = view.findViewById(R.id.close);
|
ImageButton close = view.findViewById(R.id.close);
|
||||||
ImageButton drafts = view.findViewById(R.id.drafts);
|
ImageButton drafts = view.findViewById(R.id.drafts);
|
||||||
@ -75,9 +80,12 @@ public class BottomSheetReplyFragment extends BottomSheetDialogFragment {
|
|||||||
|
|
||||||
send.setEnabled(false);
|
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) {
|
if(arguments.getString("draftId") != null) {
|
||||||
@ -99,16 +107,16 @@ public class BottomSheetReplyFragment extends BottomSheetDialogFragment {
|
|||||||
send.setEnabled(true);
|
send.setEnabled(true);
|
||||||
send.setAlpha(1f);
|
send.setAlpha(1f);
|
||||||
|
|
||||||
commentContent.setText(arguments.getString("commentBody"));
|
comment.setText(arguments.getString("commentBody"));
|
||||||
|
|
||||||
if(arguments.getBoolean("cursorToEnd", false)) {
|
if(arguments.getBoolean("cursorToEnd", false)) {
|
||||||
|
|
||||||
commentContent.setSelection(commentContent.length());
|
comment.setSelection(comment.length());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
commentContent.requestFocus();
|
comment.requestFocus();
|
||||||
commentContent.setOnTouchListener((v, event) -> {
|
comment.setOnTouchListener((v, event) -> {
|
||||||
|
|
||||||
BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.from((View) view.getParent());
|
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
|
@Override
|
||||||
public void afterTextChanged(Editable s) {
|
public void afterTextChanged(Editable s) {
|
||||||
|
|
||||||
String text = commentContent.getText().toString();
|
String text = comment.getText().toString();
|
||||||
|
|
||||||
if(text.isEmpty()) {
|
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 beforeTextChanged(CharSequence s, int start, int count, int after) {}
|
||||||
@Override public void onTextChanged(CharSequence s, int start, int before, int count) {}
|
@Override public void onTextChanged(CharSequence s, int start, int before, int count) {}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
close.setOnClickListener(v -> dismiss());
|
close.setOnClickListener(v -> dismiss());
|
||||||
@ -161,33 +170,69 @@ public class BottomSheetReplyFragment extends BottomSheetDialogFragment {
|
|||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
|
|
||||||
dismiss();
|
dismiss();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
send.setOnClickListener(v -> IssueActions
|
send.setOnClickListener(v -> {
|
||||||
.reply(getContext(), commentContent.getText().toString(), issueNumber)
|
|
||||||
.accept((status, result) -> {
|
|
||||||
|
|
||||||
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);
|
if(status == ActionResult.Status.SUCCESS) {
|
||||||
tinyDB.putBoolean("resumeIssues", true);
|
|
||||||
tinyDB.putBoolean("resumePullRequests", true);
|
|
||||||
|
|
||||||
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();
|
tinyDB.putBoolean("commentPosted", true);
|
||||||
}
|
tinyDB.putBoolean("resumeIssues", true);
|
||||||
else {
|
tinyDB.putBoolean("resumePullRequests", true);
|
||||||
|
|
||||||
Toasty.error(getContext(), getString(R.string.commentError));
|
if(onInteractedListener != null) {
|
||||||
dismiss();
|
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;
|
return view;
|
||||||
}
|
}
|
||||||
@ -216,9 +261,26 @@ public class BottomSheetReplyFragment extends BottomSheetDialogFragment {
|
|||||||
}
|
}
|
||||||
else {
|
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) {
|
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");
|
DraftsApi.updateDraft(text, (int) draftId, "TODO");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,4 +296,12 @@ public class BottomSheetReplyFragment extends BottomSheetDialogFragment {
|
|||||||
|
|
||||||
return fragment;
|
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) {
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||||
View v = inflater.inflate(R.layout.bottom_sheet_repo, container, false);
|
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 createLabel = v.findViewById(R.id.createLabel);
|
||||||
TextView createIssue = v.findViewById(R.id.createNewIssue);
|
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);
|
View v = inflater.inflate(R.layout.bottom_sheet_single_issue, container, false);
|
||||||
|
|
||||||
final Context ctx = getContext();
|
final Context ctx = getContext();
|
||||||
final TinyDB tinyDB = new TinyDB(ctx);
|
final TinyDB tinyDB = TinyDB.getInstance(ctx);
|
||||||
|
|
||||||
TextView editIssue = v.findViewById(R.id.editIssue);
|
TextView editIssue = v.findViewById(R.id.editIssue);
|
||||||
TextView editLabels = v.findViewById(R.id.editLabels);
|
TextView editLabels = v.findViewById(R.id.editLabels);
|
||||||
|
@ -16,7 +16,6 @@ import androidx.lifecycle.ViewModelProvider;
|
|||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.adapters.CollaboratorsAdapter;
|
import org.mian.gitnex.adapters.CollaboratorsAdapter;
|
||||||
import org.mian.gitnex.helpers.Authorization;
|
import org.mian.gitnex.helpers.Authorization;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
|
||||||
import org.mian.gitnex.models.Collaborators;
|
import org.mian.gitnex.models.Collaborators;
|
||||||
import org.mian.gitnex.viewmodels.CollaboratorsViewModel;
|
import org.mian.gitnex.viewmodels.CollaboratorsViewModel;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -65,18 +64,12 @@ public class CollaboratorsFragment extends Fragment {
|
|||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
|
|
||||||
View v = inflater.inflate(R.layout.fragment_collaborators, container, false);
|
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);
|
noDataCollaborators = v.findViewById(R.id.noDataCollaborators);
|
||||||
|
|
||||||
mProgressBar = v.findViewById(R.id.progress_bar);
|
mProgressBar = v.findViewById(R.id.progress_bar);
|
||||||
|
|
||||||
mGridView = v.findViewById(R.id.gridView);
|
mGridView = v.findViewById(R.id.gridView);
|
||||||
|
|
||||||
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName);
|
fetchDataAsync(Authorization.get(getContext()), repoOwner, repoName);
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,11 +89,11 @@ public class CollaboratorsFragment extends Fragment {
|
|||||||
void onFragmentInteraction(Uri uri);
|
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);
|
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
|
@Override
|
||||||
public void onChanged(@Nullable List<Collaborators> collaboratorsListMain) {
|
public void onChanged(@Nullable List<Collaborators> collaboratorsListMain) {
|
||||||
adapter = new CollaboratorsAdapter(getContext(), collaboratorsListMain);
|
adapter = new CollaboratorsAdapter(getContext(), collaboratorsListMain);
|
||||||
|
@ -54,7 +54,7 @@ public class DraftsFragment extends Fragment {
|
|||||||
|
|
||||||
((MainActivity) requireActivity()).setActionBarTitle(getResources().getString(R.string.titleDrafts));
|
((MainActivity) requireActivity()).setActionBarTitle(getResources().getString(R.string.titleDrafts));
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(ctx);
|
TinyDB tinyDb = TinyDB.getInstance(ctx);
|
||||||
|
|
||||||
draftsList_ = new ArrayList<>();
|
draftsList_ = new ArrayList<>();
|
||||||
draftsApi = new DraftsApi(ctx);
|
draftsApi = new DraftsApi(ctx);
|
||||||
|
@ -36,7 +36,7 @@ public class ExploreFragment extends Fragment {
|
|||||||
|
|
||||||
View v = inflater.inflate(R.layout.fragment_explore, container,false);
|
View v = inflater.inflate(R.layout.fragment_explore, container,false);
|
||||||
ctx = getContext();
|
ctx = getContext();
|
||||||
tinyDB = new TinyDB(ctx);
|
tinyDB = TinyDB.getInstance(ctx);
|
||||||
|
|
||||||
((MainActivity) requireActivity()).setActionBarTitle(getResources().getString(R.string.navExplore));
|
((MainActivity) requireActivity()).setActionBarTitle(getResources().getString(R.string.navExplore));
|
||||||
|
|
||||||
|
@ -58,10 +58,6 @@ public class ExploreRepositoriesFragment extends Fragment {
|
|||||||
private List<UserRepositories> dataList;
|
private List<UserRepositories> dataList;
|
||||||
private ExploreRepositoriesAdapter adapter;
|
private ExploreRepositoriesAdapter adapter;
|
||||||
|
|
||||||
private String instanceUrl;
|
|
||||||
private String loginUid;
|
|
||||||
private String instanceToken;
|
|
||||||
|
|
||||||
private Dialog dialogFilterOptions;
|
private Dialog dialogFilterOptions;
|
||||||
private CustomExploreRepositoriesDialogBinding filterBinding;
|
private CustomExploreRepositoriesDialogBinding filterBinding;
|
||||||
|
|
||||||
@ -72,11 +68,7 @@ public class ExploreRepositoriesFragment extends Fragment {
|
|||||||
setHasOptionsMenu(true);
|
setHasOptionsMenu(true);
|
||||||
|
|
||||||
ctx = getContext();
|
ctx = getContext();
|
||||||
tinyDb = new TinyDB(getContext());
|
tinyDb = TinyDB.getInstance(getContext());
|
||||||
|
|
||||||
instanceUrl = tinyDb.getString("instanceUrl");
|
|
||||||
loginUid = tinyDb.getString("loginUid");
|
|
||||||
instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
|
||||||
|
|
||||||
dataList = new ArrayList<>();
|
dataList = new ArrayList<>();
|
||||||
adapter = new ExploreRepositoriesAdapter(dataList, ctx);
|
adapter = new ExploreRepositoriesAdapter(dataList, ctx);
|
||||||
@ -183,7 +175,7 @@ public class ExploreRepositoriesFragment extends Fragment {
|
|||||||
viewBinding.loadingMoreView.setVisibility(View.VISIBLE);
|
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>() {
|
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.adapters.FilesAdapter;
|
||||||
import org.mian.gitnex.helpers.AppUtil;
|
import org.mian.gitnex.helpers.AppUtil;
|
||||||
import org.mian.gitnex.helpers.Authorization;
|
import org.mian.gitnex.helpers.Authorization;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
|
||||||
import org.mian.gitnex.viewmodels.FilesViewModel;
|
import org.mian.gitnex.viewmodels.FilesViewModel;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
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);
|
View v = inflater.inflate(R.layout.fragment_files, container, false);
|
||||||
setHasOptionsMenu(true);
|
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);
|
noDataFiles = v.findViewById(R.id.noDataFiles);
|
||||||
filesFrame = v.findViewById(R.id.filesFrame);
|
filesFrame = v.findViewById(R.id.filesFrame);
|
||||||
|
|
||||||
@ -115,11 +109,11 @@ public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapter
|
|||||||
fileStructure.setText("");
|
fileStructure.setText("");
|
||||||
ref = repoBranch;
|
ref = repoBranch;
|
||||||
mBreadcrumbsView.setItems(new ArrayList<>(Collections.singletonList(BreadcrumbItem.createSimpleItem(getResources().getString(R.string.filesBreadcrumbRoot) + getResources().getString(R.string.colonDivider) + ref))));
|
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;
|
return v;
|
||||||
}
|
}
|
||||||
@ -133,11 +127,6 @@ public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapter
|
|||||||
@Override
|
@Override
|
||||||
public void onClickDir(String dirName) {
|
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();
|
StringBuilder breadcrumbBuilder = new StringBuilder();
|
||||||
|
|
||||||
breadcrumbBuilder.append(fileStructure.getText().toString()).append("/").append(dirName);
|
breadcrumbBuilder.append(fileStructure.getText().toString()).append("/").append(dirName);
|
||||||
@ -158,7 +147,7 @@ public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapter
|
|||||||
|
|
||||||
if(position == 0) {
|
if(position == 0) {
|
||||||
|
|
||||||
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, ref);
|
fetchDataAsync(Authorization.get(getContext()), repoOwner, repoName, ref);
|
||||||
fileStructure.setText("");
|
fileStructure.setText("");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -169,7 +158,7 @@ public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapter
|
|||||||
|
|
||||||
String currentIndex = (result + item.getSelectedItem()).substring(1);
|
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);
|
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);
|
mRecyclerView.setVisibility(View.GONE);
|
||||||
mProgressBar.setVisibility(View.VISIBLE);
|
mProgressBar.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
FilesViewModel filesModel = new ViewModelProvider(this).get(FilesViewModel.class);
|
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);
|
adapter = new FilesAdapter(getContext(), filesListMain, FilesFragment.this);
|
||||||
mBreadcrumbsView.removeItemAfter(1);
|
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);
|
mRecyclerView.setVisibility(View.GONE);
|
||||||
mProgressBar.setVisibility(View.VISIBLE);
|
mProgressBar.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
FilesViewModel filesModel2 = new ViewModelProvider(this).get(FilesViewModel.class);
|
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);
|
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.R;
|
||||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||||
import org.mian.gitnex.adapters.IssuesAdapter;
|
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.Authorization;
|
||||||
import org.mian.gitnex.helpers.StaticGlobalVariables;
|
import org.mian.gitnex.helpers.StaticGlobalVariables;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
import org.mian.gitnex.helpers.TinyDB;
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
import org.mian.gitnex.helpers.Version;
|
import org.mian.gitnex.helpers.Version;
|
||||||
import org.mian.gitnex.interfaces.ApiInterface;
|
|
||||||
import org.mian.gitnex.models.Issues;
|
import org.mian.gitnex.models.Issues;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -47,7 +46,6 @@ public class IssuesFragment extends Fragment {
|
|||||||
private RecyclerView recyclerView;
|
private RecyclerView recyclerView;
|
||||||
private List<Issues> issuesList;
|
private List<Issues> issuesList;
|
||||||
private IssuesAdapter adapter;
|
private IssuesAdapter adapter;
|
||||||
private ApiInterface api;
|
|
||||||
private Context context;
|
private Context context;
|
||||||
private int pageSize = StaticGlobalVariables.issuesPageInit;
|
private int pageSize = StaticGlobalVariables.issuesPageInit;
|
||||||
private ProgressBar mProgressBar;
|
private ProgressBar mProgressBar;
|
||||||
@ -65,12 +63,11 @@ public class IssuesFragment extends Fragment {
|
|||||||
setHasOptionsMenu(true);
|
setHasOptionsMenu(true);
|
||||||
context = getContext();
|
context = getContext();
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(getContext());
|
TinyDB tinyDb = TinyDB.getInstance(getContext());
|
||||||
String repoFullName = tinyDb.getString("repoFullName");
|
String repoFullName = tinyDb.getString("repoFullName");
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
final String repoOwner = parts[0];
|
final String repoOwner = parts[0];
|
||||||
final String repoName = parts[1];
|
final String repoName = parts[1];
|
||||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
|
||||||
final String loginUid = tinyDb.getString("loginUid");
|
final String loginUid = tinyDb.getString("loginUid");
|
||||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||||
|
|
||||||
@ -102,7 +99,7 @@ public class IssuesFragment extends Fragment {
|
|||||||
if(issuesList.size() == resultLimit || pageSize == resultLimit) {
|
if(issuesList.size() == resultLimit || pageSize == resultLimit) {
|
||||||
|
|
||||||
int page = (issuesList.size() + resultLimit) / 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) {
|
if(issuesList.size() == resultLimit || pageSize == resultLimit) {
|
||||||
|
|
||||||
int page = (issuesList.size() + resultLimit) / 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);
|
mProgressBar.setVisibility(View.VISIBLE);
|
||||||
noDataIssues.setVisibility(View.GONE);
|
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);
|
recyclerView.setAdapter(adapter);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
api = AppApiService.createService(ApiInterface.class, instanceUrl, getContext());
|
loadInitial(Authorization.get(getContext()), repoOwner, repoName, resultLimit, requestType, tinyDb.getString("repoIssuesState"));
|
||||||
loadInitial(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, resultLimit, requestType, tinyDb.getString("repoIssuesState"));
|
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
|
|
||||||
@ -156,17 +152,16 @@ public class IssuesFragment extends Fragment {
|
|||||||
public void onResume() {
|
public void onResume() {
|
||||||
|
|
||||||
super.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 repoFullName = tinyDb.getString("repoFullName");
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
final String repoOwner = parts[0];
|
final String repoOwner = parts[0];
|
||||||
final String repoName = parts[1];
|
final String repoName = parts[1];
|
||||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
|
||||||
|
|
||||||
if(tinyDb.getBoolean("resumeIssues")) {
|
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);
|
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) {
|
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>>() {
|
call.enqueue(new Callback<List<Issues>>() {
|
||||||
|
|
||||||
@ -230,7 +225,7 @@ public class IssuesFragment extends Fragment {
|
|||||||
|
|
||||||
progressLoadMore.setVisibility(View.VISIBLE);
|
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>>() {
|
call.enqueue(new Callback<List<Issues>>() {
|
||||||
|
|
||||||
@ -285,7 +280,7 @@ public class IssuesFragment extends Fragment {
|
|||||||
inflater.inflate(R.menu.filter_menu, menu);
|
inflater.inflate(R.menu.filter_menu, menu);
|
||||||
super.onCreateOptionsMenu(menu, inflater);
|
super.onCreateOptionsMenu(menu, inflater);
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(context);
|
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
|
|
||||||
if(tinyDb.getString("repoIssuesState").equals("closed")) {
|
if(tinyDb.getString("repoIssuesState").equals("closed")) {
|
||||||
menu.getItem(1).setIcon(R.drawable.ic_filter_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);
|
final View v = inflater.inflate(R.layout.fragment_labels, container, false);
|
||||||
setHasOptionsMenu(true);
|
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);
|
final SwipeRefreshLayout swipeRefresh = v.findViewById(R.id.pullToRefresh);
|
||||||
noData = v.findViewById(R.id.noData);
|
noData = v.findViewById(R.id.noData);
|
||||||
|
|
||||||
@ -91,11 +87,11 @@ public class LabelsFragment extends Fragment {
|
|||||||
swipeRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
swipeRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||||
|
|
||||||
swipeRefresh.setRefreshing(false);
|
swipeRefresh.setRefreshing(false);
|
||||||
LabelsViewModel.loadLabelsList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, getContext());
|
LabelsViewModel.loadLabelsList(Authorization.get(getContext()), repoOwner, repoName, getContext());
|
||||||
|
|
||||||
}, 200));
|
}, 200));
|
||||||
|
|
||||||
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName);
|
fetchDataAsync(Authorization.get(getContext()), repoOwner, repoName);
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
|
|
||||||
@ -104,17 +100,15 @@ public class LabelsFragment extends Fragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
final TinyDB tinyDb = new TinyDB(getContext());
|
final TinyDB tinyDb = TinyDB.getInstance(getContext());
|
||||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
|
||||||
final String loginUid = tinyDb.getString("loginUid");
|
|
||||||
String repoFullName = tinyDb.getString("repoFullName");
|
String repoFullName = tinyDb.getString("repoFullName");
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
final String repoOwner = parts[0];
|
final String repoOwner = parts[0];
|
||||||
final String repoName = parts[1];
|
final String repoName = parts[1];
|
||||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
|
||||||
|
|
||||||
if(tinyDb.getBoolean("labelsRefresh")) {
|
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);
|
tinyDb.putBoolean("labelsRefresh", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -135,11 +129,11 @@ public class LabelsFragment extends Fragment {
|
|||||||
void onFragmentInteraction(Uri uri);
|
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);
|
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
|
@Override
|
||||||
public void onChanged(@Nullable List<Labels> labelsListMain) {
|
public void onChanged(@Nullable List<Labels> labelsListMain) {
|
||||||
adapter = new LabelsAdapter(getContext(), 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);
|
View v = inflater.inflate(R.layout.fragment_members_by_org, container, false);
|
||||||
setHasOptionsMenu(true);
|
setHasOptionsMenu(true);
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(getContext());
|
TinyDB tinyDb = TinyDB.getInstance(getContext());
|
||||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
|
||||||
final String loginUid = tinyDb.getString("loginUid");
|
final String loginUid = tinyDb.getString("loginUid");
|
||||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||||
noDataMembers = v.findViewById(R.id.noDataMembers);
|
noDataMembers = v.findViewById(R.id.noDataMembers);
|
||||||
@ -77,16 +76,16 @@ public class MembersByOrgFragment extends Fragment {
|
|||||||
progressBar = v.findViewById(R.id.progressBar);
|
progressBar = v.findViewById(R.id.progressBar);
|
||||||
mGridView = v.findViewById(R.id.gridView);
|
mGridView = v.findViewById(R.id.gridView);
|
||||||
|
|
||||||
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), orgName);
|
fetchDataAsync(Authorization.get(getContext()), orgName);
|
||||||
|
|
||||||
return v;
|
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);
|
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
|
@Override
|
||||||
public void onChanged(@Nullable List<UserInfo> membersListMain) {
|
public void onChanged(@Nullable List<UserInfo> membersListMain) {
|
||||||
adapter = new MembersByOrgAdapter(getContext(), membersListMain);
|
adapter = new MembersByOrgAdapter(getContext(), membersListMain);
|
||||||
|
@ -18,13 +18,12 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
|||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||||
import org.mian.gitnex.adapters.MilestonesAdapter;
|
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.databinding.FragmentMilestonesBinding;
|
||||||
import org.mian.gitnex.helpers.Authorization;
|
import org.mian.gitnex.helpers.Authorization;
|
||||||
import org.mian.gitnex.helpers.StaticGlobalVariables;
|
import org.mian.gitnex.helpers.StaticGlobalVariables;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
import org.mian.gitnex.helpers.TinyDB;
|
||||||
import org.mian.gitnex.helpers.Version;
|
import org.mian.gitnex.helpers.Version;
|
||||||
import org.mian.gitnex.interfaces.ApiInterface;
|
|
||||||
import org.mian.gitnex.models.Milestones;
|
import org.mian.gitnex.models.Milestones;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -43,7 +42,6 @@ public class MilestonesFragment extends Fragment {
|
|||||||
private Menu menu;
|
private Menu menu;
|
||||||
private List<Milestones> dataList;
|
private List<Milestones> dataList;
|
||||||
private MilestonesAdapter adapter;
|
private MilestonesAdapter adapter;
|
||||||
private ApiInterface api;
|
|
||||||
private Context ctx;
|
private Context ctx;
|
||||||
private int pageSize = StaticGlobalVariables.milestonesPageInit;
|
private int pageSize = StaticGlobalVariables.milestonesPageInit;
|
||||||
private String TAG = StaticGlobalVariables.tagMilestonesFragment;
|
private String TAG = StaticGlobalVariables.tagMilestonesFragment;
|
||||||
@ -56,12 +54,11 @@ public class MilestonesFragment extends Fragment {
|
|||||||
setHasOptionsMenu(true);
|
setHasOptionsMenu(true);
|
||||||
ctx = getContext();
|
ctx = getContext();
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(getContext());
|
TinyDB tinyDb = TinyDB.getInstance(getContext());
|
||||||
String repoFullName = tinyDb.getString("repoFullName");
|
String repoFullName = tinyDb.getString("repoFullName");
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
final String repoOwner = parts[0];
|
final String repoOwner = parts[0];
|
||||||
final String repoName = parts[1];
|
final String repoName = parts[1];
|
||||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
|
||||||
final String loginUid = tinyDb.getString("loginUid");
|
final String loginUid = tinyDb.getString("loginUid");
|
||||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||||
|
|
||||||
@ -83,7 +80,7 @@ public class MilestonesFragment extends Fragment {
|
|||||||
if(dataList.size() == resultLimit || pageSize == resultLimit) {
|
if(dataList.size() == resultLimit || pageSize == resultLimit) {
|
||||||
|
|
||||||
int page = (dataList.size() + resultLimit) / 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();
|
dataList.clear();
|
||||||
viewBinding.pullToRefresh.setRefreshing(false);
|
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);
|
adapter.updateList(dataList);
|
||||||
|
|
||||||
}, 50));
|
}, 50));
|
||||||
@ -124,7 +121,7 @@ public class MilestonesFragment extends Fragment {
|
|||||||
if(dataList.size() == resultLimit || pageSize == resultLimit) {
|
if(dataList.size() == resultLimit || pageSize == resultLimit) {
|
||||||
|
|
||||||
int page = (dataList.size() + resultLimit) / 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.progressBar.setVisibility(View.VISIBLE);
|
||||||
viewBinding.noDataMilestone.setVisibility(View.GONE);
|
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);
|
viewBinding.recyclerView.setAdapter(adapter);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
api = AppApiService.createService(ApiInterface.class, instanceUrl, ctx);
|
loadInitial(Authorization.get(getContext()), repoOwner, repoName, resultLimit, tinyDb.getString("milestoneState"));
|
||||||
loadInitial(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, resultLimit, tinyDb.getString("milestoneState"));
|
|
||||||
|
|
||||||
return viewBinding.getRoot();
|
return viewBinding.getRoot();
|
||||||
|
|
||||||
@ -153,7 +149,7 @@ public class MilestonesFragment extends Fragment {
|
|||||||
public void onResume() {
|
public void onResume() {
|
||||||
|
|
||||||
super.onResume();
|
super.onResume();
|
||||||
TinyDB tinyDb = new TinyDB(getContext());
|
TinyDB tinyDb = TinyDB.getInstance(getContext());
|
||||||
final String loginUid = tinyDb.getString("loginUid");
|
final String loginUid = tinyDb.getString("loginUid");
|
||||||
String repoFullName = tinyDb.getString("repoFullName");
|
String repoFullName = tinyDb.getString("repoFullName");
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
@ -163,7 +159,7 @@ public class MilestonesFragment extends Fragment {
|
|||||||
|
|
||||||
if(tinyDb.getBoolean("milestoneCreated")) {
|
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);
|
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) {
|
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>>() {
|
call.enqueue(new Callback<List<Milestones>>() {
|
||||||
|
|
||||||
@ -221,7 +217,7 @@ public class MilestonesFragment extends Fragment {
|
|||||||
|
|
||||||
viewBinding.progressLoadMore.setVisibility(View.VISIBLE);
|
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>>() {
|
call.enqueue(new Callback<List<Milestones>>() {
|
||||||
|
|
||||||
@ -278,7 +274,7 @@ public class MilestonesFragment extends Fragment {
|
|||||||
inflater.inflate(R.menu.filter_menu_milestone, menu);
|
inflater.inflate(R.menu.filter_menu_milestone, menu);
|
||||||
super.onCreateOptionsMenu(menu, inflater);
|
super.onCreateOptionsMenu(menu, inflater);
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(ctx);
|
TinyDB tinyDb = TinyDB.getInstance(ctx);
|
||||||
|
|
||||||
if(tinyDb.getString("milestoneState").equals("closed")) {
|
if(tinyDb.getString("milestoneState").equals("closed")) {
|
||||||
menu.getItem(1).setIcon(R.drawable.ic_filter_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.CreateRepoActivity;
|
||||||
import org.mian.gitnex.activities.MainActivity;
|
import org.mian.gitnex.activities.MainActivity;
|
||||||
import org.mian.gitnex.adapters.MyReposListAdapter;
|
import org.mian.gitnex.adapters.MyReposListAdapter;
|
||||||
import org.mian.gitnex.helpers.AppUtil;
|
|
||||||
import org.mian.gitnex.helpers.Authorization;
|
import org.mian.gitnex.helpers.Authorization;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
import org.mian.gitnex.helpers.TinyDB;
|
||||||
import org.mian.gitnex.viewmodels.MyRepositoriesViewModel;
|
import org.mian.gitnex.viewmodels.MyRepositoriesViewModel;
|
||||||
@ -78,15 +77,10 @@ public class MyRepositoriesFragment extends Fragment {
|
|||||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
|
|
||||||
boolean connToInternet = AppUtil.hasNetworkConnection(requireContext());
|
|
||||||
|
|
||||||
final View v = inflater.inflate(R.layout.fragment_my_repositories, container, false);
|
final View v = inflater.inflate(R.layout.fragment_my_repositories, container, false);
|
||||||
setHasOptionsMenu(true);
|
setHasOptionsMenu(true);
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(getContext());
|
TinyDB tinyDb = TinyDB.getInstance(getContext());
|
||||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
|
||||||
final String loginUid = tinyDb.getString("loginUid");
|
|
||||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
|
||||||
final String userLogin = tinyDb.getString("userLogin");
|
final String userLogin = tinyDb.getString("userLogin");
|
||||||
tinyDb.putBoolean("isRepoAdmin", true);
|
tinyDb.putBoolean("isRepoAdmin", true);
|
||||||
|
|
||||||
@ -132,11 +126,11 @@ public class MyRepositoriesFragment extends Fragment {
|
|||||||
swipeRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
swipeRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||||
|
|
||||||
swipeRefresh.setRefreshing(false);
|
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));
|
}, 50));
|
||||||
|
|
||||||
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), userLogin, pageSize, resultLimit);
|
fetchDataAsync(Authorization.get(getContext()), userLogin, pageSize, resultLimit);
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
|
|
||||||
@ -145,24 +139,21 @@ public class MyRepositoriesFragment extends Fragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
TinyDB tinyDb = new TinyDB(getContext());
|
TinyDB tinyDb = TinyDB.getInstance(getContext());
|
||||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
|
||||||
final String loginUid = tinyDb.getString("loginUid");
|
|
||||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
|
||||||
final String userLogin = tinyDb.getString("userLogin");
|
final String userLogin = tinyDb.getString("userLogin");
|
||||||
|
|
||||||
if(tinyDb.getBoolean("repoCreated")) {
|
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);
|
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);
|
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 -> {
|
myReposListMain -> {
|
||||||
|
|
||||||
adapter = new MyReposListAdapter(getContext(), myReposListMain);
|
adapter = new MyReposListAdapter(getContext(), myReposListMain);
|
||||||
@ -183,8 +174,6 @@ public class MyRepositoriesFragment extends Fragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
||||||
|
|
||||||
boolean connToInternet = AppUtil.hasNetworkConnection(requireContext());
|
|
||||||
|
|
||||||
inflater.inflate(R.menu.search_menu, menu);
|
inflater.inflate(R.menu.search_menu, menu);
|
||||||
super.onCreateOptionsMenu(menu, inflater);
|
super.onCreateOptionsMenu(menu, inflater);
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ public class NotificationsFragment extends Fragment implements NotificationsAdap
|
|||||||
|
|
||||||
activity = requireActivity();
|
activity = requireActivity();
|
||||||
context = getContext();
|
context = getContext();
|
||||||
tinyDB = new TinyDB(context);
|
tinyDB = TinyDB.getInstance(context);
|
||||||
|
|
||||||
pageResultLimit = StaticGlobalVariables.getCurrentResultLimit(context);
|
pageResultLimit = StaticGlobalVariables.getCurrentResultLimit(context);
|
||||||
tinyDB.putString("notificationsFilterState", currentFilterMode);
|
tinyDB.putString("notificationsFilterState", currentFilterMode);
|
||||||
@ -193,7 +193,6 @@ public class NotificationsFragment extends Fragment implements NotificationsAdap
|
|||||||
loadingMoreView.setVisibility(View.VISIBLE);
|
loadingMoreView.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
String instanceUrl = tinyDB.getString("instanceUrl");
|
|
||||||
String loginUid = tinyDB.getString("loginUid");
|
String loginUid = tinyDB.getString("loginUid");
|
||||||
String instanceToken = "token " + tinyDB.getString(loginUid + "-token");
|
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", "read"} :
|
||||||
new String[]{"pinned", "unread"};
|
new String[]{"pinned", "unread"};
|
||||||
|
|
||||||
Call<List<NotificationThread>> call = RetrofitClient.getInstance(instanceUrl, context)
|
Call<List<NotificationThread>> call = RetrofitClient
|
||||||
.getApiInterface()
|
.getApiInterface(context)
|
||||||
.getNotificationThreads(instanceToken, false, filter,
|
.getNotificationThreads(instanceToken, false, filter,
|
||||||
StaticGlobalVariables.defaultOldestTimestamp, "",
|
StaticGlobalVariables.defaultOldestTimestamp, "",
|
||||||
pageCurrentIndex, pageResultLimit);
|
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