feat(ui): add pointer location and stop all scripts to circular menu
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.stardust.scriptdroid.tool;
|
||||
|
||||
import com.stardust.autojs.core.util.ProcessShell;
|
||||
import com.stericson.RootShell.RootShell;
|
||||
|
||||
/**
|
||||
@@ -16,4 +17,29 @@ public class RootTool {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static final String cmd = "enabled=$(settings get system pointer_location)\n" +
|
||||
"pkg=%s\n" +
|
||||
"if [[ $enabled == 1 ]]\n" +
|
||||
"then\n" +
|
||||
"settings put system pointer_location 0\n" +
|
||||
"else\n" +
|
||||
"settings put system pointer_location 1\n" +
|
||||
"fi\n";
|
||||
|
||||
public static void togglePointerLocation() {
|
||||
try {
|
||||
ProcessShell.execCommand(cmd, true);
|
||||
} catch (Exception ignored) {
|
||||
ignored.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void setPointerLocationEnabled(boolean enabled) {
|
||||
try {
|
||||
ProcessShell.execCommand("settings put system pointer_location " + (enabled ? 1 : 0), true);
|
||||
} catch (Exception ignored) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,6 +79,7 @@ public class CircularMenu implements Recorder.OnStateChangedListener, LayoutInsp
|
||||
private Context mContext;
|
||||
private GlobalActionRecorder mRecorder;
|
||||
private MaterialDialog mSettingsDialog;
|
||||
private MaterialDialog mLayoutInspectDialog;
|
||||
private String mRunningPackage, mRunningActivity;
|
||||
private Deferred<NodeInfo, Void, Void> mCaptureDeferred;
|
||||
|
||||
@@ -182,10 +183,25 @@ public class CircularMenu implements Recorder.OnStateChangedListener, LayoutInsp
|
||||
mRecorder.stop();
|
||||
}
|
||||
|
||||
@Optional
|
||||
@OnClick(R.id.layout_inspect)
|
||||
void inspectLayout() {
|
||||
mWindow.collapse();
|
||||
mLayoutInspectDialog = new OperationDialogBuilder(mContext)
|
||||
.item(R.id.layout_bounds, R.drawable.ic_circular_menu_bounds, R.string.text_inspect_layout_bounds)
|
||||
.item(R.id.layout_hierarchy, R.drawable.ic_circular_menu_hierarchy,
|
||||
R.string.text_inspect_layout_hierarchy)
|
||||
.bindItemClick(this)
|
||||
.title(R.string.text_inspect_layout)
|
||||
.build();
|
||||
DialogUtils.showDialog(mLayoutInspectDialog);
|
||||
}
|
||||
|
||||
@Optional
|
||||
@OnClick(R.id.layout_bounds)
|
||||
void showLayoutBounds() {
|
||||
mWindow.collapse();
|
||||
mLayoutInspectDialog.dismiss();
|
||||
mLayoutInspectDialog = null;
|
||||
if (!ensureCapture()) {
|
||||
return;
|
||||
}
|
||||
@@ -200,7 +216,8 @@ public class CircularMenu implements Recorder.OnStateChangedListener, LayoutInsp
|
||||
@Optional
|
||||
@OnClick(R.id.layout_hierarchy)
|
||||
void showLayoutHierarchy() {
|
||||
mWindow.collapse();
|
||||
mLayoutInspectDialog.dismiss();
|
||||
mLayoutInspectDialog = null;
|
||||
if (!ensureCapture()) {
|
||||
return;
|
||||
}
|
||||
@@ -212,6 +229,15 @@ public class CircularMenu implements Recorder.OnStateChangedListener, LayoutInsp
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Optional
|
||||
@OnClick(R.id.stop_all_scripts)
|
||||
void stopAllScripts() {
|
||||
mWindow.collapse();
|
||||
AutoJs.getInstance().getScriptEngineService().stopAllAndToast();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onCaptureAvailable(NodeInfo capture) {
|
||||
if (mCaptureDeferred != null && mCaptureDeferred.isPending())
|
||||
@@ -250,6 +276,7 @@ public class CircularMenu implements Recorder.OnStateChangedListener, LayoutInsp
|
||||
.item(R.id.class_name, R.drawable.ic_ali_android,
|
||||
mContext.getString(R.string.text_current_activity) + mRunningActivity)
|
||||
.item(R.id.open_launcher, R.drawable.ic_android_eat_js, R.string.text_open_main_activity)
|
||||
.item(R.id.pointer_location, R.drawable.ic_zoom_out_map_white_24dp, R.string.text_pointer_location)
|
||||
.item(R.id.exit, R.drawable.ic_close_white_48dp, R.string.text_exit_floating_window)
|
||||
.bindItemClick(this)
|
||||
.title(R.string.text_more)
|
||||
@@ -265,6 +292,7 @@ public class CircularMenu implements Recorder.OnStateChangedListener, LayoutInsp
|
||||
AccessibilityServiceTool.enableAccessibilityService();
|
||||
}
|
||||
|
||||
|
||||
private void dismissSettingsDialog() {
|
||||
if (mSettingsDialog == null)
|
||||
return;
|
||||
@@ -300,6 +328,12 @@ public class CircularMenu implements Recorder.OnStateChangedListener, LayoutInsp
|
||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
|
||||
}
|
||||
|
||||
@Optional
|
||||
@OnClick(R.id.pointer_location)
|
||||
void togglePointerLocation() {
|
||||
dismissSettingsDialog();
|
||||
RootTool.togglePointerLocation();
|
||||
}
|
||||
|
||||
@Optional
|
||||
@OnClick(R.id.exit)
|
||||
|
||||
Reference in New Issue
Block a user