From 2cde78c2a36d4d5986854aaf398e8332cd2e0bbf Mon Sep 17 00:00:00 2001 From: M M Arif Date: Wed, 6 Mar 2024 14:37:09 +0000 Subject: [PATCH] Fixes and improvements (#1328) Closes #1327 Closes #1308 Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1328 Co-authored-by: M M Arif Co-committed-by: M M Arif --- app/build.gradle | 12 ++--- .../gitnex/activities/DeepLinksActivity.java | 47 +++++++++---------- .../org/mian/gitnex/helpers/SnackBar.java | 8 ++-- .../main/res/layout/activity_deeplinks.xml | 35 +++++++++----- app/src/main/res/values/strings.xml | 4 +- 5 files changed, 58 insertions(+), 48 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 7295fd1e..df246fdf 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -67,14 +67,14 @@ dependencies { testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' - implementation 'com.squareup.okhttp3:okhttp:5.0.0-alpha.2' + implementation 'com.squareup.okhttp3:okhttp:5.0.0-alpha.12' implementation 'com.google.code.gson:gson:2.10.1' implementation "com.squareup.picasso:picasso:2.71828" implementation 'com.github.ramseth001:TextDrawable:1.1.3' implementation 'com.squareup.retrofit2:retrofit:2.9.0' implementation 'com.squareup.retrofit2:converter-gson:2.9.0' implementation 'com.squareup.retrofit2:converter-scalars:2.9.0' - implementation 'com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.2' + implementation 'com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.12' implementation 'org.ocpsoft.prettytime:prettytime:5.0.7.Final' implementation "com.github.skydoves:colorpickerview:2.3.0" implementation "io.noties.markwon:core:4.6.2" @@ -96,9 +96,9 @@ dependencies { implementation 'commons-io:commons-io:2.5' implementation 'org.apache.commons:commons-lang3:3.13.0' implementation "com.github.chrisbanes:PhotoView:2.3.0" - implementation 'ch.acra:acra-mail:5.11.2' - implementation 'ch.acra:acra-limiter:5.11.2' - implementation 'ch.acra:acra-notification:5.11.2' + implementation 'ch.acra:acra-mail:5.11.3' + implementation 'ch.acra:acra-limiter:5.11.3' + implementation 'ch.acra:acra-notification:5.11.3' implementation 'androidx.room:room-runtime:2.6.1' annotationProcessor 'androidx.room:room-compiler:2.6.1' implementation "androidx.work:work-runtime:2.9.0" @@ -113,7 +113,7 @@ dependencies { implementation('org.codeberg.gitnex:tea4j-autodeploy:4646f53557') { exclude module: 'org.apache.oltu.oauth2.common' } - implementation 'io.github.amrdeveloper:codeview:1.3.8' + implementation 'io.github.amrdeveloper:codeview:1.3.9' constraints { implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.0") diff --git a/app/src/main/java/org/mian/gitnex/activities/DeepLinksActivity.java b/app/src/main/java/org/mian/gitnex/activities/DeepLinksActivity.java index ce298321..07d2122a 100644 --- a/app/src/main/java/org/mian/gitnex/activities/DeepLinksActivity.java +++ b/app/src/main/java/org/mian/gitnex/activities/DeepLinksActivity.java @@ -8,8 +8,6 @@ import android.os.Looper; import android.util.Log; import android.view.View; import androidx.annotation.NonNull; -import io.mikael.urlbuilder.UrlBuilder; -import java.net.URI; import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -26,7 +24,6 @@ import org.mian.gitnex.database.api.UserAccountsApi; import org.mian.gitnex.database.models.UserAccount; import org.mian.gitnex.databinding.ActivityDeeplinksBinding; import org.mian.gitnex.helpers.AppUtil; -import org.mian.gitnex.helpers.UrlHelper; import org.mian.gitnex.helpers.contexts.IssueContext; import org.mian.gitnex.helpers.contexts.RepositoryContext; import retrofit2.Call; @@ -40,12 +37,12 @@ public class DeepLinksActivity extends BaseActivity { private ActivityDeeplinksBinding viewBinding; private boolean accountFound = false; - private Intent mainIntent; private Intent issueIntent; private Intent repoIntent; private Intent orgIntent; private Intent userIntent; + private Uri data; @Override public void onCreate(Bundle savedInstanceState) { @@ -62,7 +59,7 @@ public class DeepLinksActivity extends BaseActivity { userIntent = new Intent(ctx, ProfileActivity.class); Intent intent = getIntent(); - Uri data = intent.getData(); + data = intent.getData(); assert data != null; // check for login @@ -111,20 +108,21 @@ public class DeepLinksActivity extends BaseActivity { // redirect to proper fragment/activity, if no action is there, show options where user // to want to go like repos, profile, notifications etc if (data.getPathSegments().size() == 1) { - if (data.getLastPathSegment().equals("notifications")) { // notifications + if (Objects.equals(data.getLastPathSegment(), "notifications")) { // notifications mainIntent.putExtra("launchFragmentByLinkHandler", "notification"); ctx.startActivity(mainIntent); finish(); - } else if (data.getLastPathSegment().equals("explore")) { // explore + } else if (Objects.equals(data.getLastPathSegment(), "explore")) { // explore mainIntent.putExtra("launchFragmentByLinkHandler", "explore"); ctx.startActivity(mainIntent); finish(); - } else if (data.getLastPathSegment() - .equals(getAccount().getAccount().getUserName())) { // your user profile + } else if (Objects.equals( + data.getLastPathSegment(), + getAccount().getAccount().getUserName())) { // your user profile mainIntent.putExtra("launchFragmentByLinkHandler", "profile"); ctx.startActivity(mainIntent); finish(); - } else if (data.getLastPathSegment().equals("admin")) { + } else if (Objects.equals(data.getLastPathSegment(), "admin")) { mainIntent.putExtra("launchFragmentByLinkHandler", "admin"); ctx.startActivity(mainIntent); finish(); @@ -152,9 +150,10 @@ public class DeepLinksActivity extends BaseActivity { mainIntent.putExtra("giteaAdminAction", data.getLastPathSegment()); ctx.startActivity(mainIntent); finish(); - } else if (!data.getPathSegments().get(0).equals("") - & !data.getLastPathSegment().equals("")) { // go to repo + } else if (!data.getPathSegments().get(0).isEmpty() + & !Objects.equals(data.getLastPathSegment(), "")) { // go to repo String repo = data.getLastPathSegment(); + assert repo != null; if (repo.endsWith(".git")) { // Git clone URL repo = repo.substring(0, repo.length() - 4); } @@ -300,7 +299,7 @@ public class DeepLinksActivity extends BaseActivity { "commitsList"), 500); } else if (data.getPathSegments().get(2).equals("milestones") - && data.getLastPathSegment().equals("new")) { // new milestone + && Objects.equals(data.getLastPathSegment(), "new")) { // new milestone new Handler(Looper.getMainLooper()) .postDelayed( () -> @@ -329,7 +328,7 @@ public class DeepLinksActivity extends BaseActivity { "milestones"), 500); } else if (data.getPathSegments().get(2).equals("releases") - && data.getLastPathSegment().equals("new")) { // new release + && Objects.equals(data.getLastPathSegment(), "new")) { // new release new Handler(Looper.getMainLooper()) .postDelayed( () -> @@ -371,7 +370,7 @@ public class DeepLinksActivity extends BaseActivity { data.getPathSegments().get(1), "settings"), 500); - } else if (data.getLastPathSegment().equals("branches")) { // branches list + } else if (Objects.equals(data.getLastPathSegment(), "branches")) { // branches list new Handler(Looper.getMainLooper()) .postDelayed( () -> @@ -414,7 +413,8 @@ public class DeepLinksActivity extends BaseActivity { } else if (data.getPathSegments().get(2).equals("wiki")) { // wiki if (data.getQueryParameter("action") != null - && data.getQueryParameter("action").equalsIgnoreCase("_new")) { + && Objects.requireNonNull(data.getQueryParameter("action")) + .equalsIgnoreCase("_new")) { new Handler(Looper.getMainLooper()) .postDelayed( () -> @@ -461,14 +461,7 @@ public class DeepLinksActivity extends BaseActivity { viewBinding.openInBrowser.setOnClickListener( addNewAccount -> { - Integer port = data.getPort() >= 0 ? data.getPort() : null; - - URI host = - UrlBuilder.fromString(UrlHelper.fixScheme(data.getHost(), "https")) - .withPort(port) - .toUri(); - - AppUtil.openUrlInBrowser(this, String.valueOf(host)); + AppUtil.openUrlInBrowser(this, String.valueOf(data)); finish(); }); @@ -707,6 +700,12 @@ public class DeepLinksActivity extends BaseActivity { viewBinding.noActionFrame.setVisibility(View.VISIBLE); viewBinding.addNewAccountFrame.setVisibility(View.GONE); + viewBinding.openInBrowserNoActionFrame.setOnClickListener( + noActionFrameOpenInBrowser -> { + AppUtil.openUrlInBrowser(this, String.valueOf(data)); + finish(); + }); + viewBinding.repository.setOnClickListener( repository -> { tinyDB.putInt("defaultScreenId", 1); diff --git a/app/src/main/java/org/mian/gitnex/helpers/SnackBar.java b/app/src/main/java/org/mian/gitnex/helpers/SnackBar.java index c62367b8..162a813a 100644 --- a/app/src/main/java/org/mian/gitnex/helpers/SnackBar.java +++ b/app/src/main/java/org/mian/gitnex/helpers/SnackBar.java @@ -15,7 +15,7 @@ public class SnackBar { Snackbar snackBar = Snackbar.make(view, message, Snackbar.LENGTH_LONG); View sbView = snackBar.getView(); TextView textView = sbView.findViewById(R.id.snackbar_text); - snackBar.setBackgroundTint(context.getColor(R.color.material_dynamic_neutral10)); + snackBar.setBackgroundTint(context.getColor(R.color.cardBackground)); textView.setTextColor(context.getColor(R.color.colorWhite)); snackBar.show(); } @@ -24,7 +24,7 @@ public class SnackBar { Snackbar snackBar = Snackbar.make(view, message, Snackbar.LENGTH_LONG); View sbView = snackBar.getView(); TextView textView = sbView.findViewById(R.id.snackbar_text); - snackBar.setBackgroundTint(context.getColor(R.color.material_dynamic_neutral10)); + snackBar.setBackgroundTint(context.getColor(R.color.cardBackground)); textView.setTextColor(context.getColor(R.color.colorWhite)); snackBar.show(); } @@ -33,7 +33,7 @@ public class SnackBar { Snackbar snackBar = Snackbar.make(view, message, Snackbar.LENGTH_LONG); View sbView = snackBar.getView(); TextView textView = sbView.findViewById(R.id.snackbar_text); - snackBar.setBackgroundTint(context.getColor(R.color.material_dynamic_neutral10)); + snackBar.setBackgroundTint(context.getColor(R.color.cardBackground)); textView.setTextColor(context.getColor(R.color.warningColor)); snackBar.show(); } @@ -42,7 +42,7 @@ public class SnackBar { Snackbar snackBar = Snackbar.make(view, message, Snackbar.LENGTH_LONG); View sbView = snackBar.getView(); TextView textView = sbView.findViewById(R.id.snackbar_text); - snackBar.setBackgroundTint(context.getColor(R.color.material_dynamic_neutral10)); + snackBar.setBackgroundTint(context.getColor(R.color.cardBackground)); textView.setTextColor(context.getColor(R.color.darkRed)); snackBar.show(); } diff --git a/app/src/main/res/layout/activity_deeplinks.xml b/app/src/main/res/layout/activity_deeplinks.xml index 284218a6..056287b9 100644 --- a/app/src/main/res/layout/activity_deeplinks.xml +++ b/app/src/main/res/layout/activity_deeplinks.xml @@ -12,7 +12,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:indeterminate="true" - app:indicatorColor="?attr/progressIndicatorColor"/> + app:indicatorColor="?attr/progressIndicatorColor" /> + android:textSize="@dimen/dimen16sp" /> + android:textStyle="bold" /> + android:textSize="@dimen/dimen16sp" + android:textStyle="bold" /> + android:textStyle="bold" /> @@ -91,17 +92,27 @@ android:layout_height="wrap_content" android:text="@string/noActionText" android:textColor="?attr/primaryTextColor" - android:textSize="@dimen/dimen16sp"/> + android:textSize="@dimen/dimen16sp" /> + + + android:textStyle="bold" /> + android:textStyle="bold" /> + android:textStyle="bold" /> + android:textStyle="bold" /> + android:textStyle="bold" /> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index bf33ffa2..e7d59dd9 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -742,9 +742,9 @@ Pull Request reopened Pull Request Info - It seems that account for URI %1$s does not exists in the app. You can add one by tapping on the Add New Account button. + It seems that the account for URI %1$s does not exist in the app. You can add one by tapping on the Add New Account button. Go to App - GitNex cannot handle the requested resource, you can open an issue at the project repository as an improvement with providing details of the work. Just launch a default screen for now from the buttons below, it can be changed from settings. + GitNex cannot handle the requested resource. You can open an issue at the project repository as an improvement, providing details of the work. Just launch a default screen for now from the buttons below; it can be changed from settings. Biometric Authentication Unlock using your biometric credentials