mirror of
https://codeberg.org/gitnex/GitNex
synced 2025-03-09 16:10:50 +01:00
Move to tea4j-autodeploy (#1088)
Move to https://codeberg.org/GitNex/tea4j-autodeploy as Retrofit interfaces. Closes #907 closes #1084 Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: M M Arif <mmarif@swatian.com> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1088 Reviewed-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
This commit is contained in:
parent
c04e1dc584
commit
fbe55035f2
@ -30,16 +30,15 @@ android {
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
lintOptions {
|
||||
//checkReleaseBuilds false
|
||||
abortOnError false
|
||||
}
|
||||
compileOptions {
|
||||
coreLibraryDesugaringEnabled true
|
||||
|
||||
sourceCompatibility JavaVersion.VERSION_11
|
||||
targetCompatibility JavaVersion.VERSION_11
|
||||
}
|
||||
lint {
|
||||
abortOnError false
|
||||
}
|
||||
defaultConfig{
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
}
|
||||
@ -107,10 +106,12 @@ dependencies {
|
||||
implementation "androidx.work:work-runtime:$work_version"
|
||||
implementation "io.mikael:urlbuilder:2.0.9"
|
||||
implementation "org.codeberg.gitnex-garage:emoji-java:v5.1.2"
|
||||
implementation "org.codeberg.gitnex:tea4j:1.1.4"
|
||||
coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:1.1.5"
|
||||
implementation 'androidx.biometric:biometric:1.1.0'
|
||||
implementation 'com.github.chrisvest:stormpot:2.4.2'
|
||||
implementation 'androidx.browser:browser:1.4.0'
|
||||
implementation 'com.google.android.flexbox:flexbox:3.0.0'
|
||||
implementation('org.codeberg.gitnex:tea4j-autodeploy:4cd6803f8f') {
|
||||
exclude module: 'org.apache.oltu.oauth2.common'
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mian.gitnex.activities.MainActivity;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* @author qwerty287
|
||||
|
@ -8,7 +8,9 @@ import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
|
||||
/**
|
||||
* @author qwerty287
|
||||
|
@ -4,10 +4,9 @@ import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import androidx.annotation.NonNull;
|
||||
import org.gitnex.tea4j.models.Collaborators;
|
||||
import org.gitnex.tea4j.models.Issues;
|
||||
import org.gitnex.tea4j.v2.models.Issue;
|
||||
import org.gitnex.tea4j.v2.models.User;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.adapters.AssigneesListAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.CustomAssigneesSelectionDialogBinding;
|
||||
@ -24,18 +23,18 @@ public class AssigneesActions {
|
||||
|
||||
public static void getCurrentIssueAssignees(Context ctx, String repoOwner, String repoName, int issueIndex, List<String> currentAssignees) {
|
||||
|
||||
Call<Issues> callSingleIssueLabels = RetrofitClient
|
||||
Call<Issue> callSingleIssueLabels = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.getIssueByIndex(((BaseActivity) ctx).getAccount().getAuthorization(), repoOwner, repoName, issueIndex);
|
||||
.issueGetIssue(repoOwner, repoName, (long) issueIndex);
|
||||
|
||||
callSingleIssueLabels.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Issues> call, @NonNull retrofit2.Response<Issues> response) {
|
||||
public void onResponse(@NonNull Call<Issue> call, @NonNull retrofit2.Response<Issue> response) {
|
||||
|
||||
if(response.code() == 200) {
|
||||
|
||||
Issues issueAssigneesList = response.body();
|
||||
Issue issueAssigneesList = response.body();
|
||||
assert issueAssigneesList != null;
|
||||
|
||||
if(issueAssigneesList.getAssignees() != null) {
|
||||
@ -56,26 +55,26 @@ public class AssigneesActions {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Issues> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<Issue> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void getRepositoryAssignees(Context ctx, String repoOwner, String repoName, List<Collaborators> assigneesList, Dialog dialogAssignees, AssigneesListAdapter assigneesAdapter, CustomAssigneesSelectionDialogBinding assigneesBinding) {
|
||||
public static void getRepositoryAssignees(Context ctx, String repoOwner, String repoName, List<User> assigneesList, Dialog dialogAssignees, AssigneesListAdapter assigneesAdapter, CustomAssigneesSelectionDialogBinding assigneesBinding) {
|
||||
|
||||
Call<List<Collaborators>> call = RetrofitClient
|
||||
Call<List<User>> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.getAllAssignees(((BaseActivity) ctx).getAccount().getAuthorization(), repoOwner, repoName);
|
||||
.repoGetAssignees(repoOwner, repoName);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Collaborators>> call, @NonNull retrofit2.Response<List<Collaborators>> response) {
|
||||
public void onResponse(@NonNull Call<List<User>> call, @NonNull retrofit2.Response<List<User>> response) {
|
||||
|
||||
assigneesList.clear();
|
||||
List<Collaborators> assigneesList_ = response.body();
|
||||
List<User> assigneesList_ = response.body();
|
||||
|
||||
assigneesBinding.progressBar.setVisibility(View.GONE);
|
||||
assigneesBinding.dialogFrame.setVisibility(View.VISIBLE);
|
||||
@ -104,7 +103,7 @@ public class AssigneesActions {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Collaborators>> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<List<User>> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
|
@ -2,11 +2,9 @@ package org.mian.gitnex.actions;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.annotation.NonNull;
|
||||
import org.gitnex.tea4j.models.Collaborators;
|
||||
import org.gitnex.tea4j.models.Permission;
|
||||
import org.gitnex.tea4j.v2.models.AddCollaboratorOption;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.AddCollaboratorToRepositoryActivity;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.fragments.CollaboratorsFragment;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
@ -23,14 +21,14 @@ public class CollaboratorActions {
|
||||
|
||||
public static void deleteCollaborator(final Context context, String userName, RepositoryContext repository) {
|
||||
|
||||
Call<Collaborators> call = RetrofitClient
|
||||
Call<Void> call = RetrofitClient
|
||||
.getApiInterface(context)
|
||||
.deleteCollaborator(((BaseActivity) context).getAccount().getAuthorization(), repository.getOwner(), repository.getName(), userName);
|
||||
.repoDeleteCollaborator(repository.getOwner(), repository.getName(), userName);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Collaborators> call, @NonNull retrofit2.Response<Collaborators> response) {
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if(response.code() == 204) {
|
||||
@ -61,7 +59,7 @@ public class CollaboratorActions {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Collaborators> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(context, context.getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
@ -71,16 +69,17 @@ public class CollaboratorActions {
|
||||
|
||||
public static void addCollaborator(final Context context, String permission, String userName, RepositoryContext repository) {
|
||||
|
||||
Permission permissionString = new Permission(permission);
|
||||
AddCollaboratorOption permissionString = new AddCollaboratorOption();
|
||||
permissionString.setPermission(permission);
|
||||
|
||||
Call<Permission> call = RetrofitClient
|
||||
Call<Void> call = RetrofitClient
|
||||
.getApiInterface(context)
|
||||
.addCollaborator(((BaseActivity) context).getAccount().getAuthorization(), repository.getOwner(), repository.getName(), userName, permissionString);
|
||||
.repoAddCollaborator(repository.getOwner(), repository.getName(), userName, permissionString);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Permission> call, @NonNull retrofit2.Response<Permission> response) {
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if(response.code() == 204) {
|
||||
@ -111,7 +110,7 @@ public class CollaboratorActions {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Permission> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(context, context.getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
|
@ -2,13 +2,15 @@ package org.mian.gitnex.actions;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.annotation.NonNull;
|
||||
import com.google.gson.JsonElement;
|
||||
import org.gitnex.tea4j.models.IssueComments;
|
||||
import org.gitnex.tea4j.models.Issues;
|
||||
import org.gitnex.tea4j.models.UpdateIssueState;
|
||||
import org.gitnex.tea4j.v2.models.Comment;
|
||||
import org.gitnex.tea4j.v2.models.CreateIssueCommentOption;
|
||||
import org.gitnex.tea4j.v2.models.EditIssueCommentOption;
|
||||
import org.gitnex.tea4j.v2.models.EditIssueOption;
|
||||
import org.gitnex.tea4j.v2.models.Issue;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.activities.IssueDetailActivity;
|
||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.fragments.IssuesFragment;
|
||||
import org.mian.gitnex.fragments.PullRequestsFragment;
|
||||
@ -29,15 +31,18 @@ public class IssueActions {
|
||||
|
||||
ActionResult<Response<?>> actionResult = new ActionResult<>();
|
||||
|
||||
Call<IssueComments> call = RetrofitClient
|
||||
EditIssueCommentOption commentObj = new EditIssueCommentOption();
|
||||
commentObj.setBody(comment);
|
||||
|
||||
Call<Comment> call = RetrofitClient
|
||||
.getApiInterface(context)
|
||||
.patchIssueComment(((BaseActivity) context).getAccount().getAuthorization(), issue.getRepository().getOwner(),
|
||||
issue.getRepository().getName(), commentId, new IssueComments(comment));
|
||||
.issueEditComment(issue.getRepository().getOwner(),
|
||||
issue.getRepository().getName(), (long) commentId, commentObj);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<IssueComments> call, @NonNull retrofit2.Response<IssueComments> response) {
|
||||
public void onResponse(@NonNull Call<Comment> call, @NonNull retrofit2.Response<Comment> response) {
|
||||
|
||||
switch(response.code()) {
|
||||
|
||||
@ -60,47 +65,56 @@ public class IssueActions {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<IssueComments> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<Comment> call, @NonNull Throwable t) {
|
||||
|
||||
actionResult.finish(ActionResult.Status.FAILED);
|
||||
}
|
||||
});
|
||||
|
||||
return actionResult;
|
||||
|
||||
}
|
||||
|
||||
public static void closeReopenIssue(final Context ctx, final String issueState, IssueContext issue) {
|
||||
|
||||
UpdateIssueState issueStatJson = new UpdateIssueState(issueState);
|
||||
Call<JsonElement> call;
|
||||
|
||||
call = RetrofitClient
|
||||
EditIssueOption issueStatJson = new EditIssueOption();
|
||||
issueStatJson.setState(issueState);
|
||||
Call<Issue> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.closeReopenIssue(((BaseActivity) ctx).getAccount().getAuthorization(), issue.getRepository().getOwner(),
|
||||
issue.getRepository().getName(), issue.getIssueIndex(), issueStatJson);
|
||||
.issueEditIssue(issue.getRepository().getOwner(),
|
||||
issue.getRepository().getName(), (long) issue.getIssueIndex(), issueStatJson);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
|
||||
public void onResponse(@NonNull Call<Issue> call, @NonNull retrofit2.Response<Issue> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if(response.code() == 201) {
|
||||
|
||||
if(issue.hasIssue()) {
|
||||
IssuesFragment.resumeIssues = issue.getIssue().getPull_request() == null;
|
||||
PullRequestsFragment.resumePullRequests = issue.getIssue().getPull_request() != null;
|
||||
IssuesFragment.resumeIssues = issue.getIssue().getPullRequest() == null;
|
||||
PullRequestsFragment.resumePullRequests = issue.getIssue().getPullRequest() != null;
|
||||
}
|
||||
if(issue.getIssueType().equals("Pull")) {
|
||||
if(issueState.equals("closed")) {
|
||||
Toasty.success(ctx, ctx.getString(R.string.prClosed));
|
||||
}
|
||||
else if(issueState.equals("open")) {
|
||||
Toasty.success(ctx, ctx.getString(R.string.prReopened));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(issueState.equals("closed")) {
|
||||
Toasty.success(ctx, ctx.getString(R.string.issueStateClosed));
|
||||
}
|
||||
else if(issueState.equals("open")) {
|
||||
Toasty.success(ctx, ctx.getString(R.string.issueStateReopened));
|
||||
}
|
||||
}
|
||||
|
||||
((IssueDetailActivity) ctx).singleIssueUpdate = true;
|
||||
IssueDetailActivity.singleIssueUpdate = true;
|
||||
((IssueDetailActivity) ctx).onResume();
|
||||
RepoDetailActivity.updateRepo = true;
|
||||
}
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
@ -124,7 +138,7 @@ public class IssueActions {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<Issue> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
@ -138,8 +152,8 @@ public class IssueActions {
|
||||
|
||||
call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.addIssueSubscriber(((BaseActivity) ctx).getAccount().getAuthorization(), issue.getRepository().getOwner(),
|
||||
issue.getRepository().getName(), issue.getIssueIndex(), ((BaseActivity) ctx).getAccount().getAccount().getUserName());
|
||||
.issueAddSubscription(issue.getRepository().getOwner(),
|
||||
issue.getRepository().getName(), (long) issue.getIssueIndex(), ((BaseActivity) ctx).getAccount().getAccount().getUserName());
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@ -173,15 +187,14 @@ public class IssueActions {
|
||||
Toasty.error(ctx, ctx.getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public static void unsubscribe(final Context ctx, IssueContext issue) {
|
||||
|
||||
Call<Void> call;
|
||||
|
||||
call = RetrofitClient.getApiInterface(ctx).delIssueSubscriber(((BaseActivity) ctx).getAccount().getAuthorization(), issue.getRepository().getOwner(),
|
||||
issue.getRepository().getName(), issue.getIssueIndex(), ((BaseActivity) ctx).getAccount().getAccount().getUserName());
|
||||
call = RetrofitClient.getApiInterface(ctx).issueDeleteSubscription(issue.getRepository().getOwner(),
|
||||
issue.getRepository().getName(), (long) issue.getIssueIndex(), ((BaseActivity) ctx).getAccount().getAccount().getUserName());
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@ -223,24 +236,25 @@ public class IssueActions {
|
||||
|
||||
ActionResult<ActionResult.None> actionResult = new ActionResult<>();
|
||||
|
||||
Issues issueComment = new Issues(comment);
|
||||
CreateIssueCommentOption issueComment = new CreateIssueCommentOption();
|
||||
issueComment.setBody(comment);
|
||||
|
||||
Call<Issues> call = RetrofitClient
|
||||
Call<Comment> call = RetrofitClient
|
||||
.getApiInterface(context)
|
||||
.replyCommentToIssue(((BaseActivity) context).getAccount().getAuthorization(), issue.getRepository().getOwner(),
|
||||
issue.getRepository().getName(), issue.getIssueIndex(), issueComment);
|
||||
.issueCreateComment(issue.getRepository().getOwner(),
|
||||
issue.getRepository().getName(), (long) issue.getIssueIndex(), issueComment);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Issues> call, @NonNull retrofit2.Response<Issues> response) {
|
||||
public void onResponse(@NonNull Call<Comment> call, @NonNull retrofit2.Response<Comment> response) {
|
||||
|
||||
if(response.code() == 201) {
|
||||
actionResult.finish(ActionResult.Status.SUCCESS);
|
||||
|
||||
if(issue.hasIssue()) {
|
||||
IssuesFragment.resumeIssues = issue.getIssue().getPull_request() == null;
|
||||
PullRequestsFragment.resumePullRequests = issue.getIssue().getPull_request() != null;
|
||||
IssuesFragment.resumeIssues = issue.getIssue().getPullRequest() == null;
|
||||
PullRequestsFragment.resumePullRequests = issue.getIssue().getPullRequest() != null;
|
||||
}
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
@ -257,7 +271,7 @@ public class IssueActions {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Issues> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<Comment> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(context, context.getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
|
@ -4,9 +4,8 @@ import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import androidx.annotation.NonNull;
|
||||
import org.gitnex.tea4j.models.Labels;
|
||||
import org.gitnex.tea4j.v2.models.Label;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.adapters.LabelsListAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.CustomLabelsSelectionDialogBinding;
|
||||
@ -23,25 +22,26 @@ public class LabelsActions {
|
||||
|
||||
public static void getCurrentIssueLabels(Context ctx, String repoOwner, String repoName, int issueIndex, List<Integer> currentLabelsIds) {
|
||||
|
||||
Call<List<Labels>> callSingleIssueLabels = RetrofitClient
|
||||
Call<List<Label>> callSingleIssueLabels = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.getIssueLabels(((BaseActivity) ctx).getAccount().getAuthorization(), repoOwner, repoName, issueIndex);
|
||||
.issueGetLabels(repoOwner, repoName, (long) issueIndex);
|
||||
|
||||
callSingleIssueLabels.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Labels>> call, @NonNull retrofit2.Response<List<Labels>> response) {
|
||||
public void onResponse(@NonNull Call<List<Label>> call, @NonNull retrofit2.Response<List<Label>> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
|
||||
List<Labels> issueLabelsList = response.body();
|
||||
List<Label> issueLabelsList = response.body();
|
||||
|
||||
assert issueLabelsList != null;
|
||||
|
||||
if(issueLabelsList.size() > 0) {
|
||||
|
||||
for(int i = 0; i < issueLabelsList.size(); i++) {
|
||||
|
||||
currentLabelsIds.add(issueLabelsList.get(i).getId());
|
||||
currentLabelsIds.add(Math.toIntExact(issueLabelsList.get(i).getId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -51,23 +51,23 @@ public class LabelsActions {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Labels>> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<List<Label>> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void getRepositoryLabels(Context ctx, String repoOwner, String repoName, List<Labels> labelsList, Dialog dialogLabels, LabelsListAdapter labelsAdapter, CustomLabelsSelectionDialogBinding labelsBinding) {
|
||||
public static void getRepositoryLabels(Context ctx, String repoOwner, String repoName, List<Label> labelsList, Dialog dialogLabels, LabelsListAdapter labelsAdapter, CustomLabelsSelectionDialogBinding labelsBinding) {
|
||||
|
||||
Call<List<Labels>> call = RetrofitClient
|
||||
Call<List<Label>> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.getLabels(((BaseActivity) ctx).getAccount().getAuthorization(), repoOwner, repoName);
|
||||
.issueListLabels(repoOwner, repoName, null, null);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Labels>> call, @NonNull retrofit2.Response<List<Labels>> response) {
|
||||
public void onResponse(@NonNull Call<List<Label>> call, @NonNull retrofit2.Response<List<Label>> response) {
|
||||
|
||||
labelsList.clear();
|
||||
|
||||
@ -79,13 +79,14 @@ public class LabelsActions {
|
||||
}
|
||||
|
||||
// Load organization labels
|
||||
Call<List<Labels>> callOrgLabels = RetrofitClient.getApiInterface(ctx)
|
||||
.getOrganizationLabels(((BaseActivity) ctx).getAccount().getAuthorization(), repoOwner);
|
||||
Call<List<Label>> callOrgLabels = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.orgListLabels(repoOwner, null, null);
|
||||
|
||||
callOrgLabels.enqueue(new Callback<>() {
|
||||
callOrgLabels.enqueue(new Callback<List<Label>>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Labels>> call, @NonNull retrofit2.Response<List<Labels>> responseOrg) {
|
||||
public void onResponse(@NonNull Call<List<Label>> call, @NonNull retrofit2.Response<List<Label>> responseOrg) {
|
||||
|
||||
labelsBinding.progressBar.setVisibility(View.GONE);
|
||||
labelsBinding.dialogFrame.setVisibility(View.VISIBLE);
|
||||
@ -106,7 +107,7 @@ public class LabelsActions {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Labels>> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<List<Label>> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
@ -121,7 +122,7 @@ public class LabelsActions {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Labels>> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<List<Label>> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
|
@ -2,10 +2,9 @@ package org.mian.gitnex.actions;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.annotation.NonNull;
|
||||
import com.google.gson.JsonElement;
|
||||
import org.gitnex.tea4j.models.Milestones;
|
||||
import org.gitnex.tea4j.v2.models.EditMilestoneOption;
|
||||
import org.gitnex.tea4j.v2.models.Milestone;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
@ -14,84 +13,64 @@ import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
/**
|
||||
* @author M M Arif
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
public class MilestoneActions {
|
||||
|
||||
static final private String TAG = "MilestoneActions : ";
|
||||
|
||||
public static void closeMilestone(final Context ctx, int milestoneId_, RepositoryContext repository) {
|
||||
|
||||
Milestones milestoneStateJson = new Milestones("closed");
|
||||
Call<JsonElement> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.closeReopenMilestone(((BaseActivity) ctx).getAccount().getAuthorization(), repository.getOwner(), repository.getName(), milestoneId_, milestoneStateJson);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
|
||||
Toasty.success(ctx, ctx.getString(R.string.milestoneStatusUpdate));
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx, ctx.getResources().getString(R.string.alertDialogTokenRevokedTitle),
|
||||
ctx.getResources().getString(R.string.alertDialogTokenRevokedMessage), ctx.getResources().getString(R.string.cancelButton),
|
||||
ctx.getResources().getString(R.string.navLogout));
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
updateMilestoneState(ctx, milestoneId_, repository, "closed");
|
||||
}
|
||||
|
||||
public static void openMilestone(final Context ctx, int milestoneId_, RepositoryContext repository) {
|
||||
updateMilestoneState(ctx, milestoneId_, repository, "open");
|
||||
}
|
||||
|
||||
Milestones milestoneStateJson = new Milestones("open");
|
||||
Call<JsonElement> call;
|
||||
private static void updateMilestoneState(final Context ctx, int milestoneId_, RepositoryContext repository, String state) {
|
||||
|
||||
call = RetrofitClient
|
||||
EditMilestoneOption milestoneStateJson = new EditMilestoneOption();
|
||||
milestoneStateJson.setState(state);
|
||||
Call<Milestone> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.closeReopenMilestone(((BaseActivity) ctx).getAccount().getAuthorization(), repository.getOwner(), repository.getName(), milestoneId_, milestoneStateJson);
|
||||
.issueEditMilestone(repository.getOwner(), repository.getName(), String.valueOf(milestoneId_), milestoneStateJson);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
|
||||
public void onResponse(@NonNull Call<Milestone> call, @NonNull retrofit2.Response<Milestone> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
|
||||
Toasty.success(ctx, ctx.getString(R.string.milestoneStatusUpdate));
|
||||
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx, ctx.getResources().getString(R.string.alertDialogTokenRevokedTitle),
|
||||
ctx.getResources().getString(R.string.alertDialogTokenRevokedMessage), ctx.getResources().getString(R.string.cancelButton),
|
||||
ctx.getResources().getString(R.string.navLogout));
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<Milestone> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,9 +2,7 @@ package org.mian.gitnex.actions;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.annotation.NonNull;
|
||||
import com.google.gson.JsonElement;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
@ -19,14 +17,14 @@ import retrofit2.Response;
|
||||
public class PullRequestActions {
|
||||
|
||||
public static void deleteHeadBranch(Context context, String repoOwner, String repoName, String headBranch, boolean showToasts) {
|
||||
Call<JsonElement> call = RetrofitClient
|
||||
Call<Void> call = RetrofitClient
|
||||
.getApiInterface(context)
|
||||
.deleteBranch(((BaseActivity) context).getAccount().getAuthorization(), repoOwner, repoName, headBranch);
|
||||
.repoDeleteBranch(repoOwner, repoName, headBranch);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
|
||||
if(response.code() == 204) {
|
||||
|
||||
@ -61,7 +59,7 @@ public class PullRequestActions {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
if(showToasts) {
|
||||
Toasty.error(context, context.getString(R.string.deleteBranchError));
|
||||
@ -83,8 +81,7 @@ public class PullRequestActions {
|
||||
else {
|
||||
strategy = "rebase";
|
||||
}
|
||||
|
||||
RetrofitClient.getApiInterface(context).updatePullRequest(((BaseActivity) context).getAccount().getAuthorization(), repoOwner, repoName, Integer.parseInt(index), strategy)
|
||||
RetrofitClient.getApiInterface(context).repoUpdatePullRequest(repoOwner, repoName, Long.valueOf(index), strategy)
|
||||
.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
|
@ -2,9 +2,8 @@ package org.mian.gitnex.actions;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.annotation.NonNull;
|
||||
import com.google.gson.JsonElement;
|
||||
import org.gitnex.tea4j.v2.models.WatchInfo;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.activities.MainActivity;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
@ -21,16 +20,14 @@ public class RepositoryActions {
|
||||
|
||||
public static void starRepository(final Context context, RepositoryContext repository) {
|
||||
|
||||
Call<JsonElement> call;
|
||||
|
||||
call = RetrofitClient
|
||||
Call<Void> call = RetrofitClient
|
||||
.getApiInterface(context)
|
||||
.starRepository(((BaseActivity) context).getAccount().getAuthorization(), repository.getOwner(), repository.getName());
|
||||
.userCurrentPutStar(repository.getOwner(), repository.getName());
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if(response.code() == 204) {
|
||||
@ -60,7 +57,7 @@ public class RepositoryActions {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
@ -69,16 +66,14 @@ public class RepositoryActions {
|
||||
|
||||
public static void unStarRepository(final Context context, RepositoryContext repository) {
|
||||
|
||||
Call<JsonElement> call;
|
||||
|
||||
call = RetrofitClient
|
||||
Call<Void> call = RetrofitClient
|
||||
.getApiInterface(context)
|
||||
.unStarRepository(((BaseActivity) context).getAccount().getAuthorization(), repository.getOwner(), repository.getName());
|
||||
.userCurrentDeleteStar(repository.getOwner(), repository.getName());
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if(response.code() == 204) {
|
||||
@ -108,7 +103,7 @@ public class RepositoryActions {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
@ -117,16 +112,14 @@ public class RepositoryActions {
|
||||
|
||||
public static void watchRepository(final Context context, RepositoryContext repository) {
|
||||
|
||||
Call<JsonElement> call;
|
||||
|
||||
call = RetrofitClient
|
||||
Call<WatchInfo> call = RetrofitClient
|
||||
.getApiInterface(context)
|
||||
.watchRepository(((BaseActivity) context).getAccount().getAuthorization(), repository.getOwner(), repository.getName());
|
||||
.userCurrentPutSubscription(repository.getOwner(), repository.getName());
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
|
||||
public void onResponse(@NonNull Call<WatchInfo> call, @NonNull retrofit2.Response<WatchInfo> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if(response.code() == 200) {
|
||||
@ -157,7 +150,7 @@ public class RepositoryActions {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<WatchInfo> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
@ -166,16 +159,14 @@ public class RepositoryActions {
|
||||
|
||||
public static void unWatchRepository(final Context context, RepositoryContext repository) {
|
||||
|
||||
Call<JsonElement> call;
|
||||
|
||||
call = RetrofitClient
|
||||
Call<Void> call = RetrofitClient
|
||||
.getApiInterface(context)
|
||||
.unWatchRepository(((BaseActivity) context).getAccount().getAuthorization(), repository.getOwner(), repository.getName());
|
||||
.userCurrentDeleteStar(repository.getOwner(), repository.getName());
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
|
||||
if(response.code() == 204) {
|
||||
|
||||
@ -202,7 +193,7 @@ public class RepositoryActions {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
|
@ -2,10 +2,8 @@ package org.mian.gitnex.actions;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.annotation.NonNull;
|
||||
import com.google.gson.JsonElement;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.AddNewTeamMemberActivity;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
@ -20,14 +18,14 @@ public class TeamActions {
|
||||
|
||||
public static void removeTeamMember(final Context context, String userName, int teamId) {
|
||||
|
||||
Call<JsonElement> call = RetrofitClient
|
||||
Call<Void> call = RetrofitClient
|
||||
.getApiInterface(context)
|
||||
.removeTeamMember(((BaseActivity) context).getAccount().getAuthorization(), teamId, userName);
|
||||
.orgRemoveTeamMember((long) teamId, userName);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
|
||||
@ -59,7 +57,7 @@ public class TeamActions {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(context, context.getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
@ -68,14 +66,14 @@ public class TeamActions {
|
||||
|
||||
public static void addTeamMember(final Context context, String userName, int teamId) {
|
||||
|
||||
Call<JsonElement> call = RetrofitClient
|
||||
Call<Void> call = RetrofitClient
|
||||
.getApiInterface(context)
|
||||
.addTeamMember(((BaseActivity) context).getAccount().getAuthorization(), teamId, userName);
|
||||
.orgAddTeamMember((long) teamId, userName);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
|
||||
@ -106,7 +104,7 @@ public class TeamActions {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(context, context.getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
|
@ -12,8 +12,8 @@ import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import org.gitnex.tea4j.models.UserInfo;
|
||||
import org.gitnex.tea4j.models.UserSearch;
|
||||
import org.gitnex.tea4j.v2.models.InlineResponse2001;
|
||||
import org.gitnex.tea4j.v2.models.User;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.CollaboratorSearchAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
@ -83,14 +83,14 @@ public class AddCollaboratorToRepositoryActivity extends BaseActivity {
|
||||
|
||||
public void loadUserSearchList(String searchKeyword) {
|
||||
|
||||
Call<UserSearch> call = RetrofitClient
|
||||
Call<InlineResponse2001> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.getUserBySearch(getAccount().getAuthorization(), searchKeyword, 10, 1);
|
||||
.userSearch(searchKeyword, null, 1, 10);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<UserSearch> call, @NonNull Response<UserSearch> response) {
|
||||
public void onResponse(@NonNull Call<InlineResponse2001> call, @NonNull Response<InlineResponse2001> response) {
|
||||
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
|
||||
@ -106,14 +106,13 @@ public class AddCollaboratorToRepositoryActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<UserSearch> call, @NonNull Throwable t) {
|
||||
|
||||
public void onFailure(@NonNull Call<InlineResponse2001> call, @NonNull Throwable t) {
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void getUsersList(List<UserInfo> dataList, Context context) {
|
||||
private void getUsersList(List<User> dataList, Context context) {
|
||||
|
||||
CollaboratorSearchAdapter adapter = new CollaboratorSearchAdapter(dataList, context, repository);
|
||||
|
||||
|
@ -8,8 +8,8 @@ import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import org.gitnex.tea4j.models.GiteaVersion;
|
||||
import org.gitnex.tea4j.models.UserInfo;
|
||||
import org.gitnex.tea4j.v2.models.ServerVersion;
|
||||
import org.gitnex.tea4j.v2.models.User;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.database.api.BaseApi;
|
||||
@ -23,12 +23,13 @@ import org.mian.gitnex.helpers.UrlHelper;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import org.mian.gitnex.structs.Protocol;
|
||||
import java.net.URI;
|
||||
import java.util.Objects;
|
||||
import io.mikael.urlbuilder.UrlBuilder;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class AddNewAccountActivity extends BaseActivity {
|
||||
@ -37,6 +38,7 @@ public class AddNewAccountActivity extends BaseActivity {
|
||||
private ActivityAddNewAccountBinding viewBinding;
|
||||
|
||||
private String spinnerSelectedValue;
|
||||
private Version giteaVersion;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
@ -117,7 +119,6 @@ public class AddNewAccountActivity extends BaseActivity {
|
||||
}
|
||||
catch(Exception e) {
|
||||
|
||||
Log.e("onFailure-login", e.toString());
|
||||
Toasty.error(ctx, getResources().getString(R.string.malformedUrl));
|
||||
}
|
||||
|
||||
@ -125,16 +126,15 @@ public class AddNewAccountActivity extends BaseActivity {
|
||||
|
||||
private void versionCheck(final String instanceUrl, final String loginToken) {
|
||||
|
||||
Call<GiteaVersion> callVersion;
|
||||
callVersion = RetrofitClient.getApiInterface(ctx, instanceUrl).getGiteaVersionWithToken("token " + loginToken);
|
||||
callVersion.enqueue(new Callback<GiteaVersion>() {
|
||||
Call<ServerVersion> callVersion = RetrofitClient.getApiInterface(ctx, instanceUrl, "token " + loginToken).getVersion();
|
||||
callVersion.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull final Call<GiteaVersion> callVersion, @NonNull retrofit2.Response<GiteaVersion> responseVersion) {
|
||||
public void onResponse(@NonNull final Call<ServerVersion> callVersion, @NonNull retrofit2.Response<ServerVersion> responseVersion) {
|
||||
|
||||
if(responseVersion.code() == 200) {
|
||||
|
||||
GiteaVersion version = responseVersion.body();
|
||||
ServerVersion version = responseVersion.body();
|
||||
|
||||
assert version != null;
|
||||
|
||||
@ -144,7 +144,7 @@ public class AddNewAccountActivity extends BaseActivity {
|
||||
return;
|
||||
}
|
||||
|
||||
Version giteaVersion = new Version(version.getVersion());
|
||||
giteaVersion = new Version(version.getVersion());
|
||||
|
||||
if(giteaVersion.less(getString(R.string.versionLow))) {
|
||||
|
||||
@ -188,7 +188,7 @@ public class AddNewAccountActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<GiteaVersion> callVersion, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<ServerVersion> callVersion, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure-versionCheck", t.toString());
|
||||
Toasty.error(ctx, getResources().getString(R.string.genericServerResponseError));
|
||||
@ -198,14 +198,14 @@ public class AddNewAccountActivity extends BaseActivity {
|
||||
|
||||
private void setupNewAccountWithToken(String instanceUrl, final String loginToken) {
|
||||
|
||||
Call<UserInfo> call = RetrofitClient.getApiInterface(ctx, instanceUrl).getUserInfo("token " + loginToken);
|
||||
Call<User> call = RetrofitClient.getApiInterface(ctx, instanceUrl, "token " + loginToken).userGetCurrent();
|
||||
|
||||
call.enqueue(new Callback<UserInfo>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<UserInfo> call, @NonNull retrofit2.Response<UserInfo> response) {
|
||||
public void onResponse(@NonNull Call<User> call, @NonNull retrofit2.Response<User> response) {
|
||||
|
||||
UserInfo userDetails = response.body();
|
||||
User userDetails = response.body();
|
||||
|
||||
switch(response.code()) {
|
||||
|
||||
@ -213,31 +213,32 @@ public class AddNewAccountActivity extends BaseActivity {
|
||||
|
||||
assert userDetails != null;
|
||||
// insert new account to db if does not exist
|
||||
String accountName = userDetails.getUsername() + "@" + instanceUrl;
|
||||
String accountName = userDetails.getLogin() + "@" + instanceUrl;
|
||||
UserAccountsApi userAccountsApi = BaseApi.getInstance(ctx, UserAccountsApi.class);
|
||||
boolean userAccountExists = userAccountsApi.userAccountExists(accountName);
|
||||
boolean userAccountExists = Objects.requireNonNull(userAccountsApi).userAccountExists(accountName);
|
||||
|
||||
if(!userAccountExists) {
|
||||
|
||||
long id = userAccountsApi.createNewAccount(accountName, instanceUrl, userDetails.getUsername(), loginToken, "");
|
||||
long id = userAccountsApi.createNewAccount(accountName, instanceUrl, userDetails.getLogin(), loginToken, giteaVersion.toString());
|
||||
UserAccount account = userAccountsApi.getAccountById((int) id);
|
||||
AppUtil.switchToAccount(AddNewAccountActivity.this, account);
|
||||
Toasty.success(ctx, getResources().getString(R.string.accountAddedMessage));
|
||||
MainActivity.refActivity = true;
|
||||
finish();
|
||||
|
||||
}
|
||||
else {
|
||||
UserAccount account = userAccountsApi.getAccountByName(accountName);
|
||||
if(account.isLoggedIn()) {
|
||||
Toasty.warning(ctx, getResources().getString(R.string.accountAlreadyExistsError));
|
||||
AppUtil.switchToAccount(ctx, account);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
userAccountsApi.updateTokenByAccountName(accountName, loginToken);
|
||||
userAccountsApi.login(account.getAccountId());
|
||||
AppUtil.switchToAccount(AddNewAccountActivity.this, account);
|
||||
}
|
||||
finish();
|
||||
}
|
||||
finish();
|
||||
break;
|
||||
|
||||
case 401:
|
||||
@ -253,9 +254,8 @@ public class AddNewAccountActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<UserInfo> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<User> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
Toasty.error(ctx, getResources().getString(R.string.genericError));
|
||||
}
|
||||
});
|
||||
@ -266,5 +266,4 @@ public class AddNewAccountActivity extends BaseActivity {
|
||||
|
||||
onClickListener = view -> finish();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -14,14 +14,13 @@ import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import org.gitnex.tea4j.models.UserInfo;
|
||||
import org.gitnex.tea4j.models.UserSearch;
|
||||
import org.gitnex.tea4j.v2.models.InlineResponse2001;
|
||||
import org.gitnex.tea4j.v2.models.User;
|
||||
import org.mian.gitnex.adapters.UserSearchForTeamMemberAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.ActivityAddNewTeamMemberBinding;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
@ -38,10 +37,10 @@ public class AddNewTeamMemberActivity extends BaseActivity {
|
||||
private ProgressBar mProgressBar;
|
||||
|
||||
private RecyclerView mRecyclerView;
|
||||
private List<UserInfo> dataList;
|
||||
private List<User> dataList;
|
||||
private UserSearchForTeamMemberAdapter adapter;
|
||||
|
||||
private String teamId;
|
||||
private long teamId;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
@ -66,14 +65,7 @@ public class AddNewTeamMemberActivity extends BaseActivity {
|
||||
initCloseListener();
|
||||
closeActivity.setOnClickListener(onClickListener);
|
||||
|
||||
if(getIntent().getStringExtra("teamId") != null && !Objects.requireNonNull(getIntent().getStringExtra("teamId")).equals("")) {
|
||||
|
||||
teamId = getIntent().getStringExtra("teamId");
|
||||
}
|
||||
else {
|
||||
|
||||
teamId = "0";
|
||||
}
|
||||
teamId = getIntent().getLongExtra("teamId", 0);
|
||||
|
||||
mRecyclerView.setHasFixedSize(true);
|
||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(ctx));
|
||||
@ -90,7 +82,7 @@ public class AddNewTeamMemberActivity extends BaseActivity {
|
||||
|
||||
if(!addNewTeamMember.getText().toString().equals("") && addNewTeamMember.getText().toString().length() > 1) {
|
||||
|
||||
adapter = new UserSearchForTeamMemberAdapter(dataList, ctx, Integer.parseInt(teamId), getIntent().getStringExtra("orgName"));
|
||||
adapter = new UserSearchForTeamMemberAdapter(dataList, ctx, Math.toIntExact(teamId), getIntent().getStringExtra("orgName"));
|
||||
loadUserSearchList(addNewTeamMember.getText().toString());
|
||||
}
|
||||
}
|
||||
@ -109,14 +101,14 @@ public class AddNewTeamMemberActivity extends BaseActivity {
|
||||
|
||||
public void loadUserSearchList(String searchKeyword) {
|
||||
|
||||
Call<UserSearch> call = RetrofitClient.getApiInterface(ctx).getUserBySearch(getAccount().getAuthorization(), searchKeyword, 10, 1);
|
||||
Call<InlineResponse2001> call = RetrofitClient.getApiInterface(ctx).userSearch(searchKeyword, null, 1, 10);
|
||||
|
||||
mProgressBar.setVisibility(View.VISIBLE);
|
||||
|
||||
call.enqueue(new Callback<UserSearch>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<UserSearch> call, @NonNull Response<UserSearch> response) {
|
||||
public void onResponse(@NonNull Call<InlineResponse2001> call, @NonNull Response<InlineResponse2001> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
|
||||
@ -139,7 +131,8 @@ public class AddNewTeamMemberActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<UserSearch> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<InlineResponse2001> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
}
|
||||
|
||||
|
@ -51,18 +51,18 @@ public class AdminCronTasksActivity extends BaseActivity {
|
||||
activityAdminCronTasksBinding.pullToRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
|
||||
activityAdminCronTasksBinding.pullToRefresh.setRefreshing(false);
|
||||
AdminCronTasksViewModel.loadCronTasksList(ctx, getAccount().getAuthorization(), PAGE, LIMIT);
|
||||
AdminCronTasksViewModel.loadCronTasksList(ctx, PAGE, LIMIT);
|
||||
|
||||
}, 500));
|
||||
|
||||
fetchDataAsync(ctx, getAccount().getAuthorization());
|
||||
fetchDataAsync(ctx);
|
||||
}
|
||||
|
||||
private void fetchDataAsync(Context ctx, String instanceToken) {
|
||||
private void fetchDataAsync(Context ctx) {
|
||||
|
||||
AdminCronTasksViewModel cronTasksViewModel = new ViewModelProvider(this).get(AdminCronTasksViewModel.class);
|
||||
|
||||
cronTasksViewModel.getCronTasksList(ctx, instanceToken, PAGE, LIMIT).observe(this, cronTasksListMain -> {
|
||||
cronTasksViewModel.getCronTasksList(ctx, PAGE, LIMIT).observe(this, cronTasksListMain -> {
|
||||
|
||||
adapter = new AdminCronTasksAdapter(cronTasksListMain);
|
||||
|
||||
|
@ -59,18 +59,18 @@ public class AdminGetUsersActivity extends BaseActivity implements BottomSheetLi
|
||||
|
||||
page = 1;
|
||||
activityAdminGetUsersBinding.pullToRefresh.setRefreshing(false);
|
||||
fetchDataAsync(getAccount().getAuthorization());
|
||||
fetchDataAsync();
|
||||
activityAdminGetUsersBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
}, 50));
|
||||
|
||||
fetchDataAsync(getAccount().getAuthorization());
|
||||
fetchDataAsync();
|
||||
};
|
||||
|
||||
private void fetchDataAsync(String instanceToken) {
|
||||
private void fetchDataAsync() {
|
||||
|
||||
AdminGetUsersViewModel adminUsersModel = new ViewModelProvider(this).get(AdminGetUsersViewModel.class);
|
||||
|
||||
adminUsersModel.getUsersList(instanceToken, page, resultLimit, ctx).observe(this, adminUsersListMain -> {
|
||||
adminUsersModel.getUsersList(page, resultLimit, ctx).observe(this, adminUsersListMain -> {
|
||||
|
||||
adapter = new AdminGetUsersAdapter(adminUsersListMain, ctx);
|
||||
adapter.setLoadMoreListener(new AdminGetUsersAdapter.OnLoadMoreListener() {
|
||||
@ -79,7 +79,7 @@ public class AdminGetUsersActivity extends BaseActivity implements BottomSheetLi
|
||||
public void onLoadMore() {
|
||||
|
||||
page += 1;
|
||||
AdminGetUsersViewModel.loadMoreUsersList(instanceToken, page, resultLimit, ctx, adapter);
|
||||
AdminGetUsersViewModel.loadMoreUsersList(page, resultLimit, ctx, adapter);
|
||||
activityAdminGetUsersBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
import org.gitnex.tea4j.models.Commits;
|
||||
import org.gitnex.tea4j.v2.models.Commit;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.CommitsAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
@ -46,7 +46,7 @@ public class CommitsActivity extends BaseActivity {
|
||||
private int pageSize = 1;
|
||||
|
||||
private RecyclerView recyclerView;
|
||||
private List<Commits> commitsList;
|
||||
private List<Commit> commitsList;
|
||||
private CommitsAdapter adapter;
|
||||
private ProgressBar progressLoadMore;
|
||||
|
||||
@ -92,7 +92,7 @@ public class CommitsActivity extends BaseActivity {
|
||||
swipeRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
|
||||
swipeRefresh.setRefreshing(false);
|
||||
loadInitial(getAccount().getAuthorization(), repository.getOwner(), repository.getName(), branchName, resultLimit);
|
||||
loadInitial(repository.getOwner(), repository.getName(), branchName, resultLimit);
|
||||
adapter.notifyDataChanged();
|
||||
}, 200));
|
||||
|
||||
@ -102,7 +102,7 @@ public class CommitsActivity extends BaseActivity {
|
||||
if(commitsList.size() == resultLimit || pageSize == resultLimit) {
|
||||
|
||||
int page = (commitsList.size() + resultLimit) / resultLimit;
|
||||
loadMore(getAccount().getAuthorization(), repository.getOwner(), repository.getName(), page, branchName, resultLimit);
|
||||
loadMore(repository.getOwner(), repository.getName(), page, branchName, resultLimit);
|
||||
}
|
||||
}));
|
||||
|
||||
@ -110,17 +110,17 @@ public class CommitsActivity extends BaseActivity {
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(ctx));
|
||||
recyclerView.setAdapter(adapter);
|
||||
|
||||
loadInitial(getAccount().getAuthorization(), repository.getOwner(), repository.getName(), branchName, resultLimit);
|
||||
loadInitial(repository.getOwner(), repository.getName(), branchName, resultLimit);
|
||||
}
|
||||
|
||||
private void loadInitial(String token, String repoOwner, String repoName, String branchName, int resultLimit) {
|
||||
private void loadInitial(String repoOwner, String repoName, String branchName, int resultLimit) {
|
||||
|
||||
Call<List<Commits>> call = RetrofitClient.getApiInterface(ctx).getRepositoryCommits(token, repoOwner, repoName, 1, branchName, resultLimit);
|
||||
Call<List<Commit>> call = RetrofitClient.getApiInterface(ctx).repoGetAllCommits(repoOwner, repoName, branchName, null, 1, resultLimit);
|
||||
|
||||
call.enqueue(new Callback<List<Commits>>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Commits>> call, @NonNull Response<List<Commits>> response) {
|
||||
public void onResponse(@NonNull Call<List<Commit>> call, @NonNull Response<List<Commit>> response) {
|
||||
|
||||
if(response.code() == 200) {
|
||||
|
||||
@ -152,7 +152,7 @@ public class CommitsActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Commits>> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<List<Commit>> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
@ -161,20 +161,20 @@ public class CommitsActivity extends BaseActivity {
|
||||
|
||||
}
|
||||
|
||||
private void loadMore(String token, String repoOwner, String repoName, final int page, String branchName, int resultLimit) {
|
||||
private void loadMore(String repoOwner, String repoName, final int page, String branchName, int resultLimit) {
|
||||
|
||||
progressLoadMore.setVisibility(View.VISIBLE);
|
||||
|
||||
Call<List<Commits>> call = RetrofitClient.getApiInterface(ctx).getRepositoryCommits(token, repoOwner, repoName, page, branchName, resultLimit);
|
||||
Call<List<Commit>> call = RetrofitClient.getApiInterface(ctx).repoGetAllCommits(repoOwner, repoName, branchName, null, page, resultLimit);
|
||||
|
||||
call.enqueue(new Callback<List<Commits>>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Commits>> call, @NonNull Response<List<Commits>> response) {
|
||||
public void onResponse(@NonNull Call<List<Commit>> call, @NonNull Response<List<Commit>> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
|
||||
List<Commits> result = response.body();
|
||||
List<Commit> result = response.body();
|
||||
assert result != null;
|
||||
|
||||
if(result.size() > 0) {
|
||||
@ -198,7 +198,7 @@ public class CommitsActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Commits>> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<List<Commit>> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
@ -239,9 +239,9 @@ public class CommitsActivity extends BaseActivity {
|
||||
|
||||
private void filter(String text) {
|
||||
|
||||
List<Commits> arr = new ArrayList<>();
|
||||
List<Commit> arr = new ArrayList<>();
|
||||
|
||||
for(Commits d : commitsList) {
|
||||
for(Commit d : commitsList) {
|
||||
|
||||
if(d.getCommit().getMessage().toLowerCase().contains(text) || d.getSha().toLowerCase().contains(text)) {
|
||||
|
||||
@ -254,10 +254,7 @@ public class CommitsActivity extends BaseActivity {
|
||||
|
||||
private void initCloseListener() {
|
||||
|
||||
onClickListener = view -> {
|
||||
|
||||
finish();
|
||||
};
|
||||
onClickListener = view -> finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -11,11 +11,12 @@ import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import com.google.gson.JsonElement;
|
||||
import org.gitnex.tea4j.models.Branches;
|
||||
import org.gitnex.tea4j.models.DeleteFile;
|
||||
import org.gitnex.tea4j.models.EditFile;
|
||||
import org.gitnex.tea4j.models.NewFile;
|
||||
import org.gitnex.tea4j.v2.models.Branch;
|
||||
import org.gitnex.tea4j.v2.models.CreateFileOptions;
|
||||
import org.gitnex.tea4j.v2.models.DeleteFileOptions;
|
||||
import org.gitnex.tea4j.v2.models.FileDeleteResponse;
|
||||
import org.gitnex.tea4j.v2.models.FileResponse;
|
||||
import org.gitnex.tea4j.v2.models.UpdateFileOptions;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.ActivityCreateFileBinding;
|
||||
@ -175,18 +176,23 @@ public class CreateFileActivity extends BaseActivity {
|
||||
|
||||
private void createNewFile(String repoOwner, String repoName, String fileName, String fileContent, String fileCommitMessage, String branchName) {
|
||||
|
||||
NewFile createNewFileJsonStr = branches.contains(branchName) ?
|
||||
new NewFile(branchName, fileContent, fileCommitMessage, "") :
|
||||
new NewFile("", fileContent, fileCommitMessage, branchName);
|
||||
CreateFileOptions createNewFileJsonStr = new CreateFileOptions();
|
||||
createNewFileJsonStr.setContent(fileContent);
|
||||
createNewFileJsonStr.setMessage(fileCommitMessage);
|
||||
if(branches.contains(branchName)) {
|
||||
createNewFileJsonStr.setBranch(branchName);
|
||||
} else {
|
||||
createNewFileJsonStr.setNewBranch(branchName);
|
||||
}
|
||||
|
||||
Call<JsonElement> call = RetrofitClient
|
||||
Call<FileResponse> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.createNewFile(getAccount().getAuthorization(), repoOwner, repoName, fileName, createNewFileJsonStr);
|
||||
.repoCreateFile(createNewFileJsonStr, repoOwner, repoName, fileName);
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
call.enqueue(new Callback<FileResponse>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
|
||||
public void onResponse(@NonNull Call<FileResponse> call, @NonNull retrofit2.Response<FileResponse> response) {
|
||||
|
||||
switch(response.code()) {
|
||||
|
||||
@ -195,6 +201,7 @@ public class CreateFileActivity extends BaseActivity {
|
||||
Toasty.success(ctx, getString(R.string.newFileSuccessMessage));
|
||||
Intent result = new Intent();
|
||||
result.putExtra("fileModified", true);
|
||||
result.putExtra("fileAction", fileAction);
|
||||
setResult(200, result);
|
||||
finish();
|
||||
break;
|
||||
@ -221,7 +228,7 @@ public class CreateFileActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<FileResponse> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
enableProcessButton();
|
||||
@ -233,18 +240,23 @@ public class CreateFileActivity extends BaseActivity {
|
||||
|
||||
private void deleteFile(String repoOwner, String repoName, String fileName, String fileCommitMessage, String branchName, String fileSha) {
|
||||
|
||||
DeleteFile deleteFileJsonStr = branches.contains(branchName) ?
|
||||
new DeleteFile(branchName, fileCommitMessage, "", fileSha) :
|
||||
new DeleteFile("", fileCommitMessage, branchName, fileSha);
|
||||
DeleteFileOptions deleteFileJsonStr = new DeleteFileOptions();
|
||||
deleteFileJsonStr.setMessage(fileCommitMessage);
|
||||
deleteFileJsonStr.setSha(fileSha);
|
||||
if(branches.contains(branchName)) {
|
||||
deleteFileJsonStr.setBranch(branchName);
|
||||
} else {
|
||||
deleteFileJsonStr.setNewBranch(branchName);
|
||||
}
|
||||
|
||||
Call<JsonElement> call = RetrofitClient
|
||||
Call<FileDeleteResponse> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.deleteFile(getAccount().getAuthorization(), repoOwner, repoName, fileName, deleteFileJsonStr);
|
||||
.repoDeleteFileWithBody(repoOwner, repoName, fileName, deleteFileJsonStr);
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
call.enqueue(new Callback<FileDeleteResponse>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
|
||||
public void onResponse(@NonNull Call<FileDeleteResponse> call, @NonNull retrofit2.Response<FileDeleteResponse> response) {
|
||||
|
||||
switch(response.code()) {
|
||||
|
||||
@ -253,6 +265,7 @@ public class CreateFileActivity extends BaseActivity {
|
||||
Toasty.info(ctx, getString(R.string.deleteFileMessage, repository.getBranchRef()));
|
||||
Intent result = new Intent();
|
||||
result.putExtra("fileModified", true);
|
||||
result.putExtra("fileAction", fileAction);
|
||||
setResult(200, result);
|
||||
finish();
|
||||
break;
|
||||
@ -279,7 +292,7 @@ public class CreateFileActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<FileDeleteResponse> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
enableProcessButton();
|
||||
@ -290,18 +303,24 @@ public class CreateFileActivity extends BaseActivity {
|
||||
|
||||
private void editFile(String repoOwner, String repoName, String fileName, String fileContent, String fileCommitMessage, String branchName, String fileSha) {
|
||||
|
||||
EditFile editFileJsonStr = branches.contains(branchName) ?
|
||||
new EditFile(branchName, fileCommitMessage, "", fileSha, fileContent) :
|
||||
new EditFile("", fileCommitMessage, branchName, fileSha, fileContent);
|
||||
UpdateFileOptions editFileJsonStr = new UpdateFileOptions();
|
||||
editFileJsonStr.setContent(fileContent);
|
||||
editFileJsonStr.setMessage(fileCommitMessage);
|
||||
editFileJsonStr.setSha(fileSha);
|
||||
if(branches.contains(branchName)) {
|
||||
editFileJsonStr.setBranch(branchName);
|
||||
} else {
|
||||
editFileJsonStr.setNewBranch(branchName);
|
||||
}
|
||||
|
||||
Call<JsonElement> call = RetrofitClient
|
||||
Call<FileResponse> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.editFile(getAccount().getAuthorization(), repoOwner, repoName, fileName, editFileJsonStr);
|
||||
.repoUpdateFile(editFileJsonStr, repoOwner, repoName, fileName);
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
call.enqueue(new Callback<FileResponse>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
|
||||
public void onResponse(@NonNull Call<FileResponse> call, @NonNull retrofit2.Response<FileResponse> response) {
|
||||
|
||||
switch(response.code()) {
|
||||
|
||||
@ -310,6 +329,7 @@ public class CreateFileActivity extends BaseActivity {
|
||||
Toasty.info(ctx, getString(R.string.editFileMessage, branchName));
|
||||
Intent result = new Intent();
|
||||
result.putExtra("fileModified", true);
|
||||
result.putExtra("fileAction", fileAction);
|
||||
setResult(200, result);
|
||||
finish();
|
||||
break;
|
||||
@ -336,7 +356,7 @@ public class CreateFileActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<FileResponse> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
enableProcessButton();
|
||||
@ -348,19 +368,19 @@ public class CreateFileActivity extends BaseActivity {
|
||||
|
||||
private void getBranches(String repoOwner, String repoName) {
|
||||
|
||||
Call<List<Branches>> call = RetrofitClient
|
||||
Call<List<Branch>> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.getBranches(getAccount().getAuthorization(), repoOwner, repoName);
|
||||
.repoListBranches(repoOwner, repoName, null, null);
|
||||
|
||||
call.enqueue(new Callback<List<Branches>>() {
|
||||
call.enqueue(new Callback<List<Branch>>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Branches>> call, @NonNull retrofit2.Response<List<Branches>> response) {
|
||||
public void onResponse(@NonNull Call<List<Branch>> call, @NonNull retrofit2.Response<List<Branch>> response) {
|
||||
|
||||
if(response.code() == 200) {
|
||||
|
||||
assert response.body() != null;
|
||||
for(Branches branch : response.body()) branches.add(branch.getName());
|
||||
for(Branch branch : response.body()) branches.add(branch.getName());
|
||||
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<>(CreateFileActivity.this, R.layout.list_spinner_items, branches);
|
||||
|
||||
@ -373,7 +393,7 @@ public class CreateFileActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Branches>> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<List<Branch>> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
}
|
||||
|
@ -12,12 +12,13 @@ import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import com.google.gson.JsonElement;
|
||||
import org.gitnex.tea4j.models.Collaborators;
|
||||
import org.gitnex.tea4j.models.CreateIssue;
|
||||
import org.gitnex.tea4j.models.Labels;
|
||||
import org.gitnex.tea4j.models.Milestones;
|
||||
import org.gitnex.tea4j.v2.models.CreateIssueOption;
|
||||
import org.gitnex.tea4j.v2.models.Issue;
|
||||
import org.gitnex.tea4j.v2.models.Label;
|
||||
import org.gitnex.tea4j.v2.models.Milestone;
|
||||
import org.gitnex.tea4j.v2.models.User;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.actions.AssigneesActions;
|
||||
import org.mian.gitnex.actions.LabelsActions;
|
||||
@ -35,13 +36,15 @@ import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class CreateIssueActivity extends BaseActivity implements View.OnClickListener, LabelsListAdapter.LabelsListAdapterListener, AssigneesListAdapter.AssigneesListAdapterListener {
|
||||
@ -56,6 +59,7 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
||||
private String labelsSetter;
|
||||
private String assigneesSetter;
|
||||
private int milestoneId;
|
||||
private Date currentDate = null;
|
||||
|
||||
private RepositoryContext repository;
|
||||
|
||||
@ -63,9 +67,9 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
||||
private AssigneesListAdapter assigneesAdapter;
|
||||
|
||||
private List<Integer> labelsIds = new ArrayList<>();
|
||||
private List<Labels> labelsList = new ArrayList<>();
|
||||
private List<Milestones> milestonesList = new ArrayList<>();
|
||||
private List<Collaborators> assigneesList = new ArrayList<>();
|
||||
private final List<Label> labelsList = new ArrayList<>();
|
||||
private final LinkedHashMap<String, Milestone> milestonesList = new LinkedHashMap<>();
|
||||
private final List<User> assigneesList = new ArrayList<>();
|
||||
private List<String> assigneesListData = new ArrayList<>();
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
@ -131,7 +135,7 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
||||
viewBinding.createNewIssueButton.setOnClickListener(this);
|
||||
}
|
||||
|
||||
if(!repository.getPermissions().canPush()) {
|
||||
if(!repository.getPermissions().isPush()) {
|
||||
viewBinding.newIssueAssigneesListLayout.setVisibility(View.GONE);
|
||||
viewBinding.newIssueMilestoneSpinnerLayout.setVisibility(View.GONE);
|
||||
viewBinding.newIssueLabelsLayout.setVisibility(View.GONE);
|
||||
@ -221,33 +225,33 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
||||
return;
|
||||
}
|
||||
|
||||
if (newIssueDueDateForm.equals("")) {
|
||||
|
||||
newIssueDueDateForm = null;
|
||||
}
|
||||
else {
|
||||
|
||||
newIssueDueDateForm = (AppUtil.customDateCombine(AppUtil.customDateFormat(newIssueDueDateForm)));
|
||||
}
|
||||
|
||||
disableProcessButton();
|
||||
createNewIssueFunc(repository.getOwner(), repository.getName(), getAccount().getAccount().getUserName(), newIssueDescriptionForm, newIssueDueDateForm, milestoneId, newIssueTitleForm);
|
||||
createNewIssueFunc(repository.getOwner(), repository.getName(), newIssueDescriptionForm, milestoneId, newIssueTitleForm);
|
||||
}
|
||||
|
||||
private void createNewIssueFunc(String repoOwner, String repoName, String loginUid, String newIssueDescriptionForm, String newIssueDueDateForm, int newIssueMilestoneIdForm, String newIssueTitleForm) {
|
||||
private void createNewIssueFunc(String repoOwner, String repoName, String newIssueDescriptionForm, int newIssueMilestoneIdForm, String newIssueTitleForm) {
|
||||
|
||||
CreateIssue createNewIssueJson = new CreateIssue(loginUid, newIssueDescriptionForm, false, newIssueDueDateForm, newIssueMilestoneIdForm, newIssueTitleForm, assigneesListData, labelsIds);
|
||||
ArrayList<Long> labelIds = new ArrayList<>();
|
||||
for(Integer i : labelsIds) {
|
||||
labelIds.add((long) i);
|
||||
}
|
||||
|
||||
Call<JsonElement> call3;
|
||||
CreateIssueOption createNewIssueJson = new CreateIssueOption();
|
||||
createNewIssueJson.setBody(newIssueDescriptionForm);
|
||||
createNewIssueJson.setMilestone((long) newIssueMilestoneIdForm);
|
||||
createNewIssueJson.setDueDate(currentDate);
|
||||
createNewIssueJson.setTitle(newIssueTitleForm);
|
||||
createNewIssueJson.setAssignees(assigneesListData);
|
||||
createNewIssueJson.setLabels(labelIds);
|
||||
|
||||
call3 = RetrofitClient
|
||||
Call<Issue> call3 = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.createNewIssue(getAccount().getAuthorization(), repoOwner, repoName, createNewIssueJson);
|
||||
.issueCreateIssue(repoOwner, repoName, createNewIssueJson);
|
||||
|
||||
call3.enqueue(new Callback<JsonElement>() {
|
||||
call3.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response2) {
|
||||
public void onResponse(@NonNull Call<Issue> call, @NonNull retrofit2.Response<Issue> response2) {
|
||||
|
||||
if(response2.code() == 201) {
|
||||
|
||||
@ -255,15 +259,15 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
||||
|
||||
Toasty.success(ctx, getString(R.string.issueCreated));
|
||||
enableProcessButton();
|
||||
RepoDetailActivity.updateRepo = true;
|
||||
MainActivity.repoCreated = true;
|
||||
finish();
|
||||
}
|
||||
else if(response2.code() == 401) {
|
||||
|
||||
enableProcessButton();
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle),
|
||||
getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||
getResources().getString(R.string.cancelButton),
|
||||
getResources().getString(R.string.navLogout));
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle), getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||
getResources().getString(R.string.cancelButton), getResources().getString(R.string.navLogout));
|
||||
}
|
||||
else {
|
||||
|
||||
@ -274,13 +278,12 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<Issue> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.genericServerResponseError));
|
||||
enableProcessButton();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void initCloseListener() {
|
||||
@ -291,49 +294,51 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
||||
private void getMilestones(String repoOwner, String repoName, int resultLimit) {
|
||||
|
||||
String msState = "open";
|
||||
Call<List<Milestones>> call = RetrofitClient
|
||||
Call<List<Milestone>> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.getMilestones(getAccount().getAuthorization(), repoOwner, repoName, 1, resultLimit, msState);
|
||||
.issueGetMilestonesList(repoOwner, repoName, msState, null, 1, resultLimit);
|
||||
|
||||
call.enqueue(new Callback<List<Milestones>>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Milestones>> call, @NonNull retrofit2.Response<List<Milestones>> response) {
|
||||
public void onResponse(@NonNull Call<List<Milestone>> call, @NonNull retrofit2.Response<List<Milestone>> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
|
||||
if(response.code() == 200) {
|
||||
|
||||
List<Milestones> milestonesList_ = response.body();
|
||||
List<Milestone> milestonesList_ = response.body();
|
||||
|
||||
milestonesList.add(new Milestones(0,getString(R.string.issueCreatedNoMilestone)));
|
||||
Milestone ms = new Milestone();
|
||||
ms.setId(0L);
|
||||
ms.setTitle(getString(R.string.issueCreatedNoMilestone));
|
||||
milestonesList.put(ms.getTitle(), ms);
|
||||
assert milestonesList_ != null;
|
||||
|
||||
if(milestonesList_.size() > 0) {
|
||||
|
||||
for (int i = 0; i < milestonesList_.size(); i++) {
|
||||
for(Milestone milestone : milestonesList_) {
|
||||
|
||||
//Don't translate "open" is a enum
|
||||
if(milestonesList_.get(i).getState().equals("open")) {
|
||||
Milestones data = new Milestones(
|
||||
milestonesList_.get(i).getId(),
|
||||
milestonesList_.get(i).getTitle()
|
||||
);
|
||||
milestonesList.add(data);
|
||||
if(milestone.getState().equals("open")) {
|
||||
milestonesList.put(milestone.getTitle(), milestone);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ArrayAdapter<Milestones> adapter = new ArrayAdapter<>(CreateIssueActivity.this,
|
||||
R.layout.list_spinner_items, milestonesList);
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<>(CreateIssueActivity.this, R.layout.list_spinner_items, new ArrayList<>(milestonesList.keySet()));
|
||||
|
||||
viewBinding.newIssueMilestoneSpinner.setAdapter(adapter);
|
||||
enableProcessButton();
|
||||
|
||||
viewBinding.newIssueMilestoneSpinner.setOnItemClickListener ((parent, view, position, id) ->
|
||||
|
||||
milestoneId = milestonesList.get(position).getId()
|
||||
);
|
||||
viewBinding.newIssueMilestoneSpinner.setOnItemClickListener((parent, view, position, id) -> {
|
||||
if(position == 0) {
|
||||
milestoneId = 0;
|
||||
}
|
||||
else if(view instanceof TextView) {
|
||||
milestoneId = Math.toIntExact(Objects.requireNonNull(milestonesList.get(((TextView) view).getText().toString())).getId());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
@ -341,12 +346,11 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Milestones>> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<List<Milestone>> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -360,7 +364,10 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
||||
final int mDay = c.get(Calendar.DAY_OF_MONTH);
|
||||
|
||||
DatePickerDialog datePickerDialog = new DatePickerDialog(this,
|
||||
(view, year, monthOfYear, dayOfMonth) -> viewBinding.newIssueDueDate.setText(getString(R.string.setDueDate, year, (monthOfYear + 1), dayOfMonth)), mYear, mMonth, mDay);
|
||||
(view, year, monthOfYear, dayOfMonth) -> {
|
||||
viewBinding.newIssueDueDate.setText(getString(R.string.setDueDate, year, (monthOfYear + 1), dayOfMonth));
|
||||
currentDate = new Date(year - 1900, monthOfYear, dayOfMonth);
|
||||
}, mYear, mMonth, mDay);
|
||||
datePickerDialog.show();
|
||||
}
|
||||
else if(v == viewBinding.createNewIssueButton) {
|
||||
|
@ -13,8 +13,9 @@ import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import com.pes.androidmaterialcolorpickerdialog.ColorPicker;
|
||||
import org.gitnex.tea4j.models.CreateLabel;
|
||||
import org.gitnex.tea4j.models.Labels;
|
||||
import org.gitnex.tea4j.v2.models.CreateLabelOption;
|
||||
import org.gitnex.tea4j.v2.models.EditLabelOption;
|
||||
import org.gitnex.tea4j.v2.models.Label;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.ActivityCreateLabelBinding;
|
||||
@ -154,7 +155,7 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
disableProcessButton();
|
||||
patchLabel(repository.getOwner(), repository.getName(), updateLabelName, updateLabelColor, Integer.parseInt(
|
||||
patchLabel(repository, updateLabelName, updateLabelColor, Integer.parseInt(
|
||||
Objects.requireNonNull(getIntent().getStringExtra("labelId"))));
|
||||
|
||||
}
|
||||
@ -194,28 +195,32 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
disableProcessButton();
|
||||
createNewLabel(repository.getOwner(), repository.getName(), newLabelName, newLabelColor);
|
||||
createNewLabel(newLabelName, newLabelColor);
|
||||
}
|
||||
|
||||
private void createNewLabel(String repoOwner, String repoName, String newLabelName, String newLabelColor) {
|
||||
private void createNewLabel(String newLabelName, String newLabelColor) {
|
||||
|
||||
CreateLabel createLabelFunc = new CreateLabel(newLabelName, newLabelColor);
|
||||
CreateLabelOption createLabelFunc = new CreateLabelOption();
|
||||
createLabelFunc.setColor(newLabelColor);
|
||||
createLabelFunc.setName(newLabelName);
|
||||
|
||||
Call<CreateLabel> call;
|
||||
Call<Label> call;
|
||||
|
||||
if(getIntent().getStringExtra("type") != null && Objects.requireNonNull(getIntent().getStringExtra("type")).equals("org")) {
|
||||
|
||||
call = RetrofitClient.getApiInterface(ctx).createOrganizationLabel(getAccount().getAuthorization(), getIntent().getStringExtra("orgName"), createLabelFunc);
|
||||
call = RetrofitClient.getApiInterface(ctx).orgCreateLabel(getIntent().getStringExtra("orgName"), createLabelFunc);
|
||||
}
|
||||
else {
|
||||
else if(repository != null) {
|
||||
|
||||
call = RetrofitClient.getApiInterface(ctx).createLabel(getAccount().getAuthorization(), repoOwner, repoName, createLabelFunc);
|
||||
call = RetrofitClient.getApiInterface(ctx).issueCreateLabel(repository.getOwner(), repository.getName(), createLabelFunc);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
call.enqueue(new Callback<CreateLabel>() {
|
||||
call.enqueue(new Callback<Label>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<CreateLabel> call, @NonNull retrofit2.Response<CreateLabel> response) {
|
||||
public void onResponse(@NonNull Call<Label> call, @NonNull retrofit2.Response<Label> response) {
|
||||
|
||||
if(response.code() == 201) {
|
||||
|
||||
@ -240,7 +245,7 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<CreateLabel> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<Label> call, @NonNull Throwable t) {
|
||||
|
||||
labelColor = "";
|
||||
Log.e("onFailure", t.toString());
|
||||
@ -250,25 +255,27 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
|
||||
}
|
||||
|
||||
private void patchLabel(String repoOwner, String repoName, String updateLabelName, String updateLabelColor, int labelId) {
|
||||
private void patchLabel(RepositoryContext repository, String updateLabelName, String updateLabelColor, int labelId) {
|
||||
|
||||
CreateLabel createLabelFunc = new CreateLabel(updateLabelName, updateLabelColor);
|
||||
EditLabelOption createLabelFunc = new EditLabelOption();
|
||||
createLabelFunc.setColor(updateLabelColor);
|
||||
createLabelFunc.setName(updateLabelName);
|
||||
|
||||
Call<CreateLabel> call;
|
||||
Call<Label> call;
|
||||
|
||||
if(getIntent().getStringExtra("type") != null && Objects.requireNonNull(getIntent().getStringExtra("type")).equals("org")) {
|
||||
|
||||
call = RetrofitClient.getApiInterface(ctx).patchOrganizationLabel(getAccount().getAuthorization(), getIntent().getStringExtra("orgName"), labelId, createLabelFunc);
|
||||
call = RetrofitClient.getApiInterface(ctx).orgEditLabel(getIntent().getStringExtra("orgName"), (long) labelId, createLabelFunc);
|
||||
}
|
||||
else {
|
||||
|
||||
call = RetrofitClient.getApiInterface(ctx).patchLabel(getAccount().getAuthorization(), repoOwner, repoName, labelId, createLabelFunc);
|
||||
call = RetrofitClient.getApiInterface(ctx).issueEditLabel(repository.getOwner(), repository.getName(), (long) labelId, createLabelFunc);
|
||||
}
|
||||
|
||||
call.enqueue(new Callback<CreateLabel>() {
|
||||
call.enqueue(new Callback<Label>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<CreateLabel> call, @NonNull retrofit2.Response<CreateLabel> response) {
|
||||
public void onResponse(@NonNull Call<Label> call, @NonNull retrofit2.Response<Label> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
|
||||
@ -297,7 +304,7 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<CreateLabel> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<Label> call, @NonNull Throwable t) {
|
||||
|
||||
labelColor = "";
|
||||
labelColorDefault = "";
|
||||
@ -315,21 +322,21 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
|
||||
private void deleteLabel(int labelId) {
|
||||
|
||||
Call<Labels> call;
|
||||
Call<Void> call;
|
||||
|
||||
if(getIntent().getStringExtra("type") != null && Objects.requireNonNull(getIntent().getStringExtra("type")).equals("org")) {
|
||||
|
||||
call = RetrofitClient.getApiInterface(ctx).deleteOrganizationLabel(getAccount().getAuthorization(), getIntent().getStringExtra("orgName"), labelId);
|
||||
call = RetrofitClient.getApiInterface(ctx).orgDeleteLabel(getIntent().getStringExtra("orgName"), (long) labelId);
|
||||
}
|
||||
else {
|
||||
|
||||
call = RetrofitClient.getApiInterface(ctx).deleteLabel(getAccount().getAuthorization(), repository.getOwner(), repository.getName(), labelId);
|
||||
call = RetrofitClient.getApiInterface(ctx).issueDeleteLabel(repository.getOwner(), repository.getName(), (long) labelId);
|
||||
}
|
||||
|
||||
call.enqueue(new Callback<Labels>() {
|
||||
call.enqueue(new Callback<Void>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Labels> call, @NonNull retrofit2.Response<Labels> response) {
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
|
||||
@ -338,11 +345,11 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
Toasty.success(ctx, getString(R.string.labelDeleteText));
|
||||
if(getIntent().getStringExtra("type") != null && Objects.requireNonNull(getIntent().getStringExtra("type")).equals("org")) {
|
||||
|
||||
OrganizationLabelsViewModel.loadOrgLabelsList(getAccount().getAuthorization(), getIntent().getStringExtra("orgName"), ctx, null, null);
|
||||
OrganizationLabelsViewModel.loadOrgLabelsList(getIntent().getStringExtra("orgName"), ctx, null, null);
|
||||
}
|
||||
else {
|
||||
|
||||
LabelsViewModel.loadLabelsList(getAccount().getAuthorization(), repository.getOwner(), repository.getName(), ctx);
|
||||
LabelsViewModel.loadLabelsList(repository.getOwner(), repository.getName(), ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -360,7 +367,7 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Labels> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
Log.e("onFailure", t.toString());
|
||||
}
|
||||
});
|
||||
|
@ -13,7 +13,8 @@ import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import androidx.annotation.NonNull;
|
||||
import org.gitnex.tea4j.models.Milestones;
|
||||
import org.gitnex.tea4j.v2.models.CreateMilestoneOption;
|
||||
import org.gitnex.tea4j.v2.models.Milestone;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.ActivityCreateMilestoneBinding;
|
||||
@ -22,6 +23,7 @@ import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
@ -38,6 +40,8 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
||||
private Button createNewMilestoneButton;
|
||||
private RepositoryContext repository;
|
||||
|
||||
private Date currentDate = null;
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
@ -96,7 +100,6 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
||||
|
||||
String newMilestoneTitle = milestoneTitle.getText().toString();
|
||||
String newMilestoneDescription = milestoneDescription.getText().toString();
|
||||
String newMilestoneDueDate = milestoneDueDate.getText().toString();
|
||||
|
||||
if(!connToInternet) {
|
||||
|
||||
@ -119,37 +122,27 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
||||
}
|
||||
}
|
||||
|
||||
String finalMilestoneDueDate = null;
|
||||
|
||||
if(!newMilestoneDueDate.isEmpty()) {
|
||||
|
||||
finalMilestoneDueDate = (AppUtil.customDateCombine(AppUtil.customDateFormat(newMilestoneDueDate)));
|
||||
}
|
||||
else if (!getAccount().requiresVersion("1.10.0")) {
|
||||
|
||||
// if Gitea version is less than 1.10.0 DueDate is required
|
||||
Toasty.warning(ctx, getString(R.string.milestoneDateEmpty));
|
||||
return;
|
||||
}
|
||||
|
||||
disableProcessButton();
|
||||
createNewMilestone(getAccount().getAuthorization(), repository.getOwner(), repository.getName(), newMilestoneTitle, newMilestoneDescription, finalMilestoneDueDate);
|
||||
createNewMilestone(repository.getOwner(), repository.getName(), newMilestoneTitle, newMilestoneDescription);
|
||||
}
|
||||
|
||||
private void createNewMilestone(final String token, String repoOwner, String repoName, String newMilestoneTitle, String newMilestoneDescription, String newMilestoneDueDate) {
|
||||
private void createNewMilestone(String repoOwner, String repoName, String newMilestoneTitle, String newMilestoneDescription) {
|
||||
|
||||
Milestones createMilestone = new Milestones(newMilestoneDescription, newMilestoneTitle, newMilestoneDueDate);
|
||||
CreateMilestoneOption createMilestone = new CreateMilestoneOption();
|
||||
createMilestone.setDescription(newMilestoneDescription);
|
||||
createMilestone.setTitle(newMilestoneTitle);
|
||||
createMilestone.setDueOn(currentDate);
|
||||
|
||||
Call<Milestones> call;
|
||||
Call<Milestone> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.createMilestone(token, repoOwner, repoName, createMilestone);
|
||||
.issueCreateMilestone(repoOwner, repoName, createMilestone);
|
||||
|
||||
call.enqueue(new Callback<Milestones>() {
|
||||
call.enqueue(new Callback<Milestone>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Milestones> call, @NonNull retrofit2.Response<Milestones> response) {
|
||||
public void onResponse(@NonNull Call<Milestone> call, @NonNull retrofit2.Response<Milestone> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
|
||||
@ -179,7 +172,7 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Milestones> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<Milestone> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
enableProcessButton();
|
||||
@ -199,7 +192,10 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
||||
final int mDay = c.get(Calendar.DAY_OF_MONTH);
|
||||
|
||||
DatePickerDialog datePickerDialog = new DatePickerDialog(this,
|
||||
(view, year, monthOfYear, dayOfMonth) -> milestoneDueDate.setText(getString(R.string.setDueDate, year, (monthOfYear + 1), dayOfMonth)), mYear, mMonth, mDay);
|
||||
(view, year, monthOfYear, dayOfMonth) -> {
|
||||
milestoneDueDate.setText(getString(R.string.setDueDate, year, (monthOfYear + 1), dayOfMonth));
|
||||
currentDate = new Date(year - 1900, monthOfYear, dayOfMonth);
|
||||
}, mYear, mMonth, mDay);
|
||||
datePickerDialog.show();
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,8 @@ import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import androidx.annotation.NonNull;
|
||||
import org.gitnex.tea4j.models.UserInfo;
|
||||
import org.gitnex.tea4j.v2.models.CreateUserOption;
|
||||
import org.gitnex.tea4j.v2.models.User;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.ActivityCreateNewUserBinding;
|
||||
@ -109,23 +110,26 @@ public class CreateNewUserActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
disableProcessButton();
|
||||
createNewUser(getAccount().getAuthorization(), newFullName, newUserName, newUserEmail, newUserPassword);
|
||||
createNewUser(newFullName, newUserName, newUserEmail, newUserPassword);
|
||||
}
|
||||
|
||||
private void createNewUser(final String instanceToken, String newFullName, String newUserName, String newUserEmail, String newUserPassword) {
|
||||
private void createNewUser(String newFullName, String newUserName, String newUserEmail, String newUserPassword) {
|
||||
|
||||
UserInfo createUser = new UserInfo(newUserEmail, newFullName, newUserName, newUserPassword, newUserName, 0, true);
|
||||
CreateUserOption createUser = new CreateUserOption();
|
||||
createUser.setEmail(newUserEmail);
|
||||
createUser.setFullName(newFullName);
|
||||
createUser.setUsername(newUserName);
|
||||
createUser.setPassword(newUserPassword);
|
||||
createUser.setMustChangePassword(true);
|
||||
|
||||
Call<UserInfo> call;
|
||||
|
||||
call = RetrofitClient
|
||||
Call<User> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.createNewUser(instanceToken, createUser);
|
||||
.adminCreateUser(createUser);
|
||||
|
||||
call.enqueue(new Callback<UserInfo>() {
|
||||
call.enqueue(new Callback<User>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<UserInfo> call, @NonNull retrofit2.Response<UserInfo> response) {
|
||||
public void onResponse(@NonNull Call<User> call, @NonNull retrofit2.Response<User> response) {
|
||||
|
||||
if(response.code() == 201) {
|
||||
|
||||
@ -164,7 +168,7 @@ public class CreateNewUserActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<UserInfo> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<User> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
enableProcessButton();
|
||||
|
@ -11,7 +11,8 @@ import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import androidx.annotation.NonNull;
|
||||
import org.gitnex.tea4j.models.UserOrganizations;
|
||||
import org.gitnex.tea4j.v2.models.CreateOrgOption;
|
||||
import org.gitnex.tea4j.v2.models.Organization;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.ActivityCreateOrganizationBinding;
|
||||
@ -123,23 +124,25 @@ public class CreateOrganizationActivity extends BaseActivity {
|
||||
else {
|
||||
|
||||
disableProcessButton();
|
||||
createNewOrganization(getAccount().getAuthorization(), newOrgName, newOrgDesc);
|
||||
createNewOrganization(newOrgName, newOrgDesc);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void createNewOrganization(final String token, String orgName, String orgDesc) {
|
||||
private void createNewOrganization(String orgName, String orgDesc) {
|
||||
|
||||
UserOrganizations createOrganization = new UserOrganizations(orgName, null, orgDesc, null, null);
|
||||
CreateOrgOption createOrganization = new CreateOrgOption();
|
||||
createOrganization.setDescription(orgDesc);
|
||||
createOrganization.setUsername(orgName);
|
||||
|
||||
Call<UserOrganizations> call = RetrofitClient
|
||||
Call<Organization> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.createNewOrganization(token, createOrganization);
|
||||
.orgCreate(createOrganization);
|
||||
|
||||
call.enqueue(new Callback<UserOrganizations>() {
|
||||
call.enqueue(new Callback<Organization>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<UserOrganizations> call, @NonNull retrofit2.Response<UserOrganizations> response) {
|
||||
public void onResponse(@NonNull Call<Organization> call, @NonNull retrofit2.Response<Organization> response) {
|
||||
|
||||
if(response.code() == 201) {
|
||||
OrganizationsFragment.orgCreated = true;
|
||||
@ -181,7 +184,7 @@ public class CreateOrganizationActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<UserOrganizations> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<Organization> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
enableProcessButton();
|
||||
|
@ -11,24 +11,29 @@ import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import org.gitnex.tea4j.models.Branches;
|
||||
import org.gitnex.tea4j.models.CreatePullRequest;
|
||||
import org.gitnex.tea4j.models.Labels;
|
||||
import org.gitnex.tea4j.models.Milestones;
|
||||
import org.gitnex.tea4j.v2.models.Branch;
|
||||
import org.gitnex.tea4j.v2.models.CreatePullRequestOption;
|
||||
import org.gitnex.tea4j.v2.models.Label;
|
||||
import org.gitnex.tea4j.v2.models.Milestone;
|
||||
import org.gitnex.tea4j.v2.models.PullRequest;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.actions.LabelsActions;
|
||||
import org.mian.gitnex.adapters.LabelsListAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.ActivityCreatePrBinding;
|
||||
import org.mian.gitnex.databinding.CustomLabelsSelectionDialogBinding;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.fragments.PullRequestsFragment;
|
||||
import org.mian.gitnex.helpers.Constants;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
@ -45,14 +50,15 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
||||
private List<Integer> labelsIds = new ArrayList<>();
|
||||
private final List<String> assignees = new ArrayList<>();
|
||||
private int milestoneId;
|
||||
private Date currentDate = null;
|
||||
|
||||
private RepositoryContext repository;
|
||||
|
||||
private LabelsListAdapter labelsAdapter;
|
||||
|
||||
List<Milestones> milestonesList = new ArrayList<>();
|
||||
List<Branches> branchesList = new ArrayList<>();
|
||||
List<Labels> labelsList = new ArrayList<>();
|
||||
LinkedHashMap<String, Milestone> milestonesList = new LinkedHashMap<>();
|
||||
List<String> branchesList = new ArrayList<>();
|
||||
List<Label> labelsList = new ArrayList<>();
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
@Override
|
||||
@ -102,9 +108,10 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
||||
|
||||
viewBinding.createPr.setOnClickListener(createPr -> processPullRequest());
|
||||
|
||||
if(!repository.getPermissions().canPush()) {
|
||||
if(!repository.getPermissions().isPush()) {
|
||||
viewBinding.prDueDateLayout.setVisibility(View.GONE);
|
||||
viewBinding.prLabelsLayout.setVisibility(View.GONE);
|
||||
viewBinding.milestonesSpinnerLayout.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -114,7 +121,6 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
||||
String prDescription = String.valueOf(viewBinding.prBody.getText());
|
||||
String mergeInto = viewBinding.mergeIntoBranchSpinner.getText().toString();
|
||||
String pullFrom = viewBinding.pullFromBranchSpinner.getText().toString();
|
||||
String dueDate = String.valueOf(viewBinding.prDueDate.getText());
|
||||
|
||||
assignees.add("");
|
||||
|
||||
@ -123,15 +129,6 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
||||
labelsIds.add(0);
|
||||
}
|
||||
|
||||
if (dueDate.matches("")) {
|
||||
|
||||
dueDate = null;
|
||||
}
|
||||
else {
|
||||
|
||||
dueDate = AppUtil.customDateCombine(AppUtil.customDateFormat(dueDate));
|
||||
}
|
||||
|
||||
if(prTitle.matches("")) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.titleError));
|
||||
@ -150,31 +147,47 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
||||
}
|
||||
else {
|
||||
|
||||
createPullRequest(prTitle, prDescription, mergeInto, pullFrom, milestoneId, dueDate, assignees);
|
||||
createPullRequest(prTitle, prDescription, mergeInto, pullFrom, milestoneId, assignees);
|
||||
}
|
||||
}
|
||||
|
||||
private void createPullRequest(String prTitle, String prDescription, String mergeInto, String pullFrom, int milestoneId, String dueDate, List<String> assignees) {
|
||||
private void createPullRequest(String prTitle, String prDescription, String mergeInto, String pullFrom, int milestoneId, List<String> assignees) {
|
||||
|
||||
CreatePullRequest createPullRequest = new CreatePullRequest(prTitle, prDescription, getAccount().getAccount().getUserName(), mergeInto, pullFrom, milestoneId, dueDate, assignees, labelsIds);
|
||||
ArrayList<Long> labelIds = new ArrayList<>();
|
||||
for(Integer i : labelsIds) {
|
||||
labelIds.add((long) i);
|
||||
}
|
||||
|
||||
Call<Void> transferCall = RetrofitClient
|
||||
CreatePullRequestOption createPullRequest = new CreatePullRequestOption();
|
||||
createPullRequest.setTitle(prTitle);
|
||||
createPullRequest.setMilestone((long) milestoneId);
|
||||
createPullRequest.setAssignees(assignees);
|
||||
createPullRequest.setBody(prDescription);
|
||||
createPullRequest.setBase(mergeInto);
|
||||
createPullRequest.setHead(pullFrom);
|
||||
createPullRequest.setLabels(labelIds);
|
||||
createPullRequest.setDueDate(currentDate);
|
||||
|
||||
Call<PullRequest> transferCall = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.createPullRequest(getAccount().getAuthorization(), repository.getOwner(), repository.getName(), createPullRequest);
|
||||
.repoCreatePullRequest(repository.getOwner(), repository.getName(), createPullRequest);
|
||||
|
||||
transferCall.enqueue(new Callback<Void>() {
|
||||
transferCall.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
public void onResponse(@NonNull Call<PullRequest> call, @NonNull retrofit2.Response<PullRequest> response) {
|
||||
|
||||
disableProcessButton();
|
||||
|
||||
if(response.code() == 201) {
|
||||
|
||||
Toasty.success(ctx, getString(R.string.prCreateSuccess));
|
||||
RepoDetailActivity.updateRepo = true;
|
||||
PullRequestsFragment.resumePullRequests = true;
|
||||
MainActivity.repoCreated = true;
|
||||
finish();
|
||||
}
|
||||
else if (response.code() == 409 && response.message().equals("Conflict")) {
|
||||
else if(response.code() == 409 || response.message().equals("Conflict")) {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, getString(R.string.prAlreadyExists));
|
||||
@ -192,7 +205,7 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<PullRequest> call, @NonNull Throwable t) {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, getString(R.string.genericServerResponseError));
|
||||
@ -236,32 +249,27 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
||||
|
||||
private void getBranches(String repoOwner, String repoName) {
|
||||
|
||||
Call<List<Branches>> call = RetrofitClient
|
||||
Call<List<Branch>> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.getBranches(getAccount().getAuthorization(), repoOwner, repoName);
|
||||
.repoListBranches(repoOwner, repoName, null, null);
|
||||
|
||||
call.enqueue(new Callback<List<Branches>>() {
|
||||
call.enqueue(new Callback<List<Branch>>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Branches>> call, @NonNull retrofit2.Response<List<Branches>> response) {
|
||||
public void onResponse(@NonNull Call<List<Branch>> call, @NonNull retrofit2.Response<List<Branch>> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
|
||||
if(response.code() == 200) {
|
||||
|
||||
List<Branches> branchesList_ = response.body();
|
||||
List<Branch> branchesList_ = response.body();
|
||||
assert branchesList_ != null;
|
||||
|
||||
if(branchesList_.size() > 0) {
|
||||
|
||||
for (int i = 0; i < branchesList_.size(); i++) {
|
||||
|
||||
Branches data = new Branches(branchesList_.get(i).getName());
|
||||
branchesList.add(data);
|
||||
}
|
||||
for(Branch i : branchesList_) {
|
||||
branchesList.add(i.getName());
|
||||
}
|
||||
|
||||
ArrayAdapter<Branches> adapter = new ArrayAdapter<>(CreatePullRequestActivity.this,
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<>(CreatePullRequestActivity.this,
|
||||
R.layout.list_spinner_items, branchesList);
|
||||
|
||||
viewBinding.mergeIntoBranchSpinner.setAdapter(adapter);
|
||||
@ -274,69 +282,66 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Branches>> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<List<Branch>> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void getMilestones(String repoOwner, String repoName, int resultLimit) {
|
||||
|
||||
String msState = "open";
|
||||
Call<List<Milestones>> call = RetrofitClient
|
||||
Call<List<Milestone>> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.getMilestones(getAccount().getAuthorization(), repoOwner, repoName, 1, resultLimit, msState);
|
||||
.issueGetMilestonesList(repoOwner, repoName, msState, null, 1, resultLimit);
|
||||
|
||||
call.enqueue(new Callback<List<Milestones>>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Milestones>> call, @NonNull retrofit2.Response<List<Milestones>> response) {
|
||||
public void onResponse(@NonNull Call<List<Milestone>> call, @NonNull retrofit2.Response<List<Milestone>> response) {
|
||||
|
||||
if(response.code() == 200) {
|
||||
|
||||
List<Milestones> milestonesList_ = response.body();
|
||||
List<Milestone> milestonesList_ = response.body();
|
||||
|
||||
milestonesList.add(new Milestones(0,getString(R.string.issueCreatedNoMilestone)));
|
||||
milestonesList.put(getString(R.string.issueCreatedNoMilestone), new Milestone().id(0L).title(getString(R.string.issueCreatedNoMilestone)));
|
||||
assert milestonesList_ != null;
|
||||
|
||||
if(milestonesList_.size() > 0) {
|
||||
|
||||
for (int i = 0; i < milestonesList_.size(); i++) {
|
||||
for(Milestone milestone : milestonesList_) {
|
||||
|
||||
//Don't translate "open" is a enum
|
||||
if(milestonesList_.get(i).getState().equals("open")) {
|
||||
Milestones data = new Milestones(
|
||||
milestonesList_.get(i).getId(),
|
||||
milestonesList_.get(i).getTitle()
|
||||
);
|
||||
milestonesList.add(data);
|
||||
if(milestone.getState().equals("open")) {
|
||||
milestonesList.put(milestone.getTitle(), milestone);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ArrayAdapter<Milestones> adapter = new ArrayAdapter<>(CreatePullRequestActivity.this,
|
||||
R.layout.list_spinner_items, milestonesList);
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<>(CreatePullRequestActivity.this, R.layout.list_spinner_items, new ArrayList<>(milestonesList.keySet()));
|
||||
|
||||
viewBinding.milestonesSpinner.setAdapter(adapter);
|
||||
enableProcessButton();
|
||||
|
||||
viewBinding.milestonesSpinner.setOnItemClickListener ((parent, view, position, id) ->
|
||||
|
||||
milestoneId = milestonesList.get(position).getId()
|
||||
);
|
||||
viewBinding.milestonesSpinner.setOnItemClickListener((parent, view, position, id) -> {
|
||||
if(position == 0) {
|
||||
milestoneId = 0;
|
||||
}
|
||||
else if(view instanceof TextView) {
|
||||
milestoneId = Math.toIntExact(Objects.requireNonNull(milestonesList.get(((TextView) view).getText().toString())).getId());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Milestones>> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<List<Milestone>> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void setDueDate() {
|
||||
@ -347,7 +352,10 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
||||
final int mDay = c.get(Calendar.DAY_OF_MONTH);
|
||||
|
||||
DatePickerDialog datePickerDialog = new DatePickerDialog(this,
|
||||
(view, year, monthOfYear, dayOfMonth) -> viewBinding.prDueDate.setText(getString(R.string.setDueDate, year, (monthOfYear + 1), dayOfMonth)), mYear, mMonth, mDay);
|
||||
(view, year, monthOfYear, dayOfMonth) -> {
|
||||
viewBinding.prDueDate.setText(getString(R.string.setDueDate, year, (monthOfYear + 1), dayOfMonth));
|
||||
currentDate = new Date(year - 1900, monthOfYear, dayOfMonth);
|
||||
}, mYear, mMonth, mDay);
|
||||
datePickerDialog.show();
|
||||
}
|
||||
|
||||
|
@ -15,10 +15,11 @@ import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import androidx.annotation.NonNull;
|
||||
import org.gitnex.tea4j.models.Branches;
|
||||
import org.gitnex.tea4j.models.CreateTagOptions;
|
||||
import org.gitnex.tea4j.models.GitTag;
|
||||
import org.gitnex.tea4j.models.Releases;
|
||||
import org.gitnex.tea4j.v2.models.Branch;
|
||||
import org.gitnex.tea4j.v2.models.CreateReleaseOption;
|
||||
import org.gitnex.tea4j.v2.models.CreateTagOption;
|
||||
import org.gitnex.tea4j.v2.models.Release;
|
||||
import org.gitnex.tea4j.v2.models.Tag;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.ActivityCreateReleaseBinding;
|
||||
@ -32,7 +33,7 @@ import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class CreateReleaseActivity extends BaseActivity {
|
||||
@ -51,7 +52,7 @@ public class CreateReleaseActivity extends BaseActivity {
|
||||
|
||||
private RepositoryContext repository;
|
||||
|
||||
List<Branches> branchesList = new ArrayList<>();
|
||||
List<String> branchesList = new ArrayList<>();
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
@Override
|
||||
@ -94,7 +95,7 @@ public class CreateReleaseActivity extends BaseActivity {
|
||||
closeActivity.setOnClickListener(onClickListener);
|
||||
|
||||
releaseBranch = activityCreateReleaseBinding.releaseBranch;
|
||||
getBranches(getAccount().getAuthorization(), repository.getOwner(), repository.getName());
|
||||
getBranches(repository.getOwner(), repository.getName());
|
||||
|
||||
createNewRelease = activityCreateReleaseBinding.createNewRelease;
|
||||
createNewTag = activityCreateReleaseBinding.createNewTag;
|
||||
@ -136,16 +137,19 @@ public class CreateReleaseActivity extends BaseActivity {
|
||||
|
||||
disableProcessButton();
|
||||
|
||||
CreateTagOptions createReleaseJson = new CreateTagOptions(message, tagName, selectedBranch);
|
||||
CreateTagOption createReleaseJson = new CreateTagOption();
|
||||
createReleaseJson.setMessage(message);
|
||||
createReleaseJson.setTagName(tagName);
|
||||
createReleaseJson.setTarget(selectedBranch);
|
||||
|
||||
Call<GitTag> call = RetrofitClient
|
||||
Call<Tag> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.createTag(getAccount().getAuthorization(), repository.getOwner(), repository.getName(), createReleaseJson);
|
||||
.repoCreateTag(repository.getOwner(), repository.getName(), createReleaseJson);
|
||||
|
||||
call.enqueue(new Callback<GitTag>() {
|
||||
call.enqueue(new Callback<Tag>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<GitTag> call, @NonNull retrofit2.Response<GitTag> response) {
|
||||
public void onResponse(@NonNull Call<Tag> call, @NonNull retrofit2.Response<Tag> response) {
|
||||
|
||||
if (response.code() == 201) {
|
||||
Toasty.success(ctx, getString(R.string.tagCreated));
|
||||
@ -173,14 +177,11 @@ public class CreateReleaseActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<GitTag> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<Tag> call, @NonNull Throwable t) {
|
||||
Log.e("onFailure", t.toString());
|
||||
enableProcessButton();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private final View.OnClickListener createReleaseListener = v -> processNewRelease();
|
||||
@ -221,23 +222,28 @@ public class CreateReleaseActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
disableProcessButton();
|
||||
createNewReleaseFunc(getAccount().getAuthorization(), repository.getOwner(), repository.getName(), newReleaseTagName, newReleaseTitle, newReleaseContent, selectedBranch, newReleaseType, newReleaseDraft);
|
||||
createNewReleaseFunc(repository.getOwner(), repository.getName(), newReleaseTagName, newReleaseTitle, newReleaseContent, selectedBranch, newReleaseType, newReleaseDraft);
|
||||
}
|
||||
|
||||
private void createNewReleaseFunc(final String token, String repoOwner, String repoName, String newReleaseTagName, String newReleaseTitle, String newReleaseContent, String selectedBranch, boolean newReleaseType, boolean newReleaseDraft) {
|
||||
private void createNewReleaseFunc(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);
|
||||
CreateReleaseOption createReleaseJson = new CreateReleaseOption();
|
||||
createReleaseJson.setName(newReleaseTitle);
|
||||
createReleaseJson.setTagName(newReleaseTagName);
|
||||
createReleaseJson.setBody(newReleaseContent);
|
||||
createReleaseJson.setDraft(newReleaseDraft);
|
||||
createReleaseJson.setPrerelease(newReleaseType);
|
||||
createReleaseJson.setTargetCommitish(selectedBranch);
|
||||
|
||||
Call<Releases> call;
|
||||
|
||||
call = RetrofitClient
|
||||
Call<Release> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.createNewRelease(token, repoOwner, repoName, createReleaseJson);
|
||||
.repoCreateRelease(repoOwner, repoName, createReleaseJson);
|
||||
|
||||
call.enqueue(new Callback<Releases>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Releases> call, @NonNull retrofit2.Response<Releases> response) {
|
||||
public void onResponse(@NonNull Call<Release> call, @NonNull retrofit2.Response<Release> response) {
|
||||
|
||||
if(response.code() == 201) {
|
||||
|
||||
@ -251,8 +257,7 @@ public class CreateReleaseActivity extends BaseActivity {
|
||||
|
||||
enableProcessButton();
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx, ctx.getResources().getString(R.string.alertDialogTokenRevokedTitle),
|
||||
ctx.getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||
ctx.getResources().getString(R.string.cancelButton),
|
||||
ctx.getResources().getString(R.string.alertDialogTokenRevokedMessage), ctx.getResources().getString(R.string.cancelButton),
|
||||
ctx.getResources().getString(R.string.navLogout));
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
@ -273,64 +278,53 @@ public class CreateReleaseActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Releases> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
public void onFailure(@NonNull Call<Release> call, @NonNull Throwable t) {
|
||||
enableProcessButton();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void getBranches(String instanceToken, final String repoOwner, final String repoName) {
|
||||
private void getBranches(final String repoOwner, final String repoName) {
|
||||
|
||||
Call<List<Branches>> call = RetrofitClient
|
||||
Call<List<Branch>> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.getBranches(instanceToken, repoOwner, repoName);
|
||||
.repoListBranches(repoOwner, repoName, null, null);
|
||||
|
||||
call.enqueue(new Callback<List<Branches>>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Branches>> call, @NonNull retrofit2.Response<List<Branches>> response) {
|
||||
public void onResponse(@NonNull Call<List<Branch>> call, @NonNull retrofit2.Response<List<Branch>> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
|
||||
if(response.code() == 200) {
|
||||
|
||||
List<Branches> branchesList_ = response.body();
|
||||
List<Branch> branchesList_ = response.body();
|
||||
|
||||
assert branchesList_ != null;
|
||||
if(branchesList_.size() > 0) {
|
||||
|
||||
branchesList.addAll(branchesList_);
|
||||
for(Branch i : branchesList_) {
|
||||
branchesList.add(i.getName());
|
||||
}
|
||||
|
||||
ArrayAdapter<Branches> adapter = new ArrayAdapter<>(CreateReleaseActivity.this,
|
||||
R.layout.list_spinner_items, branchesList);
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<>(CreateReleaseActivity.this, R.layout.list_spinner_items, branchesList);
|
||||
|
||||
releaseBranch.setAdapter(adapter);
|
||||
enableProcessButton();
|
||||
|
||||
releaseBranch.setOnItemClickListener ((parent, view, position, id) ->
|
||||
|
||||
selectedBranch = branchesList.get(position).getName()
|
||||
);
|
||||
releaseBranch.setOnItemClickListener((parent, view, position, id) -> selectedBranch = branchesList.get(position));
|
||||
}
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle),
|
||||
getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||
getResources().getString(R.string.cancelButton),
|
||||
getResources().getString(R.string.navLogout));
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle), getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||
getResources().getString(R.string.cancelButton), getResources().getString(R.string.navLogout));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Branches>> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
public void onFailure(@NonNull Call<List<Branch>> call, @NonNull Throwable t) {
|
||||
}
|
||||
});
|
||||
|
||||
@ -356,5 +350,4 @@ public class CreateReleaseActivity extends BaseActivity {
|
||||
super.onResume();
|
||||
repository.checkAccountSwitch(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -14,8 +14,9 @@ import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import androidx.annotation.NonNull;
|
||||
import org.gitnex.tea4j.models.OrgOwner;
|
||||
import org.gitnex.tea4j.models.OrganizationRepository;
|
||||
import org.gitnex.tea4j.v2.models.CreateRepoOption;
|
||||
import org.gitnex.tea4j.v2.models.Organization;
|
||||
import org.gitnex.tea4j.v2.models.Repository;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.ActivityCreateRepoBinding;
|
||||
@ -47,7 +48,7 @@ public class CreateRepoActivity extends BaseActivity {
|
||||
|
||||
private String selectedOwner;
|
||||
|
||||
List<OrgOwner> organizationsList = new ArrayList<>();
|
||||
List<String> organizationsList = new ArrayList<>();
|
||||
|
||||
//https://github.com/go-gitea/gitea/blob/52cfd2743c0e85b36081cf80a850e6a5901f1865/models/repo.go#L964-L967
|
||||
final List<String> reservedRepoNames = Arrays.asList(".", "..");
|
||||
@ -80,7 +81,7 @@ public class CreateRepoActivity extends BaseActivity {
|
||||
closeActivity.setOnClickListener(onClickListener);
|
||||
|
||||
spinner = activityCreateRepoBinding.ownerSpinner;
|
||||
getOrganizations(getAccount().getAuthorization(), loginUid);
|
||||
getOrganizations(loginUid);
|
||||
|
||||
createRepo = activityCreateRepoBinding.createNewRepoButton;
|
||||
disableProcessButton();
|
||||
@ -143,32 +144,37 @@ public class CreateRepoActivity extends BaseActivity {
|
||||
else {
|
||||
|
||||
disableProcessButton();
|
||||
createNewRepository(getAccount().getAuthorization(), loginUid, newRepoName, newRepoDesc, selectedOwner, newRepoAccess);
|
||||
createNewRepository(loginUid, newRepoName, newRepoDesc, selectedOwner, newRepoAccess);
|
||||
}
|
||||
}
|
||||
|
||||
private void createNewRepository(final String token, String loginUid, String repoName, String repoDesc, String selectedOwner, boolean isPrivate) {
|
||||
private void createNewRepository(String loginUid, String repoName, String repoDesc, String selectedOwner, boolean isPrivate) {
|
||||
|
||||
OrganizationRepository createRepository = new OrganizationRepository(true, repoDesc, null, null, repoName, isPrivate, "Default");
|
||||
CreateRepoOption createRepository = new CreateRepoOption();
|
||||
createRepository.setAutoInit(true);
|
||||
createRepository.setDescription(repoDesc);
|
||||
createRepository.setPrivate(isPrivate);
|
||||
createRepository.setReadme("Default");
|
||||
createRepository.setName(repoName);
|
||||
|
||||
Call<OrganizationRepository> call;
|
||||
Call<Repository> call;
|
||||
if(selectedOwner.equals(loginUid)) {
|
||||
|
||||
call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.createNewUserRepository(token, createRepository);
|
||||
.createCurrentUserRepo(createRepository);
|
||||
}
|
||||
else {
|
||||
|
||||
call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.createNewUserOrgRepository(token, selectedOwner, createRepository);
|
||||
.createOrgRepo(selectedOwner, createRepository);
|
||||
}
|
||||
|
||||
call.enqueue(new Callback<OrganizationRepository>() {
|
||||
call.enqueue(new Callback<Repository>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<OrganizationRepository> call, @NonNull retrofit2.Response<OrganizationRepository> response) {
|
||||
public void onResponse(@NonNull Call<Repository> call, @NonNull retrofit2.Response<Repository> response) {
|
||||
|
||||
if(response.code() == 201) {
|
||||
|
||||
@ -198,7 +204,7 @@ public class CreateRepoActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<OrganizationRepository> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<Repository> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
enableProcessButton();
|
||||
@ -206,54 +212,53 @@ public class CreateRepoActivity extends BaseActivity {
|
||||
});
|
||||
}
|
||||
|
||||
private void getOrganizations(String instanceToken, final String userLogin) {
|
||||
private void getOrganizations(final String userLogin) {
|
||||
|
||||
Call<List<OrgOwner>> call = RetrofitClient
|
||||
Call<List<Organization>> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.getOrgOwners(instanceToken, 1, 50);
|
||||
.orgListCurrentUserOrgs(1, 50);
|
||||
|
||||
call.enqueue(new Callback<List<OrgOwner>>() {
|
||||
call.enqueue(new Callback<List<Organization>>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<OrgOwner>> call, @NonNull retrofit2.Response<List<OrgOwner>> response) {
|
||||
public void onResponse(@NonNull Call<List<Organization>> call, @NonNull retrofit2.Response<List<Organization>> response) {
|
||||
|
||||
if(response.code() == 200) {
|
||||
|
||||
int organizationId = 0;
|
||||
|
||||
List<OrgOwner> organizationsList_ = response.body();
|
||||
List<Organization> organizationsList_ = response.body();
|
||||
|
||||
organizationsList.add(new OrgOwner(userLogin));
|
||||
organizationsList.add(userLogin);
|
||||
assert organizationsList_ != null;
|
||||
|
||||
if(organizationsList_.size() > 0) {
|
||||
|
||||
for(int i = 0; i < organizationsList_.size(); i++) {
|
||||
|
||||
if(!getIntent().getStringExtra("orgName").equals("")) {
|
||||
if(getIntent().getStringExtra("orgName") != null && !"".equals(getIntent().getStringExtra("orgName"))) {
|
||||
if(getIntent().getStringExtra("orgName").equals(organizationsList_.get(i).getUsername())) {
|
||||
organizationId = i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
OrgOwner data = new OrgOwner(organizationsList_.get(i).getUsername());
|
||||
organizationsList.add(data);
|
||||
organizationsList.add(organizationsList_.get(i).getUsername());
|
||||
}
|
||||
}
|
||||
|
||||
ArrayAdapter<OrgOwner> adapter = new ArrayAdapter<>(CreateRepoActivity.this, R.layout.list_spinner_items, organizationsList);
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<>(CreateRepoActivity.this, R.layout.list_spinner_items, organizationsList);
|
||||
|
||||
spinner.setAdapter(adapter);
|
||||
|
||||
spinner.setOnItemClickListener ((parent, view, position, id) -> selectedOwner = organizationsList.get(position).getUsername());
|
||||
spinner.setOnItemClickListener ((parent, view, position, id) -> selectedOwner = organizationsList.get(position));
|
||||
|
||||
if(getIntent().getBooleanExtra("organizationAction", false) && organizationId != 0) {
|
||||
|
||||
int selectOwnerById = organizationId;
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
|
||||
spinner.setText(organizationsList.get(selectOwnerById).getUsername(), false);
|
||||
selectedOwner = organizationsList.get(selectOwnerById).getUsername();
|
||||
spinner.setText(organizationsList.get(selectOwnerById), false);
|
||||
selectedOwner = organizationsList.get(selectOwnerById);
|
||||
}, 500);
|
||||
getIntent().removeExtra("organizationAction");
|
||||
}
|
||||
@ -270,7 +275,7 @@ public class CreateRepoActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<OrgOwner>> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<List<Organization>> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
enableProcessButton();
|
||||
|
@ -12,7 +12,8 @@ import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.core.content.res.ResourcesCompat;
|
||||
import org.gitnex.tea4j.models.Teams;
|
||||
import org.gitnex.tea4j.v2.models.CreateTeamOption;
|
||||
import org.gitnex.tea4j.v2.models.Team;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.ActivityCreateTeamByOrgBinding;
|
||||
@ -223,7 +224,6 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
||||
|
||||
private void processCreateTeam() {
|
||||
|
||||
final String instanceToken = getAccount().getAuthorization();
|
||||
final String orgName = getIntent().getStringExtra("orgName");
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
@ -278,23 +278,35 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
||||
newTeamAccessControls_.set(i, newTeamAccessControls_.get(i).trim());
|
||||
}
|
||||
|
||||
createNewTeamCall(instanceToken, orgName, newTeamName, newTeamDesc, newTeamPermission, newTeamAccessControls_, getAccount().getAccount().getUserName());
|
||||
createNewTeamCall(orgName, newTeamName, newTeamDesc, newTeamPermission, newTeamAccessControls_);
|
||||
}
|
||||
|
||||
private void createNewTeamCall(final String instanceToken, String orgName, String newTeamName, String newTeamDesc, String newTeamPermission, List<String> newTeamAccessControls, String loginUid) {
|
||||
private void createNewTeamCall(String orgName, String newTeamName, String newTeamDesc, String newTeamPermission, List<String> newTeamAccessControls) {
|
||||
|
||||
Teams createNewTeamJson = new Teams(newTeamName, newTeamDesc, newTeamPermission, newTeamAccessControls);
|
||||
CreateTeamOption createNewTeamJson = new CreateTeamOption();
|
||||
createNewTeamJson.setName(newTeamName);
|
||||
createNewTeamJson.setDescription(newTeamDesc);
|
||||
switch(newTeamPermission) {
|
||||
case "Read":
|
||||
createNewTeamJson.setPermission(CreateTeamOption.PermissionEnum.READ);
|
||||
break;
|
||||
case "Write":
|
||||
createNewTeamJson.setPermission(CreateTeamOption.PermissionEnum.WRITE);
|
||||
break;
|
||||
case "Admin":
|
||||
createNewTeamJson.setPermission(CreateTeamOption.PermissionEnum.ADMIN);
|
||||
break;
|
||||
}
|
||||
createNewTeamJson.setUnits(newTeamAccessControls);
|
||||
|
||||
Call<Teams> call3;
|
||||
|
||||
call3 = RetrofitClient
|
||||
Call<Team> call3 = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.createTeamsByOrg(getAccount().getAuthorization(), orgName, createNewTeamJson);
|
||||
.orgCreateTeam(orgName, createNewTeamJson);
|
||||
|
||||
call3.enqueue(new Callback<Teams>() {
|
||||
call3.enqueue(new Callback<Team>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Teams> call, @NonNull retrofit2.Response<Teams> response2) {
|
||||
public void onResponse(@NonNull Call<Team> call, @NonNull retrofit2.Response<Team> response2) {
|
||||
|
||||
if(response2.isSuccessful()) {
|
||||
|
||||
@ -324,7 +336,7 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Teams> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<Team> call, @NonNull Throwable t) {
|
||||
Log.e("onFailure", t.toString());
|
||||
}
|
||||
});
|
||||
|
@ -9,11 +9,11 @@ import android.util.Log;
|
||||
import android.view.View;
|
||||
import androidx.annotation.NonNull;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.gitnex.tea4j.models.Files;
|
||||
import org.gitnex.tea4j.models.Organization;
|
||||
import org.gitnex.tea4j.models.PullRequests;
|
||||
import org.gitnex.tea4j.models.UserInfo;
|
||||
import org.gitnex.tea4j.models.UserRepositories;
|
||||
import org.gitnex.tea4j.v2.models.ContentsResponse;
|
||||
import org.gitnex.tea4j.v2.models.Organization;
|
||||
import org.gitnex.tea4j.v2.models.PullRequest;
|
||||
import org.gitnex.tea4j.v2.models.Repository;
|
||||
import org.gitnex.tea4j.v2.models.User;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.database.api.BaseApi;
|
||||
@ -41,8 +41,6 @@ import retrofit2.Response;
|
||||
public class DeepLinksActivity extends BaseActivity {
|
||||
|
||||
private ActivityDeeplinksBinding viewBinding;
|
||||
private String currentInstance;
|
||||
private String instanceToken;
|
||||
private boolean accountFound = false;
|
||||
|
||||
private Intent mainIntent;
|
||||
@ -86,8 +84,6 @@ public class DeepLinksActivity extends BaseActivity {
|
||||
|
||||
String hostUri = userAccount.getInstanceUrl();
|
||||
|
||||
currentInstance = userAccount.getInstanceUrl();
|
||||
instanceToken = userAccount.getToken();
|
||||
String host = data.getHost();
|
||||
if (host == null) host = "";
|
||||
|
||||
@ -127,7 +123,7 @@ public class DeepLinksActivity extends BaseActivity {
|
||||
}
|
||||
else {
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() ->
|
||||
getUserOrOrg(currentInstance, instanceToken, data.getLastPathSegment()), 500);
|
||||
getUserOrOrg(data.getLastPathSegment()), 500);
|
||||
}
|
||||
}
|
||||
else if(data.getPathSegments().size() == 2) {
|
||||
@ -159,7 +155,7 @@ public class DeepLinksActivity extends BaseActivity {
|
||||
}
|
||||
String finalRepo = repo;
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() ->
|
||||
goToRepoSection(currentInstance, instanceToken, data.getPathSegments().get(0), finalRepo, "repo"), 500);
|
||||
goToRepoSection(data.getPathSegments().get(0), finalRepo, "repo"), 500);
|
||||
}
|
||||
else { // no action, show options
|
||||
showNoActionButtons();
|
||||
@ -207,11 +203,11 @@ public class DeepLinksActivity extends BaseActivity {
|
||||
}
|
||||
else if(Objects.requireNonNull(data.getLastPathSegment()).contains("issues")) {
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() ->
|
||||
goToRepoSection(currentInstance, instanceToken, data.getPathSegments().get(0), data.getPathSegments().get(1), "issue"), 500);
|
||||
goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "issue"), 500);
|
||||
}
|
||||
else if(data.getLastPathSegment().equals("new")) {
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() ->
|
||||
goToRepoSection(currentInstance, instanceToken, data.getPathSegments().get(0), data.getPathSegments().get(1), "issueNew"), 500);
|
||||
goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "issueNew"), 500);
|
||||
}
|
||||
else {
|
||||
ctx.startActivity(mainIntent);
|
||||
@ -229,18 +225,18 @@ public class DeepLinksActivity extends BaseActivity {
|
||||
issueIntent.putExtra("issueComment", urlSplitted[1]);
|
||||
}
|
||||
|
||||
getPullRequest(currentInstance, instanceToken, data.getPathSegments().get(0), data.getPathSegments().get(1), Integer.parseInt(data.getLastPathSegment()));
|
||||
getPullRequest(data.getPathSegments().get(0), data.getPathSegments().get(1), Integer.parseInt(data.getLastPathSegment()));
|
||||
}, 500);
|
||||
|
||||
}
|
||||
else if(Objects.requireNonNull(data.getLastPathSegment()).contains("pulls")) {
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() ->
|
||||
goToRepoSection(currentInstance, instanceToken, data.getPathSegments().get(0), data.getPathSegments().get(1), "pull"), 500);
|
||||
goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "pull"), 500);
|
||||
}
|
||||
else if(data.getLastPathSegment().equals("files")) { // pr diff
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
issueIntent.putExtra("openPrDiff", "true");
|
||||
getPullRequest(currentInstance, instanceToken, data.getPathSegments().get(0), data.getPathSegments().get(1), Integer.parseInt(data.getPathSegments().get(3)));
|
||||
getPullRequest(data.getPathSegments().get(0), data.getPathSegments().get(1), Integer.parseInt(data.getPathSegments().get(3)));
|
||||
}, 500);
|
||||
}
|
||||
else {
|
||||
@ -251,35 +247,35 @@ public class DeepLinksActivity extends BaseActivity {
|
||||
|
||||
else if(data.getPathSegments().get(2).equals("compare")) { // new pull request
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() ->
|
||||
goToRepoSection(currentInstance, instanceToken, data.getPathSegments().get(0), data.getPathSegments().get(1), "pullNew"), 500);
|
||||
goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "pullNew"), 500);
|
||||
}
|
||||
else if(data.getPathSegments().get(2).equals("commit")) {
|
||||
repoIntent.putExtra("sha", data.getLastPathSegment());
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() ->
|
||||
goToRepoSection(currentInstance, instanceToken, data.getPathSegments().get(0), data.getPathSegments().get(1), "commit"), 500);
|
||||
goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "commit"), 500);
|
||||
}
|
||||
else if(data.getPathSegments().get(2).equals("commits")) { // commits list
|
||||
String branch = data.getLastPathSegment();
|
||||
repoIntent.putExtra("branchName", branch);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() ->
|
||||
goToRepoSection(currentInstance, instanceToken, data.getPathSegments().get(0), data.getPathSegments().get(1), "commitsList"), 500);
|
||||
goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "commitsList"), 500);
|
||||
}
|
||||
else if(data.getPathSegments().get(2).equals("milestones") && data.getLastPathSegment().equals("new")) { // new milestone
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() ->
|
||||
goToRepoSection(currentInstance, instanceToken, data.getPathSegments().get(0), data.getPathSegments().get(1), "milestonesNew"), 500);
|
||||
goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "milestonesNew"), 500);
|
||||
}
|
||||
else if(data.getPathSegments().get(2).equals("milestones")) { // milestones
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() ->
|
||||
goToRepoSection(currentInstance, instanceToken, data.getPathSegments().get(0), data.getPathSegments().get(1), "milestones"), 500);
|
||||
goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "milestones"), 500);
|
||||
}
|
||||
else if(data.getPathSegments().get(2).equals("milestone")) { // milestone
|
||||
repoIntent.putExtra("milestoneId", data.getLastPathSegment());
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() ->
|
||||
goToRepoSection(currentInstance, instanceToken, data.getPathSegments().get(0), data.getPathSegments().get(1), "milestones"), 500);
|
||||
goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "milestones"), 500);
|
||||
}
|
||||
else if(data.getPathSegments().get(2).equals("releases") && data.getLastPathSegment().equals("new")) { // new release
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() ->
|
||||
goToRepoSection(currentInstance, instanceToken, data.getPathSegments().get(0), data.getPathSegments().get(1), "newRelease"), 500);
|
||||
goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "newRelease"), 500);
|
||||
}
|
||||
else if(data.getPathSegments().get(2).equals("releases")) { // releases
|
||||
if(data.getPathSegments().size() == 5) {
|
||||
@ -288,25 +284,25 @@ public class DeepLinksActivity extends BaseActivity {
|
||||
}
|
||||
}
|
||||
new Handler(Looper.getMainLooper()).postDelayed(
|
||||
() -> goToRepoSection(currentInstance, instanceToken, data.getPathSegments().get(0), data.getPathSegments().get(1),
|
||||
() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1),
|
||||
"releases"), 500);
|
||||
}
|
||||
else if(data.getPathSegments().get(2).equals("labels")) { // labels
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() ->
|
||||
goToRepoSection(currentInstance, instanceToken, data.getPathSegments().get(0), data.getPathSegments().get(1), "labels"), 500);
|
||||
goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "labels"), 500);
|
||||
}
|
||||
else if(data.getPathSegments().get(2).equals("settings")) { // repo settings
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() ->
|
||||
goToRepoSection(currentInstance, instanceToken, data.getPathSegments().get(0), data.getPathSegments().get(1), "settings"), 500);
|
||||
goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "settings"), 500);
|
||||
}
|
||||
else if(data.getLastPathSegment().equals("branches")) { // branches list
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() ->
|
||||
goToRepoSection(currentInstance, instanceToken, data.getPathSegments().get(0), data.getPathSegments().get(1), "branchesList"), 500);
|
||||
goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "branchesList"), 500);
|
||||
}
|
||||
else if(data.getPathSegments().size() == 5 && data.getPathSegments().get(2).equals("src") && data.getPathSegments().get(3).equals("branch")) { // branch
|
||||
repoIntent.putExtra("selectedBranch", data.getLastPathSegment());
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() ->
|
||||
goToRepoSection(currentInstance, instanceToken, data.getPathSegments().get(0), data.getPathSegments().get(1), "branch"), 500);
|
||||
goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "branch"), 500);
|
||||
}
|
||||
else if(data.getPathSegments().get(2).equals("src") && data.getPathSegments().get(3).equals("branch")) { // file/dir
|
||||
StringBuilder filePath = new StringBuilder();
|
||||
@ -318,7 +314,7 @@ public class DeepLinksActivity extends BaseActivity {
|
||||
}
|
||||
filePath.deleteCharAt(filePath.toString().length() - 1);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() ->
|
||||
getFile(currentInstance, instanceToken, data.getPathSegments().get(0),
|
||||
getFile(data.getPathSegments().get(0),
|
||||
data.getPathSegments().get(1), filePath.toString(), data.getPathSegments().get(4)), 500);
|
||||
}
|
||||
else { // no action, show options
|
||||
@ -367,18 +363,18 @@ public class DeepLinksActivity extends BaseActivity {
|
||||
}
|
||||
}
|
||||
|
||||
private void getPullRequest(String url, String token, String repoOwner, String repoName, int index) {
|
||||
private void getPullRequest(String repoOwner, String repoName, int index) {
|
||||
|
||||
Call<PullRequests> call = RetrofitClient
|
||||
.getApiInterface(ctx, url)
|
||||
.getPullRequestByIndex(token, repoOwner, repoName, index);
|
||||
Call<PullRequest> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.repoGetPullRequest(repoOwner, repoName, (long) index);
|
||||
|
||||
call.enqueue(new Callback<PullRequests>() {
|
||||
call.enqueue(new Callback<PullRequest>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<PullRequests> call, @NonNull retrofit2.Response<PullRequests> response) {
|
||||
public void onResponse(@NonNull Call<PullRequest> call, @NonNull retrofit2.Response<PullRequest> response) {
|
||||
|
||||
PullRequests prInfo = response.body();
|
||||
PullRequest prInfo = response.body();
|
||||
|
||||
if (response.code() == 200) {
|
||||
|
||||
@ -417,7 +413,7 @@ public class DeepLinksActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<PullRequests> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<PullRequest> call, @NonNull Throwable t) {
|
||||
|
||||
ctx.startActivity(issueIntent);
|
||||
finish();
|
||||
@ -426,17 +422,17 @@ public class DeepLinksActivity extends BaseActivity {
|
||||
});
|
||||
}
|
||||
|
||||
private void goToRepoSection(String url, String token, String repoOwner, String repoName, String type) {
|
||||
private void goToRepoSection(String repoOwner, String repoName, String type) {
|
||||
|
||||
Call<UserRepositories> call = RetrofitClient
|
||||
.getApiInterface(ctx, url)
|
||||
.getUserRepository(token, repoOwner, repoName);
|
||||
Call<Repository> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.repoGet(repoOwner, repoName);
|
||||
|
||||
call.enqueue(new Callback<UserRepositories>() {
|
||||
call.enqueue(new Callback<Repository>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<UserRepositories> call, @NonNull retrofit2.Response<UserRepositories> response) {
|
||||
UserRepositories repoInfo = response.body();
|
||||
public void onResponse(@NonNull Call<Repository> call, @NonNull retrofit2.Response<Repository> response) {
|
||||
Repository repoInfo = response.body();
|
||||
|
||||
if (response.code() == 200) {
|
||||
assert repoInfo != null;
|
||||
@ -473,7 +469,7 @@ public class DeepLinksActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<UserRepositories> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<Repository> call, @NonNull Throwable t) {
|
||||
|
||||
ctx.startActivity(mainIntent);
|
||||
finish();
|
||||
@ -482,8 +478,8 @@ public class DeepLinksActivity extends BaseActivity {
|
||||
});
|
||||
}
|
||||
|
||||
private void getUserOrOrg(String url, String instanceToken, String userOrgName) {
|
||||
Call<Organization> call = RetrofitClient.getApiInterface(ctx, url).getOrganization(instanceToken, userOrgName);
|
||||
private void getUserOrOrg(String userOrgName) {
|
||||
Call<Organization> call = RetrofitClient.getApiInterface(ctx).orgGet(userOrgName);
|
||||
|
||||
call.enqueue(new Callback<Organization>() {
|
||||
|
||||
@ -491,7 +487,7 @@ public class DeepLinksActivity extends BaseActivity {
|
||||
public void onResponse(@NonNull Call<Organization> call, @NonNull Response<Organization> response) {
|
||||
if(response.code() == 404) { // org doesn't exist or it's a user user
|
||||
Log.d("getUserOrOrg-404", String.valueOf(response.code()));
|
||||
getUser(url, instanceToken, userOrgName);
|
||||
getUser(userOrgName);
|
||||
}
|
||||
else if(response.code() == 200) { // org
|
||||
assert response.body() != null;
|
||||
@ -515,13 +511,13 @@ public class DeepLinksActivity extends BaseActivity {
|
||||
});
|
||||
}
|
||||
|
||||
private void getUser(String url, String instanceToken, String userName) {
|
||||
Call<UserInfo> call = RetrofitClient.getApiInterface(ctx, url).getUserProfile(instanceToken, userName);
|
||||
private void getUser(String userName) {
|
||||
Call<User> call = RetrofitClient.getApiInterface(ctx).userGet(userName);
|
||||
|
||||
call.enqueue(new Callback<UserInfo>() {
|
||||
call.enqueue(new Callback<User>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<UserInfo> call, @NonNull Response<UserInfo> response) {
|
||||
public void onResponse(@NonNull Call<User> call, @NonNull Response<User> response) {
|
||||
if(response.code() == 200) {
|
||||
assert response.body() != null;
|
||||
userIntent.putExtra("username", response.body().getLogin());
|
||||
@ -535,7 +531,7 @@ public class DeepLinksActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<UserInfo> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<User> call, @NonNull Throwable t) {
|
||||
Log.e("onFailure-getUser", t.toString());
|
||||
ctx.startActivity(mainIntent);
|
||||
finish();
|
||||
@ -543,21 +539,21 @@ public class DeepLinksActivity extends BaseActivity {
|
||||
});
|
||||
}
|
||||
|
||||
private void getFile(String url, String instanceToken, String owner, String repo, String filePath, String branch) {
|
||||
Call<Files> call = RetrofitClient.getApiInterface(ctx, url).getSingleFileContents(instanceToken, owner, repo, filePath, branch);
|
||||
private void getFile(String owner, String repo, String filePath, String branch) {
|
||||
Call<ContentsResponse> call = RetrofitClient.getApiInterface(ctx).repoGetContents(owner, repo, filePath, branch);
|
||||
|
||||
call.enqueue(new Callback<Files>() {
|
||||
call.enqueue(new Callback<ContentsResponse>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Files> call, @NonNull Response<Files> response) {
|
||||
public void onResponse(@NonNull Call<ContentsResponse> call, @NonNull Response<ContentsResponse> response) {
|
||||
if(response.code() == 200) {
|
||||
// check if file and open file/dir
|
||||
Files file = response.body();
|
||||
ContentsResponse file = response.body();
|
||||
assert file != null;
|
||||
if(file.getType().equals("file")) {
|
||||
repoIntent.putExtra("file", file);
|
||||
repoIntent.putExtra("branch", branch);
|
||||
goToRepoSection(url, instanceToken, owner, repo, "file");
|
||||
goToRepoSection(owner, repo, "file");
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -568,18 +564,18 @@ public class DeepLinksActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Files> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<ContentsResponse> call, @NonNull Throwable t) {
|
||||
Log.e("getFile-onFailure", t.toString());
|
||||
// maybe it's a directory
|
||||
getDir(url, instanceToken, owner, repo, filePath, branch);
|
||||
getDir(owner, repo, filePath, branch);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void getDir(String url, String instanceToken, String owner, String repo, String filePath, String branch) {
|
||||
private void getDir(String owner, String repo, String filePath, String branch) {
|
||||
repoIntent.putExtra("branch", branch);
|
||||
repoIntent.putExtra("dir", filePath);
|
||||
goToRepoSection(url, instanceToken, owner, repo, "dir");
|
||||
goToRepoSection(owner, repo, "dir");
|
||||
}
|
||||
|
||||
private void showNoActionButtons() {
|
||||
|
@ -18,10 +18,9 @@ import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import com.google.gson.JsonElement;
|
||||
import org.gitnex.tea4j.models.CreateIssue;
|
||||
import org.gitnex.tea4j.models.Issues;
|
||||
import org.gitnex.tea4j.models.Milestones;
|
||||
import org.gitnex.tea4j.v2.models.EditIssueOption;
|
||||
import org.gitnex.tea4j.v2.models.Issue;
|
||||
import org.gitnex.tea4j.v2.models.Milestone;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.ActivityEditIssueBinding;
|
||||
@ -36,7 +35,10 @@ import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
@ -55,10 +57,11 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
||||
private Button editIssueButton;
|
||||
private AutoCompleteTextView editIssueMilestoneSpinner;
|
||||
|
||||
private String msState = "open";
|
||||
private int milestoneId;
|
||||
private final String msState = "open";
|
||||
private int milestoneId = 0;
|
||||
private Date currentDate = null;
|
||||
|
||||
List<Milestones> milestonesList = new ArrayList<>();
|
||||
private LinkedHashMap<String, Milestone> milestonesList = new LinkedHashMap<>();
|
||||
|
||||
private IssueContext issue;
|
||||
|
||||
@ -123,7 +126,7 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
||||
disableProcessButton();
|
||||
getIssue(issue.getRepository().getOwner(), issue.getRepository().getName(), issue.getIssueIndex(), resultLimit);
|
||||
|
||||
if(!issue.getRepository().getPermissions().canPush()) {
|
||||
if(!issue.getRepository().getPermissions().isPush()) {
|
||||
findViewById(R.id.editIssueMilestoneSpinnerLayout).setVisibility(View.GONE);
|
||||
findViewById(R.id.editIssueDueDateLayout).setVisibility(View.GONE);
|
||||
}
|
||||
@ -140,7 +143,6 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
||||
|
||||
String editIssueTitleForm = editIssueTitle.getText().toString();
|
||||
String editIssueDescriptionForm = editIssueDescription.getText().toString();
|
||||
String editIssueDueDateForm = editIssueDueDate.getText().toString();
|
||||
|
||||
if(!connToInternet) {
|
||||
|
||||
@ -154,31 +156,27 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
||||
return;
|
||||
}
|
||||
|
||||
if (editIssueDueDateForm.equals("")) {
|
||||
|
||||
editIssueDueDateForm = null;
|
||||
}
|
||||
else {
|
||||
|
||||
editIssueDueDateForm = (AppUtil.customDateCombine(AppUtil.customDateFormat(editIssueDueDateForm)));
|
||||
}
|
||||
|
||||
disableProcessButton();
|
||||
editIssue(issue.getRepository().getOwner(), issue.getRepository().getName(), issue.getIssueIndex(), editIssueTitleForm, editIssueDescriptionForm, editIssueDueDateForm, milestoneId);
|
||||
editIssue(issue.getRepository().getOwner(), issue.getRepository().getName(), issue.getIssueIndex(), editIssueTitleForm, editIssueDescriptionForm,
|
||||
milestoneId);
|
||||
}
|
||||
|
||||
private void editIssue(String repoOwner, String repoName, int issueIndex, String title, String description, String dueDate, int milestoneId) {
|
||||
private void editIssue(String repoOwner, String repoName, int issueIndex, String title, String description, int milestoneId) {
|
||||
|
||||
CreateIssue issueData = new CreateIssue(title, description, dueDate, milestoneId);
|
||||
EditIssueOption issueData = new EditIssueOption();
|
||||
issueData.setTitle(title);
|
||||
issueData.setBody(description);
|
||||
issueData.setDueDate(currentDate);
|
||||
issueData.setMilestone((long) milestoneId);
|
||||
|
||||
Call<JsonElement> call = RetrofitClient
|
||||
Call<Issue> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.patchIssue(getAccount().getAuthorization(), repoOwner, repoName, issueIndex, issueData);
|
||||
.issueEditIssue(repoOwner, repoName, (long) issueIndex, issueData);
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
call.enqueue(new Callback<Issue>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
|
||||
public void onResponse(@NonNull Call<Issue> call, @NonNull retrofit2.Response<Issue> response) {
|
||||
|
||||
if(response.code() == 201) {
|
||||
|
||||
@ -193,8 +191,8 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
||||
|
||||
Intent result = new Intent();
|
||||
result.putExtra("issueEdited", true);
|
||||
IssuesFragment.resumeIssues = issue.getIssue().getPull_request() == null;
|
||||
PullRequestsFragment.resumePullRequests = issue.getIssue().getPull_request() != null;
|
||||
IssuesFragment.resumeIssues = issue.getIssue().getPullRequest() == null;
|
||||
PullRequestsFragment.resumePullRequests = issue.getIssue().getPullRequest() != null;
|
||||
setResult(200, result);
|
||||
finish();
|
||||
}
|
||||
@ -214,7 +212,7 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<Issue> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
enableProcessButton();
|
||||
@ -234,7 +232,10 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
||||
final int mDay = c.get(Calendar.DAY_OF_MONTH);
|
||||
|
||||
DatePickerDialog datePickerDialog = new DatePickerDialog(this,
|
||||
(view, year, monthOfYear, dayOfMonth) -> editIssueDueDate.setText(getString(R.string.setDueDate, year, (monthOfYear + 1), dayOfMonth)), mYear, mMonth, mDay);
|
||||
(view, year, monthOfYear, dayOfMonth) -> {
|
||||
editIssueDueDate.setText(getString(R.string.setDueDate, year, (monthOfYear + 1), dayOfMonth));
|
||||
currentDate = new Date(year - 1900, monthOfYear, dayOfMonth);
|
||||
}, mYear, mMonth, mDay);
|
||||
datePickerDialog.show();
|
||||
}
|
||||
else if(v == editIssueButton) {
|
||||
@ -246,14 +247,14 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
||||
|
||||
private void getIssue(final String repoOwner, final String repoName, int issueIndex, int resultLimit) {
|
||||
|
||||
Call<Issues> call = RetrofitClient
|
||||
Call<Issue> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.getIssueByIndex(getAccount().getAuthorization(), repoOwner, repoName, issueIndex);
|
||||
.issueGetIssue(repoOwner, repoName, (long) issueIndex);
|
||||
|
||||
call.enqueue(new Callback<Issues>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Issues> call, @NonNull retrofit2.Response<Issues> response) {
|
||||
public void onResponse(@NonNull Call<Issue> call, @NonNull retrofit2.Response<Issue> response) {
|
||||
|
||||
if(response.code() == 200) {
|
||||
|
||||
@ -261,59 +262,62 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
||||
editIssueTitle.setText(response.body().getTitle());
|
||||
editIssueDescription.setText(response.body().getBody());
|
||||
|
||||
int currentMilestoneId = 0;
|
||||
if(response.body().getMilestone() != null) {
|
||||
|
||||
currentMilestoneId = response.body().getMilestone().getId();
|
||||
}
|
||||
Milestone currentMilestone = response.body().getMilestone();
|
||||
|
||||
// get milestones list
|
||||
if(response.body().getId() > 0) {
|
||||
|
||||
Call<List<Milestones>> call_ = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.getMilestones(getAccount().getAuthorization(), repoOwner, repoName, 1, resultLimit, msState);
|
||||
Call<List<Milestone>> call_ = RetrofitClient.getApiInterface(ctx).issueGetMilestonesList(repoOwner, repoName, msState, null, 1, resultLimit);
|
||||
|
||||
int checkMilestoneId = currentMilestoneId;
|
||||
|
||||
call_.enqueue(new Callback<List<Milestones>>() {
|
||||
call_.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Milestones>> call, @NonNull retrofit2.Response<List<Milestones>> response_) {
|
||||
|
||||
int getSelectedMilestoneId = 0;
|
||||
public void onResponse(@NonNull Call<List<Milestone>> call, @NonNull retrofit2.Response<List<Milestone>> response_) {
|
||||
|
||||
if(response_.code() == 200) {
|
||||
|
||||
List<Milestones> milestonesList_ = response_.body();
|
||||
List<Milestone> milestonesList_ = response_.body();
|
||||
|
||||
milestonesList.add(new Milestones(0, "No milestone"));
|
||||
assert milestonesList_ != null;
|
||||
|
||||
Milestone ms = new Milestone();
|
||||
ms.setId(0L);
|
||||
ms.setTitle(getString(R.string.issueCreatedNoMilestone));
|
||||
milestonesList.put(ms.getTitle(), ms);
|
||||
|
||||
if(milestonesList_.size() > 0) {
|
||||
|
||||
milestonesList.addAll(milestonesList_);
|
||||
for(Milestone milestone : milestonesList_) {
|
||||
|
||||
for (int i = 0; i < milestonesList_.size(); i++) {
|
||||
|
||||
if(checkMilestoneId == milestonesList_.get(i).getId()) {
|
||||
getSelectedMilestoneId = i + 1;
|
||||
//Don't translate "open" is a enum
|
||||
if(milestone.getState().equals("open")) {
|
||||
milestonesList.put(milestone.getTitle(), milestone);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ArrayAdapter<Milestones> adapter = new ArrayAdapter<>(EditIssueActivity.this,
|
||||
R.layout.list_spinner_items, milestonesList);
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<>(EditIssueActivity.this, R.layout.list_spinner_items, new ArrayList<>(milestonesList.keySet()));
|
||||
|
||||
editIssueMilestoneSpinner.setAdapter(adapter);
|
||||
|
||||
editIssueMilestoneSpinner.setOnItemClickListener ((parent, view, position, id) -> milestoneId = milestonesList.get(position).getId());
|
||||
editIssueMilestoneSpinner.setOnItemClickListener((parent, view, position, id) -> {
|
||||
if(position == 0) {
|
||||
milestoneId = 0;
|
||||
}
|
||||
else if(view instanceof TextView) {
|
||||
milestoneId = Math.toIntExact(
|
||||
Objects.requireNonNull(milestonesList.get(((TextView) view).getText().toString())).getId());
|
||||
}
|
||||
});
|
||||
|
||||
int finalMsId = getSelectedMilestoneId;
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
|
||||
editIssueMilestoneSpinner.setText(milestonesList.get(finalMsId).getTitle(),false);
|
||||
milestoneId = milestonesList.get(finalMsId).getId();
|
||||
if(currentMilestone != null) {
|
||||
milestoneId = Math.toIntExact(currentMilestone.getId());
|
||||
editIssueMilestoneSpinner.setText(currentMilestone.getTitle(), false);
|
||||
} else {
|
||||
milestoneId = 0;
|
||||
editIssueMilestoneSpinner.setText(getString(R.string.issueCreatedNoMilestone), false);
|
||||
}
|
||||
}, 500);
|
||||
|
||||
enableProcessButton();
|
||||
@ -321,7 +325,7 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Milestones>> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<List<Milestone>> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
}
|
||||
@ -330,10 +334,10 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
||||
}
|
||||
// get milestones list
|
||||
|
||||
if(response.body().getDue_date() != null) {
|
||||
if(response.body().getDueDate() != null) {
|
||||
|
||||
@SuppressLint("SimpleDateFormat") DateFormat formatter = new SimpleDateFormat("yyyy-M-dd");
|
||||
String dueDate = formatter.format(response.body().getDue_date());
|
||||
String dueDate = formatter.format(response.body().getDueDate());
|
||||
editIssueDueDate.setText(dueDate);
|
||||
}
|
||||
//enableProcessButton();
|
||||
@ -341,10 +345,8 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle),
|
||||
getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||
getResources().getString(R.string.cancelButton),
|
||||
getResources().getString(R.string.navLogout));
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle), getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||
getResources().getString(R.string.cancelButton), getResources().getString(R.string.navLogout));
|
||||
}
|
||||
else {
|
||||
|
||||
@ -353,7 +355,7 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Issues> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<Issue> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ import androidx.activity.result.contract.ActivityResultContracts;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
import com.vdurmont.emoji.EmojiParser;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.gitnex.tea4j.models.Files;
|
||||
import org.gitnex.tea4j.v2.models.ContentsResponse;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.ActivityFileViewBinding;
|
||||
@ -45,7 +45,7 @@ import retrofit2.Response;
|
||||
public class FileViewActivity extends BaseActivity implements BottomSheetListener {
|
||||
|
||||
private ActivityFileViewBinding binding;
|
||||
private Files file;
|
||||
private ContentsResponse file;
|
||||
private RepositoryContext repository;
|
||||
private boolean renderMd = false;
|
||||
|
||||
@ -54,7 +54,14 @@ public class FileViewActivity extends BaseActivity implements BottomSheetListene
|
||||
if(result.getResultCode() == 200) {
|
||||
assert result.getData() != null;
|
||||
if(result.getData().getBooleanExtra("fileModified", false)) {
|
||||
switch(result.getData().getIntExtra("fileAction", CreateFileActivity.FILE_ACTION_EDIT)) {
|
||||
case CreateFileActivity.FILE_ACTION_CREATE:
|
||||
case CreateFileActivity.FILE_ACTION_EDIT:
|
||||
getSingleFileContents(repository.getOwner(), repository.getName(), file.getPath(), repository.getBranchRef());
|
||||
break;
|
||||
default:
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -70,7 +77,7 @@ public class FileViewActivity extends BaseActivity implements BottomSheetListene
|
||||
setContentView(binding.getRoot());
|
||||
setSupportActionBar(binding.toolbar);
|
||||
|
||||
file = (Files) getIntent().getSerializableExtra("file");
|
||||
file = (ContentsResponse) getIntent().getSerializableExtra("file");
|
||||
|
||||
binding.close.setOnClickListener(view -> finish());
|
||||
|
||||
@ -86,7 +93,7 @@ public class FileViewActivity extends BaseActivity implements BottomSheetListene
|
||||
|
||||
Call<ResponseBody> call = RetrofitClient
|
||||
.getWebInterface(ctx)
|
||||
.getFileContents(getAccount().getWebAuthorization(), owner, repo, ref, filename);
|
||||
.getFileContents(owner, repo, ref, filename);
|
||||
|
||||
try {
|
||||
|
||||
@ -296,7 +303,7 @@ public class FileViewActivity extends BaseActivity implements BottomSheetListene
|
||||
intent.putExtra("fileSha", file.getSha());
|
||||
intent.putExtra("fileContents", binding.contents.getContent());
|
||||
|
||||
ctx.startActivity(intent);
|
||||
editFileLauncher.launch(intent);
|
||||
|
||||
} else {
|
||||
Toasty.error(ctx, getString(R.string.fileTypeCannotBeEdited));
|
||||
@ -346,7 +353,7 @@ public class FileViewActivity extends BaseActivity implements BottomSheetListene
|
||||
|
||||
Call<ResponseBody> call = RetrofitClient
|
||||
.getWebInterface(ctx)
|
||||
.getFileContents(getAccount().getWebAuthorization(), repository.getOwner(), repository.getName(), repository.getBranchRef(), file.getPath());
|
||||
.getFileContents(repository.getOwner(), repository.getName(), repository.getBranchRef(), file.getPath());
|
||||
|
||||
Response<ResponseBody> response = call.execute();
|
||||
|
||||
|
@ -31,15 +31,15 @@ import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.amulyakhare.textdrawable.TextDrawable;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.vdurmont.emoji.EmojiParser;
|
||||
import org.gitnex.tea4j.models.Collaborators;
|
||||
import org.gitnex.tea4j.models.Issues;
|
||||
import org.gitnex.tea4j.models.Labels;
|
||||
import org.gitnex.tea4j.models.PullRequests;
|
||||
import org.gitnex.tea4j.models.UpdateIssueAssignees;
|
||||
import org.gitnex.tea4j.models.UserRepositories;
|
||||
import org.gitnex.tea4j.models.WatchInfo;
|
||||
import org.gitnex.tea4j.v2.models.EditIssueOption;
|
||||
import org.gitnex.tea4j.v2.models.Issue;
|
||||
import org.gitnex.tea4j.v2.models.IssueLabelsOption;
|
||||
import org.gitnex.tea4j.v2.models.Label;
|
||||
import org.gitnex.tea4j.v2.models.PullRequest;
|
||||
import org.gitnex.tea4j.v2.models.Repository;
|
||||
import org.gitnex.tea4j.v2.models.User;
|
||||
import org.gitnex.tea4j.v2.models.WatchInfo;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.actions.AssigneesActions;
|
||||
import org.mian.gitnex.actions.LabelsActions;
|
||||
@ -100,8 +100,8 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
|
||||
private List<Integer> currentLabelsIds = new ArrayList<>();
|
||||
private List<Integer> labelsIds = new ArrayList<>();
|
||||
private final List<Labels> labelsList = new ArrayList<>();
|
||||
private final List<Collaborators> assigneesList = new ArrayList<>();
|
||||
private final List<Label> labelsList = new ArrayList<>();
|
||||
private final List<User> assigneesList = new ArrayList<>();
|
||||
private List<String> assigneesListData = new ArrayList<>();
|
||||
private List<String> currentAssignees = new ArrayList<>();
|
||||
|
||||
@ -112,10 +112,12 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
private CustomAssigneesSelectionDialogBinding assigneesBinding;
|
||||
private ActivityIssueDetailBinding viewBinding;
|
||||
|
||||
public boolean singleIssueUpdate = false;
|
||||
public static boolean singleIssueUpdate = false;
|
||||
public boolean commentEdited = false;
|
||||
public boolean commentPosted = false;
|
||||
|
||||
private IssueCommentsViewModel issueCommentsModel;
|
||||
|
||||
public ActivityResultLauncher<Intent> editIssueLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(),
|
||||
result -> {
|
||||
if(result.getResultCode() == 200) {
|
||||
@ -150,6 +152,8 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
Objects.requireNonNull(getSupportActionBar()).setTitle(repoName);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
issueCommentsModel = new ViewModelProvider(this).get(IssueCommentsViewModel.class);
|
||||
|
||||
viewBinding.recyclerView.setHasFixedSize(true);
|
||||
viewBinding.recyclerView.setNestedScrollingEnabled(false);
|
||||
viewBinding.recyclerView.setLayoutManager(new LinearLayoutManager(ctx));
|
||||
@ -172,8 +176,8 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
viewBinding.pullToRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
|
||||
viewBinding.pullToRefresh.setRefreshing(false);
|
||||
IssueCommentsViewModel
|
||||
.loadIssueComments(getAccount().getAuthorization(), repoOwner, repoName, issueIndex,
|
||||
issueCommentsModel
|
||||
.loadIssueComments(repoOwner, repoName, issueIndex,
|
||||
ctx);
|
||||
|
||||
}, 500));
|
||||
@ -317,18 +321,16 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
|
||||
private void updateIssueAssignees() {
|
||||
|
||||
UpdateIssueAssignees updateAssigneeJson = new UpdateIssueAssignees(assigneesListData);
|
||||
EditIssueOption updateAssigneeJson = new EditIssueOption().assignees(assigneesListData);
|
||||
|
||||
Call<JsonElement> call3;
|
||||
|
||||
call3 = RetrofitClient
|
||||
Call<Issue> call3 = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.patchIssueAssignees(getAccount().getAuthorization(), repoOwner, repoName, issueIndex, updateAssigneeJson);
|
||||
.issueEditIssue(repoOwner, repoName, (long) issueIndex, updateAssigneeJson);
|
||||
|
||||
call3.enqueue(new Callback<JsonElement>() {
|
||||
call3.enqueue(new Callback<Issue>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response2) {
|
||||
public void onResponse(@NonNull Call<Issue> call, @NonNull retrofit2.Response<Issue> response2) {
|
||||
|
||||
if(response2.code() == 201) {
|
||||
|
||||
@ -338,7 +340,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
|
||||
viewBinding.frameAssignees.removeAllViews();
|
||||
viewBinding.frameLabels.removeAllViews();
|
||||
issue.setIssue(null);
|
||||
issue.setIssue(response2.body());
|
||||
getSingleIssue(repoOwner, repoName, issueIndex);
|
||||
currentAssignees.clear();
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> AssigneesActions.getCurrentIssueAssignees(ctx, repoOwner, repoName, issueIndex, currentAssignees), 1000);
|
||||
@ -366,25 +368,30 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<Issue> call, @NonNull Throwable t) {
|
||||
Log.e("onFailure", t.toString());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void updateIssueLabels() {
|
||||
|
||||
Labels patchIssueLabels = new Labels(labelsIds);
|
||||
ArrayList<Long> labelIds = new ArrayList<>();
|
||||
for(Integer i : labelsIds) {
|
||||
labelIds.add((long) i);
|
||||
}
|
||||
|
||||
Call<JsonElement> call = RetrofitClient
|
||||
IssueLabelsOption patchIssueLabels = new IssueLabelsOption();
|
||||
patchIssueLabels.setLabels(labelIds);
|
||||
|
||||
Call<List<Label>> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.updateIssueLabels(getAccount().getAuthorization(), repoOwner, repoName, issueIndex, patchIssueLabels);
|
||||
.issueReplaceLabels(repoOwner, repoName, (long) issueIndex, patchIssueLabels);
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
|
||||
public void onResponse(@NonNull Call<List<Label>> call, @NonNull retrofit2.Response<List<Label>> response) {
|
||||
|
||||
if(response.code() == 200) {
|
||||
|
||||
@ -402,8 +409,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
else if(response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle),
|
||||
getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||
getResources().getString(R.string.cancelButton),
|
||||
getResources().getString(R.string.alertDialogTokenRevokedMessage), getResources().getString(R.string.cancelButton),
|
||||
getResources().getString(R.string.navLogout));
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
@ -422,11 +428,11 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<List<Label>> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -476,8 +482,8 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
|
||||
viewBinding.scrollViewComments.post(() -> {
|
||||
|
||||
IssueCommentsViewModel
|
||||
.loadIssueComments(getAccount().getAuthorization(), repoOwner, repoName, issueIndex,
|
||||
issueCommentsModel
|
||||
.loadIssueComments(repoOwner, repoName, issueIndex,
|
||||
ctx, () -> viewBinding.scrollViewComments.fullScroll(ScrollView.FOCUS_DOWN));
|
||||
|
||||
commentPosted = false;
|
||||
@ -488,8 +494,8 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
|
||||
viewBinding.scrollViewComments.post(() -> {
|
||||
|
||||
IssueCommentsViewModel
|
||||
.loadIssueComments(getAccount().getAuthorization(), repoOwner, repoName, issueIndex,
|
||||
issueCommentsModel
|
||||
.loadIssueComments(repoOwner, repoName, issueIndex,
|
||||
ctx);
|
||||
commentEdited = false;
|
||||
});
|
||||
@ -511,9 +517,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
|
||||
private void fetchDataAsync(String owner, String repo, int index) {
|
||||
|
||||
IssueCommentsViewModel issueCommentsModel = new ViewModelProvider(this).get(IssueCommentsViewModel.class);
|
||||
|
||||
issueCommentsModel.getIssueCommentList(getAccount().getAuthorization(), owner, repo, index, ctx)
|
||||
issueCommentsModel.getIssueCommentList(owner, repo, index, ctx)
|
||||
.observe(this, issueCommentsMain -> {
|
||||
|
||||
assert issueCommentsMain != null;
|
||||
@ -543,18 +547,19 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
return;
|
||||
}
|
||||
|
||||
Call<Issues> call = RetrofitClient.getApiInterface(ctx)
|
||||
.getIssueByIndex(getAccount().getAuthorization(), repoOwner, repoName, issueIndex);
|
||||
Call<Issue> call = RetrofitClient.getApiInterface(ctx)
|
||||
.issueGetIssue(repoOwner, repoName, (long) issueIndex);
|
||||
|
||||
call.enqueue(new Callback<Issues>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Issues> call, @NonNull Response<Issues> response) {
|
||||
public void onResponse(@NonNull Call<Issue> call, @NonNull Response<Issue> response) {
|
||||
|
||||
viewBinding.progressBar.setVisibility(View.GONE);
|
||||
|
||||
if(response.code() == 200) {
|
||||
|
||||
Issues singleIssue = response.body();
|
||||
Issue singleIssue = response.body();
|
||||
assert singleIssue != null;
|
||||
|
||||
issue.setIssue(singleIssue);
|
||||
@ -563,8 +568,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
else if(response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle),
|
||||
getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||
getResources().getString(R.string.cancelButton),
|
||||
getResources().getString(R.string.alertDialogTokenRevokedMessage), getResources().getString(R.string.cancelButton),
|
||||
getResources().getString(R.string.navLogout));
|
||||
|
||||
}
|
||||
@ -576,7 +580,8 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Issues> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<Issue> call, @NonNull Throwable t) {
|
||||
|
||||
viewBinding.progressBar.setVisibility(View.GONE);
|
||||
Log.e("onFailure", t.toString());
|
||||
}
|
||||
@ -589,20 +594,24 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
|
||||
private void getSubscribed() {
|
||||
RetrofitClient.getApiInterface(ctx)
|
||||
.checkIssueWatchStatus(getAccount().getAuthorization(), repoOwner, repoName, issueIndex)
|
||||
.enqueue(new Callback<WatchInfo>() {
|
||||
.issueCheckSubscription(repoOwner, repoName, (long) issueIndex)
|
||||
.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<WatchInfo> call, @NonNull Response<WatchInfo> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
assert response.body() != null;
|
||||
issue.setSubscribed(response.body().getSubscribed());
|
||||
} else {
|
||||
issue.setSubscribed(response.body().isSubscribed());
|
||||
}
|
||||
else {
|
||||
issue.setSubscribed(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<WatchInfo> call, @NonNull Throwable t) {
|
||||
|
||||
issue.setSubscribed(false);
|
||||
}
|
||||
});
|
||||
@ -615,14 +624,14 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
|
||||
viewBinding.issuePrState.setVisibility(View.VISIBLE);
|
||||
|
||||
if(issue.getIssue().getPull_request() != null) {
|
||||
if(issue.getIssue().getPullRequest() != null) {
|
||||
getPullRequest();
|
||||
if(issue.getIssue().getPull_request().isMerged()) { // merged
|
||||
if(issue.getIssue().getPullRequest().isMerged()) { // merged
|
||||
|
||||
viewBinding.issuePrState.setImageResource(R.drawable.ic_pull_request);
|
||||
ImageViewCompat.setImageTintList(viewBinding.issuePrState, ColorStateList.valueOf(ctx.getResources().getColor(R.color.iconPrMergedColor)));
|
||||
}
|
||||
else if(!issue.getIssue().getPull_request().isMerged() && issue.getIssue().getState().equals("closed")) { // closed
|
||||
else if(!issue.getIssue().getPullRequest().isMerged() && issue.getIssue().getState().equals("closed")) { // closed
|
||||
|
||||
viewBinding.issuePrState.setImageResource(R.drawable.ic_pull_request);
|
||||
ImageViewCompat.setImageTintList(viewBinding.issuePrState, ColorStateList.valueOf(ctx.getResources().getColor(R.color.iconIssuePrClosedColor)));
|
||||
@ -630,6 +639,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
else { // open
|
||||
|
||||
viewBinding.issuePrState.setImageResource(R.drawable.ic_pull_request);
|
||||
ImageViewCompat.setImageTintList(viewBinding.issuePrState, ColorStateList.valueOf(ctx.getResources().getColor(R.color.darkGreen)));
|
||||
}
|
||||
}
|
||||
else if(issue.getIssue().getState().equals("closed")) { // issue closed
|
||||
@ -638,6 +648,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
ImageViewCompat.setImageTintList(viewBinding.issuePrState, ColorStateList.valueOf(ctx.getResources().getColor(R.color.iconIssuePrClosedColor)));
|
||||
} else {
|
||||
viewBinding.issuePrState.setImageResource(R.drawable.ic_issue);
|
||||
ImageViewCompat.setImageTintList(viewBinding.issuePrState, ColorStateList.valueOf(ctx.getResources().getColor(R.color.darkGreen)));
|
||||
}
|
||||
|
||||
TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||
@ -645,7 +656,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
final String timeFormat = tinyDb.getString("dateFormat", "pretty");
|
||||
issueCreator = issue.getIssue().getUser().getLogin();
|
||||
|
||||
PicassoService.getInstance(ctx).get().load(issue.getIssue().getUser().getAvatar_url()).placeholder(R.drawable.loader_animated)
|
||||
PicassoService.getInstance(ctx).get().load(issue.getIssue().getUser().getAvatarUrl()).placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(viewBinding.assigneeAvatar);
|
||||
String issueNumber_ = "<font color='" + ResourcesCompat.getColor(getResources(), R.color.lightGray, null) + "'>" + appCtx.getResources()
|
||||
.getString(R.string.hash) + issue.getIssue().getNumber() + "</font>";
|
||||
@ -678,7 +689,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
|
||||
ImageView assigneesView = new ImageView(ctx);
|
||||
|
||||
PicassoService.getInstance(ctx).get().load(issue.getIssue().getAssignees().get(i).getAvatar_url())
|
||||
PicassoService.getInstance(ctx).get().load(issue.getIssue().getAssignees().get(i).getAvatarUrl())
|
||||
.placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(100, 100).centerCrop()
|
||||
.into(assigneesView);
|
||||
|
||||
@ -750,20 +761,20 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
viewBinding.labelsScrollView.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if(issue.getIssue().getDue_date() != null) {
|
||||
if(issue.getIssue().getDueDate() != null) {
|
||||
|
||||
if(timeFormat.equals("normal") || timeFormat.equals("pretty")) {
|
||||
|
||||
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd", locale);
|
||||
String dueDate = formatter.format(issue.getIssue().getDue_date());
|
||||
String dueDate = formatter.format(issue.getIssue().getDueDate());
|
||||
viewBinding.issueDueDate.setText(dueDate);
|
||||
viewBinding.issueDueDate
|
||||
.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(issue.getIssue().getDue_date()), ctx));
|
||||
.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(issue.getIssue().getDueDate()), ctx));
|
||||
}
|
||||
else if(timeFormat.equals("normal1")) {
|
||||
|
||||
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy", locale);
|
||||
String dueDate = formatter.format(issue.getIssue().getDue_date());
|
||||
String dueDate = formatter.format(issue.getIssue().getDueDate());
|
||||
viewBinding.issueDueDate.setText(dueDate);
|
||||
}
|
||||
}
|
||||
@ -774,25 +785,25 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
|
||||
String edited;
|
||||
|
||||
if(!issue.getIssue().getUpdated_at().equals(issue.getIssue().getCreated_at())) {
|
||||
if(!issue.getIssue().getUpdatedAt().equals(issue.getIssue().getUpdatedAt())) {
|
||||
|
||||
edited = getString(R.string.colorfulBulletSpan) + getString(R.string.modifiedText);
|
||||
viewBinding.issueModified.setVisibility(View.VISIBLE);
|
||||
viewBinding.issueModified.setText(edited);
|
||||
viewBinding.issueModified
|
||||
.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(issue.getIssue().getUpdated_at()), ctx));
|
||||
.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(issue.getIssue().getUpdatedAt()), ctx));
|
||||
}
|
||||
else {
|
||||
|
||||
viewBinding.issueModified.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
if((issue.getIssue().getDue_date() == null && issue.getIssue().getMilestone() == null) && issue.getIssue().getAssignees() != null) {
|
||||
if((issue.getIssue().getDueDate() == null && issue.getIssue().getMilestone() == null) && issue.getIssue().getAssignees() != null) {
|
||||
|
||||
paramsDesc.setMargins(0, 35, 0, 0);
|
||||
viewBinding.issueDescription.setLayoutParams(paramsDesc);
|
||||
}
|
||||
else if(issue.getIssue().getDue_date() == null && issue.getIssue().getMilestone() == null) {
|
||||
else if(issue.getIssue().getDueDate() == null && issue.getIssue().getMilestone() == null) {
|
||||
|
||||
paramsDesc.setMargins(0, 55, 0, 0);
|
||||
viewBinding.issueDescription.setLayoutParams(paramsDesc);
|
||||
@ -808,19 +819,19 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
viewBinding.issueDescription.setLayoutParams(paramsDesc);
|
||||
}
|
||||
|
||||
viewBinding.issueCreatedTime.setText(TimeHelper.formatTime(issue.getIssue().getCreated_at(), locale, timeFormat, ctx));
|
||||
viewBinding.issueCreatedTime.setText(TimeHelper.formatTime(issue.getIssue().getCreatedAt(), locale, timeFormat, ctx));
|
||||
viewBinding.issueCreatedTime.setVisibility(View.VISIBLE);
|
||||
|
||||
if(timeFormat.equals("pretty")) {
|
||||
|
||||
viewBinding.issueCreatedTime
|
||||
.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(issue.getIssue().getCreated_at()), ctx));
|
||||
.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(issue.getIssue().getCreatedAt()), ctx));
|
||||
}
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("repoOwner", repoOwner);
|
||||
bundle.putString("repoName", repoName);
|
||||
bundle.putInt("issueId", issue.getIssue().getNumber());
|
||||
bundle.putInt("issueId", Math.toIntExact(issue.getIssue().getNumber()));
|
||||
|
||||
ReactionList reactionList = new ReactionList(ctx, bundle);
|
||||
|
||||
@ -857,30 +868,29 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
}
|
||||
|
||||
private void getPullRequest() {
|
||||
RetrofitClient.getApiInterface(this).getPullRequestByIndex(getAccount().getAuthorization(), repoOwner, repoName, issueIndex).enqueue(new Callback<PullRequests>() {
|
||||
RetrofitClient.getApiInterface(this).repoGetPullRequest(repoOwner, repoName, (long) issueIndex).enqueue(new Callback<PullRequest>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<PullRequests> call, @NonNull Response<PullRequests> response) {
|
||||
public void onResponse(@NonNull Call<PullRequest> call, @NonNull Response<PullRequest> response) {
|
||||
if(response.isSuccessful() && response.body() != null) {
|
||||
issue.setPullRequest(response.body());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<PullRequests> call, @NonNull Throwable t) {
|
||||
|
||||
public void onFailure(@NonNull Call<PullRequest> call, @NonNull Throwable t) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void getRepoInfo() {
|
||||
Call<UserRepositories> call = RetrofitClient.getApiInterface(ctx).getUserRepository(getAccount().getAuthorization(), issue.getRepository().getOwner(), issue.getRepository().getName());
|
||||
call.enqueue(new Callback<UserRepositories>() {
|
||||
Call<Repository> call = RetrofitClient.getApiInterface(ctx).repoGet(issue.getRepository().getOwner(), issue.getRepository().getName());
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<UserRepositories> call, @NonNull retrofit2.Response<UserRepositories> response) {
|
||||
public void onResponse(@NonNull Call<Repository> call, @NonNull retrofit2.Response<Repository> response) {
|
||||
|
||||
UserRepositories repoInfo = response.body();
|
||||
Repository repoInfo = response.body();
|
||||
|
||||
if(response.code() == 200) {
|
||||
assert repoInfo != null;
|
||||
@ -888,18 +898,14 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
||||
}
|
||||
else {
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
Log.e("onFailure", String.valueOf(response.code()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<UserRepositories> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<Repository> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
Log.e("onFailure", t.toString());
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package org.mian.gitnex.activities;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.AutoCompleteTextView;
|
||||
@ -11,10 +10,10 @@ import android.widget.EditText;
|
||||
import android.widget.RadioGroup;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import org.gitnex.tea4j.ApiInterface;
|
||||
import org.gitnex.tea4j.models.GiteaVersion;
|
||||
import org.gitnex.tea4j.models.UserInfo;
|
||||
import org.gitnex.tea4j.models.UserTokens;
|
||||
import org.gitnex.tea4j.v2.models.AccessToken;
|
||||
import org.gitnex.tea4j.v2.models.CreateAccessTokenOption;
|
||||
import org.gitnex.tea4j.v2.models.ServerVersion;
|
||||
import org.gitnex.tea4j.v2.models.User;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.database.api.BaseApi;
|
||||
@ -38,7 +37,7 @@ import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class LoginActivity extends BaseActivity {
|
||||
@ -201,7 +200,6 @@ public class LoginActivity extends BaseActivity {
|
||||
}
|
||||
catch(Exception e) {
|
||||
|
||||
Log.e("onFailure-login", e.toString());
|
||||
Toasty.error(ctx, getResources().getString(R.string.malformedUrl));
|
||||
enableProcessButton();
|
||||
}
|
||||
@ -210,35 +208,33 @@ public class LoginActivity extends BaseActivity {
|
||||
private void versionCheck(final String loginUid, final String loginPass, final int loginOTP, final String loginToken,
|
||||
final LoginType loginType) {
|
||||
|
||||
Call<GiteaVersion> callVersion;
|
||||
Call<ServerVersion> callVersion;
|
||||
|
||||
if(!loginToken.equals("")) {
|
||||
|
||||
callVersion = RetrofitClient.getApiInterface(ctx).getGiteaVersionWithToken("token " + loginToken);
|
||||
callVersion = RetrofitClient.getApiInterface(ctx, instanceUrl.toString(), "token " + loginToken).getVersion();
|
||||
}
|
||||
else {
|
||||
|
||||
String credential = Credentials.basic(loginUid, loginPass, StandardCharsets.UTF_8);
|
||||
|
||||
ApiInterface apiClient = RetrofitClient.getApiInterface(ctx);
|
||||
|
||||
if (loginOTP != 0) {
|
||||
|
||||
callVersion = apiClient.getGiteaVersionWithOTP(credential, loginOTP);
|
||||
callVersion = RetrofitClient.getApiInterface(ctx, instanceUrl.toString(), credential).getVersion(loginOTP);
|
||||
} else {
|
||||
|
||||
callVersion = apiClient.getGiteaVersionWithBasic(credential);
|
||||
callVersion = RetrofitClient.getApiInterface(ctx, instanceUrl.toString(), credential).getVersion();
|
||||
}
|
||||
}
|
||||
|
||||
callVersion.enqueue(new Callback<GiteaVersion>() {
|
||||
callVersion.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull final Call<GiteaVersion> callVersion, @NonNull retrofit2.Response<GiteaVersion> responseVersion) {
|
||||
public void onResponse(@NonNull final Call<ServerVersion> callVersion, @NonNull retrofit2.Response<ServerVersion> responseVersion) {
|
||||
|
||||
if(responseVersion.code() == 200) {
|
||||
|
||||
GiteaVersion version = responseVersion.body();
|
||||
ServerVersion version = responseVersion.body();
|
||||
assert version != null;
|
||||
|
||||
if(!Version.valid(version.getVersion())) {
|
||||
@ -252,10 +248,8 @@ public class LoginActivity extends BaseActivity {
|
||||
|
||||
if(giteaVersion.less(getString(R.string.versionLow))) {
|
||||
|
||||
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ctx)
|
||||
.setTitle(getString(R.string.versionAlertDialogHeader))
|
||||
.setMessage(getResources().getString(R.string.versionUnsupportedOld, version.getVersion()))
|
||||
.setIcon(R.drawable.ic_warning)
|
||||
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ctx).setTitle(getString(R.string.versionAlertDialogHeader))
|
||||
.setMessage(getResources().getString(R.string.versionUnsupportedOld, version.getVersion())).setIcon(R.drawable.ic_warning)
|
||||
.setCancelable(true);
|
||||
|
||||
alertDialogBuilder.setNeutralButton(getString(R.string.cancelButton), (dialog, which) -> {
|
||||
@ -307,7 +301,7 @@ public class LoginActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<GiteaVersion> callVersion, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<ServerVersion> callVersion, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.genericServerResponseError));
|
||||
enableProcessButton();
|
||||
@ -317,14 +311,14 @@ public class LoginActivity extends BaseActivity {
|
||||
|
||||
private void setupUsingExistingToken(final String loginToken) {
|
||||
|
||||
Call<UserInfo> call = RetrofitClient.getApiInterface(ctx).getUserInfo("token " + loginToken);
|
||||
Call<User> call = RetrofitClient.getApiInterface(ctx, instanceUrl.toString(), "token " + loginToken).userGetCurrent();
|
||||
|
||||
call.enqueue(new Callback<UserInfo>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<UserInfo> call, @NonNull retrofit2.Response<UserInfo> response) {
|
||||
public void onResponse(@NonNull Call<User> call, @NonNull retrofit2.Response<User> response) {
|
||||
|
||||
UserInfo userDetails = response.body();
|
||||
User userDetails = response.body();
|
||||
|
||||
switch(response.code()) {
|
||||
|
||||
@ -333,13 +327,13 @@ public class LoginActivity extends BaseActivity {
|
||||
assert userDetails != null;
|
||||
|
||||
// insert new account to db if does not exist
|
||||
String accountName = userDetails.getUsername() + "@" + instanceUrl;
|
||||
String accountName = userDetails.getLogin() + "@" + instanceUrl;
|
||||
UserAccountsApi userAccountsApi = BaseApi.getInstance(ctx, UserAccountsApi.class);
|
||||
assert userAccountsApi != null;
|
||||
boolean userAccountExists = userAccountsApi.userAccountExists(accountName);
|
||||
UserAccount account;
|
||||
if(!userAccountExists) {
|
||||
long accountId = userAccountsApi.createNewAccount(accountName, instanceUrl.toString(), userDetails.getUsername(), loginToken, giteaVersion.toString());
|
||||
long accountId = userAccountsApi.createNewAccount(accountName, instanceUrl.toString(), userDetails.getLogin(), loginToken, giteaVersion.toString());
|
||||
account = userAccountsApi.getAccountById((int) accountId);
|
||||
}
|
||||
else {
|
||||
@ -367,10 +361,9 @@ public class LoginActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<UserInfo> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<User> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
Toasty.error(ctx, getResources().getString(R.string.genericError));
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
enableProcessButton();
|
||||
}
|
||||
});
|
||||
@ -382,49 +375,49 @@ public class LoginActivity extends BaseActivity {
|
||||
final String credential = Credentials.basic(loginUid, loginPass, StandardCharsets.UTF_8);
|
||||
final String tokenName = "gitnex-app-" + device_id;
|
||||
|
||||
Call<List<UserTokens>> call;
|
||||
Call<List<AccessToken>> call;
|
||||
if(loginOTP != 0) {
|
||||
|
||||
call = RetrofitClient.getApiInterface(ctx).getUserTokensWithOTP(credential, loginOTP, loginUid);
|
||||
call = RetrofitClient.getApiInterface(ctx, instanceUrl.toString(), credential).userGetTokens(loginOTP, loginUid, null, null);
|
||||
}
|
||||
else {
|
||||
|
||||
call = RetrofitClient.getApiInterface(ctx).getUserTokens(credential, loginUid);
|
||||
call = RetrofitClient.getApiInterface(ctx, instanceUrl.toString(), credential).userGetTokens(loginUid, null, null);
|
||||
}
|
||||
|
||||
call.enqueue(new Callback<List<UserTokens>>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<UserTokens>> call, @NonNull retrofit2.Response<List<UserTokens>> response) {
|
||||
public void onResponse(@NonNull Call<List<AccessToken>> call, @NonNull retrofit2.Response<List<AccessToken>> response) {
|
||||
|
||||
List<UserTokens> userTokens = response.body();
|
||||
List<AccessToken> userTokens = response.body();
|
||||
|
||||
if(response.code() == 200) {
|
||||
|
||||
assert userTokens != null;
|
||||
|
||||
for(UserTokens t : userTokens) {
|
||||
for(AccessToken t : userTokens) {
|
||||
|
||||
if(t.getName().equals(tokenName)) {
|
||||
|
||||
// this app had created an token on this instance before
|
||||
// -> since it looks like GitNex forgot the secret we have to delete it first
|
||||
|
||||
Call<Void> delcall;
|
||||
Call<Void> delToken;
|
||||
if(loginOTP != 0) {
|
||||
|
||||
delcall = RetrofitClient.getApiInterface(ctx)
|
||||
.deleteTokenWithOTP(credential, loginOTP, loginUid, t.getId());
|
||||
delToken = RetrofitClient.getApiInterface(ctx, instanceUrl.toString(), credential)
|
||||
.userDeleteAccessToken(loginOTP, loginUid, String.valueOf(t.getId()));
|
||||
}
|
||||
else {
|
||||
|
||||
delcall = RetrofitClient.getApiInterface(ctx).deleteToken(credential, loginUid, t.getId());
|
||||
delToken = RetrofitClient.getApiInterface(ctx, instanceUrl.toString(), credential).userDeleteAccessToken(loginUid, String.valueOf(t.getId()));
|
||||
}
|
||||
|
||||
delcall.enqueue(new Callback<Void>() {
|
||||
delToken.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> delcall, @NonNull retrofit2.Response<Void> response) {
|
||||
public void onResponse(@NonNull Call<Void> delToken, @NonNull retrofit2.Response<Void> response) {
|
||||
|
||||
if(response.code() == 204) {
|
||||
|
||||
@ -438,9 +431,8 @@ public class LoginActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> delcall, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<Void> delToken, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure-login", t.toString());
|
||||
Toasty.error(ctx, getResources().getString(R.string.malformedJson));
|
||||
enableProcessButton();
|
||||
}
|
||||
@ -459,9 +451,8 @@ public class LoginActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<UserTokens>> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<List<AccessToken>> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure-login", t.toString());
|
||||
Toasty.error(ctx, getResources().getString(R.string.malformedJson));
|
||||
enableProcessButton();
|
||||
}
|
||||
@ -473,41 +464,40 @@ public class LoginActivity extends BaseActivity {
|
||||
|
||||
final String credential = Credentials.basic(loginUid, loginPass, StandardCharsets.UTF_8);
|
||||
|
||||
UserTokens createUserToken = new UserTokens(tokenName);
|
||||
Call<UserTokens> callCreateToken;
|
||||
CreateAccessTokenOption createUserToken = new CreateAccessTokenOption().name(tokenName);
|
||||
Call<AccessToken> callCreateToken;
|
||||
|
||||
if(loginOTP != 0) {
|
||||
|
||||
callCreateToken = RetrofitClient.getApiInterface(ctx)
|
||||
.createNewTokenWithOTP(credential, loginOTP, loginUid, createUserToken);
|
||||
callCreateToken = RetrofitClient.getApiInterface(ctx, instanceUrl.toString(), credential)
|
||||
.userCreateToken(loginOTP, loginUid, createUserToken);
|
||||
}
|
||||
else {
|
||||
|
||||
callCreateToken = RetrofitClient.getApiInterface(ctx)
|
||||
.createNewToken(credential, loginUid, createUserToken);
|
||||
callCreateToken = RetrofitClient.getApiInterface(ctx, instanceUrl.toString(), credential)
|
||||
.userCreateToken(loginUid, createUserToken);
|
||||
}
|
||||
|
||||
callCreateToken.enqueue(new Callback<UserTokens>() {
|
||||
callCreateToken.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<UserTokens> callCreateToken, @NonNull retrofit2.Response<UserTokens> responseCreate) {
|
||||
public void onResponse(@NonNull Call<AccessToken> callCreateToken, @NonNull retrofit2.Response<AccessToken> responseCreate) {
|
||||
|
||||
if(responseCreate.code() == 201) {
|
||||
|
||||
UserTokens newToken = responseCreate.body();
|
||||
AccessToken newToken = responseCreate.body();
|
||||
assert newToken != null;
|
||||
|
||||
if(!newToken.getSha1().equals("")) {
|
||||
|
||||
Call<UserInfo> call = RetrofitClient.getApiInterface(ctx)
|
||||
.getUserInfo("token " + newToken.getSha1());
|
||||
Call<User> call = RetrofitClient.getApiInterface(ctx, instanceUrl.toString(), "token " + newToken.getSha1()).userGetCurrent();
|
||||
|
||||
call.enqueue(new Callback<UserInfo>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<UserInfo> call, @NonNull retrofit2.Response<UserInfo> response) {
|
||||
public void onResponse(@NonNull Call<User> call, @NonNull retrofit2.Response<User> response) {
|
||||
|
||||
UserInfo userDetails = response.body();
|
||||
User userDetails = response.body();
|
||||
|
||||
switch(response.code()) {
|
||||
|
||||
@ -516,7 +506,7 @@ public class LoginActivity extends BaseActivity {
|
||||
assert userDetails != null;
|
||||
|
||||
// insert new account to db if does not exist
|
||||
String accountName = userDetails.getUsername() + "@" + instanceUrl;
|
||||
String accountName = userDetails.getLogin() + "@" + instanceUrl;
|
||||
UserAccountsApi userAccountsApi = BaseApi.getInstance(ctx, UserAccountsApi.class);
|
||||
assert userAccountsApi != null;
|
||||
boolean userAccountExists = userAccountsApi.userAccountExists(accountName);
|
||||
@ -524,7 +514,8 @@ public class LoginActivity extends BaseActivity {
|
||||
UserAccount account;
|
||||
if(!userAccountExists) {
|
||||
long accountId = userAccountsApi
|
||||
.createNewAccount(accountName, instanceUrl.toString(), userDetails.getUsername(), newToken.getSha1(), giteaVersion.toString());
|
||||
.createNewAccount(accountName, instanceUrl.toString(), userDetails.getLogin(), newToken.getSha1(),
|
||||
giteaVersion.toString());
|
||||
account = userAccountsApi.getAccountById((int) accountId);
|
||||
}
|
||||
else {
|
||||
@ -550,9 +541,8 @@ public class LoginActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<UserInfo> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<User> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
Toasty.error(ctx, getResources().getString(R.string.genericError));
|
||||
enableProcessButton();
|
||||
}
|
||||
@ -567,9 +557,9 @@ public class LoginActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<UserTokens> createUserToken, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<AccessToken> createUserToken, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure-token", t.toString());
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -23,9 +23,9 @@ import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.google.android.material.navigation.NavigationView;
|
||||
import org.gitnex.tea4j.models.GiteaVersion;
|
||||
import org.gitnex.tea4j.models.NotificationCount;
|
||||
import org.gitnex.tea4j.models.UserInfo;
|
||||
import org.gitnex.tea4j.v2.models.NotificationCount;
|
||||
import org.gitnex.tea4j.v2.models.ServerVersion;
|
||||
import org.gitnex.tea4j.v2.models.User;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.UserAccountsNavAdapter;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
@ -68,13 +68,13 @@ import retrofit2.Callback;
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public class MainActivity extends BaseActivity implements NavigationView.OnNavigationItemSelectedListener, BottomSheetListener {
|
||||
|
||||
public static boolean refActivity = false;
|
||||
public static boolean repoCreated = false;
|
||||
|
||||
private DrawerLayout drawer;
|
||||
private TextView toolbarTitle;
|
||||
private Typeface myTypeface;
|
||||
|
||||
private String instanceToken;
|
||||
private boolean noConnection = false;
|
||||
|
||||
private View hView;
|
||||
@ -112,7 +112,6 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
return;
|
||||
}
|
||||
|
||||
instanceToken = getAccount().getAuthorization();
|
||||
noConnection = false;
|
||||
|
||||
Toolbar toolbar = activityMainBinding.toolbar;
|
||||
@ -170,7 +169,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
toolbarTitle.setText(getResources().getString(R.string.navMyIssues));
|
||||
}
|
||||
|
||||
getNotificationsCount(instanceToken);
|
||||
getNotificationsCount();
|
||||
|
||||
drawer = activityMainBinding.drawerLayout;
|
||||
navigationView = activityMainBinding.navView;
|
||||
@ -207,7 +206,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
RecyclerView navRecyclerViewUserAccounts = hView.findViewById(R.id.userAccounts);
|
||||
UserAccountsNavAdapter adapterUserAccounts = new UserAccountsNavAdapter(ctx, userAccountsList, drawer);
|
||||
|
||||
userAccountsApi.getAllLoggedInAccounts().observe((AppCompatActivity) ctx, userAccounts -> {
|
||||
userAccountsApi.getAllAccounts().observe((AppCompatActivity) ctx, userAccounts -> {
|
||||
if(userAccounts.size() > 0) {
|
||||
userAccountsList.clear();
|
||||
userAccountsList.addAll(userAccounts);
|
||||
@ -222,7 +221,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
if (getAccount().getUserInfo() != null) {
|
||||
String userEmailNav = getAccount().getUserInfo().getEmail();
|
||||
String userFullNameNav = getAccount().getFullName();
|
||||
String userAvatarNav = getAccount().getUserInfo().getAvatar();
|
||||
String userAvatarNav = getAccount().getUserInfo().getAvatarUrl();
|
||||
|
||||
if(!userEmailNav.equals("")) {
|
||||
userEmail.setText(userEmailNav);
|
||||
@ -267,14 +266,14 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
|
||||
});
|
||||
|
||||
getNotificationsCount(instanceToken);
|
||||
getNotificationsCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDrawerSlide(@NonNull View drawerView, float slideOffset) {
|
||||
|
||||
if (getAccount().getUserInfo() != null) {
|
||||
navigationView.getMenu().findItem(R.id.nav_administration).setVisible(getAccount().getUserInfo().getIs_admin());
|
||||
navigationView.getMenu().findItem(R.id.nav_administration).setVisible(getAccount().getUserInfo().isIsAdmin());
|
||||
} else {
|
||||
// hide first
|
||||
navigationView.getMenu().findItem(R.id.nav_administration).setVisible(false);
|
||||
@ -456,6 +455,17 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
if(refActivity) {
|
||||
this.recreate();
|
||||
this.overridePendingTransition(0, 0);
|
||||
refActivity = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void setActionBarTitle(String title) {
|
||||
|
||||
toolbarTitle.setText(title);
|
||||
@ -619,11 +629,11 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
|
||||
private void giteaVersion() {
|
||||
|
||||
Call<GiteaVersion> callVersion = RetrofitClient.getApiInterface(ctx).getGiteaVersionWithToken(getAccount().getAuthorization());
|
||||
callVersion.enqueue(new Callback<GiteaVersion>() {
|
||||
Call<ServerVersion> callVersion = RetrofitClient.getApiInterface(ctx).getVersion();
|
||||
callVersion.enqueue(new Callback<ServerVersion>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull final Call<GiteaVersion> callVersion, @NonNull retrofit2.Response<GiteaVersion> responseVersion) {
|
||||
public void onResponse(@NonNull final Call<ServerVersion> callVersion, @NonNull retrofit2.Response<ServerVersion> responseVersion) {
|
||||
|
||||
if(responseVersion.code() == 200 && responseVersion.body() != null) {
|
||||
String version = responseVersion.body().getVersion();
|
||||
@ -634,21 +644,21 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<GiteaVersion> callVersion, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<ServerVersion> callVersion, @NonNull Throwable t) {
|
||||
Log.e("onFailure-version", t.toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void loadUserInfo() {
|
||||
Call<UserInfo> call = RetrofitClient.getApiInterface(ctx).getUserInfo(getAccount().getAuthorization());
|
||||
Call<User> call = RetrofitClient.getApiInterface(ctx).userGetCurrent();
|
||||
|
||||
call.enqueue(new Callback<UserInfo>() {
|
||||
call.enqueue(new Callback<User>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<UserInfo> call, @NonNull retrofit2.Response<UserInfo> response) {
|
||||
public void onResponse(@NonNull Call<User> call, @NonNull retrofit2.Response<User> response) {
|
||||
|
||||
UserInfo userDetails = response.body();
|
||||
User userDetails = response.body();
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
|
||||
@ -657,12 +667,12 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
assert userDetails != null;
|
||||
|
||||
getAccount().setUserInfo(userDetails);
|
||||
navigationView.getMenu().findItem(R.id.nav_administration).setVisible(userDetails.getIs_admin());
|
||||
if(!getAccount().getAccount().getUserName().equals(userDetails.getUsername())) {
|
||||
navigationView.getMenu().findItem(R.id.nav_administration).setVisible(userDetails.isIsAdmin());
|
||||
if(!getAccount().getAccount().getUserName().equals(userDetails.getLogin())) {
|
||||
// user changed it's name -> update database
|
||||
int accountId = getAccount().getAccount().getAccountId();
|
||||
BaseApi.getInstance(MainActivity.this, UserAccountsApi.class).updateUsername(accountId,
|
||||
userDetails.getUsername());
|
||||
userDetails.getLogin());
|
||||
getAccount().setAccount(BaseApi.getInstance(MainActivity.this, UserAccountsApi.class).getAccountById(accountId));
|
||||
}
|
||||
if(profileInitListener != null) profileInitListener.onButtonClicked(null);
|
||||
@ -680,7 +690,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<UserInfo> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<User> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
}
|
||||
@ -688,11 +698,11 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
|
||||
}
|
||||
|
||||
private void getNotificationsCount(String token) {
|
||||
private void getNotificationsCount() {
|
||||
|
||||
Call<NotificationCount> call = RetrofitClient.getApiInterface(ctx).checkUnreadNotifications(token);
|
||||
Call<NotificationCount> call = RetrofitClient.getApiInterface(ctx).notifyNewAvailable();
|
||||
|
||||
call.enqueue(new Callback<NotificationCount>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<NotificationCount> call, @NonNull retrofit2.Response<NotificationCount> response) {
|
||||
@ -703,7 +713,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
|
||||
assert notificationCount != null;
|
||||
notificationCounter = navNotifications.getActionView().findViewById(R.id.counterBadgeNotification);
|
||||
notificationCounter.setText(String.valueOf(notificationCount.getCounter()));
|
||||
notificationCounter.setText(String.valueOf(notificationCount.getNew()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,13 +4,11 @@ import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.ArrayAdapter;
|
||||
import androidx.annotation.NonNull;
|
||||
import org.gitnex.tea4j.models.MergePullRequest;
|
||||
import org.gitnex.tea4j.models.MergePullRequestSpinner;
|
||||
import org.gitnex.tea4j.v2.models.MergePullRequestOption;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.actions.PullRequestActions;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
@ -18,6 +16,7 @@ import org.mian.gitnex.databinding.ActivityMergePullRequestBinding;
|
||||
import org.mian.gitnex.fragments.PullRequestsFragment;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.MergePullRequestSpinner;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.contexts.IssueContext;
|
||||
import java.util.ArrayList;
|
||||
@ -26,17 +25,14 @@ import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class MergePullRequestActivity extends BaseActivity {
|
||||
|
||||
private View.OnClickListener onClickListener;
|
||||
|
||||
private IssueContext issue;
|
||||
|
||||
private ActivityMergePullRequestBinding viewBinding;
|
||||
|
||||
private String Do;
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@ -107,7 +103,6 @@ public class MergePullRequestActivity extends BaseActivity {
|
||||
viewBinding.deleteBranch.setVisibility(View.GONE);
|
||||
viewBinding.deleteBranchForkInfo.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void setMergeAdapter() {
|
||||
@ -130,7 +125,6 @@ public class MergePullRequestActivity extends BaseActivity {
|
||||
|
||||
Do = mergeList.get(position).getId();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void initCloseListener() {
|
||||
@ -167,11 +161,28 @@ public class MergePullRequestActivity extends BaseActivity {
|
||||
|
||||
private void mergeFunction(String Do, String mergePRDT, String mergeTitle, boolean deleteBranch) {
|
||||
|
||||
MergePullRequest mergePR = new MergePullRequest(Do, mergePRDT, mergeTitle);
|
||||
MergePullRequestOption mergePR = new MergePullRequestOption();
|
||||
mergePR.setDeleteBranchAfterMerge(deleteBranch);
|
||||
mergePR.setMergeTitleField(mergeTitle);
|
||||
mergePR.setMergeMessageField(mergePRDT);
|
||||
switch(Do) {
|
||||
case "merge":
|
||||
mergePR.setDo(MergePullRequestOption.DoEnum.MERGE);
|
||||
break;
|
||||
case "rebase":
|
||||
mergePR.setDo(MergePullRequestOption.DoEnum.REBASE);
|
||||
break;
|
||||
case "rebase-merge":
|
||||
mergePR.setDo(MergePullRequestOption.DoEnum.REBASE_MERGE);
|
||||
break;
|
||||
case "squash":
|
||||
mergePR.setDo(MergePullRequestOption.DoEnum.SQUASH);
|
||||
break;
|
||||
}
|
||||
|
||||
Call<Void> call = RetrofitClient.getApiInterface(ctx).mergePullRequest(getAccount().getAuthorization(), issue.getRepository().getOwner(), issue.getRepository().getName(), issue.getIssueIndex(), mergePR);
|
||||
Call<Void> call = RetrofitClient.getApiInterface(ctx).repoMergePullRequest(issue.getRepository().getOwner(), issue.getRepository().getName(), (long) issue.getIssueIndex(), mergePR);
|
||||
|
||||
call.enqueue(new Callback<Void>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
@ -181,7 +192,7 @@ public class MergePullRequestActivity extends BaseActivity {
|
||||
if(deleteBranch) {
|
||||
|
||||
if(issue.prIsFork()) {
|
||||
String repoFullName = issue.getPullRequest().getHead().getRepo().getFull_name();
|
||||
String repoFullName = issue.getPullRequest().getHead().getRepo().getFullName();
|
||||
String[] parts = repoFullName.split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
@ -189,21 +200,25 @@ public class MergePullRequestActivity extends BaseActivity {
|
||||
PullRequestActions.deleteHeadBranch(ctx, repoOwner, repoName, issue.getPullRequest().getHead().getRef(), false);
|
||||
}
|
||||
else {
|
||||
PullRequestActions.deleteHeadBranch(ctx, issue.getRepository().getOwner(), issue.getRepository().getName(), issue.getPullRequest().getHead().getRef(), false);
|
||||
PullRequestActions.deleteHeadBranch(ctx, issue.getRepository().getOwner(), issue.getRepository().getName(),
|
||||
issue.getPullRequest().getHead().getRef(), false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Toasty.success(ctx, getString(R.string.mergePRSuccessMsg));
|
||||
Intent result = new Intent();
|
||||
PullRequestsFragment.resumePullRequests = true;
|
||||
IssueDetailActivity.singleIssueUpdate = true;
|
||||
RepoDetailActivity.updateRepo = true;
|
||||
setResult(200, result);
|
||||
finish();
|
||||
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
enableProcessButton();
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle), getResources().getString(R.string.alertDialogTokenRevokedMessage), getResources().getString(R.string.cancelButton), getResources().getString(R.string.navLogout));
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle), getResources().getString(R.string.alertDialogTokenRevokedMessage), getResources().getString(R.string.cancelButton),
|
||||
getResources().getString(R.string.navLogout));
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
|
||||
@ -213,7 +228,7 @@ public class MergePullRequestActivity extends BaseActivity {
|
||||
else if(response.code() == 405) {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.warning(ctx, getString(R.string.mergeNotAllowed));;
|
||||
Toasty.warning(ctx, getString(R.string.mergeNotAllowed));
|
||||
}
|
||||
else {
|
||||
|
||||
@ -225,13 +240,9 @@ public class MergePullRequestActivity extends BaseActivity {
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
enableProcessButton();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void disableProcessButton() {
|
||||
@ -249,5 +260,4 @@ public class MergePullRequestActivity extends BaseActivity {
|
||||
super.onResume();
|
||||
issue.getRepository().checkAccountSwitch(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,8 +10,8 @@ import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import androidx.annotation.NonNull;
|
||||
import com.google.gson.JsonElement;
|
||||
import org.gitnex.tea4j.models.AddEmail;
|
||||
import org.gitnex.tea4j.v2.models.CreateEmailOption;
|
||||
import org.gitnex.tea4j.v2.models.Email;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.ActivityProfileEmailBinding;
|
||||
@ -96,23 +96,22 @@ public class MyProfileEmailActivity extends BaseActivity {
|
||||
List<String> newEmailList = new ArrayList<>(Arrays.asList(newUserEmail.split(",")));
|
||||
|
||||
disableProcessButton();
|
||||
addNewEmail(getAccount().getAuthorization(), newEmailList);
|
||||
addNewEmail(newEmailList);
|
||||
}
|
||||
|
||||
private void addNewEmail(final String token, List<String> newUserEmail) {
|
||||
private void addNewEmail(List<String> newUserEmail) {
|
||||
|
||||
AddEmail addEmailFunc = new AddEmail(newUserEmail);
|
||||
CreateEmailOption addEmailFunc = new CreateEmailOption();
|
||||
addEmailFunc.setEmails(newUserEmail);
|
||||
|
||||
Call<JsonElement> call;
|
||||
|
||||
call = RetrofitClient
|
||||
Call<List<Email>> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.addNewEmail(token, addEmailFunc);
|
||||
.userAddEmail(addEmailFunc);
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
|
||||
public void onResponse(@NonNull Call<List<Email>> call, @NonNull retrofit2.Response<List<Email>> response) {
|
||||
|
||||
if(response.code() == 201) {
|
||||
|
||||
@ -124,10 +123,8 @@ public class MyProfileEmailActivity extends BaseActivity {
|
||||
else if(response.code() == 401) {
|
||||
|
||||
enableProcessButton();
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle),
|
||||
getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||
getResources().getString(R.string.cancelButton),
|
||||
getResources().getString(R.string.navLogout));
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle), getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||
getResources().getString(R.string.cancelButton), getResources().getString(R.string.navLogout));
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
|
||||
@ -152,7 +149,7 @@ public class MyProfileEmailActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<List<Email>> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
enableProcessButton();
|
||||
|
@ -19,7 +19,7 @@ import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentPagerAdapter;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
import org.gitnex.tea4j.models.OrgPermissions;
|
||||
import org.gitnex.tea4j.v2.models.OrganizationPermissions;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.fragments.BottomSheetOrganizationFragment;
|
||||
@ -42,7 +42,7 @@ import retrofit2.Response;
|
||||
|
||||
public class OrganizationDetailActivity extends BaseActivity implements BottomSheetListener {
|
||||
|
||||
public OrgPermissions permissions;
|
||||
public OrganizationPermissions permissions;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
@ -112,10 +112,10 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
||||
|
||||
if(getAccount().requiresVersion("1.16.0")) {
|
||||
RetrofitClient.getApiInterface(this)
|
||||
.getOrgPermissions(getAccount().getAuthorization(), getAccount().getAccount().getUserName(), orgName).enqueue(new Callback<OrgPermissions>() {
|
||||
.orgGetUserPermissions(getAccount().getAccount().getUserName(), orgName).enqueue(new Callback<OrganizationPermissions>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<OrgPermissions> call, @NonNull Response<OrgPermissions> response) {
|
||||
public void onResponse(@NonNull Call<OrganizationPermissions> call, @NonNull Response<OrganizationPermissions> response) {
|
||||
if(response.isSuccessful()) {
|
||||
permissions = response.body();
|
||||
}
|
||||
@ -125,7 +125,7 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<OrgPermissions> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<OrganizationPermissions> call, @NonNull Throwable t) {
|
||||
permissions = null;
|
||||
}
|
||||
});
|
||||
|
@ -12,8 +12,8 @@ import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.viewpager2.adapter.FragmentStateAdapter;
|
||||
import com.google.android.material.tabs.TabLayoutMediator;
|
||||
import org.gitnex.tea4j.models.OrgPermissions;
|
||||
import org.gitnex.tea4j.models.Teams;
|
||||
import org.gitnex.tea4j.v2.models.OrganizationPermissions;
|
||||
import org.gitnex.tea4j.v2.models.Team;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.databinding.ActivityOrgTeamInfoBinding;
|
||||
import org.mian.gitnex.fragments.BottomSheetOrganizationTeamsFragment;
|
||||
@ -27,7 +27,7 @@ import org.mian.gitnex.structs.BottomSheetListener;
|
||||
|
||||
public class OrganizationTeamInfoActivity extends BaseActivity implements BottomSheetListener {
|
||||
|
||||
private Teams team;
|
||||
private Team team;
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
@ -40,7 +40,7 @@ public class OrganizationTeamInfoActivity extends BaseActivity implements Bottom
|
||||
setContentView(binding.getRoot());
|
||||
setSupportActionBar(binding.toolbar);
|
||||
|
||||
team = (Teams) getIntent().getSerializableExtra("team");
|
||||
team = (Team) getIntent().getSerializableExtra("team");
|
||||
|
||||
if(team.getName() != null && !team.getName().isEmpty()) {
|
||||
binding.toolbarTitle.setText(team.getName());
|
||||
@ -87,8 +87,8 @@ public class OrganizationTeamInfoActivity extends BaseActivity implements Bottom
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
OrgPermissions permissions = (OrgPermissions) getIntent().getSerializableExtra("permissions");
|
||||
if(permissions == null || permissions.isOwner()) {
|
||||
OrganizationPermissions permissions = (OrganizationPermissions) getIntent().getSerializableExtra("permissions");
|
||||
if(permissions == null || permissions.isIsOwner()) {
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.generic_nav_dotted_menu, menu);
|
||||
}
|
||||
@ -117,7 +117,7 @@ public class OrganizationTeamInfoActivity extends BaseActivity implements Bottom
|
||||
public void onButtonClicked(String text) {
|
||||
if("newMember".equals(text)) {
|
||||
Intent intent = new Intent(OrganizationTeamInfoActivity.this, AddNewTeamMemberActivity.class);
|
||||
intent.putExtra("team", team);
|
||||
intent.putExtra("teamId", team.getId());
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,6 @@ import androidx.viewpager2.adapter.FragmentStateAdapter;
|
||||
import androidx.viewpager2.widget.ViewPager2;
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
import com.google.android.material.tabs.TabLayoutMediator;
|
||||
import com.google.gson.JsonElement;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.fragments.BottomSheetUserProfileFragment;
|
||||
@ -118,10 +117,10 @@ public class ProfileActivity extends BaseActivity implements BottomSheetListener
|
||||
}
|
||||
|
||||
private void checkFollowStatus() {
|
||||
RetrofitClient.getApiInterface(this).checkFollowing(getAccount().getAuthorization(), username).enqueue(new Callback<JsonElement>() {
|
||||
RetrofitClient.getApiInterface(this).userCurrentCheckFollowing(username).enqueue(new Callback<Void>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<JsonElement> call, @NonNull Response<JsonElement> response) {
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull Response<Void> response) {
|
||||
if(response.code() == 204) {
|
||||
following = true;
|
||||
}
|
||||
@ -134,25 +133,25 @@ public class ProfileActivity extends BaseActivity implements BottomSheetListener
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
following = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void followUnfollow() {
|
||||
Call<JsonElement> call;
|
||||
Call<Void> call;
|
||||
if (following) {
|
||||
call = RetrofitClient.getApiInterface(this).unfollowUser(getAccount().getAuthorization(), username);
|
||||
call = RetrofitClient.getApiInterface(this).userCurrentDeleteFollow(username);
|
||||
}
|
||||
else {
|
||||
call = RetrofitClient.getApiInterface(this).followUser(getAccount().getAuthorization(), username);
|
||||
call = RetrofitClient.getApiInterface(this).userCurrentPutFollow(username);
|
||||
}
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
call.enqueue(new Callback<Void>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<JsonElement> call, @NonNull Response<JsonElement> response) {
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull Response<Void> response) {
|
||||
if (response.isSuccessful()) {
|
||||
following = !following;
|
||||
if (following) {
|
||||
@ -172,7 +171,7 @@ public class ProfileActivity extends BaseActivity implements BottomSheetListener
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
if (following) {
|
||||
Toasty.error(ProfileActivity.this, getString(R.string.unfollowingFailed));
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ import android.content.Intent;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
@ -29,11 +28,10 @@ import androidx.fragment.app.FragmentStatePagerAdapter;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
import com.google.android.material.progressindicator.LinearProgressIndicator;
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
import com.google.gson.JsonElement;
|
||||
import org.gitnex.tea4j.models.Branches;
|
||||
import org.gitnex.tea4j.models.Milestones;
|
||||
import org.gitnex.tea4j.models.UserRepositories;
|
||||
import org.gitnex.tea4j.models.WatchInfo;
|
||||
import org.gitnex.tea4j.v2.models.Branch;
|
||||
import org.gitnex.tea4j.v2.models.Milestone;
|
||||
import org.gitnex.tea4j.v2.models.Repository;
|
||||
import org.gitnex.tea4j.v2.models.WatchInfo;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.fragments.BottomSheetIssuesFilterFragment;
|
||||
@ -62,7 +60,7 @@ import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class RepoDetailActivity extends BaseActivity implements BottomSheetListener {
|
||||
@ -84,12 +82,17 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
||||
|
||||
public RepositoryContext repository;
|
||||
|
||||
public static boolean updateRepo = false;
|
||||
private Dialog progressDialog;
|
||||
|
||||
private final ActivityResultLauncher<Intent> createReleaseLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(),
|
||||
result -> {
|
||||
if(result.getResultCode() == 201) {
|
||||
assert result.getData() != null;
|
||||
if(result.getData().getBooleanExtra("updateReleases", false)) {
|
||||
if(fragmentRefreshListenerReleases != null) fragmentRefreshListenerReleases.onRefresh(null);
|
||||
repository.removeRepository();
|
||||
getRepoInfo(repository.getOwner(), repository.getName());
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -124,8 +127,6 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
@ -162,16 +163,21 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
||||
|
||||
toolbarTitle.setTypeface(myTypeface);
|
||||
|
||||
getRepoInfo(getAccount().getAuthorization(), repository.getOwner(), repository.getName());
|
||||
getRepoInfo(repository.getOwner(), repository.getName());
|
||||
|
||||
checkRepositoryStarStatus(getAccount().getAuthorization(), repository.getOwner(), repository.getName());
|
||||
checkRepositoryWatchStatus(getAccount().getAuthorization(), repository.getOwner(), repository.getName());
|
||||
checkRepositoryStarStatus(repository.getOwner(), repository.getName());
|
||||
checkRepositoryWatchStatus(repository.getOwner(), repository.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
repository.checkAccountSwitch(this);
|
||||
if(updateRepo) {
|
||||
updateRepo = false;
|
||||
repository.removeRepository();
|
||||
getRepoInfo(repository.getOwner(), repository.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -270,20 +276,20 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
||||
createReleaseLauncher.launch(repository.getIntent(ctx, CreateReleaseActivity.class));
|
||||
break;
|
||||
case "openWebRepo":
|
||||
AppUtil.openUrlInBrowser(this, repository.getRepository().getHtml_url());
|
||||
AppUtil.openUrlInBrowser(this, repository.getRepository().getHtmlUrl());
|
||||
break;
|
||||
case "shareRepo":
|
||||
|
||||
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
|
||||
sharingIntent.setType("text/plain");
|
||||
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, repository.getRepository().getHtml_url());
|
||||
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, repository.getRepository().getHtml_url());
|
||||
startActivity(Intent.createChooser(sharingIntent, repository.getRepository().getHtml_url()));
|
||||
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, repository.getRepository().getHtmlUrl());
|
||||
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, repository.getRepository().getHtmlUrl());
|
||||
startActivity(Intent.createChooser(sharingIntent, repository.getRepository().getHtmlUrl()));
|
||||
break;
|
||||
case "copyRepoUrl":
|
||||
|
||||
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(ctx).getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipData clip = ClipData.newPlainText("repoUrl", repository.getRepository().getHtml_url());
|
||||
ClipData clip = ClipData.newPlainText("repoUrl", repository.getRepository().getHtmlUrl());
|
||||
assert clipboard != null;
|
||||
clipboard.setPrimaryClip(clip);
|
||||
Toasty.info(ctx, ctx.getString(R.string.copyIssueUrlToastMsg));
|
||||
@ -371,33 +377,37 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
||||
|
||||
private void filterIssuesByMilestone() {
|
||||
|
||||
Dialog progressDialog = new Dialog(this);
|
||||
progressDialog = new Dialog(this);
|
||||
progressDialog.setContentView(R.layout.custom_progress_loader);
|
||||
progressDialog.show();
|
||||
|
||||
Call<List<Milestones>> call = RetrofitClient
|
||||
Call<List<Milestone>> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.getMilestones(getAccount().getAuthorization(), repository.getOwner(), repository.getName(), 1, 50, "open");
|
||||
.issueGetMilestonesList(repository.getOwner(), repository.getName(), "open", null, 1, 50);
|
||||
|
||||
call.enqueue(new Callback<List<Milestones>>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Milestones>> call, @NonNull Response<List<Milestones>> response) {
|
||||
public void onResponse(@NonNull Call<List<Milestone>> call, @NonNull Response<List<Milestone>> response) {
|
||||
|
||||
progressDialog.hide();
|
||||
if(response.code() == 200) {
|
||||
|
||||
Milestones milestones;
|
||||
List<String> milestonesList = new ArrayList<>();
|
||||
int selectedMilestone = 0;
|
||||
assert response.body() != null;
|
||||
|
||||
milestonesList.add("All");
|
||||
for(int i = 0; i < response.body().size(); i++) {
|
||||
milestones = response.body().get(i);
|
||||
Milestone milestones = response.body().get(i);
|
||||
milestonesList.add(milestones.getTitle());
|
||||
if(repository.getIssueMilestoneFilterName().equals(milestones.getTitle())) {
|
||||
selectedMilestone = i;
|
||||
}
|
||||
|
||||
for(int j = 0; j < milestonesList.size(); j++) {
|
||||
if(repository.getIssueMilestoneFilterName() != null) {
|
||||
if(repository.getIssueMilestoneFilterName().equals(milestonesList.get(j))) {
|
||||
selectedMilestone = j;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -406,7 +416,7 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
||||
|
||||
pBuilder.setSingleChoiceItems(milestonesList.toArray(new String[0]), selectedMilestone, (dialogInterface, i) -> {
|
||||
|
||||
repository.setIssueMilestoneFilterName(response.body().get(i).getTitle());
|
||||
repository.setIssueMilestoneFilterName(milestonesList.get(i));
|
||||
|
||||
if(getFragmentRefreshListenerFilterIssuesByMilestone() != null) {
|
||||
getFragmentRefreshListenerFilterIssuesByMilestone().onRefresh(milestonesList.get(i));
|
||||
@ -420,28 +430,36 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Milestones>> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<List<Milestone>> call, @NonNull Throwable t) {
|
||||
progressDialog.hide();
|
||||
Log.e("onFailure", t.toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
if(progressDialog != null) {
|
||||
progressDialog.dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
private void chooseBranch() {
|
||||
|
||||
Dialog progressDialog = new Dialog(this);
|
||||
progressDialog = new Dialog(this);
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.setContentView(R.layout.custom_progress_loader);
|
||||
progressDialog.show();
|
||||
|
||||
Call<List<Branches>> call = RetrofitClient
|
||||
Call<List<Branch>> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.getBranches(getAccount().getAuthorization(), repository.getOwner(), repository.getName());
|
||||
.repoListBranches(repository.getOwner(), repository.getName(), null, null);
|
||||
|
||||
call.enqueue(new Callback<List<Branches>>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Branches>> call, @NonNull Response<List<Branches>> response) {
|
||||
public void onResponse(@NonNull Call<List<Branch>> call, @NonNull Response<List<Branch>> response) {
|
||||
|
||||
progressDialog.hide();
|
||||
if(response.code() == 200) {
|
||||
@ -452,7 +470,7 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
||||
|
||||
for(int i = 0; i < response.body().size(); i++) {
|
||||
|
||||
Branches branches = response.body().get(i);
|
||||
Branch branches = response.body().get(i);
|
||||
branchesList.add(branches.getName());
|
||||
|
||||
if(repository.getBranchRef().equals(branches.getName())) {
|
||||
@ -479,9 +497,8 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Branches>> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<List<Branch>> call, @NonNull Throwable t) {
|
||||
progressDialog.hide();
|
||||
Log.e("onFailure", t.toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -539,7 +556,7 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
||||
}
|
||||
}
|
||||
|
||||
private void getRepoInfo(String token, final String owner, String repo) {
|
||||
private void getRepoInfo(final String owner, String repo) {
|
||||
|
||||
LinearProgressIndicator loading = findViewById(R.id.loadingIndicator);
|
||||
if(repository.hasRepository()) {
|
||||
@ -548,13 +565,13 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
||||
return;
|
||||
}
|
||||
|
||||
Call<UserRepositories> call = RetrofitClient.getApiInterface(ctx).getUserRepository(token, owner, repo);
|
||||
call.enqueue(new Callback<UserRepositories>() {
|
||||
Call<Repository> call = RetrofitClient.getApiInterface(ctx).repoGet(owner, repo);
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<UserRepositories> call, @NonNull retrofit2.Response<UserRepositories> response) {
|
||||
public void onResponse(@NonNull Call<Repository> call, @NonNull retrofit2.Response<Repository> response) {
|
||||
|
||||
UserRepositories repoInfo = response.body();
|
||||
Repository repoInfo = response.body();
|
||||
loading.setVisibility(View.GONE);
|
||||
|
||||
if(response.code() == 200) {
|
||||
@ -564,27 +581,24 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
||||
}
|
||||
else {
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
Log.e("onFailure", String.valueOf(response.code()));
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<UserRepositories> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<Repository> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
Log.e("onFailure", t.toString());
|
||||
finish();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void initWithRepo() {
|
||||
repository.setBranchRef(repository.getRepository().getDefault_branch());
|
||||
repository.setBranchRef(repository.getRepository().getDefaultBranch());
|
||||
|
||||
ImageView repoTypeToolbar = findViewById(R.id.repoTypeToolbar);
|
||||
if(repository.getRepository().isPrivateFlag()) {
|
||||
if(repository.getRepository().isPrivate()) {
|
||||
repoTypeToolbar.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
repoTypeToolbar.setVisibility(View.GONE);
|
||||
@ -612,61 +626,76 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
||||
}
|
||||
}
|
||||
|
||||
if(mViewPager == null) {
|
||||
mViewPager = findViewById(R.id.container);
|
||||
mViewPager.setVisibility(View.VISIBLE);
|
||||
|
||||
mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
|
||||
tabLayout.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(mViewPager));
|
||||
|
||||
SectionsPagerAdapter mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
|
||||
mViewPager.setAdapter(mSectionsPagerAdapter);
|
||||
}
|
||||
|
||||
if(tinyDB.getBoolean("enableCounterBadges", true)) {
|
||||
@SuppressLint("InflateParams") View tabHeader2 = LayoutInflater.from(ctx).inflate(R.layout.badge_issue, null);
|
||||
if(textViewBadgeIssue == null) {
|
||||
textViewBadgeIssue = tabHeader2.findViewById(R.id.counterBadgeIssue);
|
||||
}
|
||||
|
||||
@SuppressLint("InflateParams") View tabHeader4 = LayoutInflater.from(ctx).inflate(R.layout.badge_pull, null);
|
||||
if(textViewBadgePull == null) {
|
||||
textViewBadgePull = tabHeader4.findViewById(R.id.counterBadgePull);
|
||||
}
|
||||
|
||||
@SuppressLint("InflateParams") View tabHeader6 = LayoutInflater.from(ctx).inflate(R.layout.badge_release, null);
|
||||
if(textViewBadgeRelease == null) {
|
||||
textViewBadgeRelease = tabHeader6.findViewById(R.id.counterBadgeRelease);
|
||||
}
|
||||
|
||||
ColorStateList textColor = tabLayout.getTabTextColors();
|
||||
|
||||
if(repository.getRepository().getOpen_issues_count() != null) {
|
||||
if(repository.getRepository().getOpenIssuesCount() != null) {
|
||||
textViewBadgeIssue.setVisibility(View.VISIBLE);
|
||||
textViewBadgeIssue.setText(repository.getRepository().getOpen_issues_count());
|
||||
textViewBadgeIssue.setText(String.valueOf(repository.getRepository().getOpenIssuesCount()));
|
||||
|
||||
TabLayout.Tab tabOpenIssues = tabLayout.getTabAt(2);
|
||||
assert tabOpenIssues != null;
|
||||
|
||||
if(tabOpenIssues.getCustomView() == null) {
|
||||
tabOpenIssues.setCustomView(tabHeader2);
|
||||
}
|
||||
TextView openIssueTabView = Objects.requireNonNull(tabOpenIssues.getCustomView()).findViewById(R.id.counterBadgeIssueText);
|
||||
openIssueTabView.setTextColor(textColor);
|
||||
} else {
|
||||
textViewBadgeIssue.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if(repository.getRepository().getOpen_pull_count() != null) {
|
||||
if(repository.getRepository().getOpenPrCounter() != null) {
|
||||
textViewBadgePull.setVisibility(View.VISIBLE);
|
||||
textViewBadgePull.setText(repository.getRepository().getOpen_pull_count());
|
||||
textViewBadgePull.setText(String.valueOf(repository.getRepository().getOpenPrCounter()));
|
||||
|
||||
Objects.requireNonNull(tabLayout.getTabAt(3)).setCustomView(tabHeader4);
|
||||
TabLayout.Tab tabOpenPulls = tabLayout.getTabAt(3);
|
||||
assert tabOpenPulls != null; // FIXME This should be cleaned up
|
||||
assert tabOpenPulls != null;
|
||||
|
||||
if(tabOpenPulls.getCustomView() == null) {
|
||||
tabOpenPulls.setCustomView(tabHeader4);
|
||||
}
|
||||
TextView openPullTabView = Objects.requireNonNull(tabOpenPulls.getCustomView()).findViewById(R.id.counterBadgePullText);
|
||||
openPullTabView.setTextColor(textColor);
|
||||
} else {
|
||||
textViewBadgePull.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if(repository.getRepository().getRelease_count() != null) {
|
||||
if(repository.getRepository().getReleaseCounter() != null) {
|
||||
textViewBadgeRelease.setVisibility(View.VISIBLE);
|
||||
textViewBadgeRelease.setText(repository.getRepository().getRelease_count());
|
||||
textViewBadgeRelease.setText(String.valueOf(repository.getRepository().getReleaseCounter()));
|
||||
|
||||
|
||||
Objects.requireNonNull(tabLayout.getTabAt(4)).setCustomView(tabHeader6);
|
||||
TabLayout.Tab tabOpenRelease = tabLayout.getTabAt(4);
|
||||
assert tabOpenRelease != null; // FIXME This should be cleaned up
|
||||
assert tabOpenRelease != null;
|
||||
if(tabOpenRelease.getCustomView() == null) {
|
||||
tabOpenRelease.setCustomView(tabHeader6);
|
||||
}
|
||||
TextView openReleaseTabView = Objects.requireNonNull(tabOpenRelease.getCustomView()).findViewById(R.id.counterBadgeReleaseText);
|
||||
openReleaseTabView.setTextColor(textColor);
|
||||
} else {
|
||||
@ -762,39 +791,34 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
||||
}
|
||||
}
|
||||
|
||||
private void checkRepositoryStarStatus(String instanceToken, final String owner, String repo) {
|
||||
private void checkRepositoryStarStatus(final String owner, String repo) {
|
||||
|
||||
Call<JsonElement> call = RetrofitClient.getApiInterface(ctx).checkRepoStarStatus(instanceToken, owner, repo);
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
Call<Void> call = RetrofitClient.getApiInterface(ctx).userCurrentCheckStarring(owner, repo);
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
|
||||
repository.setStarred(response.code() == 204);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void checkRepositoryWatchStatus(String instanceToken, final String owner, String repo) {
|
||||
private void checkRepositoryWatchStatus(final String owner, String repo) {
|
||||
|
||||
Call<WatchInfo> call;
|
||||
|
||||
call = RetrofitClient.getApiInterface(ctx).checkRepoWatchStatus(instanceToken, owner, repo);
|
||||
call.enqueue(new Callback<WatchInfo>() {
|
||||
Call<WatchInfo> call = RetrofitClient.getApiInterface(ctx).userCurrentCheckSubscription(owner, repo);
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<WatchInfo> call, @NonNull retrofit2.Response<WatchInfo> response) {
|
||||
|
||||
if(response.code() == 200) {
|
||||
assert response.body() != null;
|
||||
repository.setWatched(response.body().getSubscribed());
|
||||
repository.setWatched(response.body().isSubscribed());
|
||||
}
|
||||
else {
|
||||
repository.setWatched(false);
|
||||
@ -803,11 +827,8 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<WatchInfo> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// Issues milestone filter interface
|
||||
|
@ -20,7 +20,7 @@ import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
import org.gitnex.tea4j.models.UserRepositories;
|
||||
import org.gitnex.tea4j.v2.models.Repository;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.RepoForksAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
@ -46,7 +46,7 @@ public class RepoForksActivity extends BaseActivity {
|
||||
private int pageSize = 1;
|
||||
|
||||
private RecyclerView recyclerView;
|
||||
private List<UserRepositories> forksList;
|
||||
private List<Repository> forksList;
|
||||
private RepoForksAdapter adapter;
|
||||
private ProgressBar progressLoadMore;
|
||||
|
||||
@ -91,8 +91,9 @@ public class RepoForksActivity extends BaseActivity {
|
||||
|
||||
swipeRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
|
||||
pageSize = 1;
|
||||
swipeRefresh.setRefreshing(false);
|
||||
loadInitial(getAccount().getAuthorization(), repoOwner, repoName, pageSize, resultLimit);
|
||||
loadInitial(repoOwner, repoName, pageSize, resultLimit);
|
||||
adapter.notifyDataChanged();
|
||||
|
||||
}, 200));
|
||||
@ -103,7 +104,7 @@ public class RepoForksActivity extends BaseActivity {
|
||||
if(forksList.size() == resultLimit || pageSize == resultLimit) {
|
||||
|
||||
int page = (forksList.size() + resultLimit) / resultLimit;
|
||||
loadMore(getAccount().getAuthorization(), repoOwner, repoName, page, resultLimit);
|
||||
loadMore(repoOwner, repoName, page, resultLimit);
|
||||
}
|
||||
}));
|
||||
|
||||
@ -111,19 +112,19 @@ public class RepoForksActivity extends BaseActivity {
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(ctx));
|
||||
recyclerView.setAdapter(adapter);
|
||||
|
||||
loadInitial(getAccount().getAuthorization(), repoOwner, repoName, pageSize, resultLimit);
|
||||
loadInitial(repoOwner, repoName, pageSize, resultLimit);
|
||||
}
|
||||
|
||||
private void loadInitial(String instanceToken, String repoOwner, String repoName, int pageSize, int resultLimit) {
|
||||
private void loadInitial(String repoOwner, String repoName, int pageSize, int resultLimit) {
|
||||
|
||||
Call<List<UserRepositories>> call = RetrofitClient
|
||||
Call<List<Repository>> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.getRepositoryForks(instanceToken, repoOwner, repoName, pageSize, resultLimit);
|
||||
.listForks(repoOwner, repoName, pageSize, resultLimit);
|
||||
|
||||
call.enqueue(new Callback<List<UserRepositories>>() {
|
||||
call.enqueue(new Callback<List<Repository>>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<UserRepositories>> call, @NonNull Response<List<UserRepositories>> response) {
|
||||
public void onResponse(@NonNull Call<List<Repository>> call, @NonNull Response<List<Repository>> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
|
||||
@ -147,32 +148,32 @@ public class RepoForksActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<UserRepositories>> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<List<Repository>> call, @NonNull Throwable t) {
|
||||
Log.e(TAG, t.toString());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void loadMore(String instanceToken, String repoOwner, String repoName, int page, int resultLimit) {
|
||||
private void loadMore(String repoOwner, String repoName, int page, int resultLimit) {
|
||||
|
||||
progressLoadMore.setVisibility(View.VISIBLE);
|
||||
|
||||
Call<List<UserRepositories>> call = RetrofitClient
|
||||
Call<List<Repository>> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.getRepositoryForks(instanceToken, repoOwner, repoName, page, resultLimit);
|
||||
.listForks(repoOwner, repoName, page, resultLimit);
|
||||
|
||||
call.enqueue(new Callback<List<UserRepositories>>() {
|
||||
call.enqueue(new Callback<List<Repository>>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<UserRepositories>> call, @NonNull Response<List<UserRepositories>> response) {
|
||||
public void onResponse(@NonNull Call<List<Repository>> call, @NonNull Response<List<Repository>> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
|
||||
//remove loading view
|
||||
forksList.remove(forksList.size() - 1);
|
||||
|
||||
List<UserRepositories> result = response.body();
|
||||
List<Repository> result = response.body();
|
||||
assert result != null;
|
||||
|
||||
if(result.size() > 0) {
|
||||
@ -190,7 +191,7 @@ public class RepoForksActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<UserRepositories>> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<List<Repository>> call, @NonNull Throwable t) {
|
||||
Log.e(TAG, t.toString());
|
||||
}
|
||||
|
||||
@ -226,9 +227,9 @@ public class RepoForksActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
private void filter(String text) {
|
||||
List<UserRepositories> userRepositories = new ArrayList<>();
|
||||
List<Repository> userRepositories = new ArrayList<>();
|
||||
|
||||
for(UserRepositories d : forksList) {
|
||||
for(Repository d : forksList) {
|
||||
if(d.getName().toLowerCase().contains(text) ||
|
||||
d.getDescription().toLowerCase().contains(text)) {
|
||||
|
||||
|
@ -50,14 +50,14 @@ public class RepoStargazersActivity extends BaseActivity {
|
||||
|
||||
toolbarTitle.setText(R.string.repoStargazersInMenu);
|
||||
|
||||
fetchDataAsync(getAccount().getAuthorization(), repoOwner, repoName);
|
||||
fetchDataAsync(repoOwner, repoName);
|
||||
}
|
||||
|
||||
private void fetchDataAsync(String instanceToken, String repoOwner, String repoName) {
|
||||
private void fetchDataAsync(String repoOwner, String repoName) {
|
||||
|
||||
RepoStargazersViewModel repoStargazersModel = new ViewModelProvider(this).get(RepoStargazersViewModel.class);
|
||||
|
||||
repoStargazersModel.getRepoStargazers(instanceToken, repoOwner, repoName, ctx).observe(this, stargazersListMain -> {
|
||||
repoStargazersModel.getRepoStargazers(repoOwner, repoName, ctx).observe(this, stargazersListMain -> {
|
||||
|
||||
adapter = new UserGridAdapter(ctx, stargazersListMain);
|
||||
|
||||
|
@ -50,14 +50,14 @@ public class RepoWatchersActivity extends BaseActivity {
|
||||
|
||||
toolbarTitle.setText(R.string.repoWatchersInMenu);
|
||||
|
||||
fetchDataAsync(getAccount().getAuthorization(), repoOwner, repoName);
|
||||
fetchDataAsync(repoOwner, repoName);
|
||||
}
|
||||
|
||||
private void fetchDataAsync(String instanceToken, String repoOwner, String repoName) {
|
||||
private void fetchDataAsync(String repoOwner, String repoName) {
|
||||
|
||||
RepoWatchersViewModel repoWatchersModel = new ViewModelProvider(this).get(RepoWatchersViewModel.class);
|
||||
|
||||
repoWatchersModel.getRepoWatchers(instanceToken, repoOwner, repoName, ctx).observe(this, watchersListMain -> {
|
||||
repoWatchersModel.getRepoWatchers(repoOwner, repoName, ctx).observe(this, watchersListMain -> {
|
||||
|
||||
adapter = new UserGridAdapter(ctx, watchersListMain);
|
||||
|
||||
|
@ -9,9 +9,10 @@ import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import androidx.annotation.NonNull;
|
||||
import com.google.gson.JsonElement;
|
||||
import org.gitnex.tea4j.models.RepositoryTransfer;
|
||||
import org.gitnex.tea4j.models.UserRepositories;
|
||||
import org.gitnex.tea4j.v2.models.EditRepoOption;
|
||||
import org.gitnex.tea4j.v2.models.InternalTracker;
|
||||
import org.gitnex.tea4j.v2.models.Repository;
|
||||
import org.gitnex.tea4j.v2.models.TransferRepoOption;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.database.api.BaseApi;
|
||||
@ -111,16 +112,17 @@ public class RepositorySettingsActivity extends BaseActivity {
|
||||
|
||||
private void transferRepository(String newOwner) {
|
||||
|
||||
RepositoryTransfer repositoryTransfer = new RepositoryTransfer(newOwner);
|
||||
TransferRepoOption repositoryTransfer = new TransferRepoOption();
|
||||
repositoryTransfer.setNewOwner(newOwner);
|
||||
|
||||
Call<JsonElement> transferCall = RetrofitClient
|
||||
Call<Repository> transferCall = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.transferRepository(getAccount().getAuthorization(), repository.getOwner(), repository.getName(), repositoryTransfer);
|
||||
.repoTransfer(repositoryTransfer, repository.getOwner(), repository.getName());
|
||||
|
||||
transferCall.enqueue(new Callback<JsonElement>() {
|
||||
transferCall.enqueue(new Callback<Repository>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
|
||||
public void onResponse(@NonNull Call<Repository> call, @NonNull retrofit2.Response<Repository> response) {
|
||||
|
||||
transferRepoBinding.transfer.setVisibility(View.GONE);
|
||||
transferRepoBinding.processingRequest.setVisibility(View.VISIBLE);
|
||||
@ -151,7 +153,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<Repository> call, @NonNull Throwable t) {
|
||||
|
||||
transferRepoBinding.transfer.setVisibility(View.VISIBLE);
|
||||
transferRepoBinding.processingRequest.setVisibility(View.GONE);
|
||||
@ -194,14 +196,14 @@ public class RepositorySettingsActivity extends BaseActivity {
|
||||
|
||||
private void deleteRepository() {
|
||||
|
||||
Call<JsonElement> deleteCall = RetrofitClient
|
||||
Call<Void> deleteCall = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.deleteRepository(getAccount().getAuthorization(), repository.getOwner(), repository.getName());
|
||||
.repoDelete(repository.getOwner(), repository.getName());
|
||||
|
||||
deleteCall.enqueue(new Callback<JsonElement>() {
|
||||
deleteCall.enqueue(new Callback<Void>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
|
||||
deleteRepoBinding.delete.setVisibility(View.GONE);
|
||||
deleteRepoBinding.processingRequest.setVisibility(View.VISIBLE);
|
||||
@ -226,7 +228,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
deleteRepoBinding.delete.setVisibility(View.VISIBLE);
|
||||
deleteRepoBinding.processingRequest.setVisibility(View.GONE);
|
||||
@ -250,7 +252,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
||||
dialogProp.setContentView(view);
|
||||
|
||||
propBinding.cancel.setOnClickListener(editProperties -> dialogProp.dismiss());
|
||||
UserRepositories repoInfo = repository.getRepository();
|
||||
Repository repoInfo = repository.getRepository();
|
||||
|
||||
propBinding.progressBar.setVisibility(View.GONE);
|
||||
propBinding.mainView.setVisibility(View.VISIBLE);
|
||||
@ -260,10 +262,10 @@ public class RepositorySettingsActivity extends BaseActivity {
|
||||
propBinding.repoName.setText(repoInfo.getName());
|
||||
propBinding.repoWebsite.setText(repoInfo.getWebsite());
|
||||
propBinding.repoDescription.setText(repoInfo.getDescription());
|
||||
propBinding.repoPrivate.setChecked(repoInfo.getPrivateFlag());
|
||||
propBinding.repoPrivate.setChecked(repoInfo.isPrivate());
|
||||
propBinding.repoAsTemplate.setChecked(repoInfo.isTemplate());
|
||||
|
||||
propBinding.repoEnableIssues.setChecked(repoInfo.getHas_issues());
|
||||
propBinding.repoEnableIssues.setChecked(repoInfo.isHasIssues());
|
||||
|
||||
propBinding.repoEnableIssues.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
|
||||
@ -275,21 +277,21 @@ public class RepositorySettingsActivity extends BaseActivity {
|
||||
}
|
||||
});
|
||||
|
||||
if(repoInfo.getInternal_tracker() != null) {
|
||||
if(repoInfo.getInternalTracker() != null) {
|
||||
|
||||
propBinding.repoEnableTimer.setChecked(repoInfo.getInternal_tracker().isEnable_time_tracker());
|
||||
propBinding.repoEnableTimer.setChecked(repoInfo.getInternalTracker().isEnableTimeTracker());
|
||||
}
|
||||
else {
|
||||
|
||||
propBinding.repoEnableTimer.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
propBinding.repoEnableWiki.setChecked(repoInfo.isHas_wiki());
|
||||
propBinding.repoEnablePr.setChecked(repoInfo.isHas_pull_requests());
|
||||
propBinding.repoEnableMerge.setChecked(repoInfo.isAllow_merge_commits());
|
||||
propBinding.repoEnableRebase.setChecked(repoInfo.isAllow_rebase());
|
||||
propBinding.repoEnableSquash.setChecked(repoInfo.isAllow_squash_merge());
|
||||
propBinding.repoEnableForceMerge.setChecked(repoInfo.isAllow_rebase_explicit());
|
||||
propBinding.repoEnableWiki.setChecked(repoInfo.isHasWiki());
|
||||
propBinding.repoEnablePr.setChecked(repoInfo.isHasPullRequests());
|
||||
propBinding.repoEnableMerge.setChecked(repoInfo.isAllowMergeCommits());
|
||||
propBinding.repoEnableRebase.setChecked(repoInfo.isAllowRebase());
|
||||
propBinding.repoEnableSquash.setChecked(repoInfo.isAllowSquashMerge());
|
||||
propBinding.repoEnableForceMerge.setChecked(repoInfo.isAllowRebaseExplicit());
|
||||
|
||||
propBinding.save.setOnClickListener(saveProperties -> saveRepositoryProperties(String.valueOf(propBinding.repoName.getText()),
|
||||
String.valueOf(propBinding.repoWebsite.getText()),
|
||||
@ -309,29 +311,29 @@ public class RepositorySettingsActivity extends BaseActivity {
|
||||
boolean repoEnablePr, boolean repoEnableTimer, boolean repoEnableMerge, boolean repoEnableRebase,
|
||||
boolean repoEnableSquash, boolean repoEnableForceMerge) {
|
||||
|
||||
UserRepositories.internalTimeTrackerObject repoPropsTimeTracker = new UserRepositories.internalTimeTrackerObject(repoEnableTimer);
|
||||
EditRepoOption repoProps = new EditRepoOption();
|
||||
repoProps.setName(repoName);
|
||||
repoProps.setWebsite(repoWebsite);
|
||||
repoProps.setDescription(repoDescription);
|
||||
repoProps.setPrivate(repoPrivate);
|
||||
repoProps.setTemplate(repoAsTemplate);
|
||||
repoProps.setHasIssues(repoEnableIssues);
|
||||
repoProps.setHasWiki(repoEnableWiki);
|
||||
repoProps.setHasPullRequests(repoEnablePr);
|
||||
repoProps.setInternalTracker(new InternalTracker().enableTimeTracker(repoEnableTimer));
|
||||
repoProps.setAllowMergeCommits(repoEnableMerge);
|
||||
repoProps.setAllowRebase(repoEnableRebase);
|
||||
repoProps.setAllowSquashMerge(repoEnableSquash);
|
||||
repoProps.setAllowRebaseExplicit(repoEnableForceMerge);
|
||||
|
||||
UserRepositories repoProps;
|
||||
|
||||
if(!repoEnableIssues) {
|
||||
|
||||
repoProps = new UserRepositories(repoName, repoWebsite, repoDescription, repoPrivate, repoAsTemplate, repoEnableIssues, repoEnableWiki, repoEnablePr, repoEnableMerge,
|
||||
repoEnableRebase, repoEnableSquash, repoEnableForceMerge);
|
||||
}
|
||||
else {
|
||||
|
||||
repoProps = new UserRepositories(repoName, repoWebsite, repoDescription, repoPrivate, repoAsTemplate, repoEnableIssues, repoEnableWiki, repoEnablePr, repoPropsTimeTracker, repoEnableMerge,
|
||||
repoEnableRebase, repoEnableSquash, repoEnableForceMerge);
|
||||
}
|
||||
|
||||
Call<UserRepositories> propsCall = RetrofitClient
|
||||
Call<Repository> propsCall = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.updateRepositoryProperties(getAccount().getAuthorization(), repository.getOwner(), repository.getName(), repoProps);
|
||||
.repoEdit(repository.getOwner(), repository.getName(), repoProps);
|
||||
|
||||
propsCall.enqueue(new Callback<UserRepositories>() {
|
||||
propsCall.enqueue(new Callback<Repository>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<UserRepositories> call, @NonNull retrofit2.Response<UserRepositories> response) {
|
||||
public void onResponse(@NonNull Call<Repository> call, @NonNull retrofit2.Response<Repository> response) {
|
||||
|
||||
propBinding.save.setVisibility(View.GONE);
|
||||
propBinding.processingRequest.setVisibility(View.VISIBLE);
|
||||
@ -360,7 +362,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<UserRepositories> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<Repository> call, @NonNull Throwable t) {
|
||||
|
||||
propBinding.save.setVisibility(View.VISIBLE);
|
||||
propBinding.processingRequest.setVisibility(View.GONE);
|
||||
|
@ -10,11 +10,9 @@ import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.google.gson.JsonElement;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.gitnex.tea4j.models.CronTasks;
|
||||
import org.gitnex.tea4j.v2.models.Cron;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
@ -31,11 +29,11 @@ import retrofit2.Callback;
|
||||
|
||||
public class AdminCronTasksAdapter extends RecyclerView.Adapter<AdminCronTasksAdapter.CronTasksViewHolder> {
|
||||
|
||||
private final List<CronTasks> tasksList;
|
||||
private final List<Cron> tasksList;
|
||||
|
||||
static class CronTasksViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private CronTasks cronTasks;
|
||||
private Cron cronTasks;
|
||||
|
||||
private final TextView taskName;
|
||||
|
||||
@ -74,7 +72,7 @@ public class AdminCronTasksAdapter extends RecyclerView.Adapter<AdminCronTasksAd
|
||||
taskScheduleContent.setText(cronTasks.getSchedule());
|
||||
nextRunContent.setText(nextRun);
|
||||
lastRunContent.setText(lastRun);
|
||||
execTimeContent.setText(String.valueOf(cronTasks.getExec_times()));
|
||||
execTimeContent.setText(String.valueOf(cronTasks.getExecTimes()));
|
||||
|
||||
AlertDialog.Builder alertDialog = new AlertDialog.Builder(ctx);
|
||||
|
||||
@ -92,7 +90,7 @@ public class AdminCronTasksAdapter extends RecyclerView.Adapter<AdminCronTasksAd
|
||||
}
|
||||
}
|
||||
|
||||
public AdminCronTasksAdapter(List<CronTasks> tasksListMain) {
|
||||
public AdminCronTasksAdapter(List<Cron> tasksListMain) {
|
||||
this.tasksList = tasksListMain;
|
||||
}
|
||||
|
||||
@ -107,7 +105,7 @@ public class AdminCronTasksAdapter extends RecyclerView.Adapter<AdminCronTasksAd
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull AdminCronTasksAdapter.CronTasksViewHolder holder, int position) {
|
||||
|
||||
CronTasks currentItem = tasksList.get(position);
|
||||
Cron currentItem = tasksList.get(position);
|
||||
|
||||
holder.cronTasks = currentItem;
|
||||
holder.taskName.setText(StringUtils.capitalize(currentItem.getName().replace("_", " ")));
|
||||
@ -115,14 +113,14 @@ public class AdminCronTasksAdapter extends RecyclerView.Adapter<AdminCronTasksAd
|
||||
|
||||
private static void runCronTask(final Context ctx, final String taskName) {
|
||||
|
||||
Call<JsonElement> call = RetrofitClient
|
||||
Call<Void> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.adminRunCronTask(((BaseActivity) ctx).getAccount().getAuthorization(), taskName);
|
||||
.adminCronRun(taskName);
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
call.enqueue(new Callback<Void>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
|
||||
switch(response.code()) {
|
||||
|
||||
@ -152,7 +150,7 @@ public class AdminCronTasksAdapter extends RecyclerView.Adapter<AdminCronTasksAd
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.core.content.res.ResourcesCompat;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.amulyakhare.textdrawable.TextDrawable;
|
||||
import org.gitnex.tea4j.models.UserInfo;
|
||||
import org.gitnex.tea4j.v2.models.User;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.ProfileActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
@ -30,13 +30,13 @@ import java.util.List;
|
||||
|
||||
public class AdminGetUsersAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements Filterable {
|
||||
|
||||
private List<UserInfo> usersList;
|
||||
private final List<UserInfo> usersListFull;
|
||||
private List<User> usersList;
|
||||
private final List<User> usersListFull;
|
||||
private final Context context;
|
||||
private OnLoadMoreListener loadMoreListener;
|
||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
||||
|
||||
public AdminGetUsersAdapter(List<UserInfo> usersListMain, Context ctx) {
|
||||
public AdminGetUsersAdapter(List<User> usersListMain, Context ctx) {
|
||||
this.context = ctx;
|
||||
this.usersList = usersListMain;
|
||||
usersListFull = new ArrayList<>(usersList);
|
||||
@ -99,20 +99,20 @@ public class AdminGetUsersAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
});
|
||||
}
|
||||
|
||||
void bindData(UserInfo users) {
|
||||
void bindData(User users) {
|
||||
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||
|
||||
userLoginId = users.getLogin();
|
||||
|
||||
if(!users.getFullname().equals("")) {
|
||||
if(!users.getFullName().equals("")) {
|
||||
|
||||
userFullName.setText(Html.fromHtml(users.getFullname()));
|
||||
userName.setText(context.getResources().getString(R.string.usernameWithAt, users.getUsername()));
|
||||
userFullName.setText(Html.fromHtml(users.getFullName()));
|
||||
userName.setText(context.getResources().getString(R.string.usernameWithAt, users.getLogin()));
|
||||
}
|
||||
else {
|
||||
|
||||
userFullName.setText(context.getResources().getString(R.string.usernameWithAt, users.getUsername()));
|
||||
userFullName.setText(context.getResources().getString(R.string.usernameWithAt, users.getLogin()));
|
||||
userName.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@ -123,7 +123,7 @@ public class AdminGetUsersAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
userEmail.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if(users.getIs_admin()) {
|
||||
if(users.isIsAdmin()) {
|
||||
|
||||
userRole.setVisibility(View.VISIBLE);
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig()
|
||||
@ -136,7 +136,7 @@ public class AdminGetUsersAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
userRole.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
PicassoService.getInstance(context).get().load(users.getAvatar()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(userAvatar);
|
||||
PicassoService.getInstance(context).get().load(users.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(userAvatar);
|
||||
}
|
||||
}
|
||||
|
||||
@ -163,7 +163,7 @@ public class AdminGetUsersAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<UserInfo> list) {
|
||||
public void updateList(List<User> list) {
|
||||
usersList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
@ -176,7 +176,7 @@ public class AdminGetUsersAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
private final Filter usersFilter = new Filter() {
|
||||
@Override
|
||||
protected FilterResults performFiltering(CharSequence constraint) {
|
||||
List<UserInfo> filteredList = new ArrayList<>();
|
||||
List<User> filteredList = new ArrayList<>();
|
||||
|
||||
if (constraint == null || constraint.length() == 0) {
|
||||
filteredList.addAll(usersListFull);
|
||||
@ -184,8 +184,8 @@ public class AdminGetUsersAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
else {
|
||||
String filterPattern = constraint.toString().toLowerCase().trim();
|
||||
|
||||
for (UserInfo item : usersListFull) {
|
||||
if (item.getEmail().toLowerCase().contains(filterPattern) || item.getFullname().toLowerCase().contains(filterPattern) || item.getUsername().toLowerCase().contains(filterPattern)) {
|
||||
for (User item : usersListFull) {
|
||||
if (item.getEmail().toLowerCase().contains(filterPattern) || item.getFullName().toLowerCase().contains(filterPattern) || item.getLogin().toLowerCase().contains(filterPattern)) {
|
||||
filteredList.add(item);
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import org.gitnex.tea4j.models.Collaborators;
|
||||
import org.gitnex.tea4j.v2.models.User;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
@ -27,7 +27,7 @@ import java.util.List;
|
||||
public class AssigneesListAdapter extends RecyclerView.Adapter<AssigneesListAdapter.AssigneesViewHolder> {
|
||||
|
||||
private final Context context;
|
||||
private final List<Collaborators> assigneesList;
|
||||
private final List<User> assigneesList;
|
||||
private List<String> assigneesStrings = new ArrayList<>();
|
||||
private List<String> currentAssignees;
|
||||
|
||||
@ -38,7 +38,7 @@ public class AssigneesListAdapter extends RecyclerView.Adapter<AssigneesListAdap
|
||||
void assigneesInterface(List<String> data);
|
||||
}
|
||||
|
||||
public AssigneesListAdapter(Context ctx, List<Collaborators> dataMain, AssigneesListAdapterListener assigneesListener, List<String> currentAssignees) {
|
||||
public AssigneesListAdapter(Context ctx, List<User> dataMain, AssigneesListAdapterListener assigneesListener, List<String> currentAssignees) {
|
||||
|
||||
this.context = ctx;
|
||||
this.assigneesList = dataMain;
|
||||
@ -74,19 +74,19 @@ public class AssigneesListAdapter extends RecyclerView.Adapter<AssigneesListAdap
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull AssigneesListAdapter.AssigneesViewHolder holder, int position) {
|
||||
|
||||
Collaborators currentItem = assigneesList.get(position);
|
||||
User currentItem = assigneesList.get(position);
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||
|
||||
if(currentItem.getFull_name().equals("")) {
|
||||
if(currentItem.getFullName().equals("")) {
|
||||
|
||||
holder.assigneesName.setText(currentItem.getLogin());
|
||||
}
|
||||
else {
|
||||
|
||||
holder.assigneesName.setText(Html.fromHtml(currentItem.getFull_name()));
|
||||
holder.assigneesName.setText(Html.fromHtml(currentItem.getFullName()));
|
||||
}
|
||||
PicassoService
|
||||
.getInstance(context).get().load(currentItem.getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(180, 180).centerCrop().into(holder.assigneesAvatar);
|
||||
.getInstance(context).get().load(currentItem.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(180, 180).centerCrop().into(holder.assigneesAvatar);
|
||||
|
||||
for(int i = 0; i < assigneesList.size(); i++) {
|
||||
|
||||
|
@ -13,8 +13,7 @@ import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import org.gitnex.tea4j.models.Collaborators;
|
||||
import org.gitnex.tea4j.models.UserInfo;
|
||||
import org.gitnex.tea4j.v2.models.User;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.actions.CollaboratorActions;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
@ -36,11 +35,11 @@ import retrofit2.Response;
|
||||
|
||||
public class CollaboratorSearchAdapter extends RecyclerView.Adapter<CollaboratorSearchAdapter.CollaboratorSearchViewHolder> {
|
||||
|
||||
private final List<UserInfo> usersSearchList;
|
||||
private final List<User> usersSearchList;
|
||||
private final Context context;
|
||||
private final RepositoryContext repository;
|
||||
|
||||
public CollaboratorSearchAdapter(List<UserInfo> dataList, Context ctx, RepositoryContext repository) {
|
||||
public CollaboratorSearchAdapter(List<User> dataList, Context ctx, RepositoryContext repository) {
|
||||
this.context = ctx;
|
||||
this.usersSearchList = dataList;
|
||||
this.repository = repository;
|
||||
@ -48,7 +47,7 @@ public class CollaboratorSearchAdapter extends RecyclerView.Adapter<Collaborator
|
||||
|
||||
class CollaboratorSearchViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private UserInfo userInfo;
|
||||
private User userInfo;
|
||||
|
||||
private final ImageView userAvatar;
|
||||
private final TextView userFullName;
|
||||
@ -80,14 +79,14 @@ public class CollaboratorSearchAdapter extends RecyclerView.Adapter<Collaborator
|
||||
ListView lw = ((AlertDialog)dialog).getListView();
|
||||
Object checkedItem = lw.getAdapter().getItem(lw.getCheckedItemPosition());
|
||||
|
||||
CollaboratorActions.addCollaborator(context, String.valueOf(checkedItem).toLowerCase(), userInfo.getUsername(), repository);
|
||||
CollaboratorActions.addCollaborator(context, String.valueOf(checkedItem).toLowerCase(), userInfo.getLogin(), repository);
|
||||
});
|
||||
|
||||
AlertDialog pDialog = pBuilder.create();
|
||||
pDialog.show();
|
||||
});
|
||||
|
||||
addCollaboratorButtonRemove.setOnClickListener(v -> AlertDialogs.collaboratorRemoveDialog(context, userInfo.getUsername(), repository));
|
||||
addCollaboratorButtonRemove.setOnClickListener(v -> AlertDialogs.collaboratorRemoveDialog(context, userInfo.getLogin(), repository));
|
||||
|
||||
userAvatar.setOnClickListener(loginId -> {
|
||||
Intent intent = new Intent(context, ProfileActivity.class);
|
||||
@ -113,40 +112,40 @@ public class CollaboratorSearchAdapter extends RecyclerView.Adapter<Collaborator
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull final CollaboratorSearchViewHolder holder, int position) {
|
||||
|
||||
UserInfo currentItem = usersSearchList.get(position);
|
||||
User currentItem = usersSearchList.get(position);
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||
holder.userInfo = currentItem;
|
||||
|
||||
if (!currentItem.getFullname().equals("")) {
|
||||
if (!currentItem.getFullName().equals("")) {
|
||||
|
||||
holder.userFullName.setText(Html.fromHtml(currentItem.getFullname()));
|
||||
holder.userFullName.setText(Html.fromHtml(currentItem.getFullName()));
|
||||
}
|
||||
else {
|
||||
|
||||
holder.userFullName.setText(context.getResources().getString(R.string.usernameWithAt, currentItem.getUsername()));
|
||||
holder.userFullName.setText(context.getResources().getString(R.string.usernameWithAt, currentItem.getLogin()));
|
||||
}
|
||||
|
||||
holder.userName.setText(context.getResources().getString(R.string.usernameWithAt, currentItem.getUsername()));
|
||||
holder.userName.setText(context.getResources().getString(R.string.usernameWithAt, currentItem.getLogin()));
|
||||
|
||||
if (!currentItem.getAvatar().equals("")) {
|
||||
PicassoService.getInstance(context).get().load(currentItem.getAvatar()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(holder.userAvatar);
|
||||
if (!currentItem.getAvatarUrl().equals("")) {
|
||||
PicassoService.getInstance(context).get().load(currentItem.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(holder.userAvatar);
|
||||
}
|
||||
|
||||
if(getItemCount() > 0) {
|
||||
|
||||
final String loginUid = ((BaseActivity) context).getAccount().getAccount().getUserName();
|
||||
|
||||
Call<Collaborators> call = RetrofitClient
|
||||
Call<Void> call = RetrofitClient
|
||||
.getApiInterface(context)
|
||||
.checkRepoCollaborator(((BaseActivity) context).getAccount().getAuthorization(), repository.getOwner(), repository.getName(), currentItem.getUsername());
|
||||
.repoCheckCollaborator(repository.getOwner(), repository.getName(), currentItem.getLogin());
|
||||
|
||||
call.enqueue(new Callback<Collaborators>() {
|
||||
call.enqueue(new Callback<Void>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Collaborators> call, @NonNull Response<Collaborators> response) {
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull Response<Void> response) {
|
||||
|
||||
if(response.code() == 204) {
|
||||
if(!currentItem.getUsername().equals(loginUid) && !currentItem.getUsername().equals(repository.getOwner())) {
|
||||
if(!currentItem.getLogin().equals(loginUid) && !currentItem.getLogin().equals(repository.getOwner())) {
|
||||
holder.addCollaboratorButtonRemove.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
@ -154,7 +153,7 @@ public class CollaboratorSearchAdapter extends RecyclerView.Adapter<Collaborator
|
||||
}
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
if(!currentItem.getUsername().equals(loginUid) && !currentItem.getUsername().equals(repository.getOwner())) {
|
||||
if(!currentItem.getLogin().equals(loginUid) && !currentItem.getLogin().equals(repository.getOwner())) {
|
||||
holder.addCollaboratorButtonAdd.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
@ -169,7 +168,7 @@ public class CollaboratorSearchAdapter extends RecyclerView.Adapter<Collaborator
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Collaborators> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
Log.i("onFailure", t.toString());
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@ import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import org.gitnex.tea4j.models.Collaborators;
|
||||
import org.gitnex.tea4j.v2.models.User;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.ProfileActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
@ -24,7 +24,7 @@ import java.util.List;
|
||||
|
||||
public class CollaboratorsAdapter extends BaseAdapter {
|
||||
|
||||
private final List<Collaborators> collaboratorsList;
|
||||
private final List<User> collaboratorsList;
|
||||
private final Context context;
|
||||
|
||||
private class ViewHolder {
|
||||
@ -52,7 +52,7 @@ public class CollaboratorsAdapter extends BaseAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
public CollaboratorsAdapter(Context ctx, List<Collaborators> collaboratorsListMain) {
|
||||
public CollaboratorsAdapter(Context ctx, List<User> collaboratorsListMain) {
|
||||
|
||||
this.context = ctx;
|
||||
this.collaboratorsList = collaboratorsListMain;
|
||||
@ -98,14 +98,14 @@ public class CollaboratorsAdapter extends BaseAdapter {
|
||||
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||
|
||||
Collaborators currentItem = collaboratorsList.get(position);
|
||||
PicassoService.getInstance(context).get().load(currentItem.getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(180, 180).centerCrop().into(viewHolder.collaboratorAvatar);
|
||||
User currentItem = collaboratorsList.get(position);
|
||||
PicassoService.getInstance(context).get().load(currentItem.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(180, 180).centerCrop().into(viewHolder.collaboratorAvatar);
|
||||
|
||||
viewHolder.userLoginId = currentItem.getLogin();
|
||||
|
||||
if(!currentItem.getFull_name().equals("")) {
|
||||
if(!currentItem.getFullName().equals("")) {
|
||||
|
||||
viewHolder.collaboratorName.setText(Html.fromHtml(currentItem.getFull_name()));
|
||||
viewHolder.collaboratorName.setText(Html.fromHtml(currentItem.getFullName()));
|
||||
}
|
||||
else {
|
||||
|
||||
|
@ -12,7 +12,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.core.text.HtmlCompat;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.vdurmont.emoji.EmojiParser;
|
||||
import org.gitnex.tea4j.models.Commits;
|
||||
import org.gitnex.tea4j.v2.models.Commit;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.CommitDetailActivity;
|
||||
import org.mian.gitnex.activities.CommitsActivity;
|
||||
@ -30,12 +30,12 @@ import java.util.Objects;
|
||||
public class CommitsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
private final Context context;
|
||||
private List<Commits> commitsList;
|
||||
private List<Commit> commitsList;
|
||||
private Runnable loadMoreListener;
|
||||
private boolean isLoading = false;
|
||||
private boolean isMoreDataAvailable = true;
|
||||
|
||||
public CommitsAdapter(Context ctx, List<Commits> commitsListMain) {
|
||||
public CommitsAdapter(Context ctx, List<Commit> commitsListMain) {
|
||||
|
||||
this.context = ctx;
|
||||
this.commitsList = commitsListMain;
|
||||
@ -93,35 +93,36 @@ public class CommitsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
||||
|
||||
}
|
||||
|
||||
void bindData(Commits commitsModel) {
|
||||
void bindData(Commit commitsModel) {
|
||||
|
||||
String[] commitMessageParts = commitsModel.getCommit().getMessage().split("(\r\n|\n)", 2);
|
||||
|
||||
commitSubject.setText(EmojiParser.parseToUnicode(commitMessageParts[0].trim()));
|
||||
|
||||
|
||||
if(!Objects.equals(commitsModel.getCommit().getCommitter().getEmail(), commitsModel.getCommit().getAuthor().getEmail())) {
|
||||
commitAuthorAndCommitter.setText(HtmlCompat.fromHtml(context
|
||||
.getString(R.string.commitAuthoredByAndCommittedByWhen, commitsModel.getCommit().getAuthor().getName(), commitsModel.getCommit().getCommitter().getName(),
|
||||
TimeHelper
|
||||
.formatTime(commitsModel.getCommit().getCommitter().getDate(), context.getResources().getConfiguration().locale, "pretty",
|
||||
.formatTime(TimeHelper.parseIso8601(commitsModel.getCommit().getCommitter().getDate()), context.getResources().getConfiguration().locale, "pretty",
|
||||
context)), HtmlCompat.FROM_HTML_MODE_COMPACT));
|
||||
} else {
|
||||
commitAuthorAndCommitter.setText(HtmlCompat.fromHtml(context
|
||||
.getString(R.string.commitCommittedByWhen, commitsModel.getCommit().getCommitter().getName(),
|
||||
TimeHelper
|
||||
.formatTime(commitsModel.getCommit().getCommitter().getDate(), context.getResources().getConfiguration().locale, "pretty",
|
||||
.formatTime(TimeHelper.parseIso8601(commitsModel.getCommit().getCommitter().getDate()), context.getResources().getConfiguration().locale, "pretty",
|
||||
context)), HtmlCompat.FROM_HTML_MODE_COMPACT));
|
||||
}
|
||||
|
||||
if(commitsModel.getAuthor() != null && commitsModel.getAuthor().getAvatar_url() != null &&
|
||||
!commitsModel.getAuthor().getAvatar_url().isEmpty()) {
|
||||
if(commitsModel.getAuthor() != null && commitsModel.getAuthor().getAvatarUrl() != null &&
|
||||
!commitsModel.getAuthor().getAvatarUrl().isEmpty()) {
|
||||
|
||||
commitAuthorAvatar.setVisibility(View.VISIBLE);
|
||||
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||
|
||||
PicassoService.getInstance(context).get()
|
||||
.load(commitsModel.getAuthor().getAvatar_url())
|
||||
.load(commitsModel.getAuthor().getAvatarUrl())
|
||||
.placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(imgRadius, 0))
|
||||
.resize(120, 120)
|
||||
@ -134,15 +135,15 @@ public class CommitsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
||||
|
||||
if(commitsModel.getCommitter() != null &&
|
||||
(commitsModel.getAuthor() == null || !commitsModel.getAuthor().getLogin().equals(commitsModel.getCommitter().getLogin())) &&
|
||||
commitsModel.getCommitter().getAvatar_url() != null &&
|
||||
!commitsModel.getCommitter().getAvatar_url().isEmpty()) {
|
||||
commitsModel.getCommitter().getAvatarUrl() != null &&
|
||||
!commitsModel.getCommitter().getAvatarUrl().isEmpty()) {
|
||||
|
||||
commitCommitterAvatar.setVisibility(View.VISIBLE);
|
||||
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||
|
||||
PicassoService.getInstance(context).get()
|
||||
.load(commitsModel.getCommitter().getAvatar_url())
|
||||
.load(commitsModel.getCommitter().getAvatarUrl())
|
||||
.placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(imgRadius, 0))
|
||||
.resize(120, 120)
|
||||
@ -177,7 +178,7 @@ public class CommitsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<Commits> list) {
|
||||
public void updateList(List<Commit> list) {
|
||||
commitsList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Author opyale
|
||||
* @author opyale
|
||||
*/
|
||||
|
||||
public class DiffAdapter extends BaseAdapter {
|
||||
@ -82,7 +82,7 @@ public class DiffAdapter extends BaseAdapter {
|
||||
textView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
||||
textView.setTextColor(COLOR_FONT);
|
||||
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
|
||||
textView.setPadding(15, 0, 15, 0);
|
||||
textView.setPadding(32, 0, 32, 0);
|
||||
textView.setTypeface(typeface);
|
||||
|
||||
convertView = textView;
|
||||
|
@ -6,8 +6,8 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.TextView;
|
||||
import org.gitnex.tea4j.models.FileDiffView;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.helpers.FileDiffView;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
@ -19,7 +19,7 @@ import androidx.core.content.res.ResourcesCompat;
|
||||
import androidx.core.text.HtmlCompat;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.amulyakhare.textdrawable.TextDrawable;
|
||||
import org.gitnex.tea4j.models.Issues;
|
||||
import org.gitnex.tea4j.v2.models.Issue;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.activities.IssueDetailActivity;
|
||||
@ -50,12 +50,12 @@ import java.util.Locale;
|
||||
public class ExploreIssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
private final Context context;
|
||||
private List<Issues> searchedList;
|
||||
private List<Issue> searchedList;
|
||||
private OnLoadMoreListener loadMoreListener;
|
||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
||||
private final TinyDB tinyDb;
|
||||
|
||||
public ExploreIssuesAdapter(List<Issues> dataList, Context ctx) {
|
||||
public ExploreIssuesAdapter(List<Issue> dataList, Context ctx) {
|
||||
this.context = ctx;
|
||||
this.searchedList = dataList;
|
||||
this.tinyDb = TinyDB.getInstance(context);
|
||||
@ -90,7 +90,7 @@ public class ExploreIssuesAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
|
||||
class IssuesHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private Issues issue;
|
||||
private Issue issue;
|
||||
|
||||
private final ImageView issueAssigneeAvatar;
|
||||
private final TextView issueTitle;
|
||||
@ -115,7 +115,7 @@ public class ExploreIssuesAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
|
||||
new Handler().postDelayed(() -> {
|
||||
|
||||
String[] parts = issue.getRepository().getFull_name().split("/");
|
||||
String[] parts = issue.getRepository().getFullName().split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
|
||||
@ -156,7 +156,7 @@ public class ExploreIssuesAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
});
|
||||
}
|
||||
|
||||
void bindData(Issues issue) {
|
||||
void bindData(Issue issue) {
|
||||
|
||||
this.issue = issue;
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||
@ -165,14 +165,14 @@ public class ExploreIssuesAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
String timeFormat = tinyDb.getString("dateFormat", "pretty");
|
||||
|
||||
PicassoService.getInstance(context).get()
|
||||
.load(issue.getUser().getAvatar_url())
|
||||
.load(issue.getUser().getAvatarUrl())
|
||||
.placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(imgRadius, 0))
|
||||
.resize(120, 120)
|
||||
.centerCrop()
|
||||
.into(issueAssigneeAvatar);
|
||||
|
||||
String issueNumber_ = "<font color='" + ResourcesCompat.getColor(context.getResources(), R.color.lightGray, null) + "'>" + issue.getRepository().getFull_name() + context.getResources().getString(R.string.hash) + issue.getNumber() + "</font>";
|
||||
String issueNumber_ = "<font color='" + ResourcesCompat.getColor(context.getResources(), R.color.lightGray, null) + "'>" + issue.getRepository().getFullName() + context.getResources().getString(R.string.hash) + issue.getNumber() + "</font>";
|
||||
|
||||
issueTitle.setText(HtmlCompat.fromHtml(issueNumber_ + " " + issue.getTitle(), HtmlCompat.FROM_HTML_MODE_LEGACY));
|
||||
issueCommentsCount.setText(String.valueOf(issue.getComments()));
|
||||
@ -242,20 +242,20 @@ public class ExploreIssuesAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
switch(timeFormat) {
|
||||
case "pretty": {
|
||||
PrettyTime prettyTime = new PrettyTime(locale);
|
||||
String createdTime = prettyTime.format(issue.getCreated_at());
|
||||
String createdTime = prettyTime.format(issue.getCreatedAt());
|
||||
issueCreatedTime.setText(createdTime);
|
||||
issueCreatedTime.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(issue.getCreated_at()), context));
|
||||
issueCreatedTime.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(issue.getCreatedAt()), context));
|
||||
break;
|
||||
}
|
||||
case "normal": {
|
||||
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", locale);
|
||||
String createdTime = formatter.format(issue.getCreated_at());
|
||||
String createdTime = formatter.format(issue.getCreatedAt());
|
||||
issueCreatedTime.setText(createdTime);
|
||||
break;
|
||||
}
|
||||
case "normal1": {
|
||||
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", locale);
|
||||
String createdTime = formatter.format(issue.getCreated_at());
|
||||
String createdTime = formatter.format(issue.getCreatedAt());
|
||||
issueCreatedTime.setText(createdTime);
|
||||
break;
|
||||
}
|
||||
@ -287,7 +287,7 @@ public class ExploreIssuesAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<Issues> list) {
|
||||
public void updateList(List<Issue> list) {
|
||||
searchedList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import org.gitnex.tea4j.models.Organization;
|
||||
import org.gitnex.tea4j.v2.models.Organization;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.OrganizationDetailActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
@ -86,7 +86,7 @@ public class ExplorePublicOrganizationsAdapter extends RecyclerView.Adapter<Recy
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||
orgName.setText(organization.getUsername());
|
||||
PicassoService.getInstance(context).get()
|
||||
.load(organization.getAvatar_url())
|
||||
.load(organization.getAvatarUrl())
|
||||
.placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(imgRadius, 0))
|
||||
.resize(120, 120)
|
||||
|
@ -14,7 +14,6 @@ import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.amulyakhare.textdrawable.TextDrawable;
|
||||
import com.amulyakhare.textdrawable.util.ColorGenerator;
|
||||
import org.gitnex.tea4j.models.UserRepositories;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
@ -40,12 +39,12 @@ import java.util.Locale;
|
||||
public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
private final Context context;
|
||||
private List<UserRepositories> reposList;
|
||||
private List<org.gitnex.tea4j.v2.models.Repository> reposList;
|
||||
private Runnable loadMoreListener;
|
||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
||||
private final TinyDB tinyDb;
|
||||
|
||||
public ExploreRepositoriesAdapter(List<UserRepositories> dataList, Context ctx) {
|
||||
public ExploreRepositoriesAdapter(List<org.gitnex.tea4j.v2.models.Repository> dataList, Context ctx) {
|
||||
this.context = ctx;
|
||||
this.reposList = dataList;
|
||||
this.tinyDb = TinyDB.getInstance(context);
|
||||
@ -78,7 +77,7 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<RecyclerVie
|
||||
}
|
||||
|
||||
class RepositoriesHolder extends RecyclerView.ViewHolder {
|
||||
private UserRepositories userRepositories;
|
||||
private org.gitnex.tea4j.v2.models.Repository userRepositories;
|
||||
|
||||
private final ImageView image;
|
||||
private final TextView repoName;
|
||||
@ -125,7 +124,7 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<RecyclerVie
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
void bindData(UserRepositories userRepositories) {
|
||||
void bindData(org.gitnex.tea4j.v2.models.Repository userRepositories) {
|
||||
this.userRepositories = userRepositories;
|
||||
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||
@ -134,7 +133,7 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<RecyclerVie
|
||||
|
||||
orgName.setText(userRepositories.getFullName().split("/")[0]);
|
||||
repoName.setText(userRepositories.getFullName().split("/")[1]);
|
||||
repoStars.setText(userRepositories.getStars_count());
|
||||
repoStars.setText(String.valueOf(userRepositories.getStarsCount()));
|
||||
|
||||
ColorGenerator generator = ColorGenerator.Companion.getMATERIAL();
|
||||
int color = generator.getColor(userRepositories.getName());
|
||||
@ -142,9 +141,9 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<RecyclerVie
|
||||
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).fontSize(18).toUpperCase().width(28).height(28).endConfig().buildRoundRect(firstCharacter, color, 3);
|
||||
|
||||
if(userRepositories.getAvatar_url() != null) {
|
||||
if(!userRepositories.getAvatar_url().equals("")) {
|
||||
PicassoService.getInstance(context).get().load(userRepositories.getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(image);
|
||||
if(userRepositories.getAvatarUrl() != null) {
|
||||
if(!userRepositories.getAvatarUrl().equals("")) {
|
||||
PicassoService.getInstance(context).get().load(userRepositories.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(image);
|
||||
}
|
||||
else {
|
||||
image.setImageDrawable(drawable);
|
||||
@ -154,25 +153,25 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<RecyclerVie
|
||||
image.setImageDrawable(drawable);
|
||||
}
|
||||
|
||||
if(userRepositories.getUpdated_at() != null) {
|
||||
if(userRepositories.getUpdatedAt() != null) {
|
||||
|
||||
switch(timeFormat) {
|
||||
case "pretty": {
|
||||
PrettyTime prettyTime = new PrettyTime(locale);
|
||||
String createdTime = prettyTime.format(userRepositories.getUpdated_at());
|
||||
String createdTime = prettyTime.format(userRepositories.getUpdatedAt());
|
||||
repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
|
||||
repoLastUpdated.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(userRepositories.getUpdated_at()), context));
|
||||
repoLastUpdated.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(userRepositories.getUpdatedAt()), context));
|
||||
break;
|
||||
}
|
||||
case "normal": {
|
||||
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", locale);
|
||||
String createdTime = formatter.format(userRepositories.getUpdated_at());
|
||||
String createdTime = formatter.format(userRepositories.getUpdatedAt());
|
||||
repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
|
||||
break;
|
||||
}
|
||||
case "normal1": {
|
||||
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", locale);
|
||||
String createdTime = formatter.format(userRepositories.getUpdated_at());
|
||||
String createdTime = formatter.format(userRepositories.getUpdatedAt());
|
||||
repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
|
||||
break;
|
||||
}
|
||||
@ -213,7 +212,7 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<RecyclerVie
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<UserRepositories> list) {
|
||||
public void updateList(List<org.gitnex.tea4j.v2.models.Repository> list) {
|
||||
reposList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.content.res.AppCompatResources;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.gitnex.tea4j.models.Files;
|
||||
import org.gitnex.tea4j.v2.models.ContentsResponse;
|
||||
import org.mian.gitnex.R;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -24,8 +24,8 @@ import java.util.List;
|
||||
|
||||
public class FilesAdapter extends RecyclerView.Adapter<FilesAdapter.FilesViewHolder> implements Filterable {
|
||||
|
||||
private final List<Files> originalFiles = new ArrayList<>();
|
||||
private final List<Files> alteredFiles = new ArrayList<>();
|
||||
private final List<ContentsResponse> originalFiles = new ArrayList<>();
|
||||
private final List<ContentsResponse> alteredFiles = new ArrayList<>();
|
||||
|
||||
private final Context context;
|
||||
|
||||
@ -33,12 +33,12 @@ public class FilesAdapter extends RecyclerView.Adapter<FilesAdapter.FilesViewHol
|
||||
|
||||
public interface FilesAdapterListener {
|
||||
|
||||
void onClickFile(Files file);
|
||||
void onClickFile(ContentsResponse file);
|
||||
}
|
||||
|
||||
class FilesViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private Files file;
|
||||
private ContentsResponse file;
|
||||
|
||||
private final ImageView fileTypeIs;
|
||||
private final TextView fileName;
|
||||
@ -129,7 +129,7 @@ public class FilesAdapter extends RecyclerView.Adapter<FilesAdapter.FilesViewHol
|
||||
this.filesListener = filesListener;
|
||||
}
|
||||
|
||||
public List<Files> getOriginalFiles() {
|
||||
public List<ContentsResponse> getOriginalFiles() {
|
||||
return originalFiles;
|
||||
}
|
||||
|
||||
@ -151,7 +151,7 @@ public class FilesAdapter extends RecyclerView.Adapter<FilesAdapter.FilesViewHol
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull FilesAdapter.FilesViewHolder holder, int position) {
|
||||
|
||||
Files currentItem = alteredFiles.get(position);
|
||||
ContentsResponse currentItem = alteredFiles.get(position);
|
||||
|
||||
holder.file = currentItem;
|
||||
holder.fileName.setText(currentItem.getName());
|
||||
@ -161,7 +161,7 @@ public class FilesAdapter extends RecyclerView.Adapter<FilesAdapter.FilesViewHol
|
||||
case "file":
|
||||
holder.fileTypeIs.setImageDrawable(AppCompatResources.getDrawable(context, R.drawable.ic_file));
|
||||
holder.fileInfo.setVisibility(View.VISIBLE);
|
||||
holder.fileInfo.setText(FileUtils.byteCountToDisplaySize(currentItem.getSize()));
|
||||
holder.fileInfo.setText(FileUtils.byteCountToDisplaySize(Math.toIntExact(currentItem.getSize())));
|
||||
break;
|
||||
|
||||
case "dir":
|
||||
@ -200,14 +200,14 @@ public class FilesAdapter extends RecyclerView.Adapter<FilesAdapter.FilesViewHol
|
||||
@Override
|
||||
protected FilterResults performFiltering(CharSequence constraint) {
|
||||
|
||||
List<Files> filteredList = new ArrayList<>();
|
||||
List<ContentsResponse> filteredList = new ArrayList<>();
|
||||
|
||||
if (constraint == null || constraint.length() == 0) {
|
||||
filteredList.addAll(originalFiles);
|
||||
} else {
|
||||
String filterPattern = constraint.toString().toLowerCase().trim();
|
||||
|
||||
for (Files item : originalFiles) {
|
||||
for (ContentsResponse item : originalFiles) {
|
||||
if (item.getName().toLowerCase().contains(filterPattern) || item.getPath().toLowerCase().contains(filterPattern)) {
|
||||
filteredList.add(item);
|
||||
}
|
||||
|
@ -17,9 +17,8 @@ import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.vdurmont.emoji.EmojiParser;
|
||||
import org.gitnex.tea4j.models.IssueComments;
|
||||
import org.gitnex.tea4j.v2.models.Comment;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.activities.ProfileActivity;
|
||||
@ -52,13 +51,13 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
||||
private final Context context;
|
||||
private final TinyDB tinyDB;
|
||||
private final Bundle bundle;
|
||||
private final List<IssueComments> issuesComments;
|
||||
private final List<Comment> issuesComments;
|
||||
private final FragmentManager fragmentManager;
|
||||
private final Runnable onInteractedListener;
|
||||
private final Locale locale;
|
||||
private final IssueContext issue;
|
||||
|
||||
public IssueCommentsAdapter(Context ctx, Bundle bundle, List<IssueComments> issuesCommentsMain, FragmentManager fragmentManager, Runnable onInteractedListener, IssueContext issue) {
|
||||
public IssueCommentsAdapter(Context ctx, Bundle bundle, List<Comment> issuesCommentsMain, FragmentManager fragmentManager, Runnable onInteractedListener, IssueContext issue) {
|
||||
|
||||
this.context = ctx;
|
||||
this.bundle = bundle;
|
||||
@ -73,7 +72,7 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
||||
class IssueCommentViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private String userLoginId;
|
||||
private IssueComments issueComment;
|
||||
private Comment issueComment;
|
||||
|
||||
private final ImageView avatar;
|
||||
private final TextView author;
|
||||
@ -113,7 +112,7 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
||||
linearLayout.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if(!loginUid.contentEquals(issueComment.getUser().getUsername()) && !issue.getRepository().getPermissions().canPush()) {
|
||||
if(!loginUid.contentEquals(issueComment.getUser().getLogin()) && !issue.getRepository().getPermissions().isPush()) {
|
||||
commentMenuEdit.setVisibility(View.GONE);
|
||||
commentMenuDelete.setVisibility(View.GONE);
|
||||
}
|
||||
@ -134,7 +133,7 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
||||
|
||||
Bundle bundle1 = new Bundle();
|
||||
bundle1.putAll(bundle);
|
||||
bundle1.putInt("commentId", issueComment.getId());
|
||||
bundle1.putInt("commentId", Math.toIntExact(issueComment.getId()));
|
||||
|
||||
ReactionSpinner reactionSpinner = new ReactionSpinner(context, bundle1);
|
||||
reactionSpinner.setOnInteractedListener(() -> {
|
||||
@ -150,7 +149,7 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
||||
|
||||
commentMenuEdit.setOnClickListener(v1 -> {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putInt("commentId", issueComment.getId());
|
||||
bundle.putInt("commentId", Math.toIntExact(issueComment.getId()));
|
||||
bundle.putString("commentAction", "edit");
|
||||
bundle.putString("commentBody", issueComment.getBody());
|
||||
|
||||
@ -163,7 +162,7 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
||||
|
||||
commentShare.setOnClickListener(v1 -> {
|
||||
// get comment Url
|
||||
CharSequence commentUrl = issueComment.getHtml_url();
|
||||
CharSequence commentUrl = issueComment.getHtmlUrl();
|
||||
|
||||
// share issue comment
|
||||
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
|
||||
@ -178,7 +177,7 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
||||
|
||||
issueCommentCopyUrl.setOnClickListener(v1 -> {
|
||||
// comment Url
|
||||
CharSequence commentUrl = issueComment.getHtml_url();
|
||||
CharSequence commentUrl = issueComment.getHtmlUrl();
|
||||
|
||||
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(context).getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
assert clipboard != null;
|
||||
@ -192,7 +191,7 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
||||
|
||||
commentMenuQuote.setOnClickListener(v1 -> {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
String commenterName = issueComment.getUser().getUsername();
|
||||
String commenterName = issueComment.getUser().getLogin();
|
||||
|
||||
if(!commenterName.equals(((BaseActivity) context).getAccount().getAccount().getUserName())) {
|
||||
stringBuilder.append("@").append(commenterName).append("\n\n");
|
||||
@ -226,7 +225,7 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
||||
});
|
||||
|
||||
commentMenuDelete.setOnClickListener(v1 -> {
|
||||
deleteIssueComment(context, issueComment.getId(), getAdapterPosition());
|
||||
deleteIssueComment(context, Math.toIntExact(issueComment.getId()), getAdapterPosition());
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
@ -254,14 +253,14 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
||||
|
||||
private void deleteIssueComment(final Context ctx, final int commentId, int position) {
|
||||
|
||||
Call<JsonElement> call = RetrofitClient
|
||||
Call<Void> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.deleteComment(((BaseActivity) context).getAccount().getAuthorization(), issue.getRepository().getOwner(), issue.getRepository().getName(), commentId);
|
||||
.issueDeleteComment(issue.getRepository().getOwner(), issue.getRepository().getName(), (long) commentId);
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
call.enqueue(new Callback<Void>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
|
||||
switch(response.code()) {
|
||||
|
||||
@ -293,7 +292,7 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
@ -311,16 +310,16 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
||||
public void onBindViewHolder(@NonNull IssueCommentsAdapter.IssueCommentViewHolder holder, int position) {
|
||||
|
||||
String timeFormat = tinyDB.getString("dateFormat", "pretty");
|
||||
IssueComments issueComment = issuesComments.get(position);
|
||||
Comment issueComment = issuesComments.get(position);
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||
|
||||
holder.userLoginId = issueComment.getUser().getLogin();
|
||||
|
||||
holder.issueComment = issueComment;
|
||||
holder.author.setText(issueComment.getUser().getUsername());
|
||||
holder.author.setText(issueComment.getUser().getLogin());
|
||||
|
||||
PicassoService.getInstance(context).get()
|
||||
.load(issueComment.getUser().getAvatar_url())
|
||||
.load(issueComment.getUser().getAvatarUrl())
|
||||
.placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(imgRadius, 0))
|
||||
.resize(AppUtil.getPixelsFromDensity(context, 35), AppUtil.getPixelsFromDensity(context, 35))
|
||||
@ -330,17 +329,17 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
||||
Markdown.render(context, EmojiParser.parseToUnicode(issueComment.getBody()), holder.comment, issue.getRepository());
|
||||
|
||||
StringBuilder informationBuilder = null;
|
||||
if(issueComment.getCreated_at() != null) {
|
||||
if(issueComment.getCreatedAt() != null) {
|
||||
|
||||
if(timeFormat.equals("pretty")) {
|
||||
informationBuilder = new StringBuilder(TimeHelper.formatTime(issueComment.getCreated_at(), locale, "pretty", context));
|
||||
holder.information.setOnClickListener(v -> TimeHelper.customDateFormatForToastDateFormat(issueComment.getCreated_at()));
|
||||
informationBuilder = new StringBuilder(TimeHelper.formatTime(issueComment.getCreatedAt(), locale, "pretty", context));
|
||||
holder.information.setOnClickListener(v -> TimeHelper.customDateFormatForToastDateFormat(issueComment.getCreatedAt()));
|
||||
}
|
||||
else if(timeFormat.equals("normal")) {
|
||||
informationBuilder = new StringBuilder(TimeHelper.formatTime(issueComment.getCreated_at(), locale, "normal", context));
|
||||
informationBuilder = new StringBuilder(TimeHelper.formatTime(issueComment.getCreatedAt(), locale, "normal", context));
|
||||
}
|
||||
|
||||
if(!issueComment.getCreated_at().equals(issueComment.getUpdated_at())) {
|
||||
if(!issueComment.getCreatedAt().equals(issueComment.getUpdatedAt())) {
|
||||
if(informationBuilder != null) {
|
||||
informationBuilder.append(context.getString(R.string.colorfulBulletSpan)).append(context.getString(R.string.modifiedText));
|
||||
}
|
||||
@ -351,7 +350,7 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
||||
|
||||
Bundle bundle1 = new Bundle();
|
||||
bundle1.putAll(bundle);
|
||||
bundle1.putInt("commentId", issueComment.getId());
|
||||
bundle1.putInt("commentId", Math.toIntExact(issueComment.getId()));
|
||||
|
||||
ReactionList reactionList = new ReactionList(context, bundle1);
|
||||
|
||||
|
@ -5,7 +5,6 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Handler;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@ -20,7 +19,7 @@ import androidx.core.text.HtmlCompat;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.amulyakhare.textdrawable.TextDrawable;
|
||||
import com.vdurmont.emoji.EmojiParser;
|
||||
import org.gitnex.tea4j.models.Issues;
|
||||
import org.gitnex.tea4j.v2.models.Issue;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.IssueDetailActivity;
|
||||
import org.mian.gitnex.activities.ProfileActivity;
|
||||
@ -47,12 +46,12 @@ import java.util.Locale;
|
||||
public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
private final Context context;
|
||||
private List<Issues> issuesList;
|
||||
private List<Issue> issuesList;
|
||||
private Runnable loadMoreListener;
|
||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
||||
TinyDB tinyDb;
|
||||
|
||||
public IssuesAdapter(Context ctx, List<Issues> issuesListMain) {
|
||||
public IssuesAdapter(Context ctx, List<Issue> issuesListMain) {
|
||||
|
||||
this.context = ctx;
|
||||
this.issuesList = issuesListMain;
|
||||
@ -90,7 +89,7 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
|
||||
class IssuesHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private Issues issueObject;
|
||||
private Issue issueObject;
|
||||
|
||||
private final ImageView issueAssigneeAvatar;
|
||||
private final TextView issueTitle;
|
||||
@ -118,18 +117,6 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
return true;
|
||||
});
|
||||
|
||||
new Handler().postDelayed(() -> {
|
||||
|
||||
Intent intentIssueDetail = new IssueContext(issueObject, ((RepoDetailActivity) context).repository).getIntent(context, IssueDetailActivity.class);
|
||||
|
||||
itemView.setOnClickListener(layoutView -> {
|
||||
context.startActivity(intentIssueDetail);
|
||||
});
|
||||
frameLabels.setOnClickListener(v -> context.startActivity(intentIssueDetail));
|
||||
frameLabelsDots.setOnClickListener(v -> context.startActivity(intentIssueDetail));
|
||||
|
||||
}, 200);
|
||||
|
||||
issueAssigneeAvatar.setOnClickListener(v -> {
|
||||
Intent intent = new Intent(context, ProfileActivity.class);
|
||||
intent.putExtra("username", issueObject.getUser().getLogin());
|
||||
@ -138,7 +125,7 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
void bindData(Issues issue) {
|
||||
void bindData(Issue issue) {
|
||||
|
||||
Locale locale = context.getResources().getConfiguration().locale;
|
||||
String timeFormat = tinyDb.getString("dateFormat", "pretty");
|
||||
@ -146,7 +133,7 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||
|
||||
PicassoService.getInstance(context).get()
|
||||
.load(issue.getUser().getAvatar_url())
|
||||
.load(issue.getUser().getAvatarUrl())
|
||||
.placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(imgRadius, 0))
|
||||
.resize(120, 120)
|
||||
@ -159,6 +146,12 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
this.issueObject = issue;
|
||||
this.issueCommentsCount.setText(String.valueOf(issue.getComments()));
|
||||
|
||||
Intent intentIssueDetail = new IssueContext(issueObject, ((RepoDetailActivity) context).repository).getIntent(context, IssueDetailActivity.class);
|
||||
|
||||
itemView.setOnClickListener(layoutView -> context.startActivity(intentIssueDetail));
|
||||
frameLabels.setOnClickListener(v -> context.startActivity(intentIssueDetail));
|
||||
frameLabelsDots.setOnClickListener(v -> context.startActivity(intentIssueDetail));
|
||||
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
params.setMargins(0, 0, 15, 0);
|
||||
@ -219,20 +212,20 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
switch(timeFormat) {
|
||||
case "pretty": {
|
||||
PrettyTime prettyTime = new PrettyTime(locale);
|
||||
String createdTime = prettyTime.format(issue.getCreated_at());
|
||||
String createdTime = prettyTime.format(issue.getCreatedAt());
|
||||
this.issueCreatedTime.setText(createdTime);
|
||||
this.issueCreatedTime.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(issue.getCreated_at()), context));
|
||||
this.issueCreatedTime.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(issue.getCreatedAt()), context));
|
||||
break;
|
||||
}
|
||||
case "normal": {
|
||||
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", locale);
|
||||
String createdTime = formatter.format(issue.getCreated_at());
|
||||
String createdTime = formatter.format(issue.getCreatedAt());
|
||||
this.issueCreatedTime.setText(createdTime);
|
||||
break;
|
||||
}
|
||||
case "normal1": {
|
||||
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", locale);
|
||||
String createdTime = formatter.format(issue.getCreated_at());
|
||||
String createdTime = formatter.format(issue.getCreatedAt());
|
||||
this.issueCreatedTime.setText(createdTime);
|
||||
break;
|
||||
}
|
||||
@ -256,7 +249,7 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<Issues> list) {
|
||||
public void updateList(List<Issue> list) {
|
||||
issuesList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ import androidx.cardview.widget.CardView;
|
||||
import androidx.core.widget.ImageViewCompat;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
import org.gitnex.tea4j.models.Labels;
|
||||
import org.gitnex.tea4j.v2.models.Label;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.CreateLabelActivity;
|
||||
import org.mian.gitnex.activities.OrganizationDetailActivity;
|
||||
@ -31,13 +31,13 @@ import java.util.List;
|
||||
|
||||
public class LabelsAdapter extends RecyclerView.Adapter<LabelsAdapter.LabelsViewHolder> {
|
||||
|
||||
private final List<Labels> labelsList;
|
||||
private final List<Label> labelsList;
|
||||
private final String type;
|
||||
private final String orgName;
|
||||
|
||||
class LabelsViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private Labels labels;
|
||||
private Label labels;
|
||||
|
||||
private final CardView labelView;
|
||||
private final ImageView labelIcon;
|
||||
@ -51,8 +51,8 @@ public class LabelsAdapter extends RecyclerView.Adapter<LabelsAdapter.LabelsView
|
||||
labelName = itemView.findViewById(R.id.labelName);
|
||||
ImageView labelsOptionsMenu = itemView.findViewById(R.id.labelsOptionsMenu);
|
||||
|
||||
if((type.equals("repo") && !((RepoDetailActivity) itemView.getContext()).repository.getPermissions().canPush()) ||
|
||||
(type.equals("org") && !((OrganizationDetailActivity) itemView.getContext()).permissions.isOwner())) {
|
||||
if((type.equals("repo") && !((RepoDetailActivity) itemView.getContext()).repository.getPermissions().isPush()) ||
|
||||
(type.equals("org") && !((OrganizationDetailActivity) itemView.getContext()).permissions.isIsOwner())) {
|
||||
labelsOptionsMenu.setVisibility(View.GONE);
|
||||
}
|
||||
labelsOptionsMenu.setOnClickListener(v -> {
|
||||
@ -80,7 +80,9 @@ public class LabelsAdapter extends RecyclerView.Adapter<LabelsAdapter.LabelsView
|
||||
intent.putExtra("labelAction", "edit");
|
||||
intent.putExtra("type", type);
|
||||
intent.putExtra("orgName", orgName);
|
||||
if(type.equals("repo")) {
|
||||
intent.putExtra(RepositoryContext.INTENT_EXTRA, ((RepoDetailActivity) itemView.getContext()).repository);
|
||||
}
|
||||
context.startActivity(intent);
|
||||
dialog.dismiss();
|
||||
});
|
||||
@ -103,7 +105,7 @@ public class LabelsAdapter extends RecyclerView.Adapter<LabelsAdapter.LabelsView
|
||||
}
|
||||
}
|
||||
|
||||
public LabelsAdapter(Context ctx, List<Labels> labelsMain, String type, String orgName) {
|
||||
public LabelsAdapter(Context ctx, List<Label> labelsMain, String type, String orgName) {
|
||||
|
||||
this.labelsList = labelsMain;
|
||||
this.type = type;
|
||||
@ -120,7 +122,7 @@ public class LabelsAdapter extends RecyclerView.Adapter<LabelsAdapter.LabelsView
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull LabelsAdapter.LabelsViewHolder holder, int position) {
|
||||
|
||||
Labels currentItem = labelsList.get(position);
|
||||
Label currentItem = labelsList.get(position);
|
||||
holder.labels = currentItem;
|
||||
|
||||
String labelColor = currentItem.getColor();
|
||||
|
@ -9,7 +9,7 @@ import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import org.gitnex.tea4j.models.Labels;
|
||||
import org.gitnex.tea4j.v2.models.Label;
|
||||
import org.mian.gitnex.R;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashSet;
|
||||
@ -22,7 +22,7 @@ import java.util.List;
|
||||
public class LabelsListAdapter extends RecyclerView.Adapter<LabelsListAdapter.LabelsViewHolder> {
|
||||
|
||||
private List<Integer> currentLabelsIds;
|
||||
private final List<Labels> labels;
|
||||
private final List<Label> labels;
|
||||
private final List<String> labelsStrings = new ArrayList<>();
|
||||
private List<Integer> labelsIds = new ArrayList<>();
|
||||
|
||||
@ -34,7 +34,7 @@ public class LabelsListAdapter extends RecyclerView.Adapter<LabelsListAdapter.La
|
||||
void labelsIdsInterface(List<Integer> data);
|
||||
}
|
||||
|
||||
public LabelsListAdapter(List<Labels> labelsMain, LabelsListAdapterListener labelsListener, List<Integer> currentLabelsIds) {
|
||||
public LabelsListAdapter(List<Label> labelsMain, LabelsListAdapterListener labelsListener, List<Integer> currentLabelsIds) {
|
||||
|
||||
this.labels = labelsMain;
|
||||
this.labelsListener = labelsListener;
|
||||
@ -69,7 +69,7 @@ public class LabelsListAdapter extends RecyclerView.Adapter<LabelsListAdapter.La
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull LabelsListAdapter.LabelsViewHolder holder, int position) {
|
||||
|
||||
Labels currentItem = labels.get(position);
|
||||
Label currentItem = labels.get(position);
|
||||
|
||||
String labelColor = currentItem.getColor();
|
||||
int color = Color.parseColor("#" + labelColor);
|
||||
@ -89,7 +89,7 @@ public class LabelsListAdapter extends RecyclerView.Adapter<LabelsListAdapter.La
|
||||
|
||||
for(int i = 0; i < currentLabelsIds.size(); i++) {
|
||||
|
||||
if(currentLabelsIds.contains(currentItem.getId())) {
|
||||
if(currentLabelsIds.contains(currentItem.getId().intValue())) {
|
||||
|
||||
holder.labelSelection.setChecked(true);
|
||||
labelsIds.add(currentLabelsIds.get(i));
|
||||
@ -103,12 +103,12 @@ public class LabelsListAdapter extends RecyclerView.Adapter<LabelsListAdapter.La
|
||||
if(isChecked) {
|
||||
|
||||
labelsStrings.add(currentItem.getName());
|
||||
labelsIds.add(currentItem.getId());
|
||||
labelsIds.add(currentItem.getId().intValue());
|
||||
}
|
||||
else {
|
||||
|
||||
labelsStrings.remove(currentItem.getName());
|
||||
labelsIds.remove(Integer.valueOf(currentItem.getId()));
|
||||
labelsIds.remove(Integer.valueOf(currentItem.getId().intValue()));
|
||||
}
|
||||
|
||||
labelsListener.labelsInterface(labelsStrings);
|
||||
|
@ -2,7 +2,6 @@ package org.mian.gitnex.adapters;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@ -14,7 +13,7 @@ import androidx.core.content.res.ResourcesCompat;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
import com.vdurmont.emoji.EmojiParser;
|
||||
import org.gitnex.tea4j.models.Milestones;
|
||||
import org.gitnex.tea4j.v2.models.Milestone;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.actions.MilestoneActions;
|
||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||
@ -25,7 +24,6 @@ import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@ -38,12 +36,12 @@ import java.util.Locale;
|
||||
public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
private final Context context;
|
||||
private List<Milestones> dataList;
|
||||
private List<Milestone> dataList;
|
||||
private OnLoadMoreListener loadMoreListener;
|
||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
||||
private final RepositoryContext repository;
|
||||
|
||||
public MilestonesAdapter(Context ctx, List<Milestones> dataListMain, RepositoryContext repository) {
|
||||
public MilestonesAdapter(Context ctx, List<Milestone> dataListMain, RepositoryContext repository) {
|
||||
this.repository = repository;
|
||||
this.context = ctx;
|
||||
this.dataList = dataListMain;
|
||||
@ -69,7 +67,7 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
|
||||
class DataHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private Milestones milestones;
|
||||
private Milestone milestones;
|
||||
|
||||
private final TextView msTitle;
|
||||
private final TextView msDescription;
|
||||
@ -90,7 +88,7 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
msProgress = itemView.findViewById(R.id.milestoneProgress);
|
||||
ImageView milestonesMenu = itemView.findViewById(R.id.milestonesMenu);
|
||||
|
||||
if(!((RepoDetailActivity) itemView.getContext()).repository.getPermissions().canPush()) {
|
||||
if(!((RepoDetailActivity) itemView.getContext()).repository.getPermissions().isPush()) {
|
||||
milestonesMenu.setVisibility(View.GONE);
|
||||
}
|
||||
milestonesMenu.setOnClickListener(v -> {
|
||||
@ -137,7 +135,7 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
void bindData(Milestones dataModel) {
|
||||
void bindData(Milestone dataModel) {
|
||||
|
||||
this.milestones = dataModel;
|
||||
final TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
@ -155,19 +153,19 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
msDescription.setText(context.getString(R.string.milestoneNoDescription));
|
||||
}
|
||||
|
||||
msOpenIssues.setText(context.getString(R.string.milestoneIssueStatusOpen, dataModel.getOpen_issues()));
|
||||
msClosedIssues.setText(context.getString(R.string.milestoneIssueStatusClosed, dataModel.getClosed_issues()));
|
||||
msOpenIssues.setText(context.getString(R.string.milestoneIssueStatusOpen, dataModel.getOpenIssues()));
|
||||
msClosedIssues.setText(context.getString(R.string.milestoneIssueStatusClosed, dataModel.getClosedIssues()));
|
||||
|
||||
if((dataModel.getOpen_issues() + dataModel.getClosed_issues()) > 0) {
|
||||
if((dataModel.getOpenIssues() + dataModel.getClosedIssues()) > 0) {
|
||||
|
||||
if(dataModel.getOpen_issues() == 0) {
|
||||
if(dataModel.getOpenIssues() == 0) {
|
||||
|
||||
msProgress.setProgress(100);
|
||||
msProgress.setOnClickListener(new ClickListener(context.getResources().getString(R.string.milestoneCompletion, 100), context));
|
||||
}
|
||||
else {
|
||||
|
||||
int msCompletion = 100 * dataModel.getClosed_issues() / (dataModel.getOpen_issues() + dataModel.getClosed_issues());
|
||||
int msCompletion = (int) (100 * dataModel.getClosedIssues() / (dataModel.getOpenIssues() + dataModel.getClosedIssues()));
|
||||
msProgress.setOnClickListener(new ClickListener(context.getResources().getString(R.string.milestoneCompletion, msCompletion), context));
|
||||
msProgress.setProgress(msCompletion);
|
||||
}
|
||||
@ -179,20 +177,13 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
msProgress.setOnClickListener(new ClickListener(context.getResources().getString(R.string.milestoneCompletion, 0), context));
|
||||
}
|
||||
|
||||
if(dataModel.getDue_on() != null) {
|
||||
if(dataModel.getDueOn() != null) {
|
||||
|
||||
String TAG = Constants.tagMilestonesAdapter;
|
||||
if(timeFormat.equals("normal") || timeFormat.equals("pretty")) {
|
||||
|
||||
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd", new Locale(locale));
|
||||
Date date = null;
|
||||
|
||||
try {
|
||||
date = formatter.parse(dataModel.getDue_on());
|
||||
}
|
||||
catch(ParseException e) {
|
||||
Log.e(TAG, e.toString());
|
||||
}
|
||||
Date date = dataModel.getDueOn();
|
||||
|
||||
assert date != null;
|
||||
String dueDate = formatter.format(date);
|
||||
@ -202,20 +193,13 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
}
|
||||
|
||||
msDueDate.setText(dueDate);
|
||||
msDueDate.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToast(dataModel.getDue_on()), context));
|
||||
msDueDate.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(dataModel.getDueOn()), context));
|
||||
}
|
||||
else if(timeFormat.equals("normal1")) {
|
||||
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy", new Locale(locale));
|
||||
|
||||
Date date1 = null;
|
||||
|
||||
try {
|
||||
date1 = formatter.parse(dataModel.getDue_on());
|
||||
}
|
||||
catch(ParseException e) {
|
||||
Log.e(TAG, e.toString());
|
||||
}
|
||||
Date date1 = dataModel.getDueOn();
|
||||
|
||||
assert date1 != null;
|
||||
String dueDate = formatter.format(date1);
|
||||
@ -269,7 +253,7 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<Milestones> list) {
|
||||
public void updateList(List<Milestone> list) {
|
||||
dataList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.core.content.res.ResourcesCompat;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.amulyakhare.textdrawable.TextDrawable;
|
||||
import org.gitnex.tea4j.models.Emails;
|
||||
import org.gitnex.tea4j.v2.models.Email;
|
||||
import org.mian.gitnex.R;
|
||||
import java.util.List;
|
||||
|
||||
@ -20,7 +20,7 @@ import java.util.List;
|
||||
|
||||
public class MyProfileEmailsAdapter extends RecyclerView.Adapter<MyProfileEmailsAdapter.EmailsViewHolder> {
|
||||
|
||||
private final List<Emails> emailsList;
|
||||
private final List<Email> emailsList;
|
||||
private final Context context;
|
||||
|
||||
static class EmailsViewHolder extends RecyclerView.ViewHolder {
|
||||
@ -37,7 +37,7 @@ public class MyProfileEmailsAdapter extends RecyclerView.Adapter<MyProfileEmails
|
||||
}
|
||||
}
|
||||
|
||||
public MyProfileEmailsAdapter(Context ctx, List<Emails> emailsListMain) {
|
||||
public MyProfileEmailsAdapter(Context ctx, List<Email> emailsListMain) {
|
||||
this.context = ctx;
|
||||
this.emailsList = emailsListMain;
|
||||
}
|
||||
@ -52,11 +52,11 @@ public class MyProfileEmailsAdapter extends RecyclerView.Adapter<MyProfileEmails
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull MyProfileEmailsAdapter.EmailsViewHolder holder, int position) {
|
||||
|
||||
Emails currentItem = emailsList.get(position);
|
||||
Email currentItem = emailsList.get(position);
|
||||
|
||||
holder.userEmail.setText(currentItem.getEmail());
|
||||
|
||||
if(currentItem.getPrimary()) {
|
||||
if(currentItem.isPrimary()) {
|
||||
TextDrawable drawable = TextDrawable.builder()
|
||||
.beginConfig()
|
||||
.textColor(ResourcesCompat.getColor(context.getResources(), R.color.colorWhite, null))
|
||||
|
@ -15,7 +15,7 @@ import androidx.core.text.HtmlCompat;
|
||||
import androidx.core.widget.ImageViewCompat;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.gitnex.tea4j.models.NotificationThread;
|
||||
import org.gitnex.tea4j.v2.models.NotificationThread;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import java.util.List;
|
||||
|
@ -12,7 +12,7 @@ import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import org.gitnex.tea4j.models.UserOrganizations;
|
||||
import org.gitnex.tea4j.v2.models.Organization;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.OrganizationDetailActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
@ -28,12 +28,12 @@ import java.util.List;
|
||||
public class OrganizationsListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements Filterable {
|
||||
|
||||
private final Context context;
|
||||
private List<UserOrganizations> orgList;
|
||||
private final List<UserOrganizations> orgListFull;
|
||||
private List<Organization> orgList;
|
||||
private final List<Organization> orgListFull;
|
||||
private OnLoadMoreListener loadMoreListener;
|
||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
||||
|
||||
public OrganizationsListAdapter(List<UserOrganizations> orgListMain, Context ctx) {
|
||||
public OrganizationsListAdapter(List<Organization> orgListMain, Context ctx) {
|
||||
this.context = ctx;
|
||||
this.orgList = orgListMain;
|
||||
orgListFull = new ArrayList<>(orgList);
|
||||
@ -68,7 +68,7 @@ public class OrganizationsListAdapter extends RecyclerView.Adapter<RecyclerView.
|
||||
|
||||
class OrgHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private UserOrganizations userOrganizations;
|
||||
private Organization userOrganizations;
|
||||
|
||||
private final ImageView image;
|
||||
private final TextView orgName;
|
||||
@ -89,14 +89,14 @@ public class OrganizationsListAdapter extends RecyclerView.Adapter<RecyclerView.
|
||||
});
|
||||
}
|
||||
|
||||
void bindData(UserOrganizations org) {
|
||||
void bindData(Organization org) {
|
||||
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||
|
||||
this.userOrganizations = org;
|
||||
orgName.setText(org.getUsername());
|
||||
|
||||
PicassoService.getInstance(context).get().load(org.getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(image);
|
||||
PicassoService.getInstance(context).get().load(org.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(image);
|
||||
|
||||
if(!org.getDescription().equals("")) {
|
||||
orgDescription.setVisibility(View.VISIBLE);
|
||||
@ -132,7 +132,7 @@ public class OrganizationsListAdapter extends RecyclerView.Adapter<RecyclerView.
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<UserOrganizations> list) {
|
||||
public void updateList(List<Organization> list) {
|
||||
orgList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
@ -147,7 +147,7 @@ public class OrganizationsListAdapter extends RecyclerView.Adapter<RecyclerView.
|
||||
@Override
|
||||
protected FilterResults performFiltering(CharSequence constraint) {
|
||||
|
||||
List<UserOrganizations> filteredList = new ArrayList<>();
|
||||
List<Organization> filteredList = new ArrayList<>();
|
||||
|
||||
if(constraint == null || constraint.length() == 0) {
|
||||
|
||||
@ -157,7 +157,7 @@ public class OrganizationsListAdapter extends RecyclerView.Adapter<RecyclerView.
|
||||
|
||||
String filterPattern = constraint.toString().toLowerCase().trim();
|
||||
|
||||
for(UserOrganizations item : orgListFull) {
|
||||
for(Organization item : orgListFull) {
|
||||
if(item.getUsername().toLowerCase().contains(filterPattern) || item.getDescription().toLowerCase().contains(filterPattern)) {
|
||||
filteredList.add(item);
|
||||
}
|
||||
|
@ -19,10 +19,11 @@ import androidx.core.text.HtmlCompat;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.amulyakhare.textdrawable.TextDrawable;
|
||||
import com.vdurmont.emoji.EmojiParser;
|
||||
import org.gitnex.tea4j.models.PullRequests;
|
||||
import org.gitnex.tea4j.v2.models.PullRequest;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.IssueDetailActivity;
|
||||
import org.mian.gitnex.activities.ProfileActivity;
|
||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.ClickListener;
|
||||
@ -32,7 +33,6 @@ import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.contexts.IssueContext;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
@ -43,11 +43,11 @@ import java.util.Locale;
|
||||
public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
private final Context context;
|
||||
private List<PullRequests> prList;
|
||||
private List<PullRequest> prList;
|
||||
private Runnable loadMoreListener;
|
||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
||||
|
||||
public PullRequestsAdapter(Context context, List<PullRequests> prListMain) {
|
||||
public PullRequestsAdapter(Context context, List<PullRequest> prListMain) {
|
||||
this.context = context;
|
||||
this.prList = prListMain;
|
||||
}
|
||||
@ -81,7 +81,7 @@ public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||
|
||||
class PullRequestsHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private PullRequests pullRequestObject;
|
||||
private PullRequest pullRequestObject;
|
||||
|
||||
private final ImageView assigneeAvatar;
|
||||
private final TextView prTitle;
|
||||
@ -104,16 +104,14 @@ public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||
labelsScrollViewDots = itemView.findViewById(R.id.labelsScrollViewDots);
|
||||
frameLabelsDots = itemView.findViewById(R.id.frameLabelsDots);
|
||||
|
||||
itemView.setOnClickListener(v -> {
|
||||
Intent intent = new IssueContext(
|
||||
pullRequestObject,
|
||||
new RepositoryContext(pullRequestObject.getBase().getRepo().getFull_name().split("/")[0], pullRequestObject.getBase().getRepo().getName(), context)
|
||||
)
|
||||
.getIntent(context, IssueDetailActivity.class);
|
||||
View.OnClickListener openPr = v -> {
|
||||
Intent intentPrDetail = new IssueContext(pullRequestObject, ((RepoDetailActivity) context).repository).getIntent(context, IssueDetailActivity.class);
|
||||
context.startActivity(intentPrDetail);
|
||||
};
|
||||
|
||||
context.startActivity(intent);
|
||||
|
||||
});
|
||||
itemView.setOnClickListener(openPr);
|
||||
frameLabels.setOnClickListener(openPr);
|
||||
frameLabelsDots.setOnClickListener(openPr);
|
||||
|
||||
assigneeAvatar.setOnClickListener(v -> {
|
||||
Intent intent = new Intent(context, ProfileActivity.class);
|
||||
@ -128,7 +126,7 @@ public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
void bindData(PullRequests pullRequest) {
|
||||
void bindData(PullRequest pullRequest) {
|
||||
|
||||
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
Locale locale = context.getResources().getConfiguration().locale;
|
||||
@ -136,7 +134,7 @@ public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||
|
||||
PicassoService.getInstance(context).get()
|
||||
.load(pullRequest.getUser().getAvatar_url())
|
||||
.load(pullRequest.getUser().getAvatarUrl())
|
||||
.placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(imgRadius, 0))
|
||||
.resize(120, 120)
|
||||
@ -210,10 +208,10 @@ public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||
|
||||
this.prTitle.setText(HtmlCompat.fromHtml(prNumber_ + " " + EmojiParser.parseToUnicode(pullRequest.getTitle()), HtmlCompat.FROM_HTML_MODE_LEGACY));
|
||||
this.prCommentsCount.setText(String.valueOf(pullRequest.getComments()));
|
||||
this.prCreatedTime.setText(TimeHelper.formatTime(pullRequest.getCreated_at(), locale, timeFormat, context));
|
||||
this.prCreatedTime.setText(TimeHelper.formatTime(pullRequest.getCreatedAt(), locale, timeFormat, context));
|
||||
|
||||
if(timeFormat.equals("pretty")) {
|
||||
this.prCreatedTime.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(pullRequest.getCreated_at()), context));
|
||||
this.prCreatedTime.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(pullRequest.getCreatedAt()), context));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -232,7 +230,7 @@ public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<PullRequests> list) {
|
||||
public void updateList(List<PullRequest> list) {
|
||||
prList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import org.gitnex.tea4j.models.UserInfo;
|
||||
import org.gitnex.tea4j.v2.models.User;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
@ -22,9 +22,9 @@ import java.util.List;
|
||||
public class ReactionAuthorsAdapter extends RecyclerView.Adapter<ReactionAuthorsAdapter.ViewHolder> {
|
||||
|
||||
private final Context context;
|
||||
private final List<UserInfo> userInfos;
|
||||
private final List<User> userInfos;
|
||||
|
||||
public ReactionAuthorsAdapter(Context context, List<UserInfo> userInfos) {
|
||||
public ReactionAuthorsAdapter(Context context, List<User> userInfos) {
|
||||
this.context = context;
|
||||
this.userInfos = userInfos;
|
||||
}
|
||||
@ -37,19 +37,19 @@ public class ReactionAuthorsAdapter extends RecyclerView.Adapter<ReactionAuthors
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||
UserInfo userInfo = userInfos.get(position);
|
||||
User userInfo = userInfos.get(position);
|
||||
|
||||
PicassoService.getInstance(context).get()
|
||||
.load(userInfo.getAvatar())
|
||||
.load(userInfo.getAvatarUrl())
|
||||
.placeholder(R.drawable.loader_animated)
|
||||
.resize(240, 240)
|
||||
.transform(new RoundedTransformation(AppUtil.getPixelsFromDensity(context, 6), 0))
|
||||
.centerCrop().into(holder.authorAvatar);
|
||||
|
||||
if(userInfo.getFullname() == null || userInfo.getFullname().isEmpty()) {
|
||||
if(userInfo.getFullName() == null || userInfo.getFullName().isEmpty()) {
|
||||
holder.authorFullName.setVisibility(View.GONE);
|
||||
} else {
|
||||
holder.authorFullName.setText(userInfo.getFullname());
|
||||
holder.authorFullName.setText(userInfo.getFullName());
|
||||
holder.authorFullName.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.core.text.HtmlCompat;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import org.gitnex.tea4j.models.Releases;
|
||||
import org.gitnex.tea4j.v2.models.Release;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.ProfileActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
@ -32,7 +32,7 @@ import java.util.Locale;
|
||||
|
||||
public class ReleasesAdapter extends RecyclerView.Adapter<ReleasesAdapter.ReleasesViewHolder> {
|
||||
|
||||
private List<Releases> releasesList;
|
||||
private List<Release> releasesList;
|
||||
private final Context context;
|
||||
|
||||
private OnLoadMoreListener loadMoreListener;
|
||||
@ -40,7 +40,7 @@ public class ReleasesAdapter extends RecyclerView.Adapter<ReleasesAdapter.Releas
|
||||
|
||||
static class ReleasesViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private Releases releases;
|
||||
private Release releases;
|
||||
|
||||
private final TextView releaseType;
|
||||
private final TextView releaseName;
|
||||
@ -88,7 +88,7 @@ public class ReleasesAdapter extends RecyclerView.Adapter<ReleasesAdapter.Releas
|
||||
}
|
||||
}
|
||||
|
||||
public ReleasesAdapter(Context ctx, List<Releases> releasesMain) {
|
||||
public ReleasesAdapter(Context ctx, List<Release> releasesMain) {
|
||||
this.context = ctx;
|
||||
this.releasesList = releasesMain;
|
||||
}
|
||||
@ -108,7 +108,7 @@ public class ReleasesAdapter extends RecyclerView.Adapter<ReleasesAdapter.Releas
|
||||
final String timeFormat = tinyDb.getString("dateFormat", "pretty");
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||
|
||||
Releases currentItem = releasesList.get(position);
|
||||
Release currentItem = releasesList.get(position);
|
||||
holder.releases = currentItem;
|
||||
|
||||
holder.releaseName.setText(currentItem.getName());
|
||||
@ -126,22 +126,22 @@ public class ReleasesAdapter extends RecyclerView.Adapter<ReleasesAdapter.Releas
|
||||
holder.releaseType.setText(R.string.releaseTypeStable);
|
||||
}
|
||||
|
||||
if(currentItem.getAuthor().getAvatar_url() != null) {
|
||||
PicassoService.getInstance(context).get().load(currentItem.getAuthor().getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(holder.authorAvatar);
|
||||
if(currentItem.getAuthor().getAvatarUrl() != null) {
|
||||
PicassoService.getInstance(context).get().load(currentItem.getAuthor().getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(holder.authorAvatar);
|
||||
}
|
||||
|
||||
holder.authorName.setText(context.getResources().getString(R.string.releasePublishedBy, currentItem.getAuthor().getUsername()));
|
||||
holder.authorName.setText(context.getResources().getString(R.string.releasePublishedBy, currentItem.getAuthor().getLogin()));
|
||||
|
||||
if(currentItem.getTag_name() != null) {
|
||||
holder.releaseTag.setText(currentItem.getTag_name());
|
||||
if(currentItem.getTagName() != null) {
|
||||
holder.releaseTag.setText(currentItem.getTagName());
|
||||
}
|
||||
|
||||
if(currentItem.getPublished_at() != null) {
|
||||
holder.releaseDate.setText(TimeHelper.formatTime(currentItem.getPublished_at(), locale, timeFormat, context));
|
||||
if(currentItem.getPublishedAt() != null) {
|
||||
holder.releaseDate.setText(TimeHelper.formatTime(currentItem.getPublishedAt(), locale, timeFormat, context));
|
||||
}
|
||||
|
||||
if(timeFormat.equals("pretty")) {
|
||||
holder.releaseDate.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(currentItem.getPublished_at()), context));
|
||||
holder.releaseDate.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(currentItem.getPublishedAt()), context));
|
||||
}
|
||||
|
||||
if(!currentItem.getBody().equals("")) {
|
||||
@ -167,11 +167,11 @@ public class ReleasesAdapter extends RecyclerView.Adapter<ReleasesAdapter.Releas
|
||||
});
|
||||
|
||||
holder.releaseZipDownload.setText(
|
||||
HtmlCompat.fromHtml("<a href='" + currentItem.getZipball_url() + "'>" + context.getResources().getString(R.string.zipArchiveDownloadReleasesTab) + "</a> ", HtmlCompat.FROM_HTML_MODE_LEGACY));
|
||||
HtmlCompat.fromHtml("<a href='" + currentItem.getZipballUrl() + "'>" + context.getResources().getString(R.string.zipArchiveDownloadReleasesTab) + "</a> ", HtmlCompat.FROM_HTML_MODE_LEGACY));
|
||||
holder.releaseZipDownload.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
|
||||
holder.releaseTarDownload.setText(
|
||||
HtmlCompat.fromHtml("<a href='" + currentItem.getTarball_url() + "'>" + context.getResources().getString(R.string.tarArchiveDownloadReleasesTab) + "</a> ", HtmlCompat.FROM_HTML_MODE_LEGACY));
|
||||
HtmlCompat.fromHtml("<a href='" + currentItem.getTarballUrl() + "'>" + context.getResources().getString(R.string.tarArchiveDownloadReleasesTab) + "</a> ", HtmlCompat.FROM_HTML_MODE_LEGACY));
|
||||
holder.releaseTarDownload.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
|
||||
ReleasesDownloadsAdapter adapter = new ReleasesDownloadsAdapter(currentItem.getAssets());
|
||||
@ -211,7 +211,7 @@ public class ReleasesAdapter extends RecyclerView.Adapter<ReleasesAdapter.Releas
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<Releases> list) {
|
||||
public void updateList(List<Release> list) {
|
||||
releasesList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.text.HtmlCompat;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import org.gitnex.tea4j.models.Releases;
|
||||
import org.gitnex.tea4j.v2.models.Attachment;
|
||||
import org.mian.gitnex.R;
|
||||
import java.util.List;
|
||||
|
||||
@ -18,7 +18,7 @@ import java.util.List;
|
||||
|
||||
public class ReleasesDownloadsAdapter extends RecyclerView.Adapter<ReleasesDownloadsAdapter.ReleasesDownloadsViewHolder> {
|
||||
|
||||
private final List<Releases.assetsObject> releasesDownloadsList;
|
||||
private final List<Attachment> releasesDownloadsList;
|
||||
|
||||
static class ReleasesDownloadsViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
@ -31,7 +31,7 @@ public class ReleasesDownloadsAdapter extends RecyclerView.Adapter<ReleasesDownl
|
||||
}
|
||||
}
|
||||
|
||||
ReleasesDownloadsAdapter(List<Releases.assetsObject> releasesDownloadsMain) {
|
||||
ReleasesDownloadsAdapter(List<Attachment> releasesDownloadsMain) {
|
||||
|
||||
this.releasesDownloadsList = releasesDownloadsMain;
|
||||
}
|
||||
@ -46,12 +46,12 @@ public class ReleasesDownloadsAdapter extends RecyclerView.Adapter<ReleasesDownl
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ReleasesDownloadsAdapter.ReleasesDownloadsViewHolder holder, int position) {
|
||||
|
||||
Releases.assetsObject currentItem = releasesDownloadsList.get(position);
|
||||
Attachment currentItem = releasesDownloadsList.get(position);
|
||||
|
||||
if(currentItem.getName() != null) {
|
||||
|
||||
holder.downloadName.setText(
|
||||
HtmlCompat.fromHtml("<a href='" + currentItem.getBrowser_download_url() + "'>" + currentItem.getName() + "</a> ", HtmlCompat.FROM_HTML_MODE_LEGACY));
|
||||
HtmlCompat.fromHtml("<a href='" + currentItem.getBrowserDownloadUrl() + "'>" + currentItem.getName() + "</a> ", HtmlCompat.FROM_HTML_MODE_LEGACY));
|
||||
holder.downloadName.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
|
||||
}
|
||||
|
@ -14,7 +14,6 @@ import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.amulyakhare.textdrawable.TextDrawable;
|
||||
import com.amulyakhare.textdrawable.util.ColorGenerator;
|
||||
import org.gitnex.tea4j.models.UserRepositories;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
@ -40,12 +39,12 @@ import java.util.Locale;
|
||||
public class RepoForksAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
private final Context context;
|
||||
private List<UserRepositories> forksList;
|
||||
private List<org.gitnex.tea4j.v2.models.Repository> forksList;
|
||||
private Runnable loadMoreListener;
|
||||
private boolean isLoading = false;
|
||||
private boolean isMoreDataAvailable = true;
|
||||
|
||||
public RepoForksAdapter(Context ctx, List<UserRepositories> forksListMain) {
|
||||
public RepoForksAdapter(Context ctx, List<org.gitnex.tea4j.v2.models.Repository> forksListMain) {
|
||||
|
||||
this.context = ctx;
|
||||
this.forksList = forksListMain;
|
||||
@ -80,7 +79,7 @@ public class RepoForksAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
||||
|
||||
class ForksHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private UserRepositories userRepositories;
|
||||
private org.gitnex.tea4j.v2.models.Repository userRepositories;
|
||||
|
||||
private final ImageView image;
|
||||
private final TextView repoName;
|
||||
@ -103,7 +102,7 @@ public class RepoForksAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
void bindData(UserRepositories forksModel) {
|
||||
void bindData(org.gitnex.tea4j.v2.models.Repository forksModel) {
|
||||
|
||||
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||
@ -113,7 +112,7 @@ public class RepoForksAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
||||
this.userRepositories = forksModel;
|
||||
orgName.setText(forksModel.getFullName().split("/")[0]);
|
||||
repoName.setText(forksModel.getFullName().split("/")[1]);
|
||||
repoStars.setText(forksModel.getStars_count());
|
||||
repoStars.setText(String.valueOf(forksModel.getStarsCount()));
|
||||
|
||||
ColorGenerator generator = ColorGenerator.Companion.getMATERIAL();
|
||||
int color = generator.getColor(forksModel.getName());
|
||||
@ -122,9 +121,9 @@ public class RepoForksAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).fontSize(18).toUpperCase().width(28).height(28)
|
||||
.endConfig().buildRoundRect(firstCharacter, color, 3);
|
||||
|
||||
if(forksModel.getAvatar_url() != null) {
|
||||
if(!forksModel.getAvatar_url().equals("")) {
|
||||
PicassoService.getInstance(context).get().load(forksModel.getAvatar_url()).placeholder(R.drawable.loader_animated)
|
||||
if(forksModel.getAvatarUrl() != null) {
|
||||
if(!forksModel.getAvatarUrl().equals("")) {
|
||||
PicassoService.getInstance(context).get().load(forksModel.getAvatarUrl()).placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(image);
|
||||
}
|
||||
else {
|
||||
@ -135,25 +134,25 @@ public class RepoForksAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
||||
image.setImageDrawable(drawable);
|
||||
}
|
||||
|
||||
if(forksModel.getUpdated_at() != null) {
|
||||
if(forksModel.getUpdatedAt() != null) {
|
||||
|
||||
switch(timeFormat) {
|
||||
case "pretty": {
|
||||
PrettyTime prettyTime = new PrettyTime(locale);
|
||||
String createdTime = prettyTime.format(forksModel.getUpdated_at());
|
||||
String createdTime = prettyTime.format(forksModel.getUpdatedAt());
|
||||
repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
|
||||
repoLastUpdated.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(forksModel.getUpdated_at()), context));
|
||||
repoLastUpdated.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(forksModel.getUpdatedAt()), context));
|
||||
break;
|
||||
}
|
||||
case "normal": {
|
||||
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", locale);
|
||||
String createdTime = formatter.format(forksModel.getUpdated_at());
|
||||
String createdTime = formatter.format(forksModel.getUpdatedAt());
|
||||
repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
|
||||
break;
|
||||
}
|
||||
case "normal1": {
|
||||
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", locale);
|
||||
String createdTime = formatter.format(forksModel.getUpdated_at());
|
||||
String createdTime = formatter.format(forksModel.getUpdatedAt());
|
||||
repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
|
||||
break;
|
||||
}
|
||||
@ -221,7 +220,7 @@ public class RepoForksAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<UserRepositories> list) {
|
||||
public void updateList(List<org.gitnex.tea4j.v2.models.Repository> list) {
|
||||
forksList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
@ -16,7 +16,6 @@ import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.amulyakhare.textdrawable.TextDrawable;
|
||||
import com.amulyakhare.textdrawable.util.ColorGenerator;
|
||||
import org.gitnex.tea4j.models.UserRepositories;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
@ -43,13 +42,13 @@ import java.util.Locale;
|
||||
public class ReposListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements Filterable {
|
||||
|
||||
private final Context context;
|
||||
private List<UserRepositories> reposList;
|
||||
private final List<UserRepositories> reposListFull;
|
||||
private List<org.gitnex.tea4j.v2.models.Repository> reposList;
|
||||
private final List<org.gitnex.tea4j.v2.models.Repository> reposListFull;
|
||||
private OnLoadMoreListener loadMoreListener;
|
||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
||||
private final TinyDB tinyDb;
|
||||
|
||||
public ReposListAdapter(List<UserRepositories> reposListMain, Context ctx) {
|
||||
public ReposListAdapter(List<org.gitnex.tea4j.v2.models.Repository> reposListMain, Context ctx) {
|
||||
this.context = ctx;
|
||||
this.reposList = reposListMain;
|
||||
reposListFull = new ArrayList<>(reposList);
|
||||
@ -85,7 +84,7 @@ public class ReposListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
||||
|
||||
class ReposHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private UserRepositories userRepositories;
|
||||
private org.gitnex.tea4j.v2.models.Repository userRepositories;
|
||||
|
||||
private final ImageView image;
|
||||
private final TextView repoName;
|
||||
@ -133,7 +132,7 @@ public class ReposListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
void bindData(UserRepositories repositories) {
|
||||
void bindData(org.gitnex.tea4j.v2.models.Repository repositories) {
|
||||
|
||||
this.userRepositories = repositories;
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||
@ -142,7 +141,7 @@ public class ReposListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
||||
String timeFormat = tinyDb.getString("dateFormat", "pretty");
|
||||
orgName.setText(repositories.getFullName().split("/")[0]);
|
||||
repoName.setText(repositories.getFullName().split("/")[1]);
|
||||
repoStars.setText(repositories.getStars_count());
|
||||
repoStars.setText(String.valueOf(repositories.getStarsCount()));
|
||||
|
||||
ColorGenerator generator = ColorGenerator.Companion.getMATERIAL();
|
||||
int color = generator.getColor(repositories.getName());
|
||||
@ -150,9 +149,9 @@ public class ReposListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
||||
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).fontSize(18).toUpperCase().width(28).height(28).endConfig().buildRoundRect(firstCharacter, color, 3);
|
||||
|
||||
if(repositories.getAvatar_url() != null) {
|
||||
if(!repositories.getAvatar_url().equals("")) {
|
||||
PicassoService.getInstance(context).get().load(repositories.getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(image);
|
||||
if(repositories.getAvatarUrl() != null) {
|
||||
if(!repositories.getAvatarUrl().equals("")) {
|
||||
PicassoService.getInstance(context).get().load(repositories.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(image);
|
||||
}
|
||||
else {
|
||||
image.setImageDrawable(drawable);
|
||||
@ -162,25 +161,25 @@ public class ReposListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
||||
image.setImageDrawable(drawable);
|
||||
}
|
||||
|
||||
if(repositories.getUpdated_at() != null) {
|
||||
if(repositories.getUpdatedAt() != null) {
|
||||
|
||||
switch(timeFormat) {
|
||||
case "pretty": {
|
||||
PrettyTime prettyTime = new PrettyTime(locale);
|
||||
String createdTime = prettyTime.format(repositories.getUpdated_at());
|
||||
String createdTime = prettyTime.format(repositories.getUpdatedAt());
|
||||
repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
|
||||
repoLastUpdated.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(repositories.getUpdated_at()), context));
|
||||
repoLastUpdated.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(repositories.getUpdatedAt()), context));
|
||||
break;
|
||||
}
|
||||
case "normal": {
|
||||
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", locale);
|
||||
String createdTime = formatter.format(repositories.getUpdated_at());
|
||||
String createdTime = formatter.format(repositories.getUpdatedAt());
|
||||
repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
|
||||
break;
|
||||
}
|
||||
case "normal1": {
|
||||
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", locale);
|
||||
String createdTime = formatter.format(repositories.getUpdated_at());
|
||||
String createdTime = formatter.format(repositories.getUpdatedAt());
|
||||
repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
|
||||
break;
|
||||
}
|
||||
@ -230,7 +229,7 @@ public class ReposListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<UserRepositories> list) {
|
||||
public void updateList(List<org.gitnex.tea4j.v2.models.Repository> list) {
|
||||
reposList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
@ -245,7 +244,7 @@ public class ReposListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
||||
@Override
|
||||
protected FilterResults performFiltering(CharSequence constraint) {
|
||||
|
||||
List<UserRepositories> filteredList = new ArrayList<>();
|
||||
List<org.gitnex.tea4j.v2.models.Repository> filteredList = new ArrayList<>();
|
||||
|
||||
if(constraint == null || constraint.length() == 0) {
|
||||
filteredList.addAll(reposListFull);
|
||||
@ -253,7 +252,7 @@ public class ReposListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
||||
else {
|
||||
String filterPattern = constraint.toString().toLowerCase().trim();
|
||||
|
||||
for(UserRepositories item : reposListFull) {
|
||||
for(org.gitnex.tea4j.v2.models.Repository item : reposListFull) {
|
||||
if(item.getFullName().toLowerCase().contains(filterPattern) || item.getDescription().toLowerCase().contains(filterPattern)) {
|
||||
filteredList.add(item);
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.core.text.HtmlCompat;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
import org.gitnex.tea4j.models.GitTag;
|
||||
import org.gitnex.tea4j.v2.models.Tag;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
@ -26,7 +26,7 @@ import java.util.List;
|
||||
|
||||
public class TagsAdapter extends RecyclerView.Adapter<TagsAdapter.TagsViewHolder> {
|
||||
|
||||
private List<GitTag> tags;
|
||||
private List<Tag> tags;
|
||||
private final Context context;
|
||||
private final String repo;
|
||||
private final String owner;
|
||||
@ -60,7 +60,7 @@ public class TagsAdapter extends RecyclerView.Adapter<TagsAdapter.TagsViewHolder
|
||||
}
|
||||
}
|
||||
|
||||
public TagsAdapter(Context ctx, List<GitTag> releasesMain, String repoOwner, String repoName) {
|
||||
public TagsAdapter(Context ctx, List<Tag> releasesMain, String repoOwner, String repoName) {
|
||||
this.context = ctx;
|
||||
this.tags = releasesMain;
|
||||
owner = repoOwner;
|
||||
@ -77,7 +77,7 @@ public class TagsAdapter extends RecyclerView.Adapter<TagsAdapter.TagsViewHolder
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull TagsViewHolder holder, int position) {
|
||||
|
||||
GitTag currentItem = tags.get(position);
|
||||
Tag currentItem = tags.get(position);
|
||||
|
||||
holder.tagName.setText(currentItem.getName());
|
||||
|
||||
@ -102,7 +102,7 @@ public class TagsAdapter extends RecyclerView.Adapter<TagsAdapter.TagsViewHolder
|
||||
}
|
||||
});
|
||||
|
||||
if(!((RepoDetailActivity) context).repository.getPermissions().canPush()) {
|
||||
if(!((RepoDetailActivity) context).repository.getPermissions().isPush()) {
|
||||
holder.options.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@ -165,7 +165,7 @@ public class TagsAdapter extends RecyclerView.Adapter<TagsAdapter.TagsViewHolder
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<GitTag> list) {
|
||||
public void updateList(List<Tag> list) {
|
||||
tags = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import org.gitnex.tea4j.models.UserInfo;
|
||||
import org.gitnex.tea4j.v2.models.User;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
@ -21,9 +21,9 @@ import java.util.List;
|
||||
public class TeamMembersByOrgPreviewAdapter extends RecyclerView.Adapter<TeamMembersByOrgPreviewAdapter.ViewHolder> {
|
||||
|
||||
private final Context context;
|
||||
private final List<UserInfo> userData;
|
||||
private final List<User> userData;
|
||||
|
||||
public TeamMembersByOrgPreviewAdapter(Context context, List<UserInfo> userInfo) {
|
||||
public TeamMembersByOrgPreviewAdapter(Context context, List<User> userInfo) {
|
||||
this.context = context;
|
||||
this.userData = userInfo;
|
||||
}
|
||||
@ -37,10 +37,10 @@ public class TeamMembersByOrgPreviewAdapter extends RecyclerView.Adapter<TeamMem
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||
UserInfo userInfo = userData.get(position);
|
||||
User userInfo = userData.get(position);
|
||||
|
||||
PicassoService.getInstance(context).get()
|
||||
.load(userInfo.getAvatar())
|
||||
.load(userInfo.getAvatarUrl())
|
||||
.placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(AppUtil.getPixelsFromDensity(context, 3), 0))
|
||||
.resize(120, 120)
|
||||
|
@ -12,11 +12,10 @@ import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import org.gitnex.tea4j.models.OrgPermissions;
|
||||
import org.gitnex.tea4j.models.Teams;
|
||||
import org.gitnex.tea4j.models.UserInfo;
|
||||
import org.gitnex.tea4j.v2.models.OrganizationPermissions;
|
||||
import org.gitnex.tea4j.v2.models.Team;
|
||||
import org.gitnex.tea4j.v2.models.User;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.activities.OrganizationTeamInfoActivity;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import java.util.ArrayList;
|
||||
@ -32,22 +31,22 @@ import retrofit2.Response;
|
||||
|
||||
public class TeamsByOrgAdapter extends RecyclerView.Adapter<TeamsByOrgAdapter.OrgTeamsViewHolder> implements Filterable {
|
||||
|
||||
private final List<Teams> teamList;
|
||||
private final List<Team> teamList;
|
||||
private final Context context;
|
||||
private final List<Teams> teamListFull;
|
||||
private final OrgPermissions permissions;
|
||||
private final List<Team> teamListFull;
|
||||
private final OrganizationPermissions permissions;
|
||||
private final String orgName;
|
||||
|
||||
static class OrgTeamsViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private Teams team;
|
||||
private Team team;
|
||||
|
||||
private OrgPermissions permissions;
|
||||
private OrganizationPermissions permissions;
|
||||
private final TextView teamTitle;
|
||||
private final TextView teamDescription;
|
||||
private final LinearLayout membersPreviewFrame;
|
||||
|
||||
private final List<UserInfo> userInfos;
|
||||
private final List<User> userInfos;
|
||||
private final TeamMembersByOrgPreviewAdapter adapter;
|
||||
private String orgName;
|
||||
|
||||
@ -78,7 +77,7 @@ public class TeamsByOrgAdapter extends RecyclerView.Adapter<TeamsByOrgAdapter.Or
|
||||
}
|
||||
}
|
||||
|
||||
public TeamsByOrgAdapter(Context ctx, List<Teams> teamListMain, OrgPermissions permissions, String orgName) {
|
||||
public TeamsByOrgAdapter(Context ctx, List<Team> teamListMain, OrganizationPermissions permissions, String orgName) {
|
||||
this.context = ctx;
|
||||
this.teamList = teamListMain;
|
||||
this.permissions = permissions;
|
||||
@ -96,7 +95,7 @@ public class TeamsByOrgAdapter extends RecyclerView.Adapter<TeamsByOrgAdapter.Or
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull TeamsByOrgAdapter.OrgTeamsViewHolder holder, int position) {
|
||||
|
||||
Teams currentItem = teamList.get(position);
|
||||
Team currentItem = teamList.get(position);
|
||||
|
||||
holder.team = currentItem;
|
||||
holder.teamTitle.setText(currentItem.getName());
|
||||
@ -108,10 +107,10 @@ public class TeamsByOrgAdapter extends RecyclerView.Adapter<TeamsByOrgAdapter.Or
|
||||
holder.adapter.notifyDataSetChanged();
|
||||
|
||||
RetrofitClient.getApiInterface(context)
|
||||
.getTeamMembersByOrg(((BaseActivity) context).getAccount().getAuthorization(), currentItem.getId())
|
||||
.enqueue(new Callback<List<UserInfo>>() {
|
||||
.orgListTeamMembers(currentItem.getId(), null, null)
|
||||
.enqueue(new Callback<List<User>>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<UserInfo>> call, @NonNull Response<List<UserInfo>> response) {
|
||||
public void onResponse(@NonNull Call<List<User>> call, @NonNull Response<List<User>> response) {
|
||||
if(response.isSuccessful() &&
|
||||
response.body() != null &&
|
||||
response.body().size() > 0) {
|
||||
@ -125,7 +124,7 @@ public class TeamsByOrgAdapter extends RecyclerView.Adapter<TeamsByOrgAdapter.Or
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void onFailure(@NonNull Call<List<UserInfo>> call, @NonNull Throwable t) {}
|
||||
@Override public void onFailure(@NonNull Call<List<User>> call, @NonNull Throwable t) {}
|
||||
});
|
||||
|
||||
if (currentItem.getDescription() != null && !currentItem.getDescription().isEmpty()) {
|
||||
@ -150,14 +149,14 @@ public class TeamsByOrgAdapter extends RecyclerView.Adapter<TeamsByOrgAdapter.Or
|
||||
private final Filter orgTeamsFilter = new Filter() {
|
||||
@Override
|
||||
protected FilterResults performFiltering(CharSequence constraint) {
|
||||
List<Teams> filteredList = new ArrayList<>();
|
||||
List<Team> filteredList = new ArrayList<>();
|
||||
|
||||
if (constraint == null || constraint.length() == 0) {
|
||||
filteredList.addAll(teamListFull);
|
||||
} else {
|
||||
String filterPattern = constraint.toString().toLowerCase().trim();
|
||||
|
||||
for (Teams item : teamListFull) {
|
||||
for (Team item : teamListFull) {
|
||||
if (item.getName().toLowerCase().contains(filterPattern) || item.getDescription().toLowerCase().contains(filterPattern)) {
|
||||
filteredList.add(item);
|
||||
}
|
||||
@ -173,7 +172,7 @@ public class TeamsByOrgAdapter extends RecyclerView.Adapter<TeamsByOrgAdapter.Or
|
||||
@Override
|
||||
protected void publishResults(CharSequence constraint, FilterResults results) {
|
||||
teamList.clear();
|
||||
teamList.addAll((List<Teams>) results.values);
|
||||
teamList.addAll((List<Team>) results.values);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
};
|
||||
|
@ -29,7 +29,7 @@ import java.util.Objects;
|
||||
import io.mikael.urlbuilder.UrlBuilder;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapter.UserAccountsViewHolder> {
|
||||
@ -67,7 +67,7 @@ public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapte
|
||||
.setMessage(context.getResources().getString(R.string.removeAccountPopupMessage))
|
||||
.setPositiveButton(context.getResources().getString(R.string.removeButton), (dialog, which) -> {
|
||||
|
||||
updateLayoutByPosition(getAdapterPosition());
|
||||
updateLayoutByPosition(getBindingAdapterPosition());
|
||||
UserAccountsApi userAccountsApi = BaseApi.getInstance(context, UserAccountsApi.class);
|
||||
assert userAccountsApi != null;
|
||||
userAccountsApi.deleteAccount(Integer.parseInt(String.valueOf(accountId)));
|
||||
|
@ -12,7 +12,7 @@ import android.widget.Filter;
|
||||
import android.widget.Filterable;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import org.gitnex.tea4j.models.UserInfo;
|
||||
import org.gitnex.tea4j.v2.models.User;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.ProfileActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
@ -27,9 +27,9 @@ import java.util.List;
|
||||
|
||||
public class UserGridAdapter extends BaseAdapter implements Filterable {
|
||||
|
||||
private final List<UserInfo> membersList;
|
||||
private final List<User> membersList;
|
||||
private final Context context;
|
||||
private final List<UserInfo> membersListFull;
|
||||
private final List<User> membersListFull;
|
||||
|
||||
private class ViewHolder {
|
||||
|
||||
@ -56,7 +56,7 @@ public class UserGridAdapter extends BaseAdapter implements Filterable {
|
||||
}
|
||||
}
|
||||
|
||||
public UserGridAdapter(Context ctx, List<UserInfo> membersListMain) {
|
||||
public UserGridAdapter(Context ctx, List<User> membersListMain) {
|
||||
|
||||
this.context = ctx;
|
||||
this.membersList = membersListMain;
|
||||
@ -101,16 +101,16 @@ public class UserGridAdapter extends BaseAdapter implements Filterable {
|
||||
|
||||
private void initData(UserGridAdapter.ViewHolder viewHolder, int position) {
|
||||
|
||||
UserInfo currentItem = membersList.get(position);
|
||||
User currentItem = membersList.get(position);
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||
|
||||
PicassoService.getInstance(context).get().load(currentItem.getAvatar()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(viewHolder.memberAvatar);
|
||||
PicassoService.getInstance(context).get().load(currentItem.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(viewHolder.memberAvatar);
|
||||
|
||||
viewHolder.userLoginId = currentItem.getLogin();
|
||||
|
||||
if(!currentItem.getFullname().equals("")) {
|
||||
if(!currentItem.getFullName().equals("")) {
|
||||
|
||||
viewHolder.memberName.setText(Html.fromHtml(currentItem.getFullname()));
|
||||
viewHolder.memberName.setText(Html.fromHtml(currentItem.getFullName()));
|
||||
}
|
||||
else {
|
||||
|
||||
@ -126,7 +126,7 @@ public class UserGridAdapter extends BaseAdapter implements Filterable {
|
||||
private final Filter membersFilter = new Filter() {
|
||||
@Override
|
||||
protected FilterResults performFiltering(CharSequence constraint) {
|
||||
List<UserInfo> filteredList = new ArrayList<>();
|
||||
List<User> filteredList = new ArrayList<>();
|
||||
|
||||
if (constraint == null || constraint.length() == 0) {
|
||||
|
||||
@ -136,8 +136,8 @@ public class UserGridAdapter extends BaseAdapter implements Filterable {
|
||||
|
||||
String filterPattern = constraint.toString().toLowerCase().trim();
|
||||
|
||||
for (UserInfo item : membersListFull) {
|
||||
if (item.getFullname().toLowerCase().contains(filterPattern) || item.getLogin().toLowerCase().contains(filterPattern)) {
|
||||
for (User item : membersListFull) {
|
||||
if (item.getFullName().toLowerCase().contains(filterPattern) || item.getLogin().toLowerCase().contains(filterPattern)) {
|
||||
filteredList.add(item);
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import org.gitnex.tea4j.models.UserInfo;
|
||||
import org.gitnex.tea4j.v2.models.User;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.activities.ProfileActivity;
|
||||
@ -31,12 +31,12 @@ import retrofit2.Response;
|
||||
|
||||
public class UserSearchForTeamMemberAdapter extends RecyclerView.Adapter<UserSearchForTeamMemberAdapter.UserSearchViewHolder> {
|
||||
|
||||
private final List<UserInfo> usersSearchList;
|
||||
private final List<User> usersSearchList;
|
||||
private final Context context;
|
||||
private final int teamId;
|
||||
private final String orgName;
|
||||
|
||||
public UserSearchForTeamMemberAdapter(List<UserInfo> dataList, Context ctx, int teamId, String orgName) {
|
||||
public UserSearchForTeamMemberAdapter(List<User> dataList, Context ctx, int teamId, String orgName) {
|
||||
this.context = ctx;
|
||||
this.usersSearchList = dataList;
|
||||
this.teamId = teamId;
|
||||
@ -45,7 +45,7 @@ public class UserSearchForTeamMemberAdapter extends RecyclerView.Adapter<UserSea
|
||||
|
||||
class UserSearchViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private UserInfo userInfo;
|
||||
private User userInfo;
|
||||
|
||||
private final ImageView userAvatar;
|
||||
private final TextView userFullName;
|
||||
@ -102,13 +102,13 @@ public class UserSearchForTeamMemberAdapter extends RecyclerView.Adapter<UserSea
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull final UserSearchForTeamMemberAdapter.UserSearchViewHolder holder, int position) {
|
||||
|
||||
UserInfo currentItem = usersSearchList.get(position);
|
||||
User currentItem = usersSearchList.get(position);
|
||||
holder.userInfo = currentItem;
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||
|
||||
if (!currentItem.getFullname().equals("")) {
|
||||
if (!currentItem.getFullName().equals("")) {
|
||||
|
||||
holder.userFullName.setText(Html.fromHtml(currentItem.getFullname()));
|
||||
holder.userFullName.setText(Html.fromHtml(currentItem.getFullName()));
|
||||
}
|
||||
else {
|
||||
|
||||
@ -117,22 +117,22 @@ public class UserSearchForTeamMemberAdapter extends RecyclerView.Adapter<UserSea
|
||||
|
||||
holder.userName.setText(context.getResources().getString(R.string.usernameWithAt, currentItem.getLogin()));
|
||||
|
||||
if (!currentItem.getAvatar().equals("")) {
|
||||
PicassoService.getInstance(context).get().load(currentItem.getAvatar()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(holder.userAvatar);
|
||||
if (!currentItem.getAvatarUrl().equals("")) {
|
||||
PicassoService.getInstance(context).get().load(currentItem.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(holder.userAvatar);
|
||||
}
|
||||
|
||||
if(getItemCount() > 0) {
|
||||
|
||||
final String loginUid = ((BaseActivity) context).getAccount().getAccount().getUserName();
|
||||
|
||||
Call<UserInfo> call = RetrofitClient
|
||||
Call<User> call = RetrofitClient
|
||||
.getApiInterface(context)
|
||||
.checkTeamMember(((BaseActivity) context).getAccount().getAuthorization(), teamId, currentItem.getLogin());
|
||||
.orgListTeamMember((long) teamId, currentItem.getLogin());
|
||||
|
||||
call.enqueue(new Callback<UserInfo>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<UserInfo> call, @NonNull Response<UserInfo> response) {
|
||||
public void onResponse(@NonNull Call<User> call, @NonNull Response<User> response) {
|
||||
|
||||
if(response.code() == 200) {
|
||||
|
||||
@ -162,7 +162,7 @@ public class UserSearchForTeamMemberAdapter extends RecyclerView.Adapter<UserSea
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<UserInfo> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<User> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(context, context.getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import org.gitnex.tea4j.models.UserInfo;
|
||||
import org.gitnex.tea4j.v2.models.User;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.ProfileActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
@ -26,11 +26,11 @@ import java.util.List;
|
||||
public class UsersAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
private final Context context;
|
||||
private List<UserInfo> followersList;
|
||||
private List<User> followersList;
|
||||
private Runnable loadMoreListener;
|
||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
||||
|
||||
public UsersAdapter(List<UserInfo> dataList, Context ctx) {
|
||||
public UsersAdapter(List<User> dataList, Context ctx) {
|
||||
this.context = ctx;
|
||||
this.followersList = dataList;
|
||||
}
|
||||
@ -62,7 +62,7 @@ public class UsersAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
}
|
||||
|
||||
class UsersHolder extends RecyclerView.ViewHolder {
|
||||
private UserInfo userInfo;
|
||||
private User userInfo;
|
||||
private final ImageView userAvatar;
|
||||
private final TextView userFullName;
|
||||
private final TextView userName;
|
||||
@ -87,20 +87,20 @@ public class UsersAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
void bindData(UserInfo userInfo) {
|
||||
void bindData(User userInfo) {
|
||||
this.userInfo = userInfo;
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||
|
||||
if(!userInfo.getFullname().equals("")) {
|
||||
userFullName.setText(Html.fromHtml(userInfo.getFullname()));
|
||||
userName.setText(context.getResources().getString(R.string.usernameWithAt, userInfo.getUsername()));
|
||||
if(!userInfo.getFullName().equals("")) {
|
||||
userFullName.setText(Html.fromHtml(userInfo.getFullName()));
|
||||
userName.setText(context.getResources().getString(R.string.usernameWithAt, userInfo.getLogin()));
|
||||
}
|
||||
else {
|
||||
userFullName.setText(userInfo.getUsername());
|
||||
userFullName.setText(userInfo.getLogin());
|
||||
userName.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
PicassoService.getInstance(context).get().load(userInfo.getAvatar()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(userAvatar);
|
||||
PicassoService.getInstance(context).get().load(userInfo.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(userAvatar);
|
||||
}
|
||||
}
|
||||
|
||||
@ -118,7 +118,7 @@ public class UsersAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<UserInfo> list) {
|
||||
public void updateList(List<User> list) {
|
||||
followersList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import org.gitnex.tea4j.models.UserOrganizations;
|
||||
import org.gitnex.tea4j.v2.models.Organization;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.OrganizationDetailActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
@ -25,11 +25,11 @@ import java.util.List;
|
||||
public class OrganizationsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
private final Context context;
|
||||
private List<UserOrganizations> organizationsList;
|
||||
private List<Organization> organizationsList;
|
||||
private Runnable loadMoreListener;
|
||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
||||
|
||||
public OrganizationsAdapter(Context ctx, List<UserOrganizations> organizationsListMain) {
|
||||
public OrganizationsAdapter(Context ctx, List<Organization> organizationsListMain) {
|
||||
this.context = ctx;
|
||||
this.organizationsList = organizationsListMain;
|
||||
}
|
||||
@ -63,7 +63,7 @@ public class OrganizationsAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
|
||||
class OrganizationsHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private UserOrganizations userOrganizations;
|
||||
private Organization userOrganizations;
|
||||
|
||||
private final ImageView image;
|
||||
private final TextView orgName;
|
||||
@ -85,14 +85,14 @@ public class OrganizationsAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
void bindData(UserOrganizations userOrganizations) {
|
||||
void bindData(Organization userOrganizations) {
|
||||
|
||||
this.userOrganizations = userOrganizations;
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||
|
||||
orgName.setText(userOrganizations.getUsername());
|
||||
|
||||
PicassoService.getInstance(context).get().load(userOrganizations.getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(image);
|
||||
PicassoService.getInstance(context).get().load(userOrganizations.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(image);
|
||||
|
||||
if (!userOrganizations.getDescription().equals("")) {
|
||||
orgDescription.setText(userOrganizations.getDescription());
|
||||
@ -114,7 +114,7 @@ public class OrganizationsAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<UserOrganizations> list) {
|
||||
public void updateList(List<Organization> list) {
|
||||
organizationsList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
@ -14,13 +14,12 @@ import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.amulyakhare.textdrawable.TextDrawable;
|
||||
import com.amulyakhare.textdrawable.util.ColorGenerator;
|
||||
import org.gitnex.tea4j.models.UserRepositories;
|
||||
import org.gitnex.tea4j.v2.models.Repository;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.database.api.BaseApi;
|
||||
import org.mian.gitnex.database.api.RepositoriesApi;
|
||||
import org.mian.gitnex.database.models.Repository;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.ClickListener;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
@ -37,11 +36,11 @@ import java.util.Locale;
|
||||
public class RepositoriesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
private final Context context;
|
||||
private List<UserRepositories> reposList;
|
||||
private List<Repository> reposList;
|
||||
private Runnable loadMoreListener;
|
||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
||||
|
||||
public RepositoriesAdapter(Context ctx, List<UserRepositories> reposListMain) {
|
||||
public RepositoriesAdapter(Context ctx, List<Repository> reposListMain) {
|
||||
this.context = ctx;
|
||||
this.reposList = reposListMain;
|
||||
}
|
||||
@ -76,7 +75,7 @@ public class RepositoriesAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||
|
||||
class RepositoriesHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private UserRepositories userRepositories;
|
||||
private Repository userRepositories;
|
||||
|
||||
private final ImageView avatar;
|
||||
private final TextView repoName;
|
||||
@ -113,7 +112,7 @@ public class RepositoriesAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||
repo.setRepositoryId((int) id);
|
||||
}
|
||||
else {
|
||||
Repository data = repositoryData.getRepository(currentActiveAccountId, repo.getOwner(), repo.getName());
|
||||
org.mian.gitnex.database.models.Repository data = repositoryData.getRepository(currentActiveAccountId, repo.getOwner(), repo.getName());
|
||||
repo.setRepositoryId(data.getRepositoryId());
|
||||
}
|
||||
|
||||
@ -123,7 +122,7 @@ public class RepositoriesAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
void bindData(UserRepositories userRepositories) {
|
||||
void bindData(Repository userRepositories) {
|
||||
|
||||
this.userRepositories = userRepositories;
|
||||
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
@ -134,7 +133,7 @@ public class RepositoriesAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||
|
||||
orgName.setText(userRepositories.getFullName().split("/")[0]);
|
||||
repoName.setText(userRepositories.getFullName().split("/")[1]);
|
||||
repoStars.setText(userRepositories.getStars_count());
|
||||
repoStars.setText(String.valueOf(userRepositories.getStarsCount()));
|
||||
|
||||
ColorGenerator generator = ColorGenerator.Companion.getMATERIAL();
|
||||
int color = generator.getColor(userRepositories.getName());
|
||||
@ -142,10 +141,10 @@ public class RepositoriesAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).fontSize(18).toUpperCase().width(28).height(28).endConfig().buildRoundRect(firstCharacter, color, 3);
|
||||
|
||||
if(userRepositories.getAvatar_url() != null) {
|
||||
if(!userRepositories.getAvatar_url().equals("")) {
|
||||
if(userRepositories.getAvatarUrl() != null) {
|
||||
if(!userRepositories.getAvatarUrl().equals("")) {
|
||||
PicassoService
|
||||
.getInstance(context).get().load(userRepositories.getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(avatar);
|
||||
.getInstance(context).get().load(userRepositories.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(avatar);
|
||||
}
|
||||
else {
|
||||
avatar.setImageDrawable(drawable);
|
||||
@ -155,11 +154,11 @@ public class RepositoriesAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||
avatar.setImageDrawable(drawable);
|
||||
}
|
||||
|
||||
if(userRepositories.getUpdated_at() != null) {
|
||||
if(userRepositories.getUpdatedAt() != null) {
|
||||
|
||||
repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, TimeHelper.formatTime(userRepositories.getUpdated_at(), locale, timeFormat, context)));
|
||||
repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, TimeHelper.formatTime(userRepositories.getUpdatedAt(), locale, timeFormat, context)));
|
||||
if(timeFormat.equals("pretty")) {
|
||||
repoLastUpdated.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(userRepositories.getUpdated_at()), context));
|
||||
repoLastUpdated.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(userRepositories.getUpdatedAt()), context));
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -195,7 +194,7 @@ public class RepositoriesAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<UserRepositories> list) {
|
||||
public void updateList(List<Repository> list) {
|
||||
reposList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
@ -14,7 +14,6 @@ import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.amulyakhare.textdrawable.TextDrawable;
|
||||
import com.amulyakhare.textdrawable.util.ColorGenerator;
|
||||
import org.gitnex.tea4j.models.UserRepositories;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
@ -37,11 +36,11 @@ import java.util.Locale;
|
||||
public class StarredRepositoriesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
private final Context context;
|
||||
private List<UserRepositories> reposList;
|
||||
private List<org.gitnex.tea4j.v2.models.Repository> reposList;
|
||||
private Runnable loadMoreListener;
|
||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
||||
|
||||
public StarredRepositoriesAdapter(Context ctx, List<UserRepositories> reposListMain) {
|
||||
public StarredRepositoriesAdapter(Context ctx, List<org.gitnex.tea4j.v2.models.Repository> reposListMain) {
|
||||
this.context = ctx;
|
||||
this.reposList = reposListMain;
|
||||
}
|
||||
@ -76,7 +75,7 @@ public class StarredRepositoriesAdapter extends RecyclerView.Adapter<RecyclerVie
|
||||
|
||||
class StarredRepositoriesHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private UserRepositories userRepositories;
|
||||
private org.gitnex.tea4j.v2.models.Repository userRepositories;
|
||||
|
||||
private final ImageView avatar;
|
||||
private final TextView repoName;
|
||||
@ -122,7 +121,7 @@ public class StarredRepositoriesAdapter extends RecyclerView.Adapter<RecyclerVie
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
void bindData(UserRepositories userRepositories) {
|
||||
void bindData(org.gitnex.tea4j.v2.models.Repository userRepositories) {
|
||||
|
||||
this.userRepositories = userRepositories;
|
||||
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
@ -133,7 +132,7 @@ public class StarredRepositoriesAdapter extends RecyclerView.Adapter<RecyclerVie
|
||||
|
||||
orgName.setText(userRepositories.getFullName().split("/")[0]);
|
||||
repoName.setText(userRepositories.getFullName().split("/")[1]);
|
||||
repoStars.setText(userRepositories.getStars_count());
|
||||
repoStars.setText(String.valueOf(userRepositories.getStarsCount()));
|
||||
|
||||
ColorGenerator generator = ColorGenerator.Companion.getMATERIAL();
|
||||
int color = generator.getColor(userRepositories.getName());
|
||||
@ -141,10 +140,10 @@ public class StarredRepositoriesAdapter extends RecyclerView.Adapter<RecyclerVie
|
||||
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).fontSize(18).toUpperCase().width(28).height(28).endConfig().buildRoundRect(firstCharacter, color, 3);
|
||||
|
||||
if(userRepositories.getAvatar_url() != null) {
|
||||
if(!userRepositories.getAvatar_url().equals("")) {
|
||||
if(userRepositories.getAvatarUrl() != null) {
|
||||
if(!userRepositories.getAvatarUrl().equals("")) {
|
||||
PicassoService
|
||||
.getInstance(context).get().load(userRepositories.getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(avatar);
|
||||
.getInstance(context).get().load(userRepositories.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(avatar);
|
||||
}
|
||||
else {
|
||||
avatar.setImageDrawable(drawable);
|
||||
@ -154,12 +153,12 @@ public class StarredRepositoriesAdapter extends RecyclerView.Adapter<RecyclerVie
|
||||
avatar.setImageDrawable(drawable);
|
||||
}
|
||||
|
||||
if(userRepositories.getUpdated_at() != null) {
|
||||
if(userRepositories.getUpdatedAt() != null) {
|
||||
|
||||
repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, TimeHelper
|
||||
.formatTime(userRepositories.getUpdated_at(), locale, timeFormat, context)));
|
||||
.formatTime(userRepositories.getUpdatedAt(), locale, timeFormat, context)));
|
||||
if(timeFormat.equals("pretty")) {
|
||||
repoLastUpdated.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(userRepositories.getUpdated_at()), context));
|
||||
repoLastUpdated.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(userRepositories.getUpdatedAt()), context));
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -195,7 +194,7 @@ public class StarredRepositoriesAdapter extends RecyclerView.Adapter<RecyclerVie
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<UserRepositories> list) {
|
||||
public void updateList(List<org.gitnex.tea4j.v2.models.Repository> list) {
|
||||
reposList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
@ -2,8 +2,21 @@ package org.mian.gitnex.clients;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import org.gitnex.tea4j.ApiInterface;
|
||||
import org.gitnex.tea4j.WebInterface;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import org.gitnex.tea4j.v2.apis.AdminApi;
|
||||
import org.gitnex.tea4j.v2.apis.IssueApi;
|
||||
import org.gitnex.tea4j.v2.apis.MiscellaneousApi;
|
||||
import org.gitnex.tea4j.v2.apis.NotificationApi;
|
||||
import org.gitnex.tea4j.v2.apis.OrganizationApi;
|
||||
import org.gitnex.tea4j.v2.apis.PackageApi;
|
||||
import org.gitnex.tea4j.v2.apis.RepositoryApi;
|
||||
import org.gitnex.tea4j.v2.apis.SettingsApi;
|
||||
import org.gitnex.tea4j.v2.apis.UserApi;
|
||||
import org.gitnex.tea4j.v2.apis.custom.CustomApi;
|
||||
import org.gitnex.tea4j.v2.apis.custom.OTPApi;
|
||||
import org.gitnex.tea4j.v2.apis.custom.WebApi;
|
||||
import org.gitnex.tea4j.v2.auth.ApiKeyAuth;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
@ -11,8 +24,15 @@ 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.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Type;
|
||||
import java.security.SecureRandom;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import javax.net.ssl.SSLContext;
|
||||
@ -20,6 +40,7 @@ import javax.net.ssl.X509TrustManager;
|
||||
import okhttp3.Cache;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import retrofit2.Converter;
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
import retrofit2.converter.scalars.ScalarsConverterFactory;
|
||||
@ -31,9 +52,9 @@ import retrofit2.converter.scalars.ScalarsConverterFactory;
|
||||
public class RetrofitClient {
|
||||
|
||||
private static final Map<String, ApiInterface> apiInterfaces = new ConcurrentHashMap<>();
|
||||
private static final Map<String, WebInterface> webInterfaces = new ConcurrentHashMap<>();
|
||||
private static final Map<String, WebApi> webInterfaces = new ConcurrentHashMap<>();
|
||||
|
||||
private static Retrofit createRetrofit(Context context, String instanceUrl, boolean cacheEnabled) {
|
||||
private static Retrofit createRetrofit(Context context, String instanceUrl, boolean cacheEnabled, String token) {
|
||||
|
||||
TinyDB tinyDB = TinyDB.getInstance(context);
|
||||
|
||||
@ -47,8 +68,11 @@ public class RetrofitClient {
|
||||
MemorizingTrustManager memorizingTrustManager = new MemorizingTrustManager(context);
|
||||
sslContext.init(null, new X509TrustManager[]{ memorizingTrustManager }, new SecureRandom());
|
||||
|
||||
ApiKeyAuth auth = new ApiKeyAuth("header", "Authorization");
|
||||
auth.setApiKey(token);
|
||||
OkHttpClient.Builder okHttpClient = new OkHttpClient.Builder()
|
||||
// .addInterceptor(logging)
|
||||
.addInterceptor(auth)
|
||||
.sslSocketFactory(sslContext.getSocketFactory(), memorizingTrustManager)
|
||||
.hostnameVerifier(memorizingTrustManager.wrapHostnameVerifier(HttpsURLConnection.getDefaultHostnameVerifier()));
|
||||
|
||||
@ -74,7 +98,9 @@ public class RetrofitClient {
|
||||
.baseUrl(instanceUrl)
|
||||
.client(okHttpClient.build())
|
||||
.addConverterFactory(ScalarsConverterFactory.create())
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
.addConverterFactory(GsonConverterFactory.create(new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
|
||||
.create()))
|
||||
.addConverterFactory(DateQueryConverterFactory.create())
|
||||
.build();
|
||||
|
||||
}
|
||||
@ -87,51 +113,90 @@ public class RetrofitClient {
|
||||
}
|
||||
|
||||
public static ApiInterface getApiInterface(Context context) {
|
||||
return getApiInterface(context, ((BaseActivity) context).getAccount().getAccount().getInstanceUrl());
|
||||
return getApiInterface(context, ((BaseActivity) context).getAccount().getAccount().getInstanceUrl(),
|
||||
((BaseActivity) context).getAccount().getAuthorization());
|
||||
}
|
||||
|
||||
public static WebInterface getWebInterface(Context context) {
|
||||
public static WebApi getWebInterface(Context context) {
|
||||
|
||||
String instanceUrl = ((BaseActivity) context).getAccount().getAccount().getInstanceUrl();
|
||||
instanceUrl = instanceUrl.substring(0, instanceUrl.lastIndexOf("api/v1/"));
|
||||
|
||||
return getWebInterface(context, instanceUrl);
|
||||
return getWebInterface(context, instanceUrl, ((BaseActivity) context).getAccount().getWebAuthorization());
|
||||
|
||||
}
|
||||
|
||||
public static ApiInterface getApiInterface(Context context, String url) {
|
||||
public static ApiInterface getApiInterface(Context context, String url, String token) {
|
||||
|
||||
if(!apiInterfaces.containsKey(url)) {
|
||||
String key = token.hashCode() + "@" + url;
|
||||
if(!apiInterfaces.containsKey(key)) {
|
||||
synchronized(RetrofitClient.class) {
|
||||
if(!apiInterfaces.containsKey(url)) {
|
||||
if(!apiInterfaces.containsKey(key)) {
|
||||
|
||||
ApiInterface apiInterface = createRetrofit(context, url, true).create(ApiInterface.class);
|
||||
apiInterfaces.put(url, apiInterface);
|
||||
ApiInterface apiInterface = createRetrofit(context, url, true, token).create(ApiInterface.class);
|
||||
apiInterfaces.put(key, apiInterface);
|
||||
|
||||
return apiInterface;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return apiInterfaces.get(url);
|
||||
return apiInterfaces.get(key);
|
||||
|
||||
}
|
||||
|
||||
public static WebInterface getWebInterface(Context context, String url) {
|
||||
public static WebApi getWebInterface(Context context, String url, String token) {
|
||||
|
||||
if(!webInterfaces.containsKey(url)) {
|
||||
String key = token.hashCode() + "@" + url;
|
||||
if(!webInterfaces.containsKey(key)) {
|
||||
synchronized(RetrofitClient.class) {
|
||||
if(!webInterfaces.containsKey(url)) {
|
||||
if(!webInterfaces.containsKey(key)) {
|
||||
|
||||
WebInterface webInterface = createRetrofit(context, url, false).create(WebInterface.class);
|
||||
webInterfaces.put(url, webInterface);
|
||||
WebApi webInterface = createRetrofit(context, url, false, token).create(WebApi.class);
|
||||
webInterfaces.put(key, webInterface);
|
||||
|
||||
return webInterface;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return webInterfaces.get(url);
|
||||
return webInterfaces.get(key);
|
||||
|
||||
}
|
||||
|
||||
public interface ApiInterface extends AdminApi, OrganizationApi, IssueApi, RepositoryApi, MiscellaneousApi, NotificationApi,
|
||||
UserApi, SettingsApi, OTPApi, CustomApi, PackageApi {}
|
||||
|
||||
private static class DateQueryConverterFactory extends Converter.Factory {
|
||||
public static DateQueryConverterFactory create() {
|
||||
return new DateQueryConverterFactory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Converter<?, String> stringConverter(@NotNull Type type, @NotNull Annotation[] annotations, @NotNull Retrofit retrofit) {
|
||||
if (type == Date.class) {
|
||||
return DateQueryConverter.INSTANCE;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static final class DateQueryConverter implements Converter<Date, String> {
|
||||
static final DateQueryConverter INSTANCE = new DateQueryConverter();
|
||||
|
||||
private static final ThreadLocal<DateFormat> DF = new ThreadLocal<>() {
|
||||
|
||||
@Override
|
||||
public DateFormat initialValue() {
|
||||
|
||||
return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US);
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public String convert(@NotNull Date date) {
|
||||
return Objects.requireNonNull(DF.get()).format(date);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ public class BottomSheetFileViewerFragment extends BottomSheetDialogFragment {
|
||||
RepositoryContext repository = RepositoryContext.fromBundle(requireArguments());
|
||||
BottomSheetFileViewerBinding bottomSheetFileViewerBinding = BottomSheetFileViewerBinding.inflate(inflater, container, false);
|
||||
|
||||
if(!repository.getPermissions().canPush()) {
|
||||
if(!repository.getPermissions().isPush()) {
|
||||
bottomSheetFileViewerBinding.deleteFile.setVisibility(View.GONE);
|
||||
bottomSheetFileViewerBinding.editFile.setVisibility(View.GONE);
|
||||
}
|
||||
|
@ -9,8 +9,7 @@ import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||
import org.gitnex.tea4j.models.NotificationThread;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.gitnex.tea4j.v2.models.NotificationThread;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.BottomSheetNotificationsBinding;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
@ -56,8 +55,8 @@ public class BottomSheetNotificationsFragment extends BottomSheetDialogFragment
|
||||
|
||||
markPinned.setOnClickListener(v12 ->
|
||||
RetrofitClient.getApiInterface(context)
|
||||
.markNotificationThreadAsRead(((BaseActivity) context).getAccount().getAuthorization(), notificationThread.getId(), "pinned")
|
||||
.enqueue((SimpleCallback<Void>) (call, voidResponse) -> {
|
||||
.notifyReadThread(String.valueOf(notificationThread.getId()), "pinned")
|
||||
.enqueue((SimpleCallback<NotificationThread>) (call, voidResponse) -> {
|
||||
|
||||
// reload without any checks, because Gitea returns a 205 and Java expects this to be empty
|
||||
// but Gitea send a response -> results in a call of onFailure and no response is present
|
||||
@ -72,8 +71,8 @@ public class BottomSheetNotificationsFragment extends BottomSheetDialogFragment
|
||||
|
||||
markRead.setOnClickListener(v1 ->
|
||||
RetrofitClient.getApiInterface(context)
|
||||
.markNotificationThreadAsRead(((BaseActivity) context).getAccount().getAuthorization(), notificationThread.getId(), "read")
|
||||
.enqueue((SimpleCallback<Void>) (call, voidResponse) -> {
|
||||
.notifyReadThread(String.valueOf(notificationThread.getId()), "read")
|
||||
.enqueue((SimpleCallback<NotificationThread>) (call, voidResponse) -> {
|
||||
|
||||
// reload without any checks, because Gitea returns a 205 and Java expects this to be empty
|
||||
// but Gitea send a response -> results in a call of onFailure and no response is present
|
||||
@ -90,8 +89,8 @@ public class BottomSheetNotificationsFragment extends BottomSheetDialogFragment
|
||||
|
||||
markUnread.setOnClickListener(v13 ->
|
||||
RetrofitClient.getApiInterface(context)
|
||||
.markNotificationThreadAsRead(((BaseActivity) context).getAccount().getAuthorization(), notificationThread.getId(), "unread")
|
||||
.enqueue((SimpleCallback<Void>) (call, voidResponse) -> {
|
||||
.notifyReadThread(String.valueOf(notificationThread.getId()), "unread")
|
||||
.enqueue((SimpleCallback<NotificationThread>) (call, voidResponse) -> {
|
||||
|
||||
// reload without any checks, because Gitea returns a 205 and Java expects this to be empty
|
||||
// but Gitea send a response -> results in a call of onFailure and no response is present
|
||||
|
@ -8,7 +8,7 @@ import android.view.ViewGroup;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||
import org.gitnex.tea4j.models.OrgPermissions;
|
||||
import org.gitnex.tea4j.v2.models.OrganizationPermissions;
|
||||
import org.mian.gitnex.databinding.BottomSheetOrganizationBinding;
|
||||
import org.mian.gitnex.structs.BottomSheetListener;
|
||||
|
||||
@ -19,9 +19,9 @@ import org.mian.gitnex.structs.BottomSheetListener;
|
||||
public class BottomSheetOrganizationFragment extends BottomSheetDialogFragment {
|
||||
|
||||
private BottomSheetListener bmListener;
|
||||
private final OrgPermissions permissions;
|
||||
private final OrganizationPermissions permissions;
|
||||
|
||||
public BottomSheetOrganizationFragment(OrgPermissions org) {
|
||||
public BottomSheetOrganizationFragment(OrganizationPermissions org) {
|
||||
permissions = org;
|
||||
}
|
||||
|
||||
@ -32,14 +32,14 @@ public class BottomSheetOrganizationFragment extends BottomSheetDialogFragment {
|
||||
BottomSheetOrganizationBinding bottomSheetOrganizationBinding = BottomSheetOrganizationBinding.inflate(inflater, container, false);
|
||||
|
||||
if(permissions != null) {
|
||||
if(!permissions.canCreateRepositories()) {
|
||||
if(!permissions.isCanCreateRepository()) {
|
||||
bottomSheetOrganizationBinding.createRepository.setVisibility(View.GONE);
|
||||
}
|
||||
if(!permissions.isOwner()) {
|
||||
if(!permissions.isIsOwner()) {
|
||||
bottomSheetOrganizationBinding.createLabel.setVisibility(View.GONE);
|
||||
bottomSheetOrganizationBinding.createTeam.setVisibility(View.GONE);
|
||||
}
|
||||
if(!permissions.canCreateRepositories() || !permissions.isOwner()) {
|
||||
if(!permissions.isCanCreateRepository() || !permissions.isIsOwner()) {
|
||||
bottomSheetOrganizationBinding.orgCreate.setVisibility(View.GONE);
|
||||
bottomSheetOrganizationBinding.orgCreateSection.setVisibility(View.GONE);
|
||||
bottomSheetOrganizationBinding.orgDivider.setVisibility(View.GONE);
|
||||
|
@ -49,7 +49,7 @@ public class BottomSheetRepoFragment extends BottomSheetDialogFragment {
|
||||
TextView repoSettings = bottomSheetRepoBinding.repoSettings;
|
||||
TextView createPullRequest = bottomSheetRepoBinding.createPullRequest;
|
||||
|
||||
boolean canPush = repository.getPermissions().canPush();
|
||||
boolean canPush = repository.getPermissions().isPush();
|
||||
if(!canPush) {
|
||||
createMilestone.setVisibility(View.GONE);
|
||||
createLabel.setVisibility(View.GONE);
|
||||
@ -73,7 +73,7 @@ public class BottomSheetRepoFragment extends BottomSheetDialogFragment {
|
||||
dismiss();
|
||||
});
|
||||
|
||||
if(repository.getRepository().getHas_issues() && !archived) {
|
||||
if(repository.getRepository().isHasIssues() && !archived) {
|
||||
|
||||
createIssue.setVisibility(View.VISIBLE);
|
||||
createIssue.setOnClickListener(v12 -> {
|
||||
@ -87,7 +87,7 @@ public class BottomSheetRepoFragment extends BottomSheetDialogFragment {
|
||||
createIssue.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if(repository.getRepository().isHas_pull_requests() && !archived) {
|
||||
if(repository.getRepository().isHasPullRequests() && !archived) {
|
||||
|
||||
createPullRequest.setVisibility(View.VISIBLE);
|
||||
createPullRequest.setOnClickListener(vPr -> {
|
||||
|
@ -30,7 +30,7 @@ import org.mian.gitnex.views.ReactionSpinner;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class BottomSheetSingleIssueFragment extends BottomSheetDialogFragment {
|
||||
@ -54,7 +54,7 @@ public class BottomSheetSingleIssueFragment extends BottomSheetDialogFragment {
|
||||
|
||||
boolean userIsCreator = issueCreator.equals(((BaseActivity) requireActivity()).getAccount().getAccount().getUserName());
|
||||
boolean isRepoAdmin = issue.getRepository().getPermissions().isAdmin();
|
||||
boolean canPush = issue.getRepository().getPermissions().canPush();
|
||||
boolean canPush = issue.getRepository().getPermissions().isPush();
|
||||
boolean archived = issue.getRepository().getRepository().isArchived();
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
@ -71,7 +71,7 @@ public class BottomSheetSingleIssueFragment extends BottomSheetDialogFragment {
|
||||
ReactionSpinner reactionSpinner = new ReactionSpinner(ctx, bundle);
|
||||
reactionSpinner.setOnInteractedListener(() -> {
|
||||
|
||||
((IssueDetailActivity) requireActivity()).singleIssueUpdate = true;
|
||||
IssueDetailActivity.singleIssueUpdate = true;
|
||||
|
||||
bmListener.onButtonClicked("onResume");
|
||||
dismiss();
|
||||
@ -112,7 +112,7 @@ public class BottomSheetSingleIssueFragment extends BottomSheetDialogFragment {
|
||||
if(!userIsCreator && !canPush) {
|
||||
binding.editIssue.setVisibility(View.GONE);
|
||||
}
|
||||
if(canPush && !issue.getPullRequest().isMergeable()) {
|
||||
if(canPush && issue.getPullRequest().isMergeable()) {
|
||||
binding.mergePullRequest.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
@ -179,7 +179,7 @@ public class BottomSheetSingleIssueFragment extends BottomSheetDialogFragment {
|
||||
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
|
||||
sharingIntent.setType("text/plain");
|
||||
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, getResources().getString(R.string.hash) + issue.getIssueIndex() + " " + issue.getIssue().getTitle());
|
||||
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, issue.getIssue().getHtml_url());
|
||||
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, issue.getIssue().getHtmlUrl());
|
||||
startActivity(Intent.createChooser(sharingIntent, getResources().getString(R.string.hash) + issue.getIssueIndex() + " " + issue.getIssue().getTitle()));
|
||||
|
||||
dismiss();
|
||||
@ -189,7 +189,7 @@ public class BottomSheetSingleIssueFragment extends BottomSheetDialogFragment {
|
||||
|
||||
// copy to clipboard
|
||||
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(ctx).getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipData clip = ClipData.newPlainText("issueUrl", issue.getIssue().getHtml_url());
|
||||
ClipData clip = ClipData.newPlainText("issueUrl", issue.getIssue().getHtmlUrl());
|
||||
assert clipboard != null;
|
||||
clipboard.setPrimaryClip(clip);
|
||||
|
||||
|
@ -8,17 +8,12 @@ import android.widget.GridView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import org.gitnex.tea4j.models.Collaborators;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.adapters.CollaboratorsAdapter;
|
||||
import org.mian.gitnex.databinding.FragmentCollaboratorsBinding;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import org.mian.gitnex.viewmodels.CollaboratorsViewModel;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
@ -60,18 +55,16 @@ public class CollaboratorsFragment extends Fragment {
|
||||
mProgressBar = fragmentCollaboratorsBinding.progressBar;
|
||||
mGridView = fragmentCollaboratorsBinding.gridView;
|
||||
|
||||
fetchDataAsync(((BaseActivity) requireActivity()).getAccount().getAuthorization(), repository.getOwner(), repository.getName());
|
||||
fetchDataAsync(repository.getOwner(), repository.getName());
|
||||
return fragmentCollaboratorsBinding.getRoot();
|
||||
|
||||
}
|
||||
|
||||
private void fetchDataAsync(String instanceToken, String owner, String repo) {
|
||||
private void fetchDataAsync(String owner, String repo) {
|
||||
|
||||
CollaboratorsViewModel collaboratorsModel = new ViewModelProvider(this).get(CollaboratorsViewModel.class);
|
||||
|
||||
collaboratorsModel.getCollaboratorsList(instanceToken, owner, repo, getContext()).observe(getViewLifecycleOwner(), new Observer<List<Collaborators>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<Collaborators> collaboratorsListMain) {
|
||||
collaboratorsModel.getCollaboratorsList(owner, repo, getContext()).observe(getViewLifecycleOwner(), collaboratorsListMain -> {
|
||||
adapter = new CollaboratorsAdapter(getContext(), collaboratorsListMain);
|
||||
if(adapter.getCount() > 0) {
|
||||
mGridView.setAdapter(adapter);
|
||||
@ -83,7 +76,6 @@ public class CollaboratorsFragment extends Fragment {
|
||||
noDataCollaborators.setVisibility(View.VISIBLE);
|
||||
}
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
@ -93,7 +85,7 @@ public class CollaboratorsFragment extends Fragment {
|
||||
|
||||
super.onResume();
|
||||
if(refreshCollaborators) {
|
||||
fetchDataAsync(((BaseActivity) requireActivity()).getAccount().getAuthorization(), repository.getOwner(), repository.getName());
|
||||
fetchDataAsync(repository.getOwner(), repository.getName());
|
||||
refreshCollaborators = false;
|
||||
}
|
||||
}
|
||||
|
@ -13,10 +13,8 @@ import androidx.annotation.Nullable;
|
||||
import androidx.core.text.HtmlCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import com.vdurmont.emoji.EmojiParser;
|
||||
import org.gitnex.tea4j.models.Commits;
|
||||
import org.gitnex.tea4j.models.FileDiffView;
|
||||
import org.gitnex.tea4j.v2.models.Commit;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.activities.ProfileActivity;
|
||||
import org.mian.gitnex.adapters.DiffFilesAdapter;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
@ -25,6 +23,7 @@ import org.mian.gitnex.databinding.CustomCommitHeaderBinding;
|
||||
import org.mian.gitnex.databinding.FragmentCommitDetailsBinding;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.FileDiffView;
|
||||
import org.mian.gitnex.helpers.ParseDiff;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
@ -32,10 +31,8 @@ import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import okhttp3.ResponseBody;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
@ -85,26 +82,21 @@ public class CommitDetailFragment extends Fragment {
|
||||
}
|
||||
|
||||
private void getDiff() {
|
||||
Call<ResponseBody> call = new Version(TinyDB.getInstance(requireContext()).getString("giteaVersion")).higherOrEqual("1.16.0") ?
|
||||
RetrofitClient.getApiInterface(requireContext()).getCommitDiff(((BaseActivity) requireActivity()).getAccount().getAuthorization(), repoOwner, repoName, sha) :
|
||||
RetrofitClient.getWebInterface(requireContext()).getCommitDiff(((BaseActivity) requireActivity()).getAccount().getWebAuthorization(), repoOwner, repoName, sha);
|
||||
Call<String> call = new Version(TinyDB.getInstance(requireContext()).getString("giteaVersion")).higherOrEqual("1.16.0") ?
|
||||
RetrofitClient.getApiInterface(requireContext()).repoDownloadCommitDiffOrPatch(repoOwner, repoName, sha, "diff") :
|
||||
RetrofitClient.getWebInterface(requireContext()).repoDownloadCommitDiffOrPatch(repoOwner, repoName, sha, "diff");
|
||||
|
||||
call.enqueue(new Callback<ResponseBody>() {
|
||||
call.enqueue(new Callback<String>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<ResponseBody> call, @NonNull Response<ResponseBody> response) {
|
||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||
checkLoading();
|
||||
assert response.body() != null;
|
||||
switch(response.code()) {
|
||||
|
||||
case 200:
|
||||
List<FileDiffView> fileDiffViews;
|
||||
try {
|
||||
fileDiffViews = ParseDiff.getFileDiffViewArray(response.body().string());
|
||||
} catch(IOException e) {
|
||||
onFailure(call, e);
|
||||
return;
|
||||
}
|
||||
fileDiffViews = ParseDiff.getFileDiffViewArray(response.body());
|
||||
|
||||
DiffFilesAdapter adapter = new DiffFilesAdapter(requireContext(), fileDiffViews);
|
||||
requireActivity().runOnUiThread(() -> binding.diffFiles.setAdapter(adapter));
|
||||
@ -129,7 +121,7 @@ public class CommitDetailFragment extends Fragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<ResponseBody> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
|
||||
checkLoading();
|
||||
Toasty.error(requireContext(), getString(R.string.genericError));
|
||||
}
|
||||
@ -138,11 +130,11 @@ public class CommitDetailFragment extends Fragment {
|
||||
|
||||
private void getCommit() {
|
||||
|
||||
RetrofitClient.getApiInterface(requireContext()).getCommit(((BaseActivity) requireActivity()).getAccount().getAuthorization(), repoOwner, repoName, sha)
|
||||
.enqueue(new Callback<Commits>() {
|
||||
RetrofitClient.getApiInterface(requireContext()).repoGetSingleCommit(repoOwner, repoName, sha)
|
||||
.enqueue(new Callback<Commit>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Commits> call, @NonNull Response<Commits> response) {
|
||||
public void onResponse(@NonNull Call<Commit> call, @NonNull Response<Commit> response) {
|
||||
checkLoading();
|
||||
CustomCommitHeaderBinding binding = CustomCommitHeaderBinding.inflate(getLayoutInflater());
|
||||
binding.getRoot().setOnClickListener((v) -> {
|
||||
@ -150,7 +142,7 @@ public class CommitDetailFragment extends Fragment {
|
||||
});
|
||||
CommitDetailFragment.this.binding.diffFiles.addHeaderView(binding.getRoot());
|
||||
assert response.body() != null;
|
||||
Commits commitsModel = response.body();
|
||||
Commit commitsModel = response.body();
|
||||
String[] commitMessageParts = commitsModel.getCommit().getMessage().split("(\r\n|\n)", 2);
|
||||
|
||||
if(commitMessageParts.length > 1 && !commitMessageParts[1].trim().isEmpty()) {
|
||||
@ -166,25 +158,25 @@ public class CommitDetailFragment extends Fragment {
|
||||
binding.commitAuthorAndCommitter.setText(HtmlCompat.fromHtml(CommitDetailFragment.this
|
||||
.getString(R.string.commitAuthoredByAndCommittedByWhen, commitsModel.getCommit().getAuthor().getName(), commitsModel.getCommit().getCommitter().getName(),
|
||||
TimeHelper
|
||||
.formatTime(commitsModel.getCommit().getCommitter().getDate(), getResources().getConfiguration().locale, "pretty",
|
||||
.formatTime(TimeHelper.parseIso8601(commitsModel.getCommit().getCommitter().getDate()), getResources().getConfiguration().locale, "pretty",
|
||||
requireContext())), HtmlCompat.FROM_HTML_MODE_COMPACT));
|
||||
} else {
|
||||
binding.commitAuthorAndCommitter.setText(HtmlCompat.fromHtml(CommitDetailFragment.this
|
||||
.getString(R.string.commitCommittedByWhen, commitsModel.getCommit().getCommitter().getName(),
|
||||
TimeHelper
|
||||
.formatTime(commitsModel.getCommit().getCommitter().getDate(), getResources().getConfiguration().locale, "pretty",
|
||||
.formatTime(TimeHelper.parseIso8601(commitsModel.getCommit().getCommitter().getDate()), getResources().getConfiguration().locale, "pretty",
|
||||
requireContext())), HtmlCompat.FROM_HTML_MODE_COMPACT));
|
||||
}
|
||||
|
||||
if(commitsModel.getAuthor() != null && commitsModel.getAuthor().getAvatar_url() != null &&
|
||||
!commitsModel.getAuthor().getAvatar_url().isEmpty()) {
|
||||
if(commitsModel.getAuthor() != null && commitsModel.getAuthor().getAvatarUrl() != null &&
|
||||
!commitsModel.getAuthor().getAvatarUrl().isEmpty()) {
|
||||
|
||||
binding.commitAuthorAvatar.setVisibility(View.VISIBLE);
|
||||
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(requireContext(), 3);
|
||||
|
||||
PicassoService.getInstance(requireContext()).get()
|
||||
.load(commitsModel.getAuthor().getAvatar_url())
|
||||
.load(commitsModel.getAuthor().getAvatarUrl())
|
||||
.placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(imgRadius, 0))
|
||||
.resize(120, 120)
|
||||
@ -192,7 +184,7 @@ public class CommitDetailFragment extends Fragment {
|
||||
|
||||
binding.commitAuthorAvatar.setOnClickListener((v) -> {
|
||||
Intent intent = new Intent(requireContext(), ProfileActivity.class);
|
||||
intent.putExtra("username", commitsModel.getAuthor().getUsername());
|
||||
intent.putExtra("username", commitsModel.getAuthor().getLogin());
|
||||
startActivity(intent);
|
||||
});
|
||||
|
||||
@ -203,15 +195,15 @@ public class CommitDetailFragment extends Fragment {
|
||||
|
||||
if(commitsModel.getCommitter() != null &&
|
||||
(commitsModel.getAuthor() == null || !commitsModel.getAuthor().getLogin().equals(commitsModel.getCommitter().getLogin())) &&
|
||||
commitsModel.getCommitter().getAvatar_url() != null &&
|
||||
!commitsModel.getCommitter().getAvatar_url().isEmpty()) {
|
||||
commitsModel.getCommitter().getAvatarUrl() != null &&
|
||||
!commitsModel.getCommitter().getAvatarUrl().isEmpty()) {
|
||||
|
||||
binding.commitCommitterAvatar.setVisibility(View.VISIBLE);
|
||||
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(requireContext(), 3);
|
||||
|
||||
PicassoService.getInstance(requireContext()).get()
|
||||
.load(commitsModel.getCommitter().getAvatar_url())
|
||||
.load(commitsModel.getCommitter().getAvatarUrl())
|
||||
.placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(imgRadius, 0))
|
||||
.resize(120, 120)
|
||||
@ -219,7 +211,7 @@ public class CommitDetailFragment extends Fragment {
|
||||
|
||||
binding.commitCommitterAvatar.setOnClickListener((v) -> {
|
||||
Intent intent = new Intent(requireContext(), ProfileActivity.class);
|
||||
intent.putExtra("username", commitsModel.getCommitter().getUsername());
|
||||
intent.putExtra("username", commitsModel.getCommitter().getLogin());
|
||||
startActivity(intent);
|
||||
});
|
||||
|
||||
@ -239,7 +231,7 @@ public class CommitDetailFragment extends Fragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Commits> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<Commit> call, @NonNull Throwable t) {
|
||||
|
||||
checkLoading();
|
||||
Toasty.error(requireContext(), getString(R.string.genericError));
|
||||
|
@ -7,19 +7,17 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import org.gitnex.tea4j.models.FileDiffView;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.adapters.DiffFilesAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.FragmentDiffFilesBinding;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.FileDiffView;
|
||||
import org.mian.gitnex.helpers.ParseDiff;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.contexts.IssueContext;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import okhttp3.ResponseBody;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Response;
|
||||
|
||||
@ -51,7 +49,7 @@ public class DiffFilesFragment extends Fragment {
|
||||
|
||||
binding.diffFiles.setOnItemClickListener((parent, view, position, id) -> requireActivity().getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
.replace(R.id.fragment_container, DiffFragment.newInstance((FileDiffView) parent.getItemAtPosition(position), issue))
|
||||
.replace(R.id.fragment_container, DiffFragment.newInstance((FileDiffView) parent.getItemAtPosition(position), issue.getIssueType().toLowerCase()))
|
||||
.commit());
|
||||
|
||||
getPullDiffFiles(issue.getRepository().getOwner(), issue.getRepository().getName(), String.valueOf(issue.getIssueIndex()));
|
||||
@ -64,13 +62,11 @@ public class DiffFilesFragment extends Fragment {
|
||||
|
||||
Thread thread = new Thread(() -> {
|
||||
|
||||
Call<ResponseBody> call = ((BaseActivity) ctx).getAccount().requiresVersion("1.13.0") ?
|
||||
RetrofitClient.getApiInterface(ctx).getPullDiffContent(((BaseActivity) requireActivity()).getAccount().getAuthorization(), owner, repo, pullIndex) :
|
||||
RetrofitClient.getWebInterface(ctx).getPullDiffContent(((BaseActivity) requireActivity()).getAccount().getWebAuthorization(), owner, repo, pullIndex);
|
||||
Call<String> call = RetrofitClient.getApiInterface(ctx).repoDownloadPullDiffOrPatch(owner, repo, Long.valueOf(pullIndex), "diff", null);
|
||||
|
||||
try {
|
||||
|
||||
Response<ResponseBody> response = call.execute();
|
||||
Response<String> response = call.execute();
|
||||
if(response.body() == null) {
|
||||
Toasty.error(requireContext(), getString(R.string.genericError));
|
||||
requireActivity().finish();
|
||||
@ -80,7 +76,7 @@ public class DiffFilesFragment extends Fragment {
|
||||
switch(response.code()) {
|
||||
|
||||
case 200:
|
||||
List<FileDiffView> fileDiffViews = ParseDiff.getFileDiffViewArray(response.body().string());
|
||||
List<FileDiffView> fileDiffViews = ParseDiff.getFileDiffViewArray(response.body());
|
||||
|
||||
int filesCount = fileDiffViews.size();
|
||||
|
||||
|
@ -7,10 +7,10 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import org.gitnex.tea4j.models.FileDiffView;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.DiffAdapter;
|
||||
import org.mian.gitnex.databinding.FragmentDiffBinding;
|
||||
import org.mian.gitnex.helpers.FileDiffView;
|
||||
import org.mian.gitnex.helpers.contexts.IssueContext;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
@ -16,7 +16,6 @@ import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.adapters.ExploreIssuesAdapter;
|
||||
import org.mian.gitnex.databinding.FragmentSearchIssuesBinding;
|
||||
import org.mian.gitnex.viewmodels.IssuesViewModel;
|
||||
@ -40,7 +39,7 @@ public class ExploreIssuesFragment extends Fragment {
|
||||
viewBinding.pullToRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
|
||||
viewBinding.pullToRefresh.setRefreshing(false);
|
||||
fetchDataAsync(((BaseActivity) requireActivity()).getAccount().getAuthorization(), "");
|
||||
fetchDataAsync("");
|
||||
viewBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
}, 50));
|
||||
|
||||
@ -49,16 +48,16 @@ public class ExploreIssuesFragment extends Fragment {
|
||||
viewBinding.recyclerViewSearchIssues.addItemDecoration(dividerItemDecoration);
|
||||
viewBinding.recyclerViewSearchIssues.setLayoutManager(new LinearLayoutManager(requireActivity()));
|
||||
|
||||
fetchDataAsync(((BaseActivity) requireActivity()).getAccount().getAuthorization(), "");
|
||||
fetchDataAsync("");
|
||||
|
||||
return viewBinding.getRoot();
|
||||
}
|
||||
|
||||
private void fetchDataAsync(String instanceToken, String searchKeyword) {
|
||||
private void fetchDataAsync(String searchKeyword) {
|
||||
|
||||
IssuesViewModel issuesModel = new ViewModelProvider(this).get(IssuesViewModel.class);
|
||||
|
||||
issuesModel.getIssuesList(instanceToken, searchKeyword, "issues", null, "open", getContext()).observe(getViewLifecycleOwner(), issuesListMain -> {
|
||||
issuesModel.getIssuesList(searchKeyword, "issues", null, "open", getContext()).observe(getViewLifecycleOwner(), issuesListMain -> {
|
||||
|
||||
adapter = new ExploreIssuesAdapter(issuesListMain, getContext());
|
||||
adapter.setLoadMoreListener(new ExploreIssuesAdapter.OnLoadMoreListener() {
|
||||
@ -67,7 +66,7 @@ public class ExploreIssuesFragment extends Fragment {
|
||||
public void onLoadMore() {
|
||||
|
||||
page += 1;
|
||||
IssuesViewModel.loadMoreIssues(instanceToken, searchKeyword, "issues", null, "open", page, getContext(), adapter);
|
||||
IssuesViewModel.loadMoreIssues(searchKeyword, "issues", null, "open", page, getContext(), adapter);
|
||||
viewBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@ -108,7 +107,7 @@ public class ExploreIssuesFragment extends Fragment {
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
viewBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
fetchDataAsync(((BaseActivity) requireActivity()).getAccount().getAuthorization(), query);
|
||||
fetchDataAsync(query);
|
||||
searchView.setQuery(null, false);
|
||||
searchItem.collapseActionView();
|
||||
return false;
|
||||
|
@ -13,9 +13,8 @@ import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import org.gitnex.tea4j.models.Organization;
|
||||
import org.gitnex.tea4j.v2.models.Organization;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.adapters.ExplorePublicOrganizationsAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.FragmentOrganizationsBinding;
|
||||
@ -55,7 +54,7 @@ public class ExplorePublicOrganizationsFragment extends Fragment {
|
||||
|
||||
fragmentPublicOrgBinding.pullToRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
fragmentPublicOrgBinding.pullToRefresh.setRefreshing(false);
|
||||
loadInitial(((BaseActivity) requireActivity()).getAccount().getAuthorization(), resultLimit);
|
||||
loadInitial(resultLimit);
|
||||
adapter.notifyDataChanged();
|
||||
}, 200));
|
||||
|
||||
@ -63,7 +62,7 @@ public class ExplorePublicOrganizationsFragment extends Fragment {
|
||||
adapter.setLoadMoreListener(() -> fragmentPublicOrgBinding.recyclerView.post(() -> {
|
||||
if(organizationsList.size() == resultLimit || pageSize == resultLimit) {
|
||||
int page = (organizationsList.size() + resultLimit) / resultLimit;
|
||||
loadMore(((BaseActivity) requireActivity()).getAccount().getAuthorization(), page, resultLimit);
|
||||
loadMore(page, resultLimit);
|
||||
}
|
||||
}));
|
||||
|
||||
@ -73,15 +72,15 @@ public class ExplorePublicOrganizationsFragment extends Fragment {
|
||||
fragmentPublicOrgBinding.recyclerView.setLayoutManager(new LinearLayoutManager(context));
|
||||
fragmentPublicOrgBinding.recyclerView.setAdapter(adapter);
|
||||
|
||||
loadInitial(((BaseActivity) requireActivity()).getAccount().getAuthorization(), resultLimit);
|
||||
loadInitial(resultLimit);
|
||||
|
||||
return fragmentPublicOrgBinding.getRoot();
|
||||
}
|
||||
|
||||
private void loadInitial(String token, int resultLimit) {
|
||||
private void loadInitial(int resultLimit) {
|
||||
|
||||
Call<List<Organization>> call = RetrofitClient
|
||||
.getApiInterface(context).getAllOrgs(token, Constants.publicOrganizationsPageInit, resultLimit);
|
||||
.getApiInterface(context).orgGetAll(Constants.publicOrganizationsPageInit, resultLimit);
|
||||
call.enqueue(new Callback<List<Organization>>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Organization>> call, @NonNull Response<List<Organization>> response) {
|
||||
@ -115,10 +114,10 @@ public class ExplorePublicOrganizationsFragment extends Fragment {
|
||||
});
|
||||
}
|
||||
|
||||
private void loadMore(String token, int page, int resultLimit) {
|
||||
private void loadMore(int page, int resultLimit) {
|
||||
|
||||
fragmentPublicOrgBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
Call<List<Organization>> call = RetrofitClient.getApiInterface(context).getAllOrgs(token, page, resultLimit);
|
||||
Call<List<Organization>> call = RetrofitClient.getApiInterface(context).orgGetAll(page, resultLimit);
|
||||
call.enqueue(new Callback<List<Organization>>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Organization>> call, @NonNull Response<List<Organization>> response) {
|
||||
|
@ -18,10 +18,10 @@ import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import org.gitnex.tea4j.models.ExploreRepositories;
|
||||
import org.gitnex.tea4j.models.UserRepositories;
|
||||
import org.gitnex.tea4j.v2.models.Repository;
|
||||
import org.gitnex.tea4j.v2.models.SearchResults;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.activities.MainActivity;
|
||||
import org.mian.gitnex.adapters.ExploreRepositoriesAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.CustomExploreRepositoriesDialogBinding;
|
||||
@ -49,7 +49,7 @@ public class ExploreRepositoriesFragment extends Fragment {
|
||||
private final String sort = "updated";
|
||||
private final String order = "desc";
|
||||
private int resultLimit;
|
||||
private List<UserRepositories> dataList;
|
||||
private List<Repository> dataList;
|
||||
private ExploreRepositoriesAdapter adapter;
|
||||
|
||||
private Dialog dialogFilterOptions;
|
||||
@ -59,6 +59,7 @@ public class ExploreRepositoriesFragment extends Fragment {
|
||||
private boolean includeDescription = false;
|
||||
private boolean includeTemplate = false;
|
||||
private boolean onlyArchived = false;
|
||||
private String searchQuery = "";
|
||||
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
@ -98,18 +99,16 @@ public class ExploreRepositoriesFragment extends Fragment {
|
||||
|
||||
private void loadInitial(String searchKeyword, int resultLimit) {
|
||||
|
||||
Call<ExploreRepositories> call = RetrofitClient
|
||||
.getApiInterface(context).queryRepos(((BaseActivity) requireActivity()).getAccount().getAuthorization(), searchKeyword, repoTypeInclude, sort, order, includeTopic, includeDescription, includeTemplate, onlyArchived, resultLimit, 1);
|
||||
|
||||
Call<SearchResults> call = RetrofitClient
|
||||
.getApiInterface(context).repoSearch(searchKeyword, includeTopic, includeDescription, null, null, null, null,
|
||||
null, null, includeTemplate, onlyArchived, null, null, null, null, 1, resultLimit);
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<ExploreRepositories> call, @NonNull Response<ExploreRepositories> response) {
|
||||
|
||||
public void onResponse(@NonNull Call<SearchResults> call, @NonNull Response<SearchResults> response) {
|
||||
if(response.isSuccessful()) {
|
||||
if(response.body() != null && response.body().getSearchedData().size() > 0) {
|
||||
if(response.body() != null && response.body().getData().size() > 0) {
|
||||
dataList.clear();
|
||||
dataList.addAll(response.body().getSearchedData());
|
||||
dataList.addAll(response.body().getData());
|
||||
adapter.notifyDataChanged();
|
||||
viewBinding.noData.setVisibility(View.GONE);
|
||||
}
|
||||
@ -130,7 +129,7 @@ public class ExploreRepositoriesFragment extends Fragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<ExploreRepositories> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<SearchResults> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(requireActivity(), requireActivity().getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
@ -140,17 +139,16 @@ public class ExploreRepositoriesFragment extends Fragment {
|
||||
private void loadMore(String searchKeyword, int resultLimit, int page) {
|
||||
|
||||
viewBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
Call<ExploreRepositories> call = RetrofitClient.getApiInterface(context)
|
||||
.queryRepos(((BaseActivity) requireActivity()).getAccount().getAuthorization(), searchKeyword, repoTypeInclude, sort, order, includeTopic, includeDescription, includeTemplate, onlyArchived, resultLimit, page);
|
||||
Call<SearchResults> call = RetrofitClient.getApiInterface(context)
|
||||
.repoSearch(searchKeyword, includeTopic, includeDescription, null, null, null, null,
|
||||
null, null, includeTemplate, onlyArchived, null, null, null, null, page, resultLimit);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<ExploreRepositories> call, @NonNull Response<ExploreRepositories> response) {
|
||||
|
||||
public void onResponse(@NonNull Call<SearchResults> call, @NonNull Response<SearchResults> response) {
|
||||
if(response.isSuccessful()) {
|
||||
assert response.body() != null;
|
||||
List<UserRepositories> result = response.body().getSearchedData();
|
||||
List<Repository> result = response.body().getData();
|
||||
if(result.size() > 0) {
|
||||
pageSize = result.size();
|
||||
dataList.addAll(result);
|
||||
@ -168,7 +166,7 @@ public class ExploreRepositoriesFragment extends Fragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<ExploreRepositories> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<SearchResults> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(requireActivity(), requireActivity().getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
@ -206,6 +204,7 @@ public class ExploreRepositoriesFragment extends Fragment {
|
||||
loadMore(query, resultLimit, page);
|
||||
}
|
||||
}));
|
||||
searchQuery = query;
|
||||
searchView.setQuery(null, false);
|
||||
searchItem.collapseActionView();
|
||||
return false;
|
||||
@ -248,4 +247,16 @@ public class ExploreRepositoriesFragment extends Fragment {
|
||||
|
||||
dialogFilterOptions.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
if(MainActivity.repoCreated) {
|
||||
dataList.clear();
|
||||
loadInitial(searchQuery, resultLimit);
|
||||
MainActivity.repoCreated = false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -15,10 +15,9 @@ import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import org.gitnex.tea4j.models.UserInfo;
|
||||
import org.gitnex.tea4j.models.UserSearch;
|
||||
import org.gitnex.tea4j.v2.models.InlineResponse2001;
|
||||
import org.gitnex.tea4j.v2.models.User;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.adapters.UsersAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.FragmentExploreUsersBinding;
|
||||
@ -40,7 +39,7 @@ public class ExploreUsersFragment extends Fragment {
|
||||
private FragmentExploreUsersBinding viewBinding;
|
||||
private Context context;
|
||||
|
||||
private List<UserInfo> usersList;
|
||||
private List<User> usersList;
|
||||
private UsersAdapter adapter;
|
||||
private int pageSize;
|
||||
private int resultLimit;
|
||||
@ -59,14 +58,14 @@ public class ExploreUsersFragment extends Fragment {
|
||||
|
||||
viewBinding.pullToRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
viewBinding.pullToRefresh.setRefreshing(false);
|
||||
loadInitial(((BaseActivity) requireActivity()).getAccount().getAuthorization(), "", resultLimit);
|
||||
loadInitial("", resultLimit);
|
||||
adapter.notifyDataChanged();
|
||||
}, 200));
|
||||
|
||||
adapter.setLoadMoreListener(() -> viewBinding.recyclerViewExploreUsers.post(() -> {
|
||||
if(usersList.size() == resultLimit || pageSize == resultLimit) {
|
||||
int page = (usersList.size() + resultLimit) / resultLimit;
|
||||
loadMore(((BaseActivity) requireActivity()).getAccount().getAuthorization(), "", resultLimit, page);
|
||||
loadMore("", resultLimit, page);
|
||||
}
|
||||
}));
|
||||
|
||||
@ -76,21 +75,18 @@ public class ExploreUsersFragment extends Fragment {
|
||||
viewBinding.recyclerViewExploreUsers.setLayoutManager(new LinearLayoutManager(context));
|
||||
viewBinding.recyclerViewExploreUsers.setAdapter(adapter);
|
||||
|
||||
loadInitial(((BaseActivity) requireActivity()).getAccount().getAuthorization(), "", resultLimit);
|
||||
loadInitial("", resultLimit);
|
||||
|
||||
return viewBinding.getRoot();
|
||||
}
|
||||
|
||||
private void loadInitial(String token, String searchKeyword, int resultLimit) {
|
||||
|
||||
Call<UserSearch> call = RetrofitClient
|
||||
.getApiInterface(context).getUserBySearch(token, searchKeyword, resultLimit, 1);
|
||||
private void loadInitial(String searchKeyword, int resultLimit) {
|
||||
|
||||
Call<InlineResponse2001> call = RetrofitClient
|
||||
.getApiInterface(context).userSearch(searchKeyword, null, resultLimit, 1);
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<UserSearch> call, @NonNull Response<UserSearch> response) {
|
||||
|
||||
public void onResponse(@NonNull Call<InlineResponse2001> call, @NonNull Response<InlineResponse2001> response) {
|
||||
if(response.isSuccessful()) {
|
||||
if(response.body() != null && response.body().getData().size() > 0) {
|
||||
usersList.clear();
|
||||
@ -115,26 +111,23 @@ public class ExploreUsersFragment extends Fragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<UserSearch> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<InlineResponse2001> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(requireActivity(), requireActivity().getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void loadMore(String token, String searchKeyword, int resultLimit, int page) {
|
||||
private void loadMore(String searchKeyword, int resultLimit, int page) {
|
||||
|
||||
viewBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
Call<UserSearch> call = RetrofitClient.getApiInterface(context).getUserBySearch(token, searchKeyword, resultLimit, page);
|
||||
|
||||
Call<InlineResponse2001> call = RetrofitClient.getApiInterface(context).userSearch(searchKeyword, null, resultLimit, page);
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<UserSearch> call, @NonNull Response<UserSearch> response) {
|
||||
|
||||
public void onResponse(@NonNull Call<InlineResponse2001> call, @NonNull Response<InlineResponse2001> response) {
|
||||
if(response.isSuccessful()) {
|
||||
assert response.body() != null;
|
||||
List<UserInfo> result = response.body().getData();
|
||||
List<User> result = response.body().getData();
|
||||
if(result != null) {
|
||||
if(result.size() > 0) {
|
||||
pageSize = result.size();
|
||||
@ -154,7 +147,7 @@ public class ExploreUsersFragment extends Fragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<UserSearch> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<InlineResponse2001> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(requireActivity(), requireActivity().getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
@ -177,11 +170,11 @@ public class ExploreUsersFragment extends Fragment {
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
viewBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
loadInitial(((BaseActivity) requireActivity()).getAccount().getAuthorization(), query, resultLimit);
|
||||
loadInitial(query, resultLimit);
|
||||
adapter.setLoadMoreListener(() -> viewBinding.recyclerViewExploreUsers.post(() -> {
|
||||
if(usersList.size() == resultLimit || pageSize == resultLimit) {
|
||||
int page = (usersList.size() + resultLimit) / resultLimit;
|
||||
loadMore(((BaseActivity) requireActivity()).getAccount().getAuthorization(), query, resultLimit, page);
|
||||
loadMore(query, resultLimit, page);
|
||||
}
|
||||
}));
|
||||
searchView.setQuery(null, false);
|
||||
|
@ -18,9 +18,8 @@ import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import org.gitnex.tea4j.models.Files;
|
||||
import org.gitnex.tea4j.v2.models.ContentsResponse;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.activities.FileViewActivity;
|
||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||
import org.mian.gitnex.adapters.FilesAdapter;
|
||||
@ -112,9 +111,9 @@ public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapter
|
||||
path.remove(path.size() - 1);
|
||||
binding.breadcrumbsView.removeLastItem();
|
||||
if(path.size() == 0) {
|
||||
fetchDataAsync(((BaseActivity) requireActivity()).getAccount().getAuthorization(), repository.getOwner(), repository.getName(), repository.getBranchRef());
|
||||
fetchDataAsync(repository.getOwner(), repository.getName(), repository.getBranchRef());
|
||||
} else {
|
||||
fetchDataAsyncSub(((BaseActivity) requireActivity()).getAccount().getAuthorization(), repository.getOwner(), repository.getName(), path.toString(), repository.getBranchRef());
|
||||
fetchDataAsyncSub(repository.getOwner(), repository.getName(), path.toString(), repository.getBranchRef());
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -147,7 +146,7 @@ public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapter
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClickFile(Files file) {
|
||||
public void onClickFile(ContentsResponse file) {
|
||||
|
||||
switch(file.getType()) {
|
||||
|
||||
@ -166,7 +165,7 @@ public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapter
|
||||
break;
|
||||
|
||||
case "submodule":
|
||||
String rawUrl = file.getSubmodule_git_url();
|
||||
String rawUrl = file.getSubmoduleGitUrl();
|
||||
if(rawUrl == null) {
|
||||
return;
|
||||
}
|
||||
@ -211,20 +210,20 @@ public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapter
|
||||
|
||||
public void refresh() {
|
||||
if(path.size() > 0) {
|
||||
fetchDataAsyncSub(((BaseActivity) requireActivity()).getAccount().getAuthorization(), repository.getOwner(), repository.getName(), path.toString(), repository.getBranchRef());
|
||||
fetchDataAsyncSub(repository.getOwner(), repository.getName(), path.toString(), repository.getBranchRef());
|
||||
} else {
|
||||
fetchDataAsync(((BaseActivity) requireActivity()).getAccount().getAuthorization(), repository.getOwner(), repository.getName(), repository.getBranchRef());
|
||||
fetchDataAsync(repository.getOwner(), repository.getName(), repository.getBranchRef());
|
||||
}
|
||||
}
|
||||
|
||||
private void fetchDataAsync(String instanceToken, String owner, String repo, String ref) {
|
||||
private void fetchDataAsync(String owner, String repo, String ref) {
|
||||
|
||||
binding.recyclerView.setVisibility(View.GONE);
|
||||
binding.progressBar.setVisibility(View.VISIBLE);
|
||||
|
||||
FilesViewModel filesModel = new ViewModelProvider(this).get(FilesViewModel.class);
|
||||
|
||||
filesModel.getFilesList(instanceToken, owner, repo, ref, getContext(), binding.progressBar, binding.noDataFiles).observe(getViewLifecycleOwner(), filesListMain -> {
|
||||
filesModel.getFilesList(owner, repo, ref, getContext(), binding.progressBar, binding.noDataFiles).observe(getViewLifecycleOwner(), filesListMain -> {
|
||||
|
||||
filesAdapter.getOriginalFiles().clear();
|
||||
filesAdapter.getOriginalFiles().addAll(filesListMain);
|
||||
@ -247,14 +246,14 @@ public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapter
|
||||
|
||||
}
|
||||
|
||||
private void fetchDataAsyncSub(String instanceToken, String owner, String repo, String filesDir, String ref) {
|
||||
private void fetchDataAsyncSub(String owner, String repo, String filesDir, String ref) {
|
||||
|
||||
binding.recyclerView.setVisibility(View.GONE);
|
||||
binding.progressBar.setVisibility(View.VISIBLE);
|
||||
|
||||
FilesViewModel filesModel = new ViewModelProvider(this).get(FilesViewModel.class);
|
||||
|
||||
filesModel.getFilesList2(instanceToken, owner, repo, filesDir, ref, getContext(), binding.progressBar, binding.noDataFiles).observe(getViewLifecycleOwner(), filesListMain2 -> {
|
||||
filesModel.getFilesList2(owner, repo, filesDir, ref, getContext(), binding.progressBar, binding.noDataFiles).observe(getViewLifecycleOwner(), filesListMain2 -> {
|
||||
|
||||
filesAdapter.getOriginalFiles().clear();
|
||||
filesAdapter.getOriginalFiles().addAll(filesListMain2);
|
||||
|
@ -17,7 +17,7 @@ import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import org.gitnex.tea4j.models.Issues;
|
||||
import org.gitnex.tea4j.v2.models.Issue;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||
@ -45,7 +45,7 @@ public class IssuesFragment extends Fragment {
|
||||
private Context context;
|
||||
|
||||
private Menu menu;
|
||||
private List<Issues> issuesList;
|
||||
private List<Issue> issuesList;
|
||||
private IssuesAdapter adapter;
|
||||
|
||||
private int pageSize = Constants.issuesPageInit;
|
||||
@ -80,7 +80,7 @@ public class IssuesFragment extends Fragment {
|
||||
|
||||
fragmentIssuesBinding.pullToRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
fragmentIssuesBinding.pullToRefresh.setRefreshing(false);
|
||||
loadInitial(((BaseActivity) requireActivity()).getAccount().getAuthorization(), repository.getOwner(), repository.getName(), resultLimit, requestType, repository.getIssueState().toString(), "");
|
||||
loadInitial(repository.getOwner(), repository.getName(), resultLimit, requestType, repository.getIssueState().toString(), repository.getIssueMilestoneFilterName());
|
||||
adapter.notifyDataChanged();
|
||||
}, 200));
|
||||
|
||||
@ -88,7 +88,7 @@ public class IssuesFragment extends Fragment {
|
||||
adapter.setLoadMoreListener(() -> fragmentIssuesBinding.recyclerView.post(() -> {
|
||||
if(issuesList.size() == resultLimit || pageSize == resultLimit) {
|
||||
int page = (issuesList.size() + resultLimit) / resultLimit;
|
||||
loadMore(((BaseActivity) requireActivity()).getAccount().getAuthorization(), repository.getOwner(), repository.getName(), page, resultLimit, requestType, repository.getIssueState().toString(), "");
|
||||
loadMore(repository.getOwner(), repository.getName(), page, resultLimit, requestType, repository.getIssueState().toString(), repository.getIssueMilestoneFilterName());
|
||||
}
|
||||
}));
|
||||
|
||||
@ -114,14 +114,14 @@ public class IssuesFragment extends Fragment {
|
||||
|
||||
if(issuesList.size() == resultLimit || pageSize == resultLimit) {
|
||||
int page = (issuesList.size() + resultLimit) / resultLimit;
|
||||
loadMore(((BaseActivity) requireActivity()).getAccount().getAuthorization(), repository.getOwner(), repository.getName(), page, resultLimit, requestType, repository.getIssueState().toString(), repository.getIssueMilestoneFilterName());
|
||||
loadMore(repository.getOwner(), repository.getName(), page, resultLimit, requestType, repository.getIssueState().toString(), repository.getIssueMilestoneFilterName());
|
||||
}
|
||||
}));
|
||||
|
||||
fragmentIssuesBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
fragmentIssuesBinding.noDataIssues.setVisibility(View.GONE);
|
||||
|
||||
loadInitial(((BaseActivity) requireActivity()).getAccount().getAuthorization(), repository.getOwner(), repository.getName(), resultLimit, requestType, issueState, repository.getIssueMilestoneFilterName());
|
||||
loadInitial(repository.getOwner(), repository.getName(), resultLimit, requestType, issueState, repository.getIssueMilestoneFilterName());
|
||||
fragmentIssuesBinding.recyclerView.setAdapter(adapter);
|
||||
});
|
||||
|
||||
@ -134,18 +134,18 @@ public class IssuesFragment extends Fragment {
|
||||
|
||||
if(issuesList.size() == resultLimit || pageSize == resultLimit) {
|
||||
int page = (issuesList.size() + resultLimit) / resultLimit;
|
||||
loadMore(((BaseActivity) requireActivity()).getAccount().getAuthorization(), repository.getOwner(), repository.getName(), page, resultLimit, requestType, repository.getIssueState().toString(), repository.getIssueMilestoneFilterName());
|
||||
loadMore(repository.getOwner(), repository.getName(), page, resultLimit, requestType, repository.getIssueState().toString(), repository.getIssueMilestoneFilterName());
|
||||
}
|
||||
}));
|
||||
|
||||
fragmentIssuesBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
fragmentIssuesBinding.noDataIssues.setVisibility(View.GONE);
|
||||
|
||||
loadInitial(((BaseActivity) requireActivity()).getAccount().getAuthorization(), repository.getOwner(), repository.getName(), resultLimit, requestType, repository.getIssueState().toString(), filterIssueByMilestone);
|
||||
loadInitial(repository.getOwner(), repository.getName(), resultLimit, requestType, repository.getIssueState().toString(), filterIssueByMilestone);
|
||||
fragmentIssuesBinding.recyclerView.setAdapter(adapter);
|
||||
});
|
||||
|
||||
loadInitial(((BaseActivity) requireActivity()).getAccount().getAuthorization(), repository.getOwner(), repository.getName(), resultLimit, requestType, repository.getIssueState().toString(), repository.getIssueMilestoneFilterName());
|
||||
loadInitial(repository.getOwner(), repository.getName(), resultLimit, requestType, repository.getIssueState().toString(), repository.getIssueMilestoneFilterName());
|
||||
|
||||
return fragmentIssuesBinding.getRoot();
|
||||
}
|
||||
@ -154,18 +154,19 @@ public class IssuesFragment extends Fragment {
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if(resumeIssues) {
|
||||
loadInitial(((BaseActivity) requireActivity()).getAccount().getAuthorization(), repository.getOwner(), repository.getName(), resultLimit, requestType, repository.getIssueState().toString(), repository.getIssueMilestoneFilterName());
|
||||
loadInitial(repository.getOwner(), repository.getName(), resultLimit, requestType, repository.getIssueState().toString(), repository.getIssueMilestoneFilterName());
|
||||
resumeIssues = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void loadInitial(String token, String repoOwner, String repoName, int resultLimit, String requestType, String issueState, String filterByMilestone) {
|
||||
private void loadInitial(String repoOwner, String repoName, int resultLimit, String requestType, String issueState, String filterByMilestone) {
|
||||
|
||||
Call<List<Issues>> call = RetrofitClient.getApiInterface(context).getIssues(token, repoOwner, repoName, 1, resultLimit, requestType, issueState, filterByMilestone);
|
||||
Call<List<Issue>> call = RetrofitClient.getApiInterface(context).issueListIssues(repoOwner, repoName, issueState, null, null, requestType,
|
||||
filterByMilestone, null, null, null, null, null, 1, resultLimit);
|
||||
|
||||
call.enqueue(new Callback<List<Issues>>() {
|
||||
call.enqueue(new Callback<List<Issue>>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Issues>> call, @NonNull Response<List<Issues>> response) {
|
||||
public void onResponse(@NonNull Call<List<Issue>> call, @NonNull Response<List<Issue>> response) {
|
||||
|
||||
if(response.code() == 200) {
|
||||
assert response.body() != null;
|
||||
@ -192,24 +193,24 @@ public class IssuesFragment extends Fragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Issues>> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<List<Issue>> call, @NonNull Throwable t) {
|
||||
Log.e(TAG, t.toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void loadMore(String token, String repoOwner, String repoName, int page, int resultLimit, String requestType, String issueState, String filterByMilestone) {
|
||||
private void loadMore(String repoOwner, String repoName, int page, int resultLimit, String requestType, String issueState, String filterByMilestone) {
|
||||
|
||||
fragmentIssuesBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
|
||||
Call<List<Issues>> call = RetrofitClient.getApiInterface(context).getIssues(token, repoOwner, repoName, page, resultLimit, requestType, issueState, filterByMilestone);
|
||||
|
||||
call.enqueue(new Callback<List<Issues>>() {
|
||||
Call<List<Issue>> call = RetrofitClient.getApiInterface(context).issueListIssues(repoOwner, repoName, issueState, null, null, requestType,
|
||||
filterByMilestone, null, null, null, null, null, page, resultLimit);
|
||||
call.enqueue(new Callback<List<Issue>>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Issues>> call, @NonNull Response<List<Issues>> response) {
|
||||
public void onResponse(@NonNull Call<List<Issue>> call, @NonNull Response<List<Issue>> response) {
|
||||
if(response.code() == 200) {
|
||||
List<Issues> result = response.body();
|
||||
List<Issue> result = response.body();
|
||||
assert result != null;
|
||||
if(result.size() > 0) {
|
||||
pageSize = result.size();
|
||||
@ -228,7 +229,7 @@ public class IssuesFragment extends Fragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Issues>> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<List<Issue>> call, @NonNull Throwable t) {
|
||||
Log.e(TAG, t.toString());
|
||||
}
|
||||
});
|
||||
@ -270,9 +271,9 @@ public class IssuesFragment extends Fragment {
|
||||
|
||||
private void filter(String text) {
|
||||
|
||||
List<Issues> arr = new ArrayList<>();
|
||||
List<Issue> arr = new ArrayList<>();
|
||||
|
||||
for(Issues d : issuesList) {
|
||||
for(Issue d : issuesList) {
|
||||
if(d == null || d.getTitle() == null || d.getBody() == null) {
|
||||
continue;
|
||||
}
|
||||
|
@ -15,7 +15,6 @@ import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.activities.CreateLabelActivity;
|
||||
import org.mian.gitnex.adapters.LabelsAdapter;
|
||||
import org.mian.gitnex.databinding.FragmentLabelsBinding;
|
||||
@ -73,10 +72,10 @@ public class LabelsFragment extends Fragment {
|
||||
swipeRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
|
||||
swipeRefresh.setRefreshing(false);
|
||||
LabelsViewModel.loadLabelsList(((BaseActivity) requireActivity()).getAccount().getAuthorization(), repository.getOwner(), repository.getName(), getContext());
|
||||
LabelsViewModel.loadLabelsList(repository.getOwner(), repository.getName(), getContext());
|
||||
}, 200));
|
||||
|
||||
fetchDataAsync(((BaseActivity) requireActivity()).getAccount().getAuthorization(), repository.getOwner(), repository.getName());
|
||||
fetchDataAsync(repository.getOwner(), repository.getName());
|
||||
|
||||
return fragmentLabelsBinding.getRoot();
|
||||
}
|
||||
@ -88,16 +87,16 @@ public class LabelsFragment extends Fragment {
|
||||
|
||||
if(CreateLabelActivity.refreshLabels) {
|
||||
|
||||
LabelsViewModel.loadLabelsList(((BaseActivity) requireActivity()).getAccount().getAuthorization(), repository.getOwner(), repository.getName(), getContext());
|
||||
LabelsViewModel.loadLabelsList(repository.getOwner(), repository.getName(), getContext());
|
||||
CreateLabelActivity.refreshLabels = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void fetchDataAsync(String instanceToken, String owner, String repo) {
|
||||
private void fetchDataAsync(String owner, String repo) {
|
||||
|
||||
LabelsViewModel labelsModel = new ViewModelProvider(this).get(LabelsViewModel.class);
|
||||
|
||||
labelsModel.getLabelsList(instanceToken, owner, repo, getContext()).observe(getViewLifecycleOwner(), labelsListMain -> {
|
||||
labelsModel.getLabelsList(owner, repo, getContext()).observe(getViewLifecycleOwner(), labelsListMain -> {
|
||||
|
||||
adapter = new LabelsAdapter(getContext(), labelsListMain, "repo", owner);
|
||||
|
||||
|
@ -15,7 +15,6 @@ import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.adapters.UserGridAdapter;
|
||||
import org.mian.gitnex.databinding.FragmentMembersByOrgBinding;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
@ -65,16 +64,16 @@ public class MembersByOrgFragment extends Fragment {
|
||||
progressBar = fragmentMembersByOrgBinding.progressBar;
|
||||
mGridView = fragmentMembersByOrgBinding.gridView;
|
||||
|
||||
fetchDataAsync(((BaseActivity) requireActivity()).getAccount().getAuthorization(), orgName);
|
||||
fetchDataAsync(orgName);
|
||||
|
||||
return fragmentMembersByOrgBinding.getRoot();
|
||||
}
|
||||
|
||||
private void fetchDataAsync(String instanceToken, String owner) {
|
||||
private void fetchDataAsync(String owner) {
|
||||
|
||||
MembersByOrgViewModel membersModel= new ViewModelProvider(this).get(MembersByOrgViewModel.class);
|
||||
|
||||
membersModel.getMembersList(instanceToken, owner, getContext()).observe(getViewLifecycleOwner(), membersListMain -> {
|
||||
membersModel.getMembersList(owner, getContext()).observe(getViewLifecycleOwner(), membersListMain -> {
|
||||
adapter = new UserGridAdapter(getContext(), membersListMain);
|
||||
if(adapter.getCount() > 0) {
|
||||
mGridView.setAdapter(adapter);
|
||||
|
@ -17,9 +17,8 @@ import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import org.gitnex.tea4j.models.Milestones;
|
||||
import org.gitnex.tea4j.v2.models.Milestone;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||
import org.mian.gitnex.adapters.MilestonesAdapter;
|
||||
import org.mian.gitnex.databinding.FragmentMilestonesBinding;
|
||||
@ -36,7 +35,7 @@ public class MilestonesFragment extends Fragment {
|
||||
|
||||
private FragmentMilestonesBinding viewBinding;
|
||||
private Menu menu;
|
||||
private List<Milestones> dataList;
|
||||
private List<Milestone> dataList;
|
||||
private MilestonesAdapter adapter;
|
||||
private RepositoryContext repository;
|
||||
private String milestoneId;
|
||||
@ -80,7 +79,7 @@ public class MilestonesFragment extends Fragment {
|
||||
page = 1;
|
||||
dataList.clear();
|
||||
viewBinding.pullToRefresh.setRefreshing(false);
|
||||
fetchDataAsync(((BaseActivity) requireActivity()).getAccount().getAuthorization(), repository.getOwner(), repository.getName(), state);
|
||||
fetchDataAsync(repository.getOwner(), repository.getName(), state);
|
||||
}, 50));
|
||||
|
||||
((RepoDetailActivity) requireActivity()).setFragmentRefreshListenerMilestone(milestoneState -> {
|
||||
@ -98,18 +97,18 @@ public class MilestonesFragment extends Fragment {
|
||||
viewBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
viewBinding.noDataMilestone.setVisibility(View.GONE);
|
||||
|
||||
fetchDataAsync(((BaseActivity) requireActivity()).getAccount().getAuthorization(), repository.getOwner(), repository.getName(), milestoneState);
|
||||
fetchDataAsync(repository.getOwner(), repository.getName(), milestoneState);
|
||||
});
|
||||
|
||||
fetchDataAsync(((BaseActivity) requireActivity()).getAccount().getAuthorization(), repository.getOwner(), repository.getName(), state);
|
||||
fetchDataAsync(repository.getOwner(), repository.getName(), state);
|
||||
return viewBinding.getRoot();
|
||||
}
|
||||
|
||||
private void fetchDataAsync(String instanceToken, String repoOwner, String repoName, String state) {
|
||||
private void fetchDataAsync(String repoOwner, String repoName, String state) {
|
||||
|
||||
MilestonesViewModel milestonesViewModel = new ViewModelProvider(this).get(MilestonesViewModel.class);
|
||||
|
||||
milestonesViewModel.getMilestonesList(instanceToken, repoOwner, repoName, state, getContext()).observe(getViewLifecycleOwner(), milestonesListMain -> {
|
||||
milestonesViewModel.getMilestonesList(repoOwner, repoName, state, getContext()).observe(getViewLifecycleOwner(), milestonesListMain -> {
|
||||
|
||||
adapter = new MilestonesAdapter(getContext(), milestonesListMain, repository);
|
||||
adapter.setLoadMoreListener(new MilestonesAdapter.OnLoadMoreListener() {
|
||||
@ -118,7 +117,7 @@ public class MilestonesFragment extends Fragment {
|
||||
public void onLoadMore() {
|
||||
|
||||
page += 1;
|
||||
MilestonesViewModel.loadMoreMilestones(instanceToken, repoOwner, repoName, page, state, getContext(), adapter);
|
||||
MilestonesViewModel.loadMoreMilestones(repoOwner, repoName, page, state, getContext(), adapter);
|
||||
viewBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@ -147,8 +146,8 @@ public class MilestonesFragment extends Fragment {
|
||||
});
|
||||
}
|
||||
|
||||
private static int getMilestoneIndex(int milestoneId, List<Milestones> milestones) {
|
||||
for (Milestones milestone : milestones) {
|
||||
private static int getMilestoneIndex(int milestoneId, List<Milestone> milestones) {
|
||||
for (Milestone milestone : milestones) {
|
||||
if(milestone.getId() == milestoneId) {
|
||||
return milestones.indexOf(milestone);
|
||||
}
|
||||
@ -187,9 +186,9 @@ public class MilestonesFragment extends Fragment {
|
||||
|
||||
private void filter(String text) {
|
||||
|
||||
List<Milestones> arr = new ArrayList<>();
|
||||
List<Milestone> arr = new ArrayList<>();
|
||||
|
||||
for(Milestones d : dataList) {
|
||||
for(Milestone d : dataList) {
|
||||
if(d == null || d.getTitle() == null || d.getDescription() == null) {
|
||||
continue;
|
||||
}
|
||||
|
@ -16,7 +16,6 @@ import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.activities.MainActivity;
|
||||
import org.mian.gitnex.adapters.ExploreIssuesAdapter;
|
||||
import org.mian.gitnex.databinding.FragmentIssuesBinding;
|
||||
@ -59,27 +58,27 @@ public class MyIssuesFragment extends Fragment {
|
||||
fragmentIssuesBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
fragmentIssuesBinding.noDataIssues.setVisibility(View.GONE);
|
||||
|
||||
fetchDataAsync(((BaseActivity) requireActivity()).getAccount().getAuthorization(), null, myIssuesState);
|
||||
fetchDataAsync(null, myIssuesState);
|
||||
});
|
||||
|
||||
fragmentIssuesBinding.pullToRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
|
||||
page = 1;
|
||||
fragmentIssuesBinding.pullToRefresh.setRefreshing(false);
|
||||
IssuesViewModel.loadIssuesList(((BaseActivity) requireActivity()).getAccount().getAuthorization(), null, "issues", true, state, getContext());
|
||||
IssuesViewModel.loadIssuesList(null, "issues", true, state, getContext());
|
||||
fragmentIssuesBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
}, 50));
|
||||
|
||||
fetchDataAsync(((BaseActivity) requireActivity()).getAccount().getAuthorization(), null, state);
|
||||
fetchDataAsync(null, state);
|
||||
|
||||
return fragmentIssuesBinding.getRoot();
|
||||
};
|
||||
|
||||
private void fetchDataAsync(String instanceToken, String query, String state) {
|
||||
private void fetchDataAsync(String query, String state) {
|
||||
|
||||
IssuesViewModel issuesModel = new ViewModelProvider(this).get(IssuesViewModel.class);
|
||||
|
||||
issuesModel.getIssuesList(instanceToken, query, "issues", true, state, getContext()).observe(getViewLifecycleOwner(), issuesListMain -> {
|
||||
issuesModel.getIssuesList(query, "issues", true, state, getContext()).observe(getViewLifecycleOwner(), issuesListMain -> {
|
||||
|
||||
adapter = new ExploreIssuesAdapter(issuesListMain, getContext());
|
||||
adapter.setLoadMoreListener(new ExploreIssuesAdapter.OnLoadMoreListener() {
|
||||
@ -88,7 +87,7 @@ public class MyIssuesFragment extends Fragment {
|
||||
public void onLoadMore() {
|
||||
|
||||
page += 1;
|
||||
IssuesViewModel.loadMoreIssues(instanceToken, query, "issues", true, state, page, getContext(), adapter);
|
||||
IssuesViewModel.loadMoreIssues(query, "issues", true, state, page, getContext(), adapter);
|
||||
fragmentIssuesBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@ -129,7 +128,7 @@ public class MyIssuesFragment extends Fragment {
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
fetchDataAsync(((BaseActivity) requireActivity()).getAccount().getAuthorization(), query, state);
|
||||
fetchDataAsync(query, state);
|
||||
searchView.setQuery(null, false);
|
||||
searchItem.collapseActionView();
|
||||
return false;
|
||||
|
@ -15,7 +15,6 @@ import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.adapters.MyProfileEmailsAdapter;
|
||||
import org.mian.gitnex.databinding.FragmentProfileEmailsBinding;
|
||||
import org.mian.gitnex.viewmodels.ProfileEmailsViewModel;
|
||||
@ -58,21 +57,21 @@ public class MyProfileEmailsFragment extends Fragment {
|
||||
swipeRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
|
||||
swipeRefresh.setRefreshing(false);
|
||||
ProfileEmailsViewModel.loadEmailsList(((BaseActivity) requireActivity()).getAccount().getAuthorization(), getContext());
|
||||
ProfileEmailsViewModel.loadEmailsList(getContext());
|
||||
|
||||
}, 200));
|
||||
|
||||
fetchDataAsync(((BaseActivity) requireActivity()).getAccount().getAuthorization());
|
||||
fetchDataAsync();
|
||||
|
||||
return fragmentProfileEmailsBinding.getRoot();
|
||||
|
||||
}
|
||||
|
||||
private void fetchDataAsync(String instanceToken) {
|
||||
private void fetchDataAsync() {
|
||||
|
||||
ProfileEmailsViewModel profileEmailModel = new ViewModelProvider(this).get(ProfileEmailsViewModel.class);
|
||||
|
||||
profileEmailModel.getEmailsList(instanceToken, getContext()).observe(getViewLifecycleOwner(), emailsListMain -> {
|
||||
profileEmailModel.getEmailsList(getContext()).observe(getViewLifecycleOwner(), emailsListMain -> {
|
||||
adapter = new MyProfileEmailsAdapter(getContext(), emailsListMain);
|
||||
if(adapter.getItemCount() > 0) {
|
||||
mRecyclerView.setAdapter(adapter);
|
||||
@ -94,7 +93,7 @@ public class MyProfileEmailsFragment extends Fragment {
|
||||
super.onResume();
|
||||
|
||||
if(refreshEmails) {
|
||||
ProfileEmailsViewModel.loadEmailsList(((BaseActivity) requireActivity()).getAccount().getAuthorization(), getContext());
|
||||
ProfileEmailsViewModel.loadEmailsList(getContext());
|
||||
refreshEmails = false;
|
||||
}
|
||||
}
|
||||
|
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