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;
|
package com.stardust.scriptdroid.tool;
|
||||||
|
|
||||||
|
import com.stardust.autojs.core.util.ProcessShell;
|
||||||
import com.stericson.RootShell.RootShell;
|
import com.stericson.RootShell.RootShell;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -16,4 +17,29 @@ public class RootTool {
|
|||||||
return false;
|
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 Context mContext;
|
||||||
private GlobalActionRecorder mRecorder;
|
private GlobalActionRecorder mRecorder;
|
||||||
private MaterialDialog mSettingsDialog;
|
private MaterialDialog mSettingsDialog;
|
||||||
|
private MaterialDialog mLayoutInspectDialog;
|
||||||
private String mRunningPackage, mRunningActivity;
|
private String mRunningPackage, mRunningActivity;
|
||||||
private Deferred<NodeInfo, Void, Void> mCaptureDeferred;
|
private Deferred<NodeInfo, Void, Void> mCaptureDeferred;
|
||||||
|
|
||||||
@@ -182,10 +183,25 @@ public class CircularMenu implements Recorder.OnStateChangedListener, LayoutInsp
|
|||||||
mRecorder.stop();
|
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
|
@Optional
|
||||||
@OnClick(R.id.layout_bounds)
|
@OnClick(R.id.layout_bounds)
|
||||||
void showLayoutBounds() {
|
void showLayoutBounds() {
|
||||||
mWindow.collapse();
|
mLayoutInspectDialog.dismiss();
|
||||||
|
mLayoutInspectDialog = null;
|
||||||
if (!ensureCapture()) {
|
if (!ensureCapture()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -200,7 +216,8 @@ public class CircularMenu implements Recorder.OnStateChangedListener, LayoutInsp
|
|||||||
@Optional
|
@Optional
|
||||||
@OnClick(R.id.layout_hierarchy)
|
@OnClick(R.id.layout_hierarchy)
|
||||||
void showLayoutHierarchy() {
|
void showLayoutHierarchy() {
|
||||||
mWindow.collapse();
|
mLayoutInspectDialog.dismiss();
|
||||||
|
mLayoutInspectDialog = null;
|
||||||
if (!ensureCapture()) {
|
if (!ensureCapture()) {
|
||||||
return;
|
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
|
@Override
|
||||||
public void onCaptureAvailable(NodeInfo capture) {
|
public void onCaptureAvailable(NodeInfo capture) {
|
||||||
if (mCaptureDeferred != null && mCaptureDeferred.isPending())
|
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,
|
.item(R.id.class_name, R.drawable.ic_ali_android,
|
||||||
mContext.getString(R.string.text_current_activity) + mRunningActivity)
|
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.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)
|
.item(R.id.exit, R.drawable.ic_close_white_48dp, R.string.text_exit_floating_window)
|
||||||
.bindItemClick(this)
|
.bindItemClick(this)
|
||||||
.title(R.string.text_more)
|
.title(R.string.text_more)
|
||||||
@@ -265,6 +292,7 @@ public class CircularMenu implements Recorder.OnStateChangedListener, LayoutInsp
|
|||||||
AccessibilityServiceTool.enableAccessibilityService();
|
AccessibilityServiceTool.enableAccessibilityService();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void dismissSettingsDialog() {
|
private void dismissSettingsDialog() {
|
||||||
if (mSettingsDialog == null)
|
if (mSettingsDialog == null)
|
||||||
return;
|
return;
|
||||||
@@ -300,6 +328,12 @@ public class CircularMenu implements Recorder.OnStateChangedListener, LayoutInsp
|
|||||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
|
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Optional
|
||||||
|
@OnClick(R.id.pointer_location)
|
||||||
|
void togglePointerLocation() {
|
||||||
|
dismissSettingsDialog();
|
||||||
|
RootTool.togglePointerLocation();
|
||||||
|
}
|
||||||
|
|
||||||
@Optional
|
@Optional
|
||||||
@OnClick(R.id.exit)
|
@OnClick(R.id.exit)
|
||||||
|
|||||||
BIN
app/src/main/res/drawable-hdpi/ic_zoom_out_map_white_24dp.png
Normal file
BIN
app/src/main/res/drawable-hdpi/ic_zoom_out_map_white_24dp.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 326 B |
BIN
app/src/main/res/drawable-mdpi/ic_zoom_out_map_white_24dp.png
Normal file
BIN
app/src/main/res/drawable-mdpi/ic_zoom_out_map_white_24dp.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 235 B |
BIN
app/src/main/res/drawable-xhdpi/ic_zoom_out_map_white_24dp.png
Normal file
BIN
app/src/main/res/drawable-xhdpi/ic_zoom_out_map_white_24dp.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 332 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_zoom_out_map_white_24dp.png
Normal file
BIN
app/src/main/res/drawable-xxhdpi/ic_zoom_out_map_white_24dp.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 510 B |
BIN
app/src/main/res/drawable-xxxhdpi/ic_zoom_out_map_white_24dp.png
Normal file
BIN
app/src/main/res/drawable-xxxhdpi/ic_zoom_out_map_white_24dp.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 584 B |
@@ -29,26 +29,24 @@
|
|||||||
android:src="@drawable/ic_ali_record"/>
|
android:src="@drawable/ic_ali_record"/>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/layout_bounds"
|
android:id="@+id/layout_inspect"
|
||||||
android:layout_width="42dp"
|
android:layout_width="42dp"
|
||||||
android:layout_height="42dp"
|
android:layout_height="42dp"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:background="@drawable/circle_blue"
|
android:background="@drawable/circle_blue"
|
||||||
android:foreground="?selectableItemBackgroundBorderless"
|
android:foreground="?selectableItemBackgroundBorderless"
|
||||||
android:padding="8dp"
|
android:padding="8dp"
|
||||||
android:src="@drawable/ic_circular_menu_bounds"
|
android:src="@drawable/ic_circular_menu_bounds"/>
|
||||||
android:tint="@android:color/white"/>
|
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/layout_hierarchy"
|
android:id="@+id/stop_all_scripts"
|
||||||
android:layout_width="42dp"
|
android:layout_width="42dp"
|
||||||
android:layout_height="42dp"
|
android:layout_height="42dp"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:background="@drawable/circle_yellow"
|
android:background="@drawable/circle_yellow"
|
||||||
android:foreground="?selectableItemBackgroundBorderless"
|
android:foreground="?selectableItemBackgroundBorderless"
|
||||||
android:padding="10dp"
|
android:padding="8dp"
|
||||||
android:src="@drawable/ic_circular_menu_hierarchy"
|
android:src="@drawable/ic_close_white_48dp"/>
|
||||||
android:tint="@android:color/white"/>
|
|
||||||
|
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
@@ -59,8 +57,7 @@
|
|||||||
android:background="@drawable/circle_gray"
|
android:background="@drawable/circle_gray"
|
||||||
android:foreground="?selectableItemBackgroundBorderless"
|
android:foreground="?selectableItemBackgroundBorderless"
|
||||||
android:padding="8dp"
|
android:padding="8dp"
|
||||||
android:src="@drawable/ic_circular_menu_settings"
|
android:src="@drawable/ic_circular_menu_settings"/>
|
||||||
android:tint="@android:color/white"/>
|
|
||||||
|
|
||||||
|
|
||||||
</com.stardust.floatingcircularactionmenu.CircularActionMenu>
|
</com.stardust.floatingcircularactionmenu.CircularActionMenu>
|
||||||
@@ -8,4 +8,8 @@
|
|||||||
<item name="class_name" type="id"/>
|
<item name="class_name" type="id"/>
|
||||||
<item name="open_launcher" type="id"/>
|
<item name="open_launcher" type="id"/>
|
||||||
<item name="accessibility_service" type="id"/>
|
<item name="accessibility_service" type="id"/>
|
||||||
|
<item name="layout_bounds" type="id"/>
|
||||||
|
<item name="layout_hierarchy" type="id"/>
|
||||||
|
<item name="pointer_location" type="id"/>
|
||||||
|
<item name="disable_pointer_location" type="id"/>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -351,4 +351,8 @@
|
|||||||
<string name="error_regex_find_prev">正则表达式不能向前查找</string>
|
<string name="error_regex_find_prev">正则表达式不能向前查找</string>
|
||||||
<string name="text_notification">通知</string>
|
<string name="text_notification">通知</string>
|
||||||
<string name="apk_builder_plugin_version_too_low">打包插件版本过低,打包的应用可能无法正常运行。是否立即下载对应版本的打包插件?</string>
|
<string name="apk_builder_plugin_version_too_low">打包插件版本过低,打包的应用可能无法正常运行。是否立即下载对应版本的打包插件?</string>
|
||||||
|
<string name="text_inspect_layout_bounds">布局范围分析</string>
|
||||||
|
<string name="text_inspect_layout_hierarchy">布局层次分析</string>
|
||||||
|
<string name="text_inspect_layout">布局分析</string>
|
||||||
|
<string name="text_pointer_location">指针位置[Root]</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user