Skip to content
This repository was archived by the owner on May 4, 2023. It is now read-only.

Commit 1ecf075

Browse files
committed
Add referrer to initial Androidacy WebView link.
1 parent a929cd1 commit 1ecf075

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

app/src/main/java/com/fox2code/mmm/androidacy/AndroidacyActivity.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
* Per Androidacy repo implementation agreement, no request of this WebView shall be modified.
3131
*/
3232
public class AndroidacyActivity extends CompatActivity {
33+
private static final String REFERRER = "utm_source=FoxMMM&utm_medium=app";
34+
3335
static {
3436
if (BuildConfig.DEBUG) {
3537
WebView.setWebContentsDebuggingEnabled(true);
@@ -51,6 +53,22 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
5153
this.forceBackPressed();
5254
return;
5355
}
56+
String url = uri.toString();
57+
int i;
58+
if (!url.startsWith("https://") || // Checking twice
59+
(i = url.indexOf("/", 8)) == -1 ||
60+
!url.substring(8, i).endsWith(".androidacy.com")) {
61+
this.forceBackPressed();
62+
return;
63+
}
64+
if (!url.endsWith(REFERRER) && (url.startsWith("https://www.androidacy.com/") ||
65+
url.startsWith("https://api.androidacy.com/magisk/readme/"))) {
66+
if (url.lastIndexOf('/') < url.lastIndexOf('?')) {
67+
url = url + '&' + REFERRER;
68+
} else {
69+
url = url + '?' + REFERRER;
70+
}
71+
}
5472
boolean allowInstall = intent.getBooleanExtra(
5573
Constants.EXTRA_ANDROIDACY_ALLOW_INSTALL, false);
5674
String title = intent.getStringExtra(Constants.EXTRA_ANDROIDACY_ACTIONBAR_TITLE);
@@ -111,7 +129,7 @@ public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathC
111129
});
112130
this.webView.addJavascriptInterface(
113131
new AndroidacyWebAPI(this, allowInstall), "mmm");
114-
this.webView.loadUrl(uri.toString());
132+
this.webView.loadUrl(url);
115133
}
116134

117135
@Override

0 commit comments

Comments
 (0)