diff --git a/app/build.gradle b/app/build.gradle index 0b85f0d..dbbfc57 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -9,8 +9,8 @@ android { applicationId "nl.privacydragon.bookwyrm" minSdk 23 targetSdk 31 - versionCode 3 - versionName "1.2.0" + versionCode 4 + versionName "1.2.1" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } diff --git a/app/release/Bookwyrm-v1.2.0.apk b/app/release/Bookwyrm-v1.2.1.apk similarity index 54% rename from app/release/Bookwyrm-v1.2.0.apk rename to app/release/Bookwyrm-v1.2.1.apk index 926392f..1001be7 100644 Binary files a/app/release/Bookwyrm-v1.2.0.apk and b/app/release/Bookwyrm-v1.2.1.apk differ diff --git a/app/release/output-metadata.json b/app/release/output-metadata.json index d59bd1c..9474d5f 100644 --- a/app/release/output-metadata.json +++ b/app/release/output-metadata.json @@ -11,8 +11,8 @@ "type": "SINGLE", "filters": [], "attributes": [], - "versionCode": 3, - "versionName": "1.2.0", + "versionCode": 4, + "versionName": "1.2.1", "outputFile": "app-release.apk" } ], diff --git a/app/src/main/java/nl/privacydragon/bookwyrm/HandlerActivity.java b/app/src/main/java/nl/privacydragon/bookwyrm/HandlerActivity.java index 3e4a8b9..b2eacf3 100644 --- a/app/src/main/java/nl/privacydragon/bookwyrm/HandlerActivity.java +++ b/app/src/main/java/nl/privacydragon/bookwyrm/HandlerActivity.java @@ -60,10 +60,15 @@ public class HandlerActivity extends AppCompatActivity { String pathMaybe = appLinkData.getPath(); String toGoServer = "bla"; if (pathMaybe.contains("user")) { - //If the path contains 'user', it is a user profile. - 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; + //If the path contains 'user', it is a user profile, unless it is followed by something like 'review'. + if (pathMaybe.contains("review") || pathMaybe.contains("generatednote") || pathMaybe.contains("quotation") || pathMaybe.contains("comment") ) { + toGoServer = "https://" + appLinkData.getHost() + pathMaybe; + } + 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 { 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_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 = ` \n" + + " \n" + + " Back to homeserver\n" + + " `;} ;})()"); } }); @@ -144,12 +154,20 @@ public class HandlerActivity extends AppCompatActivity { private class MyWebViewClient extends WebViewClient { @Override 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); String defaultValue = "none"; String server = sharedPref.getString(getString(R.string.server), defaultValue); if (server.equals(request.getUrl().getHost())) { //If the server is the same as the bookwyrm, load it in the webview. return false; + } else if (strangeHost.equals(request.getUrl().getHost())) { + return false; } // Otherwise, it should go to the default browser instead. Intent intent = new Intent(Intent.ACTION_VIEW, request.getUrl());