Fixes and improvements (#1328)

Closes #1327

Closes #1308

Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1328
Co-authored-by: M M Arif <mmarif@swatian.com>
Co-committed-by: M M Arif <mmarif@swatian.com>
This commit is contained in:
M M Arif 2024-03-06 14:37:09 +00:00 committed by M M Arif
parent 95cab94b1c
commit 2cde78c2a3
5 changed files with 58 additions and 48 deletions

View File

@ -67,14 +67,14 @@ dependencies {
testImplementation 'junit:junit:4.13.2' testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' 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.google.code.gson:gson:2.10.1'
implementation "com.squareup.picasso:picasso:2.71828" implementation "com.squareup.picasso:picasso:2.71828"
implementation 'com.github.ramseth001:TextDrawable:1.1.3' implementation 'com.github.ramseth001:TextDrawable:1.1.3'
implementation 'com.squareup.retrofit2:retrofit:2.9.0' implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0' implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation 'com.squareup.retrofit2:converter-scalars: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 'org.ocpsoft.prettytime:prettytime:5.0.7.Final'
implementation "com.github.skydoves:colorpickerview:2.3.0" implementation "com.github.skydoves:colorpickerview:2.3.0"
implementation "io.noties.markwon:core:4.6.2" implementation "io.noties.markwon:core:4.6.2"
@ -96,9 +96,9 @@ dependencies {
implementation 'commons-io:commons-io:2.5' implementation 'commons-io:commons-io:2.5'
implementation 'org.apache.commons:commons-lang3:3.13.0' implementation 'org.apache.commons:commons-lang3:3.13.0'
implementation "com.github.chrisbanes:PhotoView:2.3.0" implementation "com.github.chrisbanes:PhotoView:2.3.0"
implementation 'ch.acra:acra-mail:5.11.2' implementation 'ch.acra:acra-mail:5.11.3'
implementation 'ch.acra:acra-limiter:5.11.2' implementation 'ch.acra:acra-limiter:5.11.3'
implementation 'ch.acra:acra-notification:5.11.2' implementation 'ch.acra:acra-notification:5.11.3'
implementation 'androidx.room:room-runtime:2.6.1' implementation 'androidx.room:room-runtime:2.6.1'
annotationProcessor 'androidx.room:room-compiler:2.6.1' annotationProcessor 'androidx.room:room-compiler:2.6.1'
implementation "androidx.work:work-runtime:2.9.0" implementation "androidx.work:work-runtime:2.9.0"
@ -113,7 +113,7 @@ dependencies {
implementation('org.codeberg.gitnex:tea4j-autodeploy:4646f53557') { implementation('org.codeberg.gitnex:tea4j-autodeploy:4646f53557') {
exclude module: 'org.apache.oltu.oauth2.common' exclude module: 'org.apache.oltu.oauth2.common'
} }
implementation 'io.github.amrdeveloper:codeview:1.3.8' implementation 'io.github.amrdeveloper:codeview:1.3.9'
constraints { constraints {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.0") implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.0")

View File

@ -8,8 +8,6 @@ import android.os.Looper;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import io.mikael.urlbuilder.UrlBuilder;
import java.net.URI;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects; 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.database.models.UserAccount;
import org.mian.gitnex.databinding.ActivityDeeplinksBinding; import org.mian.gitnex.databinding.ActivityDeeplinksBinding;
import org.mian.gitnex.helpers.AppUtil; 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.IssueContext;
import org.mian.gitnex.helpers.contexts.RepositoryContext; import org.mian.gitnex.helpers.contexts.RepositoryContext;
import retrofit2.Call; import retrofit2.Call;
@ -40,12 +37,12 @@ public class DeepLinksActivity extends BaseActivity {
private ActivityDeeplinksBinding viewBinding; private ActivityDeeplinksBinding viewBinding;
private boolean accountFound = false; private boolean accountFound = false;
private Intent mainIntent; private Intent mainIntent;
private Intent issueIntent; private Intent issueIntent;
private Intent repoIntent; private Intent repoIntent;
private Intent orgIntent; private Intent orgIntent;
private Intent userIntent; private Intent userIntent;
private Uri data;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
@ -62,7 +59,7 @@ public class DeepLinksActivity extends BaseActivity {
userIntent = new Intent(ctx, ProfileActivity.class); userIntent = new Intent(ctx, ProfileActivity.class);
Intent intent = getIntent(); Intent intent = getIntent();
Uri data = intent.getData(); data = intent.getData();
assert data != null; assert data != null;
// check for login // 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 // redirect to proper fragment/activity, if no action is there, show options where user
// to want to go like repos, profile, notifications etc // to want to go like repos, profile, notifications etc
if (data.getPathSegments().size() == 1) { if (data.getPathSegments().size() == 1) {
if (data.getLastPathSegment().equals("notifications")) { // notifications if (Objects.equals(data.getLastPathSegment(), "notifications")) { // notifications
mainIntent.putExtra("launchFragmentByLinkHandler", "notification"); mainIntent.putExtra("launchFragmentByLinkHandler", "notification");
ctx.startActivity(mainIntent); ctx.startActivity(mainIntent);
finish(); finish();
} else if (data.getLastPathSegment().equals("explore")) { // explore } else if (Objects.equals(data.getLastPathSegment(), "explore")) { // explore
mainIntent.putExtra("launchFragmentByLinkHandler", "explore"); mainIntent.putExtra("launchFragmentByLinkHandler", "explore");
ctx.startActivity(mainIntent); ctx.startActivity(mainIntent);
finish(); finish();
} else if (data.getLastPathSegment() } else if (Objects.equals(
.equals(getAccount().getAccount().getUserName())) { // your user profile data.getLastPathSegment(),
getAccount().getAccount().getUserName())) { // your user profile
mainIntent.putExtra("launchFragmentByLinkHandler", "profile"); mainIntent.putExtra("launchFragmentByLinkHandler", "profile");
ctx.startActivity(mainIntent); ctx.startActivity(mainIntent);
finish(); finish();
} else if (data.getLastPathSegment().equals("admin")) { } else if (Objects.equals(data.getLastPathSegment(), "admin")) {
mainIntent.putExtra("launchFragmentByLinkHandler", "admin"); mainIntent.putExtra("launchFragmentByLinkHandler", "admin");
ctx.startActivity(mainIntent); ctx.startActivity(mainIntent);
finish(); finish();
@ -152,9 +150,10 @@ public class DeepLinksActivity extends BaseActivity {
mainIntent.putExtra("giteaAdminAction", data.getLastPathSegment()); mainIntent.putExtra("giteaAdminAction", data.getLastPathSegment());
ctx.startActivity(mainIntent); ctx.startActivity(mainIntent);
finish(); finish();
} else if (!data.getPathSegments().get(0).equals("") } else if (!data.getPathSegments().get(0).isEmpty()
& !data.getLastPathSegment().equals("")) { // go to repo & !Objects.equals(data.getLastPathSegment(), "")) { // go to repo
String repo = data.getLastPathSegment(); String repo = data.getLastPathSegment();
assert repo != null;
if (repo.endsWith(".git")) { // Git clone URL if (repo.endsWith(".git")) { // Git clone URL
repo = repo.substring(0, repo.length() - 4); repo = repo.substring(0, repo.length() - 4);
} }
@ -300,7 +299,7 @@ public class DeepLinksActivity extends BaseActivity {
"commitsList"), "commitsList"),
500); 500);
} else if (data.getPathSegments().get(2).equals("milestones") } 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()) new Handler(Looper.getMainLooper())
.postDelayed( .postDelayed(
() -> () ->
@ -329,7 +328,7 @@ public class DeepLinksActivity extends BaseActivity {
"milestones"), "milestones"),
500); 500);
} else if (data.getPathSegments().get(2).equals("releases") } 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()) new Handler(Looper.getMainLooper())
.postDelayed( .postDelayed(
() -> () ->
@ -371,7 +370,7 @@ public class DeepLinksActivity extends BaseActivity {
data.getPathSegments().get(1), data.getPathSegments().get(1),
"settings"), "settings"),
500); 500);
} else if (data.getLastPathSegment().equals("branches")) { // branches list } else if (Objects.equals(data.getLastPathSegment(), "branches")) { // branches list
new Handler(Looper.getMainLooper()) new Handler(Looper.getMainLooper())
.postDelayed( .postDelayed(
() -> () ->
@ -414,7 +413,8 @@ public class DeepLinksActivity extends BaseActivity {
} else if (data.getPathSegments().get(2).equals("wiki")) { // wiki } else if (data.getPathSegments().get(2).equals("wiki")) { // wiki
if (data.getQueryParameter("action") != null if (data.getQueryParameter("action") != null
&& data.getQueryParameter("action").equalsIgnoreCase("_new")) { && Objects.requireNonNull(data.getQueryParameter("action"))
.equalsIgnoreCase("_new")) {
new Handler(Looper.getMainLooper()) new Handler(Looper.getMainLooper())
.postDelayed( .postDelayed(
() -> () ->
@ -461,14 +461,7 @@ public class DeepLinksActivity extends BaseActivity {
viewBinding.openInBrowser.setOnClickListener( viewBinding.openInBrowser.setOnClickListener(
addNewAccount -> { addNewAccount -> {
Integer port = data.getPort() >= 0 ? data.getPort() : null; AppUtil.openUrlInBrowser(this, String.valueOf(data));
URI host =
UrlBuilder.fromString(UrlHelper.fixScheme(data.getHost(), "https"))
.withPort(port)
.toUri();
AppUtil.openUrlInBrowser(this, String.valueOf(host));
finish(); finish();
}); });
@ -707,6 +700,12 @@ public class DeepLinksActivity extends BaseActivity {
viewBinding.noActionFrame.setVisibility(View.VISIBLE); viewBinding.noActionFrame.setVisibility(View.VISIBLE);
viewBinding.addNewAccountFrame.setVisibility(View.GONE); viewBinding.addNewAccountFrame.setVisibility(View.GONE);
viewBinding.openInBrowserNoActionFrame.setOnClickListener(
noActionFrameOpenInBrowser -> {
AppUtil.openUrlInBrowser(this, String.valueOf(data));
finish();
});
viewBinding.repository.setOnClickListener( viewBinding.repository.setOnClickListener(
repository -> { repository -> {
tinyDB.putInt("defaultScreenId", 1); tinyDB.putInt("defaultScreenId", 1);

View File

@ -15,7 +15,7 @@ public class SnackBar {
Snackbar snackBar = Snackbar.make(view, message, Snackbar.LENGTH_LONG); Snackbar snackBar = Snackbar.make(view, message, Snackbar.LENGTH_LONG);
View sbView = snackBar.getView(); View sbView = snackBar.getView();
TextView textView = sbView.findViewById(R.id.snackbar_text); 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)); textView.setTextColor(context.getColor(R.color.colorWhite));
snackBar.show(); snackBar.show();
} }
@ -24,7 +24,7 @@ public class SnackBar {
Snackbar snackBar = Snackbar.make(view, message, Snackbar.LENGTH_LONG); Snackbar snackBar = Snackbar.make(view, message, Snackbar.LENGTH_LONG);
View sbView = snackBar.getView(); View sbView = snackBar.getView();
TextView textView = sbView.findViewById(R.id.snackbar_text); 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)); textView.setTextColor(context.getColor(R.color.colorWhite));
snackBar.show(); snackBar.show();
} }
@ -33,7 +33,7 @@ public class SnackBar {
Snackbar snackBar = Snackbar.make(view, message, Snackbar.LENGTH_LONG); Snackbar snackBar = Snackbar.make(view, message, Snackbar.LENGTH_LONG);
View sbView = snackBar.getView(); View sbView = snackBar.getView();
TextView textView = sbView.findViewById(R.id.snackbar_text); 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)); textView.setTextColor(context.getColor(R.color.warningColor));
snackBar.show(); snackBar.show();
} }
@ -42,7 +42,7 @@ public class SnackBar {
Snackbar snackBar = Snackbar.make(view, message, Snackbar.LENGTH_LONG); Snackbar snackBar = Snackbar.make(view, message, Snackbar.LENGTH_LONG);
View sbView = snackBar.getView(); View sbView = snackBar.getView();
TextView textView = sbView.findViewById(R.id.snackbar_text); 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)); textView.setTextColor(context.getColor(R.color.darkRed));
snackBar.show(); snackBar.show();
} }

View File

@ -12,7 +12,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:indeterminate="true" android:indeterminate="true"
app:indicatorColor="?attr/progressIndicatorColor"/> app:indicatorColor="?attr/progressIndicatorColor" />
<ScrollView <ScrollView
android:layout_width="match_parent" android:layout_width="match_parent"
@ -41,7 +41,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/accountDoesNotExist" android:text="@string/accountDoesNotExist"
android:textColor="?attr/primaryTextColor" android:textColor="?attr/primaryTextColor"
android:textSize="@dimen/dimen16sp"/> android:textSize="@dimen/dimen16sp" />
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
android:id="@+id/addNewAccount" android:id="@+id/addNewAccount"
@ -51,7 +51,7 @@
android:text="@string/addNewAccountText" android:text="@string/addNewAccountText"
android:textColor="?attr/materialCardBackgroundColor" android:textColor="?attr/materialCardBackgroundColor"
android:textSize="@dimen/dimen16sp" android:textSize="@dimen/dimen16sp"
android:textStyle="bold"/> android:textStyle="bold" />
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
android:id="@+id/openInBrowser" android:id="@+id/openInBrowser"
@ -60,7 +60,8 @@
android:layout_marginTop="@dimen/dimen8dp" android:layout_marginTop="@dimen/dimen8dp"
android:text="@string/openWebRepo" android:text="@string/openWebRepo"
android:textColor="?attr/materialCardBackgroundColor" android:textColor="?attr/materialCardBackgroundColor"
android:textSize="@dimen/dimen16sp"/> android:textSize="@dimen/dimen16sp"
android:textStyle="bold" />
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
android:id="@+id/launchApp" android:id="@+id/launchApp"
@ -70,7 +71,7 @@
android:text="@string/launchApp" android:text="@string/launchApp"
android:textColor="?attr/materialCardBackgroundColor" android:textColor="?attr/materialCardBackgroundColor"
android:textSize="@dimen/dimen16sp" android:textSize="@dimen/dimen16sp"
android:textStyle="bold"/> android:textStyle="bold" />
</LinearLayout> </LinearLayout>
@ -91,17 +92,27 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/noActionText" android:text="@string/noActionText"
android:textColor="?attr/primaryTextColor" android:textColor="?attr/primaryTextColor"
android:textSize="@dimen/dimen16sp"/> android:textSize="@dimen/dimen16sp" />
<com.google.android.material.button.MaterialButton
android:id="@+id/openInBrowserNoActionFrame"
android:layout_width="match_parent"
android:layout_height="@dimen/dimen54dp"
android:layout_marginTop="@dimen/dimen24dp"
android:text="@string/openWebRepo"
android:textColor="?attr/materialCardBackgroundColor"
android:textSize="@dimen/dimen16sp"
android:textStyle="bold" />
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
android:id="@+id/repository" android:id="@+id/repository"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/dimen54dp" android:layout_height="@dimen/dimen54dp"
android:layout_marginTop="@dimen/dimen24dp" android:layout_marginTop="@dimen/dimen8dp"
android:text="@string/navRepos" android:text="@string/navRepos"
android:textColor="?attr/materialCardBackgroundColor" android:textColor="?attr/materialCardBackgroundColor"
android:textSize="@dimen/dimen16sp" android:textSize="@dimen/dimen16sp"
android:textStyle="bold"/> android:textStyle="bold" />
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
android:id="@+id/organization" android:id="@+id/organization"
@ -111,7 +122,7 @@
android:text="@string/navOrg" android:text="@string/navOrg"
android:textColor="?attr/materialCardBackgroundColor" android:textColor="?attr/materialCardBackgroundColor"
android:textSize="@dimen/dimen16sp" android:textSize="@dimen/dimen16sp"
android:textStyle="bold"/> android:textStyle="bold" />
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
android:id="@+id/notification" android:id="@+id/notification"
@ -121,7 +132,7 @@
android:text="@string/pageTitleNotifications" android:text="@string/pageTitleNotifications"
android:textColor="?attr/materialCardBackgroundColor" android:textColor="?attr/materialCardBackgroundColor"
android:textSize="@dimen/dimen16sp" android:textSize="@dimen/dimen16sp"
android:textStyle="bold"/> android:textStyle="bold" />
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
android:id="@+id/explore" android:id="@+id/explore"
@ -131,7 +142,7 @@
android:text="@string/pageTitleExplore" android:text="@string/pageTitleExplore"
android:textColor="?attr/materialCardBackgroundColor" android:textColor="?attr/materialCardBackgroundColor"
android:textSize="@dimen/dimen16sp" android:textSize="@dimen/dimen16sp"
android:textStyle="bold"/> android:textStyle="bold" />
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
android:id="@+id/launchApp2" android:id="@+id/launchApp2"
@ -141,7 +152,7 @@
android:text="@string/launchApp" android:text="@string/launchApp"
android:textColor="?attr/materialCardBackgroundColor" android:textColor="?attr/materialCardBackgroundColor"
android:textSize="@dimen/dimen16sp" android:textSize="@dimen/dimen16sp"
android:textStyle="bold"/> android:textStyle="bold" />
</LinearLayout> </LinearLayout>

View File

@ -742,9 +742,9 @@
<string name="prReopened">Pull Request reopened</string> <string name="prReopened">Pull Request reopened</string>
<string name="prMergeInfo">Pull Request Info</string> <string name="prMergeInfo">Pull Request Info</string>
<string name="accountDoesNotExist">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.</string> <string name="accountDoesNotExist">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.</string>
<string name="launchApp">Go to App</string> <string name="launchApp">Go to App</string>
<string name="noActionText">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.</string> <string name="noActionText">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.</string>
<string name="biometricAuthTitle">Biometric Authentication</string> <string name="biometricAuthTitle">Biometric Authentication</string>
<string name="biometricAuthSubTitle">Unlock using your biometric credentials</string> <string name="biometricAuthSubTitle">Unlock using your biometric credentials</string>