opt: independent runtime
This commit is contained in:
@@ -4,7 +4,6 @@ import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.support.multidex.MultiDexApplication;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
@@ -18,7 +17,6 @@ import com.raizlabs.android.dbflow.runtime.DirectModelNotifier;
|
||||
import com.squareup.leakcanary.LeakCanary;
|
||||
import com.stardust.scriptdroid.autojs.AutoJs;
|
||||
import com.stardust.scriptdroid.autojs.key.GlobalKeyObserver;
|
||||
import com.stardust.scriptdroid.autojs.record.GlobalRecorder;
|
||||
import com.stardust.scriptdroid.network.GlideApp;
|
||||
import com.stardust.scriptdroid.storage.database.TimedTaskDatabase;
|
||||
import com.stardust.scriptdroid.timing.TimedTaskScheduler;
|
||||
@@ -31,13 +29,8 @@ import com.stardust.util.UiHandler;
|
||||
import org.autojs.dynamiclayoutinflater.ImageLoader;
|
||||
import org.autojs.dynamiclayoutinflater.util.Drawables;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import okhttp3.Headers;
|
||||
import okhttp3.MultipartBody;
|
||||
import okhttp3.RequestBody;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/1/27.
|
||||
*/
|
||||
@@ -90,7 +83,6 @@ public class App extends MultiDexApplication {
|
||||
ThemeColorManager.init(this);
|
||||
AutoJs.initInstance(this);
|
||||
GlobalKeyObserver.getSingleton();
|
||||
GlobalRecorder.initSingleton(this);
|
||||
setupDrawableImageLoader();
|
||||
TimedTaskScheduler.setupRepeating(this);
|
||||
}
|
||||
|
||||
@@ -52,15 +52,11 @@ public class Pref {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static boolean isRecordVolumeControlEnable() {
|
||||
return def().getBoolean(getString(R.string.key_use_volume_control_record), false);
|
||||
}
|
||||
|
||||
public static boolean isRunningVolumeControlEnabled() {
|
||||
return def().getBoolean(getString(R.string.key_use_volume_control_running), false);
|
||||
}
|
||||
|
||||
public static boolean enableAccessibilityServiceByRoot() {
|
||||
public static boolean shouldEnableAccessibilityServiceByRoot() {
|
||||
return def().getBoolean(getString(R.string.key_enable_accessibility_service_by_root), false);
|
||||
}
|
||||
|
||||
@@ -68,14 +64,6 @@ public class Pref {
|
||||
return App.getApp().getString(id);
|
||||
}
|
||||
|
||||
public static int getMaxTextLengthForCodeCompletion() {
|
||||
try {
|
||||
return Integer.parseInt(def().getString(App.getApp().getString(R.string.key_max_length_for_code_completion), "2000"));
|
||||
} catch (NumberFormatException e) {
|
||||
return 2000;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isFirstUsing() {
|
||||
return getDisposableBoolean("isFirstUsing", true);
|
||||
}
|
||||
|
||||
@@ -1,52 +1,17 @@
|
||||
package com.stardust.scriptdroid.autojs;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.RequiresApi;
|
||||
|
||||
import com.stardust.app.OnActivityResultDelegate;
|
||||
import com.stardust.app.SimpleActivityLifecycleCallbacks;
|
||||
import com.stardust.autojs.ScriptEngineService;
|
||||
import com.stardust.autojs.ScriptEngineServiceBuilder;
|
||||
import com.stardust.autojs.engine.LoopBasedJavaScriptEngine;
|
||||
import com.stardust.autojs.engine.RootAutomatorEngine;
|
||||
import com.stardust.autojs.engine.ScriptEngine;
|
||||
import com.stardust.autojs.engine.ScriptEngineManager;
|
||||
import com.stardust.autojs.core.accessibility.AccessibilityBridge;
|
||||
import com.stardust.autojs.runtime.ScriptRuntime;
|
||||
import com.stardust.autojs.core.console.GlobalStardustConsole;
|
||||
import com.stardust.autojs.runtime.exception.ScriptException;
|
||||
import com.stardust.autojs.runtime.api.AbstractShell;
|
||||
import com.stardust.autojs.runtime.api.AppUtils;
|
||||
import com.stardust.autojs.runtime.api.Console;
|
||||
import com.stardust.autojs.core.image.ScreenCaptureRequester;
|
||||
import com.stardust.autojs.core.inputevent.InputEventObserver;
|
||||
import com.stardust.autojs.script.AutoFileSource;
|
||||
import com.stardust.autojs.script.JavaScriptSource;
|
||||
import com.stardust.scriptdroid.App;
|
||||
import com.stardust.scriptdroid.Pref;
|
||||
import com.stardust.scriptdroid.R;
|
||||
import com.stardust.autojs.core.image.ScreenCaptureRequestActivity;
|
||||
import com.stardust.autojs.core.util.Shell;
|
||||
import com.stardust.autojs.core.console.StardustConsole;
|
||||
import com.stardust.scriptdroid.pluginclient.DevPluginService;
|
||||
import com.stardust.util.ScreenMetrics;
|
||||
import com.stardust.util.Supplier;
|
||||
import com.stardust.util.UiHandler;
|
||||
import com.stardust.view.accessibility.AccessibilityInfoProvider;
|
||||
import com.stardust.autojs.core.record.accessibility.AccessibilityActionRecorder;
|
||||
import com.stardust.view.accessibility.AccessibilityNotificationObserver;
|
||||
import com.stardust.view.accessibility.AccessibilityService;
|
||||
import com.stardust.scriptdroid.tool.AccessibilityServiceTool;
|
||||
import com.stardust.view.accessibility.LayoutInspector;
|
||||
import com.stardust.view.accessibility.NotificationListener;
|
||||
|
||||
import org.opencv.android.BaseLoaderCallback;
|
||||
import org.opencv.android.OpenCVLoader;
|
||||
|
||||
|
||||
/**
|
||||
@@ -91,7 +56,7 @@ public class AutoJs extends com.stardust.autojs.AutoJs {
|
||||
if (AccessibilityServiceTool.isAccessibilityServiceEnabled(App.getApp())) {
|
||||
errorMessage = App.getApp().getString(R.string.text_auto_operate_service_enabled_but_not_running);
|
||||
} else {
|
||||
if (Pref.enableAccessibilityServiceByRoot()) {
|
||||
if (Pref.shouldEnableAccessibilityServiceByRoot()) {
|
||||
if (!AccessibilityServiceTool.enableAccessibilityServiceByRootAndWaitFor(2000)) {
|
||||
errorMessage = App.getApp().getString(R.string.text_enable_accessibility_service_by_root_timeout);
|
||||
}
|
||||
|
||||
@@ -22,12 +22,7 @@ public class GlobalKeyObserver implements OnKeyListener, ShellKeyObserver.KeyLis
|
||||
void onVolumeDown();
|
||||
}
|
||||
|
||||
private static final EventDispatcher.Event<OnVolumeDownListener> VOLUME_DOWN_EVENT = new EventDispatcher.Event<OnVolumeDownListener>() {
|
||||
@Override
|
||||
public void notify(OnVolumeDownListener l) {
|
||||
l.onVolumeDown();
|
||||
}
|
||||
};
|
||||
private static final EventDispatcher.Event<OnVolumeDownListener> VOLUME_DOWN_EVENT = OnVolumeDownListener::onVolumeDown;
|
||||
private static final String LOG_TAG = "GlobalKeyObserver";
|
||||
private static final long EVENT_TIMEOUT = 200;
|
||||
private static GlobalKeyObserver sSingleton = new GlobalKeyObserver();
|
||||
@@ -47,6 +42,10 @@ public class GlobalKeyObserver implements OnKeyListener, ShellKeyObserver.KeyLis
|
||||
return sSingleton;
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
//do nothing
|
||||
}
|
||||
|
||||
public void onVolumeUp() {
|
||||
Log.d(LOG_TAG, "onVolumeUp at " + System.currentTimeMillis());
|
||||
if (Pref.isRunningVolumeControlEnabled()) {
|
||||
|
||||
@@ -2,16 +2,11 @@ package com.stardust.scriptdroid.autojs.record;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Looper;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.afollestad.materialdialogs.DialogAction;
|
||||
import com.afollestad.materialdialogs.MaterialDialog;
|
||||
import com.stardust.app.DialogUtils;
|
||||
import com.stardust.autojs.core.record.Recorder;
|
||||
import com.stardust.autojs.core.record.accessibility.AccessibilityActionRecorder;
|
||||
import com.stardust.autojs.core.record.inputevent.InputEventRecorder;
|
||||
import com.stardust.autojs.core.record.inputevent.InputEventToAutoFileRecorder;
|
||||
import com.stardust.autojs.core.record.inputevent.InputEventToRootAutomatorRecorder;
|
||||
@@ -19,14 +14,11 @@ import com.stardust.autojs.core.record.inputevent.TouchRecorder;
|
||||
import com.stardust.scriptdroid.App;
|
||||
import com.stardust.scriptdroid.Pref;
|
||||
import com.stardust.scriptdroid.R;
|
||||
import com.stardust.scriptdroid.accessibility.AccessibilityEventHelper;
|
||||
import com.stardust.scriptdroid.autojs.AutoJs;
|
||||
import com.stardust.scriptdroid.ui.common.ScriptOperations;
|
||||
import com.stardust.theme.dialog.ThemeColorMaterialDialogBuilder;
|
||||
import com.stardust.util.ClipboardUtil;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
@@ -34,27 +26,23 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||
* Created by Stardust on 2017/8/6.
|
||||
*/
|
||||
|
||||
public class GlobalRecorder implements Recorder.OnStateChangedListener {
|
||||
public class GlobalActionRecorder implements Recorder.OnStateChangedListener {
|
||||
|
||||
private static GlobalRecorder sSingleton;
|
||||
private Recorder mRecorder;
|
||||
private static GlobalActionRecorder sSingleton;
|
||||
private CopyOnWriteArrayList<Recorder.OnStateChangedListener> mOnStateChangedListeners = new CopyOnWriteArrayList<>();
|
||||
private TouchRecorder mTouchRecorder;
|
||||
private Context mContext;
|
||||
private boolean mDiscard = false;
|
||||
|
||||
public static GlobalRecorder getSingleton(Context context) {
|
||||
public static GlobalActionRecorder getSingleton(Context context) {
|
||||
if (sSingleton == null) {
|
||||
sSingleton = new GlobalRecorder(context);
|
||||
sSingleton = new GlobalActionRecorder(context);
|
||||
}
|
||||
return sSingleton;
|
||||
}
|
||||
|
||||
public static void initSingleton(Context context) {
|
||||
getSingleton(context);
|
||||
}
|
||||
|
||||
public GlobalRecorder(Context context) {
|
||||
public GlobalActionRecorder(Context context) {
|
||||
mContext = new ContextThemeWrapper(context.getApplicationContext(), R.style.AppTheme);
|
||||
mTouchRecorder = new TouchRecorder(context) {
|
||||
@Override
|
||||
@@ -69,43 +57,37 @@ public class GlobalRecorder implements Recorder.OnStateChangedListener {
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void start() {
|
||||
if (Pref.isRecordWithRootEnabled()) {
|
||||
mTouchRecorder.reset();
|
||||
mRecorder = mTouchRecorder;
|
||||
} else {
|
||||
mRecorder = AutoJs.getInstance().getAccessibilityActionRecorder();
|
||||
}
|
||||
mTouchRecorder.reset();
|
||||
mDiscard = false;
|
||||
mRecorder.setOnStateChangedListener(this);
|
||||
mRecorder.start();
|
||||
mTouchRecorder.setOnStateChangedListener(this);
|
||||
mTouchRecorder.start();
|
||||
}
|
||||
|
||||
public void pause() {
|
||||
mRecorder.pause();
|
||||
mTouchRecorder.pause();
|
||||
}
|
||||
|
||||
public void resume() {
|
||||
mRecorder.resume();
|
||||
mTouchRecorder.resume();
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
mRecorder.stop();
|
||||
mTouchRecorder.stop();
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return mRecorder.getCode();
|
||||
return mTouchRecorder.getCode();
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return mRecorder.getPath();
|
||||
return mTouchRecorder.getPath();
|
||||
}
|
||||
|
||||
public int getState() {
|
||||
if (mRecorder == null)
|
||||
if (mTouchRecorder == null)
|
||||
return Recorder.STATE_NOT_START;
|
||||
return mRecorder.getState();
|
||||
return mTouchRecorder.getState();
|
||||
}
|
||||
|
||||
|
||||
@@ -159,34 +141,18 @@ public class GlobalRecorder implements Recorder.OnStateChangedListener {
|
||||
stop();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onAccessibilityActionRecordEvent(AccessibilityActionRecorder.AccessibilityActionRecordEvent event) {
|
||||
if (Pref.isRecordToastEnabled()) {
|
||||
App.getApp().getUiHandler().toast(AccessibilityEventHelper.getEventTypeNameResId(event.getAccessibilityEvent()));
|
||||
}
|
||||
}
|
||||
|
||||
private void handleRecordedScript(final String script) {
|
||||
if (Looper.myLooper() == Looper.getMainLooper()) {
|
||||
showRecordHandleDialog(script);
|
||||
} else {
|
||||
App.getApp().getUiHandler().post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
showRecordHandleDialog(script);
|
||||
}
|
||||
});
|
||||
App.getApp().getUiHandler().post(() -> showRecordHandleDialog(script));
|
||||
}
|
||||
}
|
||||
|
||||
private void handleRecordedFile(final String path) {
|
||||
if (Looper.myLooper() != Looper.getMainLooper()) {
|
||||
App.getApp().getUiHandler().post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
handleRecordedFile(path);
|
||||
}
|
||||
});
|
||||
App.getApp().getUiHandler().post(() -> handleRecordedFile(path));
|
||||
return;
|
||||
}
|
||||
new ScriptOperations(mContext, null)
|
||||
@@ -200,25 +166,17 @@ public class GlobalRecorder implements Recorder.OnStateChangedListener {
|
||||
DialogUtils.showDialog(new ThemeColorMaterialDialogBuilder(mContext)
|
||||
.title(R.string.text_recorded)
|
||||
.items(getString(R.string.text_new_file), getString(R.string.text_copy_to_clip))
|
||||
.itemsCallback(new MaterialDialog.ListCallback() {
|
||||
@Override
|
||||
public void onSelection(MaterialDialog dialog, View itemView, int position, CharSequence text) {
|
||||
if (position == 0) {
|
||||
new ScriptOperations(mContext, null)
|
||||
.newScriptFileForScript(script);
|
||||
} else {
|
||||
ClipboardUtil.setClip(mContext, script);
|
||||
Toast.makeText(mContext, R.string.text_already_copy_to_clip, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
.itemsCallback((dialog, itemView, position, text) -> {
|
||||
if (position == 0) {
|
||||
new ScriptOperations(mContext, null)
|
||||
.newScriptFileForScript(script);
|
||||
} else {
|
||||
ClipboardUtil.setClip(mContext, script);
|
||||
Toast.makeText(mContext, R.string.text_already_copy_to_clip, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
})
|
||||
.negativeText(R.string.text_cancel)
|
||||
.onNegative(new MaterialDialog.SingleButtonCallback() {
|
||||
@Override
|
||||
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
})
|
||||
.onNegative((dialog, which) -> dialog.dismiss())
|
||||
.canceledOnTouchOutside(false)
|
||||
.build());
|
||||
}
|
||||
@@ -22,7 +22,7 @@ public class AccessibilityServiceTool {
|
||||
private static final Class<AccessibilityService> sAccessibilityServiceClass = AccessibilityService.class;
|
||||
|
||||
public static void enableAccessibilityService() {
|
||||
if (Pref.enableAccessibilityServiceByRoot()) {
|
||||
if (Pref.shouldEnableAccessibilityServiceByRoot()) {
|
||||
if (!enableAccessibilityServiceByRoot(sAccessibilityServiceClass)) {
|
||||
goToAccessibilitySetting();
|
||||
}
|
||||
@@ -72,7 +72,7 @@ public class AccessibilityServiceTool {
|
||||
|
||||
public static void enableAccessibilityServiceByRootIfNeeded() {
|
||||
if (AccessibilityService.getInstance() == null)
|
||||
if (Pref.enableAccessibilityServiceByRoot()) {
|
||||
if (Pref.shouldEnableAccessibilityServiceByRoot()) {
|
||||
AccessibilityServiceTool.enableAccessibilityServiceByRoot(sAccessibilityServiceClass);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +103,11 @@ public class BuildActivity extends BaseActivity implements AutoJsApkBuilder.Prog
|
||||
|
||||
private void setupWithSourceFile(ScriptFile file) {
|
||||
mSourcePath.setText(file.getPath());
|
||||
mOutputPath.setText(file.getParent());
|
||||
String dir = file.getParent();
|
||||
if (dir.startsWith(getFilesDir().getPath())) {
|
||||
dir = StorageFileProvider.DEFAULT_DIRECTORY_PATH;
|
||||
}
|
||||
mOutputPath.setText(dir);
|
||||
mAppName.setText(file.getSimplifiedName());
|
||||
mPackageName.setText(getString(R.string.format_default_package_name, System.currentTimeMillis()));
|
||||
}
|
||||
|
||||
@@ -36,12 +36,7 @@ public class NotAskAgainDialog extends MaterialDialog {
|
||||
super(context);
|
||||
mKeyRemind = key;
|
||||
readRemindStatus();
|
||||
checkBoxPrompt(context.getString(R.string.text_do_not_remind_again), false, new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
setRemindState(!isChecked);
|
||||
}
|
||||
});
|
||||
checkBoxPrompt(context.getString(R.string.text_do_not_remind_again), false, (buttonView, isChecked) -> setRemindState(!isChecked));
|
||||
}
|
||||
|
||||
public MaterialDialog show() {
|
||||
|
||||
@@ -5,7 +5,6 @@ import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Toast;
|
||||
|
||||
@@ -20,9 +19,10 @@ import com.stardust.floatingcircularactionmenu.CircularActionMenuFloaty;
|
||||
import com.stardust.scriptdroid.R;
|
||||
import com.stardust.scriptdroid.accessibility.AccessibilityService;
|
||||
import com.stardust.scriptdroid.autojs.AutoJs;
|
||||
import com.stardust.scriptdroid.autojs.record.GlobalRecorder;
|
||||
import com.stardust.scriptdroid.autojs.record.GlobalActionRecorder;
|
||||
import com.stardust.scriptdroid.storage.file.StorageFileProvider;
|
||||
import com.stardust.scriptdroid.tool.AccessibilityServiceTool;
|
||||
import com.stardust.scriptdroid.ui.common.NotAskAgainDialog;
|
||||
import com.stardust.scriptdroid.ui.floating.layoutinspector.LayoutBoundsFloatyWindow;
|
||||
import com.stardust.scriptdroid.ui.floating.layoutinspector.LayoutHierarchyFloatyWindow;
|
||||
import com.stardust.scriptdroid.ui.main.MainActivity_;
|
||||
@@ -30,6 +30,7 @@ import com.stardust.scriptdroid.ui.main.scripts.ScriptListView;
|
||||
import com.stardust.theme.dialog.ThemeColorMaterialDialogBuilder;
|
||||
import com.stardust.util.ClipboardUtil;
|
||||
import com.stardust.view.accessibility.LayoutInspector;
|
||||
import com.stericson.RootShell.RootShell;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
@@ -71,7 +72,7 @@ public class CircularMenu implements Recorder.OnStateChangedListener {
|
||||
private int mState;
|
||||
private ImageView mActionViewIcon;
|
||||
private Context mContext;
|
||||
private GlobalRecorder mRecorder;
|
||||
private GlobalActionRecorder mRecorder;
|
||||
private MaterialDialog mSettingsDialog;
|
||||
private String mRunningPackage, mRunningActivity;
|
||||
|
||||
@@ -79,7 +80,7 @@ public class CircularMenu implements Recorder.OnStateChangedListener {
|
||||
mContext = new ContextThemeWrapper(context, R.style.AppTheme);
|
||||
initFloaty();
|
||||
setupListeners();
|
||||
mRecorder = GlobalRecorder.getSingleton(context);
|
||||
mRecorder = GlobalActionRecorder.getSingleton(context);
|
||||
mRecorder.addOnStateChangedListener(this);
|
||||
}
|
||||
|
||||
@@ -138,7 +139,18 @@ public class CircularMenu implements Recorder.OnStateChangedListener {
|
||||
@OnClick(R.id.record)
|
||||
void startRecord() {
|
||||
mWindow.collapse();
|
||||
mRecorder.start();
|
||||
if (!RootShell.isRootAvailable()) {
|
||||
new NotAskAgainDialog.Builder(mContext, "root")
|
||||
.title(R.string.text_device_not_rooted)
|
||||
.content(R.string.prompt_device_not_rooted)
|
||||
.neutralText(R.string.text_device_rooted)
|
||||
.positiveText(R.string.ok)
|
||||
.onNeutral(((dialog, which) -> mRecorder.start()))
|
||||
.show();
|
||||
} else {
|
||||
mRecorder.start();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void setState(int state) {
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.stardust.scriptdroid.ui.main.drawer;
|
||||
|
||||
import android.app.NotificationManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
@@ -248,7 +246,7 @@ public class DrawerFragment extends android.support.v4.app.Fragment {
|
||||
}
|
||||
|
||||
private void enableAccessibilityServiceByRootIfNeeded() {
|
||||
Observable.fromCallable(() -> Pref.enableAccessibilityServiceByRoot() && !isAccessibilityServiceEnabled())
|
||||
Observable.fromCallable(() -> Pref.shouldEnableAccessibilityServiceByRoot() && !isAccessibilityServiceEnabled())
|
||||
.subscribeOn(Schedulers.computation())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(needed -> {
|
||||
@@ -336,7 +334,7 @@ public class DrawerFragment extends android.support.v4.app.Fragment {
|
||||
}
|
||||
|
||||
private void enableAccessibilityService() {
|
||||
if (!Pref.enableAccessibilityServiceByRoot()) {
|
||||
if (!Pref.shouldEnableAccessibilityServiceByRoot()) {
|
||||
AccessibilityServiceTool.goToAccessibilitySetting();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -106,61 +106,18 @@ public class SettingsActivity extends BaseActivity {
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
ACTION_MAP = new MapEntries<String, Runnable>()
|
||||
.entry(getString(R.string.text_theme_color), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
selectThemeColor(getActivity());
|
||||
}
|
||||
})
|
||||
.entry(getString(R.string.text_reset_background), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// EventBus.getDefault().post(new MessageEvent(MainActivity.MESSAGE_CLEAR_BACKGROUND_SETTINGS));
|
||||
Toast.makeText(getActivity(), R.string.text_already_reset, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
})
|
||||
.entry(getString(R.string.show_ad), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
SplashActivity_.intent(getActivity())
|
||||
.extra(SplashActivity.NOT_START_MAIN_ACTIVITY, true)
|
||||
.extra(SplashActivity.FORCE_SHOW_AD, true)
|
||||
.start();
|
||||
}
|
||||
})
|
||||
.entry(getString(R.string.text_check_for_updates), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
new UpdateCheckDialog(getActivity())
|
||||
.show();
|
||||
}
|
||||
})
|
||||
.entry(getString(R.string.text_issue_report), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
startActivity(new Intent(getActivity(), IssueReporterActivity.class).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
|
||||
}
|
||||
})
|
||||
.entry(getString(R.string.text_join_qq_group), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!IntentUtil.joinQQGroup(getActivity(), "-7riBQuwFUUqdgYL5vFeIdBfH4H9m-Uj")) {
|
||||
Toast.makeText(getActivity(), R.string.text_mobile_qq_not_installed, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
})
|
||||
.entry(getString(R.string.text_about_me_and_repo), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
startActivity(new Intent(getActivity(), AboutActivity_.class).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
|
||||
}
|
||||
})
|
||||
.entry(getString(R.string.text_licenses), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
showLicenseDialog();
|
||||
}
|
||||
.entry(getString(R.string.text_theme_color), () -> selectThemeColor(getActivity()))
|
||||
.entry(getString(R.string.show_ad), () -> {
|
||||
SplashActivity_.intent(getActivity())
|
||||
.extra(SplashActivity.NOT_START_MAIN_ACTIVITY, true)
|
||||
.extra(SplashActivity.FORCE_SHOW_AD, true)
|
||||
.start();
|
||||
})
|
||||
.entry(getString(R.string.text_check_for_updates), () -> new UpdateCheckDialog(getActivity())
|
||||
.show())
|
||||
.entry(getString(R.string.text_issue_report), () -> startActivity(new Intent(getActivity(), IssueReporterActivity.class).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)))
|
||||
.entry(getString(R.string.text_about_me_and_repo), () -> startActivity(new Intent(getActivity(), AboutActivity_.class).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)))
|
||||
.entry(getString(R.string.text_licenses), () -> showLicenseDialog())
|
||||
.map();
|
||||
}
|
||||
|
||||
|
||||
@@ -331,4 +331,7 @@
|
||||
<string name="format_default_package_name" formatted="true">com.example.script%d</string>
|
||||
<string name="text_should_not_be_empty">不能为空</string>
|
||||
<string name="text_icon">图标</string>
|
||||
<string name="text_device_not_rooted">设备没有root</string>
|
||||
<string name="prompt_device_not_rooted">监测到您的设备没有root, 录制脚本需要root权限, 是否继续?</string>
|
||||
<string name="text_device_rooted">仍要录制</string>
|
||||
</resources>
|
||||
|
||||
@@ -88,10 +88,6 @@
|
||||
android:layout="@layout/preference_custom"
|
||||
android:title="@string/text_theme_color"
|
||||
/>
|
||||
<Preference
|
||||
android:layout="@layout/preference_custom"
|
||||
android:title="@string/text_reset_background"
|
||||
/>
|
||||
</com.stardust.theme.preference.ThemeColorPreferenceCategory>
|
||||
|
||||
<com.stardust.theme.preference.ThemeColorPreferenceCategory
|
||||
|
||||
@@ -55,7 +55,8 @@ dependencies {
|
||||
compile 'com.squareup.okhttp3:okhttp:3.9.0'
|
||||
//JDeferred
|
||||
compile 'org.jdeferred:jdeferred-android-aar:1.2.6'
|
||||
|
||||
//RootShell
|
||||
compile 'com.github.Stericson:RootShell:1.6'
|
||||
// Gson
|
||||
compile 'com.google.code.gson:gson:2.8.0'
|
||||
// Terminal emulator
|
||||
|
||||
32
autojs/src/main/java/com/stardust/autojs/Pref.java
Normal file
32
autojs/src/main/java/com/stardust/autojs/Pref.java
Normal file
@@ -0,0 +1,32 @@
|
||||
package com.stardust.autojs;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/12/8.
|
||||
*/
|
||||
|
||||
public class Pref {
|
||||
|
||||
|
||||
private static Pref sInstance;
|
||||
private SharedPreferences mSharedPreferences;
|
||||
|
||||
public Pref(Context context) {
|
||||
mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
}
|
||||
|
||||
public static void setInstance(Pref instance) {
|
||||
if (sInstance != null)
|
||||
throw new IllegalStateException();
|
||||
sInstance = instance;
|
||||
}
|
||||
|
||||
public static Pref getInstance() {
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
package="com.stardust.auojs.inrt">
|
||||
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
|
||||
@@ -24,9 +25,11 @@
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity android:name=".SettingsActivity"/>
|
||||
|
||||
<service
|
||||
android:name="com.stardust.view.accessibility.AccessibilityService"
|
||||
android:label="@string/_app_name"
|
||||
android:name=".rt.AccessibilityService"
|
||||
android:label="inrt"
|
||||
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
|
||||
<intent-filter>
|
||||
<action android:name="android.accessibilityservice.AccessibilityService"/>
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
auto();
|
||||
toast(files.read("/sdcard/1.txt"));
|
||||
@@ -4,6 +4,7 @@ import android.app.Application;
|
||||
import android.app.Fragment;
|
||||
|
||||
import com.stardust.auojs.inrt.rt.AutoJs;
|
||||
import com.stardust.auojs.inrt.rt.GlobalKeyObserver;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/7/1.
|
||||
@@ -22,6 +23,7 @@ public class App extends Application {
|
||||
super.onCreate();
|
||||
sApp = this;
|
||||
AutoJs.initInstance(this);
|
||||
GlobalKeyObserver.init();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,20 +1,23 @@
|
||||
package com.stardust.auojs.inrt;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.RequiresApi;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import com.stardust.auojs.inrt.rt.AutoJs;
|
||||
import com.stardust.autojs.core.console.ConsoleView;
|
||||
import com.stardust.autojs.core.console.StardustConsole;
|
||||
import com.stardust.autojs.script.StringScriptSource;
|
||||
import com.stardust.pio.PFile;
|
||||
import com.stardust.pio.PFiles;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -24,19 +27,22 @@ import static android.content.pm.PackageManager.PERMISSION_GRANTED;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
private static final int PERMISSION_REQUEST_CODE = 1209;
|
||||
private static final int PERMISSION_REQUEST_CODE = 11186;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setupView();
|
||||
checkPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
checkPermission(Manifest.permission.READ_EXTERNAL_STORAGE);
|
||||
}
|
||||
|
||||
private void setupView() {
|
||||
ConsoleView consoleView = new ConsoleView(this);
|
||||
setContentView(R.layout.activity_main);
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
ConsoleView consoleView = (ConsoleView) findViewById(R.id.console);
|
||||
consoleView.setConsole((StardustConsole) AutoJs.getInstance().getGlobalConsole());
|
||||
setContentView(consoleView);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -50,24 +56,29 @@ public class MainActivity extends AppCompatActivity {
|
||||
AutoJs.getInstance().getGlobalConsole().log(e);
|
||||
}
|
||||
}).start();
|
||||
if(!Pref.shouldShowMainActivity()){
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
System.out.println(PFiles.read("/sdcard/1.txt"));
|
||||
runScript();
|
||||
}
|
||||
|
||||
protected void checkPermission(String... permissions) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
String[] requestPermissions = getRequestPermissions(permissions);
|
||||
if (requestPermissions.length > 0) {
|
||||
requestPermissions(requestPermissions, PERMISSION_REQUEST_CODE);
|
||||
return;
|
||||
}else {
|
||||
runScript();
|
||||
}
|
||||
} else {
|
||||
int[] grantResults = new int[permissions.length];
|
||||
Arrays.fill(grantResults, PERMISSION_GRANTED);
|
||||
onRequestPermissionsResult(PERMISSION_REQUEST_CODE, permissions, grantResults);
|
||||
}
|
||||
int[] grantResults = new int[permissions.length];
|
||||
Arrays.fill(grantResults, PERMISSION_GRANTED);
|
||||
onRequestPermissionsResult(PERMISSION_REQUEST_CODE, permissions, grantResults);
|
||||
}
|
||||
|
||||
|
||||
@@ -82,4 +93,15 @@ public class MainActivity extends AppCompatActivity {
|
||||
return list.toArray(new String[list.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
startActivity(new Intent(this, SettingsActivity.class));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.menu_main, menu);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
39
inrt/src/main/java/com/stardust/auojs/inrt/Pref.java
Normal file
39
inrt/src/main/java/com/stardust/auojs/inrt/Pref.java
Normal file
@@ -0,0 +1,39 @@
|
||||
package com.stardust.auojs.inrt;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/12/8.
|
||||
*/
|
||||
|
||||
public class Pref {
|
||||
|
||||
private static SharedPreferences sPreferences;
|
||||
|
||||
public static SharedPreferences getPreferences() {
|
||||
if (sPreferences == null)
|
||||
sPreferences = PreferenceManager.getDefaultSharedPreferences(App.getApp());
|
||||
return sPreferences;
|
||||
}
|
||||
|
||||
public static boolean isStableModeEnabled() {
|
||||
return getPreferences().getBoolean(getString(R.string.key_stable_mode), false);
|
||||
}
|
||||
|
||||
private static String getString(int res) {
|
||||
return App.getApp().getString(res);
|
||||
}
|
||||
|
||||
public static boolean shouldEnableAccessibilityServiceByRoot() {
|
||||
return getPreferences().getBoolean(getString(R.string.key_enable_accessibility_service_by_root), false);
|
||||
}
|
||||
|
||||
public static boolean shouldShowMainActivity() {
|
||||
return !getPreferences().getBoolean(getString(R.string.key_dont_show_main_activity), false);
|
||||
}
|
||||
|
||||
public static boolean shouldStopAllScriptsWhenVolumeUp() {
|
||||
return getPreferences().getBoolean(getString(R.string.key_use_volume_control_running), true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.stardust.auojs.inrt;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceFragment;
|
||||
import android.preference.PreferenceScreen;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.View;
|
||||
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/12/8.
|
||||
*/
|
||||
|
||||
public class SettingsActivity extends AppCompatActivity {
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setupViews();
|
||||
}
|
||||
|
||||
private void setupViews() {
|
||||
setContentView(R.layout.activity_settings);
|
||||
getFragmentManager().beginTransaction().replace(R.id.fragment_setting, new PreferenceFragment()).commit();
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
toolbar.setTitle(R.string.text_settings);
|
||||
toolbar.setNavigationOnClickListener(v -> finish());
|
||||
setSupportActionBar(toolbar);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
|
||||
public static class PreferenceFragment extends android.preference.PreferenceFragment {
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.preference);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
|
||||
return super.onPreferenceTreeClick(preferenceScreen, preference);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.stardust.auojs.inrt.rt;
|
||||
|
||||
import android.accessibilityservice.AccessibilityServiceInfo;
|
||||
|
||||
import com.stardust.auojs.inrt.Pref;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/12/8.
|
||||
*/
|
||||
|
||||
public class AccessibilityService extends com.stardust.view.accessibility.AccessibilityService {
|
||||
|
||||
|
||||
@Override
|
||||
protected void onServiceConnected() {
|
||||
AccessibilityServiceInfo serviceInfo = getServiceInfo();
|
||||
if (Pref.isStableModeEnabled()) {
|
||||
serviceInfo.flags &= ~AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS;
|
||||
} else {
|
||||
serviceInfo.flags |= AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS;
|
||||
}
|
||||
setServiceInfo(serviceInfo);
|
||||
super.onServiceConnected();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
|
||||
import com.stardust.auojs.inrt.App;
|
||||
import com.stardust.auojs.inrt.Pref;
|
||||
import com.stardust.auojs.inrt.R;
|
||||
import com.stardust.autojs.runtime.exception.ScriptException;
|
||||
import com.stardust.view.accessibility.AccessibilityService;
|
||||
@@ -32,6 +33,7 @@ public class AutoJs extends com.stardust.autojs.AutoJs {
|
||||
super(context);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void ensureAccessibilityServiceEnabled() {
|
||||
if (AccessibilityService.getInstance() != null) {
|
||||
@@ -41,7 +43,11 @@ public class AutoJs extends com.stardust.autojs.AutoJs {
|
||||
if (AccessibilityServiceUtils.isAccessibilityServiceEnabled(getApplication(), AccessibilityService.class)) {
|
||||
errorMessage = App.getApp().getString(R.string.text_auto_operate_service_enabled_but_not_running);
|
||||
} else {
|
||||
if (!AccessibilityServiceTool.enableAccessibilityServiceByRootAndWaitFor(getApplication(), 2000)) {
|
||||
if (Pref.shouldEnableAccessibilityServiceByRoot()) {
|
||||
if (!AccessibilityServiceTool.enableAccessibilityServiceByRootAndWaitFor(getApplication(), 2000)) {
|
||||
errorMessage = App.getApp().getString(R.string.text_enable_accessibility_service_by_root_timeout);
|
||||
}
|
||||
} else {
|
||||
errorMessage = App.getApp().getString(R.string.text_no_accessibility_permission);
|
||||
}
|
||||
}
|
||||
@@ -51,6 +57,7 @@ public class AutoJs extends com.stardust.autojs.AutoJs {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected Application getApplication() {
|
||||
return App.getApp();
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
package com.stardust.auojs.inrt.rt;
|
||||
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
|
||||
import com.stardust.auojs.inrt.Pref;
|
||||
import com.stardust.autojs.core.inputevent.InputEventObserver;
|
||||
import com.stardust.autojs.core.inputevent.ShellKeyObserver;
|
||||
import com.stardust.view.accessibility.AccessibilityService;
|
||||
import com.stardust.view.accessibility.OnKeyListener;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/8/14.
|
||||
*/
|
||||
|
||||
public class GlobalKeyObserver implements OnKeyListener, ShellKeyObserver.KeyListener {
|
||||
|
||||
|
||||
private static final String LOG_TAG = "GlobalKeyObserver";
|
||||
private static GlobalKeyObserver sSingleton = new GlobalKeyObserver();
|
||||
private boolean mVolumeDownFromShell, mVolumeDownFromAccessibility;
|
||||
private boolean mVolumeUpFromShell, mVolumeUpFromAccessibility;
|
||||
|
||||
GlobalKeyObserver() {
|
||||
AccessibilityService.getStickOnKeyObserver()
|
||||
.addListener(this);
|
||||
ShellKeyObserver observer = new ShellKeyObserver();
|
||||
observer.setKeyListener(this);
|
||||
InputEventObserver.getGlobal().addListener(observer);
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
//do nothing
|
||||
}
|
||||
|
||||
public void onVolumeUp() {
|
||||
Log.d(LOG_TAG, "onVolumeUp at " + System.currentTimeMillis());
|
||||
if (Pref.shouldStopAllScriptsWhenVolumeUp()) {
|
||||
AutoJs.getInstance().getScriptEngineService().stopAllAndToast();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onKeyEvent(int keyCode, KeyEvent event) {
|
||||
if (event.getAction() != KeyEvent.ACTION_UP)
|
||||
return;
|
||||
if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
|
||||
if (mVolumeDownFromShell) {
|
||||
mVolumeDownFromShell = false;
|
||||
return;
|
||||
}
|
||||
mVolumeUpFromAccessibility = true;
|
||||
onVolumeDown();
|
||||
} else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
|
||||
if (mVolumeUpFromShell) {
|
||||
mVolumeUpFromShell = false;
|
||||
return;
|
||||
}
|
||||
mVolumeUpFromAccessibility = true;
|
||||
onVolumeUp();
|
||||
}
|
||||
}
|
||||
|
||||
public void onVolumeDown() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onKeyDown(String keyName) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onKeyUp(String keyName) {
|
||||
if ("KEY_VOLUMEUP".equals(keyName)) {
|
||||
if (mVolumeUpFromAccessibility) {
|
||||
mVolumeUpFromAccessibility = false;
|
||||
return;
|
||||
}
|
||||
mVolumeUpFromShell = true;
|
||||
onVolumeUp();
|
||||
} else if ("KEY_VOLUMEDOWN".equals(keyName)) {
|
||||
if (mVolumeDownFromAccessibility) {
|
||||
mVolumeDownFromAccessibility = false;
|
||||
return;
|
||||
}
|
||||
mVolumeDownFromShell = true;
|
||||
onVolumeDown();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context="com.stardust.auojs.inrt.MainActivity">
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@android:color/white"
|
||||
android:fitsSystemWindows="true"
|
||||
android:orientation="vertical">
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
<com.stardust.autojs.core.console.ConsoleView
|
||||
android:id="@+id/console"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
</LinearLayout>
|
||||
27
inrt/src/main/res/layout/activity_settings.xml
Normal file
27
inrt/src/main/res/layout/activity_settings.xml
Normal file
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@android:color/white"
|
||||
android:fitsSystemWindows="true"
|
||||
android:orientation="vertical">
|
||||
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/fragment_setting"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@android:color/white"/>
|
||||
</LinearLayout>
|
||||
7
inrt/src/main/res/menu/menu_main.xml
Normal file
7
inrt/src/main/res/menu/menu_main.xml
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item
|
||||
android:id="@+id/settings"
|
||||
android:title="@string/text_settings"/>
|
||||
</menu>
|
||||
@@ -3,4 +3,20 @@
|
||||
<string name="text_no_accessibility_permission">无障碍服务未启动</string>
|
||||
<string name="text_auto_operate_service_enabled_but_not_running">无障碍服务已启用但没有运行,您可以尝试重新启用或重启手机</string>
|
||||
<string name="text_enable_accessibility_service_by_root_timeout">使用root权限启用无障碍服务失败</string>
|
||||
<string name="text_settings">设置</string>
|
||||
<string name="text_script_running">脚本运行</string>
|
||||
|
||||
<string name="key_use_volume_control_running">key_use_volume_control_running</string>
|
||||
<string name="key_enable_accessibility_service_by_root">key_enable_accessibility_service_by_root</string>
|
||||
<string name="text_use_volume_to_stop_running">音量上键停止所有脚本</string>
|
||||
<string name="summary_enable_accessibility_service_by_root">开启后运行脚本会使用Root权限自动开启无障碍服务</string>
|
||||
<string name="text_enable_accessibility_service_by_root">使用Root权限自动启用服务</string>
|
||||
<string name="key_stable_mode">key_stable_mode</string>
|
||||
<string name="summary_stable_mode">开启后布局分析更稳定,但小部分脚本可能无法正常运行。重启无障碍服务生效</string>
|
||||
<string name="text_stable_mode">稳定模式</string>
|
||||
<string name="text_accessibility_service">无障碍服务</string>
|
||||
<string name="text_dont_show_main_activity">不显示主界面</string>
|
||||
<string name="key_dont_show_main_activity">key_dont_show_main_activity</string>
|
||||
<string name="summary_dont_show_main_activity">打开应用后直接运行脚本</string>
|
||||
<string name="text_others">其他</string>
|
||||
</resources>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<resources>
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
|
||||
45
inrt/src/main/res/xml/preference.xml
Normal file
45
inrt/src/main/res/xml/preference.xml
Normal file
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="@string/text_script_running">
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="true"
|
||||
android:key="@string/key_use_volume_control_running"
|
||||
android:title="@string/text_use_volume_to_stop_running"/>
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="@string/key_dont_show_main_activity"
|
||||
android:summary="@string/summary_dont_show_main_activity"
|
||||
android:title="@string/text_dont_show_main_activity"/>
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="@string/text_accessibility_service">
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="@string/key_enable_accessibility_service_by_root"
|
||||
android:summary="@string/summary_enable_accessibility_service_by_root"
|
||||
android:title="@string/text_enable_accessibility_service_by_root"/>
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="@string/key_stable_mode"
|
||||
android:summary="@string/summary_stable_mode"
|
||||
android:title="@string/text_stable_mode"/>
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="@string/text_others">
|
||||
|
||||
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
|
||||
</PreferenceScreen>
|
||||
Reference in New Issue
Block a user