Fix deep links (#743)

Fix opening links

Co-authored-by: M M Arif <mmarif@swatian.com>
Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/743
Reviewed-by: 6543 <6543@noreply.codeberg.org>
This commit is contained in:
M M Arif 2020-10-29 00:21:47 +01:00 committed by 6543
parent 99925621f1
commit 65c0ecaad1

View File

@ -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