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

Commit e565a70

Browse files
committed
Minor fixes and changes for Andoridacy support.
1 parent f49234d commit e565a70

File tree

5 files changed

+27
-6
lines changed

5 files changed

+27
-6
lines changed

app/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ dependencies {
5555
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
5656
implementation 'androidx.recyclerview:recyclerview:1.2.1'
5757
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
58+
implementation 'androidx.webkit:webkit:1.4.0'
5859
implementation 'com.google.android.material:material:1.5.0'
5960
implementation "com.mikepenz:aboutlibraries:${latestAboutLibsRelease}"
6061

app/src/main/java/com/fox2code/mmm/ActionButtonType.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ public void doAction(ImageButton button, ModuleHolder moduleHolder) {
5555
if (updateZipUrl == null) return;
5656
if (updateZipUrl.startsWith("https://www.androidacy.com/")) {
5757
IntentHelper.openUrlAndroidacy(
58-
button.getContext(), updateZipUrl, true);
58+
button.getContext(), updateZipUrl, true,
59+
moduleInfo.name, moduleInfo.config);
5960
return;
6061
}
6162
String updateZipChecksum = moduleHolder.getUpdateZipChecksum();

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

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@
1111
import android.webkit.WebResourceRequest;
1212
import android.webkit.WebSettings;
1313
import android.webkit.WebView;
14-
import android.webkit.WebViewClient;
1514

15+
import androidx.annotation.NonNull;
1616
import androidx.annotation.Nullable;
17+
import androidx.webkit.WebSettingsCompat;
18+
import androidx.webkit.WebViewClientCompat;
19+
import androidx.webkit.WebViewFeature;
1720

1821
import com.fox2code.mmm.BuildConfig;
1922
import com.fox2code.mmm.Constants;
@@ -33,7 +36,8 @@ public class AndroidacyActivity extends CompatActivity {
3336
}
3437
}
3538

36-
private WebView webView;
39+
WebView webView;
40+
boolean backOnResume;
3741

3842
@Override
3943
@SuppressLint({"SetJavaScriptEnabled", "JavascriptInterface"})
@@ -52,7 +56,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
5256
String title = intent.getStringExtra(Constants.EXTRA_ANDROIDACY_ACTIONBAR_TITLE);
5357
String config = intent.getStringExtra(Constants.EXTRA_ANDROIDACY_ACTIONBAR_CONFIG);
5458
this.setContentView(R.layout.webview);
55-
if (title == null || title.isEmpty()) {
59+
if (allowInstall || title == null || title.isEmpty()) {
5660
this.hideActionBar();
5761
} else { // Only used for note section
5862
this.setTitle(title);
@@ -77,10 +81,14 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
7781
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { // Make website follow app theme
7882
webSettings.setForceDark(MainApplication.getINSTANCE().isLightTheme() ?
7983
WebSettings.FORCE_DARK_OFF : WebSettings.FORCE_DARK_ON);
84+
} else if (WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK)) {
85+
WebSettingsCompat.setForceDark(webSettings, MainApplication.getINSTANCE().isLightTheme() ?
86+
WebSettingsCompat.FORCE_DARK_OFF : WebSettingsCompat.FORCE_DARK_ON);
8087
}
81-
this.webView.setWebViewClient(new WebViewClient() {
88+
this.webView.setWebViewClient(new WebViewClientCompat() {
8289
@Override
83-
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
90+
public boolean shouldOverrideUrlLoading(
91+
@NonNull WebView view, @NonNull WebResourceRequest request) {
8492
// Don't open non andoridacy urls inside WebView
8593
if (request.isForMainFrame() && !(request.getUrl().getScheme().equals("intent") ||
8694
request.getUrl().getHost().endsWith(".androidacy.com"))) {
@@ -115,4 +123,13 @@ public void onBackPressed() {
115123
super.onBackPressed();
116124
}
117125
}
126+
127+
@Override
128+
protected void onResume() {
129+
super.onResume();
130+
if (this.backOnResume) {
131+
this.backOnResume = false;
132+
this.forceBackPressed();
133+
}
134+
}
118135
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ protected List<RepoModule> populate(JSONObject jsonObject) throws JSONException
137137
moduleInfo.version = jsonObject.optString(
138138
"version", "v" + moduleInfo.versionCode);
139139
moduleInfo.author = jsonObject.optString("author", "Unknown");
140+
moduleInfo.description = jsonObject.optString("description", "");
140141
moduleInfo.minApi = jsonObject.getInt("minApi");
141142
moduleInfo.maxApi = jsonObject.getInt("maxApi");
142143
String minMagisk = jsonObject.getString("minMagisk");

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ public void install(String moduleUrl, String installTitle,String checksum) {
8181
moduleUrl + " " + installTitle + " " + checksum);
8282
Uri uri = Uri.parse(moduleUrl);
8383
if (uri.getScheme().equals("https") && uri.getHost().endsWith(".androidacy.com")) {
84+
this.activity.backOnResume = true;
8485
IntentHelper.openInstaller(this.activity,
8586
moduleUrl, installTitle, null, checksum);
8687
} else {

0 commit comments

Comments
 (0)