fix some bugs
This commit is contained in:
@@ -54,7 +54,7 @@ public abstract class AutoJs {
|
||||
private final AccessibilityInfoProvider mAccessibilityInfoProvider;
|
||||
private final ScreenCaptureRequester mScreenCaptureRequester = new ScreenCaptureRequesterImpl();
|
||||
private final ScriptEngineService mScriptEngineService;
|
||||
private final Console mGlobalConsole;
|
||||
private final GlobalStardustConsole mGlobalConsole;
|
||||
|
||||
|
||||
protected AutoJs(final Application application) {
|
||||
@@ -70,7 +70,7 @@ public abstract class AutoJs {
|
||||
init();
|
||||
}
|
||||
|
||||
protected Console createGlobalConsole() {
|
||||
protected GlobalStardustConsole createGlobalConsole() {
|
||||
return new GlobalStardustConsole(mUiHandler);
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ public abstract class AutoJs {
|
||||
return mLayoutInspector;
|
||||
}
|
||||
|
||||
public Console getGlobalConsole() {
|
||||
public GlobalStardustConsole getGlobalConsole() {
|
||||
return mGlobalConsole;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.stardust.autojs.core.console;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.Log;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.stardust.autojs.R;
|
||||
@@ -17,6 +18,8 @@ import com.stardust.enhancedfloaty.ResizableExpandableFloatyWindow;
|
||||
import com.stardust.util.UiHandler;
|
||||
import com.stardust.util.ViewUtil;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
@@ -115,6 +118,13 @@ public class StardustConsole extends AbstractConsole {
|
||||
return mLogs;
|
||||
}
|
||||
|
||||
public void printStackTrace(Throwable t) {
|
||||
StringWriter out = new StringWriter();
|
||||
PrintWriter printWriter = new PrintWriter(out);
|
||||
t.printStackTrace(printWriter);
|
||||
println(android.util.Log.ERROR, t.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String println(int level, CharSequence charSequence) {
|
||||
Log log = new Log(mIdCounter.getAndIncrement(), level, charSequence, true);
|
||||
|
||||
@@ -2,10 +2,12 @@ package com.stardust.autojs.core.floaty;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.os.Build;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
@@ -115,10 +117,16 @@ public class BaseResizableFloatyWindow extends ResizableFloatyWindow {
|
||||
}
|
||||
|
||||
private WindowManager.LayoutParams createWindowLayoutParams() {
|
||||
int type;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
|
||||
} else {
|
||||
type = WindowManager.LayoutParams.TYPE_PHONE;
|
||||
}
|
||||
WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(
|
||||
WindowManager.LayoutParams.WRAP_CONTENT,
|
||||
WindowManager.LayoutParams.WRAP_CONTENT,
|
||||
WindowManager.LayoutParams.TYPE_PHONE,
|
||||
type,
|
||||
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
|
||||
PixelFormat.TRANSLUCENT);
|
||||
layoutParams.gravity = Gravity.TOP | Gravity.START;
|
||||
|
||||
@@ -112,7 +112,8 @@ public class ColorFinder {
|
||||
ColorDetector colorDetector = new ColorDetector.DifferenceDetector(color, threshold);
|
||||
x += startingPoint.x;
|
||||
y += startingPoint.y;
|
||||
if (x >= image.getWidth() || y >= image.getHeight()) {
|
||||
if (x >= image.getWidth() || y >= image.getHeight()
|
||||
|| x < 0 || y < 0) {
|
||||
return false;
|
||||
}
|
||||
int c = image.pixel(x, y);
|
||||
|
||||
@@ -81,14 +81,17 @@ public class ImageWrapper {
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
ensureNotRecycled();
|
||||
return mWidth;
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
ensureNotRecycled();
|
||||
return mHeight;
|
||||
}
|
||||
|
||||
public Mat getMat() {
|
||||
ensureNotRecycled();
|
||||
if (mMat == null && mBitmap != null) {
|
||||
mMat = new Mat();
|
||||
Utils.bitmapToMat(mBitmap, mMat);
|
||||
@@ -119,6 +122,7 @@ public class ImageWrapper {
|
||||
}
|
||||
|
||||
public Bitmap getBitmap() {
|
||||
ensureNotRecycled();
|
||||
return mBitmap;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,10 @@ package com.stardust.autojs.core.ui.dialog;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.ContextWrapper;
|
||||
import android.os.Build;
|
||||
import android.os.Looper;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.afollestad.materialdialogs.DialogAction;
|
||||
@@ -29,7 +31,13 @@ public class BlockedMaterialDialog extends MaterialDialog {
|
||||
@Override
|
||||
public void show() {
|
||||
if (!isActivityContext(getContext())) {
|
||||
getWindow().setType(WindowManager.LayoutParams.TYPE_PHONE);
|
||||
int type;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
|
||||
} else {
|
||||
type = WindowManager.LayoutParams.TYPE_PHONE;
|
||||
}
|
||||
getWindow().setType(type);
|
||||
}
|
||||
super.show();
|
||||
}
|
||||
|
||||
@@ -79,8 +79,15 @@ public class JsDialog {
|
||||
Context context = mDialog.getContext();
|
||||
if (!DialogUtils.isActivityContext(context)) {
|
||||
Window window = mDialog.getWindow();
|
||||
if (window != null)
|
||||
window.setType(WindowManager.LayoutParams.TYPE_PHONE);
|
||||
if (window != null){
|
||||
int type;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
|
||||
} else {
|
||||
type = WindowManager.LayoutParams.TYPE_PHONE;
|
||||
}
|
||||
window.setType(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -193,6 +193,7 @@ public class RhinoJavaScriptEngine extends JavaScriptEngine {
|
||||
}
|
||||
return super.wrap(cx, scope, obj, staticType);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class InterruptibleAndroidContextFactory extends AndroidContextFactory {
|
||||
|
||||
@@ -14,7 +14,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
public class NativeJavaClassWithPrototype extends NativeJavaClass {
|
||||
|
||||
private static final Object NULL = new Object();
|
||||
private ConcurrentHashMap<String, Object> mProperties = new ConcurrentHashMap();
|
||||
private ConcurrentHashMap<String, Object> mProperties = new ConcurrentHashMap<>();
|
||||
|
||||
public NativeJavaClassWithPrototype(Scriptable scope, Class<?> javaClass) {
|
||||
super(scope, javaClass);
|
||||
|
||||
@@ -14,6 +14,14 @@ public class NativeJavaObjectWithPrototype extends NativeJavaObject {
|
||||
super(scope, javaObject, staticType);
|
||||
}
|
||||
|
||||
public NativeJavaObjectWithPrototype(Scriptable scope, Object javaObject, Class<?> staticType, boolean isAdapter) {
|
||||
super(scope, javaObject, staticType, isAdapter);
|
||||
}
|
||||
|
||||
public NativeJavaObjectWithPrototype() {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean has(String name, Scriptable start) {
|
||||
return super.has(name, start) || (prototype != null && prototype.has(name, start))
|
||||
|
||||
Reference in New Issue
Block a user