move
'record toast' to prefs
This commit is contained in:
@@ -124,4 +124,8 @@ public class Pref {
|
|||||||
public static boolean isRecordWithRootEnabled() {
|
public static boolean isRecordWithRootEnabled() {
|
||||||
return def().getBoolean(getString(R.string.key_record_with_root), false);
|
return def().getBoolean(getString(R.string.key_record_with_root), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isRecordToastEnabled() {
|
||||||
|
return def().getBoolean(getString(R.string.key_record_toast), true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,11 +14,13 @@ import com.stardust.app.DialogUtils;
|
|||||||
import com.stardust.autojs.core.inputevent.InputEventCodes;
|
import com.stardust.autojs.core.inputevent.InputEventCodes;
|
||||||
import com.stardust.autojs.core.inputevent.ShellKeyObserver;
|
import com.stardust.autojs.core.inputevent.ShellKeyObserver;
|
||||||
import com.stardust.autojs.core.record.Recorder;
|
import com.stardust.autojs.core.record.Recorder;
|
||||||
|
import com.stardust.autojs.core.record.accessibility.AccessibilityActionRecorder;
|
||||||
import com.stardust.autojs.core.record.inputevent.TouchRecorder;
|
import com.stardust.autojs.core.record.inputevent.TouchRecorder;
|
||||||
import com.stardust.autojs.runtime.api.Shell;
|
import com.stardust.autojs.runtime.api.Shell;
|
||||||
import com.stardust.scriptdroid.App;
|
import com.stardust.scriptdroid.App;
|
||||||
import com.stardust.scriptdroid.Pref;
|
import com.stardust.scriptdroid.Pref;
|
||||||
import com.stardust.scriptdroid.R;
|
import com.stardust.scriptdroid.R;
|
||||||
|
import com.stardust.scriptdroid.accessibility.AccessibilityEventHelper;
|
||||||
import com.stardust.scriptdroid.autojs.AutoJs;
|
import com.stardust.scriptdroid.autojs.AutoJs;
|
||||||
import com.stardust.scriptdroid.ui.common.ScriptOperations;
|
import com.stardust.scriptdroid.ui.common.ScriptOperations;
|
||||||
import com.stardust.theme.dialog.ThemeColorMaterialDialogBuilder;
|
import com.stardust.theme.dialog.ThemeColorMaterialDialogBuilder;
|
||||||
@@ -26,6 +28,9 @@ import com.stardust.util.ClipboardUtil;
|
|||||||
import com.stardust.view.accessibility.AccessibilityService;
|
import com.stardust.view.accessibility.AccessibilityService;
|
||||||
import com.stardust.view.accessibility.OnKeyListener;
|
import com.stardust.view.accessibility.OnKeyListener;
|
||||||
|
|
||||||
|
import org.greenrobot.eventbus.EventBus;
|
||||||
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
|
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -59,6 +64,7 @@ public class GlobalRecorder implements Recorder.OnStateChangedListener {
|
|||||||
mContext = new ContextThemeWrapper(context.getApplicationContext(), R.style.AppTheme);
|
mContext = new ContextThemeWrapper(context.getApplicationContext(), R.style.AppTheme);
|
||||||
mTouchRecorder = new TouchRecorder(context);
|
mTouchRecorder = new TouchRecorder(context);
|
||||||
addKeyListeners();
|
addKeyListeners();
|
||||||
|
EventBus.getDefault().register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addKeyListeners() {
|
private void addKeyListeners() {
|
||||||
@@ -90,6 +96,9 @@ public class GlobalRecorder implements Recorder.OnStateChangedListener {
|
|||||||
|
|
||||||
|
|
||||||
private void onVolumeDown() {
|
private void onVolumeDown() {
|
||||||
|
if (!Pref.isRecordVolumeControlEnable()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (System.currentTimeMillis() - mLastVolumeDownEventTime < 300) {
|
if (System.currentTimeMillis() - mLastVolumeDownEventTime < 300) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -147,7 +156,8 @@ public class GlobalRecorder implements Recorder.OnStateChangedListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
App.getApp().getUiHandler().toast(R.string.text_start_record);
|
if (Pref.isRecordToastEnabled())
|
||||||
|
App.getApp().getUiHandler().toast(R.string.text_start_record);
|
||||||
for (Recorder.OnStateChangedListener listener : mOnStateChangedListeners) {
|
for (Recorder.OnStateChangedListener listener : mOnStateChangedListeners) {
|
||||||
listener.onStart();
|
listener.onStart();
|
||||||
}
|
}
|
||||||
@@ -182,6 +192,13 @@ public class GlobalRecorder implements Recorder.OnStateChangedListener {
|
|||||||
stop();
|
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) {
|
private void handleRecordedScript(final String script) {
|
||||||
if (Looper.myLooper() == Looper.getMainLooper()) {
|
if (Looper.myLooper() == Looper.getMainLooper()) {
|
||||||
showRecordHandleDialog(script);
|
showRecordHandleDialog(script);
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ public class RecordNavigatorContent implements NavigatorContent, Recorder.OnStat
|
|||||||
PrefSwitch mRecordedByRootSwitch;
|
PrefSwitch mRecordedByRootSwitch;
|
||||||
|
|
||||||
@BindView(R.id.sw_record_toast)
|
@BindView(R.id.sw_record_toast)
|
||||||
SwitchCompat mRecordToastSwitch;
|
PrefSwitch mRecordToastSwitch;
|
||||||
|
|
||||||
@BindView(R.id.img_pause_or_resume)
|
@BindView(R.id.img_pause_or_resume)
|
||||||
ImageView mPauseOrResumeImage;
|
ImageView mPauseOrResumeImage;
|
||||||
@@ -163,13 +163,6 @@ public class RecordNavigatorContent implements NavigatorContent, Recorder.OnStat
|
|||||||
mRecorder.removeOnStateChangedListener(this);
|
mRecorder.removeOnStateChangedListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onAccessibilityActionRecordEvent(AccessibilityActionRecorder.AccessibilityActionRecordEvent event) {
|
|
||||||
if (mRecordToastSwitch.isChecked()) {
|
|
||||||
Toast.makeText(mContext, AccessibilityEventHelper.getEventTypeNameResId(event.getAccessibilityEvent()), Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
setState(Recorder.STATE_RECORDING);
|
setState(Recorder.STATE_RECORDING);
|
||||||
|
|||||||
@@ -62,13 +62,15 @@
|
|||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:padding="16dp">
|
android:padding="16dp">
|
||||||
|
|
||||||
<android.support.v7.widget.SwitchCompat
|
<com.stardust.widget.PrefSwitch
|
||||||
android:id="@+id/sw_record_toast"
|
android:id="@+id/sw_record_toast"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true"
|
||||||
android:textOff="@string/text_off"
|
android:textOff="@string/text_off"
|
||||||
android:textOn="@string/text_on"/>
|
android:textOn="@string/text_on"
|
||||||
|
app:defaultValue="true"
|
||||||
|
app:key="@string/key_record_toast"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
|||||||
@@ -217,6 +217,7 @@
|
|||||||
<string name="text_run_script">运行脚本</string>
|
<string name="text_run_script">运行脚本</string>
|
||||||
<string name="text_import_script">导入脚本文件</string>
|
<string name="text_import_script">导入脚本文件</string>
|
||||||
<string name="key_record_with_root">key_record_with_root</string>
|
<string name="key_record_with_root">key_record_with_root</string>
|
||||||
|
<string name="key_record_toast">key_record_toast</string>
|
||||||
|
|
||||||
|
|
||||||
<string-array name="record_control_keys">
|
<string-array name="record_control_keys">
|
||||||
|
|||||||
@@ -13,6 +13,11 @@
|
|||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:key="@string/key_record_with_root"
|
android:key="@string/key_record_with_root"
|
||||||
android:title="@string/text_record_with_root"/>
|
android:title="@string/text_record_with_root"/>
|
||||||
|
|
||||||
|
<com.stardust.theme.preference.ThemeColorSwitchPreference
|
||||||
|
android:defaultValue="true"
|
||||||
|
android:key="@string/key_record_toast"
|
||||||
|
android:title="@string/text_record_msg"/>
|
||||||
</com.stardust.theme.preference.ThemeColorPreferenceCategory>
|
</com.stardust.theme.preference.ThemeColorPreferenceCategory>
|
||||||
|
|
||||||
<com.stardust.theme.preference.ThemeColorPreferenceCategory android:title="@string/text_script_running">
|
<com.stardust.theme.preference.ThemeColorPreferenceCategory android:title="@string/text_script_running">
|
||||||
|
|||||||
Reference in New Issue
Block a user