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 + [Get it on F-Droid](https://f-droid.org/en/packages/org.mian.gitnex/) [Get it on Google Play](https://play.google.com/store/apps/details?id=org.mian.gitnex.pro) [Download builds and releases](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 [005.png](https://codeberg.org/gitnex/GitNex/raw/branch/main/fastlane/metadata/android/en-US/images/phoneScreenshots/005.png) | [006.png](https://codeberg.org/gitnex/GitNex/raw/branch/main/fastlane/metadata/android/en-US/images/phoneScreenshots/006.png) | [007.png](https://codeberg.org/gitnex/GitNex/raw/branch/main/fastlane/metadata/android/en-US/images/phoneScreenshots/007.png) | [008.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