Use Gradle-native formatter #1208
254 changed files with 20604 additions and 14474 deletions
20
.idea/codeStyles/Project.xml
generated
20
.idea/codeStyles/Project.xml
generated
|
@ -31,17 +31,17 @@
|
|||
<option name="BLANK_LINES_AROUND_FIELD_IN_INTERFACE" value="1"/>
|
||||
<option name="BLANK_LINES_AFTER_CLASS_HEADER" value="1"/>
|
||||
<option name="BLANK_LINES_BEFORE_CLASS_END" value="1"/>
|
||||
<option name="ELSE_ON_NEW_LINE" value="true"/>
|
||||
<option name="CATCH_ON_NEW_LINE" value="true"/>
|
||||
<option name="FINALLY_ON_NEW_LINE" value="true"/>
|
||||
<option name="ELSE_ON_NEW_LINE" value="false"/>
|
||||
<option name="CATCH_ON_NEW_LINE" value="false"/>
|
||||
<option name="FINALLY_ON_NEW_LINE" value="false"/>
|
||||
<option name="ALIGN_MULTILINE_PARAMETERS" value="false"/>
|
||||
<option name="SPACE_BEFORE_IF_PARENTHESES" value="false"/>
|
||||
<option name="SPACE_BEFORE_WHILE_PARENTHESES" value="false"/>
|
||||
<option name="SPACE_BEFORE_FOR_PARENTHESES" value="false"/>
|
||||
<option name="SPACE_BEFORE_TRY_PARENTHESES" value="false"/>
|
||||
<option name="SPACE_BEFORE_CATCH_PARENTHESES" value="false"/>
|
||||
<option name="SPACE_BEFORE_SWITCH_PARENTHESES" value="false"/>
|
||||
<option name="SPACE_BEFORE_SYNCHRONIZED_PARENTHESES" value="false"/>
|
||||
<option name="SPACE_BEFORE_IF_PARENTHESES" value="true"/>
|
||||
<option name="SPACE_BEFORE_WHILE_PARENTHESES" value="true"/>
|
||||
<option name="SPACE_BEFORE_FOR_PARENTHESES" value="true"/>
|
||||
<option name="SPACE_BEFORE_TRY_PARENTHESES" value="true"/>
|
||||
<option name="SPACE_BEFORE_CATCH_PARENTHESES" value="true"/>
|
||||
<option name="SPACE_BEFORE_SWITCH_PARENTHESES" value="true"/>
|
||||
<option name="SPACE_BEFORE_SYNCHRONIZED_PARENTHESES" value="true"/>
|
||||
<option name="CALL_PARAMETERS_WRAP" value="1"/>
|
||||
<option name="METHOD_PARAMETERS_WRAP" value="1"/>
|
||||
<option name="THROWS_LIST_WRAP" value="1"/>
|
||||
|
|
|
@ -7,12 +7,11 @@ pipeline:
|
|||
regex: " \\\\* \\\\@author [\\\\S\\\\s]+"
|
||||
must_contain: true
|
||||
|
||||
#style:
|
||||
#image: qwerty287/woodpecker-intellij-formatter
|
||||
#group: check
|
||||
# settings:
|
||||
#file_pattern: "*.java"
|
||||
#path: "app/"
|
||||
style:
|
||||
image: alvrme/alpine-android:android-31-jdk11
|
||||
group: check
|
||||
commands:
|
||||
- ./gradlew :app:spotlessCheck
|
||||
|
||||
test:
|
||||
image: alvrme/alpine-android:android-31-jdk11
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
plugins {
|
||||
id "com.diffplug.spotless" version "6.11.0"
|
||||
}
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
|
@ -118,3 +121,18 @@ dependencies {
|
|||
}
|
||||
implementation 'io.github.amrdeveloper:codeview:1.3.5'
|
||||
}
|
||||
|
||||
spotless {
|
||||
java {
|
||||
target 'src/**/*.java'
|
||||
|
||||
importOrder('android', 'androidx', 'com', 'junit', 'net', 'org', 'java', 'javax', '', '\\#')
|
||||
removeUnusedImports()
|
||||
|
||||
googleJavaFormat().aosp()
|
||||
|
||||
indentWithTabs()
|
||||
|
||||
formatAnnotations()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,5 +18,4 @@ public class MainActivityTest {
|
|||
ActivityScenario<MainActivity> a = ActivityScenario.launch(MainActivity.class);
|
||||
a.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package org.main.gitnex.helpers;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.view.View;
|
||||
|
@ -8,7 +10,6 @@ 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.*;
|
||||
|
||||
/**
|
||||
* @author qwerty287
|
||||
|
@ -91,22 +92,43 @@ public class AppUtilTest {
|
|||
|
||||
@Test
|
||||
public void getUriFromGitUrlTest() {
|
||||
assertEquals("https://git@codeberg.org/gitnex/GitNex", AppUtil.getUriFromGitUrl("ssh://git@codeberg.org:gitnex/GitNex").toString());
|
||||
assertEquals("https://codeberg.org/gitnex/GitNex", AppUtil.getUriFromGitUrl("codeberg.org:gitnex/GitNex").toString());
|
||||
assertEquals("ssh://git@codeberg.org/gitnex/GitNex", AppUtil.getUriFromGitUrl("ssh://git@codeberg.org/gitnex/GitNex").toString());
|
||||
assertEquals("https://git@codeberg.org/gitnex/GitNex.git", AppUtil.getUriFromGitUrl("ssh://git@codeberg.org:gitnex/GitNex.git").toString());
|
||||
assertEquals("https://codeberg.org/gitnex/GitNex.git", AppUtil.getUriFromGitUrl("codeberg.org:gitnex/GitNex.git").toString());
|
||||
assertEquals("https://codeberg.org/gitnex/GitNex.git", AppUtil.getUriFromGitUrl("https://codeberg.org/gitnex/GitNex.git").toString());
|
||||
assertEquals("https://gitnex.com", AppUtil.getUriFromGitUrl("https://gitnex.com").toString());
|
||||
assertEquals("https://gitnex.com:3000", AppUtil.getUriFromGitUrl("https://gitnex.com:3000").toString());
|
||||
assertEquals(
|
||||
"https://git@codeberg.org/gitnex/GitNex",
|
||||
AppUtil.getUriFromGitUrl("ssh://git@codeberg.org:gitnex/GitNex").toString());
|
||||
assertEquals(
|
||||
"https://codeberg.org/gitnex/GitNex",
|
||||
AppUtil.getUriFromGitUrl("codeberg.org:gitnex/GitNex").toString());
|
||||
assertEquals(
|
||||
"ssh://git@codeberg.org/gitnex/GitNex",
|
||||
AppUtil.getUriFromGitUrl("ssh://git@codeberg.org/gitnex/GitNex").toString());
|
||||
assertEquals(
|
||||
"https://git@codeberg.org/gitnex/GitNex.git",
|
||||
AppUtil.getUriFromGitUrl("ssh://git@codeberg.org:gitnex/GitNex.git").toString());
|
||||
assertEquals(
|
||||
"https://codeberg.org/gitnex/GitNex.git",
|
||||
AppUtil.getUriFromGitUrl("codeberg.org:gitnex/GitNex.git").toString());
|
||||
assertEquals(
|
||||
"https://codeberg.org/gitnex/GitNex.git",
|
||||
AppUtil.getUriFromGitUrl("https://codeberg.org/gitnex/GitNex.git").toString());
|
||||
assertEquals(
|
||||
"https://gitnex.com", AppUtil.getUriFromGitUrl("https://gitnex.com").toString());
|
||||
assertEquals(
|
||||
"https://gitnex.com:3000",
|
||||
AppUtil.getUriFromGitUrl("https://gitnex.com:3000").toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void changeSchemeTest() {
|
||||
assertEquals("https://codeberg.org/gitnex/GitNex", AppUtil.changeScheme(Uri.parse("ssh://codeberg.org/gitnex/GitNex"), "https").toString());
|
||||
assertEquals("https://gitnex.com", AppUtil.changeScheme(Uri.parse("http://gitnex.com"), "https").toString());
|
||||
assertEquals("ssh://codeberg.org/gitnex/GitNex", AppUtil.changeScheme(Uri.parse("http://codeberg.org/gitnex/GitNex"), "ssh").toString());
|
||||
assertEquals(
|
||||
"https://codeberg.org/gitnex/GitNex",
|
||||
AppUtil.changeScheme(Uri.parse("ssh://codeberg.org/gitnex/GitNex"), "https")
|
||||
.toString());
|
||||
assertEquals(
|
||||
"https://gitnex.com",
|
||||
AppUtil.changeScheme(Uri.parse("http://gitnex.com"), "https").toString());
|
||||
assertEquals(
|
||||
"ssh://codeberg.org/gitnex/GitNex",
|
||||
AppUtil.changeScheme(Uri.parse("http://codeberg.org/gitnex/GitNex"), "ssh")
|
||||
.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -45,5 +45,4 @@ public class ToastyTest {
|
|||
Context context = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
Toasty.success(context, "GitNex success test");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ import java.util.concurrent.TimeUnit;
|
|||
/**
|
||||
* @author opyale
|
||||
*/
|
||||
|
||||
public class ActionResult<R> {
|
||||
|
||||
private final BlockingQueue<Boolean> blockingQueue;
|
||||
|
@ -22,7 +21,6 @@ public class ActionResult<R> {
|
|||
|
||||
blockingQueue = new ArrayBlockingQueue<>(1);
|
||||
onFinishedListeners = new ArrayList<>();
|
||||
|
||||
}
|
||||
|
||||
public void finish(@NonNull Status status) {
|
||||
|
@ -33,54 +31,48 @@ public class ActionResult<R> {
|
|||
public void finish(@NonNull Status status, R result) {
|
||||
|
||||
try {
|
||||
if(blockingQueue.poll(5, TimeUnit.SECONDS)) {
|
||||
if (blockingQueue.poll(5, TimeUnit.SECONDS)) {
|
||||
|
||||
for(OnFinishedListener<R> onFinishedListener : onFinishedListeners)
|
||||
for (OnFinishedListener<R> onFinishedListener : onFinishedListeners)
|
||||
onFinishedListener.onFinished(status, result);
|
||||
}
|
||||
|
||||
} catch (InterruptedException ignored) {
|
||||
}
|
||||
catch(InterruptedException ignored) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void invalidate() {
|
||||
|
||||
if(invalidated) {
|
||||
if (invalidated) {
|
||||
throw new IllegalStateException("Already invalidated");
|
||||
}
|
||||
this.invalidated = true;
|
||||
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
public synchronized final void accept(@NonNull OnFinishedListener<R>... onFinishedListeners) {
|
||||
public final synchronized void accept(@NonNull OnFinishedListener<R>... onFinishedListeners) {
|
||||
|
||||
invalidate();
|
||||
|
||||
this.blockingQueue.add(true);
|
||||
this.onFinishedListeners.addAll(Arrays.asList(onFinishedListeners));
|
||||
|
||||
}
|
||||
|
||||
public synchronized final void discard() {
|
||||
public final synchronized void discard() {
|
||||
|
||||
invalidate();
|
||||
this.blockingQueue.add(false);
|
||||
|
||||
}
|
||||
|
||||
public enum Status {SUCCESS, FAILED}
|
||||
public enum Status {
|
||||
SUCCESS,
|
||||
FAILED
|
||||
}
|
||||
|
||||
public interface OnFinishedListener<R> {
|
||||
|
||||
void onFinished(Status status, R result);
|
||||
|
||||
}
|
||||
|
||||
public static class None {
|
||||
|
||||
}
|
||||
|
||||
public static class None {}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import android.view.View;
|
|||
import android.widget.ProgressBar;
|
||||
import androidx.annotation.NonNull;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import java.util.List;
|
||||
import org.gitnex.tea4j.v2.models.Issue;
|
||||
import org.gitnex.tea4j.v2.models.User;
|
||||
import org.mian.gitnex.R;
|
||||
|
@ -12,103 +13,130 @@ import org.mian.gitnex.adapters.AssigneesListAdapter;
|
|||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.CustomAssigneesSelectionDialogBinding;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
/**
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class AssigneesActions {
|
||||
|
||||
public static void getCurrentIssueAssignees(Context ctx, String repoOwner, String repoName, int issueIndex, List<String> currentAssignees) {
|
||||
public static void getCurrentIssueAssignees(
|
||||
Context ctx,
|
||||
String repoOwner,
|
||||
String repoName,
|
||||
int issueIndex,
|
||||
List<String> currentAssignees) {
|
||||
|
||||
Call<Issue> callSingleIssueLabels = RetrofitClient.getApiInterface(ctx).issueGetIssue(repoOwner, repoName, (long) issueIndex);
|
||||
Call<Issue> callSingleIssueLabels =
|
||||
RetrofitClient.getApiInterface(ctx)
|
||||
.issueGetIssue(repoOwner, repoName, (long) issueIndex);
|
||||
|
||||
callSingleIssueLabels.enqueue(new Callback<>() {
|
||||
callSingleIssueLabels.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Issue> call, @NonNull retrofit2.Response<Issue> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<Issue> call,
|
||||
@NonNull retrofit2.Response<Issue> response) {
|
||||
|
||||
if(response.code() == 200) {
|
||||
if (response.code() == 200) {
|
||||
|
||||
Issue issueAssigneesList = response.body();
|
||||
assert issueAssigneesList != null;
|
||||
Issue issueAssigneesList = response.body();
|
||||
assert issueAssigneesList != null;
|
||||
|
||||
if(issueAssigneesList.getAssignees() != null) {
|
||||
if (issueAssigneesList.getAssignees() != null) {
|
||||
|
||||
if(issueAssigneesList.getAssignees().size() > 0) {
|
||||
if (issueAssigneesList.getAssignees().size() > 0) {
|
||||
|
||||
for(int i = 0; i < issueAssigneesList.getAssignees().size(); i++) {
|
||||
for (int i = 0;
|
||||
i < issueAssigneesList.getAssignees().size();
|
||||
i++) {
|
||||
|
||||
currentAssignees.add(issueAssigneesList.getAssignees().get(i).getLogin());
|
||||
currentAssignees.add(
|
||||
issueAssigneesList
|
||||
.getAssignees()
|
||||
.get(i)
|
||||
.getLogin());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
Toasty.error(ctx, ctx.getResources().getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(ctx, ctx.getResources().getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Issue> call, @NonNull Throwable t) {
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Issue> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
Toasty.error(
|
||||
ctx,
|
||||
ctx.getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void getRepositoryAssignees(Context ctx, String repoOwner, String repoName, List<User> assigneesList, MaterialAlertDialogBuilder materialAlertDialogBuilder, AssigneesListAdapter assigneesAdapter,
|
||||
CustomAssigneesSelectionDialogBinding assigneesBinding, ProgressBar progressBar) {
|
||||
public static void getRepositoryAssignees(
|
||||
Context ctx,
|
||||
String repoOwner,
|
||||
String repoName,
|
||||
List<User> assigneesList,
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder,
|
||||
AssigneesListAdapter assigneesAdapter,
|
||||
CustomAssigneesSelectionDialogBinding assigneesBinding,
|
||||
ProgressBar progressBar) {
|
||||
|
||||
Call<List<User>> call = RetrofitClient.getApiInterface(ctx).repoGetAssignees(repoOwner, repoName);
|
||||
Call<List<User>> call =
|
||||
RetrofitClient.getApiInterface(ctx).repoGetAssignees(repoOwner, repoName);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<User>> call, @NonNull retrofit2.Response<List<User>> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<List<User>> call,
|
||||
@NonNull retrofit2.Response<List<User>> response) {
|
||||
|
||||
assigneesList.clear();
|
||||
List<User> assigneesList_ = response.body();
|
||||
assigneesList.clear();
|
||||
List<User> assigneesList_ = response.body();
|
||||
|
||||
if(response.code() == 200) {
|
||||
if (response.code() == 200) {
|
||||
|
||||
assert assigneesList_ != null;
|
||||
assert assigneesList_ != null;
|
||||
|
||||
if(assigneesList_.size() > 0) {
|
||||
if (assigneesList_.size() > 0) {
|
||||
|
||||
assigneesList.addAll(assigneesList_);
|
||||
materialAlertDialogBuilder.show();
|
||||
}
|
||||
else {
|
||||
assigneesList.addAll(assigneesList_);
|
||||
materialAlertDialogBuilder.show();
|
||||
} else {
|
||||
|
||||
Toasty.warning(ctx, ctx.getResources().getString(R.string.noAssigneesFound));
|
||||
Toasty.warning(
|
||||
ctx,
|
||||
ctx.getResources().getString(R.string.noAssigneesFound));
|
||||
}
|
||||
|
||||
assigneesBinding.assigneesRecyclerView.setAdapter(assigneesAdapter);
|
||||
|
||||
} else {
|
||||
|
||||
Toasty.error(ctx, ctx.getResources().getString(R.string.genericError));
|
||||
}
|
||||
if (progressBar != null) {
|
||||
progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
assigneesBinding.assigneesRecyclerView.setAdapter(assigneesAdapter);
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<User>> call, @NonNull Throwable t) {
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(ctx, ctx.getResources().getString(R.string.genericError));
|
||||
}
|
||||
if(progressBar != null) {
|
||||
progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<User>> call, @NonNull Throwable t) {
|
||||
|
||||
if(progressBar != null) {
|
||||
progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
Toasty.error(ctx, ctx.getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
if (progressBar != null) {
|
||||
progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
Toasty.error(
|
||||
ctx,
|
||||
ctx.getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,97 +16,114 @@ import retrofit2.Callback;
|
|||
/**
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class CollaboratorActions {
|
||||
|
||||
public static void deleteCollaborator(final Context context, String userName, RepositoryContext repository) {
|
||||
public static void deleteCollaborator(
|
||||
final Context context, String userName, RepositoryContext repository) {
|
||||
|
||||
Call<Void> call = RetrofitClient.getApiInterface(context).repoDeleteCollaborator(repository.getOwner(), repository.getName(), userName);
|
||||
Call<Void> call =
|
||||
RetrofitClient.getApiInterface(context)
|
||||
.repoDeleteCollaborator(
|
||||
repository.getOwner(), repository.getName(), userName);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if(response.code() == 204) {
|
||||
if (response.isSuccessful()) {
|
||||
if (response.code() == 204) {
|
||||
|
||||
CollaboratorsFragment.refreshCollaborators = true;
|
||||
Toasty.success(context, context.getString(R.string.removeCollaboratorToastText));
|
||||
((AddCollaboratorToRepositoryActivity) context).finish();
|
||||
CollaboratorsFragment.refreshCollaborators = true;
|
||||
Toasty.success(
|
||||
context,
|
||||
context.getString(R.string.removeCollaboratorToastText));
|
||||
((AddCollaboratorToRepositoryActivity) context).finish();
|
||||
}
|
||||
} else if (response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(context);
|
||||
} else if (response.code() == 403) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
} else if (response.code() == 404) {
|
||||
|
||||
Toasty.warning(context, context.getString(R.string.apiNotFound));
|
||||
} else {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(context);
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
|
||||
Toasty.warning(context, context.getString(R.string.apiNotFound));
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(context, context.getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(
|
||||
context,
|
||||
context.getResources()
|
||||
.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void addCollaborator(final Context context, String permission, String userName, RepositoryContext repository) {
|
||||
public static void addCollaborator(
|
||||
final Context context,
|
||||
String permission,
|
||||
String userName,
|
||||
RepositoryContext repository) {
|
||||
|
||||
AddCollaboratorOption permissionString = new AddCollaboratorOption();
|
||||
permissionString.setPermission(permission);
|
||||
|
||||
Call<Void> call = RetrofitClient.getApiInterface(context).repoAddCollaborator(repository.getOwner(), repository.getName(), userName, permissionString);
|
||||
Call<Void> call =
|
||||
RetrofitClient.getApiInterface(context)
|
||||
.repoAddCollaborator(
|
||||
repository.getOwner(),
|
||||
repository.getName(),
|
||||
userName,
|
||||
permissionString);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if(response.code() == 204) {
|
||||
if (response.isSuccessful()) {
|
||||
if (response.code() == 204) {
|
||||
|
||||
CollaboratorsFragment.refreshCollaborators = true;
|
||||
Toasty.success(context, context.getString(R.string.addCollaboratorToastText));
|
||||
((AddCollaboratorToRepositoryActivity) context).finish();
|
||||
CollaboratorsFragment.refreshCollaborators = true;
|
||||
Toasty.success(
|
||||
context,
|
||||
context.getString(R.string.addCollaboratorToastText));
|
||||
((AddCollaboratorToRepositoryActivity) context).finish();
|
||||
}
|
||||
} else if (response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(context);
|
||||
} else if (response.code() == 403) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
} else if (response.code() == 404) {
|
||||
|
||||
Toasty.warning(context, context.getString(R.string.apiNotFound));
|
||||
} else {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(context);
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
|
||||
Toasty.warning(context, context.getString(R.string.apiNotFound));
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(context, context.getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
Toasty.error(
|
||||
context,
|
||||
context.getResources()
|
||||
.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,243 +25,288 @@ import retrofit2.Response;
|
|||
/**
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class IssueActions {
|
||||
|
||||
public static ActionResult<Response<?>> edit(Context context, String comment, int commentId, IssueContext issue) {
|
||||
public static ActionResult<Response<?>> edit(
|
||||
Context context, String comment, int commentId, IssueContext issue) {
|
||||
|
||||
ActionResult<Response<?>> actionResult = new ActionResult<>();
|
||||
|
||||
EditIssueCommentOption commentObj = new EditIssueCommentOption();
|
||||
commentObj.setBody(comment);
|
||||
|
||||
Call<Comment> call = RetrofitClient.getApiInterface(context).issueEditComment(issue.getRepository().getOwner(), issue.getRepository().getName(), (long) commentId, commentObj);
|
||||
Call<Comment> call =
|
||||
RetrofitClient.getApiInterface(context)
|
||||
.issueEditComment(
|
||||
issue.getRepository().getOwner(),
|
||||
issue.getRepository().getName(),
|
||||
(long) commentId,
|
||||
commentObj);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Comment> call, @NonNull retrofit2.Response<Comment> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<Comment> call,
|
||||
@NonNull retrofit2.Response<Comment> response) {
|
||||
|
||||
switch(response.code()) {
|
||||
switch (response.code()) {
|
||||
case 200:
|
||||
actionResult.finish(ActionResult.Status.SUCCESS);
|
||||
break;
|
||||
|
||||
case 200:
|
||||
actionResult.finish(ActionResult.Status.SUCCESS);
|
||||
break;
|
||||
case 401:
|
||||
actionResult.finish(ActionResult.Status.FAILED, response);
|
||||
AlertDialogs.authorizationTokenRevokedDialog(context);
|
||||
break;
|
||||
|
||||
case 401:
|
||||
actionResult.finish(ActionResult.Status.FAILED, response);
|
||||
AlertDialogs.authorizationTokenRevokedDialog(context);
|
||||
break;
|
||||
default:
|
||||
actionResult.finish(ActionResult.Status.FAILED, response);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
default:
|
||||
actionResult.finish(ActionResult.Status.FAILED, response);
|
||||
break;
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Comment> call, @NonNull Throwable t) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Comment> call, @NonNull Throwable t) {
|
||||
|
||||
actionResult.finish(ActionResult.Status.FAILED);
|
||||
}
|
||||
});
|
||||
actionResult.finish(ActionResult.Status.FAILED);
|
||||
}
|
||||
});
|
||||
|
||||
return actionResult;
|
||||
}
|
||||
|
||||
public static void closeReopenIssue(final Context ctx, final String issueState, IssueContext issue) {
|
||||
public static void closeReopenIssue(
|
||||
final Context ctx, final String issueState, IssueContext issue) {
|
||||
|
||||
EditIssueOption issueStatJson = new EditIssueOption();
|
||||
issueStatJson.setState(issueState);
|
||||
Call<Issue> call = RetrofitClient.getApiInterface(ctx).issueEditIssue(issue.getRepository().getOwner(), issue.getRepository().getName(), (long) issue.getIssueIndex(), issueStatJson);
|
||||
Call<Issue> call =
|
||||
RetrofitClient.getApiInterface(ctx)
|
||||
.issueEditIssue(
|
||||
issue.getRepository().getOwner(),
|
||||
issue.getRepository().getName(),
|
||||
(long) issue.getIssueIndex(),
|
||||
issueStatJson);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Issue> call, @NonNull retrofit2.Response<Issue> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<Issue> call,
|
||||
@NonNull retrofit2.Response<Issue> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if(response.code() == 201) {
|
||||
if (response.isSuccessful()) {
|
||||
if (response.code() == 201) {
|
||||
|
||||
if(issue.hasIssue()) {
|
||||
IssuesFragment.resumeIssues = issue.getIssue().getPullRequest() == null;
|
||||
PullRequestsFragment.resumePullRequests = issue.getIssue().getPullRequest() != null;
|
||||
}
|
||||
if(issue.getIssueType().equalsIgnoreCase("Pull")) {
|
||||
if(issueState.equals("closed")) {
|
||||
Toasty.success(ctx, ctx.getString(R.string.prClosed));
|
||||
if (issue.hasIssue()) {
|
||||
IssuesFragment.resumeIssues =
|
||||
issue.getIssue().getPullRequest() == null;
|
||||
PullRequestsFragment.resumePullRequests =
|
||||
issue.getIssue().getPullRequest() != null;
|
||||
}
|
||||
if (issue.getIssueType().equalsIgnoreCase("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.singleIssueUpdate = true;
|
||||
((IssueDetailActivity) ctx).onResume();
|
||||
if (((Activity) ctx).getIntent().getStringExtra("openedFromLink")
|
||||
== null
|
||||
|| !((Activity) ctx)
|
||||
.getIntent()
|
||||
.getStringExtra("openedFromLink")
|
||||
.equals("true")) {
|
||||
RepoDetailActivity.updateRepo = true;
|
||||
}
|
||||
}
|
||||
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));
|
||||
}
|
||||
}
|
||||
} else if (response.code() == 401) {
|
||||
|
||||
IssueDetailActivity.singleIssueUpdate = true;
|
||||
((IssueDetailActivity) ctx).onResume();
|
||||
if(((Activity) ctx).getIntent().getStringExtra("openedFromLink") == null || !((Activity) ctx).getIntent().getStringExtra("openedFromLink").equals("true")) {
|
||||
RepoDetailActivity.updateRepo = true;
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
} else if (response.code() == 403) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
||||
} else if (response.code() == 404) {
|
||||
|
||||
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
||||
} else {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
|
||||
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Issue> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Issue> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(
|
||||
ctx,
|
||||
ctx.getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void subscribe(final Context ctx, IssueContext issue) {
|
||||
|
||||
Call<Void> call;
|
||||
|
||||
call = RetrofitClient.getApiInterface(ctx)
|
||||
.issueAddSubscription(issue.getRepository().getOwner(), issue.getRepository().getName(), (long) issue.getIssueIndex(), ((BaseActivity) ctx).getAccount().getAccount().getUserName());
|
||||
call =
|
||||
RetrofitClient.getApiInterface(ctx)
|
||||
.issueAddSubscription(
|
||||
issue.getRepository().getOwner(),
|
||||
issue.getRepository().getName(),
|
||||
(long) issue.getIssueIndex(),
|
||||
((BaseActivity) ctx).getAccount().getAccount().getUserName());
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if (response.isSuccessful()) {
|
||||
|
||||
if(response.code() == 201) {
|
||||
if (response.code() == 201) {
|
||||
|
||||
Toasty.success(ctx, ctx.getString(R.string.subscribedSuccessfully));
|
||||
Toasty.success(ctx, ctx.getString(R.string.subscribedSuccessfully));
|
||||
} else if (response.code() == 200) {
|
||||
|
||||
Toasty.success(ctx, ctx.getString(R.string.alreadySubscribed));
|
||||
}
|
||||
} else if (response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
} else {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.subscriptionError));
|
||||
}
|
||||
}
|
||||
else if(response.code() == 200) {
|
||||
|
||||
Toasty.success(ctx, ctx.getString(R.string.alreadySubscribed));
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(
|
||||
ctx,
|
||||
ctx.getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.subscriptionError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
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)
|
||||
.issueDeleteSubscription(issue.getRepository().getOwner(), issue.getRepository().getName(), (long) 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<>() {
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if (response.isSuccessful()) {
|
||||
|
||||
if(response.code() == 201) {
|
||||
if (response.code() == 201) {
|
||||
|
||||
Toasty.success(ctx, ctx.getString(R.string.unsubscribedSuccessfully));
|
||||
Toasty.success(
|
||||
ctx, ctx.getString(R.string.unsubscribedSuccessfully));
|
||||
} else if (response.code() == 200) {
|
||||
|
||||
Toasty.success(ctx, ctx.getString(R.string.alreadyUnsubscribed));
|
||||
}
|
||||
} else if (response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
} else {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.unSubscriptionError));
|
||||
}
|
||||
}
|
||||
else if(response.code() == 200) {
|
||||
|
||||
Toasty.success(ctx, ctx.getString(R.string.alreadyUnsubscribed));
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(
|
||||
ctx,
|
||||
ctx.getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.unSubscriptionError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public static ActionResult<ActionResult.None> reply(Context context, String comment, IssueContext issue) {
|
||||
public static ActionResult<ActionResult.None> reply(
|
||||
Context context, String comment, IssueContext issue) {
|
||||
|
||||
ActionResult<ActionResult.None> actionResult = new ActionResult<>();
|
||||
|
||||
CreateIssueCommentOption issueComment = new CreateIssueCommentOption();
|
||||
issueComment.setBody(comment);
|
||||
|
||||
Call<Comment> call = RetrofitClient.getApiInterface(context).issueCreateComment(issue.getRepository().getOwner(), issue.getRepository().getName(), (long) issue.getIssueIndex(), issueComment);
|
||||
Call<Comment> call =
|
||||
RetrofitClient.getApiInterface(context)
|
||||
.issueCreateComment(
|
||||
issue.getRepository().getOwner(),
|
||||
issue.getRepository().getName(),
|
||||
(long) issue.getIssueIndex(),
|
||||
issueComment);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Comment> call, @NonNull retrofit2.Response<Comment> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<Comment> call,
|
||||
@NonNull retrofit2.Response<Comment> response) {
|
||||
|
||||
if(response.code() == 201) {
|
||||
actionResult.finish(ActionResult.Status.SUCCESS);
|
||||
if (response.code() == 201) {
|
||||
actionResult.finish(ActionResult.Status.SUCCESS);
|
||||
|
||||
if(issue.hasIssue()) {
|
||||
IssuesFragment.resumeIssues = issue.getIssue().getPullRequest() == null;
|
||||
PullRequestsFragment.resumePullRequests = issue.getIssue().getPullRequest() != null;
|
||||
if (issue.hasIssue()) {
|
||||
IssuesFragment.resumeIssues =
|
||||
issue.getIssue().getPullRequest() == null;
|
||||
PullRequestsFragment.resumePullRequests =
|
||||
issue.getIssue().getPullRequest() != null;
|
||||
}
|
||||
} else if (response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(context);
|
||||
|
||||
} else {
|
||||
|
||||
actionResult.finish(ActionResult.Status.FAILED);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(context);
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Comment> call, @NonNull Throwable t) {
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
actionResult.finish(ActionResult.Status.FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Comment> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(context, context.getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
Toasty.error(
|
||||
context,
|
||||
context.getResources()
|
||||
.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
|
||||
return actionResult;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,124 +5,160 @@ import android.view.View;
|
|||
import android.widget.ProgressBar;
|
||||
import androidx.annotation.NonNull;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import java.util.List;
|
||||
import org.gitnex.tea4j.v2.models.Label;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.LabelsListAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.CustomLabelsSelectionDialogBinding;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
/**
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class LabelsActions {
|
||||
|
||||
public static void getCurrentIssueLabels(Context ctx, String repoOwner, String repoName, int issueIndex, List<Integer> currentLabelsIds) {
|
||||
public static void getCurrentIssueLabels(
|
||||
Context ctx,
|
||||
String repoOwner,
|
||||
String repoName,
|
||||
int issueIndex,
|
||||
List<Integer> currentLabelsIds) {
|
||||
|
||||
Call<List<Label>> callSingleIssueLabels = RetrofitClient.getApiInterface(ctx).issueGetLabels(repoOwner, repoName, (long) issueIndex);
|
||||
Call<List<Label>> callSingleIssueLabels =
|
||||
RetrofitClient.getApiInterface(ctx)
|
||||
.issueGetLabels(repoOwner, repoName, (long) issueIndex);
|
||||
|
||||
callSingleIssueLabels.enqueue(new Callback<>() {
|
||||
callSingleIssueLabels.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Label>> call, @NonNull retrofit2.Response<List<Label>> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<List<Label>> call,
|
||||
@NonNull retrofit2.Response<List<Label>> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if (response.isSuccessful()) {
|
||||
|
||||
List<Label> issueLabelsList = response.body();
|
||||
List<Label> issueLabelsList = response.body();
|
||||
|
||||
assert issueLabelsList != null;
|
||||
assert issueLabelsList != null;
|
||||
|
||||
if(issueLabelsList.size() > 0) {
|
||||
if (issueLabelsList.size() > 0) {
|
||||
|
||||
for(int i = 0; i < issueLabelsList.size(); i++) {
|
||||
for (int i = 0; i < issueLabelsList.size(); i++) {
|
||||
|
||||
currentLabelsIds.add(Math.toIntExact(issueLabelsList.get(i).getId()));
|
||||
currentLabelsIds.add(
|
||||
Math.toIntExact(issueLabelsList.get(i).getId()));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Label>> call, @NonNull Throwable t) {
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Label>> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void getRepositoryLabels(Context ctx, String repoOwner, String repoName, List<Label> labelsList, MaterialAlertDialogBuilder materialAlertDialogBuilder, LabelsListAdapter labelsAdapter,
|
||||
CustomLabelsSelectionDialogBinding labelsBinding, ProgressBar progressBar) {
|
||||
public static void getRepositoryLabels(
|
||||
Context ctx,
|
||||
String repoOwner,
|
||||
String repoName,
|
||||
List<Label> labelsList,
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder,
|
||||
LabelsListAdapter labelsAdapter,
|
||||
CustomLabelsSelectionDialogBinding labelsBinding,
|
||||
ProgressBar progressBar) {
|
||||
|
||||
Call<List<Label>> call = RetrofitClient.getApiInterface(ctx).issueListLabels(repoOwner, repoName, null, null);
|
||||
Call<List<Label>> call =
|
||||
RetrofitClient.getApiInterface(ctx)
|
||||
.issueListLabels(repoOwner, repoName, null, null);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Label>> call, @NonNull retrofit2.Response<List<Label>> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<List<Label>> call,
|
||||
@NonNull retrofit2.Response<List<Label>> response) {
|
||||
|
||||
labelsList.clear();
|
||||
labelsList.clear();
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if (response.isSuccessful()) {
|
||||
|
||||
if(response.body() != null) {
|
||||
if (response.body() != null) {
|
||||
|
||||
labelsList.addAll(response.body());
|
||||
labelsList.addAll(response.body());
|
||||
}
|
||||
|
||||
// Load organization labels
|
||||
Call<List<Label>> callOrgLabels =
|
||||
RetrofitClient.getApiInterface(ctx)
|
||||
.orgListLabels(repoOwner, null, null);
|
||||
|
||||
callOrgLabels.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<List<Label>> call,
|
||||
@NonNull retrofit2.Response<List<Label>>
|
||||
responseOrg) {
|
||||
|
||||
if (responseOrg.body() != null) {
|
||||
|
||||
labelsList.addAll(responseOrg.body());
|
||||
materialAlertDialogBuilder.show();
|
||||
}
|
||||
|
||||
if (labelsList.isEmpty()) {
|
||||
|
||||
Toasty.warning(
|
||||
ctx,
|
||||
ctx.getResources()
|
||||
.getString(R.string.noDataFound));
|
||||
}
|
||||
|
||||
labelsBinding.labelsRecyclerView.setAdapter(
|
||||
labelsAdapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(
|
||||
@NonNull Call<List<Label>> call,
|
||||
@NonNull Throwable t) {
|
||||
|
||||
Toasty.error(
|
||||
ctx,
|
||||
ctx.getString(
|
||||
R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
||||
Toasty.error(ctx, ctx.getResources().getString(R.string.genericError));
|
||||
}
|
||||
if (progressBar != null) {
|
||||
progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
// Load organization labels
|
||||
Call<List<Label>> callOrgLabels = RetrofitClient.getApiInterface(ctx).orgListLabels(repoOwner, null, null);
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Label>> call, @NonNull Throwable t) {
|
||||
|
||||
callOrgLabels.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Label>> call, @NonNull retrofit2.Response<List<Label>> responseOrg) {
|
||||
|
||||
if(responseOrg.body() != null) {
|
||||
|
||||
labelsList.addAll(responseOrg.body());
|
||||
materialAlertDialogBuilder.show();
|
||||
}
|
||||
|
||||
if(labelsList.isEmpty()) {
|
||||
|
||||
Toasty.warning(ctx, ctx.getResources().getString(R.string.noDataFound));
|
||||
}
|
||||
|
||||
labelsBinding.labelsRecyclerView.setAdapter(labelsAdapter);
|
||||
if (progressBar != null) {
|
||||
progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Label>> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(ctx, ctx.getResources().getString(R.string.genericError));
|
||||
}
|
||||
if(progressBar != null) {
|
||||
progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Label>> call, @NonNull Throwable t) {
|
||||
|
||||
if(progressBar != null) {
|
||||
progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
Toasty.error(ctx, ctx.getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
Toasty.error(
|
||||
ctx,
|
||||
ctx.getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,58 +15,60 @@ import retrofit2.Callback;
|
|||
/**
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class MilestoneActions {
|
||||
|
||||
static final private String TAG = "MilestoneActions : ";
|
||||
private static final String TAG = "MilestoneActions : ";
|
||||
|
||||
public static void closeMilestone(final Context ctx, int milestoneId_, RepositoryContext repository) {
|
||||
public static void closeMilestone(
|
||||
final Context ctx, int milestoneId_, RepositoryContext repository) {
|
||||
updateMilestoneState(ctx, milestoneId_, repository, "closed");
|
||||
}
|
||||
|
||||
public static void openMilestone(final Context ctx, int milestoneId_, RepositoryContext repository) {
|
||||
public static void openMilestone(
|
||||
final Context ctx, int milestoneId_, RepositoryContext repository) {
|
||||
updateMilestoneState(ctx, milestoneId_, repository, "open");
|
||||
}
|
||||
|
||||
private static void updateMilestoneState(final Context ctx, int milestoneId_, RepositoryContext repository, String state) {
|
||||
private static void updateMilestoneState(
|
||||
final Context ctx, int milestoneId_, RepositoryContext repository, String state) {
|
||||
|
||||
EditMilestoneOption milestoneStateJson = new EditMilestoneOption();
|
||||
milestoneStateJson.setState(state);
|
||||
Call<Milestone> call = RetrofitClient.getApiInterface(ctx).issueEditMilestone(repository.getOwner(), repository.getName(), String.valueOf(milestoneId_), milestoneStateJson);
|
||||
Call<Milestone> call =
|
||||
RetrofitClient.getApiInterface(ctx)
|
||||
.issueEditMilestone(
|
||||
repository.getOwner(),
|
||||
repository.getName(),
|
||||
String.valueOf(milestoneId_),
|
||||
milestoneStateJson);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Milestone> call, @NonNull retrofit2.Response<Milestone> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<Milestone> call,
|
||||
@NonNull retrofit2.Response<Milestone> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if (response.isSuccessful()) {
|
||||
|
||||
Toasty.success(ctx, ctx.getString(R.string.milestoneStatusUpdate));
|
||||
Toasty.success(ctx, ctx.getString(R.string.milestoneStatusUpdate));
|
||||
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
} else if (response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
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.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Milestone> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,97 +13,107 @@ import retrofit2.Response;
|
|||
/**
|
||||
* @author qwerty287
|
||||
*/
|
||||
|
||||
public class PullRequestActions {
|
||||
|
||||
public static void deleteHeadBranch(Context context, String repoOwner, String repoName, String headBranch, boolean showToasts) {
|
||||
Call<Void> call = RetrofitClient.getApiInterface(context).repoDeleteBranch(repoOwner, repoName, headBranch);
|
||||
public static void deleteHeadBranch(
|
||||
Context context,
|
||||
String repoOwner,
|
||||
String repoName,
|
||||
String headBranch,
|
||||
boolean showToasts) {
|
||||
Call<Void> call =
|
||||
RetrofitClient.getApiInterface(context)
|
||||
.repoDeleteBranch(repoOwner, repoName, headBranch);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
|
||||
if(response.code() == 204) {
|
||||
if (response.code() == 204) {
|
||||
|
||||
if(showToasts) {
|
||||
Toasty.success(context, context.getString(R.string.deleteBranchSuccess));
|
||||
if (showToasts) {
|
||||
Toasty.success(
|
||||
context, context.getString(R.string.deleteBranchSuccess));
|
||||
}
|
||||
} else if (response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(context);
|
||||
} else if (response.code() == 403) {
|
||||
|
||||
if (showToasts) {
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
}
|
||||
} else if (response.code() == 404) {
|
||||
|
||||
if (showToasts) {
|
||||
Toasty.warning(
|
||||
context,
|
||||
context.getString(R.string.deleteBranchErrorNotFound));
|
||||
}
|
||||
} else {
|
||||
|
||||
if (showToasts) {
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(context);
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
if(showToasts) {
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
if (showToasts) {
|
||||
Toasty.error(context, context.getString(R.string.deleteBranchError));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
|
||||
if(showToasts) {
|
||||
Toasty.warning(context, context.getString(R.string.deleteBranchErrorNotFound));
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
if(showToasts) {
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
if(showToasts) {
|
||||
Toasty.error(context, context.getString(R.string.deleteBranchError));
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public static void updatePr(Context context, String repoOwner, String repoName, String index, Boolean rebase) {
|
||||
public static void updatePr(
|
||||
Context context, String repoOwner, String repoName, String index, Boolean rebase) {
|
||||
|
||||
String strategy;
|
||||
if(rebase == null) {
|
||||
if (rebase == null) {
|
||||
strategy = null;
|
||||
}
|
||||
else if(!rebase) {
|
||||
} else if (!rebase) {
|
||||
strategy = "merge";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
strategy = "rebase";
|
||||
}
|
||||
RetrofitClient.getApiInterface(context).repoUpdatePullRequest(repoOwner, repoName, Long.valueOf(index), strategy).enqueue(new Callback<>() {
|
||||
RetrofitClient.getApiInterface(context)
|
||||
.repoUpdatePullRequest(repoOwner, repoName, Long.valueOf(index), strategy)
|
||||
.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call call, @NonNull Response response) {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call call, @NonNull Response response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
Toasty.success(context, context.getString(R.string.updatePrSuccess));
|
||||
}
|
||||
else {
|
||||
if(response.code() == 403) {
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
}
|
||||
else if(response.code() == 409) {
|
||||
Toasty.error(context, context.getString(R.string.updatePrConflict));
|
||||
}
|
||||
else {
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (response.isSuccessful()) {
|
||||
Toasty.success(
|
||||
context, context.getString(R.string.updatePrSuccess));
|
||||
} else {
|
||||
if (response.code() == 403) {
|
||||
Toasty.error(
|
||||
context,
|
||||
context.getString(R.string.authorizeError));
|
||||
} else if (response.code() == 409) {
|
||||
Toasty.error(
|
||||
context,
|
||||
context.getString(R.string.updatePrConflict));
|
||||
} else {
|
||||
Toasty.error(
|
||||
context, context.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call call, @NonNull Throwable t) {
|
||||
@Override
|
||||
public void onFailure(@NonNull Call call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
}
|
||||
});
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,173 +15,180 @@ import retrofit2.Callback;
|
|||
/**
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class RepositoryActions {
|
||||
|
||||
public static void starRepository(final Context context, RepositoryContext repository) {
|
||||
|
||||
Call<Void> call = RetrofitClient.getApiInterface(context).userCurrentPutStar(repository.getOwner(), repository.getName());
|
||||
Call<Void> call =
|
||||
RetrofitClient.getApiInterface(context)
|
||||
.userCurrentPutStar(repository.getOwner(), repository.getName());
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if(response.code() == 204) {
|
||||
if (response.isSuccessful()) {
|
||||
if (response.code() == 204) {
|
||||
|
||||
MainActivity.reloadRepos = true;
|
||||
Toasty.success(context, context.getString(R.string.starRepositorySuccess));
|
||||
MainActivity.reloadRepos = true;
|
||||
Toasty.success(
|
||||
context, context.getString(R.string.starRepositorySuccess));
|
||||
}
|
||||
} else if (response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(context);
|
||||
} else if (response.code() == 403) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
} else if (response.code() == 404) {
|
||||
|
||||
Toasty.warning(context, context.getString(R.string.apiNotFound));
|
||||
} else {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(context);
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
|
||||
Toasty.warning(context, context.getString(R.string.apiNotFound));
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
Toasty.error(
|
||||
context, context.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void unStarRepository(final Context context, RepositoryContext repository) {
|
||||
|
||||
Call<Void> call = RetrofitClient.getApiInterface(context).userCurrentDeleteStar(repository.getOwner(), repository.getName());
|
||||
Call<Void> call =
|
||||
RetrofitClient.getApiInterface(context)
|
||||
.userCurrentDeleteStar(repository.getOwner(), repository.getName());
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if(response.code() == 204) {
|
||||
if (response.isSuccessful()) {
|
||||
if (response.code() == 204) {
|
||||
|
||||
MainActivity.reloadRepos = true;
|
||||
Toasty.success(context, context.getString(R.string.unStarRepositorySuccess));
|
||||
MainActivity.reloadRepos = true;
|
||||
Toasty.success(
|
||||
context,
|
||||
context.getString(R.string.unStarRepositorySuccess));
|
||||
}
|
||||
} else if (response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(context);
|
||||
} else if (response.code() == 403) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
} else if (response.code() == 404) {
|
||||
|
||||
Toasty.warning(context, context.getString(R.string.apiNotFound));
|
||||
} else {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(context);
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
|
||||
Toasty.warning(context, context.getString(R.string.apiNotFound));
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
Toasty.error(
|
||||
context, context.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void watchRepository(final Context context, RepositoryContext repository) {
|
||||
|
||||
Call<WatchInfo> call = RetrofitClient.getApiInterface(context).userCurrentPutSubscription(repository.getOwner(), repository.getName());
|
||||
Call<WatchInfo> call =
|
||||
RetrofitClient.getApiInterface(context)
|
||||
.userCurrentPutSubscription(repository.getOwner(), repository.getName());
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<WatchInfo> call, @NonNull retrofit2.Response<WatchInfo> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<WatchInfo> call,
|
||||
@NonNull retrofit2.Response<WatchInfo> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if(response.code() == 200) {
|
||||
if (response.isSuccessful()) {
|
||||
if (response.code() == 200) {
|
||||
|
||||
Toasty.success(context, context.getString(R.string.watchRepositorySuccess));
|
||||
Toasty.success(
|
||||
context,
|
||||
context.getString(R.string.watchRepositorySuccess));
|
||||
}
|
||||
} else if (response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(context);
|
||||
} else if (response.code() == 403) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
} else if (response.code() == 404) {
|
||||
|
||||
Toasty.warning(context, context.getString(R.string.apiNotFound));
|
||||
} else {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(context);
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<WatchInfo> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
|
||||
Toasty.warning(context, context.getString(R.string.apiNotFound));
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<WatchInfo> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
Toasty.error(
|
||||
context, context.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void unWatchRepository(final Context context, RepositoryContext repository) {
|
||||
|
||||
Call<Void> call = RetrofitClient.getApiInterface(context).userCurrentDeleteStar(repository.getOwner(), repository.getName());
|
||||
Call<Void> call =
|
||||
RetrofitClient.getApiInterface(context)
|
||||
.userCurrentDeleteStar(repository.getOwner(), repository.getName());
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
|
||||
if(response.code() == 204) {
|
||||
if (response.code() == 204) {
|
||||
|
||||
Toasty.success(context, context.getString(R.string.unWatchRepositorySuccess));
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
Toasty.success(
|
||||
context, context.getString(R.string.unWatchRepositorySuccess));
|
||||
} else if (response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(context);
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
AlertDialogs.authorizationTokenRevokedDialog(context);
|
||||
} else if (response.code() == 403) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
} else if (response.code() == 404) {
|
||||
|
||||
Toasty.warning(context, context.getString(R.string.apiNotFound));
|
||||
}
|
||||
else {
|
||||
Toasty.warning(context, context.getString(R.string.apiNotFound));
|
||||
} else {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
Toasty.error(
|
||||
context, context.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,183 +15,197 @@ import retrofit2.Callback;
|
|||
/**
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class TeamActions {
|
||||
|
||||
public static void removeTeamMember(final Context context, String userName, int teamId) {
|
||||
|
||||
Call<Void> call = RetrofitClient.getApiInterface(context).orgRemoveTeamMember((long) teamId, userName);
|
||||
Call<Void> call =
|
||||
RetrofitClient.getApiInterface(context)
|
||||
.orgRemoveTeamMember((long) teamId, userName);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if (response.isSuccessful()) {
|
||||
|
||||
if(response.code() == 204) {
|
||||
if (response.code() == 204) {
|
||||
|
||||
Toasty.success(context, context.getString(R.string.memberRemovedMessage));
|
||||
((AddNewTeamMemberActivity) context).finish();
|
||||
Toasty.success(
|
||||
context, context.getString(R.string.memberRemovedMessage));
|
||||
((AddNewTeamMemberActivity) context).finish();
|
||||
}
|
||||
|
||||
} else if (response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(context);
|
||||
} else if (response.code() == 403) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
} else if (response.code() == 404) {
|
||||
|
||||
Toasty.warning(context, context.getString(R.string.apiNotFound));
|
||||
} else {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(context);
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
|
||||
Toasty.warning(context, context.getString(R.string.apiNotFound));
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(context, context.getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
Toasty.error(
|
||||
context,
|
||||
context.getResources()
|
||||
.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void addTeamMember(final Context context, String userName, int teamId) {
|
||||
|
||||
Call<Void> call = RetrofitClient.getApiInterface(context).orgAddTeamMember((long) teamId, userName);
|
||||
Call<Void> call =
|
||||
RetrofitClient.getApiInterface(context).orgAddTeamMember((long) teamId, userName);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if (response.isSuccessful()) {
|
||||
|
||||
if(response.code() == 204) {
|
||||
if (response.code() == 204) {
|
||||
|
||||
Toasty.success(context, context.getString(R.string.memberAddedMessage));
|
||||
((AddNewTeamMemberActivity) context).finish();
|
||||
Toasty.success(
|
||||
context, context.getString(R.string.memberAddedMessage));
|
||||
((AddNewTeamMemberActivity) context).finish();
|
||||
}
|
||||
} else if (response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(context);
|
||||
} else if (response.code() == 403) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
} else if (response.code() == 404) {
|
||||
|
||||
Toasty.warning(context, context.getString(R.string.apiNotFound));
|
||||
} else {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(context);
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
|
||||
Toasty.warning(context, context.getString(R.string.apiNotFound));
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(context, context.getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
Toasty.error(
|
||||
context,
|
||||
context.getResources()
|
||||
.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void removeTeamRepo(final Context context, String orgName, int teamId, String repo) {
|
||||
public static void removeTeamRepo(
|
||||
final Context context, String orgName, int teamId, String repo) {
|
||||
|
||||
Call<Void> call = RetrofitClient.getApiInterface(context).orgRemoveTeamRepository((long) teamId, orgName, repo);
|
||||
Call<Void> call =
|
||||
RetrofitClient.getApiInterface(context)
|
||||
.orgRemoveTeamRepository((long) teamId, orgName, repo);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if (response.isSuccessful()) {
|
||||
|
||||
if(response.code() == 204) {
|
||||
if (response.code() == 204) {
|
||||
|
||||
OrganizationTeamInfoReposFragment.repoAdded = true;
|
||||
Toasty.success(context, context.getString(R.string.repoRemovedMessage));
|
||||
((AddNewTeamRepoActivity) context).finish();
|
||||
OrganizationTeamInfoReposFragment.repoAdded = true;
|
||||
Toasty.success(
|
||||
context, context.getString(R.string.repoRemovedMessage));
|
||||
((AddNewTeamRepoActivity) context).finish();
|
||||
}
|
||||
|
||||
} else if (response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(context);
|
||||
} else if (response.code() == 403) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
} else if (response.code() == 404) {
|
||||
|
||||
Toasty.warning(context, context.getString(R.string.apiNotFound));
|
||||
} else {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(context);
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
|
||||
Toasty.warning(context, context.getString(R.string.apiNotFound));
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(context, context.getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
Toasty.error(
|
||||
context,
|
||||
context.getResources()
|
||||
.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void addTeamRepo(final Context context, String orgName, int teamId, String repo) {
|
||||
|
||||
Call<Void> call = RetrofitClient.getApiInterface(context).orgAddTeamRepository((long) teamId, orgName, repo);
|
||||
Call<Void> call =
|
||||
RetrofitClient.getApiInterface(context)
|
||||
.orgAddTeamRepository((long) teamId, orgName, repo);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if (response.isSuccessful()) {
|
||||
|
||||
if(response.code() == 204) {
|
||||
if (response.code() == 204) {
|
||||
|
||||
OrganizationTeamInfoReposFragment.repoAdded = true;
|
||||
Toasty.success(context, context.getString(R.string.repoAddedMessage));
|
||||
((AddNewTeamRepoActivity) context).finish();
|
||||
OrganizationTeamInfoReposFragment.repoAdded = true;
|
||||
Toasty.success(
|
||||
context, context.getString(R.string.repoAddedMessage));
|
||||
((AddNewTeamRepoActivity) context).finish();
|
||||
}
|
||||
} else if (response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(context);
|
||||
} else if (response.code() == 403) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
} else if (response.code() == 404) {
|
||||
|
||||
Toasty.warning(context, context.getString(R.string.apiNotFound));
|
||||
} else {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(context);
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
|
||||
Toasty.warning(context, context.getString(R.string.apiNotFound));
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(context, context.getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
Toasty.error(
|
||||
context,
|
||||
context.getResources()
|
||||
.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@ import android.view.inputmethod.EditorInfo;
|
|||
import android.view.inputmethod.InputMethodManager;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import org.gitnex.tea4j.v2.models.InlineResponse2001;
|
||||
import org.gitnex.tea4j.v2.models.User;
|
||||
import org.mian.gitnex.R;
|
||||
|
@ -15,8 +17,6 @@ import org.mian.gitnex.clients.RetrofitClient;
|
|||
import org.mian.gitnex.databinding.ActivityAddCollaboratorToRepositoryBinding;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
@ -24,7 +24,6 @@ import retrofit2.Response;
|
|||
/**
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class AddCollaboratorToRepositoryActivity extends BaseActivity {
|
||||
|
||||
private ActivityAddCollaboratorToRepositoryBinding activityAddCollaboratorToRepositoryBinding;
|
||||
|
@ -36,79 +35,98 @@ public class AddCollaboratorToRepositoryActivity extends BaseActivity {
|
|||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
activityAddCollaboratorToRepositoryBinding = ActivityAddCollaboratorToRepositoryBinding.inflate(getLayoutInflater());
|
||||
activityAddCollaboratorToRepositoryBinding =
|
||||
ActivityAddCollaboratorToRepositoryBinding.inflate(getLayoutInflater());
|
||||
setContentView(activityAddCollaboratorToRepositoryBinding.getRoot());
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
InputMethodManager imm =
|
||||
(InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
repository = RepositoryContext.fromIntent(getIntent());
|
||||
|
||||
activityAddCollaboratorToRepositoryBinding.addCollaboratorSearch.requestFocus();
|
||||
assert imm != null;
|
||||
imm.showSoftInput(activityAddCollaboratorToRepositoryBinding.addCollaboratorSearch, InputMethodManager.SHOW_IMPLICIT);
|
||||
imm.showSoftInput(
|
||||
activityAddCollaboratorToRepositoryBinding.addCollaboratorSearch,
|
||||
InputMethodManager.SHOW_IMPLICIT);
|
||||
|
||||
initCloseListener();
|
||||
activityAddCollaboratorToRepositoryBinding.close.setOnClickListener(onClickListener);
|
||||
|
||||
activityAddCollaboratorToRepositoryBinding.addCollaboratorSearch.setOnEditorActionListener((v, actionId, event) -> {
|
||||
activityAddCollaboratorToRepositoryBinding.addCollaboratorSearch.setOnEditorActionListener(
|
||||
(v, actionId, event) -> {
|
||||
if (actionId == EditorInfo.IME_ACTION_SEND) {
|
||||
|
||||
if(actionId == EditorInfo.IME_ACTION_SEND) {
|
||||
if (!Objects.requireNonNull(
|
||||
activityAddCollaboratorToRepositoryBinding
|
||||
.addCollaboratorSearch.getText())
|
||||
.toString()
|
||||
.equals("")) {
|
||||
|
||||
if(!Objects.requireNonNull(activityAddCollaboratorToRepositoryBinding.addCollaboratorSearch.getText()).toString().equals("")) {
|
||||
activityAddCollaboratorToRepositoryBinding.progressBar.setVisibility(
|
||||
View.VISIBLE);
|
||||
loadUserSearchList(
|
||||
activityAddCollaboratorToRepositoryBinding
|
||||
.addCollaboratorSearch
|
||||
.getText()
|
||||
.toString());
|
||||
}
|
||||
}
|
||||
|
||||
activityAddCollaboratorToRepositoryBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
loadUserSearchList(activityAddCollaboratorToRepositoryBinding.addCollaboratorSearch.getText().toString());
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
public void loadUserSearchList(String searchKeyword) {
|
||||
|
||||
Call<InlineResponse2001> call = RetrofitClient.getApiInterface(ctx).userSearch(searchKeyword, null, 1, 10);
|
||||
Call<InlineResponse2001> call =
|
||||
RetrofitClient.getApiInterface(ctx).userSearch(searchKeyword, null, 1, 10);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<InlineResponse2001> call, @NonNull Response<InlineResponse2001> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<InlineResponse2001> call,
|
||||
@NonNull Response<InlineResponse2001> response) {
|
||||
|
||||
activityAddCollaboratorToRepositoryBinding.progressBar.setVisibility(View.GONE);
|
||||
activityAddCollaboratorToRepositoryBinding.progressBar.setVisibility(
|
||||
View.GONE);
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if (response.isSuccessful()) {
|
||||
|
||||
assert response.body() != null;
|
||||
getUsersList(response.body().getData(), ctx);
|
||||
}
|
||||
else {
|
||||
assert response.body() != null;
|
||||
getUsersList(response.body().getData(), ctx);
|
||||
} else {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<InlineResponse2001> call, @NonNull Throwable t) {
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onFailure(
|
||||
@NonNull Call<InlineResponse2001> call, @NonNull Throwable t) {
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void getUsersList(List<User> dataList, Context context) {
|
||||
|
||||
CollaboratorSearchAdapter adapter = new CollaboratorSearchAdapter(dataList, context, repository);
|
||||
CollaboratorSearchAdapter adapter =
|
||||
new CollaboratorSearchAdapter(dataList, context, repository);
|
||||
|
||||
activityAddCollaboratorToRepositoryBinding.recyclerViewUserSearch.setHasFixedSize(true);
|
||||
activityAddCollaboratorToRepositoryBinding.recyclerViewUserSearch.setLayoutManager(new LinearLayoutManager(ctx));
|
||||
activityAddCollaboratorToRepositoryBinding.recyclerViewUserSearch.setLayoutManager(
|
||||
new LinearLayoutManager(ctx));
|
||||
|
||||
activityAddCollaboratorToRepositoryBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
|
||||
if(adapter.getItemCount() > 0) {
|
||||
if (adapter.getItemCount() > 0) {
|
||||
|
||||
activityAddCollaboratorToRepositoryBinding.recyclerViewUserSearch.setAdapter(adapter);
|
||||
activityAddCollaboratorToRepositoryBinding.noData.setVisibility(View.GONE);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
activityAddCollaboratorToRepositoryBinding.noData.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
@ -125,5 +143,4 @@ public class AddCollaboratorToRepositoryActivity extends BaseActivity {
|
|||
super.onResume();
|
||||
repository.checkAccountSwitch(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,6 +8,9 @@ import android.view.View;
|
|||
import android.widget.ArrayAdapter;
|
||||
import androidx.annotation.NonNull;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import io.mikael.urlbuilder.UrlBuilder;
|
||||
import java.net.URI;
|
||||
import java.util.Objects;
|
||||
import org.gitnex.tea4j.v2.models.GeneralAPISettings;
|
||||
import org.gitnex.tea4j.v2.models.ServerVersion;
|
||||
import org.gitnex.tea4j.v2.models.User;
|
||||
|
@ -23,16 +26,12 @@ import org.mian.gitnex.helpers.Toasty;
|
|||
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
|
||||
*/
|
||||
|
||||
public class AddNewAccountActivity extends BaseActivity {
|
||||
|
||||
private View.OnClickListener onClickListener;
|
||||
|
@ -58,235 +57,292 @@ public class AddNewAccountActivity extends BaseActivity {
|
|||
viewBinding.instanceUrl.setText(getIntent().getStringExtra("instanceUrl"));
|
||||
viewBinding.loginToken.setText(getIntent().getStringExtra("token"));
|
||||
String scheme = getIntent().getStringExtra("scheme");
|
||||
if(scheme != null && scheme.equals("http")) {
|
||||
if (scheme != null && scheme.equals("http")) {
|
||||
viewBinding.protocolSpinner.setText(Protocol.HTTP.toString());
|
||||
spinnerSelectedValue = Protocol.HTTP.toString();
|
||||
}
|
||||
else { // default is https
|
||||
} else { // default is https
|
||||
viewBinding.protocolSpinner.setText(Protocol.HTTPS.toString());
|
||||
spinnerSelectedValue = Protocol.HTTPS.toString();
|
||||
}
|
||||
|
||||
ArrayAdapter<Protocol> adapterProtocols = new ArrayAdapter<>(ctx, R.layout.list_spinner_items, Protocol.values());
|
||||
ArrayAdapter<Protocol> adapterProtocols =
|
||||
new ArrayAdapter<>(ctx, R.layout.list_spinner_items, Protocol.values());
|
||||
|
||||
viewBinding.protocolSpinner.setAdapter(adapterProtocols);
|
||||
viewBinding.protocolSpinner.setOnItemClickListener((parent, view1, position, id) -> spinnerSelectedValue = String.valueOf(parent.getItemAtPosition(position)));
|
||||
viewBinding.addNewAccount.setOnClickListener(login -> {
|
||||
viewBinding.protocolSpinner.setOnItemClickListener(
|
||||
(parent, view1, position, id) ->
|
||||
spinnerSelectedValue = String.valueOf(parent.getItemAtPosition(position)));
|
||||
viewBinding.addNewAccount.setOnClickListener(
|
||||
login -> {
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
if (!connToInternet) {
|
||||
|
||||
if(!connToInternet) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
}
|
||||
else {
|
||||
|
||||
processLogin();
|
||||
}
|
||||
});
|
||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
} else {
|
||||
|
||||
processLogin();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void processLogin() {
|
||||
|
||||
try {
|
||||
|
||||
String instanceUrlET = String.valueOf(viewBinding.instanceUrl.getText()).replaceAll("[\\uFEFF|#]", "").trim();
|
||||
String loginToken = String.valueOf(viewBinding.loginToken.getText()).replaceAll("[\\uFEFF|#]", "").trim();
|
||||
String instanceUrlET =
|
||||
String.valueOf(viewBinding.instanceUrl.getText())
|
||||
.replaceAll("[\\uFEFF|#]", "")
|
||||
.trim();
|
||||
String loginToken =
|
||||
String.valueOf(viewBinding.loginToken.getText())
|
||||
.replaceAll("[\\uFEFF|#]", "")
|
||||
.trim();
|
||||
String protocol = spinnerSelectedValue;
|
||||
|
||||
if(protocol == null) {
|
||||
if (protocol == null) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.protocolEmptyError));
|
||||
return;
|
||||
}
|
||||
|
||||
if(instanceUrlET.equals("")) {
|
||||
if (instanceUrlET.equals("")) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.emptyFieldURL));
|
||||
return;
|
||||
}
|
||||
|
||||
if(loginToken.equals("")) {
|
||||
if (loginToken.equals("")) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.loginTokenError));
|
||||
return;
|
||||
}
|
||||
|
||||
URI rawInstanceUrl = UrlBuilder.fromString(UrlHelper.fixScheme(instanceUrlET, "http")).toUri();
|
||||
URI rawInstanceUrl =
|
||||
UrlBuilder.fromString(UrlHelper.fixScheme(instanceUrlET, "http")).toUri();
|
||||
|
||||
URI instanceUrl = UrlBuilder.fromUri(rawInstanceUrl).withScheme(protocol.toLowerCase()).withPath(PathsHelper.join(rawInstanceUrl.getPath(), "/api/v1/")).toUri();
|
||||
URI instanceUrl =
|
||||
UrlBuilder.fromUri(rawInstanceUrl)
|
||||
.withScheme(protocol.toLowerCase())
|
||||
.withPath(PathsHelper.join(rawInstanceUrl.getPath(), "/api/v1/"))
|
||||
.toUri();
|
||||
|
||||
versionCheck(instanceUrl.toString(), loginToken);
|
||||
serverPageLimitSettings();
|
||||
|
||||
}
|
||||
catch(Exception e) {
|
||||
} catch (Exception e) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.malformedUrl));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void versionCheck(final String instanceUrl, final String loginToken) {
|
||||
|
||||
Call<ServerVersion> callVersion = RetrofitClient.getApiInterface(ctx, instanceUrl, "token " + loginToken, null).getVersion();
|
||||
callVersion.enqueue(new Callback<>() {
|
||||
Call<ServerVersion> callVersion =
|
||||
RetrofitClient.getApiInterface(ctx, instanceUrl, "token " + loginToken, null)
|
||||
.getVersion();
|
||||
callVersion.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull final Call<ServerVersion> callVersion, @NonNull retrofit2.Response<ServerVersion> responseVersion) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull final Call<ServerVersion> callVersion,
|
||||
@NonNull retrofit2.Response<ServerVersion> responseVersion) {
|
||||
|
||||
if(responseVersion.code() == 200) {
|
||||
if (responseVersion.code() == 200) {
|
||||
|
||||
ServerVersion version = responseVersion.body();
|
||||
ServerVersion version = responseVersion.body();
|
||||
|
||||
assert version != null;
|
||||
assert version != null;
|
||||
|
||||
if(!Version.valid(version.getVersion())) {
|
||||
if (!Version.valid(version.getVersion())) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.versionUnknown));
|
||||
return;
|
||||
}
|
||||
Toasty.error(
|
||||
ctx, getResources().getString(R.string.versionUnknown));
|
||||
return;
|
||||
}
|
||||
|
||||
giteaVersion = new Version(version.getVersion());
|
||||
giteaVersion = new Version(version.getVersion());
|
||||
|
||||
if(giteaVersion.less(getString(R.string.versionLow))) {
|
||||
if (giteaVersion.less(getString(R.string.versionLow))) {
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx).setTitle(getString(R.string.versionAlertDialogHeader))
|
||||
.setMessage(getResources().getString(R.string.versionUnsupportedOld, version.getVersion())).setNeutralButton(getString(R.string.cancelButton), null)
|
||||
.setPositiveButton(getString(R.string.textContinue), (dialog, which) -> {
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder =
|
||||
new MaterialAlertDialogBuilder(ctx)
|
||||
.setTitle(
|
||||
getString(
|
||||
R.string.versionAlertDialogHeader))
|
||||
.setMessage(
|
||||
getResources()
|
||||
.getString(
|
||||
R.string
|
||||
.versionUnsupportedOld,
|
||||
version.getVersion()))
|
||||
.setNeutralButton(
|
||||
getString(R.string.cancelButton), null)
|
||||
.setPositiveButton(
|
||||
getString(R.string.textContinue),
|
||||
(dialog, which) -> {
|
||||
dialog.dismiss();
|
||||
login(instanceUrl, loginToken);
|
||||
});
|
||||
|
||||
materialAlertDialogBuilder.create().show();
|
||||
} else if (giteaVersion.lessOrEqual(getString(R.string.versionHigh))) {
|
||||
|
||||
dialog.dismiss();
|
||||
login(instanceUrl, loginToken);
|
||||
});
|
||||
} else {
|
||||
|
||||
materialAlertDialogBuilder.create().show();
|
||||
}
|
||||
else if(giteaVersion.lessOrEqual(getString(R.string.versionHigh))) {
|
||||
Toasty.warning(
|
||||
ctx,
|
||||
getResources().getString(R.string.versionUnsupportedNew));
|
||||
login(instanceUrl, loginToken);
|
||||
}
|
||||
|
||||
login(instanceUrl, loginToken);
|
||||
}
|
||||
else {
|
||||
} else if (responseVersion.code() == 403) {
|
||||
|
||||
Toasty.warning(ctx, getResources().getString(R.string.versionUnsupportedNew));
|
||||
login(instanceUrl, loginToken);
|
||||
login(instanceUrl, loginToken);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if(responseVersion.code() == 403) {
|
||||
private void login(String instanceUrl, String loginToken) {
|
||||
|
||||
login(instanceUrl, loginToken);
|
||||
}
|
||||
}
|
||||
setupNewAccountWithToken(instanceUrl, loginToken);
|
||||
}
|
||||
|
||||
private void login(String instanceUrl, String loginToken) {
|
||||
@Override
|
||||
public void onFailure(
|
||||
@NonNull Call<ServerVersion> callVersion, @NonNull Throwable t) {
|
||||
|
||||
setupNewAccountWithToken(instanceUrl, loginToken);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<ServerVersion> callVersion, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure-versionCheck", t.toString());
|
||||
Toasty.error(ctx, getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
Log.e("onFailure-versionCheck", t.toString());
|
||||
Toasty.error(
|
||||
ctx, getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void serverPageLimitSettings() {
|
||||
|
||||
Call<GeneralAPISettings> generalAPISettings = RetrofitClient.getApiInterface(ctx).getGeneralAPISettings();
|
||||
generalAPISettings.enqueue(new Callback<>() {
|
||||
Call<GeneralAPISettings> generalAPISettings =
|
||||
RetrofitClient.getApiInterface(ctx).getGeneralAPISettings();
|
||||
generalAPISettings.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull final Call<GeneralAPISettings> generalAPISettings, @NonNull retrofit2.Response<GeneralAPISettings> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull final Call<GeneralAPISettings> generalAPISettings,
|
||||
@NonNull retrofit2.Response<GeneralAPISettings> response) {
|
||||
|
||||
if(response.code() == 200 && response.body() != null) {
|
||||
if (response.code() == 200 && response.body() != null) {
|
||||
|
||||
if(response.body().getMaxResponseItems() != null) {
|
||||
maxResponseItems = Math.toIntExact(response.body().getMaxResponseItems());
|
||||
if (response.body().getMaxResponseItems() != null) {
|
||||
maxResponseItems =
|
||||
Math.toIntExact(response.body().getMaxResponseItems());
|
||||
}
|
||||
if (response.body().getDefaultPagingNum() != null) {
|
||||
defaultPagingNumber =
|
||||
Math.toIntExact(response.body().getDefaultPagingNum());
|
||||
}
|
||||
}
|
||||
}
|
||||
if(response.body().getDefaultPagingNum() != null) {
|
||||
defaultPagingNumber = Math.toIntExact(response.body().getDefaultPagingNum());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<GeneralAPISettings> generalAPISettings, @NonNull Throwable t) {
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onFailure(
|
||||
@NonNull Call<GeneralAPISettings> generalAPISettings,
|
||||
@NonNull Throwable t) {}
|
||||
});
|
||||
}
|
||||
|
||||
private void setupNewAccountWithToken(String instanceUrl, final String loginToken) {
|
||||
|
||||
Call<User> call = RetrofitClient.getApiInterface(ctx, instanceUrl, "token " + loginToken, null).userGetCurrent();
|
||||
Call<User> call =
|
||||
RetrofitClient.getApiInterface(ctx, instanceUrl, "token " + loginToken, null)
|
||||
.userGetCurrent();
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<User> call, @NonNull retrofit2.Response<User> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<User> call, @NonNull retrofit2.Response<User> response) {
|
||||
|
||||
User userDetails = response.body();
|
||||
User userDetails = response.body();
|
||||
|
||||
switch(response.code()) {
|
||||
switch (response.code()) {
|
||||
case 200:
|
||||
assert userDetails != null;
|
||||
// insert new account to db if does not exist
|
||||
String accountName = userDetails.getLogin() + "@" + instanceUrl;
|
||||
UserAccountsApi userAccountsApi =
|
||||
BaseApi.getInstance(ctx, UserAccountsApi.class);
|
||||
boolean userAccountExists =
|
||||
Objects.requireNonNull(userAccountsApi)
|
||||
.userAccountExists(accountName);
|
||||
|
||||
case 200:
|
||||
if (!userAccountExists) {
|
||||
|
||||
assert userDetails != null;
|
||||
// insert new account to db if does not exist
|
||||
String accountName = userDetails.getLogin() + "@" + instanceUrl;
|
||||
UserAccountsApi userAccountsApi = BaseApi.getInstance(ctx, UserAccountsApi.class);
|
||||
boolean userAccountExists = Objects.requireNonNull(userAccountsApi).userAccountExists(accountName);
|
||||
long id =
|
||||
userAccountsApi.createNewAccount(
|
||||
accountName,
|
||||
instanceUrl,
|
||||
userDetails.getLogin(),
|
||||
loginToken,
|
||||
giteaVersion.toString(),
|
||||
maxResponseItems,
|
||||
defaultPagingNumber);
|
||||
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 {
|
||||
userAccountsApi.updateTokenByAccountName(
|
||||
accountName, loginToken);
|
||||
userAccountsApi.login(account.getAccountId());
|
||||
AppUtil.switchToAccount(
|
||||
AddNewAccountActivity.this, account);
|
||||
}
|
||||
}
|
||||
finish();
|
||||
break;
|
||||
|
||||
if(!userAccountExists) {
|
||||
case 401:
|
||||
Toasty.error(
|
||||
ctx,
|
||||
getResources().getString(R.string.unauthorizedApiError));
|
||||
break;
|
||||
|
||||
long id = userAccountsApi.createNewAccount(accountName, instanceUrl, userDetails.getLogin(), loginToken, giteaVersion.toString(), maxResponseItems, defaultPagingNumber);
|
||||
UserAccount account = userAccountsApi.getAccountById((int) id);
|
||||
AppUtil.switchToAccount(AddNewAccountActivity.this, account);
|
||||
Toasty.success(ctx, getResources().getString(R.string.accountAddedMessage));
|
||||
MainActivity.refActivity = true;
|
||||
finish();
|
||||
default:
|
||||
Toasty.error(
|
||||
ctx,
|
||||
getResources()
|
||||
.getString(
|
||||
R.string.genericApiError, response.code()));
|
||||
}
|
||||
else {
|
||||
UserAccount account = userAccountsApi.getAccountByName(accountName);
|
||||
if(account.isLoggedIn()) {
|
||||
Toasty.warning(ctx, getResources().getString(R.string.accountAlreadyExistsError));
|
||||
AppUtil.switchToAccount(ctx, account);
|
||||
}
|
||||
else {
|
||||
userAccountsApi.updateTokenByAccountName(accountName, loginToken);
|
||||
userAccountsApi.login(account.getAccountId());
|
||||
AppUtil.switchToAccount(AddNewAccountActivity.this, account);
|
||||
}
|
||||
}
|
||||
finish();
|
||||
break;
|
||||
}
|
||||
|
||||
case 401:
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.unauthorizedApiError));
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.genericApiError, response.code()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<User> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.genericError));
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<User> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.genericError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initCloseListener() {
|
||||
|
||||
onClickListener = view -> finish();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,13 +13,13 @@ import android.widget.TextView;
|
|||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.gitnex.tea4j.v2.models.InlineResponse2001;
|
||||
import org.gitnex.tea4j.v2.models.User;
|
||||
import org.mian.gitnex.adapters.OrganizationAddUserToTeamMemberAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.ActivityAddNewTeamMemberBinding;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
@ -27,7 +27,6 @@ import retrofit2.Response;
|
|||
/**
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class AddNewTeamMemberActivity extends BaseActivity {
|
||||
|
||||
private View.OnClickListener onClickListener;
|
||||
|
@ -46,10 +45,12 @@ public class AddNewTeamMemberActivity extends BaseActivity {
|
|||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
ActivityAddNewTeamMemberBinding activityAddNewTeamMemberBinding = ActivityAddNewTeamMemberBinding.inflate(getLayoutInflater());
|
||||
ActivityAddNewTeamMemberBinding activityAddNewTeamMemberBinding =
|
||||
ActivityAddNewTeamMemberBinding.inflate(getLayoutInflater());
|
||||
setContentView(activityAddNewTeamMemberBinding.getRoot());
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
InputMethodManager imm =
|
||||
(InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
ImageView closeActivity = activityAddNewTeamMemberBinding.close;
|
||||
addNewTeamMember = activityAddNewTeamMemberBinding.addNewTeamMember;
|
||||
|
@ -71,72 +72,77 @@ public class AddNewTeamMemberActivity extends BaseActivity {
|
|||
|
||||
dataList = new ArrayList<>();
|
||||
|
||||
addNewTeamMember.addTextChangedListener(new TextWatcher() {
|
||||
addNewTeamMember.addTextChangedListener(
|
||||
new TextWatcher() {
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
|
||||
if(!addNewTeamMember.getText().toString().equals("") && addNewTeamMember.getText().toString().length() > 1) {
|
||||
if (!addNewTeamMember.getText().toString().equals("")
|
||||
&& addNewTeamMember.getText().toString().length() > 1) {
|
||||
|
||||
adapter = new OrganizationAddUserToTeamMemberAdapter(dataList, ctx, Math.toIntExact(teamId), getIntent().getStringExtra("orgName"));
|
||||
loadUserSearchList(addNewTeamMember.getText().toString());
|
||||
}
|
||||
}
|
||||
adapter =
|
||||
new OrganizationAddUserToTeamMemberAdapter(
|
||||
dataList,
|
||||
ctx,
|
||||
Math.toIntExact(teamId),
|
||||
getIntent().getStringExtra("orgName"));
|
||||
loadUserSearchList(addNewTeamMember.getText().toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
}
|
||||
|
||||
});
|
||||
@Override
|
||||
public void beforeTextChanged(
|
||||
CharSequence s, int start, int count, int after) {}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {}
|
||||
});
|
||||
}
|
||||
|
||||
public void loadUserSearchList(String searchKeyword) {
|
||||
|
||||
Call<InlineResponse2001> call = RetrofitClient.getApiInterface(ctx).userSearch(searchKeyword, null, 1, 10);
|
||||
Call<InlineResponse2001> call =
|
||||
RetrofitClient.getApiInterface(ctx).userSearch(searchKeyword, null, 1, 10);
|
||||
|
||||
mProgressBar.setVisibility(View.VISIBLE);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<InlineResponse2001> call, @NonNull Response<InlineResponse2001> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<InlineResponse2001> call,
|
||||
@NonNull Response<InlineResponse2001> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if (response.isSuccessful()) {
|
||||
|
||||
assert response.body() != null;
|
||||
if(response.body().getData().size() > 0) {
|
||||
assert response.body() != null;
|
||||
if (response.body().getData().size() > 0) {
|
||||
|
||||
dataList.clear();
|
||||
dataList.addAll(response.body().getData());
|
||||
mRecyclerView.setAdapter(adapter);
|
||||
noData.setVisibility(View.GONE);
|
||||
}
|
||||
else {
|
||||
dataList.clear();
|
||||
dataList.addAll(response.body().getData());
|
||||
mRecyclerView.setAdapter(adapter);
|
||||
noData.setVisibility(View.GONE);
|
||||
} else {
|
||||
|
||||
noData.setVisibility(View.VISIBLE);
|
||||
noData.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
}
|
||||
@Override
|
||||
public void onFailure(
|
||||
@NonNull Call<InlineResponse2001> call, @NonNull Throwable t) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<InlineResponse2001> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
}
|
||||
|
||||
});
|
||||
Log.e("onFailure", t.toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initCloseListener() {
|
||||
onClickListener = view -> finish();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@ import android.os.Bundle;
|
|||
import android.view.View;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.gitnex.tea4j.v2.models.Repository;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.OrganizationTeamRepositoriesAdapter;
|
||||
|
@ -11,8 +13,6 @@ import org.mian.gitnex.clients.RetrofitClient;
|
|||
import org.mian.gitnex.databinding.AddNewTeamRepositoryBinding;
|
||||
import org.mian.gitnex.helpers.Constants;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
@ -20,7 +20,6 @@ import retrofit2.Response;
|
|||
/**
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class AddNewTeamRepoActivity extends BaseActivity {
|
||||
|
||||
private AddNewTeamRepositoryBinding addNewTeamRepositoryBinding;
|
||||
|
@ -48,7 +47,8 @@ public class AddNewTeamRepoActivity extends BaseActivity {
|
|||
teamName = getIntent().getStringExtra("teamName");
|
||||
|
||||
addNewTeamRepositoryBinding.recyclerViewTeamRepos.setHasFixedSize(true);
|
||||
addNewTeamRepositoryBinding.recyclerViewTeamRepos.setLayoutManager(new LinearLayoutManager(ctx));
|
||||
addNewTeamRepositoryBinding.recyclerViewTeamRepos.setLayoutManager(
|
||||
new LinearLayoutManager(ctx));
|
||||
|
||||
dataList = new ArrayList<>();
|
||||
|
||||
|
@ -57,49 +57,59 @@ public class AddNewTeamRepoActivity extends BaseActivity {
|
|||
|
||||
public void loadRepos() {
|
||||
|
||||
Call<List<Repository>> call = RetrofitClient.getApiInterface(ctx).orgListRepos(getIntent().getStringExtra("orgName"), 1, resultLimit);
|
||||
Call<List<Repository>> call =
|
||||
RetrofitClient.getApiInterface(ctx)
|
||||
.orgListRepos(getIntent().getStringExtra("orgName"), 1, resultLimit);
|
||||
|
||||
addNewTeamRepositoryBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Repository>> call, @NonNull Response<List<Repository>> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<List<Repository>> call,
|
||||
@NonNull Response<List<Repository>> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if (response.isSuccessful()) {
|
||||
|
||||
assert response.body() != null;
|
||||
if(response.body().size() > 0) {
|
||||
assert response.body() != null;
|
||||
if (response.body().size() > 0) {
|
||||
|
||||
dataList.clear();
|
||||
dataList.addAll(response.body());
|
||||
dataList.clear();
|
||||
dataList.addAll(response.body());
|
||||
|
||||
adapter = new OrganizationTeamRepositoriesAdapter(dataList, ctx, Math.toIntExact(teamId), getIntent().getStringExtra("orgName"), teamName);
|
||||
adapter =
|
||||
new OrganizationTeamRepositoriesAdapter(
|
||||
dataList,
|
||||
ctx,
|
||||
Math.toIntExact(teamId),
|
||||
getIntent().getStringExtra("orgName"),
|
||||
teamName);
|
||||
|
||||
addNewTeamRepositoryBinding.recyclerViewTeamRepos.setAdapter(adapter);
|
||||
addNewTeamRepositoryBinding.noData.setVisibility(View.GONE);
|
||||
}
|
||||
else {
|
||||
addNewTeamRepositoryBinding.recyclerViewTeamRepos.setAdapter(
|
||||
adapter);
|
||||
addNewTeamRepositoryBinding.noData.setVisibility(View.GONE);
|
||||
} else {
|
||||
|
||||
addNewTeamRepositoryBinding.noData.setVisibility(View.VISIBLE);
|
||||
addNewTeamRepositoryBinding.noData.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
addNewTeamRepositoryBinding.progressBar.setVisibility(View.GONE);
|
||||
} else {
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
addNewTeamRepositoryBinding.progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
else {
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Repository>> call, @NonNull Throwable t) {
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onFailure(
|
||||
@NonNull Call<List<Repository>> call, @NonNull Throwable t) {
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initCloseListener() {
|
||||
onClickListener = view -> finish();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ import org.mian.gitnex.viewmodels.AdminCronTasksViewModel;
|
|||
/**
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class AdminCronTasksActivity extends BaseActivity {
|
||||
|
||||
private AdminCronTasksViewModel adminCronTasksViewModel;
|
||||
|
@ -47,36 +46,43 @@ public class AdminCronTasksActivity extends BaseActivity {
|
|||
activityAdminCronTasksBinding.recyclerView.setHasFixedSize(true);
|
||||
activityAdminCronTasksBinding.recyclerView.setLayoutManager(new LinearLayoutManager(ctx));
|
||||
|
||||
activityAdminCronTasksBinding.pullToRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
|
||||
activityAdminCronTasksBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
activityAdminCronTasksBinding.pullToRefresh.setRefreshing(false);
|
||||
adminCronTasksViewModel.loadCronTasksList(ctx, PAGE, resultLimit);
|
||||
|
||||
}, 500));
|
||||
activityAdminCronTasksBinding.pullToRefresh.setOnRefreshListener(
|
||||
() ->
|
||||
new Handler(Looper.getMainLooper())
|
||||
.postDelayed(
|
||||
() -> {
|
||||
activityAdminCronTasksBinding.progressBar.setVisibility(
|
||||
View.VISIBLE);
|
||||
activityAdminCronTasksBinding.pullToRefresh
|
||||
.setRefreshing(false);
|
||||
adminCronTasksViewModel.loadCronTasksList(
|
||||
ctx, PAGE, resultLimit);
|
||||
},
|
||||
500));
|
||||
|
||||
fetchDataAsync(ctx);
|
||||
}
|
||||
|
||||
private void fetchDataAsync(Context ctx) {
|
||||
|
||||
adminCronTasksViewModel.getCronTasksList(ctx, PAGE, resultLimit).observe(this, cronTasksListMain -> {
|
||||
adminCronTasksViewModel
|
||||
.getCronTasksList(ctx, PAGE, resultLimit)
|
||||
.observe(
|
||||
this,
|
||||
cronTasksListMain -> {
|
||||
adapter = new AdminCronTasksAdapter(cronTasksListMain);
|
||||
|
||||
adapter = new AdminCronTasksAdapter(cronTasksListMain);
|
||||
|
||||
if(adapter.getItemCount() > 0) {
|
||||
activityAdminCronTasksBinding.recyclerView.setAdapter(adapter);
|
||||
activityAdminCronTasksBinding.noData.setVisibility(View.GONE);
|
||||
activityAdminCronTasksBinding.progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
else {
|
||||
activityAdminCronTasksBinding.noData.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
if (adapter.getItemCount() > 0) {
|
||||
activityAdminCronTasksBinding.recyclerView.setAdapter(adapter);
|
||||
activityAdminCronTasksBinding.noData.setVisibility(View.GONE);
|
||||
activityAdminCronTasksBinding.progressBar.setVisibility(View.GONE);
|
||||
} else {
|
||||
activityAdminCronTasksBinding.noData.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initCloseListener() {
|
||||
onClickListener = view -> finish();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@ import org.mian.gitnex.viewmodels.AdminGetUsersViewModel;
|
|||
/**
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class AdminGetUsersActivity extends BaseActivity implements BottomSheetListener {
|
||||
|
||||
private AdminGetUsersViewModel adminGetUsersViewModel;
|
||||
|
@ -55,56 +54,69 @@ public class AdminGetUsersActivity extends BaseActivity implements BottomSheetLi
|
|||
activityAdminGetUsersBinding.recyclerView.setHasFixedSize(true);
|
||||
activityAdminGetUsersBinding.recyclerView.setLayoutManager(new LinearLayoutManager(ctx));
|
||||
|
||||
activityAdminGetUsersBinding.pullToRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
|
||||
page = 1;
|
||||
activityAdminGetUsersBinding.pullToRefresh.setRefreshing(false);
|
||||
fetchDataAsync();
|
||||
activityAdminGetUsersBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
}, 50));
|
||||
activityAdminGetUsersBinding.pullToRefresh.setOnRefreshListener(
|
||||
() ->
|
||||
new Handler(Looper.getMainLooper())
|
||||
.postDelayed(
|
||||
() -> {
|
||||
page = 1;
|
||||
activityAdminGetUsersBinding.pullToRefresh
|
||||
.setRefreshing(false);
|
||||
fetchDataAsync();
|
||||
activityAdminGetUsersBinding.progressBar.setVisibility(
|
||||
View.VISIBLE);
|
||||
},
|
||||
50));
|
||||
|
||||
fetchDataAsync();
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
private void fetchDataAsync() {
|
||||
|
||||
AdminGetUsersViewModel adminUsersModel = new ViewModelProvider(this).get(AdminGetUsersViewModel.class);
|
||||
AdminGetUsersViewModel adminUsersModel =
|
||||
new ViewModelProvider(this).get(AdminGetUsersViewModel.class);
|
||||
|
||||
adminUsersModel.getUsersList(page, resultLimit, ctx).observe(this, adminUsersListMain -> {
|
||||
adminUsersModel
|
||||
.getUsersList(page, resultLimit, ctx)
|
||||
.observe(
|
||||
this,
|
||||
adminUsersListMain -> {
|
||||
adapter = new AdminGetUsersAdapter(adminUsersListMain, ctx);
|
||||
adapter.setLoadMoreListener(
|
||||
new AdminGetUsersAdapter.OnLoadMoreListener() {
|
||||
|
||||
adapter = new AdminGetUsersAdapter(adminUsersListMain, ctx);
|
||||
adapter.setLoadMoreListener(new AdminGetUsersAdapter.OnLoadMoreListener() {
|
||||
@Override
|
||||
public void onLoadMore() {
|
||||
|
||||
@Override
|
||||
public void onLoadMore() {
|
||||
page += 1;
|
||||
adminGetUsersViewModel.loadMoreUsersList(
|
||||
page, resultLimit, ctx, adapter);
|
||||
activityAdminGetUsersBinding.progressBar.setVisibility(
|
||||
View.VISIBLE);
|
||||
}
|
||||
|
||||
page += 1;
|
||||
adminGetUsersViewModel.loadMoreUsersList(page, resultLimit, ctx, adapter);
|
||||
activityAdminGetUsersBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
}
|
||||
@Override
|
||||
public void onLoadFinished() {
|
||||
|
||||
@Override
|
||||
public void onLoadFinished() {
|
||||
activityAdminGetUsersBinding.progressBar.setVisibility(
|
||||
View.GONE);
|
||||
}
|
||||
});
|
||||
|
||||
activityAdminGetUsersBinding.progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
if (adapter.getItemCount() > 0) {
|
||||
activityAdminGetUsersBinding.recyclerView.setAdapter(adapter);
|
||||
activityAdminGetUsersBinding.noDataUsers.setVisibility(View.GONE);
|
||||
searchFilter = true;
|
||||
} else {
|
||||
adapter.notifyDataChanged();
|
||||
activityAdminGetUsersBinding.recyclerView.setAdapter(adapter);
|
||||
activityAdminGetUsersBinding.noDataUsers.setVisibility(
|
||||
View.VISIBLE);
|
||||
}
|
||||
|
||||
if(adapter.getItemCount() > 0) {
|
||||
activityAdminGetUsersBinding.recyclerView.setAdapter(adapter);
|
||||
activityAdminGetUsersBinding.noDataUsers.setVisibility(View.GONE);
|
||||
searchFilter = true;
|
||||
}
|
||||
else {
|
||||
adapter.notifyDataChanged();
|
||||
activityAdminGetUsersBinding.recyclerView.setAdapter(adapter);
|
||||
activityAdminGetUsersBinding.noDataUsers.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
activityAdminGetUsersBinding.progressBar.setVisibility(View.GONE);
|
||||
});
|
||||
activityAdminGetUsersBinding.progressBar.setVisibility(View.GONE);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -113,38 +125,42 @@ public class AdminGetUsersActivity extends BaseActivity implements BottomSheetLi
|
|||
final MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.generic_nav_dotted_menu, menu);
|
||||
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
new Handler(Looper.getMainLooper())
|
||||
.postDelayed(
|
||||
() -> {
|
||||
if (searchFilter) {
|
||||
|
||||
if(searchFilter) {
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
inflater.inflate(R.menu.search_menu, menu);
|
||||
|
||||
inflater.inflate(R.menu.search_menu, menu);
|
||||
MenuItem searchItem = menu.findItem(R.id.action_search);
|
||||
SearchView searchView = (SearchView) searchItem.getActionView();
|
||||
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||
|
||||
MenuItem searchItem = menu.findItem(R.id.action_search);
|
||||
SearchView searchView = (SearchView) searchItem.getActionView();
|
||||
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||
if (!connToInternet) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!connToInternet) {
|
||||
return;
|
||||
}
|
||||
searchView.setOnQueryTextListener(
|
||||
new androidx.appcompat.widget.SearchView
|
||||
.OnQueryTextListener() {
|
||||
|
||||
searchView.setOnQueryTextListener(new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
|
||||
adapter.getFilter().filter(newText);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}, 500);
|
||||
adapter.getFilter().filter(newText);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
500);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -154,18 +170,16 @@ public class AdminGetUsersActivity extends BaseActivity implements BottomSheetLi
|
|||
|
||||
int id = item.getItemId();
|
||||
|
||||
if(id == android.R.id.home) {
|
||||
if (id == android.R.id.home) {
|
||||
|
||||
finish();
|
||||
return true;
|
||||
}
|
||||
else if(id == R.id.genericMenu) {
|
||||
} else if (id == R.id.genericMenu) {
|
||||
|
||||
BottomSheetAdminUsersFragment bottomSheet = new BottomSheetAdminUsersFragment();
|
||||
bottomSheet.show(getSupportFragmentManager(), "usersBottomSheet");
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
@ -174,7 +188,7 @@ public class AdminGetUsersActivity extends BaseActivity implements BottomSheetLi
|
|||
@Override
|
||||
public void onButtonClicked(String text) {
|
||||
|
||||
if("newUser".equals(text)) {
|
||||
if ("newUser".equals(text)) {
|
||||
startActivity(new Intent(AdminGetUsersActivity.this, CreateNewUserActivity.class));
|
||||
}
|
||||
}
|
||||
|
@ -182,5 +196,4 @@ public class AdminGetUsersActivity extends BaseActivity implements BottomSheetLi
|
|||
private void initCloseListener() {
|
||||
onClickListener = view -> finish();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,19 +8,18 @@ import android.view.View;
|
|||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.AdminUnadoptedReposAdapter;
|
||||
import org.mian.gitnex.databinding.ActivityAdminCronTasksBinding;
|
||||
import org.mian.gitnex.helpers.Constants;
|
||||
import org.mian.gitnex.viewmodels.AdminUnadoptedReposViewModel;
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
* @author M M Arif
|
||||
* @author qwerty287
|
||||
*/
|
||||
|
||||
public class AdminUnadoptedReposActivity extends BaseActivity {
|
||||
|
||||
private AdminUnadoptedReposViewModel viewModel;
|
||||
|
@ -54,26 +53,34 @@ public class AdminUnadoptedReposActivity extends BaseActivity {
|
|||
binding.recyclerView.setHasFixedSize(true);
|
||||
binding.recyclerView.setLayoutManager(new LinearLayoutManager(ctx));
|
||||
|
||||
binding.pullToRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
binding.pullToRefresh.setOnRefreshListener(
|
||||
() ->
|
||||
new Handler(Looper.getMainLooper())
|
||||
.postDelayed(
|
||||
() -> {
|
||||
binding.pullToRefresh.setRefreshing(false);
|
||||
PAGE = 1;
|
||||
binding.progressBar.setVisibility(View.VISIBLE);
|
||||
reload = true;
|
||||
viewModel.loadRepos(ctx, PAGE, resultLimit, null);
|
||||
},
|
||||
500));
|
||||
|
||||
binding.pullToRefresh.setRefreshing(false);
|
||||
PAGE = 1;
|
||||
binding.progressBar.setVisibility(View.VISIBLE);
|
||||
reload = true;
|
||||
viewModel.loadRepos(ctx, PAGE, resultLimit, null);
|
||||
|
||||
}, 500));
|
||||
|
||||
adapter = new AdminUnadoptedReposAdapter(new ArrayList<>(), () -> {
|
||||
PAGE = 1;
|
||||
binding.progressBar.setVisibility(View.VISIBLE);
|
||||
reload = true;
|
||||
viewModel.loadRepos(ctx, PAGE, resultLimit, null);
|
||||
}, () -> {
|
||||
PAGE += 1;
|
||||
binding.progressBar.setVisibility(View.VISIBLE);
|
||||
viewModel.loadRepos(ctx, PAGE, resultLimit, null);
|
||||
}, binding);
|
||||
adapter =
|
||||
new AdminUnadoptedReposAdapter(
|
||||
new ArrayList<>(),
|
||||
() -> {
|
||||
PAGE = 1;
|
||||
binding.progressBar.setVisibility(View.VISIBLE);
|
||||
reload = true;
|
||||
viewModel.loadRepos(ctx, PAGE, resultLimit, null);
|
||||
},
|
||||
() -> {
|
||||
PAGE += 1;
|
||||
binding.progressBar.setVisibility(View.VISIBLE);
|
||||
viewModel.loadRepos(ctx, PAGE, resultLimit, null);
|
||||
},
|
||||
binding);
|
||||
|
||||
binding.recyclerView.setAdapter(adapter);
|
||||
|
||||
|
@ -84,28 +91,29 @@ public class AdminUnadoptedReposActivity extends BaseActivity {
|
|||
|
||||
AtomicInteger prevSize = new AtomicInteger();
|
||||
|
||||
viewModel.getUnadoptedRepos(ctx, PAGE, resultLimit, null).observe(this, list -> {
|
||||
viewModel
|
||||
.getUnadoptedRepos(ctx, PAGE, resultLimit, null)
|
||||
.observe(
|
||||
this,
|
||||
list -> {
|
||||
binding.progressBar.setVisibility(View.GONE);
|
||||
|
||||
binding.progressBar.setVisibility(View.GONE);
|
||||
boolean hasMore = reload || list.size() > prevSize.get();
|
||||
reload = false;
|
||||
|
||||
boolean hasMore = reload || list.size() > prevSize.get();
|
||||
reload = false;
|
||||
prevSize.set(list.size());
|
||||
|
||||
prevSize.set(list.size());
|
||||
|
||||
if(list.size() > 0) {
|
||||
adapter.updateList(list);
|
||||
adapter.setHasMore(hasMore);
|
||||
binding.noData.setVisibility(View.GONE);
|
||||
}
|
||||
else {
|
||||
binding.noData.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
if (list.size() > 0) {
|
||||
adapter.updateList(list);
|
||||
adapter.setHasMore(hasMore);
|
||||
binding.noData.setVisibility(View.GONE);
|
||||
} else {
|
||||
binding.noData.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initCloseListener() {
|
||||
onClickListener = view -> finish();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@ import androidx.annotation.NonNull;
|
|||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.biometric.BiometricPrompt;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.Executor;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.core.MainApplication;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
|
@ -13,13 +15,10 @@ import org.mian.gitnex.helpers.TimeHelper;
|
|||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.contexts.AccountContext;
|
||||
import org.mian.gitnex.notifications.Notifications;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
/**
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public abstract class BaseActivity extends AppCompatActivity {
|
||||
|
||||
protected TinyDB tinyDB;
|
||||
|
@ -35,41 +34,43 @@ public abstract class BaseActivity extends AppCompatActivity {
|
|||
this.appCtx = getApplicationContext();
|
||||
this.tinyDB = TinyDB.getInstance(appCtx);
|
||||
|
||||
switch(tinyDB.getInt("themeId", 6)) {
|
||||
switch (tinyDB.getInt("themeId", 6)) {
|
||||
case 0:
|
||||
setTheme(R.style.AppTheme);
|
||||
break;
|
||||
case 1:
|
||||
|
||||
setTheme(R.style.AppThemeLight);
|
||||
break;
|
||||
case 2:
|
||||
|
||||
if(TimeHelper.timeBetweenHours(tinyDB.getInt("darkThemeTimeHour", 18), tinyDB.getInt("lightThemeTimeHour", 6), tinyDB.getInt("darkThemeTimeMinute", 0), tinyDB.getInt("lightThemeTimeMinute", 0))) {
|
||||
if (TimeHelper.timeBetweenHours(
|
||||
tinyDB.getInt("darkThemeTimeHour", 18),
|
||||
tinyDB.getInt("lightThemeTimeHour", 6),
|
||||
tinyDB.getInt("darkThemeTimeMinute", 0),
|
||||
tinyDB.getInt("lightThemeTimeMinute", 0))) {
|
||||
|
||||
setTheme(R.style.AppTheme);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
setTheme(R.style.AppThemeLight);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
|
||||
setTheme(R.style.AppThemeRetro);
|
||||
break;
|
||||
case 4:
|
||||
if(TimeHelper.timeBetweenHours(tinyDB.getInt("darkThemeTimeHour", 18), tinyDB.getInt("lightThemeTimeHour", 6), tinyDB.getInt("darkThemeTimeMinute", 0), tinyDB.getInt("lightThemeTimeMinute", 0))) {
|
||||
if (TimeHelper.timeBetweenHours(
|
||||
tinyDB.getInt("darkThemeTimeHour", 18),
|
||||
tinyDB.getInt("lightThemeTimeHour", 6),
|
||||
tinyDB.getInt("darkThemeTimeMinute", 0),
|
||||
tinyDB.getInt("lightThemeTimeMinute", 0))) {
|
||||
|
||||
setTheme(R.style.AppTheme);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
setTheme(R.style.AppThemeRetro);
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
|
||||
setTheme(R.style.AppThemePitchBlack);
|
||||
break;
|
||||
case 7:
|
||||
|
@ -81,10 +82,9 @@ public abstract class BaseActivity extends AppCompatActivity {
|
|||
}
|
||||
|
||||
String locale = tinyDB.getString("locale");
|
||||
if(locale.isEmpty()) {
|
||||
if (locale.isEmpty()) {
|
||||
AppUtil.setAppLocale(getResources(), Locale.getDefault().getLanguage());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
AppUtil.setAppLocale(getResources(), locale);
|
||||
}
|
||||
|
||||
|
@ -94,48 +94,54 @@ public abstract class BaseActivity extends AppCompatActivity {
|
|||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
if(tinyDB.getBoolean("biometricStatus", false) && !tinyDB.getBoolean("biometricLifeCycle")) {
|
||||
if (tinyDB.getBoolean("biometricStatus", false)
|
||||
&& !tinyDB.getBoolean("biometricLifeCycle")) {
|
||||
|
||||
Executor executor = ContextCompat.getMainExecutor(this);
|
||||
|
||||
BiometricPrompt biometricPrompt = new BiometricPrompt(this, executor, new BiometricPrompt.AuthenticationCallback() {
|
||||
BiometricPrompt biometricPrompt =
|
||||
new BiometricPrompt(
|
||||
this,
|
||||
executor,
|
||||
new BiometricPrompt.AuthenticationCallback() {
|
||||
|
||||
@Override
|
||||
public void onAuthenticationError(int errorCode, @NonNull CharSequence errString) {
|
||||
@Override
|
||||
public void onAuthenticationError(
|
||||
int errorCode, @NonNull CharSequence errString) {
|
||||
|
||||
super.onAuthenticationError(errorCode, errString);
|
||||
super.onAuthenticationError(errorCode, errString);
|
||||
|
||||
// Authentication error, close the app
|
||||
finish();
|
||||
}
|
||||
// Authentication error, close the app
|
||||
finish();
|
||||
}
|
||||
|
||||
// Authentication succeeded, continue to app
|
||||
@Override
|
||||
public void onAuthenticationSucceeded(@NonNull BiometricPrompt.AuthenticationResult result) {
|
||||
super.onAuthenticationSucceeded(result);
|
||||
tinyDB.putBoolean("biometricLifeCycle", true);
|
||||
}
|
||||
// Authentication succeeded, continue to app
|
||||
@Override
|
||||
public void onAuthenticationSucceeded(
|
||||
@NonNull BiometricPrompt.AuthenticationResult result) {
|
||||
super.onAuthenticationSucceeded(result);
|
||||
tinyDB.putBoolean("biometricLifeCycle", true);
|
||||
}
|
||||
|
||||
// Authentication failed, close the app
|
||||
@Override
|
||||
public void onAuthenticationFailed() {
|
||||
super.onAuthenticationFailed();
|
||||
}
|
||||
// Authentication failed, close the app
|
||||
@Override
|
||||
public void onAuthenticationFailed() {
|
||||
super.onAuthenticationFailed();
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
BiometricPrompt.PromptInfo biometricPromptBuilder = new BiometricPrompt.PromptInfo.Builder().setTitle(getString(R.string.biometricAuthTitle)).setSubtitle(getString(R.string.biometricAuthSubTitle))
|
||||
.setNegativeButtonText(getString(R.string.cancelButton)).build();
|
||||
BiometricPrompt.PromptInfo biometricPromptBuilder =
|
||||
new BiometricPrompt.PromptInfo.Builder()
|
||||
.setTitle(getString(R.string.biometricAuthTitle))
|
||||
.setSubtitle(getString(R.string.biometricAuthSubTitle))
|
||||
.setNegativeButtonText(getString(R.string.cancelButton))
|
||||
.build();
|
||||
|
||||
biometricPrompt.authenticate(biometricPromptBuilder);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public AccountContext getAccount() {
|
||||
return ((MainApplication) getApplication()).currentAccount;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -7,6 +7,9 @@ import android.graphics.Typeface;
|
|||
import android.os.Bundle;
|
||||
import android.widget.ArrayAdapter;
|
||||
import com.amrdeveloper.codeview.Code;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.apache.commons.lang3.EnumUtils;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.databinding.ActivityCodeEditorBinding;
|
||||
|
@ -15,15 +18,11 @@ import org.mian.gitnex.helpers.codeeditor.LanguageManager;
|
|||
import org.mian.gitnex.helpers.codeeditor.LanguageName;
|
||||
import org.mian.gitnex.helpers.codeeditor.SourcePositionListener;
|
||||
import org.mian.gitnex.helpers.codeeditor.ThemeName;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author AmrDeveloper
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class CodeEditorActivity extends BaseActivity {
|
||||
|
||||
private final ThemeName currentTheme = ThemeName.FIVE_COLOR;
|
||||
|
@ -37,21 +36,21 @@ public class CodeEditorActivity extends BaseActivity {
|
|||
binding = ActivityCodeEditorBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
|
||||
binding.close.setOnClickListener(view -> {
|
||||
sendResults();
|
||||
finish();
|
||||
});
|
||||
binding.close.setOnClickListener(
|
||||
view -> {
|
||||
sendResults();
|
||||
finish();
|
||||
});
|
||||
|
||||
String fileContent = getIntent().getStringExtra("fileContent");
|
||||
String fileExtension;
|
||||
|
||||
if(getIntent().getStringExtra("fileExtension") != null) {
|
||||
if (getIntent().getStringExtra("fileExtension") != null) {
|
||||
fileExtension = getIntent().getStringExtra("fileExtension").toUpperCase();
|
||||
|
||||
if(EnumUtils.isValidEnum(LanguageName.class, fileExtension)) {
|
||||
if (EnumUtils.isValidEnum(LanguageName.class, fileExtension)) {
|
||||
currentLanguage = LanguageName.valueOf(fileExtension);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
currentLanguage = LanguageName.UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
@ -68,7 +67,8 @@ public class CodeEditorActivity extends BaseActivity {
|
|||
|
||||
private void configCodeView(LanguageName currentLanguage, String fileContent) {
|
||||
|
||||
binding.codeView.setTypeface(Typeface.createFromAsset(ctx.getAssets(), "fonts/sourcecodeproregular.ttf"));
|
||||
binding.codeView.setTypeface(
|
||||
Typeface.createFromAsset(ctx.getAssets(), "fonts/sourcecodeproregular.ttf"));
|
||||
|
||||
// Setup Line number feature
|
||||
binding.codeView.setEnableLineNumber(true);
|
||||
|
@ -105,28 +105,30 @@ public class CodeEditorActivity extends BaseActivity {
|
|||
private void configLanguageAutoComplete() {
|
||||
|
||||
boolean useModernAutoCompleteAdapter = true;
|
||||
if(useModernAutoCompleteAdapter) {
|
||||
if (useModernAutoCompleteAdapter) {
|
||||
List<Code> codeList = languageManager.getLanguageCodeList(currentLanguage);
|
||||
|
||||
CustomCodeViewAdapter adapter = new CustomCodeViewAdapter(this, codeList);
|
||||
|
||||
binding.codeView.setAdapter(adapter);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
String[] languageKeywords = languageManager.getLanguageKeywords(currentLanguage);
|
||||
|
||||
final int layoutId = R.layout.list_item_suggestion;
|
||||
|
||||
final int viewId = R.id.suggestItemTextView;
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, layoutId, viewId, languageKeywords);
|
||||
ArrayAdapter<String> adapter =
|
||||
new ArrayAdapter<>(this, layoutId, viewId, languageKeywords);
|
||||
|
||||
binding.codeView.setAdapter(adapter);
|
||||
}
|
||||
}
|
||||
|
||||
private void configLanguageAutoIndentation() {
|
||||
binding.codeView.setIndentationStarts(languageManager.getLanguageIndentationStarts(currentLanguage));
|
||||
binding.codeView.setIndentationEnds(languageManager.getLanguageIndentationEnds(currentLanguage));
|
||||
binding.codeView.setIndentationStarts(
|
||||
languageManager.getLanguageIndentationStarts(currentLanguage));
|
||||
binding.codeView.setIndentationEnds(
|
||||
languageManager.getLanguageIndentationEnds(currentLanguage));
|
||||
}
|
||||
|
||||
private void configCodeViewPlugins() {
|
||||
|
@ -141,10 +143,12 @@ public class CodeEditorActivity extends BaseActivity {
|
|||
}
|
||||
|
||||
private void configSourcePositionListener() {
|
||||
SourcePositionListener sourcePositionListener = new SourcePositionListener(binding.codeView);
|
||||
sourcePositionListener.setOnPositionChanged((line, column) -> {
|
||||
binding.sourcePosition.setText(getString(R.string.sourcePosition, line, column));
|
||||
});
|
||||
SourcePositionListener sourcePositionListener =
|
||||
new SourcePositionListener(binding.codeView);
|
||||
sourcePositionListener.setOnPositionChanged(
|
||||
(line, column) -> {
|
||||
binding.sourcePosition.setText(
|
||||
getString(R.string.sourcePosition, line, column));
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@ import org.mian.gitnex.fragments.DiffFragment;
|
|||
/**
|
||||
* @author qwerty287
|
||||
*/
|
||||
|
||||
public class CommitDetailActivity extends BaseActivity {
|
||||
|
||||
@Override
|
||||
|
@ -18,27 +17,35 @@ public class CommitDetailActivity extends BaseActivity {
|
|||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
ActivityCommitDetailsBinding binding = ActivityCommitDetailsBinding.inflate(getLayoutInflater());
|
||||
ActivityCommitDetailsBinding binding =
|
||||
ActivityCommitDetailsBinding.inflate(getLayoutInflater());
|
||||
|
||||
setContentView(binding.getRoot());
|
||||
|
||||
CommitDetailFragment fragment = CommitDetailFragment.newInstance();
|
||||
|
||||
getOnBackPressedDispatcher().addCallback(new OnBackPressedCallback(true) {
|
||||
getOnBackPressedDispatcher()
|
||||
.addCallback(
|
||||
new OnBackPressedCallback(true) {
|
||||
|
||||
@Override
|
||||
public void handleOnBackPressed() {
|
||||
if(getSupportFragmentManager().findFragmentById(R.id.fragment_container) instanceof DiffFragment) {
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, fragment).commit();
|
||||
}
|
||||
else {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, fragment).commit();
|
||||
@Override
|
||||
public void handleOnBackPressed() {
|
||||
if (getSupportFragmentManager()
|
||||
.findFragmentById(R.id.fragment_container)
|
||||
instanceof DiffFragment) {
|
||||
getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
.replace(R.id.fragment_container, fragment)
|
||||
.commit();
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
.replace(R.id.fragment_container, fragment)
|
||||
.commit();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,6 +18,8 @@ import androidx.appcompat.widget.Toolbar;
|
|||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.gitnex.tea4j.v2.models.Commit;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.CommitsAdapter;
|
||||
|
@ -26,8 +28,6 @@ import org.mian.gitnex.databinding.ActivityCommitsBinding;
|
|||
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.List;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
@ -35,7 +35,6 @@ import retrofit2.Response;
|
|||
/**
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class CommitsActivity extends BaseActivity {
|
||||
|
||||
private final String TAG = "CommitsActivity";
|
||||
|
@ -55,7 +54,8 @@ public class CommitsActivity extends BaseActivity {
|
|||
super.onCreate(savedInstanceState);
|
||||
this.getClass().getName();
|
||||
|
||||
ActivityCommitsBinding activityCommitsBinding = ActivityCommitsBinding.inflate(getLayoutInflater());
|
||||
ActivityCommitsBinding activityCommitsBinding =
|
||||
ActivityCommitsBinding.inflate(getLayoutInflater());
|
||||
setContentView(activityCommitsBinding.getRoot());
|
||||
|
||||
Toolbar toolbar = activityCommitsBinding.toolbar;
|
||||
|
@ -81,22 +81,38 @@ public class CommitsActivity extends BaseActivity {
|
|||
recyclerView = activityCommitsBinding.recyclerView;
|
||||
commitsList = new ArrayList<>();
|
||||
|
||||
swipeRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
|
||||
swipeRefresh.setRefreshing(false);
|
||||
loadInitial(repository.getOwner(), repository.getName(), branchName, resultLimit);
|
||||
adapter.notifyDataChanged();
|
||||
}, 200));
|
||||
swipeRefresh.setOnRefreshListener(
|
||||
() ->
|
||||
new Handler(Looper.getMainLooper())
|
||||
.postDelayed(
|
||||
() -> {
|
||||
swipeRefresh.setRefreshing(false);
|
||||
loadInitial(
|
||||
repository.getOwner(),
|
||||
repository.getName(),
|
||||
branchName,
|
||||
resultLimit);
|
||||
adapter.notifyDataChanged();
|
||||
},
|
||||
200));
|
||||
|
||||
adapter = new CommitsAdapter(ctx, commitsList);
|
||||
adapter.setLoadMoreListener(() -> recyclerView.post(() -> {
|
||||
adapter.setLoadMoreListener(
|
||||
() ->
|
||||
recyclerView.post(
|
||||
() -> {
|
||||
if (commitsList.size() == resultLimit
|
||||
|| pageSize == resultLimit) {
|
||||
|
||||
if(commitsList.size() == resultLimit || pageSize == resultLimit) {
|
||||
|
||||
int page = (commitsList.size() + resultLimit) / resultLimit;
|
||||
loadMore(repository.getOwner(), repository.getName(), page, branchName, resultLimit);
|
||||
}
|
||||
}));
|
||||
int page = (commitsList.size() + resultLimit) / resultLimit;
|
||||
loadMore(
|
||||
repository.getOwner(),
|
||||
repository.getName(),
|
||||
page,
|
||||
branchName,
|
||||
resultLimit);
|
||||
}
|
||||
}));
|
||||
|
||||
recyclerView.setHasFixedSize(true);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(ctx));
|
||||
|
@ -105,98 +121,105 @@ public class CommitsActivity extends BaseActivity {
|
|||
loadInitial(repository.getOwner(), repository.getName(), branchName, resultLimit);
|
||||
}
|
||||
|
||||
private void loadInitial(String repoOwner, String repoName, String branchName, int resultLimit) {
|
||||
private void loadInitial(
|
||||
String repoOwner, String repoName, String branchName, int resultLimit) {
|
||||
|
||||
Call<List<Commit>> call = RetrofitClient.getApiInterface(ctx).repoGetAllCommits(repoOwner, repoName, branchName, null, 1, resultLimit);
|
||||
Call<List<Commit>> call =
|
||||
RetrofitClient.getApiInterface(ctx)
|
||||
.repoGetAllCommits(repoOwner, repoName, branchName, null, 1, resultLimit);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Commit>> call, @NonNull Response<List<Commit>> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<List<Commit>> call,
|
||||
@NonNull Response<List<Commit>> response) {
|
||||
|
||||
if(response.code() == 200) {
|
||||
if (response.code() == 200) {
|
||||
|
||||
assert response.body() != null;
|
||||
if(response.body().size() > 0) {
|
||||
assert response.body() != null;
|
||||
if (response.body().size() > 0) {
|
||||
|
||||
commitsList.clear();
|
||||
commitsList.addAll(response.body());
|
||||
adapter.notifyDataChanged();
|
||||
noData.setVisibility(View.GONE);
|
||||
commitsList.clear();
|
||||
commitsList.addAll(response.body());
|
||||
adapter.notifyDataChanged();
|
||||
noData.setVisibility(View.GONE);
|
||||
} else {
|
||||
|
||||
commitsList.clear();
|
||||
adapter.notifyDataChanged();
|
||||
noData.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
if (response.code() == 409) {
|
||||
|
||||
noData.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
|
||||
Log.e(TAG, String.valueOf(response.code()));
|
||||
}
|
||||
|
||||
progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
else {
|
||||
|
||||
commitsList.clear();
|
||||
adapter.notifyDataChanged();
|
||||
noData.setVisibility(View.VISIBLE);
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Commit>> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(
|
||||
ctx, getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
}
|
||||
if(response.code() == 409) {
|
||||
|
||||
noData.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
|
||||
Log.e(TAG, String.valueOf(response.code()));
|
||||
}
|
||||
|
||||
progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Commit>> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
private void loadMore(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) {
|
||||
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
|
||||
Call<List<Commit>> call = RetrofitClient.getApiInterface(ctx).repoGetAllCommits(repoOwner, repoName, branchName, null, page, resultLimit);
|
||||
Call<List<Commit>> call =
|
||||
RetrofitClient.getApiInterface(ctx)
|
||||
.repoGetAllCommits(
|
||||
repoOwner, repoName, branchName, null, page, resultLimit);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Commit>> call, @NonNull Response<List<Commit>> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<List<Commit>> call,
|
||||
@NonNull Response<List<Commit>> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if (response.isSuccessful()) {
|
||||
|
||||
List<Commit> result = response.body();
|
||||
assert result != null;
|
||||
List<Commit> result = response.body();
|
||||
assert result != null;
|
||||
|
||||
if(result.size() > 0) {
|
||||
if (result.size() > 0) {
|
||||
|
||||
pageSize = result.size();
|
||||
commitsList.addAll(result);
|
||||
}
|
||||
else {
|
||||
pageSize = result.size();
|
||||
commitsList.addAll(result);
|
||||
} else {
|
||||
|
||||
adapter.setMoreDataAvailable(false);
|
||||
adapter.setMoreDataAvailable(false);
|
||||
}
|
||||
|
||||
adapter.notifyDataChanged();
|
||||
} else {
|
||||
|
||||
Log.e(TAG, String.valueOf(response.code()));
|
||||
}
|
||||
|
||||
progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
adapter.notifyDataChanged();
|
||||
}
|
||||
else {
|
||||
|
||||
Log.e(TAG, String.valueOf(response.code()));
|
||||
}
|
||||
|
||||
progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Commit>> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
|
||||
});
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Commit>> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(
|
||||
ctx, getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -206,25 +229,26 @@ public class CommitsActivity extends BaseActivity {
|
|||
inflater.inflate(R.menu.search_menu, menu);
|
||||
|
||||
MenuItem searchItem = menu.findItem(R.id.action_search);
|
||||
androidx.appcompat.widget.SearchView searchView = (androidx.appcompat.widget.SearchView) searchItem.getActionView();
|
||||
androidx.appcompat.widget.SearchView searchView =
|
||||
(androidx.appcompat.widget.SearchView) searchItem.getActionView();
|
||||
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||
|
||||
searchView.setOnQueryTextListener(new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
||||
searchView.setOnQueryTextListener(
|
||||
new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
|
||||
filter(newText);
|
||||
return true;
|
||||
}
|
||||
|
||||
});
|
||||
filter(newText);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
@ -233,9 +257,10 @@ public class CommitsActivity extends BaseActivity {
|
|||
|
||||
List<Commit> arr = new ArrayList<>();
|
||||
|
||||
for(Commit d : commitsList) {
|
||||
for (Commit d : commitsList) {
|
||||
|
||||
if(d.getCommit().getMessage().toLowerCase().contains(text) || d.getSha().toLowerCase().contains(text)) {
|
||||
if (d.getCommit().getMessage().toLowerCase().contains(text)
|
||||
|| d.getSha().toLowerCase().contains(text)) {
|
||||
|
||||
arr.add(d);
|
||||
}
|
||||
|
@ -254,7 +279,4 @@ public class CommitsActivity extends BaseActivity {
|
|||
super.onResume();
|
||||
repository.checkAccountSwitch(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -12,6 +12,12 @@ import android.widget.ArrayAdapter;
|
|||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
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 org.gitnex.tea4j.v2.models.CreateIssueOption;
|
||||
import org.gitnex.tea4j.v2.models.Issue;
|
||||
import org.gitnex.tea4j.v2.models.Label;
|
||||
|
@ -32,20 +38,16 @@ import org.mian.gitnex.helpers.AppUtil;
|
|||
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;
|
||||
|
||||
/**
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class CreateIssueActivity extends BaseActivity implements View.OnClickListener, LabelsListAdapter.LabelsListAdapterListener, AssigneesListAdapter.AssigneesListAdapterListener {
|
||||
public class CreateIssueActivity extends BaseActivity
|
||||
implements View.OnClickListener,
|
||||
LabelsListAdapter.LabelsListAdapterListener,
|
||||
AssigneesListAdapter.AssigneesListAdapterListener {
|
||||
|
||||
private final List<Label> labelsList = new ArrayList<>();
|
||||
private final LinkedHashMap<String, Milestone> milestonesList = new LinkedHashMap<>();
|
||||
|
@ -72,9 +74,11 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
InputMethodManager imm =
|
||||
(InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx, R.style.ThemeOverlay_Material3_Dialog_Alert);
|
||||
materialAlertDialogBuilder =
|
||||
new MaterialAlertDialogBuilder(ctx, R.style.ThemeOverlay_Material3_Dialog_Alert);
|
||||
|
||||
repository = RepositoryContext.fromIntent(getIntent());
|
||||
|
||||
|
@ -84,19 +88,22 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||
assert imm != null;
|
||||
imm.showSoftInput(viewBinding.newIssueTitle, InputMethodManager.SHOW_IMPLICIT);
|
||||
|
||||
viewBinding.newIssueDescription.setOnTouchListener((touchView, motionEvent) -> {
|
||||
viewBinding.newIssueDescription.setOnTouchListener(
|
||||
(touchView, motionEvent) -> {
|
||||
touchView.getParent().requestDisallowInterceptTouchEvent(true);
|
||||
|
||||
touchView.getParent().requestDisallowInterceptTouchEvent(true);
|
||||
if ((motionEvent.getAction() & MotionEvent.ACTION_UP) != 0
|
||||
&& (motionEvent.getActionMasked() & MotionEvent.ACTION_UP) != 0) {
|
||||
|
||||
if((motionEvent.getAction() & MotionEvent.ACTION_UP) != 0 && (motionEvent.getActionMasked() & MotionEvent.ACTION_UP) != 0) {
|
||||
|
||||
touchView.getParent().requestDisallowInterceptTouchEvent(false);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
touchView.getParent().requestDisallowInterceptTouchEvent(false);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
labelsAdapter = new LabelsListAdapter(labelsList, CreateIssueActivity.this, labelsIds);
|
||||
assigneesAdapter = new AssigneesListAdapter(ctx, assigneesList, CreateIssueActivity.this, assigneesListData);
|
||||
assigneesAdapter =
|
||||
new AssigneesListAdapter(
|
||||
ctx, assigneesList, CreateIssueActivity.this, assigneesListData);
|
||||
|
||||
initCloseListener();
|
||||
viewBinding.close.setOnClickListener(onClickListener);
|
||||
|
@ -111,31 +118,31 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||
|
||||
viewBinding.newIssueLabels.setOnClickListener(newIssueLabels -> showLabels());
|
||||
|
||||
viewBinding.newIssueAssigneesList.setOnClickListener(newIssueAssigneesList -> showAssignees());
|
||||
viewBinding.newIssueAssigneesList.setOnClickListener(
|
||||
newIssueAssigneesList -> showAssignees());
|
||||
|
||||
if(!connToInternet) {
|
||||
if (!connToInternet) {
|
||||
|
||||
viewBinding.createNewIssueButton.setEnabled(false);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
viewBinding.createNewIssueButton.setOnClickListener(this);
|
||||
}
|
||||
|
||||
if(!repository.getPermissions().isPush()) {
|
||||
if (!repository.getPermissions().isPush()) {
|
||||
viewBinding.newIssueAssigneesListLayout.setVisibility(View.GONE);
|
||||
viewBinding.newIssueMilestoneSpinnerLayout.setVisibility(View.GONE);
|
||||
viewBinding.newIssueLabelsLayout.setVisibility(View.GONE);
|
||||
viewBinding.newIssueDueDateLayout.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void assigneesInterface(List<String> data) {
|
||||
|
||||
String assigneesSetter = String.valueOf(data);
|
||||
viewBinding.newIssueAssigneesList.setText(assigneesSetter.replace("]", "").replace("[", ""));
|
||||
viewBinding.newIssueAssigneesList.setText(
|
||||
assigneesSetter.replace("]", "").replace("[", ""));
|
||||
assigneesListData = data;
|
||||
}
|
||||
|
||||
|
@ -156,56 +163,87 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||
|
||||
viewBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
|
||||
CustomAssigneesSelectionDialogBinding assigneesBinding = CustomAssigneesSelectionDialogBinding.inflate(LayoutInflater.from(ctx));
|
||||
CustomAssigneesSelectionDialogBinding assigneesBinding =
|
||||
CustomAssigneesSelectionDialogBinding.inflate(LayoutInflater.from(ctx));
|
||||
View view = assigneesBinding.getRoot();
|
||||
materialAlertDialogBuilder.setView(view);
|
||||
|
||||
materialAlertDialogBuilder.setNeutralButton(R.string.close, null);
|
||||
|
||||
AssigneesActions.getRepositoryAssignees(ctx, repository.getOwner(), repository.getName(), assigneesList, materialAlertDialogBuilder, assigneesAdapter, assigneesBinding, viewBinding.progressBar);
|
||||
AssigneesActions.getRepositoryAssignees(
|
||||
ctx,
|
||||
repository.getOwner(),
|
||||
repository.getName(),
|
||||
assigneesList,
|
||||
materialAlertDialogBuilder,
|
||||
assigneesAdapter,
|
||||
assigneesBinding,
|
||||
viewBinding.progressBar);
|
||||
}
|
||||
|
||||
private void showLabels() {
|
||||
|
||||
viewBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
|
||||
CustomLabelsSelectionDialogBinding labelsBinding = CustomLabelsSelectionDialogBinding.inflate(LayoutInflater.from(ctx));
|
||||
CustomLabelsSelectionDialogBinding labelsBinding =
|
||||
CustomLabelsSelectionDialogBinding.inflate(LayoutInflater.from(ctx));
|
||||
View view = labelsBinding.getRoot();
|
||||
materialAlertDialogBuilder.setView(view);
|
||||
|
||||
materialAlertDialogBuilder.setNeutralButton(R.string.close, null);
|
||||
|
||||
LabelsActions.getRepositoryLabels(ctx, repository.getOwner(), repository.getName(), labelsList, materialAlertDialogBuilder, labelsAdapter, labelsBinding, viewBinding.progressBar);
|
||||
LabelsActions.getRepositoryLabels(
|
||||
ctx,
|
||||
repository.getOwner(),
|
||||
repository.getName(),
|
||||
labelsList,
|
||||
materialAlertDialogBuilder,
|
||||
labelsAdapter,
|
||||
labelsBinding,
|
||||
viewBinding.progressBar);
|
||||
}
|
||||
|
||||
private void processNewIssue() {
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
String newIssueTitleForm = Objects.requireNonNull(viewBinding.newIssueTitle.getText()).toString();
|
||||
String newIssueDescriptionForm = Objects.requireNonNull(viewBinding.newIssueDescription.getText()).toString();
|
||||
String newIssueDueDateForm = Objects.requireNonNull(viewBinding.newIssueDueDate.getText()).toString();
|
||||
String newIssueTitleForm =
|
||||
Objects.requireNonNull(viewBinding.newIssueTitle.getText()).toString();
|
||||
String newIssueDescriptionForm =
|
||||
Objects.requireNonNull(viewBinding.newIssueDescription.getText()).toString();
|
||||
String newIssueDueDateForm =
|
||||
Objects.requireNonNull(viewBinding.newIssueDueDate.getText()).toString();
|
||||
|
||||
if(!connToInternet) {
|
||||
if (!connToInternet) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
return;
|
||||
}
|
||||
|
||||
if(newIssueTitleForm.equals("")) {
|
||||
if (newIssueTitleForm.equals("")) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.issueTitleEmpty));
|
||||
return;
|
||||
}
|
||||
|
||||
disableProcessButton();
|
||||
createNewIssueFunc(repository.getOwner(), repository.getName(), newIssueDescriptionForm, milestoneId, newIssueTitleForm);
|
||||
createNewIssueFunc(
|
||||
repository.getOwner(),
|
||||
repository.getName(),
|
||||
newIssueDescriptionForm,
|
||||
milestoneId,
|
||||
newIssueTitleForm);
|
||||
}
|
||||
|
||||
private void createNewIssueFunc(String repoOwner, String repoName, String newIssueDescriptionForm, int newIssueMilestoneIdForm, String newIssueTitleForm) {
|
||||
private void createNewIssueFunc(
|
||||
String repoOwner,
|
||||
String repoName,
|
||||
String newIssueDescriptionForm,
|
||||
int newIssueMilestoneIdForm,
|
||||
String newIssueTitleForm) {
|
||||
|
||||
ArrayList<Long> labelIds = new ArrayList<>();
|
||||
for(Integer i : labelsIds) {
|
||||
for (Integer i : labelsIds) {
|
||||
labelIds.add((long) i);
|
||||
}
|
||||
|
||||
|
@ -217,43 +255,45 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||
createNewIssueJson.setAssignees(assigneesListData);
|
||||
createNewIssueJson.setLabels(labelIds);
|
||||
|
||||
Call<Issue> call3 = RetrofitClient.getApiInterface(ctx).issueCreateIssue(repoOwner, repoName, createNewIssueJson);
|
||||
Call<Issue> call3 =
|
||||
RetrofitClient.getApiInterface(ctx)
|
||||
.issueCreateIssue(repoOwner, repoName, createNewIssueJson);
|
||||
|
||||
call3.enqueue(new Callback<>() {
|
||||
call3.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Issue> call, @NonNull retrofit2.Response<Issue> response2) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<Issue> call,
|
||||
@NonNull retrofit2.Response<Issue> response2) {
|
||||
|
||||
if(response2.code() == 201) {
|
||||
if (response2.code() == 201) {
|
||||
|
||||
IssuesFragment.resumeIssues = true;
|
||||
IssuesFragment.resumeIssues = true;
|
||||
|
||||
Toasty.success(ctx, getString(R.string.issueCreated));
|
||||
enableProcessButton();
|
||||
RepoDetailActivity.updateRepo = true;
|
||||
MainActivity.reloadRepos = true;
|
||||
finish();
|
||||
}
|
||||
else if(response2.code() == 401) {
|
||||
Toasty.success(ctx, getString(R.string.issueCreated));
|
||||
enableProcessButton();
|
||||
RepoDetailActivity.updateRepo = true;
|
||||
MainActivity.reloadRepos = true;
|
||||
finish();
|
||||
} else if (response2.code() == 401) {
|
||||
|
||||
enableProcessButton();
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
}
|
||||
else {
|
||||
enableProcessButton();
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
} else {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
enableProcessButton();
|
||||
}
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
enableProcessButton();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Issue> call, @NonNull Throwable t) {
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Issue> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.genericServerResponseError));
|
||||
enableProcessButton();
|
||||
}
|
||||
});
|
||||
Toasty.error(ctx, getString(R.string.genericServerResponseError));
|
||||
enableProcessButton();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initCloseListener() {
|
||||
|
@ -264,80 +304,106 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||
private void getMilestones(String repoOwner, String repoName, int resultLimit) {
|
||||
|
||||
String msState = "open";
|
||||
Call<List<Milestone>> call = RetrofitClient.getApiInterface(ctx).issueGetMilestonesList(repoOwner, repoName, msState, null, 1, resultLimit);
|
||||
Call<List<Milestone>> call =
|
||||
RetrofitClient.getApiInterface(ctx)
|
||||
.issueGetMilestonesList(repoOwner, repoName, msState, null, 1, resultLimit);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Milestone>> call, @NonNull retrofit2.Response<List<Milestone>> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<List<Milestone>> call,
|
||||
@NonNull retrofit2.Response<List<Milestone>> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if (response.isSuccessful()) {
|
||||
|
||||
if(response.code() == 200) {
|
||||
if (response.code() == 200) {
|
||||
|
||||
List<Milestone> milestonesList_ = response.body();
|
||||
List<Milestone> milestonesList_ = response.body();
|
||||
|
||||
Milestone ms = new Milestone();
|
||||
ms.setId(0L);
|
||||
ms.setTitle(getString(R.string.issueCreatedNoMilestone));
|
||||
milestonesList.put(ms.getTitle(), ms);
|
||||
assert milestonesList_ != null;
|
||||
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) {
|
||||
if (milestonesList_.size() > 0) {
|
||||
|
||||
for(Milestone milestone : milestonesList_) {
|
||||
for (Milestone milestone : milestonesList_) {
|
||||
|
||||
//Don't translate "open" is a enum
|
||||
if(milestone.getState().equals("open")) {
|
||||
milestonesList.put(milestone.getTitle(), milestone);
|
||||
// Don't translate "open" is a enum
|
||||
if (milestone.getState().equals("open")) {
|
||||
milestonesList.put(milestone.getTitle(), milestone);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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) -> {
|
||||
if (position == 0) {
|
||||
milestoneId = 0;
|
||||
} else if (view instanceof TextView) {
|
||||
milestoneId =
|
||||
Math.toIntExact(
|
||||
Objects.requireNonNull(
|
||||
milestonesList.get(
|
||||
((TextView)
|
||||
view)
|
||||
.getText()
|
||||
.toString()))
|
||||
.getId());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
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) -> {
|
||||
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<Milestone>> call, @NonNull Throwable t) {
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Milestone>> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
Toasty.error(ctx, getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
if(v == viewBinding.newIssueDueDate) {
|
||||
if (v == viewBinding.newIssueDueDate) {
|
||||
|
||||
final Calendar c = Calendar.getInstance();
|
||||
int mYear = c.get(Calendar.YEAR);
|
||||
final int mMonth = c.get(Calendar.MONTH);
|
||||
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));
|
||||
currentDate = new Date(year - 1900, monthOfYear, dayOfMonth);
|
||||
}, mYear, mMonth, mDay);
|
||||
DatePickerDialog datePickerDialog =
|
||||
new DatePickerDialog(
|
||||
this,
|
||||
(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) {
|
||||
} else if (v == viewBinding.createNewIssueButton) {
|
||||
|
||||
processNewIssue();
|
||||
}
|
||||
|
@ -358,5 +424,4 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||
super.onResume();
|
||||
repository.checkAccountSwitch(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import android.widget.TextView;
|
|||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import com.pes.androidmaterialcolorpickerdialog.ColorPicker;
|
||||
import java.util.Objects;
|
||||
import org.gitnex.tea4j.v2.models.CreateLabelOption;
|
||||
import org.gitnex.tea4j.v2.models.EditLabelOption;
|
||||
import org.gitnex.tea4j.v2.models.Label;
|
||||
|
@ -22,14 +23,12 @@ import org.mian.gitnex.helpers.Toasty;
|
|||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import org.mian.gitnex.viewmodels.LabelsViewModel;
|
||||
import org.mian.gitnex.viewmodels.OrganizationLabelsViewModel;
|
||||
import java.util.Objects;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
/**
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class CreateLabelActivity extends BaseActivity {
|
||||
|
||||
public static boolean refreshLabels = false;
|
||||
|
@ -51,13 +50,18 @@ public class CreateLabelActivity extends BaseActivity {
|
|||
activityCreateLabelBinding = ActivityCreateLabelBinding.inflate(getLayoutInflater());
|
||||
setContentView(activityCreateLabelBinding.getRoot());
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
InputMethodManager imm =
|
||||
(InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
repository = RepositoryContext.fromIntent(getIntent());
|
||||
|
||||
if(getIntent().getStringExtra("labelAction") != null && Objects.requireNonNull(getIntent().getStringExtra("labelAction")).equals("delete")) {
|
||||
if (getIntent().getStringExtra("labelAction") != null
|
||||
&& Objects.requireNonNull(getIntent().getStringExtra("labelAction"))
|
||||
.equals("delete")) {
|
||||
|
||||
deleteLabel(Integer.parseInt(Objects.requireNonNull(getIntent().getStringExtra("labelId"))));
|
||||
deleteLabel(
|
||||
Integer.parseInt(
|
||||
Objects.requireNonNull(getIntent().getStringExtra("labelId"))));
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
@ -74,15 +78,18 @@ public class CreateLabelActivity extends BaseActivity {
|
|||
activityCreateLabelBinding.close.setOnClickListener(onClickListener);
|
||||
activityCreateLabelBinding.colorPicker.setOnClickListener(v -> cp.show());
|
||||
|
||||
cp.setCallback(color -> {
|
||||
cp.setCallback(
|
||||
color -> {
|
||||
|
||||
//Log.i("#Hex no alpha", String.format("#%06X", (0xFFFFFF & color)));
|
||||
activityCreateLabelBinding.colorPicker.setBackgroundColor(color);
|
||||
labelColor = String.format("#%06X", (0xFFFFFF & color));
|
||||
cp.dismiss();
|
||||
});
|
||||
// Log.i("#Hex no alpha", String.format("#%06X", (0xFFFFFF & color)));
|
||||
activityCreateLabelBinding.colorPicker.setBackgroundColor(color);
|
||||
labelColor = String.format("#%06X", (0xFFFFFF & color));
|
||||
cp.dismiss();
|
||||
});
|
||||
|
||||
if(getIntent().getStringExtra("labelAction") != null && Objects.requireNonNull(getIntent().getStringExtra("labelAction")).equals("edit")) {
|
||||
if (getIntent().getStringExtra("labelAction") != null
|
||||
&& Objects.requireNonNull(getIntent().getStringExtra("labelAction"))
|
||||
.equals("edit")) {
|
||||
|
||||
activityCreateLabelBinding.labelName.setText(getIntent().getStringExtra("labelTitle"));
|
||||
int labelColor_ = Color.parseColor("#" + getIntent().getStringExtra("labelColor"));
|
||||
|
@ -91,17 +98,17 @@ public class CreateLabelActivity extends BaseActivity {
|
|||
|
||||
TextView toolbar_title = activityCreateLabelBinding.toolbarTitle;
|
||||
toolbar_title.setText(getResources().getString(R.string.pageTitleLabelUpdate));
|
||||
activityCreateLabelBinding.createLabelButton.setText(getResources().getString(R.string.newUpdateButtonCopy));
|
||||
activityCreateLabelBinding.createLabelButton.setText(
|
||||
getResources().getString(R.string.newUpdateButtonCopy));
|
||||
|
||||
activityCreateLabelBinding.createLabelButton.setOnClickListener(updateLabelListener);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!connToInternet) {
|
||||
if (!connToInternet) {
|
||||
|
||||
activityCreateLabelBinding.createLabelButton.setEnabled(false);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
activityCreateLabelBinding.createLabelButton.setOnClickListener(createLabelListener);
|
||||
}
|
||||
|
@ -111,69 +118,75 @@ public class CreateLabelActivity extends BaseActivity {
|
|||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
String updateLabelName = Objects.requireNonNull(activityCreateLabelBinding.labelName.getText()).toString();
|
||||
String updateLabelName =
|
||||
Objects.requireNonNull(activityCreateLabelBinding.labelName.getText()).toString();
|
||||
|
||||
String updateLabelColor;
|
||||
if(labelColor.isEmpty()) {
|
||||
if (labelColor.isEmpty()) {
|
||||
|
||||
updateLabelColor = labelColorDefault;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
updateLabelColor = labelColor;
|
||||
}
|
||||
|
||||
if(!connToInternet) {
|
||||
if (!connToInternet) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
return;
|
||||
}
|
||||
|
||||
if(updateLabelName.equals("")) {
|
||||
if (updateLabelName.equals("")) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.labelEmptyError));
|
||||
return;
|
||||
}
|
||||
|
||||
if(!AppUtil.checkStrings(updateLabelName)) {
|
||||
if (!AppUtil.checkStrings(updateLabelName)) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.labelNameError));
|
||||
return;
|
||||
}
|
||||
|
||||
disableProcessButton();
|
||||
patchLabel(repository, updateLabelName, updateLabelColor, Integer.parseInt(Objects.requireNonNull(getIntent().getStringExtra("labelId"))));
|
||||
patchLabel(
|
||||
repository,
|
||||
updateLabelName,
|
||||
updateLabelColor,
|
||||
Integer.parseInt(Objects.requireNonNull(getIntent().getStringExtra("labelId"))));
|
||||
}
|
||||
|
||||
private void processCreateLabel() {
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
String newLabelName = Objects.requireNonNull(activityCreateLabelBinding.labelName.getText()).toString();
|
||||
String newLabelName =
|
||||
Objects.requireNonNull(activityCreateLabelBinding.labelName.getText()).toString();
|
||||
String newLabelColor;
|
||||
|
||||
if(labelColor.isEmpty()) {
|
||||
if (labelColor.isEmpty()) {
|
||||
|
||||
newLabelColor = String.format("#%06X", (0xFFFFFF & ContextCompat.getColor(ctx, R.color.releasePre)));
|
||||
}
|
||||
else {
|
||||
newLabelColor =
|
||||
String.format(
|
||||
"#%06X", (0xFFFFFF & ContextCompat.getColor(ctx, R.color.releasePre)));
|
||||
} else {
|
||||
|
||||
newLabelColor = labelColor;
|
||||
}
|
||||
|
||||
if(!connToInternet) {
|
||||
if (!connToInternet) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
return;
|
||||
}
|
||||
|
||||
if(newLabelName.equals("")) {
|
||||
if (newLabelName.equals("")) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.labelEmptyError));
|
||||
return;
|
||||
}
|
||||
|
||||
if(!AppUtil.checkStrings(newLabelName)) {
|
||||
if (!AppUtil.checkStrings(newLabelName)) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.labelNameError));
|
||||
return;
|
||||
|
@ -191,52 +204,61 @@ public class CreateLabelActivity extends BaseActivity {
|
|||
|
||||
Call<Label> call;
|
||||
|
||||
if(getIntent().getStringExtra("type") != null && Objects.requireNonNull(getIntent().getStringExtra("type")).equals("org")) {
|
||||
if (getIntent().getStringExtra("type") != null
|
||||
&& Objects.requireNonNull(getIntent().getStringExtra("type")).equals("org")) {
|
||||
|
||||
call = RetrofitClient.getApiInterface(ctx).orgCreateLabel(getIntent().getStringExtra("orgName"), createLabelFunc);
|
||||
}
|
||||
else if(repository != null) {
|
||||
call =
|
||||
RetrofitClient.getApiInterface(ctx)
|
||||
.orgCreateLabel(getIntent().getStringExtra("orgName"), createLabelFunc);
|
||||
} else if (repository != null) {
|
||||
|
||||
call = RetrofitClient.getApiInterface(ctx).issueCreateLabel(repository.getOwner(), repository.getName(), createLabelFunc);
|
||||
}
|
||||
else {
|
||||
call =
|
||||
RetrofitClient.getApiInterface(ctx)
|
||||
.issueCreateLabel(
|
||||
repository.getOwner(), repository.getName(), createLabelFunc);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Label> call, @NonNull retrofit2.Response<Label> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<Label> call,
|
||||
@NonNull retrofit2.Response<Label> response) {
|
||||
|
||||
if(response.code() == 201) {
|
||||
if (response.code() == 201) {
|
||||
|
||||
Toasty.success(ctx, getString(R.string.labelCreated));
|
||||
refreshLabels = true;
|
||||
finish();
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
Toasty.success(ctx, getString(R.string.labelCreated));
|
||||
refreshLabels = true;
|
||||
finish();
|
||||
} else if (response.code() == 401) {
|
||||
|
||||
enableProcessButton();
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
}
|
||||
else {
|
||||
enableProcessButton();
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
} else {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Label> call, @NonNull Throwable t) {
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Label> call, @NonNull Throwable t) {
|
||||
|
||||
labelColor = "";
|
||||
Log.e("onFailure", t.toString());
|
||||
enableProcessButton();
|
||||
}
|
||||
});
|
||||
labelColor = "";
|
||||
Log.e("onFailure", t.toString());
|
||||
enableProcessButton();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void patchLabel(RepositoryContext repository, String updateLabelName, String updateLabelColor, int labelId) {
|
||||
private void patchLabel(
|
||||
RepositoryContext repository,
|
||||
String updateLabelName,
|
||||
String updateLabelColor,
|
||||
int labelId) {
|
||||
|
||||
EditLabelOption createLabelFunc = new EditLabelOption();
|
||||
createLabelFunc.setColor(updateLabelColor);
|
||||
|
@ -244,50 +266,62 @@ public class CreateLabelActivity extends BaseActivity {
|
|||
|
||||
Call<Label> call;
|
||||
|
||||
if(getIntent().getStringExtra("type") != null && Objects.requireNonNull(getIntent().getStringExtra("type")).equals("org")) {
|
||||
if (getIntent().getStringExtra("type") != null
|
||||
&& Objects.requireNonNull(getIntent().getStringExtra("type")).equals("org")) {
|
||||
|
||||
call = RetrofitClient.getApiInterface(ctx).orgEditLabel(getIntent().getStringExtra("orgName"), (long) labelId, createLabelFunc);
|
||||
}
|
||||
else {
|
||||
call =
|
||||
RetrofitClient.getApiInterface(ctx)
|
||||
.orgEditLabel(
|
||||
getIntent().getStringExtra("orgName"),
|
||||
(long) labelId,
|
||||
createLabelFunc);
|
||||
} else {
|
||||
|
||||
call = RetrofitClient.getApiInterface(ctx).issueEditLabel(repository.getOwner(), repository.getName(), (long) labelId, createLabelFunc);
|
||||
call =
|
||||
RetrofitClient.getApiInterface(ctx)
|
||||
.issueEditLabel(
|
||||
repository.getOwner(),
|
||||
repository.getName(),
|
||||
(long) labelId,
|
||||
createLabelFunc);
|
||||
}
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Label> call, @NonNull retrofit2.Response<Label> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<Label> call,
|
||||
@NonNull retrofit2.Response<Label> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if (response.isSuccessful()) {
|
||||
|
||||
if(response.code() == 200) {
|
||||
if (response.code() == 200) {
|
||||
|
||||
Toasty.success(ctx, getString(R.string.labelUpdated));
|
||||
refreshLabels = true;
|
||||
finish();
|
||||
Toasty.success(ctx, getString(R.string.labelUpdated));
|
||||
refreshLabels = true;
|
||||
finish();
|
||||
}
|
||||
} else if (response.code() == 401) {
|
||||
|
||||
enableProcessButton();
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
} else {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
enableProcessButton();
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
}
|
||||
else {
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Label> call, @NonNull Throwable t) {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Label> call, @NonNull Throwable t) {
|
||||
|
||||
labelColor = "";
|
||||
labelColorDefault = "";
|
||||
Log.e("onFailure", t.toString());
|
||||
enableProcessButton();
|
||||
}
|
||||
});
|
||||
labelColor = "";
|
||||
labelColorDefault = "";
|
||||
Log.e("onFailure", t.toString());
|
||||
enableProcessButton();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initCloseListener() {
|
||||
|
@ -299,51 +333,59 @@ public class CreateLabelActivity extends BaseActivity {
|
|||
|
||||
Call<Void> call;
|
||||
|
||||
if(getIntent().getStringExtra("type") != null && Objects.requireNonNull(getIntent().getStringExtra("type")).equals("org")) {
|
||||
if (getIntent().getStringExtra("type") != null
|
||||
&& Objects.requireNonNull(getIntent().getStringExtra("type")).equals("org")) {
|
||||
|
||||
call = RetrofitClient.getApiInterface(ctx).orgDeleteLabel(getIntent().getStringExtra("orgName"), (long) labelId);
|
||||
}
|
||||
else {
|
||||
call =
|
||||
RetrofitClient.getApiInterface(ctx)
|
||||
.orgDeleteLabel(getIntent().getStringExtra("orgName"), (long) labelId);
|
||||
} else {
|
||||
|
||||
call = RetrofitClient.getApiInterface(ctx).issueDeleteLabel(repository.getOwner(), repository.getName(), (long) labelId);
|
||||
call =
|
||||
RetrofitClient.getApiInterface(ctx)
|
||||
.issueDeleteLabel(
|
||||
repository.getOwner(), repository.getName(), (long) labelId);
|
||||
}
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if (response.isSuccessful()) {
|
||||
|
||||
if(response.code() == 204) {
|
||||
if (response.code() == 204) {
|
||||
|
||||
Toasty.success(ctx, getString(R.string.labelDeleteText));
|
||||
if(getIntent().getStringExtra("type") != null && Objects.requireNonNull(getIntent().getStringExtra("type")).equals("org")) {
|
||||
Toasty.success(ctx, getString(R.string.labelDeleteText));
|
||||
if (getIntent().getStringExtra("type") != null
|
||||
&& Objects.requireNonNull(
|
||||
getIntent().getStringExtra("type"))
|
||||
.equals("org")) {
|
||||
|
||||
OrganizationLabelsViewModel.loadOrgLabelsList(getIntent().getStringExtra("orgName"), ctx, null, null);
|
||||
}
|
||||
else {
|
||||
OrganizationLabelsViewModel.loadOrgLabelsList(
|
||||
getIntent().getStringExtra("orgName"), ctx, null, null);
|
||||
} else {
|
||||
|
||||
LabelsViewModel.loadLabelsList(repository.getOwner(), repository.getName(), ctx);
|
||||
LabelsViewModel.loadLabelsList(
|
||||
repository.getOwner(), repository.getName(), ctx);
|
||||
}
|
||||
}
|
||||
} else if (response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
} else {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
Log.e("onFailure", t.toString());
|
||||
}
|
||||
});
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
Log.e("onFailure", t.toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void disableProcessButton() {
|
||||
|
@ -359,10 +401,9 @@ public class CreateLabelActivity extends BaseActivity {
|
|||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if(repository == null) {
|
||||
if (repository == null) {
|
||||
return;
|
||||
}
|
||||
repository.checkAccountSwitch(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,6 +13,8 @@ import android.widget.Button;
|
|||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import androidx.annotation.NonNull;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import org.gitnex.tea4j.v2.models.CreateMilestoneOption;
|
||||
import org.gitnex.tea4j.v2.models.Milestone;
|
||||
import org.mian.gitnex.R;
|
||||
|
@ -22,15 +24,12 @@ import org.mian.gitnex.helpers.AlertDialogs;
|
|||
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;
|
||||
|
||||
/**
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class CreateMilestoneActivity extends BaseActivity implements View.OnClickListener {
|
||||
|
||||
private EditText milestoneDueDate;
|
||||
|
@ -49,12 +48,14 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
|||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
ActivityCreateMilestoneBinding activityCreateMilestoneBinding = ActivityCreateMilestoneBinding.inflate(getLayoutInflater());
|
||||
ActivityCreateMilestoneBinding activityCreateMilestoneBinding =
|
||||
ActivityCreateMilestoneBinding.inflate(getLayoutInflater());
|
||||
setContentView(activityCreateMilestoneBinding.getRoot());
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
InputMethodManager imm =
|
||||
(InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
milestoneDueDate = activityCreateMilestoneBinding.milestoneDueDate;
|
||||
ImageView closeActivity = activityCreateMilestoneBinding.close;
|
||||
|
@ -67,30 +68,29 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
|||
assert imm != null;
|
||||
imm.showSoftInput(milestoneTitle, InputMethodManager.SHOW_IMPLICIT);
|
||||
|
||||
milestoneDescription.setOnTouchListener((touchView, motionEvent) -> {
|
||||
milestoneDescription.setOnTouchListener(
|
||||
(touchView, motionEvent) -> {
|
||||
touchView.getParent().requestDisallowInterceptTouchEvent(true);
|
||||
|
||||
touchView.getParent().requestDisallowInterceptTouchEvent(true);
|
||||
if ((motionEvent.getAction() & MotionEvent.ACTION_UP) != 0
|
||||
&& (motionEvent.getActionMasked() & MotionEvent.ACTION_UP) != 0) {
|
||||
|
||||
if((motionEvent.getAction() & MotionEvent.ACTION_UP) != 0 && (motionEvent.getActionMasked() & MotionEvent.ACTION_UP) != 0) {
|
||||
|
||||
touchView.getParent().requestDisallowInterceptTouchEvent(false);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
touchView.getParent().requestDisallowInterceptTouchEvent(false);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
initCloseListener();
|
||||
closeActivity.setOnClickListener(onClickListener);
|
||||
milestoneDueDate.setOnClickListener(this);
|
||||
|
||||
if(!connToInternet) {
|
||||
if (!connToInternet) {
|
||||
|
||||
createNewMilestoneButton.setEnabled(false);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
createNewMilestoneButton.setOnClickListener(createMilestoneListener);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void processNewMilestone() {
|
||||
|
@ -100,21 +100,21 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
|||
String newMilestoneTitle = milestoneTitle.getText().toString();
|
||||
String newMilestoneDescription = milestoneDescription.getText().toString();
|
||||
|
||||
if(!connToInternet) {
|
||||
if (!connToInternet) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
return;
|
||||
}
|
||||
|
||||
if(newMilestoneTitle.equals("")) {
|
||||
if (newMilestoneTitle.equals("")) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.milestoneNameErrorEmpty));
|
||||
return;
|
||||
}
|
||||
|
||||
if(!newMilestoneDescription.equals("")) {
|
||||
if (!newMilestoneDescription.equals("")) {
|
||||
|
||||
if(newMilestoneDescription.length() > 255) {
|
||||
if (newMilestoneDescription.length() > 255) {
|
||||
|
||||
Toasty.warning(ctx, getString(R.string.milestoneDescError));
|
||||
return;
|
||||
|
@ -122,10 +122,18 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
|||
}
|
||||
|
||||
disableProcessButton();
|
||||
createNewMilestone(repository.getOwner(), repository.getName(), newMilestoneTitle, newMilestoneDescription);
|
||||
createNewMilestone(
|
||||
repository.getOwner(),
|
||||
repository.getName(),
|
||||
newMilestoneTitle,
|
||||
newMilestoneDescription);
|
||||
}
|
||||
|
||||
private void createNewMilestone(String repoOwner, String repoName, String newMilestoneTitle, String newMilestoneDescription) {
|
||||
private void createNewMilestone(
|
||||
String repoOwner,
|
||||
String repoName,
|
||||
String newMilestoneTitle,
|
||||
String newMilestoneDescription) {
|
||||
|
||||
CreateMilestoneOption createMilestone = new CreateMilestoneOption();
|
||||
createMilestone.setDescription(newMilestoneDescription);
|
||||
|
@ -134,64 +142,76 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
|||
|
||||
Call<Milestone> call;
|
||||
|
||||
call = RetrofitClient.getApiInterface(ctx).issueCreateMilestone(repoOwner, repoName, createMilestone);
|
||||
call =
|
||||
RetrofitClient.getApiInterface(ctx)
|
||||
.issueCreateMilestone(repoOwner, repoName, createMilestone);
|
||||
|
||||
call.enqueue(new Callback<Milestone>() {
|
||||
call.enqueue(
|
||||
new Callback<Milestone>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Milestone> call, @NonNull retrofit2.Response<Milestone> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<Milestone> call,
|
||||
@NonNull retrofit2.Response<Milestone> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if (response.isSuccessful()) {
|
||||
|
||||
if(response.code() == 201) {
|
||||
if (response.code() == 201) {
|
||||
|
||||
Intent result = new Intent();
|
||||
result.putExtra("milestoneCreated", true);
|
||||
setResult(201, result);
|
||||
Toasty.success(ctx, getString(R.string.milestoneCreated));
|
||||
enableProcessButton();
|
||||
finish();
|
||||
Intent result = new Intent();
|
||||
result.putExtra("milestoneCreated", true);
|
||||
setResult(201, result);
|
||||
Toasty.success(ctx, getString(R.string.milestoneCreated));
|
||||
enableProcessButton();
|
||||
finish();
|
||||
}
|
||||
} else if (response.code() == 401) {
|
||||
|
||||
enableProcessButton();
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
} else {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
enableProcessButton();
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
}
|
||||
else {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Milestone> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
enableProcessButton();
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Milestone> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
enableProcessButton();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
if(v == milestoneDueDate) {
|
||||
if (v == milestoneDueDate) {
|
||||
|
||||
final Calendar c = Calendar.getInstance();
|
||||
int mYear = c.get(Calendar.YEAR);
|
||||
final int mMonth = c.get(Calendar.MONTH);
|
||||
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));
|
||||
currentDate = new Date(year - 1900, monthOfYear, dayOfMonth);
|
||||
}, mYear, mMonth, mDay);
|
||||
DatePickerDialog datePickerDialog =
|
||||
new DatePickerDialog(
|
||||
this,
|
||||
(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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void initCloseListener() {
|
||||
|
@ -214,5 +234,4 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
|||
super.onResume();
|
||||
repository.checkAccountSwitch(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@ import retrofit2.Callback;
|
|||
/**
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class CreateNewUserActivity extends BaseActivity {
|
||||
|
||||
private View.OnClickListener onClickListener;
|
||||
|
@ -40,12 +39,14 @@ public class CreateNewUserActivity extends BaseActivity {
|
|||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
ActivityCreateNewUserBinding activityCreateNewUserBinding = ActivityCreateNewUserBinding.inflate(getLayoutInflater());
|
||||
ActivityCreateNewUserBinding activityCreateNewUserBinding =
|
||||
ActivityCreateNewUserBinding.inflate(getLayoutInflater());
|
||||
setContentView(activityCreateNewUserBinding.getRoot());
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
InputMethodManager imm =
|
||||
(InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
ImageView closeActivity = activityCreateNewUserBinding.close;
|
||||
createUserButton = activityCreateNewUserBinding.createUserButton;
|
||||
|
@ -61,11 +62,10 @@ public class CreateNewUserActivity extends BaseActivity {
|
|||
initCloseListener();
|
||||
closeActivity.setOnClickListener(onClickListener);
|
||||
|
||||
if(!connToInternet) {
|
||||
if (!connToInternet) {
|
||||
|
||||
disableProcessButton();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
createUserButton.setOnClickListener(createNewUserListener);
|
||||
}
|
||||
|
@ -80,31 +80,33 @@ public class CreateNewUserActivity extends BaseActivity {
|
|||
String newUserEmail = userEmail.getText().toString().trim();
|
||||
String newUserPassword = userPassword.getText().toString();
|
||||
|
||||
if(!connToInternet) {
|
||||
if (!connToInternet) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
return;
|
||||
}
|
||||
|
||||
if(newFullName.equals("") || newUserName.equals("") | newUserEmail.equals("") || newUserPassword.equals("")) {
|
||||
if (newFullName.equals("")
|
||||
|| newUserName.equals("") | newUserEmail.equals("")
|
||||
|| newUserPassword.equals("")) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.emptyFields));
|
||||
return;
|
||||
}
|
||||
|
||||
if(!AppUtil.checkStrings(newFullName)) {
|
||||
if (!AppUtil.checkStrings(newFullName)) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.userInvalidFullName));
|
||||
return;
|
||||
}
|
||||
|
||||
if(!AppUtil.checkStringsWithAlphaNumeric(newUserName)) {
|
||||
if (!AppUtil.checkStringsWithAlphaNumeric(newUserName)) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.userInvalidUserName));
|
||||
return;
|
||||
}
|
||||
|
||||
if(!Patterns.EMAIL_ADDRESS.matcher(newUserEmail).matches()) {
|
||||
if (!Patterns.EMAIL_ADDRESS.matcher(newUserEmail).matches()) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.userInvalidEmail));
|
||||
return;
|
||||
|
@ -114,7 +116,8 @@ public class CreateNewUserActivity extends BaseActivity {
|
|||
createNewUser(newFullName, newUserName, newUserEmail, newUserPassword);
|
||||
}
|
||||
|
||||
private void createNewUser(String newFullName, String newUserName, String newUserEmail, String newUserPassword) {
|
||||
private void createNewUser(
|
||||
String newFullName, String newUserName, String newUserEmail, String newUserPassword) {
|
||||
|
||||
CreateUserOption createUser = new CreateUserOption();
|
||||
createUser.setEmail(newUserEmail);
|
||||
|
@ -125,52 +128,48 @@ public class CreateNewUserActivity extends BaseActivity {
|
|||
|
||||
Call<User> call = RetrofitClient.getApiInterface(ctx).adminCreateUser(createUser);
|
||||
|
||||
call.enqueue(new Callback<User>() {
|
||||
call.enqueue(
|
||||
new Callback<User>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<User> call, @NonNull retrofit2.Response<User> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<User> call, @NonNull retrofit2.Response<User> response) {
|
||||
|
||||
if(response.code() == 201) {
|
||||
if (response.code() == 201) {
|
||||
|
||||
Toasty.success(ctx, getString(R.string.userCreatedText));
|
||||
enableProcessButton();
|
||||
finish();
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
Toasty.success(ctx, getString(R.string.userCreatedText));
|
||||
enableProcessButton();
|
||||
finish();
|
||||
} else if (response.code() == 401) {
|
||||
|
||||
enableProcessButton();
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
enableProcessButton();
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
} else if (response.code() == 403) {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
||||
} else if (response.code() == 404) {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
||||
}
|
||||
else if(response.code() == 422) {
|
||||
enableProcessButton();
|
||||
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
||||
} else if (response.code() == 422) {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.warning(ctx, ctx.getString(R.string.userExistsError));
|
||||
}
|
||||
else {
|
||||
enableProcessButton();
|
||||
Toasty.warning(ctx, ctx.getString(R.string.userExistsError));
|
||||
} else {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<User> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
enableProcessButton();
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<User> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
enableProcessButton();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initCloseListener() {
|
||||
|
@ -187,5 +186,4 @@ public class CreateNewUserActivity extends BaseActivity {
|
|||
|
||||
createUserButton.setEnabled(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@ import retrofit2.Callback;
|
|||
/**
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class CreateOrganizationActivity extends BaseActivity {
|
||||
|
||||
public ImageView closeActivity;
|
||||
|
@ -43,12 +42,14 @@ public class CreateOrganizationActivity extends BaseActivity {
|
|||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
ActivityCreateOrganizationBinding activityCreateOrganizationBinding = ActivityCreateOrganizationBinding.inflate(getLayoutInflater());
|
||||
ActivityCreateOrganizationBinding activityCreateOrganizationBinding =
|
||||
ActivityCreateOrganizationBinding.inflate(getLayoutInflater());
|
||||
setContentView(activityCreateOrganizationBinding.getRoot());
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
InputMethodManager imm =
|
||||
(InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
closeActivity = activityCreateOrganizationBinding.close;
|
||||
orgName = activityCreateOrganizationBinding.newOrganizationName;
|
||||
|
@ -58,31 +59,30 @@ public class CreateOrganizationActivity extends BaseActivity {
|
|||
assert imm != null;
|
||||
imm.showSoftInput(orgName, InputMethodManager.SHOW_IMPLICIT);
|
||||
|
||||
orgDesc.setOnTouchListener((touchView, motionEvent) -> {
|
||||
orgDesc.setOnTouchListener(
|
||||
(touchView, motionEvent) -> {
|
||||
touchView.getParent().requestDisallowInterceptTouchEvent(true);
|
||||
|
||||
touchView.getParent().requestDisallowInterceptTouchEvent(true);
|
||||
if ((motionEvent.getAction() & MotionEvent.ACTION_UP) != 0
|
||||
&& (motionEvent.getActionMasked() & MotionEvent.ACTION_UP) != 0) {
|
||||
|
||||
if((motionEvent.getAction() & MotionEvent.ACTION_UP) != 0 && (motionEvent.getActionMasked() & MotionEvent.ACTION_UP) != 0) {
|
||||
|
||||
touchView.getParent().requestDisallowInterceptTouchEvent(false);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
touchView.getParent().requestDisallowInterceptTouchEvent(false);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
initCloseListener();
|
||||
closeActivity.setOnClickListener(onClickListener);
|
||||
|
||||
createOrganizationButton = activityCreateOrganizationBinding.createNewOrganizationButton;
|
||||
|
||||
if(!connToInternet) {
|
||||
if (!connToInternet) {
|
||||
|
||||
createOrganizationButton.setEnabled(false);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
createOrganizationButton.setOnClickListener(createOrgListener);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void initCloseListener() {
|
||||
|
@ -97,35 +97,32 @@ public class CreateOrganizationActivity extends BaseActivity {
|
|||
String newOrgName = orgName.getText().toString();
|
||||
String newOrgDesc = orgDesc.getText().toString();
|
||||
|
||||
if(!connToInternet) {
|
||||
if (!connToInternet) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
return;
|
||||
}
|
||||
|
||||
if(!newOrgDesc.equals("")) {
|
||||
if (!newOrgDesc.equals("")) {
|
||||
|
||||
if(newOrgDesc.length() > 255) {
|
||||
if (newOrgDesc.length() > 255) {
|
||||
|
||||
Toasty.warning(ctx, getString(R.string.orgDescError));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(newOrgName.equals("")) {
|
||||
if (newOrgName.equals("")) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.orgNameErrorEmpty));
|
||||
}
|
||||
else if(!AppUtil.checkStrings(newOrgName)) {
|
||||
} else if (!AppUtil.checkStrings(newOrgName)) {
|
||||
|
||||
Toasty.warning(ctx, getString(R.string.orgNameErrorInvalid));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
disableProcessButton();
|
||||
createNewOrganization(newOrgName, newOrgDesc);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void createNewOrganization(String orgName, String orgDesc) {
|
||||
|
@ -136,55 +133,52 @@ public class CreateOrganizationActivity extends BaseActivity {
|
|||
|
||||
Call<Organization> call = RetrofitClient.getApiInterface(ctx).orgCreate(createOrganization);
|
||||
|
||||
call.enqueue(new Callback<Organization>() {
|
||||
call.enqueue(
|
||||
new Callback<Organization>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Organization> call, @NonNull retrofit2.Response<Organization> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<Organization> call,
|
||||
@NonNull retrofit2.Response<Organization> response) {
|
||||
|
||||
if(response.code() == 201) {
|
||||
OrganizationsFragment.orgCreated = true;
|
||||
enableProcessButton();
|
||||
Toasty.success(ctx, getString(R.string.orgCreated));
|
||||
finish();
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
if (response.code() == 201) {
|
||||
OrganizationsFragment.orgCreated = true;
|
||||
enableProcessButton();
|
||||
Toasty.success(ctx, getString(R.string.orgCreated));
|
||||
finish();
|
||||
} else if (response.code() == 401) {
|
||||
|
||||
enableProcessButton();
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
}
|
||||
else if(response.code() == 409) {
|
||||
enableProcessButton();
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
} else if (response.code() == 409) {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.warning(ctx, getString(R.string.orgExistsError));
|
||||
}
|
||||
else if(response.code() == 422) {
|
||||
enableProcessButton();
|
||||
Toasty.warning(ctx, getString(R.string.orgExistsError));
|
||||
} else if (response.code() == 422) {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.warning(ctx, getString(R.string.orgExistsError));
|
||||
}
|
||||
else {
|
||||
enableProcessButton();
|
||||
Toasty.warning(ctx, getString(R.string.orgExistsError));
|
||||
} else {
|
||||
|
||||
if(response.code() == 404) {
|
||||
if (response.code() == 404) {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.warning(ctx, getString(R.string.apiNotFound));
|
||||
enableProcessButton();
|
||||
Toasty.warning(ctx, getString(R.string.apiNotFound));
|
||||
} else {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Organization> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Organization> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
enableProcessButton();
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
private void disableProcessButton() {
|
||||
|
@ -196,5 +190,4 @@ public class CreateOrganizationActivity extends BaseActivity {
|
|||
|
||||
createOrganizationButton.setEnabled(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,6 +11,12 @@ import android.widget.ImageView;
|
|||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
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 org.gitnex.tea4j.v2.models.Branch;
|
||||
import org.gitnex.tea4j.v2.models.CreatePullRequestOption;
|
||||
import org.gitnex.tea4j.v2.models.Label;
|
||||
|
@ -26,20 +32,14 @@ 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;
|
||||
|
||||
/**
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class CreatePullRequestActivity extends BaseActivity implements LabelsListAdapter.LabelsListAdapterListener {
|
||||
public class CreatePullRequestActivity extends BaseActivity
|
||||
implements LabelsListAdapter.LabelsListAdapterListener {
|
||||
|
||||
private final List<String> assignees = new ArrayList<>();
|
||||
LinkedHashMap<String, Milestone> milestonesList = new LinkedHashMap<>();
|
||||
|
@ -63,24 +63,27 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
|||
viewBinding = ActivityCreatePrBinding.inflate(getLayoutInflater());
|
||||
setContentView(viewBinding.getRoot());
|
||||
|
||||
materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx, R.style.ThemeOverlay_Material3_Dialog_Alert);
|
||||
materialAlertDialogBuilder =
|
||||
new MaterialAlertDialogBuilder(ctx, R.style.ThemeOverlay_Material3_Dialog_Alert);
|
||||
|
||||
repository = RepositoryContext.fromIntent(getIntent());
|
||||
|
||||
int resultLimit = Constants.getCurrentResultLimit(ctx);
|
||||
|
||||
viewBinding.prBody.setOnTouchListener((touchView, motionEvent) -> {
|
||||
viewBinding.prBody.setOnTouchListener(
|
||||
(touchView, motionEvent) -> {
|
||||
touchView.getParent().requestDisallowInterceptTouchEvent(true);
|
||||
|
||||
touchView.getParent().requestDisallowInterceptTouchEvent(true);
|
||||
if ((motionEvent.getAction() & MotionEvent.ACTION_UP) != 0
|
||||
&& (motionEvent.getActionMasked() & MotionEvent.ACTION_UP) != 0) {
|
||||
|
||||
if((motionEvent.getAction() & MotionEvent.ACTION_UP) != 0 && (motionEvent.getActionMasked() & MotionEvent.ACTION_UP) != 0) {
|
||||
touchView.getParent().requestDisallowInterceptTouchEvent(false);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
touchView.getParent().requestDisallowInterceptTouchEvent(false);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
labelsAdapter = new LabelsListAdapter(labelsList, CreatePullRequestActivity.this, labelsIds);
|
||||
labelsAdapter =
|
||||
new LabelsListAdapter(labelsList, CreatePullRequestActivity.this, labelsIds);
|
||||
|
||||
ImageView closeActivity = findViewById(R.id.close);
|
||||
|
||||
|
@ -98,7 +101,7 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
|||
|
||||
viewBinding.createPr.setOnClickListener(createPr -> processPullRequest());
|
||||
|
||||
if(!repository.getPermissions().isPush()) {
|
||||
if (!repository.getPermissions().isPush()) {
|
||||
viewBinding.prDueDateLayout.setVisibility(View.GONE);
|
||||
viewBinding.prLabelsLayout.setVisibility(View.GONE);
|
||||
viewBinding.milestonesSpinnerLayout.setVisibility(View.GONE);
|
||||
|
@ -114,37 +117,39 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
|||
|
||||
assignees.add("");
|
||||
|
||||
if(labelsIds.size() == 0) {
|
||||
if (labelsIds.size() == 0) {
|
||||
|
||||
labelsIds.add(0);
|
||||
}
|
||||
|
||||
if(prTitle.matches("")) {
|
||||
if (prTitle.matches("")) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.titleError));
|
||||
}
|
||||
else if(mergeInto.matches("")) {
|
||||
} else if (mergeInto.matches("")) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.mergeIntoError));
|
||||
}
|
||||
else if(pullFrom.matches("")) {
|
||||
} else if (pullFrom.matches("")) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.pullFromError));
|
||||
}
|
||||
else if(pullFrom.equals(mergeInto)) {
|
||||
} else if (pullFrom.equals(mergeInto)) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.sameBranchesError));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
createPullRequest(prTitle, prDescription, mergeInto, pullFrom, milestoneId, assignees);
|
||||
}
|
||||
}
|
||||
|
||||
private void createPullRequest(String prTitle, String prDescription, String mergeInto, String pullFrom, int milestoneId, List<String> assignees) {
|
||||
private void createPullRequest(
|
||||
String prTitle,
|
||||
String prDescription,
|
||||
String mergeInto,
|
||||
String pullFrom,
|
||||
int milestoneId,
|
||||
List<String> assignees) {
|
||||
|
||||
ArrayList<Long> labelIds = new ArrayList<>();
|
||||
for(Integer i : labelsIds) {
|
||||
for (Integer i : labelsIds) {
|
||||
labelIds.add((long) i);
|
||||
}
|
||||
|
||||
|
@ -158,47 +163,51 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
|||
createPullRequest.setLabels(labelIds);
|
||||
createPullRequest.setDueDate(currentDate);
|
||||
|
||||
Call<PullRequest> transferCall = RetrofitClient.getApiInterface(ctx).repoCreatePullRequest(repository.getOwner(), repository.getName(), createPullRequest);
|
||||
Call<PullRequest> transferCall =
|
||||
RetrofitClient.getApiInterface(ctx)
|
||||
.repoCreatePullRequest(
|
||||
repository.getOwner(), repository.getName(), createPullRequest);
|
||||
|
||||
transferCall.enqueue(new Callback<>() {
|
||||
transferCall.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<PullRequest> call, @NonNull retrofit2.Response<PullRequest> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<PullRequest> call,
|
||||
@NonNull retrofit2.Response<PullRequest> response) {
|
||||
|
||||
disableProcessButton();
|
||||
disableProcessButton();
|
||||
|
||||
if(response.code() == 201) {
|
||||
if (response.code() == 201) {
|
||||
|
||||
Toasty.success(ctx, getString(R.string.prCreateSuccess));
|
||||
RepoDetailActivity.updateRepo = true;
|
||||
PullRequestsFragment.resumePullRequests = true;
|
||||
MainActivity.reloadRepos = true;
|
||||
finish();
|
||||
}
|
||||
else if(response.code() == 409 || response.message().equals("Conflict")) {
|
||||
Toasty.success(ctx, getString(R.string.prCreateSuccess));
|
||||
RepoDetailActivity.updateRepo = true;
|
||||
PullRequestsFragment.resumePullRequests = true;
|
||||
MainActivity.reloadRepos = true;
|
||||
finish();
|
||||
} else if (response.code() == 409
|
||||
|| response.message().equals("Conflict")) {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, getString(R.string.prAlreadyExists));
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, getString(R.string.prAlreadyExists));
|
||||
} else if (response.code() == 404) {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, getString(R.string.apiNotFound));
|
||||
}
|
||||
else {
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, getString(R.string.apiNotFound));
|
||||
} else {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<PullRequest> call, @NonNull Throwable t) {
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<PullRequest> call, @NonNull Throwable t) {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -217,104 +226,141 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
|||
private void showLabels() {
|
||||
|
||||
viewBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
CustomLabelsSelectionDialogBinding labelsBinding = CustomLabelsSelectionDialogBinding.inflate(LayoutInflater.from(ctx));
|
||||
CustomLabelsSelectionDialogBinding labelsBinding =
|
||||
CustomLabelsSelectionDialogBinding.inflate(LayoutInflater.from(ctx));
|
||||
View view = labelsBinding.getRoot();
|
||||
materialAlertDialogBuilder.setView(view);
|
||||
|
||||
materialAlertDialogBuilder.setNeutralButton(R.string.close, null);
|
||||
LabelsActions.getRepositoryLabels(ctx, repository.getOwner(), repository.getName(), labelsList, materialAlertDialogBuilder, labelsAdapter, labelsBinding, viewBinding.progressBar);
|
||||
LabelsActions.getRepositoryLabels(
|
||||
ctx,
|
||||
repository.getOwner(),
|
||||
repository.getName(),
|
||||
labelsList,
|
||||
materialAlertDialogBuilder,
|
||||
labelsAdapter,
|
||||
labelsBinding,
|
||||
viewBinding.progressBar);
|
||||
}
|
||||
|
||||
private void getBranches(String repoOwner, String repoName) {
|
||||
|
||||
Call<List<Branch>> call = RetrofitClient.getApiInterface(ctx).repoListBranches(repoOwner, repoName, null, null);
|
||||
Call<List<Branch>> call =
|
||||
RetrofitClient.getApiInterface(ctx)
|
||||
.repoListBranches(repoOwner, repoName, null, null);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Branch>> call, @NonNull retrofit2.Response<List<Branch>> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<List<Branch>> call,
|
||||
@NonNull retrofit2.Response<List<Branch>> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if (response.isSuccessful()) {
|
||||
|
||||
if(response.code() == 200) {
|
||||
if (response.code() == 200) {
|
||||
|
||||
List<Branch> branchesList_ = response.body();
|
||||
assert branchesList_ != null;
|
||||
List<Branch> branchesList_ = response.body();
|
||||
assert branchesList_ != null;
|
||||
|
||||
for(Branch i : branchesList_) {
|
||||
branchesList.add(i.getName());
|
||||
for (Branch i : branchesList_) {
|
||||
branchesList.add(i.getName());
|
||||
}
|
||||
|
||||
ArrayAdapter<String> adapter =
|
||||
new ArrayAdapter<>(
|
||||
CreatePullRequestActivity.this,
|
||||
R.layout.list_spinner_items,
|
||||
branchesList);
|
||||
|
||||
viewBinding.mergeIntoBranchSpinner.setAdapter(adapter);
|
||||
viewBinding.pullFromBranchSpinner.setAdapter(adapter);
|
||||
enableProcessButton();
|
||||
}
|
||||
}
|
||||
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<>(CreatePullRequestActivity.this, R.layout.list_spinner_items, branchesList);
|
||||
|
||||
viewBinding.mergeIntoBranchSpinner.setAdapter(adapter);
|
||||
viewBinding.pullFromBranchSpinner.setAdapter(adapter);
|
||||
enableProcessButton();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Branch>> call, @NonNull Throwable t) {
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Branch>> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
Toasty.error(ctx, getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void getMilestones(String repoOwner, String repoName, int resultLimit) {
|
||||
|
||||
String msState = "open";
|
||||
Call<List<Milestone>> call = RetrofitClient.getApiInterface(ctx).issueGetMilestonesList(repoOwner, repoName, msState, null, 1, resultLimit);
|
||||
Call<List<Milestone>> call =
|
||||
RetrofitClient.getApiInterface(ctx)
|
||||
.issueGetMilestonesList(repoOwner, repoName, msState, null, 1, resultLimit);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Milestone>> call, @NonNull retrofit2.Response<List<Milestone>> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<List<Milestone>> call,
|
||||
@NonNull retrofit2.Response<List<Milestone>> response) {
|
||||
|
||||
if(response.code() == 200) {
|
||||
if (response.code() == 200) {
|
||||
|
||||
List<Milestone> milestonesList_ = response.body();
|
||||
List<Milestone> milestonesList_ = response.body();
|
||||
|
||||
milestonesList.put(getString(R.string.issueCreatedNoMilestone), new Milestone().id(0L).title(getString(R.string.issueCreatedNoMilestone)));
|
||||
assert milestonesList_ != null;
|
||||
milestonesList.put(
|
||||
getString(R.string.issueCreatedNoMilestone),
|
||||
new Milestone()
|
||||
.id(0L)
|
||||
.title(getString(R.string.issueCreatedNoMilestone)));
|
||||
assert milestonesList_ != null;
|
||||
|
||||
if(milestonesList_.size() > 0) {
|
||||
if (milestonesList_.size() > 0) {
|
||||
|
||||
for(Milestone milestone : milestonesList_) {
|
||||
for (Milestone milestone : milestonesList_) {
|
||||
|
||||
//Don't translate "open" is a enum
|
||||
if(milestone.getState().equals("open")) {
|
||||
milestonesList.put(milestone.getTitle(), milestone);
|
||||
// Don't translate "open" is a enum
|
||||
if (milestone.getState().equals("open")) {
|
||||
milestonesList.put(milestone.getTitle(), milestone);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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) -> {
|
||||
if (position == 0) {
|
||||
milestoneId = 0;
|
||||
} else if (view instanceof TextView) {
|
||||
milestoneId =
|
||||
Math.toIntExact(
|
||||
Objects.requireNonNull(
|
||||
milestonesList.get(
|
||||
((TextView)
|
||||
view)
|
||||
.getText()
|
||||
.toString()))
|
||||
.getId());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<>(CreatePullRequestActivity.this, R.layout.list_spinner_items, new ArrayList<>(milestonesList.keySet()));
|
||||
@Override
|
||||
public void onFailure(
|
||||
@NonNull Call<List<Milestone>> call, @NonNull Throwable t) {
|
||||
|
||||
viewBinding.milestonesSpinner.setAdapter(adapter);
|
||||
enableProcessButton();
|
||||
|
||||
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<Milestone>> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
Toasty.error(ctx, getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setDueDate() {
|
||||
|
@ -324,10 +370,21 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
|||
final int mMonth = c.get(Calendar.MONTH);
|
||||
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));
|
||||
currentDate = new Date(year - 1900, monthOfYear, dayOfMonth);
|
||||
}, mYear, mMonth, mDay);
|
||||
DatePickerDialog datePickerDialog =
|
||||
new DatePickerDialog(
|
||||
this,
|
||||
(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();
|
||||
}
|
||||
|
||||
|
@ -351,5 +408,4 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
|||
super.onResume();
|
||||
repository.checkAccountSwitch(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@ import android.widget.CheckBox;
|
|||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import androidx.annotation.NonNull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.gitnex.tea4j.v2.models.Branch;
|
||||
import org.gitnex.tea4j.v2.models.CreateReleaseOption;
|
||||
import org.gitnex.tea4j.v2.models.CreateTagOption;
|
||||
|
@ -27,15 +29,12 @@ import org.mian.gitnex.helpers.AlertDialogs;
|
|||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
/**
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class CreateReleaseActivity extends BaseActivity {
|
||||
|
||||
public ImageView closeActivity;
|
||||
|
@ -59,12 +58,14 @@ public class CreateReleaseActivity extends BaseActivity {
|
|||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
ActivityCreateReleaseBinding activityCreateReleaseBinding = ActivityCreateReleaseBinding.inflate(getLayoutInflater());
|
||||
ActivityCreateReleaseBinding activityCreateReleaseBinding =
|
||||
ActivityCreateReleaseBinding.inflate(getLayoutInflater());
|
||||
setContentView(activityCreateReleaseBinding.getRoot());
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
InputMethodManager imm =
|
||||
(InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
repository = RepositoryContext.fromIntent(getIntent());
|
||||
|
||||
|
@ -79,16 +80,17 @@ public class CreateReleaseActivity extends BaseActivity {
|
|||
assert imm != null;
|
||||
imm.showSoftInput(releaseTitle, InputMethodManager.SHOW_IMPLICIT);
|
||||
|
||||
releaseContent.setOnTouchListener((touchView, motionEvent) -> {
|
||||
releaseContent.setOnTouchListener(
|
||||
(touchView, motionEvent) -> {
|
||||
touchView.getParent().requestDisallowInterceptTouchEvent(true);
|
||||
|
||||
touchView.getParent().requestDisallowInterceptTouchEvent(true);
|
||||
if ((motionEvent.getAction() & MotionEvent.ACTION_UP) != 0
|
||||
&& (motionEvent.getActionMasked() & MotionEvent.ACTION_UP) != 0) {
|
||||
|
||||
if((motionEvent.getAction() & MotionEvent.ACTION_UP) != 0 && (motionEvent.getActionMasked() & MotionEvent.ACTION_UP) != 0) {
|
||||
|
||||
touchView.getParent().requestDisallowInterceptTouchEvent(false);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
touchView.getParent().requestDisallowInterceptTouchEvent(false);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
initCloseListener();
|
||||
closeActivity.setOnClickListener(onClickListener);
|
||||
|
@ -100,11 +102,10 @@ public class CreateReleaseActivity extends BaseActivity {
|
|||
createNewTag = activityCreateReleaseBinding.createNewTag;
|
||||
disableProcessButton();
|
||||
|
||||
if(!connToInternet) {
|
||||
if (!connToInternet) {
|
||||
|
||||
disableProcessButton();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
createNewRelease.setOnClickListener(createReleaseListener);
|
||||
}
|
||||
|
@ -116,19 +117,20 @@ public class CreateReleaseActivity extends BaseActivity {
|
|||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
String tagName = releaseTagName.getText().toString();
|
||||
String message = releaseTitle.getText().toString() + "\n\n" + releaseContent.getText().toString();
|
||||
String message =
|
||||
releaseTitle.getText().toString() + "\n\n" + releaseContent.getText().toString();
|
||||
|
||||
if(!connToInternet) {
|
||||
if (!connToInternet) {
|
||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
return;
|
||||
}
|
||||
|
||||
if(tagName.equals("")) {
|
||||
if (tagName.equals("")) {
|
||||
Toasty.error(ctx, getString(R.string.tagNameErrorEmpty));
|
||||
return;
|
||||
}
|
||||
|
||||
if(selectedBranch == null) {
|
||||
if (selectedBranch == null) {
|
||||
Toasty.error(ctx, getString(R.string.selectBranchError));
|
||||
return;
|
||||
}
|
||||
|
@ -140,45 +142,46 @@ public class CreateReleaseActivity extends BaseActivity {
|
|||
createReleaseJson.setTagName(tagName);
|
||||
createReleaseJson.setTarget(selectedBranch);
|
||||
|
||||
Call<Tag> call = RetrofitClient.getApiInterface(ctx).repoCreateTag(repository.getOwner(), repository.getName(), createReleaseJson);
|
||||
Call<Tag> call =
|
||||
RetrofitClient.getApiInterface(ctx)
|
||||
.repoCreateTag(
|
||||
repository.getOwner(), repository.getName(), createReleaseJson);
|
||||
|
||||
call.enqueue(new Callback<Tag>() {
|
||||
call.enqueue(
|
||||
new Callback<Tag>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Tag> call, @NonNull retrofit2.Response<Tag> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<Tag> call, @NonNull retrofit2.Response<Tag> response) {
|
||||
|
||||
if(response.code() == 201) {
|
||||
if (response.code() == 201) {
|
||||
|
||||
Intent result = new Intent();
|
||||
result.putExtra("updateReleases", true);
|
||||
setResult(201, result);
|
||||
Toasty.success(ctx, getString(R.string.tagCreated));
|
||||
finish();
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
enableProcessButton();
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
enableProcessButton();
|
||||
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
||||
}
|
||||
else {
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
Intent result = new Intent();
|
||||
result.putExtra("updateReleases", true);
|
||||
setResult(201, result);
|
||||
Toasty.success(ctx, getString(R.string.tagCreated));
|
||||
finish();
|
||||
} else if (response.code() == 401) {
|
||||
enableProcessButton();
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
} else if (response.code() == 403) {
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
||||
} else if (response.code() == 404) {
|
||||
enableProcessButton();
|
||||
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
||||
} else {
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Tag> call, @NonNull Throwable t) {
|
||||
Log.e("onFailure", t.toString());
|
||||
enableProcessButton();
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Tag> call, @NonNull Throwable t) {
|
||||
Log.e("onFailure", t.toString());
|
||||
enableProcessButton();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void processNewRelease() {
|
||||
|
@ -192,36 +195,51 @@ public class CreateReleaseActivity extends BaseActivity {
|
|||
boolean newReleaseType = releaseType.isChecked();
|
||||
boolean newReleaseDraft = releaseDraft.isChecked();
|
||||
|
||||
if(!connToInternet) {
|
||||
if (!connToInternet) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
return;
|
||||
}
|
||||
|
||||
if(newReleaseTitle.equals("")) {
|
||||
if (newReleaseTitle.equals("")) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.titleErrorEmpty));
|
||||
return;
|
||||
}
|
||||
|
||||
if(newReleaseTagName.equals("")) {
|
||||
if (newReleaseTagName.equals("")) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.tagNameErrorEmpty));
|
||||
return;
|
||||
}
|
||||
|
||||
if(checkBranch == null) {
|
||||
if (checkBranch == null) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.selectBranchError));
|
||||
return;
|
||||
}
|
||||
|
||||
disableProcessButton();
|
||||
createNewReleaseFunc(repository.getOwner(), repository.getName(), newReleaseTagName, newReleaseTitle, newReleaseContent, selectedBranch, newReleaseType, newReleaseDraft);
|
||||
createNewReleaseFunc(
|
||||
repository.getOwner(),
|
||||
repository.getName(),
|
||||
newReleaseTagName,
|
||||
newReleaseTitle,
|
||||
newReleaseContent,
|
||||
selectedBranch,
|
||||
newReleaseType,
|
||||
newReleaseDraft);
|
||||
}
|
||||
|
||||
private void createNewReleaseFunc(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) {
|
||||
|
||||
CreateReleaseOption createReleaseJson = new CreateReleaseOption();
|
||||
createReleaseJson.setName(newReleaseTitle);
|
||||
|
@ -231,91 +249,98 @@ public class CreateReleaseActivity extends BaseActivity {
|
|||
createReleaseJson.setPrerelease(newReleaseType);
|
||||
createReleaseJson.setTargetCommitish(selectedBranch);
|
||||
|
||||
Call<Release> call = RetrofitClient.getApiInterface(ctx).repoCreateRelease(repoOwner, repoName, createReleaseJson);
|
||||
Call<Release> call =
|
||||
RetrofitClient.getApiInterface(ctx)
|
||||
.repoCreateRelease(repoOwner, repoName, createReleaseJson);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Release> call, @NonNull retrofit2.Response<Release> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<Release> call,
|
||||
@NonNull retrofit2.Response<Release> response) {
|
||||
|
||||
if(response.code() == 201) {
|
||||
if (response.code() == 201) {
|
||||
|
||||
Intent result = new Intent();
|
||||
result.putExtra("updateReleases", true);
|
||||
setResult(201, result);
|
||||
Toasty.success(ctx, getString(R.string.releaseCreatedText));
|
||||
finish();
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
Intent result = new Intent();
|
||||
result.putExtra("updateReleases", true);
|
||||
setResult(201, result);
|
||||
Toasty.success(ctx, getString(R.string.releaseCreatedText));
|
||||
finish();
|
||||
} else if (response.code() == 401) {
|
||||
|
||||
enableProcessButton();
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
enableProcessButton();
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
} else if (response.code() == 403) {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
||||
} else if (response.code() == 404) {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
||||
}
|
||||
else {
|
||||
enableProcessButton();
|
||||
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
||||
} else {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Release> call, @NonNull Throwable t) {
|
||||
enableProcessButton();
|
||||
}
|
||||
});
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Release> call, @NonNull Throwable t) {
|
||||
enableProcessButton();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void getBranches(final String repoOwner, final String repoName) {
|
||||
|
||||
Call<List<Branch>> call = RetrofitClient.getApiInterface(ctx).repoListBranches(repoOwner, repoName, null, null);
|
||||
Call<List<Branch>> call =
|
||||
RetrofitClient.getApiInterface(ctx)
|
||||
.repoListBranches(repoOwner, repoName, null, null);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Branch>> call, @NonNull retrofit2.Response<List<Branch>> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<List<Branch>> call,
|
||||
@NonNull retrofit2.Response<List<Branch>> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if (response.isSuccessful()) {
|
||||
|
||||
if(response.code() == 200) {
|
||||
if (response.code() == 200) {
|
||||
|
||||
List<Branch> branchesList_ = response.body();
|
||||
List<Branch> branchesList_ = response.body();
|
||||
|
||||
assert branchesList_ != null;
|
||||
for(Branch i : branchesList_) {
|
||||
branchesList.add(i.getName());
|
||||
assert branchesList_ != null;
|
||||
for (Branch i : branchesList_) {
|
||||
branchesList.add(i.getName());
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
} else if (response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Branch>> call, @NonNull Throwable t) {
|
||||
}
|
||||
});
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Branch>> call, @NonNull Throwable t) {}
|
||||
});
|
||||
}
|
||||
|
||||
private void initCloseListener() {
|
||||
|
@ -338,5 +363,4 @@ public class CreateReleaseActivity extends BaseActivity {
|
|||
super.onResume();
|
||||
repository.checkAccountSwitch(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,6 +14,10 @@ import android.widget.CheckBox;
|
|||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import androidx.annotation.NonNull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
import org.gitnex.tea4j.v2.models.CreateRepoOption;
|
||||
import org.gitnex.tea4j.v2.models.Organization;
|
||||
import org.gitnex.tea4j.v2.models.Repository;
|
||||
|
@ -23,20 +27,15 @@ import org.mian.gitnex.databinding.ActivityCreateRepoBinding;
|
|||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
/**
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class CreateRepoActivity extends BaseActivity {
|
||||
|
||||
//https://github.com/go-gitea/gitea/blob/52cfd2743c0e85b36081cf80a850e6a5901f1865/models/repo.go#L964-L967
|
||||
// https://github.com/go-gitea/gitea/blob/52cfd2743c0e85b36081cf80a850e6a5901f1865/models/repo.go#L964-L967
|
||||
final List<String> reservedRepoNames = Arrays.asList(".", "..");
|
||||
final Pattern reservedRepoPatterns = Pattern.compile("\\.(git|wiki)$");
|
||||
public ImageView closeActivity;
|
||||
|
@ -56,14 +55,16 @@ public class CreateRepoActivity extends BaseActivity {
|
|||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
ActivityCreateRepoBinding activityCreateRepoBinding = ActivityCreateRepoBinding.inflate(getLayoutInflater());
|
||||
ActivityCreateRepoBinding activityCreateRepoBinding =
|
||||
ActivityCreateRepoBinding.inflate(getLayoutInflater());
|
||||
setContentView(activityCreateRepoBinding.getRoot());
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(ctx);
|
||||
|
||||
loginUid = getAccount().getAccount().getUserName();
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
InputMethodManager imm =
|
||||
(InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
closeActivity = activityCreateRepoBinding.close;
|
||||
repoName = activityCreateRepoBinding.newRepoName;
|
||||
|
@ -83,11 +84,10 @@ public class CreateRepoActivity extends BaseActivity {
|
|||
createRepo = activityCreateRepoBinding.createNewRepoButton;
|
||||
disableProcessButton();
|
||||
|
||||
if(!connToInternet) {
|
||||
if (!connToInternet) {
|
||||
|
||||
disableProcessButton();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
createRepo.setOnClickListener(createRepoListener);
|
||||
}
|
||||
|
@ -101,49 +101,49 @@ public class CreateRepoActivity extends BaseActivity {
|
|||
String newRepoDesc = repoDesc.getText().toString();
|
||||
boolean newRepoAccess = repoAccess.isChecked();
|
||||
|
||||
if(!connToInternet) {
|
||||
if (!connToInternet) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
return;
|
||||
}
|
||||
|
||||
if(!newRepoDesc.equals("")) {
|
||||
if (!newRepoDesc.equals("")) {
|
||||
|
||||
if(newRepoDesc.length() > 255) {
|
||||
if (newRepoDesc.length() > 255) {
|
||||
|
||||
Toasty.warning(ctx, getString(R.string.repoDescError));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(newRepoName.equals("")) {
|
||||
if (newRepoName.equals("")) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.repoNameErrorEmpty));
|
||||
}
|
||||
else if(!AppUtil.checkStrings(newRepoName)) {
|
||||
} else if (!AppUtil.checkStrings(newRepoName)) {
|
||||
|
||||
Toasty.warning(ctx, getString(R.string.repoNameErrorInvalid));
|
||||
}
|
||||
else if(reservedRepoNames.contains(newRepoName)) {
|
||||
} else if (reservedRepoNames.contains(newRepoName)) {
|
||||
|
||||
Toasty.warning(ctx, getString(R.string.repoNameErrorReservedName));
|
||||
}
|
||||
else if(reservedRepoPatterns.matcher(newRepoName).find()) {
|
||||
} else if (reservedRepoPatterns.matcher(newRepoName).find()) {
|
||||
|
||||
Toasty.warning(ctx, getString(R.string.repoNameErrorReservedPatterns));
|
||||
}
|
||||
else if(selectedOwner == null) {
|
||||
} else if (selectedOwner == null) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.repoOwnerError));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
disableProcessButton();
|
||||
createNewRepository(loginUid, newRepoName, newRepoDesc, selectedOwner, newRepoAccess);
|
||||
}
|
||||
}
|
||||
|
||||
private void createNewRepository(String loginUid, String repoName, String repoDesc, String selectedOwner, boolean isPrivate) {
|
||||
private void createNewRepository(
|
||||
String loginUid,
|
||||
String repoName,
|
||||
String repoDesc,
|
||||
String selectedOwner,
|
||||
boolean isPrivate) {
|
||||
|
||||
CreateRepoOption createRepository = new CreateRepoOption();
|
||||
createRepository.setAutoInit(true);
|
||||
|
@ -153,119 +153,138 @@ public class CreateRepoActivity extends BaseActivity {
|
|||
createRepository.setName(repoName);
|
||||
|
||||
Call<Repository> call;
|
||||
if(selectedOwner.equals(loginUid)) {
|
||||
if (selectedOwner.equals(loginUid)) {
|
||||
|
||||
call = RetrofitClient.getApiInterface(ctx).createCurrentUserRepo(createRepository);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
call = RetrofitClient.getApiInterface(ctx).createOrgRepo(selectedOwner, createRepository);
|
||||
call =
|
||||
RetrofitClient.getApiInterface(ctx)
|
||||
.createOrgRepo(selectedOwner, createRepository);
|
||||
}
|
||||
|
||||
call.enqueue(new Callback<Repository>() {
|
||||
call.enqueue(
|
||||
new Callback<Repository>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Repository> call, @NonNull retrofit2.Response<Repository> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<Repository> call,
|
||||
@NonNull retrofit2.Response<Repository> response) {
|
||||
|
||||
if(response.code() == 201) {
|
||||
if (response.code() == 201) {
|
||||
|
||||
MainActivity.reloadRepos = true;
|
||||
Toasty.success(ctx, getString(R.string.repoCreated));
|
||||
enableProcessButton();
|
||||
finish();
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
MainActivity.reloadRepos = true;
|
||||
Toasty.success(ctx, getString(R.string.repoCreated));
|
||||
enableProcessButton();
|
||||
finish();
|
||||
} else if (response.code() == 401) {
|
||||
|
||||
enableProcessButton();
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
}
|
||||
else if(response.code() == 409) {
|
||||
enableProcessButton();
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
} else if (response.code() == 409) {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.warning(ctx, getString(R.string.repoExistsError));
|
||||
}
|
||||
else {
|
||||
enableProcessButton();
|
||||
Toasty.warning(ctx, getString(R.string.repoExistsError));
|
||||
} else {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Repository> call, @NonNull Throwable t) {
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Repository> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
enableProcessButton();
|
||||
}
|
||||
});
|
||||
Log.e("onFailure", t.toString());
|
||||
enableProcessButton();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void getOrganizations(final String userLogin) {
|
||||
|
||||
Call<List<Organization>> call = RetrofitClient.getApiInterface(ctx).orgListCurrentUserOrgs(1, 50);
|
||||
Call<List<Organization>> call =
|
||||
RetrofitClient.getApiInterface(ctx).orgListCurrentUserOrgs(1, 50);
|
||||
|
||||
call.enqueue(new Callback<List<Organization>>() {
|
||||
call.enqueue(
|
||||
new Callback<List<Organization>>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Organization>> call, @NonNull retrofit2.Response<List<Organization>> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<List<Organization>> call,
|
||||
@NonNull retrofit2.Response<List<Organization>> response) {
|
||||
|
||||
if(response.code() == 200) {
|
||||
if (response.code() == 200) {
|
||||
|
||||
int organizationId = 0;
|
||||
int organizationId = 0;
|
||||
|
||||
List<Organization> organizationsList_ = response.body();
|
||||
List<Organization> organizationsList_ = response.body();
|
||||
|
||||
organizationsList.add(userLogin);
|
||||
assert organizationsList_ != null;
|
||||
organizationsList.add(userLogin);
|
||||
assert organizationsList_ != null;
|
||||
|
||||
if(organizationsList_.size() > 0) {
|
||||
if (organizationsList_.size() > 0) {
|
||||
|
||||
for(int i = 0; i < organizationsList_.size(); i++) {
|
||||
for (int i = 0; i < organizationsList_.size(); i++) {
|
||||
|
||||
if(getIntent().getStringExtra("orgName") != null && !"".equals(getIntent().getStringExtra("orgName"))) {
|
||||
if(getIntent().getStringExtra("orgName").equals(organizationsList_.get(i).getUsername())) {
|
||||
organizationId = i + 1;
|
||||
if (getIntent().getStringExtra("orgName") != null
|
||||
&& !"".equals(getIntent().getStringExtra("orgName"))) {
|
||||
if (getIntent()
|
||||
.getStringExtra("orgName")
|
||||
.equals(organizationsList_.get(i).getUsername())) {
|
||||
organizationId = i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
organizationsList.add(organizationsList_.get(i).getUsername());
|
||||
}
|
||||
}
|
||||
|
||||
organizationsList.add(organizationsList_.get(i).getUsername());
|
||||
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));
|
||||
|
||||
if (getIntent().getBooleanExtra("organizationAction", false)
|
||||
&& organizationId != 0) {
|
||||
|
||||
int selectOwnerById = organizationId;
|
||||
new Handler(Looper.getMainLooper())
|
||||
.postDelayed(
|
||||
() -> {
|
||||
spinner.setText(
|
||||
organizationsList.get(selectOwnerById),
|
||||
false);
|
||||
selectedOwner =
|
||||
organizationsList.get(selectOwnerById);
|
||||
},
|
||||
500);
|
||||
getIntent().removeExtra("organizationAction");
|
||||
}
|
||||
|
||||
enableProcessButton();
|
||||
} else if (response.code() == 401) {
|
||||
|
||||
enableProcessButton();
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<>(CreateRepoActivity.this, R.layout.list_spinner_items, organizationsList);
|
||||
@Override
|
||||
public void onFailure(
|
||||
@NonNull Call<List<Organization>> call, @NonNull Throwable t) {
|
||||
|
||||
spinner.setAdapter(adapter);
|
||||
|
||||
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), false);
|
||||
selectedOwner = organizationsList.get(selectOwnerById);
|
||||
}, 500);
|
||||
getIntent().removeExtra("organizationAction");
|
||||
Log.e("onFailure", t.toString());
|
||||
enableProcessButton();
|
||||
}
|
||||
|
||||
enableProcessButton();
|
||||
}
|
||||
|
||||
else if(response.code() == 401) {
|
||||
|
||||
enableProcessButton();
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Organization>> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
enableProcessButton();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private void initCloseListener() {
|
||||
|
@ -282,5 +301,4 @@ public class CreateRepoActivity extends BaseActivity {
|
|||
|
||||
createRepo.setEnabled(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,6 +12,9 @@ import android.widget.TextView;
|
|||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.res.ResourcesCompat;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.gitnex.tea4j.v2.models.CreateTeamOption;
|
||||
import org.gitnex.tea4j.v2.models.Team;
|
||||
import org.mian.gitnex.R;
|
||||
|
@ -21,16 +24,12 @@ import org.mian.gitnex.fragments.OrganizationTeamsFragment;
|
|||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
/**
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClickListener {
|
||||
|
||||
private View.OnClickListener onClickListener;
|
||||
|
@ -44,23 +43,35 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
|||
private final String[] permissionList = {"Read", "Write", "Admin"};
|
||||
public int permissionSelectedChoice = -1;
|
||||
|
||||
private final String[] accessControlsList = new String[]{"Code", "Issues", "Pull Request", "Releases", "Wiki", "External Wiki", "External Issues"};
|
||||
private final String[] accessControlsList =
|
||||
new String[] {
|
||||
"Code",
|
||||
"Issues",
|
||||
"Pull Request",
|
||||
"Releases",
|
||||
"Wiki",
|
||||
"External Wiki",
|
||||
"External Issues"
|
||||
};
|
||||
|
||||
private List<String> pushAccessList;
|
||||
|
||||
private final boolean[] selectedAccessControlsTrueFalse = new boolean[]{false, false, false, false, false, false, false};
|
||||
private final boolean[] selectedAccessControlsTrueFalse =
|
||||
new boolean[] {false, false, false, false, false, false, false};
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
ActivityCreateTeamByOrgBinding activityCreateTeamByOrgBinding = ActivityCreateTeamByOrgBinding.inflate(getLayoutInflater());
|
||||
ActivityCreateTeamByOrgBinding activityCreateTeamByOrgBinding =
|
||||
ActivityCreateTeamByOrgBinding.inflate(getLayoutInflater());
|
||||
setContentView(activityCreateTeamByOrgBinding.getRoot());
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
InputMethodManager imm =
|
||||
(InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
ImageView closeActivity = activityCreateTeamByOrgBinding.close;
|
||||
teamName = activityCreateTeamByOrgBinding.teamName;
|
||||
|
@ -78,116 +89,152 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
|||
initCloseListener();
|
||||
closeActivity.setOnClickListener(onClickListener);
|
||||
|
||||
teamPermission.setOnClickListener(view -> {
|
||||
teamPermission.setOnClickListener(
|
||||
view -> {
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilderPerm =
|
||||
new MaterialAlertDialogBuilder(ctx)
|
||||
.setTitle(R.string.newTeamPermission)
|
||||
.setCancelable(permissionSelectedChoice != -1)
|
||||
.setSingleChoiceItems(
|
||||
permissionList,
|
||||
permissionSelectedChoice,
|
||||
(dialogInterface, i) -> {
|
||||
permissionSelectedChoice = i;
|
||||
teamPermission.setText(permissionList[i]);
|
||||
|
||||
switch (permissionList[i]) {
|
||||
case "Read":
|
||||
teamPermissionDetail.setVisibility(
|
||||
View.VISIBLE);
|
||||
teamPermissionDetail.setText(
|
||||
R.string.newTeamPermissionRead);
|
||||
break;
|
||||
case "Write":
|
||||
teamPermissionDetail.setVisibility(
|
||||
View.VISIBLE);
|
||||
teamPermissionDetail.setText(
|
||||
R.string.newTeamPermissionWrite);
|
||||
break;
|
||||
case "Admin":
|
||||
teamPermissionDetail.setVisibility(
|
||||
View.VISIBLE);
|
||||
teamPermissionDetail.setText(
|
||||
R.string.newTeamPermissionAdmin);
|
||||
break;
|
||||
default:
|
||||
teamPermissionDetail.setVisibility(
|
||||
View.GONE);
|
||||
break;
|
||||
}
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilderPerm = new MaterialAlertDialogBuilder(ctx).setTitle(R.string.newTeamPermission).setCancelable(permissionSelectedChoice != -1)
|
||||
.setSingleChoiceItems(permissionList, permissionSelectedChoice, (dialogInterface, i) -> {
|
||||
dialogInterface.dismiss();
|
||||
});
|
||||
|
||||
permissionSelectedChoice = i;
|
||||
teamPermission.setText(permissionList[i]);
|
||||
|
||||
switch(permissionList[i]) {
|
||||
case "Read":
|
||||
|
||||
teamPermissionDetail.setVisibility(View.VISIBLE);
|
||||
teamPermissionDetail.setText(R.string.newTeamPermissionRead);
|
||||
break;
|
||||
case "Write":
|
||||
|
||||
teamPermissionDetail.setVisibility(View.VISIBLE);
|
||||
teamPermissionDetail.setText(R.string.newTeamPermissionWrite);
|
||||
break;
|
||||
case "Admin":
|
||||
|
||||
teamPermissionDetail.setVisibility(View.VISIBLE);
|
||||
teamPermissionDetail.setText(R.string.newTeamPermissionAdmin);
|
||||
break;
|
||||
default:
|
||||
|
||||
teamPermissionDetail.setVisibility(View.GONE);
|
||||
break;
|
||||
}
|
||||
|
||||
dialogInterface.dismiss();
|
||||
materialAlertDialogBuilderPerm.create().show();
|
||||
});
|
||||
|
||||
materialAlertDialogBuilderPerm.create().show();
|
||||
});
|
||||
teamAccessControls.setOnClickListener(
|
||||
v -> {
|
||||
teamAccessControls.setText("");
|
||||
teamAccessControlsArray.setText("");
|
||||
pushAccessList = Arrays.asList(accessControlsList);
|
||||
|
||||
teamAccessControls.setOnClickListener(v -> {
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder =
|
||||
new MaterialAlertDialogBuilder(ctx)
|
||||
.setMultiChoiceItems(
|
||||
accessControlsList,
|
||||
selectedAccessControlsTrueFalse,
|
||||
(dialog, which, isChecked) -> {})
|
||||
.setTitle(R.string.newTeamAccessControls)
|
||||
.setPositiveButton(
|
||||
R.string.okButton,
|
||||
(dialog, which) -> {
|
||||
int selectedVal = 0;
|
||||
while (selectedVal
|
||||
< selectedAccessControlsTrueFalse.length) {
|
||||
boolean value =
|
||||
selectedAccessControlsTrueFalse[
|
||||
selectedVal];
|
||||
|
||||
teamAccessControls.setText("");
|
||||
teamAccessControlsArray.setText("");
|
||||
pushAccessList = Arrays.asList(accessControlsList);
|
||||
String repoCode = "";
|
||||
if (selectedVal == 0) {
|
||||
repoCode = "repo.code";
|
||||
}
|
||||
if (selectedVal == 1) {
|
||||
repoCode = "repo.issues";
|
||||
}
|
||||
if (selectedVal == 2) {
|
||||
repoCode = "repo.pulls";
|
||||
}
|
||||
if (selectedVal == 3) {
|
||||
repoCode = "repo.releases";
|
||||
}
|
||||
if (selectedVal == 4) {
|
||||
repoCode = "repo.wiki";
|
||||
}
|
||||
if (selectedVal == 5) {
|
||||
repoCode = "repo.ext_wiki";
|
||||
}
|
||||
if (selectedVal == 6) {
|
||||
repoCode = "repo.ext_issues";
|
||||
}
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx).setMultiChoiceItems(accessControlsList, selectedAccessControlsTrueFalse, (dialog, which, isChecked) -> {
|
||||
}).setTitle(R.string.newTeamAccessControls).setPositiveButton(R.string.okButton, (dialog, which) -> {
|
||||
if (value) {
|
||||
|
||||
int selectedVal = 0;
|
||||
while(selectedVal < selectedAccessControlsTrueFalse.length) {
|
||||
boolean value = selectedAccessControlsTrueFalse[selectedVal];
|
||||
teamAccessControls.setText(
|
||||
getString(
|
||||
R.string
|
||||
.newTeamPermissionValues,
|
||||
teamAccessControls
|
||||
.getText(),
|
||||
pushAccessList.get(
|
||||
selectedVal)));
|
||||
teamAccessControlsArray.setText(
|
||||
getString(
|
||||
R.string
|
||||
.newTeamPermissionValuesFinal,
|
||||
teamAccessControlsArray
|
||||
.getText(),
|
||||
repoCode));
|
||||
}
|
||||
|
||||
String repoCode = "";
|
||||
if(selectedVal == 0) {
|
||||
repoCode = "repo.code";
|
||||
}
|
||||
if(selectedVal == 1) {
|
||||
repoCode = "repo.issues";
|
||||
}
|
||||
if(selectedVal == 2) {
|
||||
repoCode = "repo.pulls";
|
||||
}
|
||||
if(selectedVal == 3) {
|
||||
repoCode = "repo.releases";
|
||||
}
|
||||
if(selectedVal == 4) {
|
||||
repoCode = "repo.wiki";
|
||||
}
|
||||
if(selectedVal == 5) {
|
||||
repoCode = "repo.ext_wiki";
|
||||
}
|
||||
if(selectedVal == 6) {
|
||||
repoCode = "repo.ext_issues";
|
||||
}
|
||||
selectedVal++;
|
||||
}
|
||||
|
||||
if(value) {
|
||||
String data =
|
||||
String.valueOf(
|
||||
teamAccessControls.getText());
|
||||
if (!data.equals("")) {
|
||||
|
||||
teamAccessControls.setText(getString(R.string.newTeamPermissionValues, teamAccessControls.getText(), pushAccessList.get(selectedVal)));
|
||||
teamAccessControlsArray.setText(getString(R.string.newTeamPermissionValuesFinal, teamAccessControlsArray.getText(), repoCode));
|
||||
}
|
||||
teamAccessControls.setText(
|
||||
data.substring(0, data.length() - 2));
|
||||
}
|
||||
|
||||
selectedVal++;
|
||||
}
|
||||
String dataArray =
|
||||
String.valueOf(
|
||||
teamAccessControlsArray.getText());
|
||||
|
||||
String data = String.valueOf(teamAccessControls.getText());
|
||||
if(!data.equals("")) {
|
||||
if (!dataArray.equals("")) {
|
||||
|
||||
teamAccessControls.setText(data.substring(0, data.length() - 2));
|
||||
}
|
||||
teamAccessControlsArray.setText(
|
||||
dataArray.substring(
|
||||
0, dataArray.length() - 2));
|
||||
}
|
||||
});
|
||||
|
||||
String dataArray = String.valueOf(teamAccessControlsArray.getText());
|
||||
|
||||
if(!dataArray.equals("")) {
|
||||
|
||||
teamAccessControlsArray.setText(dataArray.substring(0, dataArray.length() - 2));
|
||||
}
|
||||
});
|
||||
|
||||
materialAlertDialogBuilder.create().show();
|
||||
});
|
||||
materialAlertDialogBuilder.create().show();
|
||||
});
|
||||
|
||||
createTeamButton.setEnabled(false);
|
||||
|
||||
if(!connToInternet) {
|
||||
if (!connToInternet) {
|
||||
|
||||
createTeamButton.setEnabled(false);
|
||||
GradientDrawable shape = new GradientDrawable();
|
||||
shape.setCornerRadius(8);
|
||||
shape.setColor(ResourcesCompat.getColor(getResources(), R.color.hintColor, null));
|
||||
createTeamButton.setBackground(shape);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
createTeamButton.setEnabled(true);
|
||||
createTeamButton.setOnClickListener(this);
|
||||
|
@ -204,61 +251,68 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
|||
String newTeamPermission = teamPermission.getText().toString().toLowerCase();
|
||||
String newTeamAccessControls = teamAccessControlsArray.getText().toString();
|
||||
|
||||
if(!connToInternet) {
|
||||
if (!connToInternet) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
return;
|
||||
}
|
||||
|
||||
if(newTeamName.equals("")) {
|
||||
if (newTeamName.equals("")) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.teamNameEmpty));
|
||||
return;
|
||||
}
|
||||
|
||||
if(!AppUtil.checkStringsWithAlphaNumericDashDotUnderscore(newTeamName)) {
|
||||
if (!AppUtil.checkStringsWithAlphaNumericDashDotUnderscore(newTeamName)) {
|
||||
|
||||
Toasty.warning(ctx, getString(R.string.teamNameError));
|
||||
return;
|
||||
}
|
||||
|
||||
if(!newTeamDesc.equals("")) {
|
||||
if (!newTeamDesc.equals("")) {
|
||||
|
||||
if(!AppUtil.checkStrings(newTeamDesc)) {
|
||||
if (!AppUtil.checkStrings(newTeamDesc)) {
|
||||
|
||||
Toasty.warning(ctx, getString(R.string.teamDescError));
|
||||
return;
|
||||
}
|
||||
|
||||
if(newTeamDesc.length() > 100) {
|
||||
if (newTeamDesc.length() > 100) {
|
||||
|
||||
Toasty.warning(ctx, getString(R.string.teamDescLimit));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(newTeamPermission.equals("")) {
|
||||
if (newTeamPermission.equals("")) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.teamPermissionEmpty));
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> newTeamAccessControls_ = new ArrayList<>(Arrays.asList(newTeamAccessControls.split(",")));
|
||||
List<String> newTeamAccessControls_ =
|
||||
new ArrayList<>(Arrays.asList(newTeamAccessControls.split(",")));
|
||||
|
||||
for(int i = 0; i < newTeamAccessControls_.size(); i++) {
|
||||
for (int i = 0; i < newTeamAccessControls_.size(); i++) {
|
||||
|
||||
newTeamAccessControls_.set(i, newTeamAccessControls_.get(i).trim());
|
||||
}
|
||||
|
||||
createNewTeamCall(orgName, newTeamName, newTeamDesc, newTeamPermission, newTeamAccessControls_);
|
||||
createNewTeamCall(
|
||||
orgName, newTeamName, newTeamDesc, newTeamPermission, newTeamAccessControls_);
|
||||
}
|
||||
|
||||
private void createNewTeamCall(String orgName, String newTeamName, String newTeamDesc, String newTeamPermission, List<String> newTeamAccessControls) {
|
||||
private void createNewTeamCall(
|
||||
String orgName,
|
||||
String newTeamName,
|
||||
String newTeamDesc,
|
||||
String newTeamPermission,
|
||||
List<String> newTeamAccessControls) {
|
||||
|
||||
CreateTeamOption createNewTeamJson = new CreateTeamOption();
|
||||
createNewTeamJson.setName(newTeamName);
|
||||
createNewTeamJson.setDescription(newTeamDesc);
|
||||
switch(newTeamPermission) {
|
||||
switch (newTeamPermission) {
|
||||
case "Read":
|
||||
createNewTeamJson.setPermission(CreateTeamOption.PermissionEnum.READ);
|
||||
break;
|
||||
|
@ -271,49 +325,48 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
|||
}
|
||||
createNewTeamJson.setUnits(newTeamAccessControls);
|
||||
|
||||
Call<Team> call3 = RetrofitClient.getApiInterface(ctx).orgCreateTeam(orgName, createNewTeamJson);
|
||||
Call<Team> call3 =
|
||||
RetrofitClient.getApiInterface(ctx).orgCreateTeam(orgName, createNewTeamJson);
|
||||
|
||||
call3.enqueue(new Callback<Team>() {
|
||||
call3.enqueue(
|
||||
new Callback<Team>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Team> call, @NonNull retrofit2.Response<Team> response2) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<Team> call, @NonNull retrofit2.Response<Team> response2) {
|
||||
|
||||
if(response2.isSuccessful()) {
|
||||
if (response2.isSuccessful()) {
|
||||
|
||||
if(response2.code() == 201) {
|
||||
if (response2.code() == 201) {
|
||||
|
||||
OrganizationTeamsFragment.resumeTeams = true;
|
||||
OrganizationTeamsFragment.resumeTeams = true;
|
||||
|
||||
Toasty.success(ctx, getString(R.string.teamCreated));
|
||||
finish();
|
||||
Toasty.success(ctx, getString(R.string.teamCreated));
|
||||
finish();
|
||||
}
|
||||
} else if (response2.code() == 404) {
|
||||
|
||||
Toasty.warning(ctx, getString(R.string.apiNotFound));
|
||||
} else if (response2.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
} else {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(response2.code() == 404) {
|
||||
|
||||
Toasty.warning(ctx, getString(R.string.apiNotFound));
|
||||
}
|
||||
else if(response2.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Team> call, @NonNull Throwable t) {
|
||||
Log.e("onFailure", t.toString());
|
||||
}
|
||||
});
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Team> call, @NonNull Throwable t) {
|
||||
Log.e("onFailure", t.toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
if(v == createTeamButton) {
|
||||
if (v == createTeamButton) {
|
||||
|
||||
processCreateTeam();
|
||||
}
|
||||
|
@ -323,5 +376,4 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
|||
|
||||
onClickListener = view -> finish();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -10,7 +10,6 @@ import org.mian.gitnex.fragments.PullRequestChangesFragment;
|
|||
/**
|
||||
* @author opyale
|
||||
*/
|
||||
|
||||
public class DiffActivity extends BaseActivity {
|
||||
|
||||
public PullRequestChangesFragment fragment = PullRequestChangesFragment.newInstance();
|
||||
|
@ -24,21 +23,28 @@ public class DiffActivity extends BaseActivity {
|
|||
|
||||
setContentView(binding.getRoot());
|
||||
|
||||
getOnBackPressedDispatcher().addCallback(new OnBackPressedCallback(true) {
|
||||
getOnBackPressedDispatcher()
|
||||
.addCallback(
|
||||
new OnBackPressedCallback(true) {
|
||||
|
||||
@Override
|
||||
public void handleOnBackPressed() {
|
||||
if(getSupportFragmentManager().findFragmentById(R.id.fragment_container) instanceof DiffFragment) {
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, fragment).commit();
|
||||
}
|
||||
else {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, fragment).commit();
|
||||
@Override
|
||||
public void handleOnBackPressed() {
|
||||
if (getSupportFragmentManager()
|
||||
.findFragmentById(R.id.fragment_container)
|
||||
instanceof DiffFragment) {
|
||||
getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
.replace(R.id.fragment_container, fragment)
|
||||
.commit();
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
.replace(R.id.fragment_container, fragment)
|
||||
.commit();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -8,6 +8,8 @@ import android.view.View;
|
|||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.ArrayAdapter;
|
||||
import androidx.annotation.NonNull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
import org.gitnex.tea4j.v2.models.MergePullRequestOption;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.actions.PullRequestActions;
|
||||
|
@ -19,15 +21,12 @@ 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;
|
||||
import java.util.Objects;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
/**
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class MergePullRequestActivity extends BaseActivity {
|
||||
|
||||
private View.OnClickListener onClickListener;
|
||||
|
@ -49,7 +48,8 @@ public class MergePullRequestActivity extends BaseActivity {
|
|||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
InputMethodManager imm =
|
||||
(InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
viewBinding.mergeTitle.requestFocus();
|
||||
assert imm != null;
|
||||
|
@ -57,50 +57,51 @@ public class MergePullRequestActivity extends BaseActivity {
|
|||
|
||||
setMergeAdapter();
|
||||
|
||||
if(!issue.getPullRequest().getTitle().isEmpty()) {
|
||||
if (!issue.getPullRequest().getTitle().isEmpty()) {
|
||||
|
||||
viewBinding.toolbarTitle.setText(issue.getPullRequest().getTitle());
|
||||
viewBinding.mergeTitle.setText(issue.getPullRequest().getTitle() + " (#" + issue.getIssueIndex() + ")");
|
||||
viewBinding.mergeTitle.setText(
|
||||
issue.getPullRequest().getTitle() + " (#" + issue.getIssueIndex() + ")");
|
||||
}
|
||||
|
||||
initCloseListener();
|
||||
viewBinding.close.setOnClickListener(onClickListener);
|
||||
|
||||
// if gitea version is greater/equal(1.12.0) than user installed version (installed.higherOrEqual(compareVer))
|
||||
if(getAccount().requiresVersion("1.12.0")) {
|
||||
// if gitea version is greater/equal(1.12.0) than user installed version
|
||||
// (installed.higherOrEqual(compareVer))
|
||||
if (getAccount().requiresVersion("1.12.0")) {
|
||||
|
||||
viewBinding.deleteBranch.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
if(!issue.getPullRequest().isMergeable()) {
|
||||
if (!issue.getPullRequest().isMergeable()) {
|
||||
|
||||
disableProcessButton();
|
||||
viewBinding.mergeInfoDisabledMessage.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
viewBinding.mergeInfoDisabledMessage.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if(issue.prIsFork()) {
|
||||
if (issue.prIsFork()) {
|
||||
|
||||
viewBinding.deleteBranchForkInfo.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
viewBinding.deleteBranchForkInfo.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if(!connToInternet) {
|
||||
if (!connToInternet) {
|
||||
|
||||
disableProcessButton();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
viewBinding.mergeButton.setOnClickListener(mergePullRequest);
|
||||
}
|
||||
|
||||
if(!(issue.getPullRequest().getHead().getRepo() != null ? issue.getPullRequest().getHead().getRepo().getPermissions().isPush() : false)) {
|
||||
if (!(issue.getPullRequest().getHead().getRepo() != null
|
||||
? issue.getPullRequest().getHead().getRepo().getPermissions().isPush()
|
||||
: false)) {
|
||||
viewBinding.deleteBranch.setVisibility(View.GONE);
|
||||
viewBinding.deleteBranchForkInfo.setVisibility(View.GONE);
|
||||
}
|
||||
|
@ -110,22 +111,33 @@ public class MergePullRequestActivity extends BaseActivity {
|
|||
|
||||
ArrayList<MergePullRequestSpinner> mergeList = new ArrayList<>();
|
||||
|
||||
mergeList.add(new MergePullRequestSpinner("merge", getResources().getString(R.string.mergeOptionMerge)));
|
||||
mergeList.add(new MergePullRequestSpinner("rebase", getResources().getString(R.string.mergeOptionRebase)));
|
||||
mergeList.add(new MergePullRequestSpinner("rebase-merge", getResources().getString(R.string.mergeOptionRebaseCommit)));
|
||||
mergeList.add(
|
||||
new MergePullRequestSpinner(
|
||||
"merge", getResources().getString(R.string.mergeOptionMerge)));
|
||||
mergeList.add(
|
||||
new MergePullRequestSpinner(
|
||||
"rebase", getResources().getString(R.string.mergeOptionRebase)));
|
||||
mergeList.add(
|
||||
new MergePullRequestSpinner(
|
||||
"rebase-merge",
|
||||
getResources().getString(R.string.mergeOptionRebaseCommit)));
|
||||
// squash merge works only on gitea > v1.11.4 due to a bug
|
||||
if(getAccount().requiresVersion("1.12.0")) {
|
||||
if (getAccount().requiresVersion("1.12.0")) {
|
||||
|
||||
mergeList.add(new MergePullRequestSpinner("squash", getResources().getString(R.string.mergeOptionSquash)));
|
||||
mergeList.add(
|
||||
new MergePullRequestSpinner(
|
||||
"squash", getResources().getString(R.string.mergeOptionSquash)));
|
||||
}
|
||||
|
||||
ArrayAdapter<MergePullRequestSpinner> adapter = new ArrayAdapter<>(MergePullRequestActivity.this, R.layout.list_spinner_items, mergeList);
|
||||
ArrayAdapter<MergePullRequestSpinner> adapter =
|
||||
new ArrayAdapter<>(
|
||||
MergePullRequestActivity.this, R.layout.list_spinner_items, mergeList);
|
||||
viewBinding.mergeSpinner.setAdapter(adapter);
|
||||
|
||||
viewBinding.mergeSpinner.setOnItemClickListener((parent, view, position, id) -> {
|
||||
|
||||
Do = mergeList.get(position).getId();
|
||||
});
|
||||
viewBinding.mergeSpinner.setOnItemClickListener(
|
||||
(parent, view, position, id) -> {
|
||||
Do = mergeList.get(position).getId();
|
||||
});
|
||||
}
|
||||
|
||||
private void initCloseListener() {
|
||||
|
@ -135,36 +147,37 @@ public class MergePullRequestActivity extends BaseActivity {
|
|||
|
||||
private void processMergePullRequest() {
|
||||
|
||||
String mergePRDesc = Objects.requireNonNull(viewBinding.mergeDescription.getText()).toString();
|
||||
String mergePRDesc =
|
||||
Objects.requireNonNull(viewBinding.mergeDescription.getText()).toString();
|
||||
String mergePRTitle = Objects.requireNonNull(viewBinding.mergeTitle.getText()).toString();
|
||||
boolean deleteBranch = viewBinding.deleteBranch.isChecked();
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
if(!connToInternet) {
|
||||
if (!connToInternet) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
return;
|
||||
}
|
||||
|
||||
if(Do == null) {
|
||||
if (Do == null) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.selectMergeStrategy));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
disableProcessButton();
|
||||
mergeFunction(Do, mergePRDesc, mergePRTitle, deleteBranch);
|
||||
}
|
||||
}
|
||||
|
||||
private void mergeFunction(String Do, String mergePRDT, String mergeTitle, boolean deleteBranch) {
|
||||
private void mergeFunction(
|
||||
String Do, String mergePRDT, String mergeTitle, boolean deleteBranch) {
|
||||
|
||||
MergePullRequestOption mergePR = new MergePullRequestOption();
|
||||
mergePR.setDeleteBranchAfterMerge(deleteBranch);
|
||||
mergePR.setMergeTitleField(mergeTitle);
|
||||
mergePR.setMergeMessageField(mergePRDT);
|
||||
switch(Do) {
|
||||
switch (Do) {
|
||||
case "merge":
|
||||
mergePR.setDo(MergePullRequestOption.DoEnum.MERGE);
|
||||
break;
|
||||
|
@ -179,67 +192,82 @@ public class MergePullRequestActivity extends BaseActivity {
|
|||
break;
|
||||
}
|
||||
|
||||
Call<Void> call = RetrofitClient.getApiInterface(ctx).repoMergePullRequest(issue.getRepository().getOwner(), issue.getRepository().getName(), (long) issue.getIssueIndex(), mergePR);
|
||||
Call<Void> call =
|
||||
RetrofitClient.getApiInterface(ctx)
|
||||
.repoMergePullRequest(
|
||||
issue.getRepository().getOwner(),
|
||||
issue.getRepository().getName(),
|
||||
(long) issue.getIssueIndex(),
|
||||
mergePR);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
|
||||
if(response.code() == 200) {
|
||||
if (response.code() == 200) {
|
||||
|
||||
if(deleteBranch) {
|
||||
if (deleteBranch) {
|
||||
|
||||
if(issue.prIsFork()) {
|
||||
String repoFullName = issue.getPullRequest().getHead().getRepo().getFullName();
|
||||
String[] parts = repoFullName.split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
if (issue.prIsFork()) {
|
||||
String repoFullName =
|
||||
issue.getPullRequest()
|
||||
.getHead()
|
||||
.getRepo()
|
||||
.getFullName();
|
||||
String[] parts = repoFullName.split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
|
||||
PullRequestActions.deleteHeadBranch(ctx, repoOwner, repoName, issue.getPullRequest().getHead().getRef(), false);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
} else if (response.code() == 404) {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.warning(ctx, getString(R.string.mergePR404ErrorMsg));
|
||||
} else if (response.code() == 405) {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.warning(ctx, getString(R.string.mergeNotAllowed));
|
||||
} else {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
}
|
||||
else {
|
||||
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);
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.warning(ctx, getString(R.string.mergePR404ErrorMsg));
|
||||
}
|
||||
else if(response.code() == 405) {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.warning(ctx, getString(R.string.mergeNotAllowed));
|
||||
}
|
||||
else {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
enableProcessButton();
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
enableProcessButton();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void disableProcessButton() {
|
||||
|
@ -257,5 +285,4 @@ public class MergePullRequestActivity extends BaseActivity {
|
|||
super.onResume();
|
||||
issue.getRepository().checkAccountSwitch(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,6 +10,9 @@ import android.widget.Button;
|
|||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import androidx.annotation.NonNull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.gitnex.tea4j.v2.models.CreateEmailOption;
|
||||
import org.gitnex.tea4j.v2.models.Email;
|
||||
import org.mian.gitnex.R;
|
||||
|
@ -19,16 +22,12 @@ import org.mian.gitnex.fragments.MyProfileEmailsFragment;
|
|||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
/**
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class MyProfileEmailActivity extends BaseActivity {
|
||||
|
||||
private View.OnClickListener onClickListener;
|
||||
|
@ -41,12 +40,14 @@ public class MyProfileEmailActivity extends BaseActivity {
|
|||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
ActivityProfileEmailBinding activityProfileEmailBinding = ActivityProfileEmailBinding.inflate(getLayoutInflater());
|
||||
ActivityProfileEmailBinding activityProfileEmailBinding =
|
||||
ActivityProfileEmailBinding.inflate(getLayoutInflater());
|
||||
setContentView(activityProfileEmailBinding.getRoot());
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
InputMethodManager imm =
|
||||
(InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
ImageView closeActivity = activityProfileEmailBinding.close;
|
||||
userEmail = activityProfileEmailBinding.userEmail;
|
||||
|
@ -59,15 +60,13 @@ public class MyProfileEmailActivity extends BaseActivity {
|
|||
initCloseListener();
|
||||
closeActivity.setOnClickListener(onClickListener);
|
||||
|
||||
if(!connToInternet) {
|
||||
if (!connToInternet) {
|
||||
|
||||
disableProcessButton();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
addEmailButton.setOnClickListener(addEmailListener);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void processAddNewEmail() {
|
||||
|
@ -76,18 +75,17 @@ public class MyProfileEmailActivity extends BaseActivity {
|
|||
|
||||
String newUserEmail = userEmail.getText().toString().trim();
|
||||
|
||||
if(!connToInternet) {
|
||||
if (!connToInternet) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
return;
|
||||
}
|
||||
|
||||
if(newUserEmail.equals("")) {
|
||||
if (newUserEmail.equals("")) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.emailErrorEmpty));
|
||||
return;
|
||||
}
|
||||
else if(!Patterns.EMAIL_ADDRESS.matcher(newUserEmail).matches()) {
|
||||
} else if (!Patterns.EMAIL_ADDRESS.matcher(newUserEmail).matches()) {
|
||||
|
||||
Toasty.warning(ctx, getString(R.string.emailErrorInvalid));
|
||||
return;
|
||||
|
@ -106,53 +104,50 @@ public class MyProfileEmailActivity extends BaseActivity {
|
|||
|
||||
Call<List<Email>> call = RetrofitClient.getApiInterface(ctx).userAddEmail(addEmailFunc);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Email>> call, @NonNull retrofit2.Response<List<Email>> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<List<Email>> call,
|
||||
@NonNull retrofit2.Response<List<Email>> response) {
|
||||
|
||||
if(response.code() == 201) {
|
||||
if (response.code() == 201) {
|
||||
|
||||
Toasty.success(ctx, getString(R.string.emailAddedText));
|
||||
MyProfileEmailsFragment.refreshEmails = true;
|
||||
enableProcessButton();
|
||||
finish();
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
Toasty.success(ctx, getString(R.string.emailAddedText));
|
||||
MyProfileEmailsFragment.refreshEmails = true;
|
||||
enableProcessButton();
|
||||
finish();
|
||||
} else if (response.code() == 401) {
|
||||
|
||||
enableProcessButton();
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
enableProcessButton();
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
} else if (response.code() == 403) {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
||||
} else if (response.code() == 404) {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
||||
}
|
||||
else if(response.code() == 422) {
|
||||
enableProcessButton();
|
||||
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
||||
} else if (response.code() == 422) {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.warning(ctx, ctx.getString(R.string.emailErrorInUse));
|
||||
}
|
||||
else {
|
||||
enableProcessButton();
|
||||
Toasty.warning(ctx, ctx.getString(R.string.emailErrorInUse));
|
||||
} else {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Email>> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
enableProcessButton();
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Email>> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
enableProcessButton();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initCloseListener() {
|
||||
|
@ -169,5 +164,4 @@ public class MyProfileEmailActivity extends BaseActivity {
|
|||
|
||||
addEmailButton.setEnabled(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@ import androidx.fragment.app.FragmentManager;
|
|||
import androidx.fragment.app.FragmentPagerAdapter;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
import io.mikael.urlbuilder.UrlBuilder;
|
||||
import java.util.Objects;
|
||||
import org.gitnex.tea4j.v2.models.OrganizationPermissions;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
|
@ -27,8 +29,6 @@ import org.mian.gitnex.fragments.OrganizationRepositoriesFragment;
|
|||
import org.mian.gitnex.fragments.OrganizationTeamsFragment;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.structs.BottomSheetListener;
|
||||
import java.util.Objects;
|
||||
import io.mikael.urlbuilder.UrlBuilder;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
@ -36,7 +36,6 @@ import retrofit2.Response;
|
|||
/**
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class OrganizationDetailActivity extends BaseActivity implements BottomSheetListener {
|
||||
|
||||
public OrganizationPermissions permissions;
|
||||
|
@ -60,51 +59,61 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
|||
|
||||
checkIsMember();
|
||||
|
||||
if(getAccount().requiresVersion("1.16.0")) {
|
||||
RetrofitClient.getApiInterface(this).orgGetUserPermissions(getAccount().getAccount().getUserName(), orgName).enqueue(new Callback<>() {
|
||||
if (getAccount().requiresVersion("1.16.0")) {
|
||||
RetrofitClient.getApiInterface(this)
|
||||
.orgGetUserPermissions(getAccount().getAccount().getUserName(), orgName)
|
||||
.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<OrganizationPermissions> call, @NonNull Response<OrganizationPermissions> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<OrganizationPermissions> call,
|
||||
@NonNull Response<OrganizationPermissions> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
permissions = response.body();
|
||||
}
|
||||
else {
|
||||
permissions = null;
|
||||
}
|
||||
}
|
||||
if (response.isSuccessful()) {
|
||||
permissions = response.body();
|
||||
} else {
|
||||
permissions = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<OrganizationPermissions> call, @NonNull Throwable t) {
|
||||
@Override
|
||||
public void onFailure(
|
||||
@NonNull Call<OrganizationPermissions> call,
|
||||
@NonNull Throwable t) {
|
||||
|
||||
permissions = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
permissions = null;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
permissions = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void checkIsMember() {
|
||||
RetrofitClient.getApiInterface(this).orgIsMember(orgName, getAccount().getAccount().getUserName()).enqueue(new Callback<>() {
|
||||
RetrofitClient.getApiInterface(this)
|
||||
.orgIsMember(orgName, getAccount().getAccount().getUserName())
|
||||
.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull Response<Void> response) {
|
||||
isMember = response.code() != 404;
|
||||
init();
|
||||
}
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<Void> call, @NonNull Response<Void> response) {
|
||||
isMember = response.code() != 404;
|
||||
init();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
isMember = false;
|
||||
init();
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
isMember = false;
|
||||
init();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void init() {
|
||||
OrganizationDetailActivity.SectionsPagerAdapter mSectionsPagerAdapter = new OrganizationDetailActivity.SectionsPagerAdapter(getSupportFragmentManager());
|
||||
OrganizationDetailActivity.SectionsPagerAdapter mSectionsPagerAdapter =
|
||||
new OrganizationDetailActivity.SectionsPagerAdapter(getSupportFragmentManager());
|
||||
|
||||
ViewPager mViewPager = findViewById(R.id.container);
|
||||
mViewPager.setVisibility(View.VISIBLE);
|
||||
|
@ -113,7 +122,7 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
|||
TabLayout tabLayout = findViewById(R.id.tabs);
|
||||
tabLayout.setVisibility(View.VISIBLE);
|
||||
|
||||
if(!isMember) {
|
||||
if (!isMember) {
|
||||
tabLayout.removeTabAt(3);
|
||||
}
|
||||
|
||||
|
@ -126,16 +135,16 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
|||
ViewGroup vg = (ViewGroup) tabLayout.getChildAt(0);
|
||||
int tabsCount = vg.getChildCount();
|
||||
|
||||
for(int j = 0; j < tabsCount; j++) {
|
||||
for (int j = 0; j < tabsCount; j++) {
|
||||
|
||||
ViewGroup vgTab = (ViewGroup) vg.getChildAt(j);
|
||||
int tabChildCount = vgTab.getChildCount();
|
||||
|
||||
for(int i = 0; i < tabChildCount; i++) {
|
||||
for (int i = 0; i < tabChildCount; i++) {
|
||||
|
||||
View tabViewChild = vgTab.getChildAt(i);
|
||||
|
||||
if(tabViewChild instanceof TextView) {
|
||||
if (tabViewChild instanceof TextView) {
|
||||
|
||||
((TextView) tabViewChild).setTypeface(myTypeface);
|
||||
}
|
||||
|
@ -143,7 +152,8 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
|||
}
|
||||
|
||||
mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
|
||||
tabLayout.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(mViewPager));
|
||||
tabLayout.addOnTabSelectedListener(
|
||||
new TabLayout.ViewPagerOnTabSelectedListener(mViewPager));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -159,18 +169,17 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
|||
|
||||
int id = item.getItemId();
|
||||
|
||||
if(id == android.R.id.home) {
|
||||
if (id == android.R.id.home) {
|
||||
|
||||
finish();
|
||||
return true;
|
||||
}
|
||||
else if(id == R.id.repoMenu) {
|
||||
} else if (id == R.id.repoMenu) {
|
||||
|
||||
BottomSheetOrganizationFragment bottomSheet = new BottomSheetOrganizationFragment(permissions);
|
||||
BottomSheetOrganizationFragment bottomSheet =
|
||||
new BottomSheetOrganizationFragment(permissions);
|
||||
bottomSheet.show(getSupportFragmentManager(), "orgBottomSheet");
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
@ -179,10 +188,13 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
|||
@Override
|
||||
public void onButtonClicked(String text) {
|
||||
|
||||
String url = UrlBuilder.fromString(getAccount().getAccount().getInstanceUrl()).withPath("/").toString();
|
||||
String url =
|
||||
UrlBuilder.fromString(getAccount().getAccount().getInstanceUrl())
|
||||
.withPath("/")
|
||||
.toString();
|
||||
url = url + getIntent().getStringExtra("orgName");
|
||||
|
||||
switch(text) {
|
||||
switch (text) {
|
||||
case "repository":
|
||||
Intent intentRepo = new Intent(this, CreateRepoActivity.class);
|
||||
intentRepo.putExtra("organizationAction", true);
|
||||
|
@ -191,14 +203,14 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
|||
startActivity(intentRepo);
|
||||
break;
|
||||
case "label":
|
||||
|
||||
Intent intent = new Intent(ctx, CreateLabelActivity.class);
|
||||
intent.putExtra("orgName", getIntent().getStringExtra("orgName"));
|
||||
intent.putExtra("type", "org");
|
||||
ctx.startActivity(intent);
|
||||
break;
|
||||
case "team":
|
||||
Intent intentTeam = new Intent(OrganizationDetailActivity.this, CreateTeamByOrgActivity.class);
|
||||
Intent intentTeam =
|
||||
new Intent(OrganizationDetailActivity.this, CreateTeamByOrgActivity.class);
|
||||
intentTeam.putExtras(getIntent().getExtras());
|
||||
startActivity(intentTeam);
|
||||
break;
|
||||
|
@ -220,35 +232,27 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
|||
super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
@NonNull @Override
|
||||
public Fragment getItem(int position) {
|
||||
|
||||
String orgName = getIntent().getStringExtra("orgName");
|
||||
|
||||
Fragment fragment = null;
|
||||
switch(position) {
|
||||
|
||||
switch (position) {
|
||||
case 0: // info
|
||||
|
||||
return OrganizationInfoFragment.newInstance(orgName);
|
||||
case 1: // repos
|
||||
|
||||
return OrganizationRepositoriesFragment.newInstance(orgName);
|
||||
case 2: // labels
|
||||
|
||||
return OrganizationLabelsFragment.newInstance(orgName);
|
||||
case 3: // teams / members
|
||||
|
||||
if(isMember) {
|
||||
if (isMember) {
|
||||
return OrganizationTeamsFragment.newInstance(orgName, permissions);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return OrganizationMembersFragment.newInstance(orgName);
|
||||
}
|
||||
case 4: // members
|
||||
|
||||
if(isMember) {
|
||||
if (isMember) {
|
||||
return OrganizationMembersFragment.newInstance(orgName);
|
||||
}
|
||||
}
|
||||
|
@ -257,14 +261,11 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
|||
|
||||
@Override
|
||||
public int getCount() {
|
||||
if(isMember) {
|
||||
if (isMember) {
|
||||
return 5;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@ import org.mian.gitnex.structs.BottomSheetListener;
|
|||
/**
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class OrganizationTeamInfoActivity extends BaseActivity implements BottomSheetListener {
|
||||
|
||||
private Team team;
|
||||
|
@ -36,67 +35,78 @@ public class OrganizationTeamInfoActivity extends BaseActivity implements Bottom
|
|||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
org.mian.gitnex.databinding.ActivityOrgTeamInfoBinding binding = ActivityOrgTeamInfoBinding.inflate(getLayoutInflater());
|
||||
org.mian.gitnex.databinding.ActivityOrgTeamInfoBinding binding =
|
||||
ActivityOrgTeamInfoBinding.inflate(getLayoutInflater());
|
||||
|
||||
setContentView(binding.getRoot());
|
||||
setSupportActionBar(binding.toolbar);
|
||||
|
||||
team = (Team) getIntent().getSerializableExtra("team");
|
||||
|
||||
if(team.getName() != null && !team.getName().isEmpty()) {
|
||||
if (team.getName() != null && !team.getName().isEmpty()) {
|
||||
binding.toolbarTitle.setText(team.getName());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
binding.toolbarTitle.setText(R.string.orgTeamMembers);
|
||||
}
|
||||
|
||||
binding.close.setOnClickListener(view -> finish());
|
||||
binding.pager.setOffscreenPageLimit(1);
|
||||
binding.pager.setAdapter(new FragmentStateAdapter(getSupportFragmentManager(), getLifecycle()) {
|
||||
binding.pager.setAdapter(
|
||||
new FragmentStateAdapter(getSupportFragmentManager(), getLifecycle()) {
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment createFragment(int position) {
|
||||
switch(position) {
|
||||
case 0:
|
||||
return OrganizationTeamInfoReposFragment.newInstance(team);
|
||||
case 1:
|
||||
return OrganizationTeamInfoMembersFragment.newInstance(team);
|
||||
case 2:
|
||||
return OrganizationTeamInfoPermissionsFragment.newInstance(team);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@NonNull @Override
|
||||
public Fragment createFragment(int position) {
|
||||
switch (position) {
|
||||
case 0:
|
||||
return OrganizationTeamInfoReposFragment.newInstance(team);
|
||||
case 1:
|
||||
return OrganizationTeamInfoMembersFragment.newInstance(team);
|
||||
case 2:
|
||||
return OrganizationTeamInfoPermissionsFragment.newInstance(team);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return 3;
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return 3;
|
||||
}
|
||||
});
|
||||
|
||||
new TabLayoutMediator(binding.tabs, binding.pager, (tab, position) -> {
|
||||
TextView textView = (TextView) LayoutInflater.from(ctx).inflate(R.layout.layout_tab_text, findViewById(android.R.id.content), false);
|
||||
new TabLayoutMediator(
|
||||
binding.tabs,
|
||||
binding.pager,
|
||||
(tab, position) -> {
|
||||
TextView textView =
|
||||
(TextView)
|
||||
LayoutInflater.from(ctx)
|
||||
.inflate(
|
||||
R.layout.layout_tab_text,
|
||||
findViewById(android.R.id.content),
|
||||
false);
|
||||
|
||||
switch(position) {
|
||||
case 0:
|
||||
textView.setText(R.string.navRepos);
|
||||
break;
|
||||
case 1:
|
||||
textView.setText(R.string.orgTabMembers);
|
||||
break;
|
||||
case 2:
|
||||
textView.setText(R.string.teamPermissions);
|
||||
break;
|
||||
}
|
||||
switch (position) {
|
||||
case 0:
|
||||
textView.setText(R.string.navRepos);
|
||||
break;
|
||||
case 1:
|
||||
textView.setText(R.string.orgTabMembers);
|
||||
break;
|
||||
case 2:
|
||||
textView.setText(R.string.teamPermissions);
|
||||
break;
|
||||
}
|
||||
|
||||
tab.setCustomView(textView);
|
||||
}).attach();
|
||||
tab.setCustomView(textView);
|
||||
})
|
||||
.attach();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
OrganizationPermissions permissions = (OrganizationPermissions) getIntent().getSerializableExtra("permissions");
|
||||
if(permissions == null || permissions.isIsOwner()) {
|
||||
OrganizationPermissions permissions =
|
||||
(OrganizationPermissions) getIntent().getSerializableExtra("permissions");
|
||||
if (permissions == null || permissions.isIsOwner()) {
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.generic_nav_dotted_menu, menu);
|
||||
}
|
||||
|
@ -107,37 +117,36 @@ public class OrganizationTeamInfoActivity extends BaseActivity implements Bottom
|
|||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
int id = item.getItemId();
|
||||
|
||||
if(id == android.R.id.home) {
|
||||
if (id == android.R.id.home) {
|
||||
finish();
|
||||
return true;
|
||||
}
|
||||
else if(id == R.id.genericMenu) {
|
||||
BottomSheetOrganizationTeamsFragment bottomSheet = new BottomSheetOrganizationTeamsFragment();
|
||||
} else if (id == R.id.genericMenu) {
|
||||
BottomSheetOrganizationTeamsFragment bottomSheet =
|
||||
new BottomSheetOrganizationTeamsFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putBoolean("showRepo", !team.isIncludesAllRepositories());
|
||||
bottomSheet.setArguments(args);
|
||||
bottomSheet.show(getSupportFragmentManager(), "orgTeamsBottomSheet");
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onButtonClicked(String text) {
|
||||
if("newMember".equals(text)) {
|
||||
Intent intent = new Intent(OrganizationTeamInfoActivity.this, AddNewTeamMemberActivity.class);
|
||||
if ("newMember".equals(text)) {
|
||||
Intent intent =
|
||||
new Intent(OrganizationTeamInfoActivity.this, AddNewTeamMemberActivity.class);
|
||||
intent.putExtra("teamId", team.getId());
|
||||
startActivity(intent);
|
||||
}
|
||||
else if("newRepo".equals(text)) {
|
||||
Intent intent = new Intent(OrganizationTeamInfoActivity.this, AddNewTeamRepoActivity.class);
|
||||
} else if ("newRepo".equals(text)) {
|
||||
Intent intent =
|
||||
new Intent(OrganizationTeamInfoActivity.this, AddNewTeamRepoActivity.class);
|
||||
intent.putExtra("teamId", team.getId());
|
||||
intent.putExtra("teamName", team.getName());
|
||||
intent.putExtra("orgName", getIntent().getStringExtra("orgName"));
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ 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 java.util.Objects;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.fragments.BottomSheetUserProfileFragment;
|
||||
|
@ -28,7 +29,6 @@ import org.mian.gitnex.fragments.profile.StarredRepositoriesFragment;
|
|||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.structs.BottomSheetListener;
|
||||
import java.util.Objects;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
@ -36,7 +36,6 @@ import retrofit2.Response;
|
|||
/**
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class ProfileActivity extends BaseActivity implements BottomSheetListener {
|
||||
|
||||
private String username;
|
||||
|
@ -52,10 +51,10 @@ public class ProfileActivity extends BaseActivity implements BottomSheetListener
|
|||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
TextView toolbarTitle = findViewById(R.id.toolbarTitle);
|
||||
|
||||
if(profileIntent.getStringExtra("username") != null && !Objects.equals(profileIntent.getStringExtra("username"), "")) {
|
||||
if (profileIntent.getStringExtra("username") != null
|
||||
&& !Objects.equals(profileIntent.getStringExtra("username"), "")) {
|
||||
username = profileIntent.getStringExtra("username");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
Toasty.warning(ctx, ctx.getResources().getString(R.string.userInvalidUserName));
|
||||
finish();
|
||||
}
|
||||
|
@ -74,26 +73,34 @@ public class ProfileActivity extends BaseActivity implements BottomSheetListener
|
|||
|
||||
viewPager.setAdapter(new ViewPagerAdapter(this));
|
||||
|
||||
String[] tabTitles = {ctx.getResources().getString(R.string.tabTextInfo), ctx.getResources().getString(R.string.navRepos), ctx.getResources().getString(R.string.navStarredRepos),
|
||||
ctx.getResources().getString(R.string.navOrg), ctx.getResources().getString(R.string.profileTabFollowers), ctx.getResources().getString(R.string.profileTabFollowing)};
|
||||
new TabLayoutMediator(tabLayout, viewPager, (tab, position) -> tab.setText(tabTitles[position])).attach();
|
||||
String[] tabTitles = {
|
||||
ctx.getResources().getString(R.string.tabTextInfo),
|
||||
ctx.getResources().getString(R.string.navRepos),
|
||||
ctx.getResources().getString(R.string.navStarredRepos),
|
||||
ctx.getResources().getString(R.string.navOrg),
|
||||
ctx.getResources().getString(R.string.profileTabFollowers),
|
||||
ctx.getResources().getString(R.string.profileTabFollowing)
|
||||
};
|
||||
new TabLayoutMediator(
|
||||
tabLayout, viewPager, (tab, position) -> tab.setText(tabTitles[position]))
|
||||
.attach();
|
||||
|
||||
ViewGroup vg = (ViewGroup) tabLayout.getChildAt(0);
|
||||
int tabsCount = vg.getChildCount();
|
||||
|
||||
for(int j = 0; j < tabsCount; j++) {
|
||||
for (int j = 0; j < tabsCount; j++) {
|
||||
|
||||
ViewGroup vgTab = (ViewGroup) vg.getChildAt(j);
|
||||
int tabChildCount = vgTab.getChildCount();
|
||||
|
||||
for(int i = 0; i < tabChildCount; i++) {
|
||||
for (int i = 0; i < tabChildCount; i++) {
|
||||
View tabViewChild = vgTab.getChildAt(i);
|
||||
if(tabViewChild instanceof TextView) {
|
||||
if (tabViewChild instanceof TextView) {
|
||||
((TextView) tabViewChild).setTypeface(myTypeface);
|
||||
}
|
||||
}
|
||||
|
||||
if(!username.equals(getAccount().getAccount().getUserName())) {
|
||||
if (!username.equals(getAccount().getAccount().getUserName())) {
|
||||
checkFollowStatus();
|
||||
}
|
||||
}
|
||||
|
@ -101,76 +108,84 @@ public class ProfileActivity extends BaseActivity implements BottomSheetListener
|
|||
|
||||
@Override
|
||||
public void onButtonClicked(String text) {
|
||||
if(text.equals("follow")) {
|
||||
if (text.equals("follow")) {
|
||||
followUnfollow();
|
||||
}
|
||||
}
|
||||
|
||||
private void checkFollowStatus() {
|
||||
RetrofitClient.getApiInterface(this).userCurrentCheckFollowing(username).enqueue(new Callback<Void>() {
|
||||
RetrofitClient.getApiInterface(this)
|
||||
.userCurrentCheckFollowing(username)
|
||||
.enqueue(
|
||||
new Callback<Void>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull Response<Void> response) {
|
||||
if(response.code() == 204) {
|
||||
following = true;
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
following = false;
|
||||
}
|
||||
else {
|
||||
following = false;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<Void> call, @NonNull Response<Void> response) {
|
||||
if (response.code() == 204) {
|
||||
following = true;
|
||||
} else if (response.code() == 404) {
|
||||
following = false;
|
||||
} else {
|
||||
following = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
following = false;
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
following = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void followUnfollow() {
|
||||
Call<Void> call;
|
||||
if(following) {
|
||||
if (following) {
|
||||
call = RetrofitClient.getApiInterface(this).userCurrentDeleteFollow(username);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
call = RetrofitClient.getApiInterface(this).userCurrentPutFollow(username);
|
||||
}
|
||||
|
||||
call.enqueue(new Callback<Void>() {
|
||||
call.enqueue(
|
||||
new Callback<Void>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull Response<Void> response) {
|
||||
if(response.isSuccessful()) {
|
||||
following = !following;
|
||||
if(following) {
|
||||
Toasty.success(ProfileActivity.this, String.format(getString(R.string.nowFollowUser), username));
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<Void> call, @NonNull Response<Void> response) {
|
||||
if (response.isSuccessful()) {
|
||||
following = !following;
|
||||
if (following) {
|
||||
Toasty.success(
|
||||
ProfileActivity.this,
|
||||
String.format(getString(R.string.nowFollowUser), username));
|
||||
} else {
|
||||
Toasty.success(
|
||||
ProfileActivity.this,
|
||||
String.format(
|
||||
getString(R.string.unfollowedUser), username));
|
||||
}
|
||||
} else {
|
||||
if (following) {
|
||||
Toasty.error(
|
||||
ProfileActivity.this,
|
||||
getString(R.string.unfollowingFailed));
|
||||
} else {
|
||||
Toasty.error(
|
||||
ProfileActivity.this, getString(R.string.followingFailed));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
Toasty.success(ProfileActivity.this, String.format(getString(R.string.unfollowedUser), username));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(following) {
|
||||
Toasty.error(ProfileActivity.this, getString(R.string.unfollowingFailed));
|
||||
}
|
||||
else {
|
||||
Toasty.error(ProfileActivity.this, getString(R.string.followingFailed));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
if(following) {
|
||||
Toasty.error(ProfileActivity.this, getString(R.string.unfollowingFailed));
|
||||
}
|
||||
else {
|
||||
Toasty.error(ProfileActivity.this, getString(R.string.followingFailed));
|
||||
}
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
if (following) {
|
||||
Toasty.error(
|
||||
ProfileActivity.this, getString(R.string.unfollowingFailed));
|
||||
} else {
|
||||
Toasty.error(ProfileActivity.this, getString(R.string.followingFailed));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -178,22 +193,21 @@ public class ProfileActivity extends BaseActivity implements BottomSheetListener
|
|||
|
||||
int id = item.getItemId();
|
||||
|
||||
if(id == android.R.id.home) {
|
||||
if (id == android.R.id.home) {
|
||||
finish();
|
||||
return true;
|
||||
}
|
||||
else if(id == R.id.genericMenu) {
|
||||
new BottomSheetUserProfileFragment(following).show(getSupportFragmentManager(), "userProfileBottomSheet");
|
||||
} else if (id == R.id.genericMenu) {
|
||||
new BottomSheetUserProfileFragment(following)
|
||||
.show(getSupportFragmentManager(), "userProfileBottomSheet");
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
if(!username.equals(getAccount().getAccount().getUserName())) {
|
||||
if (!username.equals(getAccount().getAccount().getUserName())) {
|
||||
getMenuInflater().inflate(R.menu.generic_nav_dotted_menu, menu);
|
||||
}
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
|
@ -205,10 +219,9 @@ public class ProfileActivity extends BaseActivity implements BottomSheetListener
|
|||
super(fa);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
@NonNull @Override
|
||||
public Fragment createFragment(int position) {
|
||||
switch(position) {
|
||||
switch (position) {
|
||||
case 0: // detail
|
||||
return DetailFragment.newInstance(username);
|
||||
case 1: // repos
|
||||
|
@ -229,7 +242,5 @@ public class ProfileActivity extends BaseActivity implements BottomSheetListener
|
|||
public int getItemCount() {
|
||||
return 6;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -14,6 +14,8 @@ import androidx.annotation.NonNull;
|
|||
import androidx.appcompat.widget.SearchView;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.gitnex.tea4j.v2.models.Repository;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.RepoForksAdapter;
|
||||
|
@ -21,8 +23,6 @@ import org.mian.gitnex.clients.RetrofitClient;
|
|||
import org.mian.gitnex.databinding.ActivityRepoForksBinding;
|
||||
import org.mian.gitnex.helpers.Constants;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
@ -30,7 +30,6 @@ import retrofit2.Response;
|
|||
/**
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class RepoForksActivity extends BaseActivity {
|
||||
|
||||
private ActivityRepoForksBinding activityRepoForksBinding;
|
||||
|
@ -59,30 +58,38 @@ public class RepoForksActivity extends BaseActivity {
|
|||
final String repoOwner = repository.getOwner();
|
||||
final String repoName = repository.getName();
|
||||
|
||||
activityRepoForksBinding.toolbarTitle.setText(ctx.getResources().getString(R.string.infoTabRepoForksCount));
|
||||
activityRepoForksBinding.toolbarTitle.setText(
|
||||
ctx.getResources().getString(R.string.infoTabRepoForksCount));
|
||||
|
||||
activityRepoForksBinding.close.setOnClickListener(v -> finish());
|
||||
resultLimit = Constants.getCurrentResultLimit(ctx);
|
||||
forksList = new ArrayList<>();
|
||||
|
||||
activityRepoForksBinding.pullToRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
|
||||
pageSize = 1;
|
||||
activityRepoForksBinding.pullToRefresh.setRefreshing(false);
|
||||
loadInitial(repoOwner, repoName, pageSize, resultLimit);
|
||||
adapter.notifyDataChanged();
|
||||
|
||||
}, 200));
|
||||
activityRepoForksBinding.pullToRefresh.setOnRefreshListener(
|
||||
() ->
|
||||
new Handler(Looper.getMainLooper())
|
||||
.postDelayed(
|
||||
() -> {
|
||||
pageSize = 1;
|
||||
activityRepoForksBinding.pullToRefresh.setRefreshing(
|
||||
false);
|
||||
loadInitial(repoOwner, repoName, pageSize, resultLimit);
|
||||
adapter.notifyDataChanged();
|
||||
},
|
||||
200));
|
||||
|
||||
adapter = new RepoForksAdapter(ctx, forksList);
|
||||
adapter.setLoadMoreListener(() -> activityRepoForksBinding.recyclerView.post(() -> {
|
||||
adapter.setLoadMoreListener(
|
||||
() ->
|
||||
activityRepoForksBinding.recyclerView.post(
|
||||
() -> {
|
||||
if (forksList.size() == resultLimit
|
||||
|| pageSize == resultLimit) {
|
||||
|
||||
if(forksList.size() == resultLimit || pageSize == resultLimit) {
|
||||
|
||||
int page = (forksList.size() + resultLimit) / resultLimit;
|
||||
loadMore(repoOwner, repoName, page, resultLimit);
|
||||
}
|
||||
}));
|
||||
int page = (forksList.size() + resultLimit) / resultLimit;
|
||||
loadMore(repoOwner, repoName, page, resultLimit);
|
||||
}
|
||||
}));
|
||||
|
||||
activityRepoForksBinding.recyclerView.setHasFixedSize(true);
|
||||
activityRepoForksBinding.recyclerView.setLayoutManager(new LinearLayoutManager(ctx));
|
||||
|
@ -93,85 +100,91 @@ public class RepoForksActivity extends BaseActivity {
|
|||
|
||||
private void loadInitial(String repoOwner, String repoName, int pageSize, int resultLimit) {
|
||||
|
||||
Call<List<Repository>> call = RetrofitClient.getApiInterface(ctx).listForks(repoOwner, repoName, pageSize, resultLimit);
|
||||
Call<List<Repository>> call =
|
||||
RetrofitClient.getApiInterface(ctx)
|
||||
.listForks(repoOwner, repoName, pageSize, resultLimit);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Repository>> call, @NonNull Response<List<Repository>> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<List<Repository>> call,
|
||||
@NonNull Response<List<Repository>> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if (response.isSuccessful()) {
|
||||
|
||||
assert response.body() != null;
|
||||
assert response.body() != null;
|
||||
|
||||
if(response.body().size() > 0) {
|
||||
forksList.clear();
|
||||
forksList.addAll(response.body());
|
||||
adapter.notifyDataChanged();
|
||||
activityRepoForksBinding.noData.setVisibility(View.GONE);
|
||||
}
|
||||
else {
|
||||
forksList.clear();
|
||||
adapter.notifyDataChanged();
|
||||
activityRepoForksBinding.noData.setVisibility(View.VISIBLE);
|
||||
if (response.body().size() > 0) {
|
||||
forksList.clear();
|
||||
forksList.addAll(response.body());
|
||||
adapter.notifyDataChanged();
|
||||
activityRepoForksBinding.noData.setVisibility(View.GONE);
|
||||
} else {
|
||||
forksList.clear();
|
||||
adapter.notifyDataChanged();
|
||||
activityRepoForksBinding.noData.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
activityRepoForksBinding.progressBar.setVisibility(View.GONE);
|
||||
} else {
|
||||
Log.e(TAG, String.valueOf(response.code()));
|
||||
}
|
||||
}
|
||||
|
||||
activityRepoForksBinding.progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
else {
|
||||
Log.e(TAG, String.valueOf(response.code()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Repository>> call, @NonNull Throwable t) {
|
||||
Log.e(TAG, t.toString());
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onFailure(
|
||||
@NonNull Call<List<Repository>> call, @NonNull Throwable t) {
|
||||
Log.e(TAG, t.toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void loadMore(String repoOwner, String repoName, int page, int resultLimit) {
|
||||
|
||||
activityRepoForksBinding.progressLoadMore.setVisibility(View.VISIBLE);
|
||||
|
||||
Call<List<Repository>> call = RetrofitClient.getApiInterface(ctx).listForks(repoOwner, repoName, page, resultLimit);
|
||||
Call<List<Repository>> call =
|
||||
RetrofitClient.getApiInterface(ctx)
|
||||
.listForks(repoOwner, repoName, page, resultLimit);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Repository>> call, @NonNull Response<List<Repository>> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<List<Repository>> call,
|
||||
@NonNull Response<List<Repository>> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if (response.isSuccessful()) {
|
||||
|
||||
//remove loading view
|
||||
forksList.remove(forksList.size() - 1);
|
||||
// remove loading view
|
||||
forksList.remove(forksList.size() - 1);
|
||||
|
||||
List<Repository> result = response.body();
|
||||
assert result != null;
|
||||
List<Repository> result = response.body();
|
||||
assert result != null;
|
||||
|
||||
if(result.size() > 0) {
|
||||
pageSize = result.size();
|
||||
forksList.addAll(result);
|
||||
}
|
||||
else {
|
||||
adapter.setMoreDataAvailable(false);
|
||||
if (result.size() > 0) {
|
||||
pageSize = result.size();
|
||||
forksList.addAll(result);
|
||||
} else {
|
||||
adapter.setMoreDataAvailable(false);
|
||||
}
|
||||
|
||||
adapter.notifyDataChanged();
|
||||
activityRepoForksBinding.progressLoadMore.setVisibility(View.GONE);
|
||||
} else {
|
||||
Log.e(TAG, String.valueOf(response.code()));
|
||||
}
|
||||
}
|
||||
|
||||
adapter.notifyDataChanged();
|
||||
activityRepoForksBinding.progressLoadMore.setVisibility(View.GONE);
|
||||
}
|
||||
else {
|
||||
Log.e(TAG, String.valueOf(response.code()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Repository>> call, @NonNull Throwable t) {
|
||||
Log.e(TAG, t.toString());
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@Override
|
||||
public void onFailure(
|
||||
@NonNull Call<List<Repository>> call, @NonNull Throwable t) {
|
||||
Log.e(TAG, t.toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -184,19 +197,20 @@ public class RepoForksActivity extends BaseActivity {
|
|||
SearchView searchView = (SearchView) searchItem.getActionView();
|
||||
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||
|
||||
searchView.setOnQueryTextListener(new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
||||
searchView.setOnQueryTextListener(
|
||||
new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
filter(newText);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
filter(newText);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
@ -204,8 +218,10 @@ public class RepoForksActivity extends BaseActivity {
|
|||
private void filter(String text) {
|
||||
List<Repository> userRepositories = new ArrayList<>();
|
||||
|
||||
for(Repository d : forksList) {
|
||||
if(d.getOwner().getLogin().contains(text) || d.getName().toLowerCase().contains(text) || d.getDescription().toLowerCase().contains(text)) {
|
||||
for (Repository d : forksList) {
|
||||
if (d.getOwner().getLogin().contains(text)
|
||||
|| d.getName().toLowerCase().contains(text)
|
||||
|| d.getDescription().toLowerCase().contains(text)) {
|
||||
|
||||
userRepositories.add(d);
|
||||
}
|
||||
|
@ -219,5 +235,4 @@ public class RepoForksActivity extends BaseActivity {
|
|||
super.onResume();
|
||||
repository.checkAccountSwitch(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue