fix some bugs
This commit is contained in:
BIN
.idea/caches/build_file_checksums.ser
generated
BIN
.idea/caches/build_file_checksums.ser
generated
Binary file not shown.
@@ -45,7 +45,7 @@ public class AutoJs extends com.stardust.autojs.AutoJs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Console createGlobalConsole() {
|
protected GlobalStardustConsole createGlobalConsole() {
|
||||||
return new GlobalStardustConsole(getUiHandler()) {
|
return new GlobalStardustConsole(getUiHandler()) {
|
||||||
@Override
|
@Override
|
||||||
public String println(int level, CharSequence charSequence) {
|
public String println(int level, CharSequence charSequence) {
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ public class ScriptIntents {
|
|||||||
long interval = intent.getLongExtra(EXTRA_KEY_LOOP_INTERVAL, 0);
|
long interval = intent.getLongExtra(EXTRA_KEY_LOOP_INTERVAL, 0);
|
||||||
ScriptSource source = null;
|
ScriptSource source = null;
|
||||||
ExecutionConfig config = new ExecutionConfig().loop(delay, loopTimes, interval);
|
ExecutionConfig config = new ExecutionConfig().loop(delay, loopTimes, interval);
|
||||||
|
config.setArgument("intent", intent);
|
||||||
if (path == null && script != null) {
|
if (path == null && script != null) {
|
||||||
source = new StringScriptSource(script);
|
source = new StringScriptSource(script);
|
||||||
} else if (path != null && new PathChecker(context).checkAndToastError(path)) {
|
} else if (path != null && new PathChecker(context).checkAndToastError(path)) {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package org.autojs.autojs.model.script;
|
package org.autojs.autojs.model.script;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
@@ -147,9 +148,10 @@ public class Scripts {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void send(ScriptFile file) {
|
public static void send(ScriptFile file) {
|
||||||
GlobalAppContext.get().startActivity(Intent.createChooser(new Intent(Intent.ACTION_SEND)
|
Context context = GlobalAppContext.get();
|
||||||
|
context.startActivity(Intent.createChooser(new Intent(Intent.ACTION_SEND)
|
||||||
.setType("text/plain")
|
.setType("text/plain")
|
||||||
.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file)),
|
.putExtra(Intent.EXTRA_STREAM, IntentUtil.getUriOfFile(context, file.getPath(), AppFileProvider.AUTHORITY)),
|
||||||
GlobalAppContext.getString(R.string.text_send)
|
GlobalAppContext.getString(R.string.text_send)
|
||||||
).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
|
).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ public abstract class FullScreenFloatyWindow implements FloatyWindow {
|
|||||||
mLayoutParams = new WindowManager.LayoutParams(
|
mLayoutParams = new WindowManager.LayoutParams(
|
||||||
WindowManager.LayoutParams.MATCH_PARENT,
|
WindowManager.LayoutParams.MATCH_PARENT,
|
||||||
WindowManager.LayoutParams.MATCH_PARENT,
|
WindowManager.LayoutParams.MATCH_PARENT,
|
||||||
WindowManager.LayoutParams.TYPE_PHONE,
|
FloatyWindowManger.getWindowType(),
|
||||||
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
|
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
|
||||||
PixelFormat.TRANSLUCENT);
|
PixelFormat.TRANSLUCENT);
|
||||||
mWindowManager.addView(mView, mLayoutParams);
|
mWindowManager.addView(mView, mLayoutParams);
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import com.stardust.app.DialogUtils;
|
|||||||
import com.stardust.enhancedfloaty.FloatyService;
|
import com.stardust.enhancedfloaty.FloatyService;
|
||||||
import org.autojs.autojs.R;
|
import org.autojs.autojs.R;
|
||||||
import org.autojs.autojs.ui.codegeneration.CodeGenerateDialog;
|
import org.autojs.autojs.ui.codegeneration.CodeGenerateDialog;
|
||||||
|
import org.autojs.autojs.ui.floating.FloatyWindowManger;
|
||||||
import org.autojs.autojs.ui.floating.FullScreenFloatyWindow;
|
import org.autojs.autojs.ui.floating.FullScreenFloatyWindow;
|
||||||
import com.stardust.view.accessibility.NodeInfo;
|
import com.stardust.view.accessibility.NodeInfo;
|
||||||
import org.autojs.autojs.ui.widget.BubblePopupMenu;
|
import org.autojs.autojs.ui.widget.BubblePopupMenu;
|
||||||
@@ -115,7 +116,7 @@ public class LayoutBoundsFloatyWindow extends FullScreenFloatyWindow {
|
|||||||
.customView(mNodeInfoView, false)
|
.customView(mNodeInfoView, false)
|
||||||
.theme(Theme.LIGHT)
|
.theme(Theme.LIGHT)
|
||||||
.build();
|
.build();
|
||||||
mNodeInfoDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_PHONE);
|
mNodeInfoDialog.getWindow().setType(FloatyWindowManger.getWindowType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import com.stardust.app.DialogUtils;
|
|||||||
import com.stardust.enhancedfloaty.FloatyService;
|
import com.stardust.enhancedfloaty.FloatyService;
|
||||||
import org.autojs.autojs.R;
|
import org.autojs.autojs.R;
|
||||||
import org.autojs.autojs.ui.codegeneration.CodeGenerateDialog;
|
import org.autojs.autojs.ui.codegeneration.CodeGenerateDialog;
|
||||||
|
import org.autojs.autojs.ui.floating.FloatyWindowManger;
|
||||||
import org.autojs.autojs.ui.floating.FullScreenFloatyWindow;
|
import org.autojs.autojs.ui.floating.FullScreenFloatyWindow;
|
||||||
import com.stardust.view.accessibility.NodeInfo;
|
import com.stardust.view.accessibility.NodeInfo;
|
||||||
import org.autojs.autojs.ui.widget.BubblePopupMenu;
|
import org.autojs.autojs.ui.widget.BubblePopupMenu;
|
||||||
@@ -124,7 +125,7 @@ public class LayoutHierarchyFloatyWindow extends FullScreenFloatyWindow {
|
|||||||
.theme(Theme.LIGHT)
|
.theme(Theme.LIGHT)
|
||||||
.build();
|
.build();
|
||||||
if (mNodeInfoDialog.getWindow() != null)
|
if (mNodeInfoDialog.getWindow() != null)
|
||||||
mNodeInfoDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_PHONE);
|
mNodeInfoDialog.getWindow().setType(FloatyWindowManger.getWindowType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,15 +2,14 @@ package org.autojs.autojs.ui.project;
|
|||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.BitmapFactory;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.design.widget.TextInputEditText;
|
import android.support.design.widget.TextInputEditText;
|
||||||
import android.support.design.widget.TextInputLayout;
|
import android.support.design.widget.TextInputLayout;
|
||||||
import android.support.v7.widget.CardView;
|
import android.support.v7.widget.CardView;
|
||||||
|
import android.text.Editable;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -25,7 +24,6 @@ import org.androidannotations.annotations.AfterViews;
|
|||||||
import org.androidannotations.annotations.Click;
|
import org.androidannotations.annotations.Click;
|
||||||
import org.androidannotations.annotations.EActivity;
|
import org.androidannotations.annotations.EActivity;
|
||||||
import org.androidannotations.annotations.ViewById;
|
import org.androidannotations.annotations.ViewById;
|
||||||
import org.autojs.autojs.App;
|
|
||||||
import org.autojs.autojs.Pref;
|
import org.autojs.autojs.Pref;
|
||||||
import org.autojs.autojs.R;
|
import org.autojs.autojs.R;
|
||||||
import org.autojs.autojs.autojs.build.AutoJsApkBuilder;
|
import org.autojs.autojs.autojs.build.AutoJsApkBuilder;
|
||||||
@@ -41,9 +39,9 @@ import org.autojs.autojs.ui.shortcut.ShortcutIconSelectActivity_;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.security.KeyStore;
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import io.reactivex.Observable;
|
import io.reactivex.Observable;
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
@@ -60,6 +58,7 @@ public class BuildActivity extends BaseActivity implements AutoJsApkBuilder.Prog
|
|||||||
public static final String EXTRA_SOURCE = BuildActivity.class.getName() + ".extra_source_file";
|
public static final String EXTRA_SOURCE = BuildActivity.class.getName() + ".extra_source_file";
|
||||||
|
|
||||||
private static final String LOG_TAG = "BuildActivity";
|
private static final String LOG_TAG = "BuildActivity";
|
||||||
|
private static final Pattern REGEX_PACKAGE_NAME = Pattern.compile("^([A-Za-z][A-Za-z\\d_]*\\.)+([A-Za-z][A-Za-z\\d_]*)$");
|
||||||
|
|
||||||
@ViewById(R.id.source_path)
|
@ViewById(R.id.source_path)
|
||||||
TextInputEditText mSourcePath;
|
TextInputEditText mSourcePath;
|
||||||
@@ -221,10 +220,25 @@ public class BuildActivity extends BaseActivity implements AutoJsApkBuilder.Prog
|
|||||||
inputValid &= checkNotEmpty(mSourcePath);
|
inputValid &= checkNotEmpty(mSourcePath);
|
||||||
inputValid &= checkNotEmpty(mVersionCode);
|
inputValid &= checkNotEmpty(mVersionCode);
|
||||||
inputValid &= checkNotEmpty(mVersionName);
|
inputValid &= checkNotEmpty(mVersionName);
|
||||||
inputValid &= checkNotEmpty(mPackageName);
|
inputValid &= checkPackageNameValid(mPackageName);
|
||||||
return inputValid;
|
return inputValid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean checkPackageNameValid(TextInputEditText editText) {
|
||||||
|
Editable text = editText.getText();
|
||||||
|
String hint = ((TextInputLayout) editText.getParent().getParent()).getHint().toString();
|
||||||
|
if(TextUtils.isEmpty(text)){
|
||||||
|
editText.setError(hint + getString(R.string.text_should_not_be_empty));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(!REGEX_PACKAGE_NAME.matcher(text).matches()){
|
||||||
|
editText.setError(getString(R.string.text_invalid_package_name));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private boolean checkNotEmpty(TextInputEditText editText) {
|
private boolean checkNotEmpty(TextInputEditText editText) {
|
||||||
if (!TextUtils.isEmpty(editText.getText()) || !editText.isShown())
|
if (!TextUtils.isEmpty(editText.getText()) || !editText.isShown())
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import android.os.Bundle;
|
|||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.design.widget.TextInputEditText;
|
import android.support.design.widget.TextInputEditText;
|
||||||
import android.support.design.widget.TextInputLayout;
|
import android.support.design.widget.TextInputLayout;
|
||||||
|
import android.text.Editable;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
@@ -35,6 +36,7 @@ import org.autojs.autojs.ui.widget.SimpleTextWatcher;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import io.reactivex.Observable;
|
import io.reactivex.Observable;
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
@@ -50,6 +52,7 @@ public class ProjectConfigActivity extends BaseActivity {
|
|||||||
public static final String EXTRA_DIRECTORY = "directory";
|
public static final String EXTRA_DIRECTORY = "directory";
|
||||||
|
|
||||||
private static final int REQUEST_CODE = 12477;
|
private static final int REQUEST_CODE = 12477;
|
||||||
|
private static final Pattern REGEX_PACKAGE_NAME = Pattern.compile("^([A-Za-z][A-Za-z\\d_]*\\.)+([A-Za-z][A-Za-z\\d_]*)$");
|
||||||
|
|
||||||
|
|
||||||
@ViewById(R.id.project_location)
|
@ViewById(R.id.project_location)
|
||||||
@@ -138,10 +141,10 @@ public class ProjectConfigActivity extends BaseActivity {
|
|||||||
@SuppressLint("CheckResult")
|
@SuppressLint("CheckResult")
|
||||||
@Click(R.id.fab)
|
@Click(R.id.fab)
|
||||||
void commit() {
|
void commit() {
|
||||||
syncProjectConfig();
|
|
||||||
if (!checkInputs()) {
|
if (!checkInputs()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
syncProjectConfig();
|
||||||
if (mIconBitmap != null) {
|
if (mIconBitmap != null) {
|
||||||
saveIcon(mIconBitmap)
|
saveIcon(mIconBitmap)
|
||||||
.subscribe(ignored -> saveProjectConfig(), e -> {
|
.subscribe(ignored -> saveProjectConfig(), e -> {
|
||||||
@@ -209,10 +212,25 @@ public class ProjectConfigActivity extends BaseActivity {
|
|||||||
inputValid &= checkNotEmpty(mAppName);
|
inputValid &= checkNotEmpty(mAppName);
|
||||||
inputValid &= checkNotEmpty(mVersionCode);
|
inputValid &= checkNotEmpty(mVersionCode);
|
||||||
inputValid &= checkNotEmpty(mVersionName);
|
inputValid &= checkNotEmpty(mVersionName);
|
||||||
inputValid &= checkNotEmpty(mPackageName);
|
inputValid &= checkPackageNameValid(mPackageName);
|
||||||
return inputValid;
|
return inputValid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean checkPackageNameValid(TextInputEditText editText) {
|
||||||
|
Editable text = editText.getText();
|
||||||
|
String hint = ((TextInputLayout) editText.getParent().getParent()).getHint().toString();
|
||||||
|
if(TextUtils.isEmpty(text)){
|
||||||
|
editText.setError(hint + getString(R.string.text_should_not_be_empty));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(!REGEX_PACKAGE_NAME.matcher(text).matches()){
|
||||||
|
editText.setError(getString(R.string.text_invalid_package_name));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private boolean checkNotEmpty(TextInputEditText editText) {
|
private boolean checkNotEmpty(TextInputEditText editText) {
|
||||||
if (!TextUtils.isEmpty(editText.getText()))
|
if (!TextUtils.isEmpty(editText.getText()))
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package org.autojs.autojs.ui.timing;
|
|||||||
|
|
||||||
import android.app.DatePickerDialog;
|
import android.app.DatePickerDialog;
|
||||||
import android.app.TimePickerDialog;
|
import android.app.TimePickerDialog;
|
||||||
|
import android.content.ActivityNotFoundException;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.ColorFilter;
|
import android.graphics.ColorFilter;
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
@@ -346,8 +347,13 @@ public class TimedTaskSettingActivity extends BaseActivity {
|
|||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
if (item.getItemId() == R.id.action_done) {
|
if (item.getItemId() == R.id.action_done) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !((PowerManager) getSystemService(POWER_SERVICE)).isIgnoringBatteryOptimizations(getPackageName())) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !((PowerManager) getSystemService(POWER_SERVICE)).isIgnoringBatteryOptimizations(getPackageName())) {
|
||||||
startActivityForResult(new Intent().setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS)
|
try{
|
||||||
.setData(Uri.parse("package:" + getPackageName())), REQUEST_CODE_IGNORE_BATTERY);
|
startActivityForResult(new Intent().setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS)
|
||||||
|
.setData(Uri.parse("package:" + getPackageName())), REQUEST_CODE_IGNORE_BATTERY);
|
||||||
|
}catch(ActivityNotFoundException e){
|
||||||
|
e.printStackTrace();
|
||||||
|
createOrUpdateTask();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
createOrUpdateTask();
|
createOrUpdateTask();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -422,4 +422,5 @@
|
|||||||
<string name="text_run_on_time_tick">每分钟一次</string>
|
<string name="text_run_on_time_tick">每分钟一次</string>
|
||||||
<string name="text_run_on_config_change">某些设置(屏幕方向,地区等)更改时</string>
|
<string name="text_run_on_config_change">某些设置(屏幕方向,地区等)更改时</string>
|
||||||
<string name="error_pattern_syntax">正则表达式错误</string>
|
<string name="error_pattern_syntax">正则表达式错误</string>
|
||||||
|
<string name="text_invalid_package_name">非法包名</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ public abstract class AutoJs {
|
|||||||
private final AccessibilityInfoProvider mAccessibilityInfoProvider;
|
private final AccessibilityInfoProvider mAccessibilityInfoProvider;
|
||||||
private final ScreenCaptureRequester mScreenCaptureRequester = new ScreenCaptureRequesterImpl();
|
private final ScreenCaptureRequester mScreenCaptureRequester = new ScreenCaptureRequesterImpl();
|
||||||
private final ScriptEngineService mScriptEngineService;
|
private final ScriptEngineService mScriptEngineService;
|
||||||
private final Console mGlobalConsole;
|
private final GlobalStardustConsole mGlobalConsole;
|
||||||
|
|
||||||
|
|
||||||
protected AutoJs(final Application application) {
|
protected AutoJs(final Application application) {
|
||||||
@@ -70,7 +70,7 @@ public abstract class AutoJs {
|
|||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Console createGlobalConsole() {
|
protected GlobalStardustConsole createGlobalConsole() {
|
||||||
return new GlobalStardustConsole(mUiHandler);
|
return new GlobalStardustConsole(mUiHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,7 +161,7 @@ public abstract class AutoJs {
|
|||||||
return mLayoutInspector;
|
return mLayoutInspector;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Console getGlobalConsole() {
|
public GlobalStardustConsole getGlobalConsole() {
|
||||||
return mGlobalConsole;
|
return mGlobalConsole;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.stardust.autojs.core.console;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
|
||||||
import com.stardust.autojs.R;
|
import com.stardust.autojs.R;
|
||||||
@@ -17,6 +18,8 @@ import com.stardust.enhancedfloaty.ResizableExpandableFloatyWindow;
|
|||||||
import com.stardust.util.UiHandler;
|
import com.stardust.util.UiHandler;
|
||||||
import com.stardust.util.ViewUtil;
|
import com.stardust.util.ViewUtil;
|
||||||
|
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.io.StringWriter;
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.concurrent.ArrayBlockingQueue;
|
import java.util.concurrent.ArrayBlockingQueue;
|
||||||
@@ -115,6 +118,13 @@ public class StardustConsole extends AbstractConsole {
|
|||||||
return mLogs;
|
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
|
@Override
|
||||||
public String println(int level, CharSequence charSequence) {
|
public String println(int level, CharSequence charSequence) {
|
||||||
Log log = new Log(mIdCounter.getAndIncrement(), level, charSequence, true);
|
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.content.Context;
|
||||||
import android.graphics.PixelFormat;
|
import android.graphics.PixelFormat;
|
||||||
|
import android.os.Build;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.view.Window;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
|
|
||||||
@@ -115,10 +117,16 @@ public class BaseResizableFloatyWindow extends ResizableFloatyWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private WindowManager.LayoutParams createWindowLayoutParams() {
|
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 layoutParams = new WindowManager.LayoutParams(
|
||||||
WindowManager.LayoutParams.WRAP_CONTENT,
|
WindowManager.LayoutParams.WRAP_CONTENT,
|
||||||
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,
|
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
|
||||||
PixelFormat.TRANSLUCENT);
|
PixelFormat.TRANSLUCENT);
|
||||||
layoutParams.gravity = Gravity.TOP | Gravity.START;
|
layoutParams.gravity = Gravity.TOP | Gravity.START;
|
||||||
|
|||||||
@@ -112,7 +112,8 @@ public class ColorFinder {
|
|||||||
ColorDetector colorDetector = new ColorDetector.DifferenceDetector(color, threshold);
|
ColorDetector colorDetector = new ColorDetector.DifferenceDetector(color, threshold);
|
||||||
x += startingPoint.x;
|
x += startingPoint.x;
|
||||||
y += startingPoint.y;
|
y += startingPoint.y;
|
||||||
if (x >= image.getWidth() || y >= image.getHeight()) {
|
if (x >= image.getWidth() || y >= image.getHeight()
|
||||||
|
|| x < 0 || y < 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
int c = image.pixel(x, y);
|
int c = image.pixel(x, y);
|
||||||
|
|||||||
@@ -81,14 +81,17 @@ public class ImageWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getWidth() {
|
public int getWidth() {
|
||||||
|
ensureNotRecycled();
|
||||||
return mWidth;
|
return mWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getHeight() {
|
public int getHeight() {
|
||||||
|
ensureNotRecycled();
|
||||||
return mHeight;
|
return mHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Mat getMat() {
|
public Mat getMat() {
|
||||||
|
ensureNotRecycled();
|
||||||
if (mMat == null && mBitmap != null) {
|
if (mMat == null && mBitmap != null) {
|
||||||
mMat = new Mat();
|
mMat = new Mat();
|
||||||
Utils.bitmapToMat(mBitmap, mMat);
|
Utils.bitmapToMat(mBitmap, mMat);
|
||||||
@@ -119,6 +122,7 @@ public class ImageWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Bitmap getBitmap() {
|
public Bitmap getBitmap() {
|
||||||
|
ensureNotRecycled();
|
||||||
return mBitmap;
|
return mBitmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,8 +3,10 @@ package com.stardust.autojs.core.ui.dialog;
|
|||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.ContextWrapper;
|
import android.content.ContextWrapper;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
import android.view.Window;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
|
||||||
import com.afollestad.materialdialogs.DialogAction;
|
import com.afollestad.materialdialogs.DialogAction;
|
||||||
@@ -29,7 +31,13 @@ public class BlockedMaterialDialog extends MaterialDialog {
|
|||||||
@Override
|
@Override
|
||||||
public void show() {
|
public void show() {
|
||||||
if (!isActivityContext(getContext())) {
|
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();
|
super.show();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,8 +79,15 @@ public class JsDialog {
|
|||||||
Context context = mDialog.getContext();
|
Context context = mDialog.getContext();
|
||||||
if (!DialogUtils.isActivityContext(context)) {
|
if (!DialogUtils.isActivityContext(context)) {
|
||||||
Window window = mDialog.getWindow();
|
Window window = mDialog.getWindow();
|
||||||
if (window != null)
|
if (window != null){
|
||||||
window.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;
|
||||||
|
}
|
||||||
|
window.setType(type);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -193,6 +193,7 @@ public class RhinoJavaScriptEngine extends JavaScriptEngine {
|
|||||||
}
|
}
|
||||||
return super.wrap(cx, scope, obj, staticType);
|
return super.wrap(cx, scope, obj, staticType);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class InterruptibleAndroidContextFactory extends AndroidContextFactory {
|
private static class InterruptibleAndroidContextFactory extends AndroidContextFactory {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
public class NativeJavaClassWithPrototype extends NativeJavaClass {
|
public class NativeJavaClassWithPrototype extends NativeJavaClass {
|
||||||
|
|
||||||
private static final Object NULL = new Object();
|
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) {
|
public NativeJavaClassWithPrototype(Scriptable scope, Class<?> javaClass) {
|
||||||
super(scope, javaClass);
|
super(scope, javaClass);
|
||||||
|
|||||||
@@ -14,6 +14,14 @@ public class NativeJavaObjectWithPrototype extends NativeJavaObject {
|
|||||||
super(scope, javaObject, staticType);
|
super(scope, javaObject, staticType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public NativeJavaObjectWithPrototype(Scriptable scope, Object javaObject, Class<?> staticType, boolean isAdapter) {
|
||||||
|
super(scope, javaObject, staticType, isAdapter);
|
||||||
|
}
|
||||||
|
|
||||||
|
public NativeJavaObjectWithPrototype() {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean has(String name, Scriptable start) {
|
public boolean has(String name, Scriptable start) {
|
||||||
return super.has(name, start) || (prototype != null && prototype.has(name, start))
|
return super.has(name, start) || (prototype != null && prototype.has(name, start))
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ public class UiObject extends AccessibilityNodeInfoCompat {
|
|||||||
mIndexInParent = indexInParent;
|
mIndexInParent = indexInParent;
|
||||||
if (DEBUG)
|
if (DEBUG)
|
||||||
mStackTrace = Arrays.toString(Thread.currentThread().getStackTrace());
|
mStackTrace = Arrays.toString(Thread.currentThread().getStackTrace());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import android.app.NativeActivity;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.AssetManager;
|
import android.content.res.AssetManager;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import com.stardust.util.Func1;
|
import com.stardust.util.Func1;
|
||||||
|
|
||||||
@@ -18,6 +20,7 @@ import java.io.InputStream;
|
|||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.RandomAccessFile;
|
import java.io.RandomAccessFile;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -284,31 +287,36 @@ public class PFiles {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static boolean copyAssetDir(Context context, String assetsDir, String toDir) {
|
public static void copyAssetDir(Context context, String assetsDir, String toDir, String[] list) throws IOException {
|
||||||
new File(toDir).mkdirs();
|
new File(toDir).mkdirs();
|
||||||
AssetManager manager = context.getAssets();
|
AssetManager manager = context.getAssets();
|
||||||
try {
|
if (list == null) {
|
||||||
String[] list = manager.list(assetsDir);
|
list = manager.list(assetsDir);
|
||||||
if (list == null)
|
}
|
||||||
return false;
|
if (list == null)
|
||||||
for (String file : list) {
|
throw new IOException("not a directory: " + assetsDir);
|
||||||
InputStream stream;
|
for (String file : list) {
|
||||||
try {
|
if(TextUtils.isEmpty(file)){
|
||||||
stream = manager.open(join(assetsDir, file));
|
continue;
|
||||||
} catch (IOException e) {
|
}
|
||||||
if (!copyAssetDir(context, join(assetsDir, file), join(toDir, file))) {
|
String fullAssetsPath = join(assetsDir, file);
|
||||||
return false;
|
String[] children = manager.list(fullAssetsPath);
|
||||||
}
|
if (children == null || children.length == 0) {
|
||||||
continue;
|
InputStream stream = null;
|
||||||
}
|
try {
|
||||||
copyStream(stream, join(toDir, file));
|
stream = manager.open(fullAssetsPath);
|
||||||
}
|
copyStream(stream, join(toDir, file));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
throw e;
|
||||||
return false;
|
} finally {
|
||||||
|
if (stream != null) {
|
||||||
|
stream.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
copyAssetDir(context, fullAssetsPath, join(toDir, file), children);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String renameWithoutExtensionAndReturnNewPath(String path, String newName) {
|
public static String renameWithoutExtensionAndReturnNewPath(String path, String newName) {
|
||||||
|
|||||||
@@ -12,17 +12,16 @@ import android.support.annotation.Nullable;
|
|||||||
import android.support.annotation.RequiresApi;
|
import android.support.annotation.RequiresApi;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.stardust.auojs.inrt.launch.AssetsProjectLauncher;
|
import com.stardust.auojs.inrt.autojs.AutoJs;
|
||||||
import com.stardust.auojs.inrt.launch.GlobalProjectLauncher;
|
import com.stardust.auojs.inrt.launch.GlobalProjectLauncher;
|
||||||
import com.stardust.autojs.core.image.OpenCVHelper;
|
import com.stardust.autojs.core.image.OpenCVHelper;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static android.content.pm.PackageManager.PERMISSION_DENIED;
|
import static android.content.pm.PackageManager.PERMISSION_DENIED;
|
||||||
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Stardust on 2018/2/2.
|
* Created by Stardust on 2018/2/2.
|
||||||
@@ -58,7 +57,18 @@ public class SplashActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
|
|
||||||
private void runScript() {
|
private void runScript() {
|
||||||
new Thread(() -> GlobalProjectLauncher.getInstance().launch(this)).start();
|
new Thread(() -> {
|
||||||
|
try {
|
||||||
|
GlobalProjectLauncher.getInstance().launch(this);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
runOnUiThread(() -> {
|
||||||
|
Toast.makeText(SplashActivity.this, e.getMessage(), Toast.LENGTH_LONG).show();
|
||||||
|
startActivity(new Intent(SplashActivity.this, LogActivity.class));
|
||||||
|
AutoJs.getInstance().getGlobalConsole().printStackTrace(e);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -17,8 +17,10 @@ import com.stardust.autojs.execution.ScriptExecution;
|
|||||||
import com.stardust.autojs.project.ProjectConfig;
|
import com.stardust.autojs.project.ProjectConfig;
|
||||||
import com.stardust.autojs.script.JavaScriptFileSource;
|
import com.stardust.autojs.script.JavaScriptFileSource;
|
||||||
import com.stardust.pio.PFiles;
|
import com.stardust.pio.PFiles;
|
||||||
|
import com.stardust.pio.UncheckedIOException;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Stardust on 2018/1/24.
|
* Created by Stardust on 2018/1/24.
|
||||||
@@ -86,8 +88,12 @@ public class AssetsProjectLauncher {
|
|||||||
TextUtils.equals(projectConfig.getBuildInfo().getBuildId(), mProjectConfig.getBuildInfo().getBuildId())) {
|
TextUtils.equals(projectConfig.getBuildInfo().getBuildId(), mProjectConfig.getBuildInfo().getBuildId())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PFiles.deleteRecursively(new File(mAssetsProjectDir));
|
PFiles.deleteRecursively(new File(mProjectDir));
|
||||||
PFiles.copyAssetDir(mActivity, mAssetsProjectDir, mProjectDir);
|
try {
|
||||||
|
PFiles.copyAssetDir(mActivity, mAssetsProjectDir, mProjectDir, null);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new UncheckedIOException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user