Minor fixes and changes for Andoridacy support.

pull/27/head
Fox2Code 4 years ago
parent f49234d293
commit e565a7018f

@ -55,6 +55,7 @@ dependencies {
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
implementation 'androidx.webkit:webkit:1.4.0'
implementation 'com.google.android.material:material:1.5.0'
implementation "com.mikepenz:aboutlibraries:${latestAboutLibsRelease}"

@ -55,7 +55,8 @@ public enum ActionButtonType {
if (updateZipUrl == null) return;
if (updateZipUrl.startsWith("https://www.androidacy.com/")) {
IntentHelper.openUrlAndroidacy(
button.getContext(), updateZipUrl, true);
button.getContext(), updateZipUrl, true,
moduleInfo.name, moduleInfo.config);
return;
}
String updateZipChecksum = moduleHolder.getUpdateZipChecksum();

@ -11,9 +11,12 @@ import android.webkit.WebChromeClient;
import android.webkit.WebResourceRequest;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.webkit.WebSettingsCompat;
import androidx.webkit.WebViewClientCompat;
import androidx.webkit.WebViewFeature;
import com.fox2code.mmm.BuildConfig;
import com.fox2code.mmm.Constants;
@ -33,7 +36,8 @@ public class AndroidacyActivity extends CompatActivity {
}
}
private WebView webView;
WebView webView;
boolean backOnResume;
@Override
@SuppressLint({"SetJavaScriptEnabled", "JavascriptInterface"})
@ -52,7 +56,7 @@ public class AndroidacyActivity extends CompatActivity {
String title = intent.getStringExtra(Constants.EXTRA_ANDROIDACY_ACTIONBAR_TITLE);
String config = intent.getStringExtra(Constants.EXTRA_ANDROIDACY_ACTIONBAR_CONFIG);
this.setContentView(R.layout.webview);
if (title == null || title.isEmpty()) {
if (allowInstall || title == null || title.isEmpty()) {
this.hideActionBar();
} else { // Only used for note section
this.setTitle(title);
@ -77,10 +81,14 @@ public class AndroidacyActivity extends CompatActivity {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { // Make website follow app theme
webSettings.setForceDark(MainApplication.getINSTANCE().isLightTheme() ?
WebSettings.FORCE_DARK_OFF : WebSettings.FORCE_DARK_ON);
} else if (WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK)) {
WebSettingsCompat.setForceDark(webSettings, MainApplication.getINSTANCE().isLightTheme() ?
WebSettingsCompat.FORCE_DARK_OFF : WebSettingsCompat.FORCE_DARK_ON);
}
this.webView.setWebViewClient(new WebViewClient() {
this.webView.setWebViewClient(new WebViewClientCompat() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
public boolean shouldOverrideUrlLoading(
@NonNull WebView view, @NonNull WebResourceRequest request) {
// Don't open non andoridacy urls inside WebView
if (request.isForMainFrame() && !(request.getUrl().getScheme().equals("intent") ||
request.getUrl().getHost().endsWith(".androidacy.com"))) {
@ -115,4 +123,13 @@ public class AndroidacyActivity extends CompatActivity {
super.onBackPressed();
}
}
@Override
protected void onResume() {
super.onResume();
if (this.backOnResume) {
this.backOnResume = false;
this.forceBackPressed();
}
}
}

@ -137,6 +137,7 @@ public class AndroidacyRepoData extends RepoData {
moduleInfo.version = jsonObject.optString(
"version", "v" + moduleInfo.versionCode);
moduleInfo.author = jsonObject.optString("author", "Unknown");
moduleInfo.description = jsonObject.optString("description", "");
moduleInfo.minApi = jsonObject.getInt("minApi");
moduleInfo.maxApi = jsonObject.getInt("maxApi");
String minMagisk = jsonObject.getString("minMagisk");

@ -81,6 +81,7 @@ public class AndroidacyWebAPI {
moduleUrl + " " + installTitle + " " + checksum);
Uri uri = Uri.parse(moduleUrl);
if (uri.getScheme().equals("https") && uri.getHost().endsWith(".androidacy.com")) {
this.activity.backOnResume = true;
IntentHelper.openInstaller(this.activity,
moduleUrl, installTitle, null, checksum);
} else {

Loading…
Cancel
Save