Fix bug. improve things
This commit is contained in:
parent
21a877d6b1
commit
989299cf31
@ -9,8 +9,8 @@ android {
|
|||||||
applicationId "nl.privacydragon.bookwyrm"
|
applicationId "nl.privacydragon.bookwyrm"
|
||||||
minSdk 23
|
minSdk 23
|
||||||
targetSdk 31
|
targetSdk 31
|
||||||
versionCode 3
|
versionCode 4
|
||||||
versionName "1.2.0"
|
versionName "1.2.1"
|
||||||
|
|
||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
@ -11,8 +11,8 @@
|
|||||||
"type": "SINGLE",
|
"type": "SINGLE",
|
||||||
"filters": [],
|
"filters": [],
|
||||||
"attributes": [],
|
"attributes": [],
|
||||||
"versionCode": 3,
|
"versionCode": 4,
|
||||||
"versionName": "1.2.0",
|
"versionName": "1.2.1",
|
||||||
"outputFile": "app-release.apk"
|
"outputFile": "app-release.apk"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -60,10 +60,15 @@ public class HandlerActivity extends AppCompatActivity {
|
|||||||
String pathMaybe = appLinkData.getPath();
|
String pathMaybe = appLinkData.getPath();
|
||||||
String toGoServer = "bla";
|
String toGoServer = "bla";
|
||||||
if (pathMaybe.contains("user")) {
|
if (pathMaybe.contains("user")) {
|
||||||
//If the path contains 'user', it is a user profile.
|
//If the path contains 'user', it is a user profile, unless it is followed by something like 'review'.
|
||||||
String notAtUser = pathMaybe.substring(pathMaybe.indexOf("user") + 5); //This line gets the username.
|
if (pathMaybe.contains("review") || pathMaybe.contains("generatednote") || pathMaybe.contains("quotation") || pathMaybe.contains("comment") ) {
|
||||||
String atUser = notAtUser + "@" + appLinkData.getHost(); //This appends @[HOST] to the string, so we have the full username thing needed.
|
toGoServer = "https://" + appLinkData.getHost() + pathMaybe;
|
||||||
toGoServer = "https://" + server + "/user/" + atUser;
|
}
|
||||||
|
else {
|
||||||
|
String notAtUser = pathMaybe.substring(pathMaybe.indexOf("user") + 5); //This line gets the username.
|
||||||
|
String atUser = notAtUser + "@" + appLinkData.getHost(); //This appends @[HOST] to the string, so we have the full username thing needed.
|
||||||
|
toGoServer = "https://" + server + "/user/" + atUser;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
startActivity(new Intent(HandlerActivity.this, nl.privacydragon.bookwyrm.StartActivity.class));
|
startActivity(new Intent(HandlerActivity.this, nl.privacydragon.bookwyrm.StartActivity.class));
|
||||||
}
|
}
|
||||||
@ -132,7 +137,12 @@ public class HandlerActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
view.loadUrl("javascript:(function() { document.getElementById('id_password').value = '" + passw + "'; ;})()");
|
view.loadUrl("javascript:(function() { document.getElementById('id_password').value = '" + passw + "'; ;})()");
|
||||||
view.loadUrl("javascript:(function() { document.getElementById('id_localname').value = '" + name + "'; ;})()");
|
view.loadUrl("javascript:(function() { document.getElementById('id_localname').value = '" + name + "'; ;})()");
|
||||||
view.loadUrl("javascript:(function() { if (window.location.href == '" + finalToGoServer + "') { document.getElementsByName(\"login\")[0].submit();} ;})()");
|
view.loadUrl("javascript:(function() { if (window.location.href == '" + finalToGoServer + "' && !/(review|generatednote|quotation|comment)/i.test(window.location.href)) { document.getElementsByName(\"login\")[0].submit();} ;})()");
|
||||||
|
view.loadUrl("javascript:(function() { if (window.location.href == 'https://" + server + "') { document.getElementsByName(\"login\")[0].submit();} ;})()");
|
||||||
|
view.loadUrl("javascript:(function() { if (/(review|generatednote|quotation|comment)/i.test(window.location.href)) { document.getElementsByClassName(\"block\")[0].innerHTML = ` <a href=\"https://"+ server +"\" class=\"button\" data-back=\"\">\n" +
|
||||||
|
" <span class=\"icon icon-arrow-left\" aria-hidden=\"true\"></span>\n" +
|
||||||
|
" <span><b>Back to homeserver</b></span>\n" +
|
||||||
|
" </a>`;} ;})()");
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -144,12 +154,20 @@ public class HandlerActivity extends AppCompatActivity {
|
|||||||
private class MyWebViewClient extends WebViewClient {
|
private class MyWebViewClient extends WebViewClient {
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
|
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
|
||||||
|
// ATTENTION: This was auto-generated to handle app links.
|
||||||
|
Intent appLinkIntent = getIntent();
|
||||||
|
String appLinkAction = appLinkIntent.getAction();
|
||||||
|
Uri appLinkData = appLinkIntent.getData();
|
||||||
|
// End of auto-generated stuff
|
||||||
|
String strangeHost = appLinkData.getHost();
|
||||||
SharedPreferences sharedPref = HandlerActivity.this.getSharedPreferences(getString(R.string.server), Context.MODE_PRIVATE);
|
SharedPreferences sharedPref = HandlerActivity.this.getSharedPreferences(getString(R.string.server), Context.MODE_PRIVATE);
|
||||||
String defaultValue = "none";
|
String defaultValue = "none";
|
||||||
String server = sharedPref.getString(getString(R.string.server), defaultValue);
|
String server = sharedPref.getString(getString(R.string.server), defaultValue);
|
||||||
if (server.equals(request.getUrl().getHost())) {
|
if (server.equals(request.getUrl().getHost())) {
|
||||||
//If the server is the same as the bookwyrm, load it in the webview.
|
//If the server is the same as the bookwyrm, load it in the webview.
|
||||||
return false;
|
return false;
|
||||||
|
} else if (strangeHost.equals(request.getUrl().getHost())) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
// Otherwise, it should go to the default browser instead.
|
// Otherwise, it should go to the default browser instead.
|
||||||
Intent intent = new Intent(Intent.ACTION_VIEW, request.getUrl());
|
Intent intent = new Intent(Intent.ACTION_VIEW, request.getUrl());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user