Improve Andoridacy WebView, progress on internal APIs.
parent
7839218bbb
commit
00ae269ae2
@ -0,0 +1,72 @@
|
||||
package com.fox2code.mmm.androidacy;
|
||||
|
||||
import android.net.Uri;
|
||||
import android.webkit.JavascriptInterface;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.fox2code.mmm.MainApplication;
|
||||
import com.fox2code.mmm.installer.InstallerInitializer;
|
||||
import com.fox2code.mmm.manager.ModuleManager;
|
||||
import com.fox2code.mmm.utils.IntentHelper;
|
||||
|
||||
public class AndroidacyWebAPI {
|
||||
private final AndroidacyActivity activity;
|
||||
|
||||
public AndroidacyWebAPI(AndroidacyActivity activity) {
|
||||
this.activity = activity;
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void forceQuit(String error) {
|
||||
Toast.makeText(this.activity, error, Toast.LENGTH_LONG).show();
|
||||
this.activity.forceBackPressed();
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void cancel() {
|
||||
this.activity.forceBackPressed();
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void openUrl(String url) {
|
||||
if (Uri.parse(url).getScheme().equals("https")) {
|
||||
IntentHelper.openUrl(this.activity, url);
|
||||
}
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public boolean isLightTheme() {
|
||||
return MainApplication.getINSTANCE().isLightTheme();
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public boolean hasRoot() {
|
||||
return InstallerInitializer.peekMagiskPath() != null;
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public boolean canInstall() {
|
||||
return InstallerInitializer.peekMagiskPath() != null &&
|
||||
!MainApplication.isShowcaseMode();
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void install(String moduleUrl, String installTitle) {
|
||||
if (MainApplication.isShowcaseMode() ||
|
||||
InstallerInitializer.peekMagiskPath() != null) {
|
||||
// With lockdown mode enabled or lack of root, install should not have any effect
|
||||
return;
|
||||
}
|
||||
Uri uri = Uri.parse(moduleUrl);
|
||||
if (uri.getScheme().equals("https") && uri.getHost().endsWith(".androidacy.com")) {
|
||||
IntentHelper.openInstaller(this.activity, moduleUrl, installTitle, null);
|
||||
} else {
|
||||
this.activity.forceBackPressed();
|
||||
}
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public boolean isModuleInstalled(String moduleId) {
|
||||
return ModuleManager.getINSTANCE().getModules().get(moduleId) != null;
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M20,8h-2.81c-0.45,-0.78 -1.07,-1.45 -1.82,-1.96L17,4.41 15.59,3l-2.17,2.17C12.96,5.06 12.49,5 12,5c-0.49,0 -0.96,0.06 -1.41,0.17L8.41,3 7,4.41l1.62,1.63C7.88,6.55 7.26,7.22 6.81,8L4,8v2h2.09c-0.05,0.33 -0.09,0.66 -0.09,1v1L4,12v2h2v1c0,0.34 0.04,0.67 0.09,1L4,16v2h2.81c1.04,1.79 2.97,3 5.19,3s4.15,-1.21 5.19,-3L20,18v-2h-2.09c0.05,-0.33 0.09,-0.66 0.09,-1v-1h2v-2h-2v-1c0,-0.34 -0.04,-0.67 -0.09,-1L20,10L20,8zM14,16h-4v-2h4v2zM14,12h-4v-2h4v2z"/>
|
||||
</vector>
|
Loading…
Reference in New Issue