diff --git a/.editorconfig b/.editorconfig
index 3a04062e..c8ba226b 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -13,6 +13,7 @@ line_comment = //
block_comment_start = /*
block_comment = *
block_comment_end = */
+max_line_length = 220
[*.json]
indent_size = 2
diff --git a/.gitea/issue_template/bug.md b/.gitea/issue_template/bug.md
index 9ae53483..0cdffe9e 100644
--- a/.gitea/issue_template/bug.md
+++ b/.gitea/issue_template/bug.md
@@ -9,6 +9,7 @@ labels:
---
## # Describe your matter briefly
+
##### What did you expect?
@@ -18,13 +19,13 @@ labels:
##### Some additional details
---
-* The version of **Gitea** you are using:
-* The version of **GitNex** you are using:
-* Source of installation (Play Store, F-Droid, APK):
-* Current android version and phone model/manufacturer:
-* The type of certificate your instance is using (self-signed, signed):
-* How you used to log in (via password or token):
-
+* The version of **Gitea** you are using:
+* The version of **GitNex** you are using:
+* Source of installation (Play Store, F-Droid, APK):
+* Current android version and phone model/manufacturer:
+* The type of certificate your instance is using (self-signed, signed):
+* How you used to log in (via password or token):
+
##### We would appreciate some screenshots or stacktrace's, but this is also not required.
---
@@ -32,6 +33,6 @@ labels:
- [ ] I carefully read the [contribution guidelines](https://codeberg.org/gitnex/GitNex/wiki/Contributing).
-
+
diff --git a/.gitea/issue_template/feature.md b/.gitea/issue_template/feature.md
index 14d225b9..4eed2529 100644
--- a/.gitea/issue_template/feature.md
+++ b/.gitea/issue_template/feature.md
@@ -9,9 +9,10 @@ labels:
---
## # Describe your matter briefly
+
- [ ] I carefully read the [contribution guidelines](https://codeberg.org/gitnex/GitNex/wiki/Contributing).
-
+
diff --git a/.gitea/issue_template/suggestion.md b/.gitea/issue_template/suggestion.md
index 0e00e914..625f9af6 100644
--- a/.gitea/issue_template/suggestion.md
+++ b/.gitea/issue_template/suggestion.md
@@ -9,6 +9,7 @@ labels:
---
## # Describe your matter briefly
+
##### What did you expect?
@@ -18,13 +19,13 @@ labels:
##### Some additional details
---
-* The version of **Gitea** you are using:
-* The version of **GitNex** you are using:
-* Source of installation (Play Store, F-Droid, APK):
-* Current android version and phone model/manufacturer:
-* The type of certificate your instance is using (self-signed, signed):
-* How you used to log in (via password or token):
-
+* The version of **Gitea** you are using:
+* The version of **GitNex** you are using:
+* Source of installation (Play Store, F-Droid, APK):
+* Current android version and phone model/manufacturer:
+* The type of certificate your instance is using (self-signed, signed):
+* How you used to log in (via password or token):
+
##### We would appreciate some screenshots or stacktrace's, but this is also not required.
---
@@ -32,6 +33,6 @@ labels:
- [ ] I carefully read the [contribution guidelines](https://codeberg.org/gitnex/GitNex/wiki/Contributing).
-
+
diff --git a/.gitea/pull_request_template.md b/.gitea/pull_request_template.md
index b9a0ce9a..96fb4b18 100644
--- a/.gitea/pull_request_template.md
+++ b/.gitea/pull_request_template.md
@@ -1,4 +1,5 @@
### Describe what your pull request does and which issue you’re targeting
+
@@ -6,4 +7,5 @@
- [ ] I carefully read the [contribution guidelines](https://codeberg.org/GitNex/GitNex/src/branch/main/CONTRIBUTING.md).
- [ ] I'm following the code standards as defined [here](https://codeberg.org/gitnex/GitNex/wiki/Code-Standards).
-- [ ] By submitting this pull request, I permit GitNex to license my work under the [GNU General Public License v3](https://codeberg.org/GitNex/GitNex/src/branch/main/LICENSE).
\ No newline at end of file
+- [ ] By submitting this pull request, I permit GitNex to license my work under
+ the [GNU General Public License v3](https://codeberg.org/GitNex/GitNex/src/branch/main/LICENSE).
\ No newline at end of file
diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
index e22b2741..9b23ea37 100644
--- a/.idea/codeStyles/Project.xml
+++ b/.idea/codeStyles/Project.xml
@@ -1,182 +1,166 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- xmlns:android
-
- ^$
-
-
-
-
-
-
-
-
- xmlns:.*
-
- ^$
-
-
- BY_NAME
-
-
-
-
-
-
- .*:id
-
- http://schemas.android.com/apk/res/android
-
-
-
-
-
-
-
-
- .*:name
-
- http://schemas.android.com/apk/res/android
-
-
-
-
-
-
-
-
- name
-
- ^$
-
-
-
-
-
-
-
-
- style
-
- ^$
-
-
-
-
-
-
-
-
- .*
-
- ^$
-
-
- BY_NAME
-
-
-
-
-
-
- .*
-
- http://schemas.android.com/apk/res/android
-
-
- ANDROID_ATTRIBUTE_ORDER
-
-
-
-
-
-
- .*
-
- .*
-
-
- BY_NAME
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ xmlns:android
+
+ ^$
+
+
+
+
+
+
+
+
+ xmlns:.*
+
+ ^$
+
+
+ BY_NAME
+
+
+
+
+
+
+ .*:id
+
+ http://schemas.android.com/apk/res/android
+
+
+
+
+
+
+
+
+ .*:name
+
+ http://schemas.android.com/apk/res/android
+
+
+
+
+
+
+
+
+ name
+
+ ^$
+
+
+
+
+
+
+
+
+ style
+
+ ^$
+
+
+
+
+
+
+
+
+ .*
+
+ ^$
+
+
+ BY_NAME
+
+
+
+
+
+
+ .*
+
+ http://schemas.android.com/apk/res/android
+
+
+ ANDROID_ATTRIBUTE_ORDER
+
+
+
+
+
+
+ .*
+
+ .*
+
+
+ BY_NAME
+
+
+
+
+
+
diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml
index 79ee123c..a4e3ea4b 100644
--- a/.idea/codeStyles/codeStyleConfig.xml
+++ b/.idea/codeStyles/codeStyleConfig.xml
@@ -1,5 +1,5 @@
-
-
-
-
\ No newline at end of file
+
+
+
+
diff --git a/.woodpecker/check.yml b/.woodpecker/check.yml
index bde80909..3d929904 100644
--- a/.woodpecker/check.yml
+++ b/.woodpecker/check.yml
@@ -1,6 +1,7 @@
pipeline:
author-header:
image: qwerty287/woodpecker-regex-check
+ group: check
settings:
pattern: "*.java"
regex: " \\\\* \\\\@author [\\\\S\\\\s]+"
@@ -8,3 +9,7 @@ pipeline:
style:
image: qwerty287/woodpecker-intellij-formatter
+ group: check
+ settings:
+ file_pattern: "*.java"
+ path: "app/"
diff --git a/.woodpecker/finish.yml b/.woodpecker/finish.yml
index b6bdcf3b..7202f32d 100644
--- a/.woodpecker/finish.yml
+++ b/.woodpecker/finish.yml
@@ -1,22 +1,22 @@
depends_on:
- - build
- - locale
- - check
+ - build
+ - locale
+ - check
run_on: [ success, failure ]
skip_clone: true
pipeline:
- discord:
- image: appleboy/drone-discord
- settings:
- message: "{{#success build.status}} ✅ Build #{{build.number}} of `{{repo.name}}` succeeded.\n\n📝 Commit by {{commit.author}}:\n``` {{commit.message}} ```\n\n🌐 {{ build.link }} {{else}} ❌ Build #{{build.number}} of `{{repo.name}}` failed.\n\n📝 Commit by {{commit.author}}:\n``` {{commit.message}} ```\n\n🌐 {{ build.link }} {{/success}}\n"
- webhook_id:
- from_secret:
- DISCORD_BOT_ID
- webhook_token:
- from_secret:
- DISCORD_BOT_SECRET
- when:
- event: [ push ]
- branch: main
+ discord:
+ image: appleboy/drone-discord
+ settings:
+ message: "{{#success build.status}} ✅ Build #{{build.number}} of `{{repo.name}}` succeeded.\n\n📝 Commit by {{commit.author}}:\n``` {{commit.message}} ```\n\n🌐 {{ build.link }} {{else}} ❌ Build #{{build.number}} of `{{repo.name}}` failed.\n\n📝 Commit by {{commit.author}}:\n``` {{commit.message}} ```\n\n🌐 {{ build.link }} {{/success}}\n"
+ webhook_id:
+ from_secret:
+ DISCORD_BOT_ID
+ webhook_token:
+ from_secret:
+ DISCORD_BOT_SECRET
+ when:
+ event: [ push ]
+ branch: main
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b5e68948..0fb76b5d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,2 +1,3 @@
# Changelog
+
[Check out the release notes](https://codeberg.org/gitnex/GitNex/releases)
diff --git a/README.md b/README.md
index 3a99f1ba..e118d1cd 100644
--- a/README.md
+++ b/README.md
@@ -4,26 +4,33 @@
# GitNex - Android client for Gitea
-GitNex is a free/paid, open-source Android client for Git repository management tool Gitea. Gitea is a community managed fork of Gogs, lightweight code hosting solution written in Go.
+GitNex is a free/paid, open-source Android client for Git repository management tool Gitea. Gitea is a community managed fork of Gogs, lightweight
+code hosting solution written in Go.
-GitNex is licensed under GPLv3 License. See the LICENSE file for the full license text. **No trackers are used** and source code is available here for anyone to audit.
+GitNex is licensed under GPLv3 License. See the LICENSE file for the full license text. **No trackers are used** and source code is available here for
+anyone to audit.
## Downloads
+
[ ](https://f-droid.org/en/packages/org.mian.gitnex/)
[ ](https://play.google.com/store/apps/details?id=org.mian.gitnex.pro)
[ ](https://cloud.swatian.com/s/DN7E5xxtaw4fRbE)
## Note about Gitea version
+
Please make sure that you are on latest stable release or later for better app experience.
-Check the versions [compatibility page](https://codeberg.org/gitnex/GitNex/wiki/Compatibility) which lists all the supported versions with compatibility ratio.
+Check the versions [compatibility page](https://codeberg.org/gitnex/GitNex/wiki/Compatibility) which lists all the supported versions with
+compatibility ratio.
## Build from source
+
Option 1 - Download the source code, open it in Android Studio and build it there.
Option 2 - Open terminal(Linux) and cd to the project dir. Run `./gradlew assembleFree`.
## Features
+
- Multiple accounts support
- File and directory browser
- File viewer
@@ -37,12 +44,15 @@ Option 2 - Open terminal(Linux) and cd to the project dir. Run `./gradlew assemb
- [& more...](https://codeberg.org/gitnex/GitNex/wiki/Features)
## Contributing
+
[Contributing](https://codeberg.org/gitnex/GitNex/wiki/Contributing)
## Translation
+
Help us translate GitNex to your native language.
-We use [Crowdin](https://crowdin.com/project/gitnex) for translation. If your language is not listed, please request [here](https://codeberg.org/gitnex/GitNex/issues) to add it to the project.
+We use [Crowdin](https://crowdin.com/project/gitnex) for translation. If your language is not listed, please
+request [here](https://codeberg.org/gitnex/GitNex/issues) to add it to the project.
**Link: https://crowdin.com/project/GitNex**
@@ -53,6 +63,7 @@ We use [Crowdin](https://crowdin.com/project/gitnex) for translation. If your la
[ ](https://codeberg.org/gitnex/GitNex/raw/branch/main/fastlane/metadata/android/en-US/images/phoneScreenshots/005.png) | [ ](https://codeberg.org/gitnex/GitNex/raw/branch/main/fastlane/metadata/android/en-US/images/phoneScreenshots/006.png) | [ ](https://codeberg.org/gitnex/GitNex/raw/branch/main/fastlane/metadata/android/en-US/images/phoneScreenshots/007.png) | [ ](https://codeberg.org/gitnex/GitNex/raw/branch/main/fastlane/metadata/android/en-US/images/phoneScreenshots/008.png)
## Links
+
[Website](https://gitnex.com)
[Wiki](https://codeberg.org/gitnex/GitNex/wiki/Home)
@@ -64,9 +75,11 @@ We use [Crowdin](https://crowdin.com/project/gitnex) for translation. If your la
[Release Blog](https://gitnex.codeberg.page)
## Thanks
+
Thanks to all the open source libraries, contributors and donators.
#### Open source libraries
+
- [square/retrofit](https://github.com/square/retrofit)
- [google/gson](https://github.com/google/gson)
- [square/okhttp](https://github.com/square/okhttp)
@@ -89,6 +102,7 @@ Thanks to all the open source libraries, contributors and donators.
- [AmrDeveloper/CodeView](https://github.com/AmrDeveloper/CodeView)
#### Icon sets
+
- [lucide-icons/lucide](https://github.com/lucide-icons/lucide)
- [primer/octicons](https://github.com/primer/octicons)
- [google/material-design-icons](https://github.com/google/material-design-icons)
diff --git a/app/build.gradle b/app/build.gradle
index dbceb658..1e2668fa 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -39,7 +39,7 @@ android {
lint {
abortOnError false
}
- defaultConfig{
+ defaultConfig {
vectorDrawables.useSupportLibrary = true
}
}
diff --git a/app/src/androidTest/java/org/main/gitnex/helpers/AppUtilTest.java b/app/src/androidTest/java/org/main/gitnex/helpers/AppUtilTest.java
index ec387e2b..d8b19d11 100644
--- a/app/src/androidTest/java/org/main/gitnex/helpers/AppUtilTest.java
+++ b/app/src/androidTest/java/org/main/gitnex/helpers/AppUtilTest.java
@@ -8,9 +8,7 @@ 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.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.*;
/**
* @author qwerty287
@@ -109,5 +107,6 @@ public class AppUtilTest {
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());
}
+
}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 595f6c2b..2aaa6ec5 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -3,10 +3,10 @@
xmlns:tools="http://schemas.android.com/tools"
package="org.mian.gitnex">
-
-
-
-
+
+
+
+
+ android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
+ android:theme="@style/AppTheme.NoActionBar"/>
+ android:theme="@style/AppTheme.NoActionBar"/>
+ android:theme="@style/AppTheme.NoActionBar"/>
+ android:theme="@style/AppTheme.NoActionBar"/>
+ android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
+ android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
+ android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
+ android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
+ android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
+ android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
+ android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
+ android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
+ android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
+ android:theme="@style/AppTheme.NoActionBar"/>
+ android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
+ android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
+ android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
+ android:windowSoftInputMode="adjustNothing"/>
+ android:theme="@style/AppTheme.NoActionBar"/>
+ android:exported="true"
+ android:theme="@android:style/Theme.NoTitleBar">
-
-
+
+
+ android:theme="@android:style/Theme.NoTitleBar"/>
+ android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
+ android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
+ android:theme="@android:style/Theme.NoTitleBar"/>
+ android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
+ android:theme="@android:style/Theme.NoTitleBar"/>
+ android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
+ android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
+ android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
+ android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
+ android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
+ android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
+ android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
+ android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
+ android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
+ android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
+ android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
+ android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
+ android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
+ android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
+ android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
+ android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
+ android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"
+ android:windowSoftInputMode="adjustResize"/>
+
+ android:value="true"/>
+ android:value="true"/>
+ android:theme="@android:style/Theme.Translucent.NoTitleBar">
-
+
-
-
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/app/src/main/java/org/mian/gitnex/actions/ActionResult.java b/app/src/main/java/org/mian/gitnex/actions/ActionResult.java
index 4c88eeff..3fe1077d 100644
--- a/app/src/main/java/org/mian/gitnex/actions/ActionResult.java
+++ b/app/src/main/java/org/mian/gitnex/actions/ActionResult.java
@@ -14,11 +14,8 @@ import java.util.concurrent.TimeUnit;
public class ActionResult {
- public enum Status { SUCCESS, FAILED }
-
private final BlockingQueue blockingQueue;
private final List> onFinishedListeners;
-
private boolean invalidated = false;
public ActionResult() {
@@ -42,13 +39,17 @@ public class ActionResult {
onFinishedListener.onFinished(status, result);
}
- } catch (InterruptedException ignored) {}
+ }
+ catch(InterruptedException ignored) {
+ }
}
public void invalidate() {
- if(invalidated) throw new IllegalStateException("Already invalidated");
+ if(invalidated) {
+ throw new IllegalStateException("Already invalidated");
+ }
this.invalidated = true;
}
@@ -70,11 +71,16 @@ public class ActionResult {
}
- public static class None {}
+ public enum Status {SUCCESS, FAILED}
public interface OnFinishedListener {
void onFinished(Status status, R result);
+
+ }
+
+ public static class None {
+
}
}
diff --git a/app/src/main/java/org/mian/gitnex/actions/AssigneesActions.java b/app/src/main/java/org/mian/gitnex/actions/AssigneesActions.java
index 5144420f..1bf05b25 100644
--- a/app/src/main/java/org/mian/gitnex/actions/AssigneesActions.java
+++ b/app/src/main/java/org/mian/gitnex/actions/AssigneesActions.java
@@ -24,9 +24,7 @@ public class AssigneesActions {
public static void getCurrentIssueAssignees(Context ctx, String repoOwner, String repoName, int issueIndex, List currentAssignees) {
- Call callSingleIssueLabels = RetrofitClient
- .getApiInterface(ctx)
- .issueGetIssue(repoOwner, repoName, (long) issueIndex);
+ Call callSingleIssueLabels = RetrofitClient.getApiInterface(ctx).issueGetIssue(repoOwner, repoName, (long) issueIndex);
callSingleIssueLabels.enqueue(new Callback<>() {
@@ -63,11 +61,10 @@ public class AssigneesActions {
});
}
- public static void getRepositoryAssignees(Context ctx, String repoOwner, String repoName, List assigneesList, MaterialAlertDialogBuilder materialAlertDialogBuilder, AssigneesListAdapter assigneesAdapter, CustomAssigneesSelectionDialogBinding assigneesBinding, ProgressBar progressBar) {
+ public static void getRepositoryAssignees(Context ctx, String repoOwner, String repoName, List assigneesList, MaterialAlertDialogBuilder materialAlertDialogBuilder, AssigneesListAdapter assigneesAdapter,
+ CustomAssigneesSelectionDialogBinding assigneesBinding, ProgressBar progressBar) {
- Call> call = RetrofitClient
- .getApiInterface(ctx)
- .repoGetAssignees(repoOwner, repoName);
+ Call> call = RetrofitClient.getApiInterface(ctx).repoGetAssignees(repoOwner, repoName);
call.enqueue(new Callback<>() {
@@ -113,4 +110,5 @@ public class AssigneesActions {
}
});
}
+
}
diff --git a/app/src/main/java/org/mian/gitnex/actions/CollaboratorActions.java b/app/src/main/java/org/mian/gitnex/actions/CollaboratorActions.java
index fa65264a..bccf8195 100644
--- a/app/src/main/java/org/mian/gitnex/actions/CollaboratorActions.java
+++ b/app/src/main/java/org/mian/gitnex/actions/CollaboratorActions.java
@@ -19,97 +19,94 @@ import retrofit2.Callback;
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 call = RetrofitClient
- .getApiInterface(context)
- .repoDeleteCollaborator(repository.getOwner(), repository.getName(), userName);
+ Call call = RetrofitClient.getApiInterface(context).repoDeleteCollaborator(repository.getOwner(), repository.getName(), userName);
- call.enqueue(new Callback<>() {
+ call.enqueue(new Callback<>() {
- @Override
- public void onResponse(@NonNull Call call, @NonNull retrofit2.Response response) {
+ @Override
+ public void onResponse(@NonNull Call call, @NonNull retrofit2.Response 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();
- }
- }
- else if(response.code() == 401) {
+ 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) {
+ 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 call, @NonNull Throwable t) {
+ @Override
+ public void onFailure(@NonNull Call 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 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();
+ AddCollaboratorOption permissionString = new AddCollaboratorOption();
permissionString.setPermission(permission);
- Call call = RetrofitClient
- .getApiInterface(context)
- .repoAddCollaborator(repository.getOwner(), repository.getName(), userName, permissionString);
+ Call 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 call, @NonNull retrofit2.Response response) {
+ @Override
+ public void onResponse(@NonNull Call call, @NonNull retrofit2.Response 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();
- }
- }
- else if(response.code() == 401) {
+ 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) {
+ 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 call, @NonNull Throwable t) {
+ @Override
+ public void onFailure(@NonNull Call call, @NonNull Throwable t) {
+
+ Toasty.error(context, context.getResources().getString(R.string.genericServerResponseError));
+ }
+ });
+ }
- Toasty.error(context, context.getResources().getString(R.string.genericServerResponseError));
- }
- });
- }
}
diff --git a/app/src/main/java/org/mian/gitnex/actions/IssueActions.java b/app/src/main/java/org/mian/gitnex/actions/IssueActions.java
index 9590fba0..a8856641 100644
--- a/app/src/main/java/org/mian/gitnex/actions/IssueActions.java
+++ b/app/src/main/java/org/mian/gitnex/actions/IssueActions.java
@@ -3,11 +3,7 @@ package org.mian.gitnex.actions;
import android.app.Activity;
import android.content.Context;
import androidx.annotation.NonNull;
-import org.gitnex.tea4j.v2.models.Comment;
-import org.gitnex.tea4j.v2.models.CreateIssueCommentOption;
-import org.gitnex.tea4j.v2.models.EditIssueCommentOption;
-import org.gitnex.tea4j.v2.models.EditIssueOption;
-import org.gitnex.tea4j.v2.models.Issue;
+import org.gitnex.tea4j.v2.models.*;
import org.mian.gitnex.R;
import org.mian.gitnex.activities.BaseActivity;
import org.mian.gitnex.activities.IssueDetailActivity;
@@ -35,10 +31,7 @@ public class IssueActions {
EditIssueCommentOption commentObj = new EditIssueCommentOption();
commentObj.setBody(comment);
- Call call = RetrofitClient
- .getApiInterface(context)
- .issueEditComment(issue.getRepository().getOwner(),
- issue.getRepository().getName(), (long) commentId, commentObj);
+ Call call = RetrofitClient.getApiInterface(context).issueEditComment(issue.getRepository().getOwner(), issue.getRepository().getName(), (long) commentId, commentObj);
call.enqueue(new Callback<>() {
@@ -77,10 +70,7 @@ public class IssueActions {
EditIssueOption issueStatJson = new EditIssueOption();
issueStatJson.setState(issueState);
- Call call = RetrofitClient
- .getApiInterface(ctx)
- .issueEditIssue(issue.getRepository().getOwner(),
- issue.getRepository().getName(), (long) issue.getIssueIndex(), issueStatJson);
+ Call call = RetrofitClient.getApiInterface(ctx).issueEditIssue(issue.getRepository().getOwner(), issue.getRepository().getName(), (long) issue.getIssueIndex(), issueStatJson);
call.enqueue(new Callback<>() {
@@ -113,8 +103,7 @@ public class IssueActions {
IssueDetailActivity.singleIssueUpdate = true;
((IssueDetailActivity) ctx).onResume();
- if(((Activity) ctx).getIntent().getStringExtra("openedFromLink") == null ||
- !((Activity) ctx).getIntent().getStringExtra("openedFromLink").equals("true")) {
+ if(((Activity) ctx).getIntent().getStringExtra("openedFromLink") == null || !((Activity) ctx).getIntent().getStringExtra("openedFromLink").equals("true")) {
RepoDetailActivity.updateRepo = true;
}
}
@@ -150,10 +139,8 @@ public class IssueActions {
Call 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<>() {
@@ -193,8 +180,8 @@ public class IssueActions {
Call 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<>() {
@@ -237,10 +224,7 @@ public class IssueActions {
CreateIssueCommentOption issueComment = new CreateIssueCommentOption();
issueComment.setBody(comment);
- Call call = RetrofitClient
- .getApiInterface(context)
- .issueCreateComment(issue.getRepository().getOwner(),
- issue.getRepository().getName(), (long) issue.getIssueIndex(), issueComment);
+ Call call = RetrofitClient.getApiInterface(context).issueCreateComment(issue.getRepository().getOwner(), issue.getRepository().getName(), (long) issue.getIssueIndex(), issueComment);
call.enqueue(new Callback<>() {
@@ -275,4 +259,5 @@ public class IssueActions {
return actionResult;
}
+
}
diff --git a/app/src/main/java/org/mian/gitnex/actions/LabelsActions.java b/app/src/main/java/org/mian/gitnex/actions/LabelsActions.java
index eb0c340a..c020a977 100644
--- a/app/src/main/java/org/mian/gitnex/actions/LabelsActions.java
+++ b/app/src/main/java/org/mian/gitnex/actions/LabelsActions.java
@@ -23,9 +23,7 @@ public class LabelsActions {
public static void getCurrentIssueLabels(Context ctx, String repoOwner, String repoName, int issueIndex, List currentLabelsIds) {
- Call> callSingleIssueLabels = RetrofitClient
- .getApiInterface(ctx)
- .issueGetLabels(repoOwner, repoName, (long) issueIndex);
+ Call> callSingleIssueLabels = RetrofitClient.getApiInterface(ctx).issueGetLabels(repoOwner, repoName, (long) issueIndex);
callSingleIssueLabels.enqueue(new Callback<>() {
@@ -59,11 +57,10 @@ public class LabelsActions {
});
}
- public static void getRepositoryLabels(Context ctx, String repoOwner, String repoName, List labelsList, MaterialAlertDialogBuilder materialAlertDialogBuilder, LabelsListAdapter labelsAdapter, CustomLabelsSelectionDialogBinding labelsBinding, ProgressBar progressBar) {
+ public static void getRepositoryLabels(Context ctx, String repoOwner, String repoName, List labelsList, MaterialAlertDialogBuilder materialAlertDialogBuilder, LabelsListAdapter labelsAdapter,
+ CustomLabelsSelectionDialogBinding labelsBinding, ProgressBar progressBar) {
- Call> call = RetrofitClient
- .getApiInterface(ctx)
- .issueListLabels(repoOwner, repoName, null, null);
+ Call> call = RetrofitClient.getApiInterface(ctx).issueListLabels(repoOwner, repoName, null, null);
call.enqueue(new Callback<>() {
@@ -80,9 +77,7 @@ public class LabelsActions {
}
// Load organization labels
- Call> callOrgLabels = RetrofitClient
- .getApiInterface(ctx)
- .orgListLabels(repoOwner, null, null);
+ Call> callOrgLabels = RetrofitClient.getApiInterface(ctx).orgListLabels(repoOwner, null, null);
callOrgLabels.enqueue(new Callback<>() {
@@ -129,4 +124,5 @@ public class LabelsActions {
}
});
}
+
}
diff --git a/app/src/main/java/org/mian/gitnex/actions/MilestoneActions.java b/app/src/main/java/org/mian/gitnex/actions/MilestoneActions.java
index 2436f67e..f1cc3da7 100644
--- a/app/src/main/java/org/mian/gitnex/actions/MilestoneActions.java
+++ b/app/src/main/java/org/mian/gitnex/actions/MilestoneActions.java
@@ -32,9 +32,7 @@ public class MilestoneActions {
EditMilestoneOption milestoneStateJson = new EditMilestoneOption();
milestoneStateJson.setState(state);
- Call call = RetrofitClient
- .getApiInterface(ctx)
- .issueEditMilestone(repository.getOwner(), repository.getName(), String.valueOf(milestoneId_), milestoneStateJson);
+ Call call = RetrofitClient.getApiInterface(ctx).issueEditMilestone(repository.getOwner(), repository.getName(), String.valueOf(milestoneId_), milestoneStateJson);
call.enqueue(new Callback<>() {
diff --git a/app/src/main/java/org/mian/gitnex/actions/PullRequestActions.java b/app/src/main/java/org/mian/gitnex/actions/PullRequestActions.java
index 29f7a615..6035ee3b 100644
--- a/app/src/main/java/org/mian/gitnex/actions/PullRequestActions.java
+++ b/app/src/main/java/org/mian/gitnex/actions/PullRequestActions.java
@@ -17,9 +17,7 @@ import retrofit2.Response;
public class PullRequestActions {
public static void deleteHeadBranch(Context context, String repoOwner, String repoName, String headBranch, boolean showToasts) {
- Call call = RetrofitClient
- .getApiInterface(context)
- .repoDeleteBranch(repoOwner, repoName, headBranch);
+ Call call = RetrofitClient.getApiInterface(context).repoDeleteBranch(repoOwner, repoName, headBranch);
call.enqueue(new Callback<>() {
@@ -79,8 +77,7 @@ public class PullRequestActions {
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) {
@@ -108,4 +105,5 @@ public class PullRequestActions {
}
});
}
+
}
diff --git a/app/src/main/java/org/mian/gitnex/actions/RepositoryActions.java b/app/src/main/java/org/mian/gitnex/actions/RepositoryActions.java
index e65e460b..900b3856 100644
--- a/app/src/main/java/org/mian/gitnex/actions/RepositoryActions.java
+++ b/app/src/main/java/org/mian/gitnex/actions/RepositoryActions.java
@@ -18,177 +18,170 @@ import retrofit2.Callback;
public class RepositoryActions {
- public static void starRepository(final Context context, RepositoryContext repository) {
+ public static void starRepository(final Context context, RepositoryContext repository) {
- Call call = RetrofitClient
- .getApiInterface(context)
- .userCurrentPutStar(repository.getOwner(), repository.getName());
+ Call call = RetrofitClient.getApiInterface(context).userCurrentPutStar(repository.getOwner(), repository.getName());
- call.enqueue(new Callback<>() {
+ call.enqueue(new Callback<>() {
- @Override
- public void onResponse(@NonNull Call call, @NonNull retrofit2.Response response) {
+ @Override
+ public void onResponse(@NonNull Call call, @NonNull retrofit2.Response 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));
- }
- }
- else if(response.code() == 401) {
+ MainActivity.reloadRepos = true;
+ Toasty.success(context, context.getString(R.string.starRepositorySuccess));
+ }
+ }
+ 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 call, @NonNull Throwable t) {
+ @Override
+ public void onFailure(@NonNull Call 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) {
+ public static void unStarRepository(final Context context, RepositoryContext repository) {
- Call call = RetrofitClient
- .getApiInterface(context)
- .userCurrentDeleteStar(repository.getOwner(), repository.getName());
+ Call call = RetrofitClient.getApiInterface(context).userCurrentDeleteStar(repository.getOwner(), repository.getName());
- call.enqueue(new Callback<>() {
+ call.enqueue(new Callback<>() {
- @Override
- public void onResponse(@NonNull Call call, @NonNull retrofit2.Response response) {
+ @Override
+ public void onResponse(@NonNull Call call, @NonNull retrofit2.Response 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));
- }
- }
- else if(response.code() == 401) {
+ MainActivity.reloadRepos = true;
+ Toasty.success(context, context.getString(R.string.unStarRepositorySuccess));
+ }
+ }
+ 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 call, @NonNull Throwable t) {
+ @Override
+ public void onFailure(@NonNull Call 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) {
+ public static void watchRepository(final Context context, RepositoryContext repository) {
- Call call = RetrofitClient
- .getApiInterface(context)
- .userCurrentPutSubscription(repository.getOwner(), repository.getName());
+ Call call = RetrofitClient.getApiInterface(context).userCurrentPutSubscription(repository.getOwner(), repository.getName());
- call.enqueue(new Callback<>() {
+ call.enqueue(new Callback<>() {
- @Override
- public void onResponse(@NonNull Call call, @NonNull retrofit2.Response response) {
+ @Override
+ public void onResponse(@NonNull Call call, @NonNull retrofit2.Response 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) {
+ }
+ }
+ 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 call, @NonNull Throwable t) {
+ @Override
+ public void onFailure(@NonNull Call 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) {
+ public static void unWatchRepository(final Context context, RepositoryContext repository) {
- Call call = RetrofitClient
- .getApiInterface(context)
- .userCurrentDeleteStar(repository.getOwner(), repository.getName());
+ Call call = RetrofitClient.getApiInterface(context).userCurrentDeleteStar(repository.getOwner(), repository.getName());
- call.enqueue(new Callback<>() {
+ call.enqueue(new Callback<>() {
- @Override
- public void onResponse(@NonNull Call call, @NonNull retrofit2.Response response) {
+ @Override
+ public void onResponse(@NonNull Call call, @NonNull retrofit2.Response 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 call, @NonNull Throwable t) {
+ @Override
+ public void onFailure(@NonNull Call call, @NonNull Throwable t) {
+
+ Toasty.error(context, context.getString(R.string.genericServerResponseError));
+ }
+ });
+ }
- Toasty.error(context, context.getString(R.string.genericServerResponseError));
- }
- });
- }
}
diff --git a/app/src/main/java/org/mian/gitnex/actions/TeamActions.java b/app/src/main/java/org/mian/gitnex/actions/TeamActions.java
index 2340aaa2..7ee82dcc 100644
--- a/app/src/main/java/org/mian/gitnex/actions/TeamActions.java
+++ b/app/src/main/java/org/mian/gitnex/actions/TeamActions.java
@@ -20,9 +20,7 @@ public class TeamActions {
public static void removeTeamMember(final Context context, String userName, int teamId) {
- Call call = RetrofitClient
- .getApiInterface(context)
- .orgRemoveTeamMember((long) teamId, userName);
+ Call call = RetrofitClient.getApiInterface(context).orgRemoveTeamMember((long) teamId, userName);
call.enqueue(new Callback<>() {
@@ -66,9 +64,7 @@ public class TeamActions {
public static void addTeamMember(final Context context, String userName, int teamId) {
- Call call = RetrofitClient
- .getApiInterface(context)
- .orgAddTeamMember((long) teamId, userName);
+ Call call = RetrofitClient.getApiInterface(context).orgAddTeamMember((long) teamId, userName);
call.enqueue(new Callback<>() {
@@ -111,9 +107,7 @@ public class TeamActions {
public static void removeTeamRepo(final Context context, String orgName, int teamId, String repo) {
- Call call = RetrofitClient
- .getApiInterface(context)
- .orgRemoveTeamRepository((long) teamId, orgName, repo);
+ Call call = RetrofitClient.getApiInterface(context).orgRemoveTeamRepository((long) teamId, orgName, repo);
call.enqueue(new Callback<>() {
@@ -158,9 +152,7 @@ public class TeamActions {
public static void addTeamRepo(final Context context, String orgName, int teamId, String repo) {
- Call call = RetrofitClient
- .getApiInterface(context)
- .orgAddTeamRepository((long) teamId, orgName, repo);
+ Call call = RetrofitClient.getApiInterface(context).orgAddTeamRepository((long) teamId, orgName, repo);
call.enqueue(new Callback<>() {
@@ -201,4 +193,5 @@ public class TeamActions {
}
});
}
+
}
diff --git a/app/src/main/java/org/mian/gitnex/activities/AddCollaboratorToRepositoryActivity.java b/app/src/main/java/org/mian/gitnex/activities/AddCollaboratorToRepositoryActivity.java
index 5e76a274..14ccd54a 100644
--- a/app/src/main/java/org/mian/gitnex/activities/AddCollaboratorToRepositoryActivity.java
+++ b/app/src/main/java/org/mian/gitnex/activities/AddCollaboratorToRepositoryActivity.java
@@ -29,106 +29,104 @@ import retrofit2.Response;
public class AddCollaboratorToRepositoryActivity extends BaseActivity {
private ActivityAddCollaboratorToRepositoryBinding activityAddCollaboratorToRepositoryBinding;
- private View.OnClickListener onClickListener;
- private RepositoryContext repository;
+ private View.OnClickListener onClickListener;
+ private RepositoryContext repository;
- @Override
- public void onCreate(Bundle savedInstanceState) {
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
+ 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());
+ repository = RepositoryContext.fromIntent(getIntent());
- activityAddCollaboratorToRepositoryBinding.addCollaboratorSearch.requestFocus();
- assert imm != null;
- imm.showSoftInput(activityAddCollaboratorToRepositoryBinding.addCollaboratorSearch, InputMethodManager.SHOW_IMPLICIT);
+ activityAddCollaboratorToRepositoryBinding.addCollaboratorSearch.requestFocus();
+ assert imm != null;
+ imm.showSoftInput(activityAddCollaboratorToRepositoryBinding.addCollaboratorSearch, InputMethodManager.SHOW_IMPLICIT);
- initCloseListener();
- activityAddCollaboratorToRepositoryBinding.close.setOnClickListener(onClickListener);
+ 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) {
+ public void loadUserSearchList(String searchKeyword) {
- Call call = RetrofitClient
- .getApiInterface(ctx)
- .userSearch(searchKeyword, null, 1, 10);
+ Call call = RetrofitClient.getApiInterface(ctx).userSearch(searchKeyword, null, 1, 10);
- call.enqueue(new Callback<>() {
+ call.enqueue(new Callback<>() {
- @Override
- public void onResponse(@NonNull Call call, @NonNull Response response) {
+ @Override
+ public void onResponse(@NonNull Call call, @NonNull Response 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 call, @NonNull Throwable t) {
- Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
- }
- });
- }
+ @Override
+ public void onFailure(@NonNull Call call, @NonNull Throwable t) {
+ Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
+ }
+ });
+ }
- private void getUsersList(List dataList, Context context) {
+ private void getUsersList(List 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));
- DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(activityAddCollaboratorToRepositoryBinding.recyclerViewUserSearch.getContext(),
- DividerItemDecoration.VERTICAL);
- activityAddCollaboratorToRepositoryBinding.recyclerViewUserSearch.addItemDecoration(dividerItemDecoration);
+ activityAddCollaboratorToRepositoryBinding.recyclerViewUserSearch.setHasFixedSize(true);
+ activityAddCollaboratorToRepositoryBinding.recyclerViewUserSearch.setLayoutManager(new LinearLayoutManager(ctx));
+ DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(activityAddCollaboratorToRepositoryBinding.recyclerViewUserSearch.getContext(), DividerItemDecoration.VERTICAL);
+ activityAddCollaboratorToRepositoryBinding.recyclerViewUserSearch.addItemDecoration(dividerItemDecoration);
- activityAddCollaboratorToRepositoryBinding.progressBar.setVisibility(View.VISIBLE);
+ activityAddCollaboratorToRepositoryBinding.progressBar.setVisibility(View.VISIBLE);
- if(adapter.getItemCount() > 0) {
+ if(adapter.getItemCount() > 0) {
- activityAddCollaboratorToRepositoryBinding.recyclerViewUserSearch.setAdapter(adapter);
- activityAddCollaboratorToRepositoryBinding.noData.setVisibility(View.GONE);
- }
- else {
+ activityAddCollaboratorToRepositoryBinding.recyclerViewUserSearch.setAdapter(adapter);
+ activityAddCollaboratorToRepositoryBinding.noData.setVisibility(View.GONE);
+ }
+ else {
- activityAddCollaboratorToRepositoryBinding.noData.setVisibility(View.VISIBLE);
- }
+ activityAddCollaboratorToRepositoryBinding.noData.setVisibility(View.VISIBLE);
+ }
- activityAddCollaboratorToRepositoryBinding.progressBar.setVisibility(View.GONE);
- }
+ activityAddCollaboratorToRepositoryBinding.progressBar.setVisibility(View.GONE);
+ }
- private void initCloseListener() {
- onClickListener = view -> finish();
- }
+ private void initCloseListener() {
+ onClickListener = view -> finish();
+ }
@Override
public void onResume() {
super.onResume();
repository.checkAccountSwitch(this);
}
+
}
diff --git a/app/src/main/java/org/mian/gitnex/activities/AddNewAccountActivity.java b/app/src/main/java/org/mian/gitnex/activities/AddNewAccountActivity.java
index 1940fb73..0d198bae 100644
--- a/app/src/main/java/org/mian/gitnex/activities/AddNewAccountActivity.java
+++ b/app/src/main/java/org/mian/gitnex/activities/AddNewAccountActivity.java
@@ -17,11 +17,7 @@ import org.mian.gitnex.database.api.BaseApi;
import org.mian.gitnex.database.api.UserAccountsApi;
import org.mian.gitnex.database.models.UserAccount;
import org.mian.gitnex.databinding.ActivityAddNewAccountBinding;
-import org.mian.gitnex.helpers.AppUtil;
-import org.mian.gitnex.helpers.PathsHelper;
-import org.mian.gitnex.helpers.Toasty;
-import org.mian.gitnex.helpers.UrlHelper;
-import org.mian.gitnex.helpers.Version;
+import org.mian.gitnex.helpers.*;
import org.mian.gitnex.structs.Protocol;
import java.net.URI;
import java.util.Objects;
@@ -58,10 +54,11 @@ 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();
}
@@ -114,8 +111,7 @@ public class AddNewAccountActivity extends BaseActivity {
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();
@@ -152,10 +148,8 @@ public class AddNewAccountActivity extends BaseActivity {
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)
+ 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();
@@ -290,4 +284,5 @@ public class AddNewAccountActivity extends BaseActivity {
onClickListener = view -> finish();
}
+
}
diff --git a/app/src/main/java/org/mian/gitnex/activities/AddNewTeamMemberActivity.java b/app/src/main/java/org/mian/gitnex/activities/AddNewTeamMemberActivity.java
index bf745132..2721d321 100644
--- a/app/src/main/java/org/mian/gitnex/activities/AddNewTeamMemberActivity.java
+++ b/app/src/main/java/org/mian/gitnex/activities/AddNewTeamMemberActivity.java
@@ -70,7 +70,7 @@ public class AddNewTeamMemberActivity extends BaseActivity {
mRecyclerView.setHasFixedSize(true);
mRecyclerView.setLayoutManager(new LinearLayoutManager(ctx));
- DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mRecyclerView.getContext(), DividerItemDecoration.VERTICAL);
+ DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mRecyclerView.getContext(), DividerItemDecoration.VERTICAL);
mRecyclerView.addItemDecoration(dividerItemDecoration);
dataList = new ArrayList<>();
diff --git a/app/src/main/java/org/mian/gitnex/activities/AddNewTeamRepoActivity.java b/app/src/main/java/org/mian/gitnex/activities/AddNewTeamRepoActivity.java
index 1ad9ad74..eb43171f 100644
--- a/app/src/main/java/org/mian/gitnex/activities/AddNewTeamRepoActivity.java
+++ b/app/src/main/java/org/mian/gitnex/activities/AddNewTeamRepoActivity.java
@@ -51,7 +51,7 @@ public class AddNewTeamRepoActivity extends BaseActivity {
addNewTeamRepositoryBinding.recyclerViewTeamRepos.setHasFixedSize(true);
addNewTeamRepositoryBinding.recyclerViewTeamRepos.setLayoutManager(new LinearLayoutManager(ctx));
- DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(addNewTeamRepositoryBinding.recyclerViewTeamRepos.getContext(), DividerItemDecoration.VERTICAL);
+ DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(addNewTeamRepositoryBinding.recyclerViewTeamRepos.getContext(), DividerItemDecoration.VERTICAL);
addNewTeamRepositoryBinding.recyclerViewTeamRepos.addItemDecoration(dividerItemDecoration);
dataList = new ArrayList<>();
@@ -105,4 +105,5 @@ public class AddNewTeamRepoActivity extends BaseActivity {
private void initCloseListener() {
onClickListener = view -> finish();
}
+
}
diff --git a/app/src/main/java/org/mian/gitnex/activities/AdminCronTasksActivity.java b/app/src/main/java/org/mian/gitnex/activities/AdminCronTasksActivity.java
index ecbdfa65..3f3d3ac1 100644
--- a/app/src/main/java/org/mian/gitnex/activities/AdminCronTasksActivity.java
+++ b/app/src/main/java/org/mian/gitnex/activities/AdminCronTasksActivity.java
@@ -20,13 +20,11 @@ import org.mian.gitnex.viewmodels.AdminCronTasksViewModel;
public class AdminCronTasksActivity extends BaseActivity {
+ private final int PAGE = 1;
private AdminCronTasksViewModel adminCronTasksViewModel;
private View.OnClickListener onClickListener;
private AdminCronTasksAdapter adapter;
-
private ActivityAdminCronTasksBinding activityAdminCronTasksBinding;
-
- private final int PAGE = 1;
private int resultLimit;
@Override
@@ -48,8 +46,7 @@ public class AdminCronTasksActivity extends BaseActivity {
activityAdminCronTasksBinding.recyclerView.setHasFixedSize(true);
activityAdminCronTasksBinding.recyclerView.setLayoutManager(new LinearLayoutManager(ctx));
- DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(activityAdminCronTasksBinding.recyclerView.getContext(),
- DividerItemDecoration.VERTICAL);
+ DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(activityAdminCronTasksBinding.recyclerView.getContext(), DividerItemDecoration.VERTICAL);
activityAdminCronTasksBinding.recyclerView.addItemDecoration(dividerItemDecoration);
activityAdminCronTasksBinding.pullToRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
@@ -83,4 +80,5 @@ public class AdminCronTasksActivity extends BaseActivity {
private void initCloseListener() {
onClickListener = view -> finish();
}
+
}
diff --git a/app/src/main/java/org/mian/gitnex/activities/AdminGetUsersActivity.java b/app/src/main/java/org/mian/gitnex/activities/AdminGetUsersActivity.java
index defd9111..c3358cca 100644
--- a/app/src/main/java/org/mian/gitnex/activities/AdminGetUsersActivity.java
+++ b/app/src/main/java/org/mian/gitnex/activities/AdminGetUsersActivity.java
@@ -55,8 +55,7 @@ public class AdminGetUsersActivity extends BaseActivity implements BottomSheetLi
activityAdminGetUsersBinding.recyclerView.setHasFixedSize(true);
activityAdminGetUsersBinding.recyclerView.setLayoutManager(new LinearLayoutManager(ctx));
- DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(activityAdminGetUsersBinding.recyclerView.getContext(),
- DividerItemDecoration.VERTICAL);
+ DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(activityAdminGetUsersBinding.recyclerView.getContext(), DividerItemDecoration.VERTICAL);
activityAdminGetUsersBinding.recyclerView.addItemDecoration(dividerItemDecoration);
activityAdminGetUsersBinding.pullToRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
@@ -68,7 +67,7 @@ public class AdminGetUsersActivity extends BaseActivity implements BottomSheetLi
}, 50));
fetchDataAsync();
- };
+ }
private void fetchDataAsync() {
@@ -109,77 +108,80 @@ public class AdminGetUsersActivity extends BaseActivity implements BottomSheetLi
});
}
- @Override
- public boolean onCreateOptionsMenu(final Menu menu) {
+ @Override
+ public boolean onCreateOptionsMenu(final Menu menu) {
- final MenuInflater inflater = getMenuInflater();
- inflater.inflate(R.menu.generic_nav_dotted_menu, menu);
+ 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;
- }
+ return true;
+ }
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
- int id = item.getItemId();
+ 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) {
+ finish();
+ return true;
+ }
+ else if(id == R.id.genericMenu) {
- BottomSheetAdminUsersFragment bottomSheet = new BottomSheetAdminUsersFragment();
- bottomSheet.show(getSupportFragmentManager(), "usersBottomSheet");
- return true;
- }
- else {
+ BottomSheetAdminUsersFragment bottomSheet = new BottomSheetAdminUsersFragment();
+ bottomSheet.show(getSupportFragmentManager(), "usersBottomSheet");
+ return true;
+ }
+ else {
- return super.onOptionsItemSelected(item);
- }
- }
+ return super.onOptionsItemSelected(item);
+ }
+ }
- @Override
- public void onButtonClicked(String text) {
+ @Override
+ public void onButtonClicked(String text) {
- if("newUser".equals(text)) {
- startActivity(new Intent(AdminGetUsersActivity.this, CreateNewUserActivity.class));
- }
- }
+ if("newUser".equals(text)) {
+ startActivity(new Intent(AdminGetUsersActivity.this, CreateNewUserActivity.class));
+ }
+ }
+
+ private void initCloseListener() {
+ onClickListener = view -> finish();
+ }
- private void initCloseListener() {
- onClickListener = view -> finish();
- }
}
diff --git a/app/src/main/java/org/mian/gitnex/activities/AdminUnadoptedReposActivity.java b/app/src/main/java/org/mian/gitnex/activities/AdminUnadoptedReposActivity.java
index b297ef2c..553a69b6 100644
--- a/app/src/main/java/org/mian/gitnex/activities/AdminUnadoptedReposActivity.java
+++ b/app/src/main/java/org/mian/gitnex/activities/AdminUnadoptedReposActivity.java
@@ -55,8 +55,7 @@ public class AdminUnadoptedReposActivity extends BaseActivity {
binding.recyclerView.setHasFixedSize(true);
binding.recyclerView.setLayoutManager(new LinearLayoutManager(ctx));
- DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(binding.recyclerView.getContext(),
- DividerItemDecoration.VERTICAL);
+ DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(binding.recyclerView.getContext(), DividerItemDecoration.VERTICAL);
binding.recyclerView.addItemDecoration(dividerItemDecoration);
binding.pullToRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
@@ -112,4 +111,5 @@ public class AdminUnadoptedReposActivity extends BaseActivity {
private void initCloseListener() {
onClickListener = view -> finish();
}
+
}
diff --git a/app/src/main/java/org/mian/gitnex/activities/BaseActivity.java b/app/src/main/java/org/mian/gitnex/activities/BaseActivity.java
index 9fedd18c..63f5c619 100644
--- a/app/src/main/java/org/mian/gitnex/activities/BaseActivity.java
+++ b/app/src/main/java/org/mian/gitnex/activities/BaseActivity.java
@@ -45,12 +45,7 @@ public abstract class BaseActivity extends AppCompatActivity {
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);
}
@@ -64,12 +59,7 @@ public abstract class BaseActivity extends AppCompatActivity {
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);
}
@@ -91,7 +81,7 @@ public abstract class BaseActivity extends AppCompatActivity {
}
String locale = tinyDB.getString("locale");
- if (locale.isEmpty()) {
+ if(locale.isEmpty()) {
AppUtil.setAppLocale(getResources(), Locale.getDefault().getLanguage());
}
else {
@@ -127,15 +117,14 @@ public abstract class BaseActivity extends AppCompatActivity {
}
// Authentication failed, close the app
- @Override public void onAuthenticationFailed() {
+ @Override
+ public void onAuthenticationFailed() {
super.onAuthenticationFailed();
}
});
- BiometricPrompt.PromptInfo biometricPromptBuilder = new BiometricPrompt.PromptInfo.Builder()
- .setTitle(getString(R.string.biometricAuthTitle))
- .setSubtitle(getString(R.string.biometricAuthSubTitle))
+ 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);
@@ -146,6 +135,7 @@ public abstract class BaseActivity extends AppCompatActivity {
public AccountContext getAccount() {
return ((MainApplication) getApplication()).currentAccount;
}
+
}
diff --git a/app/src/main/java/org/mian/gitnex/activities/CodeEditorActivity.java b/app/src/main/java/org/mian/gitnex/activities/CodeEditorActivity.java
index 310de346..c1992cca 100644
--- a/app/src/main/java/org/mian/gitnex/activities/CodeEditorActivity.java
+++ b/app/src/main/java/org/mian/gitnex/activities/CodeEditorActivity.java
@@ -10,11 +10,7 @@ import com.amrdeveloper.codeview.Code;
import org.apache.commons.lang3.EnumUtils;
import org.mian.gitnex.R;
import org.mian.gitnex.databinding.ActivityCodeEditorBinding;
-import org.mian.gitnex.helpers.codeeditor.CustomCodeViewAdapter;
-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 org.mian.gitnex.helpers.codeeditor.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -26,10 +22,10 @@ import java.util.Map;
public class CodeEditorActivity extends BaseActivity {
+ private final ThemeName currentTheme = ThemeName.FIVE_COLOR;
private ActivityCodeEditorBinding binding;
private LanguageManager languageManager;
private LanguageName currentLanguage = LanguageName.UNKNOWN;
- private final ThemeName currentTheme = ThemeName.FIVE_COLOR;
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -105,7 +101,7 @@ public class CodeEditorActivity extends BaseActivity {
private void configLanguageAutoComplete() {
boolean useModernAutoCompleteAdapter = true;
- if (useModernAutoCompleteAdapter) {
+ if(useModernAutoCompleteAdapter) {
List codeList = languageManager.getLanguageCodeList(currentLanguage);
CustomCodeViewAdapter adapter = new CustomCodeViewAdapter(this, codeList);
@@ -146,4 +142,5 @@ public class CodeEditorActivity extends BaseActivity {
binding.sourcePosition.setText(getString(R.string.sourcePosition, line, column));
});
}
+
}
diff --git a/app/src/main/java/org/mian/gitnex/activities/CommitDetailActivity.java b/app/src/main/java/org/mian/gitnex/activities/CommitDetailActivity.java
index fe808d77..c4321795 100644
--- a/app/src/main/java/org/mian/gitnex/activities/CommitDetailActivity.java
+++ b/app/src/main/java/org/mian/gitnex/activities/CommitDetailActivity.java
@@ -29,20 +29,15 @@ public class CommitDetailActivity extends BaseActivity {
@Override
public void handleOnBackPressed() {
if(getSupportFragmentManager().findFragmentById(R.id.fragment_container) instanceof DiffFragment) {
- getSupportFragmentManager()
- .beginTransaction()
- .replace(R.id.fragment_container, fragment)
- .commit();
- } else {
+ getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, fragment).commit();
+ }
+ else {
finish();
}
}
});
- getSupportFragmentManager()
- .beginTransaction()
- .replace(R.id.fragment_container, fragment)
- .commit();
+ getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, fragment).commit();
}
diff --git a/app/src/main/java/org/mian/gitnex/activities/CommitsActivity.java b/app/src/main/java/org/mian/gitnex/activities/CommitsActivity.java
index e822d021..3e870922 100644
--- a/app/src/main/java/org/mian/gitnex/activities/CommitsActivity.java
+++ b/app/src/main/java/org/mian/gitnex/activities/CommitsActivity.java
@@ -38,17 +38,16 @@ import retrofit2.Response;
public class CommitsActivity extends BaseActivity {
+ private final String TAG = "CommitsActivity";
+ public RepositoryContext repository;
private View.OnClickListener onClickListener;
private TextView noData;
private ProgressBar progressBar;
- private final String TAG = "CommitsActivity";
private int resultLimit;
private int pageSize = 1;
-
private RecyclerView recyclerView;
private List commitsList;
private CommitsAdapter adapter;
- public RepositoryContext repository;
@Override
public void onCreate(Bundle savedInstanceState) {
diff --git a/app/src/main/java/org/mian/gitnex/activities/CreateFileActivity.java b/app/src/main/java/org/mian/gitnex/activities/CreateFileActivity.java
index 7b9ba9d6..ab66764c 100644
--- a/app/src/main/java/org/mian/gitnex/activities/CreateFileActivity.java
+++ b/app/src/main/java/org/mian/gitnex/activities/CreateFileActivity.java
@@ -15,12 +15,7 @@ import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.annotation.NonNull;
import org.apache.commons.io.FilenameUtils;
-import org.gitnex.tea4j.v2.models.Branch;
-import org.gitnex.tea4j.v2.models.CreateFileOptions;
-import org.gitnex.tea4j.v2.models.DeleteFileOptions;
-import org.gitnex.tea4j.v2.models.FileDeleteResponse;
-import org.gitnex.tea4j.v2.models.FileResponse;
-import org.gitnex.tea4j.v2.models.UpdateFileOptions;
+import org.gitnex.tea4j.v2.models.*;
import org.mian.gitnex.R;
import org.mian.gitnex.clients.RetrofitClient;
import org.mian.gitnex.databinding.ActivityCreateFileBinding;
@@ -41,98 +36,98 @@ import retrofit2.Callback;
public class CreateFileActivity extends BaseActivity {
- private ActivityCreateFileBinding binding;
-
public static final int FILE_ACTION_CREATE = 0;
public static final int FILE_ACTION_DELETE = 1;
public static final int FILE_ACTION_EDIT = 2;
-
+ private final List branches = new ArrayList<>();
+ private ActivityCreateFileBinding binding;
+ ActivityResultLauncher codeEditorActivityResultLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
+ if(result.getResultCode() == Activity.RESULT_OK) {
+ Intent data = result.getData();
+ assert data != null;
+ binding.newFileContent.setText(data.getStringExtra("fileContentFromActivity"));
+ }
+ });
private int fileAction = FILE_ACTION_CREATE;
-
private String filePath;
private String fileSha;
-
- private final List branches = new ArrayList<>();
-
private RepositoryContext repository;
- @SuppressLint("ClickableViewAccessibility")
- @Override
- public void onCreate(Bundle savedInstanceState) {
+ @SuppressLint("ClickableViewAccessibility")
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
+ super.onCreate(savedInstanceState);
- binding = ActivityCreateFileBinding.inflate(getLayoutInflater());
- setContentView(binding.getRoot());
+ binding = ActivityCreateFileBinding.inflate(getLayoutInflater());
+ setContentView(binding.getRoot());
- repository = RepositoryContext.fromIntent(getIntent());
+ repository = RepositoryContext.fromIntent(getIntent());
- TextView toolbarTitle = binding.toolbarTitle;
+ TextView toolbarTitle = binding.toolbarTitle;
- binding.newFileName.requestFocus();
+ binding.newFileName.requestFocus();
- InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
- assert inputMethodManager != null;
- inputMethodManager.showSoftInput(binding.newFileName, InputMethodManager.SHOW_IMPLICIT);
+ InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
+ assert inputMethodManager != null;
+ inputMethodManager.showSoftInput(binding.newFileName, InputMethodManager.SHOW_IMPLICIT);
- binding.close.setOnClickListener(view -> finish());
- binding.newFileContent.setOnTouchListener((touchView, motionEvent) -> {
+ binding.close.setOnClickListener(view -> finish());
+ binding.newFileContent.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);
- }
+ touchView.getParent().requestDisallowInterceptTouchEvent(false);
+ }
- return false;
+ return false;
- });
+ });
- if(getIntent().getStringExtra("filePath") != null && getIntent().getIntExtra("fileAction", FILE_ACTION_DELETE) == FILE_ACTION_DELETE) {
+ if(getIntent().getStringExtra("filePath") != null && getIntent().getIntExtra("fileAction", FILE_ACTION_DELETE) == FILE_ACTION_DELETE) {
- fileAction = getIntent().getIntExtra("fileAction", FILE_ACTION_DELETE);
- filePath = getIntent().getStringExtra("filePath");
- fileSha = getIntent().getStringExtra("fileSha");
+ fileAction = getIntent().getIntExtra("fileAction", FILE_ACTION_DELETE);
+ filePath = getIntent().getStringExtra("filePath");
+ fileSha = getIntent().getStringExtra("fileSha");
- toolbarTitle.setText(getString(R.string.deleteGenericTitle, filePath));
+ toolbarTitle.setText(getString(R.string.deleteGenericTitle, filePath));
- binding.newFileCreate.setText(R.string.deleteFile);
+ binding.newFileCreate.setText(R.string.deleteFile);
- binding.newFileNameLayout.setVisibility(View.GONE);
- binding.newFileContentLayout.setVisibility(View.GONE);
- }
+ binding.newFileNameLayout.setVisibility(View.GONE);
+ binding.newFileContentLayout.setVisibility(View.GONE);
+ }
- if(getIntent().getStringExtra("filePath") != null && getIntent().getIntExtra("fileAction", FILE_ACTION_EDIT) == FILE_ACTION_EDIT) {
+ if(getIntent().getStringExtra("filePath") != null && getIntent().getIntExtra("fileAction", FILE_ACTION_EDIT) == FILE_ACTION_EDIT) {
- fileAction = getIntent().getIntExtra("fileAction", FILE_ACTION_EDIT);
- filePath = getIntent().getStringExtra("filePath");
- fileSha = getIntent().getStringExtra("fileSha");
+ fileAction = getIntent().getIntExtra("fileAction", FILE_ACTION_EDIT);
+ filePath = getIntent().getStringExtra("filePath");
+ fileSha = getIntent().getStringExtra("fileSha");
- toolbarTitle.setText(getString(R.string.editFileText, filePath));
+ toolbarTitle.setText(getString(R.string.editFileText, filePath));
- binding.newFileCreate.setText(R.string.editFile);
- binding.newFileName.setText(filePath);
- binding.newFileName.setEnabled(false);
- binding.newFileName.setFocusable(false);
+ binding.newFileCreate.setText(R.string.editFile);
+ binding.newFileName.setText(filePath);
+ binding.newFileName.setEnabled(false);
+ binding.newFileName.setFocusable(false);
- binding.newFileContent.setText(getIntent().getStringExtra("fileContents"));
- }
+ binding.newFileContent.setText(getIntent().getStringExtra("fileContents"));
+ }
- getBranches(repository.getOwner(), repository.getName());
+ getBranches(repository.getOwner(), repository.getName());
- disableProcessButton();
+ disableProcessButton();
- binding.openCodeEditor.setOnClickListener(v ->
- launchCodeEditorActivityForResult(Objects.requireNonNull(binding.newFileContent.getText()).toString(), FilenameUtils.getExtension(String.valueOf(binding.newFileName.getText())))
- );
+ binding.openCodeEditor.setOnClickListener(
+ v -> launchCodeEditorActivityForResult(Objects.requireNonNull(binding.newFileContent.getText()).toString(), FilenameUtils.getExtension(String.valueOf(binding.newFileName.getText()))));
- NetworkStatusObserver networkStatusObserver = NetworkStatusObserver.getInstance(ctx);
- networkStatusObserver.registerNetworkStatusListener(hasNetworkConnection -> runOnUiThread(() -> binding.newFileCreate.setEnabled(hasNetworkConnection)));
+ NetworkStatusObserver networkStatusObserver = NetworkStatusObserver.getInstance(ctx);
+ networkStatusObserver.registerNetworkStatusListener(hasNetworkConnection -> runOnUiThread(() -> binding.newFileCreate.setEnabled(hasNetworkConnection)));
- binding.newFileCreate.setOnClickListener(v -> processNewFile());
- }
+ binding.newFileCreate.setOnClickListener(v -> processNewFile());
+ }
public void launchCodeEditorActivityForResult(String fileContent, String fileExtension) {
Intent intent = new Intent(this, CodeEditorActivity.class);
@@ -141,63 +136,54 @@ public class CreateFileActivity extends BaseActivity {
codeEditorActivityResultLauncher.launch(intent);
}
- ActivityResultLauncher codeEditorActivityResultLauncher = registerForActivityResult(
- new ActivityResultContracts.StartActivityForResult(), result -> {
- if(result.getResultCode() == Activity.RESULT_OK) {
- Intent data = result.getData();
- assert data != null;
- binding.newFileContent.setText(data.getStringExtra("fileContentFromActivity"));
- }
- });
+ private void processNewFile() {
- private void processNewFile() {
+ String newFileName = binding.newFileName.getText() != null ? binding.newFileName.getText().toString() : "";
+ String newFileContent = binding.newFileContent.getText() != null ? binding.newFileContent.getText().toString() : "";
+ String newFileBranchName = binding.newFileBranches.getText() != null ? binding.newFileBranches.getText().toString() : "";
+ String newFileCommitMessage = binding.newFileCommitMessage.getText() != null ? binding.newFileCommitMessage.getText().toString() : "";
- String newFileName = binding.newFileName.getText() != null ? binding.newFileName.getText().toString() : "";
- String newFileContent = binding.newFileContent.getText() != null ? binding.newFileContent.getText().toString() : "";
- String newFileBranchName = binding.newFileBranches.getText() != null ? binding.newFileBranches.getText().toString() : "";
- String newFileCommitMessage = binding.newFileCommitMessage.getText() != null ? binding.newFileCommitMessage.getText().toString() : "";
+ if(!AppUtil.hasNetworkConnection(appCtx)) {
+ Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
+ return;
+ }
- if(!AppUtil.hasNetworkConnection(appCtx)) {
- Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
- return;
- }
+ if(((newFileName.isEmpty() || newFileContent.isEmpty()) && fileAction != FILE_ACTION_DELETE) || newFileCommitMessage.isEmpty()) {
+ Toasty.error(ctx, getString(R.string.newFileRequiredFields));
+ return;
+ }
- if(((newFileName.isEmpty() || newFileContent.isEmpty()) && fileAction != FILE_ACTION_DELETE) || newFileCommitMessage.isEmpty()) {
- Toasty.error(ctx, getString(R.string.newFileRequiredFields));
- return;
- }
+ if(!AppUtil.checkStringsWithDash(newFileBranchName)) {
+ Toasty.error(ctx, getString(R.string.newFileInvalidBranchName));
+ return;
+ }
- if(!AppUtil.checkStringsWithDash(newFileBranchName)) {
- Toasty.error(ctx, getString(R.string.newFileInvalidBranchName));
- return;
- }
+ if(newFileCommitMessage.length() > 255) {
+ Toasty.warning(ctx, getString(R.string.newFileCommitMessageError));
+ return;
+ }
- if(newFileCommitMessage.length() > 255) {
- Toasty.warning(ctx, getString(R.string.newFileCommitMessageError));
- return;
- }
+ disableProcessButton();
- disableProcessButton();
+ switch(fileAction) {
- switch(fileAction) {
+ case FILE_ACTION_CREATE:
+ createNewFile(repository.getOwner(), repository.getName(), newFileName, AppUtil.encodeBase64(newFileContent), newFileCommitMessage, newFileBranchName);
+ break;
- case FILE_ACTION_CREATE:
- createNewFile(repository.getOwner(), repository.getName(), newFileName, AppUtil.encodeBase64(newFileContent), newFileCommitMessage, newFileBranchName);
- break;
+ case FILE_ACTION_DELETE:
+ deleteFile(repository.getOwner(), repository.getName(), filePath, newFileCommitMessage, newFileBranchName, fileSha);
+ break;
- case FILE_ACTION_DELETE:
- deleteFile(repository.getOwner(), repository.getName(), filePath, newFileCommitMessage, newFileBranchName, fileSha);
- break;
+ case FILE_ACTION_EDIT:
+ editFile(repository.getOwner(), repository.getName(), filePath, AppUtil.encodeBase64(newFileContent), newFileCommitMessage, newFileBranchName, fileSha);
+ break;
+ }
+ }
- case FILE_ACTION_EDIT:
- editFile(repository.getOwner(), repository.getName(), filePath, AppUtil.encodeBase64(newFileContent), newFileCommitMessage, newFileBranchName, fileSha);
- break;
- }
- }
+ private void createNewFile(String repoOwner, String repoName, String fileName, String fileContent, String fileCommitMessage, String branchName) {
- private void createNewFile(String repoOwner, String repoName, String fileName, String fileContent, String fileCommitMessage, String branchName) {
-
- CreateFileOptions createNewFileJsonStr = new CreateFileOptions();
+ CreateFileOptions createNewFileJsonStr = new CreateFileOptions();
createNewFileJsonStr.setContent(fileContent);
createNewFileJsonStr.setMessage(fileCommitMessage);
@@ -208,56 +194,54 @@ public class CreateFileActivity extends BaseActivity {
createNewFileJsonStr.setNewBranch(branchName);
}
- Call call = RetrofitClient
- .getApiInterface(ctx)
- .repoCreateFile(createNewFileJsonStr, repoOwner, repoName, fileName);
+ Call call = RetrofitClient.getApiInterface(ctx).repoCreateFile(createNewFileJsonStr, repoOwner, repoName, fileName);
- call.enqueue(new Callback<>() {
+ call.enqueue(new Callback<>() {
- @Override
- public void onResponse(@NonNull Call call, @NonNull retrofit2.Response response) {
+ @Override
+ public void onResponse(@NonNull Call call, @NonNull retrofit2.Response response) {
- switch(response.code()) {
+ switch(response.code()) {
- case 201:
- enableProcessButton();
- Toasty.success(ctx, getString(R.string.newFileSuccessMessage));
- Intent result = new Intent();
- result.putExtra("fileModified", true);
- result.putExtra("fileAction", fileAction);
- setResult(200, result);
- finish();
- break;
+ case 201:
+ enableProcessButton();
+ Toasty.success(ctx, getString(R.string.newFileSuccessMessage));
+ Intent result = new Intent();
+ result.putExtra("fileModified", true);
+ result.putExtra("fileAction", fileAction);
+ setResult(200, result);
+ finish();
+ break;
- case 401:
- enableProcessButton();
- AlertDialogs.authorizationTokenRevokedDialog(ctx);
- break;
+ case 401:
+ enableProcessButton();
+ AlertDialogs.authorizationTokenRevokedDialog(ctx);
+ break;
- case 404:
- enableProcessButton();
- Toasty.warning(ctx, getString(R.string.apiNotFound));
- break;
+ case 404:
+ enableProcessButton();
+ Toasty.warning(ctx, getString(R.string.apiNotFound));
+ break;
- default:
- enableProcessButton();
- Toasty.error(ctx, getString(R.string.genericError));
- break;
- }
- }
+ default:
+ enableProcessButton();
+ Toasty.error(ctx, getString(R.string.genericError));
+ break;
+ }
+ }
- @Override
- public void onFailure(@NonNull Call call, @NonNull Throwable t) {
+ @Override
+ public void onFailure(@NonNull Call call, @NonNull Throwable t) {
- Log.e("onFailure", t.toString());
- enableProcessButton();
- }
- });
- }
+ Log.e("onFailure", t.toString());
+ enableProcessButton();
+ }
+ });
+ }
private void deleteFile(String repoOwner, String repoName, String fileName, String fileCommitMessage, String branchName, String fileSha) {
- DeleteFileOptions deleteFileJsonStr = new DeleteFileOptions();
+ DeleteFileOptions deleteFileJsonStr = new DeleteFileOptions();
deleteFileJsonStr.setMessage(fileCommitMessage);
deleteFileJsonStr.setSha(fileSha);
@@ -268,9 +252,7 @@ public class CreateFileActivity extends BaseActivity {
deleteFileJsonStr.setNewBranch(branchName);
}
- Call call = RetrofitClient
- .getApiInterface(ctx)
- .repoDeleteFileWithBody(repoOwner, repoName, fileName, deleteFileJsonStr);
+ Call call = RetrofitClient.getApiInterface(ctx).repoDeleteFileWithBody(repoOwner, repoName, fileName, deleteFileJsonStr);
call.enqueue(new Callback<>() {
@@ -329,9 +311,7 @@ public class CreateFileActivity extends BaseActivity {
editFileJsonStr.setNewBranch(branchName);
}
- Call call = RetrofitClient
- .getApiInterface(ctx)
- .repoUpdateFile(editFileJsonStr, repoOwner, repoName, fileName);
+ Call call = RetrofitClient.getApiInterface(ctx).repoUpdateFile(editFileJsonStr, repoOwner, repoName, fileName);
call.enqueue(new Callback<>() {
@@ -376,46 +356,50 @@ public class CreateFileActivity extends BaseActivity {
});
}
- private void getBranches(String repoOwner, String repoName) {
+ private void getBranches(String repoOwner, String repoName) {
- Call> call = RetrofitClient
- .getApiInterface(ctx)
- .repoListBranches(repoOwner, repoName, null, null);
+ Call> call = RetrofitClient.getApiInterface(ctx).repoListBranches(repoOwner, repoName, null, null);
- call.enqueue(new Callback<>() {
+ call.enqueue(new Callback<>() {
- @Override
- public void onResponse(@NonNull Call> call, @NonNull retrofit2.Response> response) {
+ @Override
+ public void onResponse(@NonNull Call> call, @NonNull retrofit2.Response> response) {
- if(response.code() == 200) {
+ if(response.code() == 200) {
- assert response.body() != null;
- for(Branch branch : response.body())
- branches.add(branch.getName());
+ assert response.body() != null;
+ for(Branch branch : response.body())
+ branches.add(branch.getName());
- ArrayAdapter adapter = new ArrayAdapter<>(CreateFileActivity.this, R.layout.list_spinner_items, branches);
+ ArrayAdapter adapter = new ArrayAdapter<>(CreateFileActivity.this, R.layout.list_spinner_items, branches);
- binding.newFileBranches.setAdapter(adapter);
- binding.newFileBranches.setText(repository.getBranchRef(), false);
+ binding.newFileBranches.setAdapter(adapter);
+ binding.newFileBranches.setText(repository.getBranchRef(), false);
- enableProcessButton();
- }
- }
+ enableProcessButton();
+ }
+ }
- @Override
- public void onFailure(@NonNull Call> call, @NonNull Throwable t) {
+ @Override
+ public void onFailure(@NonNull Call> call, @NonNull Throwable t) {
- Log.e("onFailure", t.toString());
- }
- });
- }
+ Log.e("onFailure", t.toString());
+ }
+ });
+ }
- private void disableProcessButton() { binding.newFileCreate.setEnabled(false); }
- private void enableProcessButton() { binding.newFileCreate.setEnabled(true); }
+ private void disableProcessButton() {
+ binding.newFileCreate.setEnabled(false);
+ }
+
+ private void enableProcessButton() {
+ binding.newFileCreate.setEnabled(true);
+ }
@Override
public void onResume() {
super.onResume();
repository.checkAccountSwitch(this);
}
+
}
diff --git a/app/src/main/java/org/mian/gitnex/activities/CreateIssueActivity.java b/app/src/main/java/org/mian/gitnex/activities/CreateIssueActivity.java
index 6289bb32..51712f62 100644
--- a/app/src/main/java/org/mian/gitnex/activities/CreateIssueActivity.java
+++ b/app/src/main/java/org/mian/gitnex/activities/CreateIssueActivity.java
@@ -12,11 +12,7 @@ import android.widget.ArrayAdapter;
import android.widget.TextView;
import androidx.annotation.NonNull;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
-import org.gitnex.tea4j.v2.models.CreateIssueOption;
-import org.gitnex.tea4j.v2.models.Issue;
-import org.gitnex.tea4j.v2.models.Label;
-import org.gitnex.tea4j.v2.models.Milestone;
-import org.gitnex.tea4j.v2.models.User;
+import org.gitnex.tea4j.v2.models.*;
import org.mian.gitnex.R;
import org.mian.gitnex.actions.AssigneesActions;
import org.mian.gitnex.actions.LabelsActions;
@@ -32,12 +28,7 @@ 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 java.util.*;
import retrofit2.Call;
import retrofit2.Callback;
@@ -47,93 +38,89 @@ import retrofit2.Callback;
public class CreateIssueActivity extends BaseActivity implements View.OnClickListener, LabelsListAdapter.LabelsListAdapterListener, AssigneesListAdapter.AssigneesListAdapterListener {
+ private final List labelsList = new ArrayList<>();
+ private final LinkedHashMap milestonesList = new LinkedHashMap<>();
+ private final List assigneesList = new ArrayList<>();
private ActivityCreateIssueBinding viewBinding;
private View.OnClickListener onClickListener;
private int milestoneId;
private Date currentDate = null;
-
private RepositoryContext repository;
-
private LabelsListAdapter labelsAdapter;
private AssigneesListAdapter assigneesAdapter;
-
private MaterialAlertDialogBuilder materialAlertDialogBuilder;
-
private List labelsIds = new ArrayList<>();
- private final List labelsList = new ArrayList<>();
- private final LinkedHashMap milestonesList = new LinkedHashMap<>();
- private final List assigneesList = new ArrayList<>();
private List assigneesListData = new ArrayList<>();
- @SuppressLint("ClickableViewAccessibility")
- @Override
- public void onCreate(Bundle savedInstanceState) {
+ @SuppressLint("ClickableViewAccessibility")
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
+ super.onCreate(savedInstanceState);
- viewBinding = ActivityCreateIssueBinding.inflate(getLayoutInflater());
- setContentView(viewBinding.getRoot());
+ viewBinding = ActivityCreateIssueBinding.inflate(getLayoutInflater());
+ setContentView(viewBinding.getRoot());
- boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
+ boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
- InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
+ InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
- materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx, R.style.ThemeOverlay_Material3_Dialog_Alert);
+ materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx, R.style.ThemeOverlay_Material3_Dialog_Alert);
- repository = RepositoryContext.fromIntent(getIntent());
+ repository = RepositoryContext.fromIntent(getIntent());
- int resultLimit = Constants.getCurrentResultLimit(ctx);
+ int resultLimit = Constants.getCurrentResultLimit(ctx);
- viewBinding.newIssueTitle.requestFocus();
- assert imm != null;
- imm.showSoftInput(viewBinding.newIssueTitle, InputMethodManager.SHOW_IMPLICIT);
+ viewBinding.newIssueTitle.requestFocus();
+ 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);
+ labelsAdapter = new LabelsListAdapter(labelsList, CreateIssueActivity.this, labelsIds);
+ assigneesAdapter = new AssigneesListAdapter(ctx, assigneesList, CreateIssueActivity.this, assigneesListData);
- initCloseListener();
- viewBinding.close.setOnClickListener(onClickListener);
+ initCloseListener();
+ viewBinding.close.setOnClickListener(onClickListener);
- viewBinding.newIssueAssigneesList.setOnClickListener(this);
- viewBinding.newIssueLabels.setOnClickListener(this);
- viewBinding.newIssueDueDate.setOnClickListener(this);
+ viewBinding.newIssueAssigneesList.setOnClickListener(this);
+ viewBinding.newIssueLabels.setOnClickListener(this);
+ viewBinding.newIssueDueDate.setOnClickListener(this);
- getMilestones(repository.getOwner(), repository.getName(), resultLimit);
+ getMilestones(repository.getOwner(), repository.getName(), resultLimit);
- disableProcessButton();
+ disableProcessButton();
- viewBinding.newIssueLabels.setOnClickListener(newIssueLabels -> showLabels());
+ viewBinding.newIssueLabels.setOnClickListener(newIssueLabels -> showLabels());
- viewBinding.newIssueAssigneesList.setOnClickListener(newIssueAssigneesList -> showAssignees());
+ viewBinding.newIssueAssigneesList.setOnClickListener(newIssueAssigneesList -> showAssignees());
- if(!connToInternet) {
+ if(!connToInternet) {
- viewBinding.createNewIssueButton.setEnabled(false);
- }
- else {
+ viewBinding.createNewIssueButton.setEnabled(false);
+ }
+ else {
- viewBinding.createNewIssueButton.setOnClickListener(this);
- }
+ viewBinding.createNewIssueButton.setOnClickListener(this);
+ }
- if(!repository.getPermissions().isPush()) {
- viewBinding.newIssueAssigneesListLayout.setVisibility(View.GONE);
- viewBinding.newIssueMilestoneSpinnerLayout.setVisibility(View.GONE);
- viewBinding.newIssueLabelsLayout.setVisibility(View.GONE);
- viewBinding.newIssueDueDateLayout.setVisibility(View.GONE);
- }
+ 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 data) {
@@ -160,23 +147,20 @@ 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);
@@ -185,38 +169,38 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
LabelsActions.getRepositoryLabels(ctx, repository.getOwner(), repository.getName(), labelsList, materialAlertDialogBuilder, labelsAdapter, labelsBinding, viewBinding.progressBar);
}
- private void processNewIssue() {
+ private void processNewIssue() {
- boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
+ 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;
- }
+ Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
+ return;
+ }
- if (newIssueTitleForm.equals("")) {
+ if(newIssueTitleForm.equals("")) {
- Toasty.error(ctx, getString(R.string.issueTitleEmpty));
- return;
- }
+ Toasty.error(ctx, getString(R.string.issueTitleEmpty));
+ return;
+ }
- disableProcessButton();
- createNewIssueFunc(repository.getOwner(), repository.getName(), newIssueDescriptionForm, milestoneId, newIssueTitleForm);
- }
+ disableProcessButton();
+ 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 labelIds = new ArrayList<>();
- for(Integer i : labelsIds) {
- labelIds.add((long) i);
- }
+ for(Integer i : labelsIds) {
+ labelIds.add((long) i);
+ }
- CreateIssueOption createNewIssueJson = new CreateIssueOption();
+ CreateIssueOption createNewIssueJson = new CreateIssueOption();
createNewIssueJson.setBody(newIssueDescriptionForm);
createNewIssueJson.setMilestone((long) newIssueMilestoneIdForm);
createNewIssueJson.setDueDate(currentDate);
@@ -224,150 +208,146 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
createNewIssueJson.setAssignees(assigneesListData);
createNewIssueJson.setLabels(labelIds);
- Call call3 = RetrofitClient
- .getApiInterface(ctx)
- .issueCreateIssue(repoOwner, repoName, createNewIssueJson);
+ Call call3 = RetrofitClient.getApiInterface(ctx).issueCreateIssue(repoOwner, repoName, createNewIssueJson);
- call3.enqueue(new Callback<>() {
+ call3.enqueue(new Callback<>() {
- @Override
- public void onResponse(@NonNull Call call, @NonNull retrofit2.Response response2) {
+ @Override
+ public void onResponse(@NonNull Call call, @NonNull retrofit2.Response 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 call, @NonNull Throwable t) {
+ @Override
+ public void onFailure(@NonNull Call call, @NonNull Throwable t) {
- Toasty.error(ctx, getString(R.string.genericServerResponseError));
- enableProcessButton();
- }
- });
- }
+ Toasty.error(ctx, getString(R.string.genericServerResponseError));
+ enableProcessButton();
+ }
+ });
+ }
- private void initCloseListener() {
+ private void initCloseListener() {
- onClickListener = view -> finish();
- }
+ onClickListener = view -> finish();
+ }
- private void getMilestones(String repoOwner, String repoName, int resultLimit) {
+ private void getMilestones(String repoOwner, String repoName, int resultLimit) {
- String msState = "open";
- Call> call = RetrofitClient
- .getApiInterface(ctx)
- .issueGetMilestonesList(repoOwner, repoName, msState, null, 1, resultLimit);
+ String msState = "open";
+ Call> 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> call, @NonNull retrofit2.Response> response) {
+ @Override
+ public void onResponse(@NonNull Call> call, @NonNull retrofit2.Response> response) {
- if(response.isSuccessful()) {
+ if(response.isSuccessful()) {
- if(response.code() == 200) {
+ if(response.code() == 200) {
- List milestonesList_ = response.body();
+ List 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 adapter = new ArrayAdapter<>(CreateIssueActivity.this, R.layout.list_spinner_items, new ArrayList<>(milestonesList.keySet()));
+ ArrayAdapter adapter = new ArrayAdapter<>(CreateIssueActivity.this, R.layout.list_spinner_items, new ArrayList<>(milestonesList.keySet()));
- viewBinding.newIssueMilestoneSpinner.setAdapter(adapter);
- enableProcessButton();
+ 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());
- }
- });
+ 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> call, @NonNull Throwable t) {
+ @Override
+ public void onFailure(@NonNull Call> call, @NonNull Throwable t) {
- Toasty.error(ctx, getString(R.string.genericServerResponseError));
- }
- });
- }
+ Toasty.error(ctx, getString(R.string.genericServerResponseError));
+ }
+ });
+ }
- @Override
- public void onClick(View v) {
+ @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);
+ 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) -> {
+ 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) {
+ }, mYear, mMonth, mDay);
+ datePickerDialog.show();
+ }
+ else if(v == viewBinding.createNewIssueButton) {
- processNewIssue();
- }
- }
+ processNewIssue();
+ }
+ }
- private void disableProcessButton() {
+ private void disableProcessButton() {
- viewBinding.createNewIssueButton.setEnabled(false);
- }
+ viewBinding.createNewIssueButton.setEnabled(false);
+ }
- private void enableProcessButton() {
+ private void enableProcessButton() {
- viewBinding.createNewIssueButton.setEnabled(true);
- }
+ viewBinding.createNewIssueButton.setEnabled(true);
+ }
@Override
public void onResume() {
super.onResume();
repository.checkAccountSwitch(this);
}
+
}
diff --git a/app/src/main/java/org/mian/gitnex/activities/CreateLabelActivity.java b/app/src/main/java/org/mian/gitnex/activities/CreateLabelActivity.java
index d2251747..ed6f852d 100644
--- a/app/src/main/java/org/mian/gitnex/activities/CreateLabelActivity.java
+++ b/app/src/main/java/org/mian/gitnex/activities/CreateLabelActivity.java
@@ -35,333 +35,333 @@ public class CreateLabelActivity extends BaseActivity {
public static boolean refreshLabels = false;
private ActivityCreateLabelBinding activityCreateLabelBinding;
- private View.OnClickListener onClickListener;
+ private View.OnClickListener onClickListener;
- private RepositoryContext repository;
- private String labelColor = "";
- private String labelColorDefault = "";
+ private RepositoryContext repository;
+ private String labelColor = "";
+ private final View.OnClickListener createLabelListener = v -> processCreateLabel();
+ private String labelColorDefault = "";
+ private final View.OnClickListener updateLabelListener = v -> processUpdateLabel();
- @Override
- public void onCreate(Bundle savedInstanceState) {
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
+ super.onCreate(savedInstanceState);
- activityCreateLabelBinding = ActivityCreateLabelBinding.inflate(getLayoutInflater());
- setContentView(activityCreateLabelBinding.getRoot());
+ 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());
+ 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"))));
- finish();
- return;
- }
+ deleteLabel(Integer.parseInt(Objects.requireNonNull(getIntent().getStringExtra("labelId"))));
+ finish();
+ return;
+ }
- boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
+ boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
- activityCreateLabelBinding.labelName.requestFocus();
- assert imm != null;
- imm.showSoftInput(activityCreateLabelBinding.labelName, InputMethodManager.SHOW_IMPLICIT);
+ activityCreateLabelBinding.labelName.requestFocus();
+ assert imm != null;
+ imm.showSoftInput(activityCreateLabelBinding.labelName, InputMethodManager.SHOW_IMPLICIT);
- final ColorPicker cp = new ColorPicker(CreateLabelActivity.this, 235, 113, 33);
+ final ColorPicker cp = new ColorPicker(CreateLabelActivity.this, 235, 113, 33);
- initCloseListener();
- activityCreateLabelBinding.close.setOnClickListener(onClickListener);
- activityCreateLabelBinding.colorPicker.setOnClickListener(v -> cp.show());
+ initCloseListener();
+ 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"));
- activityCreateLabelBinding.colorPicker.setBackgroundColor(labelColor_);
- labelColorDefault = "#" + getIntent().getStringExtra("labelColor");
+ activityCreateLabelBinding.labelName.setText(getIntent().getStringExtra("labelTitle"));
+ int labelColor_ = Color.parseColor("#" + getIntent().getStringExtra("labelColor"));
+ activityCreateLabelBinding.colorPicker.setBackgroundColor(labelColor_);
+ labelColorDefault = "#" + getIntent().getStringExtra("labelColor");
- TextView toolbar_title = activityCreateLabelBinding.toolbarTitle;
- toolbar_title.setText(getResources().getString(R.string.pageTitleLabelUpdate));
- activityCreateLabelBinding.createLabelButton.setText(getResources().getString(R.string.newUpdateButtonCopy));
+ TextView toolbar_title = activityCreateLabelBinding.toolbarTitle;
+ toolbar_title.setText(getResources().getString(R.string.pageTitleLabelUpdate));
+ activityCreateLabelBinding.createLabelButton.setText(getResources().getString(R.string.newUpdateButtonCopy));
- activityCreateLabelBinding.createLabelButton.setOnClickListener(updateLabelListener);
- return;
- }
+ activityCreateLabelBinding.createLabelButton.setOnClickListener(updateLabelListener);
+ return;
+ }
- if(!connToInternet) {
+ if(!connToInternet) {
- activityCreateLabelBinding.createLabelButton.setEnabled(false);
- }
- else {
+ activityCreateLabelBinding.createLabelButton.setEnabled(false);
+ }
+ else {
- activityCreateLabelBinding.createLabelButton.setOnClickListener(createLabelListener);
- }
- }
+ activityCreateLabelBinding.createLabelButton.setOnClickListener(createLabelListener);
+ }
+ }
- private final View.OnClickListener createLabelListener = v -> processCreateLabel();
+ private void processUpdateLabel() {
- private final View.OnClickListener updateLabelListener = v -> processUpdateLabel();
+ boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
- private void processUpdateLabel() {
+ String updateLabelName = Objects.requireNonNull(activityCreateLabelBinding.labelName.getText()).toString();
- boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
+ String updateLabelColor;
+ if(labelColor.isEmpty()) {
- String updateLabelName = Objects.requireNonNull(activityCreateLabelBinding.labelName.getText()).toString();
+ updateLabelColor = labelColorDefault;
+ }
+ else {
- String updateLabelColor;
- if(labelColor.isEmpty()) {
+ updateLabelColor = labelColor;
+ }
- updateLabelColor = labelColorDefault;
- }
- else {
+ if(!connToInternet) {
- updateLabelColor = labelColor;
- }
+ Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
+ return;
+ }
- if(!connToInternet) {
+ if(updateLabelName.equals("")) {
- Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
- return;
- }
+ Toasty.error(ctx, getString(R.string.labelEmptyError));
+ return;
+ }
- if(updateLabelName.equals("")) {
+ if(!AppUtil.checkStrings(updateLabelName)) {
- Toasty.error(ctx, getString(R.string.labelEmptyError));
- return;
- }
+ Toasty.error(ctx, getString(R.string.labelNameError));
+ return;
+ }
- if(!AppUtil.checkStrings(updateLabelName)) {
+ disableProcessButton();
+ patchLabel(repository, updateLabelName, updateLabelColor, Integer.parseInt(Objects.requireNonNull(getIntent().getStringExtra("labelId"))));
+ }
- Toasty.error(ctx, getString(R.string.labelNameError));
- return;
- }
+ private void processCreateLabel() {
- disableProcessButton();
- patchLabel(repository, updateLabelName, updateLabelColor, Integer.parseInt(
- Objects.requireNonNull(getIntent().getStringExtra("labelId"))));
- }
+ boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
- private void processCreateLabel() {
+ String newLabelName = Objects.requireNonNull(activityCreateLabelBinding.labelName.getText()).toString();
+ String newLabelColor;
- boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
+ if(labelColor.isEmpty()) {
- String newLabelName = Objects.requireNonNull(activityCreateLabelBinding.labelName.getText()).toString();
- String newLabelColor;
+ newLabelColor = String.format("#%06X", (0xFFFFFF & ContextCompat.getColor(ctx, R.color.releasePre)));
+ }
+ else {
- if(labelColor.isEmpty()) {
+ newLabelColor = labelColor;
+ }
- newLabelColor = String.format("#%06X", (0xFFFFFF & ContextCompat.getColor(ctx, R.color.releasePre)));
- }
- else {
+ if(!connToInternet) {
- newLabelColor = labelColor;
- }
+ Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
+ return;
+ }
- if(!connToInternet) {
+ if(newLabelName.equals("")) {
- Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
- return;
- }
+ Toasty.error(ctx, getString(R.string.labelEmptyError));
+ return;
+ }
- if(newLabelName.equals("")) {
+ if(!AppUtil.checkStrings(newLabelName)) {
- Toasty.error(ctx, getString(R.string.labelEmptyError));
- return;
- }
+ Toasty.error(ctx, getString(R.string.labelNameError));
+ return;
+ }
- if(!AppUtil.checkStrings(newLabelName)) {
+ disableProcessButton();
+ createNewLabel(newLabelName, newLabelColor);
+ }
- Toasty.error(ctx, getString(R.string.labelNameError));
- return;
- }
+ private void createNewLabel(String newLabelName, String newLabelColor) {
- disableProcessButton();
- createNewLabel(newLabelName, newLabelColor);
- }
-
- private void createNewLabel(String newLabelName, String newLabelColor) {
-
- CreateLabelOption createLabelFunc = new CreateLabelOption();
+ CreateLabelOption createLabelFunc = new CreateLabelOption();
createLabelFunc.setColor(newLabelColor);
createLabelFunc.setName(newLabelName);
- Call call;
+ Call 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 call, @NonNull retrofit2.Response response) {
+ @Override
+ public void onResponse(@NonNull Call call, @NonNull retrofit2.Response 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 call, @NonNull Throwable t) {
+ @Override
+ public void onFailure(@NonNull Call 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();
+ EditLabelOption createLabelFunc = new EditLabelOption();
createLabelFunc.setColor(updateLabelColor);
createLabelFunc.setName(updateLabelName);
- Call call;
+ Call 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 call, @NonNull retrofit2.Response response) {
+ @Override
+ public void onResponse(@NonNull Call call, @NonNull retrofit2.Response 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();
- }
- }
- else if(response.code() == 401) {
+ Toasty.success(ctx, getString(R.string.labelUpdated));
+ 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 call, @NonNull Throwable t) {
+ @Override
+ public void onFailure(@NonNull Call call, @NonNull Throwable t) {
- labelColor = "";
- labelColorDefault = "";
- Log.e("onFailure", t.toString());
- enableProcessButton();
- }
- });
- }
+ labelColor = "";
+ labelColorDefault = "";
+ Log.e("onFailure", t.toString());
+ enableProcessButton();
+ }
+ });
+ }
- private void initCloseListener() {
+ private void initCloseListener() {
- onClickListener = view -> finish();
- }
+ onClickListener = view -> finish();
+ }
- private void deleteLabel(int labelId) {
+ private void deleteLabel(int labelId) {
- Call call;
+ Call 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 call, @NonNull retrofit2.Response response) {
+ @Override
+ public void onResponse(@NonNull Call call, @NonNull retrofit2.Response 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);
- }
- }
- }
- else if(response.code() == 401) {
+ LabelsViewModel.loadLabelsList(repository.getOwner(), repository.getName(), ctx);
+ }
+ }
+ }
+ else if(response.code() == 401) {
- AlertDialogs.authorizationTokenRevokedDialog(ctx);
- }
- else {
+ AlertDialogs.authorizationTokenRevokedDialog(ctx);
+ }
+ else {
- Toasty.error(ctx, getString(R.string.genericError));
- }
- }
+ Toasty.error(ctx, getString(R.string.genericError));
+ }
+ }
- @Override
- public void onFailure(@NonNull Call call, @NonNull Throwable t) {
- Log.e("onFailure", t.toString());
- }
- });
+ @Override
+ public void onFailure(@NonNull Call call, @NonNull Throwable t) {
+ Log.e("onFailure", t.toString());
+ }
+ });
- }
+ }
- private void disableProcessButton() {
+ private void disableProcessButton() {
- activityCreateLabelBinding.createLabelButton.setEnabled(false);
- }
+ activityCreateLabelBinding.createLabelButton.setEnabled(false);
+ }
- private void enableProcessButton() {
+ private void enableProcessButton() {
- activityCreateLabelBinding.createLabelButton.setEnabled(true);
- }
+ activityCreateLabelBinding.createLabelButton.setEnabled(true);
+ }
@Override
public void onResume() {
super.onResume();
- if(repository == null) return;
+ if(repository == null) {
+ return;
+ }
repository.checkAccountSwitch(this);
}
diff --git a/app/src/main/java/org/mian/gitnex/activities/CreateMilestoneActivity.java b/app/src/main/java/org/mian/gitnex/activities/CreateMilestoneActivity.java
index cb9c6880..5e82990d 100644
--- a/app/src/main/java/org/mian/gitnex/activities/CreateMilestoneActivity.java
+++ b/app/src/main/java/org/mian/gitnex/activities/CreateMilestoneActivity.java
@@ -33,185 +33,181 @@ import retrofit2.Callback;
public class CreateMilestoneActivity extends BaseActivity implements View.OnClickListener {
- private EditText milestoneDueDate;
- private View.OnClickListener onClickListener;
- private EditText milestoneTitle;
- private EditText milestoneDescription;
- private Button createNewMilestoneButton;
- private RepositoryContext repository;
+ private EditText milestoneDueDate;
+ private View.OnClickListener onClickListener;
+ private EditText milestoneTitle;
+ private EditText milestoneDescription;
+ private Button createNewMilestoneButton;
+ private RepositoryContext repository;
private Date currentDate = null;
+ private final View.OnClickListener createMilestoneListener = v -> processNewMilestone();
- @SuppressLint("ClickableViewAccessibility")
- @Override
- public void onCreate(Bundle savedInstanceState) {
+ @SuppressLint("ClickableViewAccessibility")
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
+ super.onCreate(savedInstanceState);
- ActivityCreateMilestoneBinding activityCreateMilestoneBinding = ActivityCreateMilestoneBinding.inflate(getLayoutInflater());
- setContentView(activityCreateMilestoneBinding.getRoot());
+ ActivityCreateMilestoneBinding activityCreateMilestoneBinding = ActivityCreateMilestoneBinding.inflate(getLayoutInflater());
+ setContentView(activityCreateMilestoneBinding.getRoot());
- boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
+ boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
- InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
+ InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
- milestoneDueDate = activityCreateMilestoneBinding.milestoneDueDate;
- ImageView closeActivity = activityCreateMilestoneBinding.close;
- createNewMilestoneButton = activityCreateMilestoneBinding.createNewMilestoneButton;
- milestoneTitle = activityCreateMilestoneBinding.milestoneTitle;
- milestoneDescription = activityCreateMilestoneBinding.milestoneDescription;
- repository = RepositoryContext.fromIntent(getIntent());
+ milestoneDueDate = activityCreateMilestoneBinding.milestoneDueDate;
+ ImageView closeActivity = activityCreateMilestoneBinding.close;
+ createNewMilestoneButton = activityCreateMilestoneBinding.createNewMilestoneButton;
+ milestoneTitle = activityCreateMilestoneBinding.milestoneTitle;
+ milestoneDescription = activityCreateMilestoneBinding.milestoneDescription;
+ repository = RepositoryContext.fromIntent(getIntent());
- milestoneTitle.requestFocus();
- assert imm != null;
- imm.showSoftInput(milestoneTitle, InputMethodManager.SHOW_IMPLICIT);
+ milestoneTitle.requestFocus();
+ 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);
+ initCloseListener();
+ closeActivity.setOnClickListener(onClickListener);
+ milestoneDueDate.setOnClickListener(this);
- if(!connToInternet) {
+ if(!connToInternet) {
- createNewMilestoneButton.setEnabled(false);
- }
- else {
+ createNewMilestoneButton.setEnabled(false);
+ }
+ else {
- createNewMilestoneButton.setOnClickListener(createMilestoneListener);
- }
+ createNewMilestoneButton.setOnClickListener(createMilestoneListener);
+ }
- }
+ }
- private final View.OnClickListener createMilestoneListener = v -> processNewMilestone();
+ private void processNewMilestone() {
- private void processNewMilestone() {
+ boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
- boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
+ String newMilestoneTitle = milestoneTitle.getText().toString();
+ String newMilestoneDescription = milestoneDescription.getText().toString();
- String newMilestoneTitle = milestoneTitle.getText().toString();
- String newMilestoneDescription = milestoneDescription.getText().toString();
+ if(!connToInternet) {
- if(!connToInternet) {
+ Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
+ return;
+ }
- Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
- return;
- }
+ if(newMilestoneTitle.equals("")) {
- if(newMilestoneTitle.equals("")) {
+ Toasty.error(ctx, getString(R.string.milestoneNameErrorEmpty));
+ return;
+ }
- 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;
+ }
+ }
- Toasty.warning(ctx, getString(R.string.milestoneDescError));
- return;
- }
- }
+ disableProcessButton();
+ createNewMilestone(repository.getOwner(), repository.getName(), newMilestoneTitle, newMilestoneDescription);
+ }
- disableProcessButton();
- 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();
+ CreateMilestoneOption createMilestone = new CreateMilestoneOption();
createMilestone.setDescription(newMilestoneDescription);
createMilestone.setTitle(newMilestoneTitle);
createMilestone.setDueOn(currentDate);
- Call call;
+ Call call;
- call = RetrofitClient
- .getApiInterface(ctx)
- .issueCreateMilestone(repoOwner, repoName, createMilestone);
+ call = RetrofitClient.getApiInterface(ctx).issueCreateMilestone(repoOwner, repoName, createMilestone);
- call.enqueue(new Callback() {
+ call.enqueue(new Callback() {
- @Override
- public void onResponse(@NonNull Call call, @NonNull retrofit2.Response response) {
+ @Override
+ public void onResponse(@NonNull Call call, @NonNull retrofit2.Response 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();
- }
- }
- else if(response.code() == 401) {
+ 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();
+ 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 call, @NonNull Throwable t) {
+ @Override
+ public void onFailure(@NonNull Call call, @NonNull Throwable t) {
- Log.e("onFailure", t.toString());
- enableProcessButton();
- }
- });
+ Log.e("onFailure", t.toString());
+ enableProcessButton();
+ }
+ });
- }
+ }
- @Override
- public void onClick(View v) {
+ @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);
+ 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) -> {
+ 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();
- }
+ }, mYear, mMonth, mDay);
+ datePickerDialog.show();
+ }
- }
+ }
- private void initCloseListener() {
+ private void initCloseListener() {
- onClickListener = view -> finish();
- }
+ onClickListener = view -> finish();
+ }
- private void disableProcessButton() {
+ private void disableProcessButton() {
- createNewMilestoneButton.setEnabled(false);
- }
+ createNewMilestoneButton.setEnabled(false);
+ }
- private void enableProcessButton() {
+ private void enableProcessButton() {
- createNewMilestoneButton.setEnabled(true);
- }
+ createNewMilestoneButton.setEnabled(true);
+ }
@Override
public void onResume() {
diff --git a/app/src/main/java/org/mian/gitnex/activities/CreateNewUserActivity.java b/app/src/main/java/org/mian/gitnex/activities/CreateNewUserActivity.java
index 6d676e42..cde022a3 100644
--- a/app/src/main/java/org/mian/gitnex/activities/CreateNewUserActivity.java
+++ b/app/src/main/java/org/mian/gitnex/activities/CreateNewUserActivity.java
@@ -27,168 +27,165 @@ import retrofit2.Callback;
public class CreateNewUserActivity extends BaseActivity {
- private View.OnClickListener onClickListener;
- private EditText fullName;
- private EditText userUserName;
- private EditText userEmail;
- private EditText userPassword;
- private Button createUserButton;
+ private View.OnClickListener onClickListener;
+ private EditText fullName;
+ private EditText userUserName;
+ private EditText userEmail;
+ private EditText userPassword;
+ private Button createUserButton;
+ private final View.OnClickListener createNewUserListener = v -> processCreateNewUser();
- @Override
- public void onCreate(Bundle savedInstanceState) {
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
+ super.onCreate(savedInstanceState);
- ActivityCreateNewUserBinding activityCreateNewUserBinding = ActivityCreateNewUserBinding.inflate(getLayoutInflater());
- setContentView(activityCreateNewUserBinding.getRoot());
+ ActivityCreateNewUserBinding activityCreateNewUserBinding = ActivityCreateNewUserBinding.inflate(getLayoutInflater());
+ setContentView(activityCreateNewUserBinding.getRoot());
- boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
+ boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
- InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
+ InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
- ImageView closeActivity = activityCreateNewUserBinding.close;
- createUserButton = activityCreateNewUserBinding.createUserButton;
- fullName = activityCreateNewUserBinding.fullName;
- userUserName = activityCreateNewUserBinding.userUserName;
- userEmail = activityCreateNewUserBinding.userEmail;
- userPassword = activityCreateNewUserBinding.userPassword;
+ ImageView closeActivity = activityCreateNewUserBinding.close;
+ createUserButton = activityCreateNewUserBinding.createUserButton;
+ fullName = activityCreateNewUserBinding.fullName;
+ userUserName = activityCreateNewUserBinding.userUserName;
+ userEmail = activityCreateNewUserBinding.userEmail;
+ userPassword = activityCreateNewUserBinding.userPassword;
- fullName.requestFocus();
- assert imm != null;
- imm.showSoftInput(fullName, InputMethodManager.SHOW_IMPLICIT);
+ fullName.requestFocus();
+ assert imm != null;
+ imm.showSoftInput(fullName, InputMethodManager.SHOW_IMPLICIT);
- initCloseListener();
- closeActivity.setOnClickListener(onClickListener);
+ initCloseListener();
+ closeActivity.setOnClickListener(onClickListener);
- if(!connToInternet) {
+ if(!connToInternet) {
- disableProcessButton();
- }
- else {
+ disableProcessButton();
+ }
+ else {
- createUserButton.setOnClickListener(createNewUserListener);
- }
- }
+ createUserButton.setOnClickListener(createNewUserListener);
+ }
+ }
- private void processCreateNewUser() {
+ private void processCreateNewUser() {
- boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
+ boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
- String newFullName = fullName.getText().toString().trim();
- String newUserName = userUserName.getText().toString().trim();
- String newUserEmail = userEmail.getText().toString().trim();
- String newUserPassword = userPassword.getText().toString();
+ String newFullName = fullName.getText().toString().trim();
+ String newUserName = userUserName.getText().toString().trim();
+ String newUserEmail = userEmail.getText().toString().trim();
+ String newUserPassword = userPassword.getText().toString();
- if(!connToInternet) {
+ if(!connToInternet) {
- Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
- return;
- }
+ 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;
- }
+ Toasty.error(ctx, getString(R.string.emptyFields));
+ return;
+ }
- if(!AppUtil.checkStrings(newFullName)) {
+ if(!AppUtil.checkStrings(newFullName)) {
- Toasty.error(ctx, getString(R.string.userInvalidFullName));
- return;
- }
+ Toasty.error(ctx, getString(R.string.userInvalidFullName));
+ return;
+ }
- if(!AppUtil.checkStringsWithAlphaNumeric(newUserName)) {
+ if(!AppUtil.checkStringsWithAlphaNumeric(newUserName)) {
- Toasty.error(ctx, getString(R.string.userInvalidUserName));
- return;
- }
+ 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;
- }
+ Toasty.error(ctx, getString(R.string.userInvalidEmail));
+ return;
+ }
- disableProcessButton();
- createNewUser(newFullName, newUserName, newUserEmail, newUserPassword);
- }
+ disableProcessButton();
+ 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();
+ CreateUserOption createUser = new CreateUserOption();
createUser.setEmail(newUserEmail);
createUser.setFullName(newFullName);
createUser.setUsername(newUserName);
createUser.setPassword(newUserPassword);
createUser.setMustChangePassword(true);
- Call call = RetrofitClient
- .getApiInterface(ctx)
- .adminCreateUser(createUser);
+ Call call = RetrofitClient.getApiInterface(ctx).adminCreateUser(createUser);
- call.enqueue(new Callback() {
+ call.enqueue(new Callback() {
- @Override
- public void onResponse(@NonNull Call call, @NonNull retrofit2.Response response) {
+ @Override
+ public void onResponse(@NonNull Call call, @NonNull retrofit2.Response 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 call, @NonNull Throwable t) {
+ @Override
+ public void onFailure(@NonNull Call call, @NonNull Throwable t) {
- Log.e("onFailure", t.toString());
- enableProcessButton();
- }
- });
+ Log.e("onFailure", t.toString());
+ enableProcessButton();
+ }
+ });
- }
+ }
- private final View.OnClickListener createNewUserListener = v -> processCreateNewUser();
+ private void initCloseListener() {
- private void initCloseListener() {
+ onClickListener = view -> finish();
+ }
- onClickListener = view -> finish();
- }
+ private void disableProcessButton() {
- private void disableProcessButton() {
+ createUserButton.setEnabled(false);
+ }
- createUserButton.setEnabled(false);
- }
+ private void enableProcessButton() {
- private void enableProcessButton() {
-
- createUserButton.setEnabled(true);
- }
+ createUserButton.setEnabled(true);
+ }
}
diff --git a/app/src/main/java/org/mian/gitnex/activities/CreateOrganizationActivity.java b/app/src/main/java/org/mian/gitnex/activities/CreateOrganizationActivity.java
index 5a0d83b5..e8707827 100644
--- a/app/src/main/java/org/mian/gitnex/activities/CreateOrganizationActivity.java
+++ b/app/src/main/java/org/mian/gitnex/activities/CreateOrganizationActivity.java
@@ -29,175 +29,172 @@ import retrofit2.Callback;
public class CreateOrganizationActivity extends BaseActivity {
- public ImageView closeActivity;
- private View.OnClickListener onClickListener;
- private Button createOrganizationButton;
+ public ImageView closeActivity;
+ private View.OnClickListener onClickListener;
+ private Button createOrganizationButton;
- private EditText orgName;
- private EditText orgDesc;
+ private EditText orgName;
+ private EditText orgDesc;
+ private final View.OnClickListener createOrgListener = v -> processNewOrganization();
- @SuppressLint("ClickableViewAccessibility")
- @Override
- public void onCreate(Bundle savedInstanceState) {
+ @SuppressLint("ClickableViewAccessibility")
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
+ super.onCreate(savedInstanceState);
- ActivityCreateOrganizationBinding activityCreateOrganizationBinding = ActivityCreateOrganizationBinding.inflate(getLayoutInflater());
- setContentView(activityCreateOrganizationBinding.getRoot());
+ ActivityCreateOrganizationBinding activityCreateOrganizationBinding = ActivityCreateOrganizationBinding.inflate(getLayoutInflater());
+ setContentView(activityCreateOrganizationBinding.getRoot());
- boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
+ boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
- InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
+ InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
- closeActivity = activityCreateOrganizationBinding.close;
- orgName = activityCreateOrganizationBinding.newOrganizationName;
- orgDesc = activityCreateOrganizationBinding.newOrganizationDescription;
+ closeActivity = activityCreateOrganizationBinding.close;
+ orgName = activityCreateOrganizationBinding.newOrganizationName;
+ orgDesc = activityCreateOrganizationBinding.newOrganizationDescription;
- orgName.requestFocus();
- assert imm != null;
- imm.showSoftInput(orgName, InputMethodManager.SHOW_IMPLICIT);
+ orgName.requestFocus();
+ 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);
+ initCloseListener();
+ closeActivity.setOnClickListener(onClickListener);
- createOrganizationButton = activityCreateOrganizationBinding.createNewOrganizationButton;
+ createOrganizationButton = activityCreateOrganizationBinding.createNewOrganizationButton;
- if(!connToInternet) {
+ if(!connToInternet) {
- createOrganizationButton.setEnabled(false);
- }
- else {
+ createOrganizationButton.setEnabled(false);
+ }
+ else {
- createOrganizationButton.setOnClickListener(createOrgListener);
- }
+ createOrganizationButton.setOnClickListener(createOrgListener);
+ }
- }
+ }
- private void initCloseListener() {
+ private void initCloseListener() {
- onClickListener = view -> finish();
- }
+ onClickListener = view -> finish();
+ }
- private final View.OnClickListener createOrgListener = v -> processNewOrganization();
+ private void processNewOrganization() {
- private void processNewOrganization() {
+ boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
- boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
+ String newOrgName = orgName.getText().toString();
+ String newOrgDesc = orgDesc.getText().toString();
- String newOrgName = orgName.getText().toString();
- String newOrgDesc = orgDesc.getText().toString();
+ if(!connToInternet) {
- if(!connToInternet) {
+ Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
+ return;
+ }
- 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;
+ }
+ }
- 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)) {
- Toasty.error(ctx, getString(R.string.orgNameErrorEmpty));
- }
- else if(!AppUtil.checkStrings(newOrgName)) {
+ Toasty.warning(ctx, getString(R.string.orgNameErrorInvalid));
+ }
+ else {
- Toasty.warning(ctx, getString(R.string.orgNameErrorInvalid));
- }
- else {
+ disableProcessButton();
+ createNewOrganization(newOrgName, newOrgDesc);
+ }
- disableProcessButton();
- createNewOrganization(newOrgName, newOrgDesc);
- }
+ }
- }
+ private void createNewOrganization(String orgName, String orgDesc) {
- private void createNewOrganization(String orgName, String orgDesc) {
-
- CreateOrgOption createOrganization = new CreateOrgOption();
+ CreateOrgOption createOrganization = new CreateOrgOption();
createOrganization.setDescription(orgDesc);
createOrganization.setUsername(orgName);
- Call call = RetrofitClient
- .getApiInterface(ctx)
- .orgCreate(createOrganization);
+ Call call = RetrofitClient.getApiInterface(ctx).orgCreate(createOrganization);
- call.enqueue(new Callback() {
+ call.enqueue(new Callback() {
- @Override
- public void onResponse(@NonNull Call call, @NonNull retrofit2.Response response) {
+ @Override
+ public void onResponse(@NonNull Call call, @NonNull retrofit2.Response 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));
- }
- else {
+ enableProcessButton();
+ Toasty.warning(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 call, @NonNull Throwable t) {
+ @Override
+ public void onFailure(@NonNull Call call, @NonNull Throwable t) {
- Log.e("onFailure", t.toString());
- enableProcessButton();
- }
- });
+ Log.e("onFailure", t.toString());
+ enableProcessButton();
+ }
+ });
- }
+ }
- private void disableProcessButton() {
+ private void disableProcessButton() {
- createOrganizationButton.setEnabled(false);
- }
+ createOrganizationButton.setEnabled(false);
+ }
- private void enableProcessButton() {
+ private void enableProcessButton() {
- createOrganizationButton.setEnabled(true);
- }
+ createOrganizationButton.setEnabled(true);
+ }
}
diff --git a/app/src/main/java/org/mian/gitnex/activities/CreatePullRequestActivity.java b/app/src/main/java/org/mian/gitnex/activities/CreatePullRequestActivity.java
index ffafa52b..ae003072 100644
--- a/app/src/main/java/org/mian/gitnex/activities/CreatePullRequestActivity.java
+++ b/app/src/main/java/org/mian/gitnex/activities/CreatePullRequestActivity.java
@@ -11,11 +11,7 @@ import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
-import org.gitnex.tea4j.v2.models.Branch;
-import org.gitnex.tea4j.v2.models.CreatePullRequestOption;
-import org.gitnex.tea4j.v2.models.Label;
-import org.gitnex.tea4j.v2.models.Milestone;
-import org.gitnex.tea4j.v2.models.PullRequest;
+import org.gitnex.tea4j.v2.models.*;
import org.mian.gitnex.R;
import org.mian.gitnex.actions.LabelsActions;
import org.mian.gitnex.adapters.LabelsListAdapter;
@@ -26,12 +22,7 @@ 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 java.util.*;
import retrofit2.Call;
import retrofit2.Callback;
@@ -41,21 +32,18 @@ import retrofit2.Callback;
public class CreatePullRequestActivity extends BaseActivity implements LabelsListAdapter.LabelsListAdapterListener {
- private View.OnClickListener onClickListener;
- private ActivityCreatePrBinding viewBinding;
- private List labelsIds = new ArrayList<>();
private final List assignees = new ArrayList<>();
- private int milestoneId;
- private Date currentDate = null;
-
- private RepositoryContext repository;
- private LabelsListAdapter labelsAdapter;
-
- private MaterialAlertDialogBuilder materialAlertDialogBuilder;
-
LinkedHashMap milestonesList = new LinkedHashMap<>();
List branchesList = new ArrayList<>();
List labelsList = new ArrayList<>();
+ private View.OnClickListener onClickListener;
+ private ActivityCreatePrBinding viewBinding;
+ private List labelsIds = new ArrayList<>();
+ private int milestoneId;
+ private Date currentDate = null;
+ private RepositoryContext repository;
+ private LabelsListAdapter labelsAdapter;
+ private MaterialAlertDialogBuilder materialAlertDialogBuilder;
@SuppressLint("ClickableViewAccessibility")
@Override
@@ -76,23 +64,21 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
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;
});
- labelsAdapter = new LabelsListAdapter(labelsList, CreatePullRequestActivity.this, labelsIds);
+ labelsAdapter = new LabelsListAdapter(labelsList, CreatePullRequestActivity.this, labelsIds);
ImageView closeActivity = findViewById(R.id.close);
initCloseListener();
closeActivity.setOnClickListener(onClickListener);
- viewBinding.prDueDate.setOnClickListener(dueDate ->
- setDueDate()
- );
+ viewBinding.prDueDate.setOnClickListener(dueDate -> setDueDate());
disableProcessButton();
@@ -119,7 +105,7 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
assignees.add("");
- if (labelsIds.size() == 0) {
+ if(labelsIds.size() == 0) {
labelsIds.add(0);
}
@@ -163,9 +149,7 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
createPullRequest.setLabels(labelIds);
createPullRequest.setDueDate(currentDate);
- Call transferCall = RetrofitClient
- .getApiInterface(ctx)
- .repoCreatePullRequest(repository.getOwner(), repository.getName(), createPullRequest);
+ Call transferCall = RetrofitClient.getApiInterface(ctx).repoCreatePullRequest(repository.getOwner(), repository.getName(), createPullRequest);
transferCall.enqueue(new Callback<>() {
@@ -224,8 +208,7 @@ 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);
@@ -235,9 +218,7 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
private void getBranches(String repoOwner, String repoName) {
- Call> call = RetrofitClient
- .getApiInterface(ctx)
- .repoListBranches(repoOwner, repoName, null, null);
+ Call> call = RetrofitClient.getApiInterface(ctx).repoListBranches(repoOwner, repoName, null, null);
call.enqueue(new Callback<>() {
@@ -277,9 +258,7 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
private void getMilestones(String repoOwner, String repoName, int resultLimit) {
String msState = "open";
- Call> call = RetrofitClient
- .getApiInterface(ctx)
- .issueGetMilestonesList(repoOwner, repoName, msState, null, 1, resultLimit);
+ Call> call = RetrofitClient.getApiInterface(ctx).issueGetMilestonesList(repoOwner, repoName, msState, null, 1, resultLimit);
call.enqueue(new Callback<>() {
@@ -336,11 +315,10 @@ 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) -> {
+ 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);
+ }, mYear, mMonth, mDay);
datePickerDialog.show();
}
@@ -364,4 +342,5 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
super.onResume();
repository.checkAccountSwitch(this);
}
+
}
diff --git a/app/src/main/java/org/mian/gitnex/activities/CreateReleaseActivity.java b/app/src/main/java/org/mian/gitnex/activities/CreateReleaseActivity.java
index 09399c29..eb520339 100644
--- a/app/src/main/java/org/mian/gitnex/activities/CreateReleaseActivity.java
+++ b/app/src/main/java/org/mian/gitnex/activities/CreateReleaseActivity.java
@@ -8,18 +8,9 @@ import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
-import android.widget.ArrayAdapter;
-import android.widget.AutoCompleteTextView;
-import android.widget.Button;
-import android.widget.CheckBox;
-import android.widget.EditText;
-import android.widget.ImageView;
+import android.widget.*;
import androidx.annotation.NonNull;
-import org.gitnex.tea4j.v2.models.Branch;
-import org.gitnex.tea4j.v2.models.CreateReleaseOption;
-import org.gitnex.tea4j.v2.models.CreateTagOption;
-import org.gitnex.tea4j.v2.models.Release;
-import org.gitnex.tea4j.v2.models.Tag;
+import org.gitnex.tea4j.v2.models.*;
import org.mian.gitnex.R;
import org.mian.gitnex.clients.RetrofitClient;
import org.mian.gitnex.databinding.ActivityCreateReleaseBinding;
@@ -38,313 +29,305 @@ import retrofit2.Callback;
public class CreateReleaseActivity extends BaseActivity {
- private View.OnClickListener onClickListener;
- public ImageView closeActivity;
- private EditText releaseTagName;
- private AutoCompleteTextView releaseBranch;
- private EditText releaseTitle;
- private EditText releaseContent;
- private CheckBox releaseType;
- private CheckBox releaseDraft;
- private Button createNewRelease;
- private String selectedBranch;
- private Button createNewTag;
-
+ public ImageView closeActivity;
+ List branchesList = new ArrayList<>();
+ private View.OnClickListener onClickListener;
+ private EditText releaseTagName;
+ private AutoCompleteTextView releaseBranch;
+ private EditText releaseTitle;
+ private EditText releaseContent;
+ private CheckBox releaseType;
+ private CheckBox releaseDraft;
+ private Button createNewRelease;
+ private String selectedBranch;
+ private Button createNewTag;
private RepositoryContext repository;
+ private final View.OnClickListener createReleaseListener = v -> processNewRelease();
- List branchesList = new ArrayList<>();
+ @SuppressLint("ClickableViewAccessibility")
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
- @SuppressLint("ClickableViewAccessibility")
- @Override
- public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
- super.onCreate(savedInstanceState);
+ ActivityCreateReleaseBinding activityCreateReleaseBinding = ActivityCreateReleaseBinding.inflate(getLayoutInflater());
+ setContentView(activityCreateReleaseBinding.getRoot());
- ActivityCreateReleaseBinding activityCreateReleaseBinding = ActivityCreateReleaseBinding.inflate(getLayoutInflater());
- setContentView(activityCreateReleaseBinding.getRoot());
+ boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
- boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
+ InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
- InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
+ repository = RepositoryContext.fromIntent(getIntent());
- repository = RepositoryContext.fromIntent(getIntent());
+ closeActivity = activityCreateReleaseBinding.close;
+ releaseTagName = activityCreateReleaseBinding.releaseTagName;
+ releaseTitle = activityCreateReleaseBinding.releaseTitle;
+ releaseContent = activityCreateReleaseBinding.releaseContent;
+ releaseType = activityCreateReleaseBinding.releaseType;
+ releaseDraft = activityCreateReleaseBinding.releaseDraft;
- closeActivity = activityCreateReleaseBinding.close;
- releaseTagName = activityCreateReleaseBinding.releaseTagName;
- releaseTitle = activityCreateReleaseBinding.releaseTitle;
- releaseContent = activityCreateReleaseBinding.releaseContent;
- releaseType = activityCreateReleaseBinding.releaseType;
- releaseDraft = activityCreateReleaseBinding.releaseDraft;
+ releaseTitle.requestFocus();
+ assert imm != null;
+ imm.showSoftInput(releaseTitle, InputMethodManager.SHOW_IMPLICIT);
- releaseTitle.requestFocus();
- 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);
- initCloseListener();
- closeActivity.setOnClickListener(onClickListener);
+ releaseBranch = activityCreateReleaseBinding.releaseBranch;
+ getBranches(repository.getOwner(), repository.getName());
- releaseBranch = activityCreateReleaseBinding.releaseBranch;
- getBranches(repository.getOwner(), repository.getName());
+ createNewRelease = activityCreateReleaseBinding.createNewRelease;
+ createNewTag = activityCreateReleaseBinding.createNewTag;
+ disableProcessButton();
- createNewRelease = activityCreateReleaseBinding.createNewRelease;
- createNewTag = activityCreateReleaseBinding.createNewTag;
- disableProcessButton();
+ if(!connToInternet) {
- if(!connToInternet) {
+ disableProcessButton();
+ }
+ else {
- disableProcessButton();
- }
- else {
+ createNewRelease.setOnClickListener(createReleaseListener);
+ }
- createNewRelease.setOnClickListener(createReleaseListener);
- }
+ createNewTag.setOnClickListener(v -> createNewTag());
+ }
- createNewTag.setOnClickListener(v -> createNewTag());
- }
+ private void createNewTag() {
+ boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
- private void createNewTag() {
- boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
+ String tagName = releaseTagName.getText().toString();
+ String message = releaseTitle.getText().toString() + "\n\n" + releaseContent.getText().toString();
- String tagName = releaseTagName.getText().toString();
- String message = releaseTitle.getText().toString() + "\n\n" + releaseContent.getText().toString();
+ if(!connToInternet) {
+ Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
+ return;
+ }
- if(!connToInternet) {
- Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
- return;
- }
+ if(tagName.equals("")) {
+ Toasty.error(ctx, getString(R.string.tagNameErrorEmpty));
+ return;
+ }
- if(tagName.equals("")) {
- Toasty.error(ctx, getString(R.string.tagNameErrorEmpty));
- return;
- }
+ if(selectedBranch == null) {
+ Toasty.error(ctx, getString(R.string.selectBranchError));
+ return;
+ }
- if(selectedBranch == null) {
- Toasty.error(ctx, getString(R.string.selectBranchError));
- return;
- }
+ disableProcessButton();
- disableProcessButton();
-
- CreateTagOption createReleaseJson = new CreateTagOption();
+ CreateTagOption createReleaseJson = new CreateTagOption();
createReleaseJson.setMessage(message);
createReleaseJson.setTagName(tagName);
createReleaseJson.setTarget(selectedBranch);
- Call call = RetrofitClient
- .getApiInterface(ctx)
- .repoCreateTag(repository.getOwner(), repository.getName(), createReleaseJson);
+ Call call = RetrofitClient.getApiInterface(ctx).repoCreateTag(repository.getOwner(), repository.getName(), createReleaseJson);
- call.enqueue(new Callback() {
+ call.enqueue(new Callback() {
- @Override
- public void onResponse(@NonNull Call call, @NonNull retrofit2.Response response) {
+ @Override
+ public void onResponse(@NonNull Call call, @NonNull retrofit2.Response 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 call, @NonNull Throwable t) {
- Log.e("onFailure", t.toString());
- enableProcessButton();
- }
- });
- }
+ @Override
+ public void onFailure(@NonNull Call call, @NonNull Throwable t) {
+ Log.e("onFailure", t.toString());
+ enableProcessButton();
+ }
+ });
+ }
- private final View.OnClickListener createReleaseListener = v -> processNewRelease();
+ private void processNewRelease() {
- private void processNewRelease() {
+ boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
- boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
+ String newReleaseTagName = releaseTagName.getText().toString();
+ String newReleaseTitle = releaseTitle.getText().toString();
+ String newReleaseContent = releaseContent.getText().toString();
+ String checkBranch = selectedBranch;
+ boolean newReleaseType = releaseType.isChecked();
+ boolean newReleaseDraft = releaseDraft.isChecked();
- String newReleaseTagName = releaseTagName.getText().toString();
- String newReleaseTitle = releaseTitle.getText().toString();
- String newReleaseContent = releaseContent.getText().toString();
- String checkBranch = selectedBranch;
- boolean newReleaseType = releaseType.isChecked();
- boolean newReleaseDraft = releaseDraft.isChecked();
+ if(!connToInternet) {
- if(!connToInternet) {
+ Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
+ return;
+ }
- Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
- return;
- }
+ if(newReleaseTitle.equals("")) {
- if(newReleaseTitle.equals("")) {
+ Toasty.error(ctx, getString(R.string.titleErrorEmpty));
+ return;
+ }
- Toasty.error(ctx, getString(R.string.titleErrorEmpty));
- return;
- }
+ if(newReleaseTagName.equals("")) {
- if(newReleaseTagName.equals("")) {
+ Toasty.error(ctx, getString(R.string.tagNameErrorEmpty));
+ return;
+ }
- Toasty.error(ctx, getString(R.string.tagNameErrorEmpty));
- return;
- }
+ if(checkBranch == null) {
- if(checkBranch == null) {
+ Toasty.error(ctx, getString(R.string.selectBranchError));
+ return;
+ }
- Toasty.error(ctx, getString(R.string.selectBranchError));
- return;
- }
+ disableProcessButton();
+ createNewReleaseFunc(repository.getOwner(), repository.getName(), newReleaseTagName, newReleaseTitle, newReleaseContent, selectedBranch, newReleaseType, newReleaseDraft);
+ }
- disableProcessButton();
- 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);
+ CreateReleaseOption createReleaseJson = new CreateReleaseOption();
+ createReleaseJson.setName(newReleaseTitle);
createReleaseJson.setTagName(newReleaseTagName);
createReleaseJson.setBody(newReleaseContent);
createReleaseJson.setDraft(newReleaseDraft);
createReleaseJson.setPrerelease(newReleaseType);
createReleaseJson.setTargetCommitish(selectedBranch);
- Call call = RetrofitClient
- .getApiInterface(ctx)
- .repoCreateRelease(repoOwner, repoName, createReleaseJson);
+ Call call = RetrofitClient.getApiInterface(ctx).repoCreateRelease(repoOwner, repoName, createReleaseJson);
- call.enqueue(new Callback<>() {
+ call.enqueue(new Callback<>() {
- @Override
- public void onResponse(@NonNull Call call, @NonNull retrofit2.Response response) {
+ @Override
+ public void onResponse(@NonNull Call call, @NonNull retrofit2.Response 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));
- }
- }
+ enableProcessButton();
+ Toasty.error(ctx, ctx.getString(R.string.genericError));
+ }
+ }
- @Override
- public void onFailure(@NonNull Call call, @NonNull Throwable t) {
- enableProcessButton();
- }
- });
+ @Override
+ public void onFailure(@NonNull Call call, @NonNull Throwable t) {
+ enableProcessButton();
+ }
+ });
- }
+ }
- private void getBranches(final String repoOwner, final String repoName) {
+ private void getBranches(final String repoOwner, final String repoName) {
- Call> call = RetrofitClient
- .getApiInterface(ctx)
- .repoListBranches(repoOwner, repoName, null, null);
+ Call> call = RetrofitClient.getApiInterface(ctx).repoListBranches(repoOwner, repoName, null, null);
- call.enqueue(new Callback<>() {
+ call.enqueue(new Callback<>() {
- @Override
- public void onResponse(@NonNull Call> call, @NonNull retrofit2.Response> response) {
+ @Override
+ public void onResponse(@NonNull Call> call, @NonNull retrofit2.Response> response) {
- if(response.isSuccessful()) {
+ if(response.isSuccessful()) {
- if(response.code() == 200) {
+ if(response.code() == 200) {
- List branchesList_ = response.body();
+ List 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 adapter = new ArrayAdapter<>(CreateReleaseActivity.this, R.layout.list_spinner_items, branchesList);
+ ArrayAdapter adapter = new ArrayAdapter<>(CreateReleaseActivity.this, R.layout.list_spinner_items, branchesList);
- releaseBranch.setAdapter(adapter);
- enableProcessButton();
+ releaseBranch.setAdapter(adapter);
+ enableProcessButton();
- releaseBranch.setOnItemClickListener((parent, view, position, id) -> selectedBranch = branchesList.get(position));
- }
- }
- else if(response.code() == 401) {
+ releaseBranch.setOnItemClickListener((parent, view, position, id) -> selectedBranch = branchesList.get(position));
+ }
+ }
+ else if(response.code() == 401) {
- AlertDialogs.authorizationTokenRevokedDialog(ctx);
- }
+ AlertDialogs.authorizationTokenRevokedDialog(ctx);
+ }
- }
+ }
- @Override
- public void onFailure(@NonNull Call