mirror of
https://github.com/TonyJiangWJ/Auto.js.git
synced 2026-06-21 21:01:43 +08:00
refactor: use GlobalAppContext to replace App.getApp()
add: Canvas
This commit is contained in:
parent
d098c77827
commit
a009eb02b0
@ -8,8 +8,8 @@ android {
|
||||
applicationId "com.stardust.scriptdroid"
|
||||
minSdkVersion 17
|
||||
targetSdkVersion 23
|
||||
versionCode 257
|
||||
versionName "3.1.1 Alpha"
|
||||
versionCode 258
|
||||
versionName "3.1.1 Alpha2"
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
multiDexEnabled true
|
||||
ndk {
|
||||
|
||||
@ -17,7 +17,7 @@ ui.layout(
|
||||
</vertical>
|
||||
);
|
||||
|
||||
id.cb1.on("check", (checked)=>{
|
||||
ui.cb1.on("check", (checked)=>{
|
||||
if(checked){
|
||||
toast("第一个框被勾选了");
|
||||
}else{
|
||||
|
||||
@ -15,6 +15,7 @@ import com.raizlabs.android.dbflow.config.FlowConfig;
|
||||
import com.raizlabs.android.dbflow.config.FlowManager;
|
||||
import com.raizlabs.android.dbflow.runtime.DirectModelNotifier;
|
||||
import com.squareup.leakcanary.LeakCanary;
|
||||
import com.stardust.app.GlobalAppContext;
|
||||
import com.stardust.autojs.core.ui.inflater.ImageLoader;
|
||||
import com.stardust.autojs.core.ui.inflater.util.Drawables;
|
||||
import com.stardust.scriptdroid.autojs.AutoJs;
|
||||
@ -40,7 +41,6 @@ public class App extends MultiDexApplication {
|
||||
private static final String TAG = "App";
|
||||
|
||||
private static WeakReference<App> instance;
|
||||
private UiHandler mUiHandler;
|
||||
|
||||
public static App getApp() {
|
||||
return instance.get();
|
||||
@ -48,8 +48,8 @@ public class App extends MultiDexApplication {
|
||||
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
GlobalAppContext.set(this);
|
||||
instance = new WeakReference<>(this);
|
||||
mUiHandler = new UiHandler(this);
|
||||
setUpStaticsTool();
|
||||
setUpDebugEnvironment();
|
||||
init();
|
||||
@ -142,7 +142,4 @@ public class App extends MultiDexApplication {
|
||||
}
|
||||
|
||||
|
||||
public UiHandler getUiHandler() {
|
||||
return mUiHandler;
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
import com.stardust.app.GlobalAppContext;
|
||||
import com.stardust.autojs.runtime.accessibility.AccessibilityConfig;
|
||||
import com.stardust.scriptdroid.autojs.key.GlobalKeyObserver;
|
||||
|
||||
@ -14,7 +15,7 @@ import java.util.concurrent.TimeUnit;
|
||||
*/
|
||||
public class Pref {
|
||||
|
||||
private static final SharedPreferences DISPOSABLE_BOOLEAN = App.getApp().getSharedPreferences("DISPOSABLE_BOOLEAN", Context.MODE_PRIVATE);
|
||||
private static final SharedPreferences DISPOSABLE_BOOLEAN = GlobalAppContext.get().getSharedPreferences("DISPOSABLE_BOOLEAN", Context.MODE_PRIVATE);
|
||||
private static final String KEY_SERVER_ADDRESS = "Still love you...17.5.14";
|
||||
private static final String KEY_SHOULD_SHOW_ANNUNCIATION = "Sing about all the things you forgot, things you are not";
|
||||
private static final String KEY_FIRST_SHOW_AD = "En, Today is 17.7.7, but, I'm still love you so....";
|
||||
@ -40,7 +41,7 @@ public class Pref {
|
||||
}
|
||||
|
||||
private static SharedPreferences def() {
|
||||
return PreferenceManager.getDefaultSharedPreferences(App.getApp());
|
||||
return PreferenceManager.getDefaultSharedPreferences(GlobalAppContext.get());
|
||||
}
|
||||
|
||||
private static boolean getDisposableBoolean(String key, boolean defaultValue) {
|
||||
@ -68,7 +69,7 @@ public class Pref {
|
||||
}
|
||||
|
||||
private static String getString(int id) {
|
||||
return App.getApp().getString(id);
|
||||
return GlobalAppContext.getString(id);
|
||||
}
|
||||
|
||||
public static boolean isFirstUsing() {
|
||||
|
||||
@ -3,6 +3,7 @@ package com.stardust.scriptdroid.autojs;
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
|
||||
import com.stardust.app.GlobalAppContext;
|
||||
import com.stardust.autojs.core.console.GlobalStardustConsole;
|
||||
import com.stardust.autojs.runtime.ScriptRuntime;
|
||||
import com.stardust.autojs.runtime.accessibility.AccessibilityConfig;
|
||||
@ -33,13 +34,13 @@ public class AutoJs extends com.stardust.autojs.AutoJs {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static void initInstance(Context context) {
|
||||
instance = new AutoJs(context);
|
||||
public static void initInstance(Application application) {
|
||||
instance = new AutoJs(application);
|
||||
}
|
||||
|
||||
|
||||
private AutoJs(final Context context) {
|
||||
super(context);
|
||||
private AutoJs(final Application application) {
|
||||
super(application);
|
||||
getScriptEngineService().registerGlobalScriptExecutionListener(new ScriptExecutionGlobalListener());
|
||||
}
|
||||
|
||||
@ -60,15 +61,15 @@ public class AutoJs extends com.stardust.autojs.AutoJs {
|
||||
return;
|
||||
}
|
||||
String errorMessage = null;
|
||||
if (AccessibilityServiceTool.isAccessibilityServiceEnabled(App.getApp())) {
|
||||
errorMessage = App.getApp().getString(R.string.text_auto_operate_service_enabled_but_not_running);
|
||||
if (AccessibilityServiceTool.isAccessibilityServiceEnabled(GlobalAppContext.get())) {
|
||||
errorMessage = GlobalAppContext.getString(R.string.text_auto_operate_service_enabled_but_not_running);
|
||||
} else {
|
||||
if (Pref.shouldEnableAccessibilityServiceByRoot()) {
|
||||
if (!AccessibilityServiceTool.enableAccessibilityServiceByRootAndWaitFor(2000)) {
|
||||
errorMessage = App.getApp().getString(R.string.text_enable_accessibility_service_by_root_timeout);
|
||||
errorMessage = GlobalAppContext.getString(R.string.text_enable_accessibility_service_by_root_timeout);
|
||||
}
|
||||
} else {
|
||||
errorMessage = App.getApp().getString(R.string.text_no_accessibility_permission);
|
||||
errorMessage = GlobalAppContext.getString(R.string.text_no_accessibility_permission);
|
||||
}
|
||||
}
|
||||
if (errorMessage != null) {
|
||||
@ -83,15 +84,15 @@ public class AutoJs extends com.stardust.autojs.AutoJs {
|
||||
return;
|
||||
}
|
||||
String errorMessage = null;
|
||||
if (AccessibilityServiceTool.isAccessibilityServiceEnabled(App.getApp())) {
|
||||
errorMessage = App.getApp().getString(R.string.text_auto_operate_service_enabled_but_not_running);
|
||||
if (AccessibilityServiceTool.isAccessibilityServiceEnabled(GlobalAppContext.get())) {
|
||||
errorMessage = GlobalAppContext.getString(R.string.text_auto_operate_service_enabled_but_not_running);
|
||||
} else {
|
||||
if (Pref.shouldEnableAccessibilityServiceByRoot()) {
|
||||
if (!AccessibilityServiceTool.enableAccessibilityServiceByRootAndWaitFor(2000)) {
|
||||
errorMessage = App.getApp().getString(R.string.text_enable_accessibility_service_by_root_timeout);
|
||||
errorMessage = GlobalAppContext.getString(R.string.text_enable_accessibility_service_by_root_timeout);
|
||||
}
|
||||
} else {
|
||||
errorMessage = App.getApp().getString(R.string.text_no_accessibility_permission);
|
||||
errorMessage = GlobalAppContext.getString(R.string.text_no_accessibility_permission);
|
||||
}
|
||||
}
|
||||
if (errorMessage != null) {
|
||||
@ -111,11 +112,6 @@ public class AutoJs extends com.stardust.autojs.AutoJs {
|
||||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Application getApplication() {
|
||||
return App.getApp();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ScriptRuntime createRuntime() {
|
||||
ScriptRuntime runtime = super.createRuntime();
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.stardust.scriptdroid.autojs;
|
||||
|
||||
import com.stardust.app.GlobalAppContext;
|
||||
import com.stardust.autojs.engine.JavaScriptEngine;
|
||||
import com.stardust.autojs.execution.ScriptExecution;
|
||||
import com.stardust.autojs.execution.ScriptExecutionListener;
|
||||
@ -29,7 +30,7 @@ public class ScriptExecutionGlobalListener implements ScriptExecutionListener {
|
||||
return;
|
||||
double seconds = (System.currentTimeMillis() - millis) / 1000.0;
|
||||
AutoJs.getInstance().getScriptEngineService().getGlobalConsole()
|
||||
.verbose(App.getApp().getString(R.string.text_execution_finished), execution.getSource().toString(), seconds);
|
||||
.verbose(GlobalAppContext.getString(R.string.text_execution_finished), execution.getSource().toString(), seconds);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -2,6 +2,7 @@ package com.stardust.scriptdroid.autojs.build;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
|
||||
import com.stardust.app.GlobalAppContext;
|
||||
import com.stardust.autojs.apkbuilder.ApkBuilder;
|
||||
import com.stardust.autojs.apkbuilder.ManifestEditor;
|
||||
import com.stardust.autojs.apkbuilder.util.StreamUtils;
|
||||
@ -98,7 +99,7 @@ public class AutoJsApkBuilder extends ApkBuilder {
|
||||
@Override
|
||||
public AutoJsApkBuilder prepare() throws IOException {
|
||||
if (mProgressCallback != null) {
|
||||
App.getApp().getUiHandler().post(() -> mProgressCallback.onPrepare(AutoJsApkBuilder.this));
|
||||
GlobalAppContext.post(() -> mProgressCallback.onPrepare(AutoJsApkBuilder.this));
|
||||
}
|
||||
return (AutoJsApkBuilder) super.prepare();
|
||||
}
|
||||
@ -179,7 +180,7 @@ public class AutoJsApkBuilder extends ApkBuilder {
|
||||
@Override
|
||||
public AutoJsApkBuilder build() throws IOException {
|
||||
if (mProgressCallback != null) {
|
||||
App.getApp().getUiHandler().post(() -> mProgressCallback.onBuild(AutoJsApkBuilder.this));
|
||||
GlobalAppContext.post(() -> mProgressCallback.onBuild(AutoJsApkBuilder.this));
|
||||
}
|
||||
mManifestEditor.commit();
|
||||
if (mAppConfig.icon != null) {
|
||||
@ -196,7 +197,7 @@ public class AutoJsApkBuilder extends ApkBuilder {
|
||||
@Override
|
||||
public AutoJsApkBuilder sign() throws Exception {
|
||||
if (mProgressCallback != null) {
|
||||
App.getApp().getUiHandler().post(() -> mProgressCallback.onSign(AutoJsApkBuilder.this));
|
||||
GlobalAppContext.post(() -> mProgressCallback.onSign(AutoJsApkBuilder.this));
|
||||
}
|
||||
return (AutoJsApkBuilder) super.sign();
|
||||
}
|
||||
@ -204,7 +205,7 @@ public class AutoJsApkBuilder extends ApkBuilder {
|
||||
@Override
|
||||
public AutoJsApkBuilder cleanWorkspace() {
|
||||
if (mProgressCallback != null) {
|
||||
App.getApp().getUiHandler().post(() -> mProgressCallback.onClean(AutoJsApkBuilder.this));
|
||||
GlobalAppContext.post(() -> mProgressCallback.onClean(AutoJsApkBuilder.this));
|
||||
}
|
||||
return (AutoJsApkBuilder) super.cleanWorkspace();
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ import android.view.ContextThemeWrapper;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.stardust.app.DialogUtils;
|
||||
import com.stardust.app.GlobalAppContext;
|
||||
import com.stardust.autojs.core.record.Recorder;
|
||||
import com.stardust.autojs.core.record.inputevent.InputEventRecorder;
|
||||
import com.stardust.autojs.core.record.inputevent.InputEventToAutoFileRecorder;
|
||||
@ -106,7 +107,7 @@ public class GlobalActionRecorder implements Recorder.OnStateChangedListener {
|
||||
@Override
|
||||
public void onStart() {
|
||||
if (Pref.isRecordToastEnabled())
|
||||
App.getApp().getUiHandler().toast(R.string.text_start_record);
|
||||
GlobalAppContext.toast(R.string.text_start_record);
|
||||
for (Recorder.OnStateChangedListener listener : mOnStateChangedListeners) {
|
||||
listener.onStart();
|
||||
}
|
||||
@ -150,13 +151,13 @@ public class GlobalActionRecorder implements Recorder.OnStateChangedListener {
|
||||
if (Looper.myLooper() == Looper.getMainLooper()) {
|
||||
showRecordHandleDialog(script);
|
||||
} else {
|
||||
App.getApp().getUiHandler().post(() -> showRecordHandleDialog(script));
|
||||
GlobalAppContext.post(() -> showRecordHandleDialog(script));
|
||||
}
|
||||
}
|
||||
|
||||
private void handleRecordedFile(final String path) {
|
||||
if (Looper.myLooper() != Looper.getMainLooper()) {
|
||||
App.getApp().getUiHandler().post(() -> handleRecordedFile(path));
|
||||
GlobalAppContext.post(() -> handleRecordedFile(path));
|
||||
return;
|
||||
}
|
||||
new ScriptOperations(mContext, null)
|
||||
|
||||
@ -4,6 +4,7 @@ import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.util.Log;
|
||||
|
||||
import com.stardust.app.GlobalAppContext;
|
||||
import com.stardust.scriptdroid.App;
|
||||
|
||||
import java.util.HashSet;
|
||||
@ -22,7 +23,7 @@ public class ScriptWidgets {
|
||||
|
||||
|
||||
private static final String LOG_TAG = "ScriptWidgets";
|
||||
private static SharedPreferences widgets = App.getApp().getSharedPreferences("ScriptWidgets", Context.MODE_PRIVATE);
|
||||
private static SharedPreferences widgets = GlobalAppContext.get().getSharedPreferences("ScriptWidgets", Context.MODE_PRIVATE);
|
||||
private static final Pattern ID_PATTERN = Pattern.compile("[a-zA-Z]+_([0-9])+");
|
||||
|
||||
static String getPathForAppWidgetId(int id) {
|
||||
|
||||
@ -4,6 +4,7 @@ import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import com.stardust.app.GlobalAppContext;
|
||||
import com.stardust.autojs.execution.ExecutionConfig;
|
||||
import com.stardust.autojs.execution.ScriptExecution;
|
||||
import com.stardust.autojs.execution.ScriptExecutionListener;
|
||||
@ -39,7 +40,7 @@ public class Scripts {
|
||||
|
||||
@Override
|
||||
public void onSuccess(ScriptExecution execution, Object result) {
|
||||
App.getApp().sendBroadcast(new Intent(ACTION_ON_EXECUTION_FINISHED));
|
||||
GlobalAppContext.get().sendBroadcast(new Intent(ACTION_ON_EXECUTION_FINISHED));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -51,11 +52,11 @@ public class Scripts {
|
||||
col = rhinoException.columnNumber();
|
||||
}
|
||||
if (ScriptInterruptedException.causedByInterrupted(e)) {
|
||||
App.getApp().sendBroadcast(new Intent(ACTION_ON_EXECUTION_FINISHED)
|
||||
GlobalAppContext.get().sendBroadcast(new Intent(ACTION_ON_EXECUTION_FINISHED)
|
||||
.putExtra(EXTRA_EXCEPTION_LINE_NUMBER, line)
|
||||
.putExtra(EXTRA_EXCEPTION_COLUMN_NUMBER, col));
|
||||
} else {
|
||||
App.getApp().sendBroadcast(new Intent(ACTION_ON_EXECUTION_FINISHED)
|
||||
GlobalAppContext.get().sendBroadcast(new Intent(ACTION_ON_EXECUTION_FINISHED)
|
||||
.putExtra(EXTRA_EXCEPTION_MESSAGE, e.getMessage())
|
||||
.putExtra(EXTRA_EXCEPTION_LINE_NUMBER, line)
|
||||
.putExtra(EXTRA_EXCEPTION_COLUMN_NUMBER, col));
|
||||
@ -67,7 +68,7 @@ public class Scripts {
|
||||
|
||||
public static void openByOtherApps(String path) {
|
||||
Uri uri = Uri.parse("file://" + path);
|
||||
App.getApp().startActivity(new Intent(Intent.ACTION_VIEW).setDataAndType(uri, "text/plain").addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
|
||||
GlobalAppContext.get().startActivity(new Intent(Intent.ACTION_VIEW).setDataAndType(uri, "text/plain").addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
|
||||
}
|
||||
|
||||
public static void openByOtherApps(File file) {
|
||||
@ -75,7 +76,7 @@ public class Scripts {
|
||||
}
|
||||
|
||||
public static void createShortcut(ScriptFile scriptFile) {
|
||||
new Shortcut(App.getApp()).name(scriptFile.getSimplifiedName())
|
||||
new Shortcut(GlobalAppContext.get()).name(scriptFile.getSimplifiedName())
|
||||
.targetClass(ShortcutActivity.class)
|
||||
.iconRes(R.drawable.ic_node_js_black)
|
||||
.extras(new Intent().putExtra(ScriptIntents.EXTRA_KEY_PATH, scriptFile.getPath()))
|
||||
@ -84,7 +85,7 @@ public class Scripts {
|
||||
|
||||
|
||||
public static void edit(ScriptFile file) {
|
||||
EditActivity.editFile(App.getApp(), file.getSimplifiedName(), file.getPath());
|
||||
EditActivity.editFile(GlobalAppContext.get(), file.getSimplifiedName(), file.getPath());
|
||||
}
|
||||
|
||||
public static void edit(String path) {
|
||||
@ -128,10 +129,10 @@ public class Scripts {
|
||||
}
|
||||
|
||||
public static void send(ScriptFile file) {
|
||||
App.getApp().startActivity(Intent.createChooser(new Intent(Intent.ACTION_SEND)
|
||||
GlobalAppContext.get().startActivity(Intent.createChooser(new Intent(Intent.ACTION_SEND)
|
||||
.setType("text/plain")
|
||||
.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file)),
|
||||
App.getApp().getString(R.string.text_send)
|
||||
GlobalAppContext.getString(R.string.text_send)
|
||||
).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
|
||||
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@ import android.text.TextUtils;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonNull;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.stardust.app.GlobalAppContext;
|
||||
import com.stardust.autojs.execution.ScriptExecution;
|
||||
import com.stardust.autojs.script.StringScriptSource;
|
||||
import com.stardust.pio.PFiles;
|
||||
@ -100,6 +101,6 @@ public class DevPluginResponseHandler implements Handler {
|
||||
name = "<remote>" + name;
|
||||
}
|
||||
PFiles.write(StorageFileProvider.DEFAULT_DIRECTORY_PATH + name, script);
|
||||
App.getApp().getUiHandler().toast(R.string.text_script_save_successfully);
|
||||
GlobalAppContext.toast(R.string.text_script_save_successfully);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ package com.stardust.scriptdroid.storage.file;
|
||||
|
||||
import android.os.Environment;
|
||||
|
||||
import com.stardust.app.GlobalAppContext;
|
||||
import com.stardust.pio.PFile;
|
||||
import com.stardust.scriptdroid.App;
|
||||
import com.stardust.scriptdroid.R;
|
||||
@ -27,7 +28,7 @@ public class StorageFileProvider {
|
||||
public static final int CREATE = 1;
|
||||
public static final int CHANGE = 2;
|
||||
public static final int ALL = 3;
|
||||
public static final String DEFAULT_DIRECTORY_PATH = Environment.getExternalStorageDirectory() + App.getApp().getString(R.string.folder_name);
|
||||
public static final String DEFAULT_DIRECTORY_PATH = Environment.getExternalStorageDirectory() + GlobalAppContext.getString(R.string.folder_name);
|
||||
public static final PFile DEFAULT_DIRECTORY = new PFile(DEFAULT_DIRECTORY_PATH);
|
||||
public static final FileFilter SCRIPT_FILTER = file ->
|
||||
file.isDirectory() || file.getName().endsWith(".js") || file.getName().endsWith(".auto");
|
||||
|
||||
@ -11,6 +11,7 @@ import com.raizlabs.android.dbflow.rx2.language.RXSQLite;
|
||||
import com.raizlabs.android.dbflow.sql.language.SQLite;
|
||||
import com.raizlabs.android.dbflow.structure.BaseModel;
|
||||
import com.raizlabs.android.dbflow.structure.ModelAdapter;
|
||||
import com.stardust.app.GlobalAppContext;
|
||||
import com.stardust.scriptdroid.App;
|
||||
import com.stardust.scriptdroid.storage.database.ModelChange;
|
||||
import com.stardust.scriptdroid.storage.database.TimedTaskDatabase;
|
||||
@ -37,7 +38,7 @@ public class TimedTaskManager {
|
||||
|
||||
public static TimedTaskManager getInstance() {
|
||||
if (sInstance == null) {
|
||||
sInstance = new TimedTaskManager(App.getApp());
|
||||
sInstance = new TimedTaskManager(GlobalAppContext.get());
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.stardust.app.GlobalAppContext;
|
||||
import com.stardust.scriptdroid.Pref;
|
||||
import com.stardust.scriptdroid.App;
|
||||
import com.stardust.scriptdroid.R;
|
||||
@ -32,14 +33,14 @@ public class AccessibilityServiceTool {
|
||||
}
|
||||
|
||||
public static void goToAccessibilitySetting() {
|
||||
Context context = App.getApp();
|
||||
Context context = GlobalAppContext.get();
|
||||
if (Pref.isFirstGoToAccessibilitySetting()) {
|
||||
App.getApp().getUiHandler().toast(context.getString(R.string.text_please_choose) + context.getString(R.string._app_name));
|
||||
GlobalAppContext.toast(context.getString(R.string.text_please_choose) + context.getString(R.string._app_name));
|
||||
}
|
||||
try {
|
||||
AccessibilityServiceUtils.goToAccessibilitySetting(context);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
App.getApp().getUiHandler().toast(context.getString(R.string.go_to_accessibility_settings) + context.getString(R.string._app_name));
|
||||
GlobalAppContext.toast(context.getString(R.string.go_to_accessibility_settings) + context.getString(R.string._app_name));
|
||||
}
|
||||
}
|
||||
|
||||
@ -55,7 +56,7 @@ public class AccessibilityServiceTool {
|
||||
"settings put secure accessibility_enabled 1";
|
||||
|
||||
public static boolean enableAccessibilityServiceByRoot(Class<? extends android.accessibilityservice.AccessibilityService> accessibilityService) {
|
||||
String serviceName = App.getApp().getPackageName() + "/" + accessibilityService.getName();
|
||||
String serviceName = GlobalAppContext.get().getPackageName() + "/" + accessibilityService.getName();
|
||||
try {
|
||||
return TextUtils.isEmpty(ProcessShell.execCommand(String.format(Locale.getDefault(), cmd, serviceName), true).error);
|
||||
} catch (Exception e) {
|
||||
|
||||
@ -12,6 +12,7 @@ import android.util.Log;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.stardust.app.GlobalAppContext;
|
||||
import com.stardust.scriptdroid.App;
|
||||
import com.stardust.scriptdroid.BuildConfig;
|
||||
import com.stardust.scriptdroid.R;
|
||||
@ -48,14 +49,14 @@ public class CrashHandler implements UncaughtExceptionHandler {
|
||||
return;
|
||||
}
|
||||
if (causedByBadWindowToken(ex)) {
|
||||
Toast.makeText(App.getApp(), R.string.text_no_floating_window_permission, Toast.LENGTH_SHORT).show();
|
||||
IntentUtil.goToAppDetailSettings(App.getApp());
|
||||
Toast.makeText(GlobalAppContext.get(), R.string.text_no_floating_window_permission, Toast.LENGTH_SHORT).show();
|
||||
IntentUtil.goToAppDetailSettings(GlobalAppContext.get());
|
||||
} else {
|
||||
try {
|
||||
Log.e(TAG, "Uncaught Exception", ex);
|
||||
if (crashTooManyTimes())
|
||||
return;
|
||||
String msg = App.getApp().getString(R.string.sorry_for_crash) + ex.toString();
|
||||
String msg = GlobalAppContext.getString(R.string.sorry_for_crash) + ex.toString();
|
||||
startErrorReportActivity(msg, throwableToString(ex));
|
||||
System.exit(1);
|
||||
} catch (Throwable throwable) {
|
||||
@ -75,11 +76,11 @@ public class CrashHandler implements UncaughtExceptionHandler {
|
||||
}
|
||||
|
||||
private void startErrorReportActivity(String msg, String detail) {
|
||||
Intent intent = new Intent(App.getApp(), this.mErrorReportClass);
|
||||
Intent intent = new Intent(GlobalAppContext.get(), this.mErrorReportClass);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||
intent.putExtra("message", msg);
|
||||
intent.putExtra("error", detail);
|
||||
App.getApp().startActivity(intent);
|
||||
GlobalAppContext.get().startActivity(intent);
|
||||
}
|
||||
|
||||
private boolean crashTooManyTimes() {
|
||||
|
||||
@ -9,6 +9,7 @@ import android.view.Window;
|
||||
import com.afollestad.materialdialogs.DialogAction;
|
||||
import com.afollestad.materialdialogs.MaterialDialog;
|
||||
import com.stardust.app.DialogUtils;
|
||||
import com.stardust.app.GlobalAppContext;
|
||||
import com.stardust.scriptdroid.App;
|
||||
import com.stardust.scriptdroid.R;
|
||||
import com.stardust.scriptdroid.model.script.ScriptFile;
|
||||
@ -60,7 +61,7 @@ public class ScriptLoopDialog {
|
||||
float loopDelay = Float.parseFloat(mLoopDelay.getText().toString());
|
||||
Scripts.runRepeatedly(mScriptFile, loopTimes, (long) (1000L * loopDelay), (long) (loopInterval * 1000L));
|
||||
} catch (NumberFormatException e) {
|
||||
App.getApp().getUiHandler().toast(R.string.text_number_format_error);
|
||||
GlobalAppContext.toast(R.string.text_number_format_error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -16,6 +16,7 @@ import android.widget.Toast;
|
||||
import com.afollestad.materialdialogs.DialogAction;
|
||||
import com.afollestad.materialdialogs.MaterialDialog;
|
||||
import com.stardust.app.DialogUtils;
|
||||
import com.stardust.app.GlobalAppContext;
|
||||
import com.stardust.pio.PFile;
|
||||
import com.stardust.pio.PFiles;
|
||||
import com.stardust.pio.UncheckedIOException;
|
||||
@ -159,7 +160,7 @@ public class ScriptOperations {
|
||||
showMessageWithoutThreadSwitch(resId);
|
||||
}
|
||||
//switch to ui thread to show message
|
||||
App.getApp().getUiHandler().post(() -> showMessageWithoutThreadSwitch(resId));
|
||||
GlobalAppContext.post(() -> showMessageWithoutThreadSwitch(resId));
|
||||
}
|
||||
|
||||
private void showMessageWithoutThreadSwitch(int resId) {
|
||||
|
||||
@ -4,6 +4,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.stardust.app.GlobalAppContext;
|
||||
import com.stardust.autojs.util.FloatingPermission;
|
||||
import com.stardust.enhancedfloaty.FloatyService;
|
||||
import com.stardust.enhancedfloaty.FloatyWindow;
|
||||
@ -53,13 +54,13 @@ public class FloatyWindowManger {
|
||||
}
|
||||
|
||||
public static boolean showCircularMenu() {
|
||||
if (!SettingsCompat.canDrawOverlays(App.getApp())) {
|
||||
Toast.makeText(App.getApp(), R.string.text_no_floating_window_permission, Toast.LENGTH_SHORT).show();
|
||||
manageDrawOverlays(App.getApp());
|
||||
if (!SettingsCompat.canDrawOverlays(GlobalAppContext.get())) {
|
||||
Toast.makeText(GlobalAppContext.get(), R.string.text_no_floating_window_permission, Toast.LENGTH_SHORT).show();
|
||||
manageDrawOverlays(GlobalAppContext.get());
|
||||
return false;
|
||||
} else {
|
||||
App.getApp().startService(new Intent(App.getApp(), FloatyService.class));
|
||||
CircularMenu menu = new CircularMenu(App.getApp());
|
||||
GlobalAppContext.get().startService(new Intent(GlobalAppContext.get(), FloatyService.class));
|
||||
CircularMenu menu = new CircularMenu(GlobalAppContext.get());
|
||||
sCircularMenu = new WeakReference<>(menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -18,6 +18,7 @@ import com.afollestad.materialdialogs.MaterialDialog;
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
||||
import com.bumptech.glide.request.target.SimpleTarget;
|
||||
import com.bumptech.glide.request.transition.Transition;
|
||||
import com.stardust.app.GlobalAppContext;
|
||||
import com.stardust.notification.NotificationListenerService;
|
||||
import com.stardust.scriptdroid.App;
|
||||
import com.stardust.scriptdroid.Pref;
|
||||
@ -276,7 +277,7 @@ public class DrawerFragment extends android.support.v4.app.Fragment {
|
||||
new UpdateInfoDialogBuilder(getActivity(), versionInfo)
|
||||
.show();
|
||||
} else {
|
||||
Toast.makeText(App.getApp(), R.string.text_is_latest_version, Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(GlobalAppContext.get(), R.string.text_is_latest_version, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
setProgress(mCheckForUpdatesItem, false);
|
||||
}
|
||||
@ -284,7 +285,7 @@ public class DrawerFragment extends android.support.v4.app.Fragment {
|
||||
@Override
|
||||
public void onError(@io.reactivex.annotations.NonNull Throwable e) {
|
||||
e.printStackTrace();
|
||||
Toast.makeText(App.getApp(), R.string.text_check_update_error, Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(GlobalAppContext.get(), R.string.text_check_update_error, Toast.LENGTH_SHORT).show();
|
||||
setProgress(mCheckForUpdatesItem, false);
|
||||
}
|
||||
});
|
||||
|
||||
@ -3,6 +3,7 @@ package com.stardust.scriptdroid.ui.main.task;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import com.stardust.app.GlobalAppContext;
|
||||
import com.stardust.autojs.engine.JavaScriptEngine;
|
||||
import com.stardust.autojs.engine.ScriptEngine;
|
||||
import com.stardust.autojs.engine.ScriptEngineFactory;
|
||||
@ -22,7 +23,7 @@ import org.joda.time.format.DateTimeFormat;
|
||||
* Created by Stardust on 2017/11/28.
|
||||
*/
|
||||
|
||||
public abstract class Task implements Parcelable {
|
||||
public abstract class Task {
|
||||
|
||||
public abstract String getName();
|
||||
|
||||
@ -32,16 +33,6 @@ public abstract class Task implements Parcelable {
|
||||
|
||||
public abstract String getEngineName();
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
|
||||
}
|
||||
|
||||
public static class PendingTask extends Task {
|
||||
|
||||
private TimedTask mTimedTask;
|
||||
@ -63,7 +54,7 @@ public abstract class Task implements Parcelable {
|
||||
@Override
|
||||
public String getDesc() {
|
||||
long nextTime = mTimedTask.getNextTime();
|
||||
return App.getApp().getString(R.string.text_next_run_time) + ": " +
|
||||
return GlobalAppContext.getString(R.string.text_next_run_time) + ": " +
|
||||
DateTimeFormat.shortDateTime().print(nextTime);
|
||||
}
|
||||
|
||||
|
||||
@ -4,6 +4,7 @@ import android.content.Context;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.afollestad.materialdialogs.MaterialDialog;
|
||||
import com.stardust.app.GlobalAppContext;
|
||||
import com.stardust.scriptdroid.App;
|
||||
import com.stardust.scriptdroid.R;
|
||||
import com.stardust.scriptdroid.network.VersionService;
|
||||
@ -42,7 +43,7 @@ public class UpdateCheckDialog {
|
||||
new UpdateInfoDialogBuilder(mContext, versionInfo)
|
||||
.show();
|
||||
} else {
|
||||
Toast.makeText(App.getApp(), R.string.text_is_latest_version, Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(GlobalAppContext.get(), R.string.text_is_latest_version, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
@ -50,7 +51,7 @@ public class UpdateCheckDialog {
|
||||
public void onError(@NonNull Throwable e) {
|
||||
e.printStackTrace();
|
||||
mProgress.dismiss();
|
||||
Toast.makeText(App.getApp(), R.string.text_check_update_error, Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(GlobalAppContext.get(), R.string.text_check_update_error, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.stardust.theme;
|
||||
|
||||
import com.stardust.app.GlobalAppContext;
|
||||
import com.stardust.scriptdroid.*;
|
||||
import com.stardust.scriptdroid.R;
|
||||
|
||||
@ -12,7 +13,7 @@ public class ThemeColorManagerCompat {
|
||||
public static int getColorPrimary() {
|
||||
int color = ThemeColorManager.getColorPrimary();
|
||||
if (color == 0) {
|
||||
return App.getApp().getResources().getColor(R.color.colorPrimary);
|
||||
return GlobalAppContext.get().getResources().getColor(R.color.colorPrimary);
|
||||
} else {
|
||||
return color;
|
||||
}
|
||||
|
||||
@ -96,6 +96,7 @@ runtime.init();
|
||||
importClass(android.view.KeyEvent);
|
||||
importClass(com.stardust.autojs.core.util.Shell);
|
||||
importClass(android.graphics.Paint);
|
||||
importClass(android.graphics.Canvas);
|
||||
|
||||
//重定向require以便支持相对路径
|
||||
(function(){
|
||||
|
||||
@ -161,7 +161,9 @@ module.exports = function(__runtime__, scope){
|
||||
function emit(){
|
||||
var args = arguments;
|
||||
scope.__exitIfError__(function(){
|
||||
view.emit.apply(view, args);
|
||||
//不支持使用apply的原因是rhino会把参数中的primitive变成object
|
||||
functionApply(view.emit, args);
|
||||
//view.emit.apply(view, args);
|
||||
});
|
||||
}
|
||||
return view;
|
||||
@ -198,7 +200,7 @@ module.exports = function(__runtime__, scope){
|
||||
if(args.length == 5)
|
||||
return func(args[0], args[1], args[2], args[3], args[4]);
|
||||
if(args.length == 6)
|
||||
return func(args[0], args[1], args[2], args[3], args[5]);
|
||||
return func(args[0], args[1], args[2], args[3], args[4], args[5]);
|
||||
throw new Error("too many arguments: " + args.length);
|
||||
}
|
||||
|
||||
|
||||
@ -4,6 +4,10 @@ import android.app.Activity;
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
@ -52,6 +56,7 @@ public abstract class AutoJs {
|
||||
private ScriptEngineManager mScriptEngineManager;
|
||||
private final LayoutInspector mLayoutInspector = new LayoutInspector();
|
||||
private final Context mContext;
|
||||
private final Application mApplication;
|
||||
private final UiHandler mUiHandler;
|
||||
private final AppUtils mAppUtils;
|
||||
private final AccessibilityInfoProvider mAccessibilityInfoProvider;
|
||||
@ -60,13 +65,14 @@ public abstract class AutoJs {
|
||||
private final Console mGlobalConsole;
|
||||
|
||||
|
||||
protected AutoJs(final Context context) {
|
||||
mContext = context;
|
||||
mUiHandler = new UiHandler(context);
|
||||
mAppUtils = new AppUtils(context);
|
||||
protected AutoJs(final Application application) {
|
||||
mContext = application.getApplicationContext();
|
||||
mApplication = application;
|
||||
mUiHandler = new UiHandler(mContext);
|
||||
mAppUtils = new AppUtils(mContext);
|
||||
mGlobalConsole = createGlobalConsole();
|
||||
mNotificationObserver = new AccessibilityNotificationObserver(context);
|
||||
mAccessibilityInfoProvider = new AccessibilityInfoProvider(context.getPackageManager());
|
||||
mNotificationObserver = new AccessibilityNotificationObserver(mContext);
|
||||
mAccessibilityInfoProvider = new AccessibilityInfoProvider(mContext.getPackageManager());
|
||||
mScriptEngineService = buildScriptEngineService();
|
||||
init();
|
||||
}
|
||||
@ -85,7 +91,9 @@ public abstract class AutoJs {
|
||||
|
||||
public abstract void ensureAccessibilityServiceEnabled();
|
||||
|
||||
protected abstract Application getApplication();
|
||||
protected Application getApplication() {
|
||||
return mApplication;
|
||||
}
|
||||
|
||||
protected ScriptEngineService buildScriptEngineService() {
|
||||
initScriptEngineManager();
|
||||
|
||||
@ -0,0 +1,463 @@
|
||||
package com.stardust.autojs.core.graphics;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.DrawFilter;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.Picture;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.Region;
|
||||
import android.os.Build;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.RequiresApi;
|
||||
|
||||
import com.stardust.autojs.core.image.ImageWrapper;
|
||||
import com.stardust.autojs.runtime.ScriptRuntime;
|
||||
import com.stardust.autojs.runtime.exception.ScriptException;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2018/3/22.
|
||||
*/
|
||||
|
||||
public class Canvas {
|
||||
|
||||
private final android.graphics.Canvas mCanvas;
|
||||
|
||||
public Canvas(android.graphics.Canvas canvas) {
|
||||
mCanvas = canvas;
|
||||
}
|
||||
|
||||
public Canvas(@NonNull Bitmap bitmap) {
|
||||
mCanvas = new android.graphics.Canvas(bitmap);
|
||||
}
|
||||
|
||||
public Canvas(@NonNull ImageWrapper image) {
|
||||
this(image.getBitmap());
|
||||
}
|
||||
|
||||
public boolean isHardwareAccelerated() {
|
||||
return mCanvas.isHardwareAccelerated();
|
||||
}
|
||||
|
||||
public void setBitmap(@Nullable Bitmap bitmap) {
|
||||
mCanvas.setBitmap(bitmap);
|
||||
}
|
||||
|
||||
public boolean isOpaque() {
|
||||
return mCanvas.isOpaque();
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return mCanvas.getWidth();
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return mCanvas.getHeight();
|
||||
}
|
||||
|
||||
public int getDensity() {
|
||||
return mCanvas.getDensity();
|
||||
}
|
||||
|
||||
public void setDensity(int density) {
|
||||
mCanvas.setDensity(density);
|
||||
}
|
||||
|
||||
public int getMaximumBitmapWidth() {
|
||||
return mCanvas.getMaximumBitmapWidth();
|
||||
}
|
||||
|
||||
public int getMaximumBitmapHeight() {
|
||||
return mCanvas.getMaximumBitmapHeight();
|
||||
}
|
||||
|
||||
public int save() {
|
||||
return mCanvas.save();
|
||||
}
|
||||
|
||||
public int save(int saveFlags) {
|
||||
return mCanvas.save(saveFlags);
|
||||
}
|
||||
|
||||
public int saveLayer(@Nullable RectF bounds, @Nullable Paint paint, int saveFlags) {
|
||||
return mCanvas.saveLayer(bounds, paint, saveFlags);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
public int saveLayer(@Nullable RectF bounds, @Nullable Paint paint) {
|
||||
ScriptRuntime.requiresApi(Build.VERSION_CODES.LOLLIPOP);
|
||||
return mCanvas.saveLayer(bounds, paint);
|
||||
}
|
||||
|
||||
public int saveLayer(float left, float top, float right, float bottom, @Nullable Paint paint, int saveFlags) {
|
||||
return mCanvas.saveLayer(left, top, right, bottom, paint, saveFlags);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
public int saveLayer(float left, float top, float right, float bottom, @Nullable Paint paint) {
|
||||
ScriptRuntime.requiresApi(Build.VERSION_CODES.LOLLIPOP);
|
||||
return mCanvas.saveLayer(left, top, right, bottom, paint);
|
||||
}
|
||||
|
||||
public int saveLayerAlpha(@Nullable RectF bounds, int alpha, int saveFlags) {
|
||||
return mCanvas.saveLayerAlpha(bounds, alpha, saveFlags);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
public int saveLayerAlpha(@Nullable RectF bounds, int alpha) {
|
||||
ScriptRuntime.requiresApi(Build.VERSION_CODES.LOLLIPOP);
|
||||
return mCanvas.saveLayerAlpha(bounds, alpha);
|
||||
}
|
||||
|
||||
public int saveLayerAlpha(float left, float top, float right, float bottom, int alpha, int saveFlags) {
|
||||
return mCanvas.saveLayerAlpha(left, top, right, bottom, alpha, saveFlags);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
public int saveLayerAlpha(float left, float top, float right, float bottom, int alpha) {
|
||||
ScriptRuntime.requiresApi(Build.VERSION_CODES.LOLLIPOP);
|
||||
return mCanvas.saveLayerAlpha(left, top, right, bottom, alpha);
|
||||
}
|
||||
|
||||
public void restore() {
|
||||
mCanvas.restore();
|
||||
}
|
||||
|
||||
public int getSaveCount() {
|
||||
return mCanvas.getSaveCount();
|
||||
}
|
||||
|
||||
public void restoreToCount(int saveCount) {
|
||||
mCanvas.restoreToCount(saveCount);
|
||||
}
|
||||
|
||||
public void translate(float dx, float dy) {
|
||||
mCanvas.translate(dx, dy);
|
||||
}
|
||||
|
||||
public void scale(float sx, float sy) {
|
||||
mCanvas.scale(sx, sy);
|
||||
}
|
||||
|
||||
public void scale(float sx, float sy, float px, float py) {
|
||||
mCanvas.scale(sx, sy, px, py);
|
||||
}
|
||||
|
||||
public void rotate(float degrees) {
|
||||
mCanvas.rotate(degrees);
|
||||
}
|
||||
|
||||
public void rotate(float degrees, float px, float py) {
|
||||
mCanvas.rotate(degrees, px, py);
|
||||
}
|
||||
|
||||
public void skew(float sx, float sy) {
|
||||
mCanvas.skew(sx, sy);
|
||||
}
|
||||
|
||||
public void concat(@Nullable Matrix matrix) {
|
||||
mCanvas.concat(matrix);
|
||||
}
|
||||
|
||||
public void setMatrix(@Nullable Matrix matrix) {
|
||||
mCanvas.setMatrix(matrix);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void getMatrix(@NonNull Matrix ctm) {
|
||||
mCanvas.getMatrix(ctm);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Matrix getMatrix() {
|
||||
return mCanvas.getMatrix();
|
||||
}
|
||||
|
||||
public boolean clipRect(@NonNull RectF rect, @NonNull Region.Op op) {
|
||||
return mCanvas.clipRect(rect, op);
|
||||
}
|
||||
|
||||
public boolean clipRect(@NonNull Rect rect, @NonNull Region.Op op) {
|
||||
return mCanvas.clipRect(rect, op);
|
||||
}
|
||||
|
||||
public boolean clipRect(@NonNull RectF rect) {
|
||||
return mCanvas.clipRect(rect);
|
||||
}
|
||||
|
||||
public boolean clipRect(@NonNull Rect rect) {
|
||||
return mCanvas.clipRect(rect);
|
||||
}
|
||||
|
||||
public boolean clipRect(float left, float top, float right, float bottom, @NonNull Region.Op op) {
|
||||
return mCanvas.clipRect(left, top, right, bottom, op);
|
||||
}
|
||||
|
||||
public boolean clipRect(float left, float top, float right, float bottom) {
|
||||
return mCanvas.clipRect(left, top, right, bottom);
|
||||
}
|
||||
|
||||
public boolean clipRect(int left, int top, int right, int bottom) {
|
||||
return mCanvas.clipRect(left, top, right, bottom);
|
||||
}
|
||||
|
||||
public boolean clipPath(@NonNull Path path, @NonNull Region.Op op) {
|
||||
return mCanvas.clipPath(path, op);
|
||||
}
|
||||
|
||||
public boolean clipPath(@NonNull Path path) {
|
||||
return mCanvas.clipPath(path);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean clipRegion(Region region, Region.Op op) {
|
||||
return mCanvas.clipRegion(region, op);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean clipRegion(Region region) {
|
||||
return mCanvas.clipRegion(region);
|
||||
}
|
||||
|
||||
public DrawFilter getDrawFilter() {
|
||||
return mCanvas.getDrawFilter();
|
||||
}
|
||||
|
||||
public void setDrawFilter(@Nullable DrawFilter filter) {
|
||||
mCanvas.setDrawFilter(filter);
|
||||
}
|
||||
|
||||
public boolean quickReject(@NonNull RectF rect, @NonNull android.graphics.Canvas.EdgeType type) {
|
||||
return mCanvas.quickReject(rect, type);
|
||||
}
|
||||
|
||||
public boolean quickReject(@NonNull Path path, @NonNull android.graphics.Canvas.EdgeType type) {
|
||||
return mCanvas.quickReject(path, type);
|
||||
}
|
||||
|
||||
public boolean quickReject(float left, float top, float right, float bottom, @NonNull android.graphics.Canvas.EdgeType type) {
|
||||
return mCanvas.quickReject(left, top, right, bottom, type);
|
||||
}
|
||||
|
||||
public boolean getClipBounds(@Nullable Rect bounds) {
|
||||
return mCanvas.getClipBounds(bounds);
|
||||
}
|
||||
|
||||
public Rect getClipBounds() {
|
||||
return mCanvas.getClipBounds();
|
||||
}
|
||||
|
||||
public void drawRGB(int r, int g, int b) {
|
||||
mCanvas.drawRGB(r, g, b);
|
||||
}
|
||||
|
||||
public void drawARGB(int a, int r, int g, int b) {
|
||||
mCanvas.drawARGB(a, r, g, b);
|
||||
}
|
||||
|
||||
public void drawColor(int color) {
|
||||
mCanvas.drawColor(color);
|
||||
}
|
||||
|
||||
public void drawColor(int color, @NonNull PorterDuff.Mode mode) {
|
||||
mCanvas.drawColor(color, mode);
|
||||
}
|
||||
|
||||
public void drawPaint(@NonNull Paint paint) {
|
||||
mCanvas.drawPaint(paint);
|
||||
}
|
||||
|
||||
public void drawPoints(float[] pts, int offset, int count, @NonNull Paint paint) {
|
||||
mCanvas.drawPoints(pts, offset, count, paint);
|
||||
}
|
||||
|
||||
public void drawPoints(@NonNull float[] pts, @NonNull Paint paint) {
|
||||
mCanvas.drawPoints(pts, paint);
|
||||
}
|
||||
|
||||
public void drawPoint(float x, float y, @NonNull Paint paint) {
|
||||
mCanvas.drawPoint(x, y, paint);
|
||||
}
|
||||
|
||||
public void drawLine(float startX, float startY, float stopX, float stopY, @NonNull Paint paint) {
|
||||
mCanvas.drawLine(startX, startY, stopX, stopY, paint);
|
||||
}
|
||||
|
||||
public void drawLines(@NonNull float[] pts, int offset, int count, @NonNull Paint paint) {
|
||||
mCanvas.drawLines(pts, offset, count, paint);
|
||||
}
|
||||
|
||||
public void drawLines(@NonNull float[] pts, @NonNull Paint paint) {
|
||||
mCanvas.drawLines(pts, paint);
|
||||
}
|
||||
|
||||
public void drawRect(@NonNull RectF rect, @NonNull Paint paint) {
|
||||
mCanvas.drawRect(rect, paint);
|
||||
}
|
||||
|
||||
public void drawRect(@NonNull Rect r, @NonNull Paint paint) {
|
||||
mCanvas.drawRect(r, paint);
|
||||
}
|
||||
|
||||
public void drawRect(float left, float top, float right, float bottom, @NonNull Paint paint) {
|
||||
mCanvas.drawRect(left, top, right, bottom, paint);
|
||||
}
|
||||
|
||||
public void drawOval(@NonNull RectF oval, @NonNull Paint paint) {
|
||||
mCanvas.drawOval(oval, paint);
|
||||
}
|
||||
|
||||
public void drawOval(float left, float top, float right, float bottom, @NonNull Paint paint) {
|
||||
mCanvas.drawOval(left, top, right, bottom, paint);
|
||||
}
|
||||
|
||||
public void drawCircle(float cx, float cy, float radius, @NonNull Paint paint) {
|
||||
mCanvas.drawCircle(cx, cy, radius, paint);
|
||||
}
|
||||
|
||||
public void drawArc(@NonNull RectF oval, float startAngle, float sweepAngle, boolean useCenter, @NonNull Paint paint) {
|
||||
mCanvas.drawArc(oval, startAngle, sweepAngle, useCenter, paint);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
public void drawArc(float left, float top, float right, float bottom, float startAngle, float sweepAngle, boolean useCenter, @NonNull Paint paint) {
|
||||
ScriptRuntime.requiresApi(Build.VERSION_CODES.LOLLIPOP);
|
||||
mCanvas.drawArc(left, top, right, bottom, startAngle, sweepAngle, useCenter, paint);
|
||||
}
|
||||
|
||||
|
||||
public void drawRoundRect(@NonNull RectF rect, float rx, float ry, @NonNull Paint paint) {
|
||||
mCanvas.drawRoundRect(rect, rx, ry, paint);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
public void drawRoundRect(float left, float top, float right, float bottom, float rx, float ry, @NonNull Paint paint) {
|
||||
ScriptRuntime.requiresApi(Build.VERSION_CODES.LOLLIPOP);
|
||||
mCanvas.drawRoundRect(left, top, right, bottom, rx, ry, paint);
|
||||
}
|
||||
|
||||
public void drawPath(@NonNull Path path, @NonNull Paint paint) {
|
||||
mCanvas.drawPath(path, paint);
|
||||
}
|
||||
|
||||
public void drawBitmap(@NonNull Bitmap bitmap, float left, float top, @Nullable Paint paint) {
|
||||
mCanvas.drawBitmap(bitmap, left, top, paint);
|
||||
}
|
||||
|
||||
public void drawBitmap(@NonNull Bitmap bitmap, @Nullable Rect src, @NonNull RectF dst, @Nullable Paint paint) {
|
||||
mCanvas.drawBitmap(bitmap, src, dst, paint);
|
||||
}
|
||||
|
||||
public void drawBitmap(@NonNull Bitmap bitmap, @Nullable Rect src, @NonNull Rect dst, @Nullable Paint paint) {
|
||||
mCanvas.drawBitmap(bitmap, src, dst, paint);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void drawBitmap(@NonNull int[] colors, int offset, int stride, float x, float y, int width, int height, boolean hasAlpha, @Nullable Paint paint) {
|
||||
mCanvas.drawBitmap(colors, offset, stride, x, y, width, height, hasAlpha, paint);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void drawBitmap(@NonNull int[] colors, int offset, int stride, int x, int y, int width, int height, boolean hasAlpha, @Nullable Paint paint) {
|
||||
mCanvas.drawBitmap(colors, offset, stride, x, y, width, height, hasAlpha, paint);
|
||||
}
|
||||
|
||||
public void drawBitmap(@NonNull Bitmap bitmap, @NonNull Matrix matrix, @Nullable Paint paint) {
|
||||
mCanvas.drawBitmap(bitmap, matrix, paint);
|
||||
}
|
||||
|
||||
public void drawBitmapMesh(@NonNull Bitmap bitmap, int meshWidth, int meshHeight, @NonNull float[] verts, int vertOffset, @Nullable int[] colors, int colorOffset, @Nullable Paint paint) {
|
||||
mCanvas.drawBitmapMesh(bitmap, meshWidth, meshHeight, verts, vertOffset, colors, colorOffset, paint);
|
||||
}
|
||||
|
||||
public void drawVertices(@NonNull android.graphics.Canvas.VertexMode mode, int vertexCount, @NonNull float[] verts, int vertOffset, @Nullable float[] texs, int texOffset, @Nullable int[] colors, int colorOffset, @Nullable short[] indices, int indexOffset, int indexCount, @NonNull Paint paint) {
|
||||
mCanvas.drawVertices(mode, vertexCount, verts, vertOffset, texs, texOffset, colors, colorOffset, indices, indexOffset, indexCount, paint);
|
||||
}
|
||||
|
||||
public void drawText(@NonNull char[] text, int index, int count, float x, float y, @NonNull Paint paint) {
|
||||
mCanvas.drawText(text, index, count, x, y, paint);
|
||||
}
|
||||
|
||||
public void drawText(@NonNull String text, float x, float y, @NonNull Paint paint) {
|
||||
mCanvas.drawText(text, x, y, paint);
|
||||
}
|
||||
|
||||
public void drawText(@NonNull String text, int start, int end, float x, float y, @NonNull Paint paint) {
|
||||
mCanvas.drawText(text, start, end, x, y, paint);
|
||||
}
|
||||
|
||||
public void drawText(@NonNull CharSequence text, int start, int end, float x, float y, @NonNull Paint paint) {
|
||||
mCanvas.drawText(text, start, end, x, y, paint);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.M)
|
||||
public void drawTextRun(@NonNull char[] text, int index, int count, int contextIndex, int contextCount, float x, float y, boolean isRtl, @NonNull Paint paint) {
|
||||
ScriptRuntime.requiresApi(Build.VERSION_CODES.M);
|
||||
mCanvas.drawTextRun(text, index, count, contextIndex, contextCount, x, y, isRtl, paint);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.M)
|
||||
public void drawTextRun(@NonNull CharSequence text, int start, int end, int contextStart, int contextEnd, float x, float y, boolean isRtl, @NonNull Paint paint) {
|
||||
ScriptRuntime.requiresApi(Build.VERSION_CODES.M);
|
||||
mCanvas.drawTextRun(text, start, end, contextStart, contextEnd, x, y, isRtl, paint);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void drawPosText(@NonNull char[] text, int index, int count, @NonNull float[] pos, @NonNull Paint paint) {
|
||||
mCanvas.drawPosText(text, index, count, pos, paint);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void drawPosText(@NonNull String text, @NonNull float[] pos, @NonNull Paint paint) {
|
||||
mCanvas.drawPosText(text, pos, paint);
|
||||
}
|
||||
|
||||
public void drawTextOnPath(@NonNull char[] text, int index, int count, @NonNull Path path, float hOffset, float vOffset, @NonNull Paint paint) {
|
||||
mCanvas.drawTextOnPath(text, index, count, path, hOffset, vOffset, paint);
|
||||
}
|
||||
|
||||
public void drawTextOnPath(@NonNull String text, @NonNull Path path, float hOffset, float vOffset, @NonNull Paint paint) {
|
||||
mCanvas.drawTextOnPath(text, path, hOffset, vOffset, paint);
|
||||
}
|
||||
|
||||
public void drawPicture(@NonNull Picture picture) {
|
||||
mCanvas.drawPicture(picture);
|
||||
}
|
||||
|
||||
public void drawPicture(@NonNull Picture picture, @NonNull RectF dst) {
|
||||
mCanvas.drawPicture(picture, dst);
|
||||
}
|
||||
|
||||
public void drawPicture(@NonNull Picture picture, @NonNull Rect dst) {
|
||||
mCanvas.drawPicture(picture, dst);
|
||||
}
|
||||
|
||||
public void drawImage(@NonNull ImageWrapper image, float left, float top, @Nullable Paint paint) {
|
||||
mCanvas.drawBitmap(image.getBitmap(), left, top, paint);
|
||||
}
|
||||
|
||||
public void drawImage(@NonNull ImageWrapper image, float left, float top, float width, float height, @Nullable Paint paint) {
|
||||
mCanvas.drawBitmap(image.getBitmap(), null, new RectF(left, top, left + width, top + height), paint);
|
||||
}
|
||||
|
||||
public void drawImage(@NonNull ImageWrapper image, int sx, int sy, int swidth, int sheight, float left, float top, float width, float height, @Nullable Paint paint) {
|
||||
mCanvas.drawBitmap(image.getBitmap(), new Rect(sx, sy, sx + swidth, sy + sheight),
|
||||
new RectF(left, top, left + width, top + height), paint);
|
||||
}
|
||||
|
||||
public void drawImage(@NonNull ImageWrapper image, @Nullable Rect src, @NonNull RectF dst, @Nullable Paint paint) {
|
||||
mCanvas.drawBitmap(image.getBitmap(), src, dst, paint);
|
||||
}
|
||||
|
||||
public void drawImage(@NonNull ImageWrapper image, @Nullable Rect src, @NonNull Rect dst, @Nullable Paint paint) {
|
||||
mCanvas.drawBitmap(image.getBitmap(), src, dst, paint);
|
||||
}
|
||||
|
||||
public void drawImage(@NonNull ImageWrapper image, @NonNull Matrix matrix, @Nullable Paint paint) {
|
||||
mCanvas.drawBitmap(image.getBitmap(), matrix, paint);
|
||||
}
|
||||
}
|
||||
@ -6,6 +6,7 @@ import android.os.Looper;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
|
||||
import com.stardust.app.GlobalAppContext;
|
||||
import com.stardust.autojs.R;
|
||||
import com.stardust.autojs.ScriptEngineService;
|
||||
import com.stardust.autojs.annotation.ScriptVariable;
|
||||
@ -303,9 +304,9 @@ public class ScriptRuntime {
|
||||
return Thread.currentThread().isInterrupted();
|
||||
}
|
||||
|
||||
public void requiresApi(int i) {
|
||||
public static void requiresApi(int i) {
|
||||
if (Build.VERSION.SDK_INT < i) {
|
||||
throw new ScriptException(uiHandler.getContext().getString(R.string.text_requires_sdk_version_to_run_the_script) + SdkVersionUtil.sdkIntToString(i));
|
||||
throw new ScriptException(GlobalAppContext.getString(R.string.text_requires_sdk_version_to_run_the_script) + SdkVersionUtil.sdkIntToString(i));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
77
common/src/main/java/com/stardust/app/GlobalAppContext.java
Normal file
77
common/src/main/java/com/stardust/app/GlobalAppContext.java
Normal file
@ -0,0 +1,77 @@
|
||||
package com.stardust.app;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.support.annotation.RequiresApi;
|
||||
import android.widget.Toast;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2018/3/22.
|
||||
*/
|
||||
|
||||
public class GlobalAppContext {
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private static Context sApplicationContext;
|
||||
private static Handler sHandler;
|
||||
|
||||
public static void set(Application a) {
|
||||
if (sApplicationContext != null)
|
||||
throw new IllegalStateException();
|
||||
sHandler = new Handler(Looper.getMainLooper());
|
||||
sApplicationContext = a.getApplicationContext();
|
||||
}
|
||||
|
||||
public static Context get() {
|
||||
if (sApplicationContext == null)
|
||||
throw new IllegalStateException("Call GlobalAppContext.set() to set a application context");
|
||||
return sApplicationContext;
|
||||
}
|
||||
|
||||
public static String getString(int resId) {
|
||||
return get().getString(resId);
|
||||
}
|
||||
|
||||
public static String getString(int resId, Object... formatArgs) {
|
||||
return get().getString(resId, formatArgs);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.M)
|
||||
public static int getColor(int id) {
|
||||
return get().getColor(id);
|
||||
}
|
||||
|
||||
public static void toast(final String message) {
|
||||
if (Looper.myLooper() == Looper.getMainLooper()) {
|
||||
Toast.makeText(get(), message, Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
sHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Toast.makeText(get(), message, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void toast(final int resId) {
|
||||
if (Looper.myLooper() == Looper.getMainLooper()) {
|
||||
Toast.makeText(get(), resId, Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
sHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Toast.makeText(get(), resId, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void post(Runnable r) {
|
||||
sHandler.post(r);
|
||||
}
|
||||
}
|
||||
@ -10,6 +10,7 @@ import android.widget.ImageView;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.request.target.SimpleTarget;
|
||||
import com.bumptech.glide.request.transition.Transition;
|
||||
import com.stardust.app.GlobalAppContext;
|
||||
import com.stardust.auojs.inrt.autojs.AutoJs;
|
||||
import com.stardust.auojs.inrt.autojs.GlobalKeyObserver;
|
||||
import com.stardust.autojs.core.ui.inflater.ImageLoader;
|
||||
@ -21,16 +22,11 @@ import com.stardust.autojs.core.ui.inflater.util.Drawables;
|
||||
|
||||
public class App extends Application {
|
||||
|
||||
private static App sApp;
|
||||
|
||||
public static App getApp() {
|
||||
return sApp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
sApp = this;
|
||||
GlobalAppContext.set(this);
|
||||
AutoJs.initInstance(this);
|
||||
GlobalKeyObserver.init();
|
||||
Drawables.setDefaultImageLoader(new ImageLoader() {
|
||||
|
||||
@ -3,6 +3,8 @@ package com.stardust.auojs.inrt;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
import com.stardust.app.GlobalAppContext;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/12/8.
|
||||
*/
|
||||
@ -14,7 +16,7 @@ public class Pref {
|
||||
|
||||
public static SharedPreferences getPreferences() {
|
||||
if (sPreferences == null)
|
||||
sPreferences = PreferenceManager.getDefaultSharedPreferences(App.getApp());
|
||||
sPreferences = PreferenceManager.getDefaultSharedPreferences(GlobalAppContext.get());
|
||||
return sPreferences;
|
||||
}
|
||||
|
||||
@ -23,7 +25,7 @@ public class Pref {
|
||||
}
|
||||
|
||||
private static String getString(int res) {
|
||||
return App.getApp().getString(res);
|
||||
return GlobalAppContext.getString(res);
|
||||
}
|
||||
|
||||
public static boolean shouldEnableAccessibilityServiceByRoot() {
|
||||
|
||||
@ -6,6 +6,7 @@ import android.content.Intent;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.stardust.app.GlobalAppContext;
|
||||
import com.stardust.auojs.inrt.App;
|
||||
import com.stardust.autojs.core.util.ProcessShell;
|
||||
|
||||
@ -45,7 +46,7 @@ public class AccessibilityServiceTool {
|
||||
}
|
||||
|
||||
public static void goToAccessibilitySetting() {
|
||||
App.getApp().startActivity(new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
|
||||
GlobalAppContext.get().startActivity(new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ package com.stardust.auojs.inrt.autojs;
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
|
||||
import com.stardust.app.GlobalAppContext;
|
||||
import com.stardust.auojs.inrt.App;
|
||||
import com.stardust.auojs.inrt.LogActivity;
|
||||
import com.stardust.auojs.inrt.Pref;
|
||||
@ -27,12 +28,12 @@ public class AutoJs extends com.stardust.autojs.AutoJs {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static void initInstance(Context context) {
|
||||
instance = new AutoJs(context);
|
||||
public static void initInstance(Application application) {
|
||||
instance = new AutoJs(application);
|
||||
}
|
||||
|
||||
private AutoJs(Context context) {
|
||||
super(context);
|
||||
private AutoJs(Application application) {
|
||||
super(application);
|
||||
}
|
||||
|
||||
|
||||
@ -43,14 +44,14 @@ public class AutoJs extends com.stardust.autojs.AutoJs {
|
||||
}
|
||||
String errorMessage = null;
|
||||
if (AccessibilityServiceUtils.isAccessibilityServiceEnabled(getApplication(), AccessibilityService.class)) {
|
||||
errorMessage = App.getApp().getString(R.string.text_auto_operate_service_enabled_but_not_running);
|
||||
errorMessage = GlobalAppContext.getString(R.string.text_auto_operate_service_enabled_but_not_running);
|
||||
} else {
|
||||
if (Pref.shouldEnableAccessibilityServiceByRoot()) {
|
||||
if (!AccessibilityServiceTool.enableAccessibilityServiceByRootAndWaitFor(getApplication(), 2000)) {
|
||||
errorMessage = App.getApp().getString(R.string.text_enable_accessibility_service_by_root_timeout);
|
||||
errorMessage = GlobalAppContext.getString(R.string.text_enable_accessibility_service_by_root_timeout);
|
||||
}
|
||||
} else {
|
||||
errorMessage = App.getApp().getString(R.string.text_no_accessibility_permission);
|
||||
errorMessage = GlobalAppContext.getString(R.string.text_no_accessibility_permission);
|
||||
}
|
||||
}
|
||||
if (errorMessage != null) {
|
||||
@ -66,14 +67,14 @@ public class AutoJs extends com.stardust.autojs.AutoJs {
|
||||
}
|
||||
String errorMessage = null;
|
||||
if (AccessibilityServiceUtils.isAccessibilityServiceEnabled(getApplication(), AccessibilityService.class)) {
|
||||
errorMessage = App.getApp().getString(R.string.text_auto_operate_service_enabled_but_not_running);
|
||||
errorMessage = GlobalAppContext.getString(R.string.text_auto_operate_service_enabled_but_not_running);
|
||||
} else {
|
||||
if (Pref.shouldEnableAccessibilityServiceByRoot()) {
|
||||
if (!AccessibilityServiceTool.enableAccessibilityServiceByRootAndWaitFor(getApplication(), 2000)) {
|
||||
errorMessage = App.getApp().getString(R.string.text_enable_accessibility_service_by_root_timeout);
|
||||
errorMessage = GlobalAppContext.getString(R.string.text_enable_accessibility_service_by_root_timeout);
|
||||
}
|
||||
} else {
|
||||
errorMessage = App.getApp().getString(R.string.text_no_accessibility_permission);
|
||||
errorMessage = GlobalAppContext.getString(R.string.text_no_accessibility_permission);
|
||||
}
|
||||
}
|
||||
if (errorMessage != null) {
|
||||
@ -84,11 +85,6 @@ public class AutoJs extends com.stardust.autojs.AutoJs {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Application getApplication() {
|
||||
return App.getApp();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ScriptRuntime createRuntime() {
|
||||
ScriptRuntime runtime = super.createRuntime();
|
||||
|
||||
@ -3,6 +3,7 @@ package com.stardust.auojs.inrt.launch;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
|
||||
import com.stardust.app.GlobalAppContext;
|
||||
import com.stardust.auojs.inrt.App;
|
||||
|
||||
/**
|
||||
@ -15,7 +16,7 @@ public class GlobalProjectLauncher extends AssetsProjectLauncher {
|
||||
|
||||
public static GlobalProjectLauncher getInstance() {
|
||||
if (sInstance == null)
|
||||
sInstance = new GlobalProjectLauncher(App.getApp());
|
||||
sInstance = new GlobalProjectLauncher(GlobalAppContext.get());
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user