make autojs module more independent
This commit is contained in:
@@ -13,8 +13,8 @@ import com.stardust.scriptdroid.R;
|
||||
import com.stardust.scriptdroid.autojs.AutoJs;
|
||||
import com.stardust.scriptdroid.external.floatingwindow.menu.HoverMenuService;
|
||||
import com.stardust.scriptdroid.external.floatingwindow.menu.layout_inspector.LayoutInspector;
|
||||
import com.stardust.scriptdroid.ui.main.MainActivity_;
|
||||
import com.stardust.util.ClipboardUtil;
|
||||
import com.stardust.scriptdroid.ui.main.MainActivity;
|
||||
import com.stardust.util.MessageEvent;
|
||||
import com.stardust.view.ViewBinder;
|
||||
import com.stardust.view.ViewBinding;
|
||||
@@ -82,7 +82,7 @@ public class MainMenuNavigatorContent implements NavigatorContent {
|
||||
|
||||
@ViewBinding.Click(R.id.open_launcher)
|
||||
private void openMainActivity() {
|
||||
App.getApp().startActivity(new Intent(App.getApp(), MainActivity.class)
|
||||
App.getApp().startActivity(new Intent(App.getApp(), MainActivity_.class)
|
||||
.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY | Intent.FLAG_ACTIVITY_NEW_TASK));
|
||||
HoverMenuService.postIntent(new Intent(HoverMenuService.ACTION_COLLAPSE_MENU));
|
||||
}
|
||||
@@ -95,7 +95,6 @@ public class MainMenuNavigatorContent implements NavigatorContent {
|
||||
|
||||
@Override
|
||||
public void onShown(@NonNull Navigator navigator) {
|
||||
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
|
||||
@@ -79,7 +79,7 @@ public class RecordNavigatorContent implements NavigatorContent, Recorder.OnStat
|
||||
HoverMenuService.getEventBus().register(this);
|
||||
App.getApp().getVolumeChangeObserver().addOnVolumeChangeListener(mOnVolumeChangeListener);
|
||||
if (Pref.hasRecordTrigger()) {
|
||||
mKeyObserver = new KeyObserver();
|
||||
mKeyObserver = new KeyObserver(mContext);
|
||||
mKeyObserver.startListening();
|
||||
mKeyObserver.setKeyListener(this);
|
||||
}
|
||||
@@ -134,7 +134,7 @@ public class RecordNavigatorContent implements NavigatorContent, Recorder.OnStat
|
||||
}
|
||||
|
||||
private void startRecord() {
|
||||
mRecorder = mRecordedByRootSwitch.isChecked() ? new TouchRecorder() : AutoJs.getInstance().getAccessibilityActionRecorder();
|
||||
mRecorder = mRecordedByRootSwitch.isChecked() ? new TouchRecorder(mContext) : AutoJs.getInstance().getAccessibilityActionRecorder();
|
||||
mRecorder.setOnStateChangedListener(this);
|
||||
mRecorder.start();
|
||||
setState(Recorder.STATE_RECORDING);
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package com.stardust.scriptdroid.external.floatingwindow.menu.layout_inspector;
|
||||
|
||||
import android.accessibilityservice.AccessibilityService;
|
||||
import android.view.accessibility.AccessibilityNodeInfo;
|
||||
|
||||
import com.stardust.scriptdroid.service.AccessibilityWatchDogService;
|
||||
import com.stardust.view.accessibility.AccessibilityService;
|
||||
import com.stardust.util.UnderuseExecutors;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
@@ -19,7 +18,7 @@ public class LayoutInspector {
|
||||
private Executor mExecutor = UnderuseExecutors.getExecutor();
|
||||
|
||||
public void captureCurrentWindow() {
|
||||
AccessibilityWatchDogService service = AccessibilityWatchDogService.getInstance();
|
||||
AccessibilityService service = AccessibilityService.getInstance();
|
||||
if (service == null) {
|
||||
mCapture = null;
|
||||
} else {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package com.stardust.scriptdroid.external.floatingwindow.menu.record.inputevent;
|
||||
|
||||
import com.stardust.scriptdroid.autojs.api.Shell;
|
||||
import android.content.Context;
|
||||
|
||||
import com.stardust.autojs.runtime.api.Shell;
|
||||
import com.stardust.scriptdroid.App;
|
||||
import com.stardust.scriptdroid.external.floatingwindow.menu.record.Recorder;
|
||||
|
||||
/**
|
||||
@@ -13,15 +16,17 @@ public class InputEventRecorder extends Recorder.AbstractRecorder {
|
||||
private String mGetEventCommand;
|
||||
private Shell mShell;
|
||||
protected InputEventConverter mInputEventConverter;
|
||||
private Context mContext;
|
||||
|
||||
|
||||
protected InputEventRecorder(InputEventConverter inputEventConverter) {
|
||||
protected InputEventRecorder(Context context, InputEventConverter inputEventConverter) {
|
||||
mGetEventCommand = inputEventConverter.getGetEventCommand();
|
||||
mInputEventConverter = inputEventConverter;
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
public void listen() {
|
||||
mShell = new Shell(true);
|
||||
mShell = new Shell(mContext, true);
|
||||
mShell.setCallback(new Shell.SimpleCallback() {
|
||||
@Override
|
||||
public void onNewLine(String str) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.stardust.scriptdroid.external.floatingwindow.menu.record.inputevent;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
/**
|
||||
@@ -19,14 +20,14 @@ public class KeyObserver {
|
||||
private InputEventRecorder mObserver;
|
||||
private KeyListener mKeyListener;
|
||||
|
||||
public KeyObserver(){
|
||||
mObserver = new InputEventRecorder(new InputEventConverter() {
|
||||
public KeyObserver(Context context) {
|
||||
mObserver = new InputEventRecorder(context, new InputEventConverter() {
|
||||
@Override
|
||||
public void convertEvent(@NonNull Event event) {
|
||||
if(event.value.equalsIgnoreCase("UP")){
|
||||
if (event.value.equalsIgnoreCase("UP")) {
|
||||
notifyKeyUp(event.code);
|
||||
}
|
||||
if(event.value.equalsIgnoreCase("DOWN")){
|
||||
if (event.value.equalsIgnoreCase("DOWN")) {
|
||||
notifyKeyDown(event.code);
|
||||
}
|
||||
}
|
||||
@@ -42,23 +43,23 @@ public class KeyObserver {
|
||||
mKeyListener = keyListener;
|
||||
}
|
||||
|
||||
public void startListening(){
|
||||
public void startListening() {
|
||||
mObserver.listen();
|
||||
mObserver.start();
|
||||
}
|
||||
|
||||
public void stopListening(){
|
||||
public void stopListening() {
|
||||
mObserver.stopImpl();
|
||||
}
|
||||
|
||||
private void notifyKeyDown(String keyName) {
|
||||
if(mKeyListener != null){
|
||||
if (mKeyListener != null) {
|
||||
mKeyListener.onKeyDown(keyName);
|
||||
}
|
||||
}
|
||||
|
||||
private void notifyKeyUp(String keyName) {
|
||||
if(mKeyListener != null){
|
||||
if (mKeyListener != null) {
|
||||
mKeyListener.onKeyUp(keyName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
package com.stardust.scriptdroid.external.floatingwindow.menu.record.inputevent;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/3/16.
|
||||
*/
|
||||
|
||||
public class TouchRecorder extends InputEventRecorder {
|
||||
|
||||
public TouchRecorder() {
|
||||
super(new InputEventToSendEventJsConverter());
|
||||
public TouchRecorder(Context context) {
|
||||
super(context, new InputEventToSendEventJsConverter());
|
||||
listen();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user