From 65c0ecaad1dbc5c6a697db9205e76f013478209d Mon Sep 17 00:00:00 2001 From: M M Arif Date: Thu, 29 Oct 2020 00:21:47 +0100 Subject: [PATCH] Fix deep links (#743) Fix opening links Co-authored-by: M M Arif Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/743 Reviewed-by: 6543 <6543@noreply.codeberg.org> --- .../gitnex/activities/DeepLinksActivity.java | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) 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 2e7264cd..0289c4be 100644 --- a/app/src/main/java/org/mian/gitnex/activities/DeepLinksActivity.java +++ b/app/src/main/java/org/mian/gitnex/activities/DeepLinksActivity.java @@ -43,6 +43,7 @@ public class DeepLinksActivity extends BaseActivity { private TinyDB tinyDb; private String currentInstance; private String instanceToken; + private boolean noAccountFound = false; private Intent mainIntent; private Intent issueIntent; @@ -94,15 +95,22 @@ public class DeepLinksActivity extends BaseActivity { currentInstance = userAccounts.get(i).getInstanceUrl(); instanceToken = userAccounts.get(i).getToken(); - if(!hostUri.contains(Objects.requireNonNull(data.getHost()))) { + if(hostUri.toLowerCase().contains(Objects.requireNonNull(data.getHost().toLowerCase()))) { - // check for valid instance - checkInstance(data); - return; + noAccountFound = false; + break; } + + noAccountFound = true; } } + if(noAccountFound) { + + checkInstance(data); + return; + } + // 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() > 0) { @@ -113,7 +121,6 @@ public class DeepLinksActivity extends BaseActivity { if(!Objects.requireNonNull(data.getLastPathSegment()).contains("issues") & StringUtils.isNumeric(data.getLastPathSegment())) { - issueIntent.putExtra("issueNumber", data.getLastPathSegment()); tinyDb.putString("issueNumber", data.getLastPathSegment()); @@ -325,6 +332,11 @@ public class DeepLinksActivity extends BaseActivity { finish(); }); } + else { + + Toasty.error(ctx, getResources().getString(R.string.versionUnknown)); + finish(); + } } @Override