mirror of
https://github.com/TonyJiangWJ/Auto.js.git
synced 2026-06-24 21:33:16 +08:00
commit
3223dbe992
@ -9,8 +9,8 @@ android {
|
||||
applicationId "com.stardust.scriptdroid"
|
||||
minSdkVersion 17
|
||||
targetSdkVersion 23
|
||||
versionCode 143
|
||||
versionName "2.0.13 Beta2"
|
||||
versionCode 145
|
||||
versionName "2.0.13 Beta3"
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
multiDexEnabled true
|
||||
ndk {
|
||||
|
||||
@ -147,7 +147,12 @@ public class Pref {
|
||||
def().edit().putLong(KEY_LAST_SHOW_AD_MILLIS, System.currentTimeMillis()).apply();
|
||||
return true;
|
||||
case "Off":
|
||||
return false;
|
||||
lastShowMillis = def().getLong(KEY_LAST_SHOW_AD_MILLIS, 0);
|
||||
if (System.currentTimeMillis() - lastShowMillis < TimeUnit.DAYS.toMillis(2)) {
|
||||
return false;
|
||||
}
|
||||
def().edit().putLong(KEY_LAST_SHOW_AD_MILLIS, System.currentTimeMillis()).apply();
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@ package com.stardust.scriptdroid.external.shortcut;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Bundle;
|
||||
|
||||
/**
|
||||
@ -15,9 +15,10 @@ public class Shortcut {
|
||||
private String mName;
|
||||
private String mTargetClass;
|
||||
private String mTargetPackage;
|
||||
private Intent.ShortcutIconResource mIcon;
|
||||
private Intent.ShortcutIconResource mIconRes;
|
||||
private boolean mDuplicate = false;
|
||||
private Intent mLaunchIntent = new Intent();
|
||||
private Bitmap mIcon;
|
||||
|
||||
public Shortcut(Context context) {
|
||||
mContext = context;
|
||||
@ -50,16 +51,32 @@ public class Shortcut {
|
||||
}
|
||||
|
||||
|
||||
public Shortcut icon(Intent.ShortcutIconResource icon) {
|
||||
public Shortcut iconRes(Intent.ShortcutIconResource icon) {
|
||||
if (mIcon != null) {
|
||||
throw new IllegalStateException("Cannot set both iconRes and icon");
|
||||
}
|
||||
mIconRes = icon;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Shortcut iconRes(int resId) {
|
||||
return iconRes(Intent.ShortcutIconResource.fromContext(mContext, resId));
|
||||
}
|
||||
|
||||
|
||||
public Shortcut icon(Bitmap icon) {
|
||||
if (mIconRes != null) {
|
||||
throw new IllegalStateException("Cannot set both iconRes and icon");
|
||||
}
|
||||
mIcon = icon;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Shortcut icon(int resId) {
|
||||
mIcon = Intent.ShortcutIconResource.fromContext(mContext, resId);
|
||||
return this;
|
||||
public Intent.ShortcutIconResource getIconRes() {
|
||||
return mIconRes;
|
||||
}
|
||||
|
||||
|
||||
public Shortcut duplicate(boolean duplicate) {
|
||||
mDuplicate = duplicate;
|
||||
return this;
|
||||
@ -69,7 +86,7 @@ public class Shortcut {
|
||||
return mName;
|
||||
}
|
||||
|
||||
public Intent.ShortcutIconResource getIcon() {
|
||||
public Bitmap getIcon() {
|
||||
return mIcon;
|
||||
}
|
||||
|
||||
@ -86,12 +103,18 @@ public class Shortcut {
|
||||
}
|
||||
|
||||
public Intent getCreateIntent() {
|
||||
return new Intent(Intent.ACTION_CREATE_SHORTCUT)
|
||||
Intent intent = new Intent(Intent.ACTION_CREATE_SHORTCUT)
|
||||
.putExtra(Intent.EXTRA_SHORTCUT_NAME, getName())
|
||||
.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, getIcon())
|
||||
.putExtra(Intent.EXTRA_SHORTCUT_INTENT, getLaunchIntent())
|
||||
.putExtra("duplicate", isDuplicate())
|
||||
.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
|
||||
Bitmap icon = getIcon();
|
||||
if (icon == null) {
|
||||
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, getIconRes());
|
||||
} else {
|
||||
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, icon);
|
||||
}
|
||||
return intent;
|
||||
}
|
||||
|
||||
public Intent getLaunchIntent() {
|
||||
|
||||
@ -32,7 +32,8 @@ public class FireSettingReceiver extends AbstractPluginSettingReceiver {
|
||||
@Override
|
||||
protected void firePluginSetting(@NonNull Context context, @NonNull Bundle bundle) {
|
||||
context.startActivity(new Intent(context, RunIntentActivity.class)
|
||||
.putExtras(bundle));
|
||||
.putExtras(bundle)
|
||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ package com.stardust.scriptdroid.script;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
|
||||
import com.stardust.autojs.execution.ExecutionConfig;
|
||||
@ -69,7 +70,7 @@ public class Scripts {
|
||||
public static void createShortcut(ScriptFile scriptFile) {
|
||||
new Shortcut(App.getApp()).name(scriptFile.getSimplifiedName())
|
||||
.targetClass(ShortcutActivity.class)
|
||||
.icon(R.drawable.ic_node_js_black)
|
||||
.iconRes(R.drawable.ic_node_js_black)
|
||||
.extras(new Intent().putExtra(CommonUtils.EXTRA_KEY_PATH, scriptFile.getPath()))
|
||||
.send();
|
||||
}
|
||||
|
||||
@ -35,7 +35,7 @@ public class SublimePluginClient {
|
||||
}
|
||||
}
|
||||
|
||||
private Socket mSocket;
|
||||
private volatile Socket mSocket;
|
||||
private Handler mResponseHandler;
|
||||
private String host;
|
||||
private int port;
|
||||
@ -73,6 +73,10 @@ public class SublimePluginClient {
|
||||
}).start();
|
||||
}
|
||||
|
||||
public boolean isListening() {
|
||||
return mSocket != null;
|
||||
}
|
||||
|
||||
private void tryClose() {
|
||||
try {
|
||||
close();
|
||||
|
||||
@ -13,7 +13,7 @@ public class SublimePluginService {
|
||||
private static SublimePluginClient client;
|
||||
|
||||
public static boolean isConnected() {
|
||||
return client != null;
|
||||
return client != null && client.isListening();
|
||||
}
|
||||
|
||||
public static void disconnectIfNeeded() {
|
||||
@ -44,6 +44,10 @@ public class SublimePluginService {
|
||||
JsonObject object = new JsonObject();
|
||||
object.addProperty("type", "log");
|
||||
object.addProperty("log", log);
|
||||
client.send(object);
|
||||
try {
|
||||
client.send(object);
|
||||
} catch (IllegalStateException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,6 +25,7 @@ import android.widget.Toast;
|
||||
|
||||
import com.afollestad.materialdialogs.DialogAction;
|
||||
import com.afollestad.materialdialogs.MaterialDialog;
|
||||
import com.qq.e.comm.DownloadService;
|
||||
import com.stardust.app.FragmentPagerAdapterBuilder;
|
||||
import com.stardust.app.NotAskAgainDialog;
|
||||
import com.stardust.app.OnActivityResultDelegate;
|
||||
@ -103,6 +104,8 @@ public class MainActivity extends BaseActivity implements OnActivityResultDelega
|
||||
EventBus.getDefault().register(this);
|
||||
mVersionGuard = new VersionGuard(this);
|
||||
showAnnunciationIfNeeded();
|
||||
//Stop download service of ad sdk
|
||||
stopService(new Intent(this, DownloadService.class));
|
||||
}
|
||||
|
||||
@AfterViews
|
||||
|
||||
@ -78,10 +78,16 @@ public class SideMenuFragment extends android.support.v4.app.Fragment {
|
||||
mExecutor.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (mAccessibilityServiceSwitch == null) {
|
||||
return;
|
||||
}
|
||||
final boolean checked = AccessibilityService.isEnabled(App.getApp());
|
||||
mAccessibilityServiceSwitch.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (mAccessibilityServiceSwitch == null) {
|
||||
return;
|
||||
}
|
||||
mAccessibilityServiceSwitch.setChecked(checked);
|
||||
}
|
||||
});
|
||||
|
||||
@ -224,7 +224,7 @@
|
||||
<string-array name="ad_showing_mode_keys">
|
||||
<item>默认</item>
|
||||
<item>每天显示一次</item>
|
||||
<item>不显示</item>
|
||||
<item>两天显示一次</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="ad_showing_mode_values">
|
||||
|
||||
@ -10,6 +10,10 @@ module.exports = function(__runtime__, scope){
|
||||
|
||||
images.saveImage = __runtime__.images.saveImage.bind(__runtime__.images);
|
||||
|
||||
images.pixel = __runtime__.images.pixel;
|
||||
|
||||
images.detectsColor = __runtime__.images.detectsColor.bind(__runtime__.images);
|
||||
|
||||
images.findColor = function(img, color, options){
|
||||
if(typeof(color) == 'string'){
|
||||
if(color.startsWith('#')){
|
||||
|
||||
@ -40,6 +40,10 @@ public class ScriptExecuteActivity extends AppCompatActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (execution == null) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
mScriptSource = execution.getSource();
|
||||
mScriptEngine = execution.getEngine();
|
||||
mExecutionListener = execution.getListener();
|
||||
|
||||
@ -5,15 +5,11 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Matrix;
|
||||
import android.media.Image;
|
||||
import android.media.ImageReader;
|
||||
import android.media.ImageWriter;
|
||||
import android.media.MediaCodec;
|
||||
import android.os.Build;
|
||||
import android.provider.ContactsContract;
|
||||
import android.support.annotation.RequiresApi;
|
||||
import android.view.Surface;
|
||||
|
||||
import com.stardust.autojs.runtime.AbstractScriptRuntime;
|
||||
import com.stardust.autojs.runtime.ScriptInterruptedException;
|
||||
@ -29,7 +25,7 @@ import java.nio.ByteBuffer;
|
||||
/**
|
||||
* Created by Stardust on 2017/5/20.
|
||||
*/
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
|
||||
public class Images {
|
||||
|
||||
private AbstractScriptRuntime mScriptRuntime;
|
||||
@ -109,13 +105,28 @@ public class Images {
|
||||
public static int pixel(Image image, int x, int y) {
|
||||
Image.Plane plane = image.getPlanes()[0];
|
||||
int offset = y * plane.getRowStride() + x * plane.getPixelStride();
|
||||
return plane.getBuffer().getInt(offset);
|
||||
int c = plane.getBuffer().getInt(offset);
|
||||
return (c & 0xff000000) + ((c & 0xff) << 16) + (c & 0x00ff00) + ((c & 0xff0000) >> 16);
|
||||
}
|
||||
|
||||
public static int pixel(Bitmap bitmap, int x, int y) {
|
||||
return bitmap.getPixel(x, y);
|
||||
}
|
||||
|
||||
public boolean detectsColor(Image image, int x, int y, int color) {
|
||||
if (image == null)
|
||||
return false;
|
||||
int pixel = pixel(image, x, y);
|
||||
return colorFinder.defaultColorDetector(color).detectsColor(Color.red(pixel), Color.green(pixel), Color.blue(pixel));
|
||||
}
|
||||
|
||||
public boolean detectsColor(Image image, int x, int y, int color, int threshold) {
|
||||
if (image == null)
|
||||
return false;
|
||||
int pixel = pixel(image, x, y);
|
||||
return colorFinder.defaultColorDetector(color, threshold).detectsColor(Color.red(pixel), Color.green(pixel), Color.blue(pixel));
|
||||
}
|
||||
|
||||
public static Bitmap read(String path) {
|
||||
return BitmapFactory.decodeFile(path);
|
||||
}
|
||||
|
||||
@ -36,8 +36,9 @@ public class BlockedMaterialDialog extends MaterialDialog {
|
||||
private boolean isActivityContext(Context context) {
|
||||
if (context == null)
|
||||
return false;
|
||||
if (context instanceof Activity)
|
||||
return true;
|
||||
if (context instanceof Activity) {
|
||||
return !((Activity) context).isFinishing();
|
||||
}
|
||||
if (context instanceof ContextWrapper) {
|
||||
return isActivityContext(((ContextWrapper) context).getBaseContext());
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.stardust.autojs.runtime.api.ui;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.ContextWrapper;
|
||||
import android.text.TextUtils;
|
||||
@ -73,7 +74,7 @@ public class Dialogs {
|
||||
private Context getContext() {
|
||||
if (mThemeWrapper != null)
|
||||
return mThemeWrapper;
|
||||
mThemeWrapper = new ContextThemeWrapper(mUiHandler.getContext(), R.style.Theme_AppCompat_Light);
|
||||
mThemeWrapper = new ContextThemeWrapper(mUiHandler.getContext().getApplicationContext(), R.style.Theme_AppCompat_Light);
|
||||
return mThemeWrapper;
|
||||
}
|
||||
|
||||
@ -115,7 +116,7 @@ public class Dialogs {
|
||||
|
||||
private BlockedMaterialDialog.Builder dialogBuilder() {
|
||||
Context context = mAppUtils.getCurrentActivity();
|
||||
if (context == null) {
|
||||
if (context == null || ((Activity) context).isFinishing()) {
|
||||
context = getContext();
|
||||
}
|
||||
return (BlockedMaterialDialog.Builder) new BlockedMaterialDialog.Builder(context, mUiHandler)
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:accessibilityEventTypes="typeAllMask"
|
||||
android:accessibilityFeedbackType="feedbackGeneric"
|
||||
android:accessibilityFlags="flagRetrieveInteractiveWindows|flagIncludeNotImportantViews|flagReportViewIds|flagRequestEnhancedWebAccessibility|flagRequestFilterKeyEvents"
|
||||
android:accessibilityFlags="flagRetrieveInteractiveWindows|flagIncludeNotImportantViews|flagReportViewIds|flagRequestEnhancedWebAccessibility"
|
||||
android:canPerformGestures="true"
|
||||
android:canRequestEnhancedWebAccessibility="true"
|
||||
android:canRetrieveWindowContent="true"
|
||||
|
||||
@ -81,28 +81,17 @@ public class AccessibilityService extends android.accessibilityservice.Accessibi
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInterrupt() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccessibilityNodeInfo getRootInActiveWindow() {
|
||||
return mRootInActiveWindow;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean onKeyEvent(KeyEvent event) {
|
||||
Log.v(TAG, "onKeyEvent: " + event);
|
||||
return super.onKeyEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onGesture(int gestureId) {
|
||||
Log.v(TAG, "onGesture: " + gestureId);
|
||||
return super.onGesture(gestureId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInterrupt() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
instance = null;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
{
|
||||
"versionCode": 137,
|
||||
"versionName": "2.0.12 Beta",
|
||||
"releaseNotes": "* 新增 安卓5.0以上免Root截图、保存与找色\n* 新增 电脑端Sublime Text 3插件的支持\n* 新增 Android7.0及以上支持免root任意坐标点击、点按、手势\n* 新增 界面相关API\n* 修复 部分机型上转屏时手机重启的问题\n",
|
||||
"versionCode": 145,
|
||||
"versionName": "2.0.13 Beta3",
|
||||
"releaseNotes": "* 新增 脚本循环运行选项,可设置循环间隔、次数、延迟等(长按脚本)\n* 新增 兼容安卓4.2 (可能会崩溃\n* 新增 跳转悬浮窗权限适配\n* 新增 SublimeText插件支持保存脚本到手机\n* 增加 点赞群成员、名片顺序点赞、批量删除QQ好友脚本\n* 修复 一些bug",
|
||||
"downloads" : [
|
||||
{
|
||||
"name": "酷安",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user