From 25ca819fa7e4a52ebcbf61d4b07aeb5b64e656d1 Mon Sep 17 00:00:00 2001
From: hyb1996 <946994919@qq.com>
Date: Sat, 1 Dec 2018 10:20:33 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20=E4=BB=BB=E5=8A=A1?=
=?UTF-8?q?=E7=AE=A1=E7=90=86=E5=B4=A9=E6=BA=83=E7=9A=84Bug=20=E4=BF=AE?=
=?UTF-8?q?=E5=A4=8D=20id=E6=9C=89=E5=85=B3=E9=80=89=E6=8B=A9=E5=99=A8?=
=?UTF-8?q?=E6=8A=A5=E9=94=99=E7=9A=84Bug=20=E4=BF=AE=E5=A4=8D=20engines.m?=
=?UTF-8?q?yEngine()=E6=8A=A5=E9=94=99=E7=9A=84Bug?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../autojs/theme/ThemeColorRecyclerView.kt | 133 ++++++++++++++++++
.../ui/main/task/TaskListRecyclerView.java | 2 +-
.../ui/widget/ExpandableRecyclerView.java | 3 +-
app/src/main/res/values-zh/strings.xml | 5 +-
app/src/main/res/values/strings.xml | 4 +
autojs/src/main/assets/modules/__engines__.js | 4 +-
.../autojs/engine/RhinoJavaScriptEngine.java | 1 +
.../java/com/stardust/automator/UiObject.kt | 17 +--
.../AccessibilityInfoProvider.kt | 4 +-
common/release/output.json | 2 +-
project-versions.json | 4 +-
11 files changed, 158 insertions(+), 21 deletions(-)
create mode 100644 app/src/main/java/org/autojs/autojs/theme/ThemeColorRecyclerView.kt
diff --git a/app/src/main/java/org/autojs/autojs/theme/ThemeColorRecyclerView.kt b/app/src/main/java/org/autojs/autojs/theme/ThemeColorRecyclerView.kt
new file mode 100644
index 00000000..580e97aa
--- /dev/null
+++ b/app/src/main/java/org/autojs/autojs/theme/ThemeColorRecyclerView.kt
@@ -0,0 +1,133 @@
+package androidx.recyclerview.widget
+
+import android.content.Context
+import android.os.Build.VERSION
+import android.util.AttributeSet
+import android.widget.EdgeEffect
+import androidx.annotation.Nullable
+import androidx.core.widget.EdgeEffectCompat
+import com.stardust.theme.ThemeColor
+import com.stardust.theme.ThemeColorManager
+import com.stardust.theme.ThemeColorMutable
+import java.lang.reflect.Field
+
+open class ThemeColorRecyclerView : RecyclerView, ThemeColorMutable {
+ private var mLeftGlowField: Field? = null
+ private var mTopGlowField: Field? = null
+ private var mRightGlowField: Field? = null
+ private var mBottomGlowField: Field? = null
+ private var mEdgeEffectField: Field? = null
+ private var mColorPrimary: Int = 0
+ private var hasAppliedThemeColorLeft: Boolean = false
+ private var hasAppliedThemeColorTop: Boolean = false
+ private var hasAppliedThemeColorRight: Boolean = false
+ private var hasAppliedThemeColorBottom: Boolean = false
+
+ constructor(context: Context) : super(context) {
+ this.init()
+ }
+
+ constructor(context: Context, @Nullable attrs: AttributeSet) : super(context, attrs) {
+ this.init()
+ }
+
+ constructor(context: Context, @Nullable attrs: AttributeSet, defStyle: Int) : super(context, attrs, defStyle) {
+ this.init()
+ }
+
+ private fun applyThemeColor(edgeEffectCompatField: Field?): Boolean {
+ try {
+ val edgeEffectCompat = edgeEffectCompatField?.get(this) as EdgeEffectCompat?
+ if (edgeEffectCompat != null) {
+ return this.setEdgeEffectColor(edgeEffectCompat, this.mColorPrimary)
+ }
+ } catch (var3: Exception) {
+ }
+
+ return false
+ }
+
+ private fun init() {
+ try {
+ this.mEdgeEffectField = EdgeEffectCompat::class.java.getDeclaredField("mEdgeEffect")
+ this.mEdgeEffectField!!.isAccessible = true
+ this.mLeftGlowField = RecyclerView::class.java.getDeclaredField("mLeftGlow")
+ this.mLeftGlowField!!.isAccessible = true
+ this.mRightGlowField = RecyclerView::class.java.getDeclaredField("mRightGlow")
+ this.mRightGlowField!!.isAccessible = true
+ this.mTopGlowField = RecyclerView::class.java.getDeclaredField("mTopGlow")
+ this.mTopGlowField!!.isAccessible = true
+ this.mBottomGlowField = RecyclerView::class.java.getDeclaredField("mBottomGlow")
+ this.mBottomGlowField!!.isAccessible = true
+ } catch (var2: Exception) {
+ var2.printStackTrace()
+ }
+
+ ThemeColorManager.add(this)
+ }
+
+ private fun setEdgeEffectColor(compat: EdgeEffectCompat?, color: Int): Boolean {
+ return if (compat == null) {
+ false
+ } else {
+ try {
+ if (VERSION.SDK_INT >= 21) {
+ val edgeEffect = this.mEdgeEffectField!!.get(compat) as EdgeEffect
+ edgeEffect.color = color
+ }
+
+ true
+ } catch (var4: Exception) {
+ true
+ }
+
+ }
+ }
+
+ override fun setThemeColor(color: ThemeColor) {
+ if (color.colorPrimary != this.mColorPrimary) {
+ this.mColorPrimary = color.colorPrimary
+ this.invalidateGlows()
+ }
+ }
+
+ internal override fun invalidateGlows() {
+ super.invalidateGlows()
+ this.hasAppliedThemeColorTop = false
+ this.hasAppliedThemeColorRight = this.hasAppliedThemeColorTop
+ this.hasAppliedThemeColorLeft = this.hasAppliedThemeColorRight
+ this.hasAppliedThemeColorBottom = this.hasAppliedThemeColorLeft
+ }
+
+ internal override fun ensureLeftGlow() {
+ super.ensureLeftGlow()
+ if (!this.hasAppliedThemeColorLeft) {
+ this.hasAppliedThemeColorLeft = this.applyThemeColor(this.mLeftGlowField)
+ }
+
+ }
+
+ internal override fun ensureRightGlow() {
+ super.ensureLeftGlow()
+ if (!this.hasAppliedThemeColorRight) {
+ this.hasAppliedThemeColorRight = this.applyThemeColor(this.mRightGlowField)
+ }
+
+ }
+
+ internal override fun ensureTopGlow() {
+ super.ensureTopGlow()
+ if (!this.hasAppliedThemeColorTop) {
+ this.hasAppliedThemeColorTop = this.applyThemeColor(this.mTopGlowField)
+ }
+
+ }
+
+ internal override fun ensureBottomGlow() {
+ super.ensureBottomGlow()
+ if (!this.hasAppliedThemeColorBottom) {
+ this.hasAppliedThemeColorBottom = this.applyThemeColor(this.mBottomGlowField)
+ }
+
+ }
+}
diff --git a/app/src/main/java/org/autojs/autojs/ui/main/task/TaskListRecyclerView.java b/app/src/main/java/org/autojs/autojs/ui/main/task/TaskListRecyclerView.java
index 67344bcb..c73a6437 100644
--- a/app/src/main/java/org/autojs/autojs/ui/main/task/TaskListRecyclerView.java
+++ b/app/src/main/java/org/autojs/autojs/ui/main/task/TaskListRecyclerView.java
@@ -5,7 +5,6 @@ import android.graphics.drawable.GradientDrawable;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
-import androidx.appcompat.widget.ThemeColorRecyclerView;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
@@ -34,6 +33,7 @@ import org.autojs.autojs.ui.timing.TimedTaskSettingActivity_;
import java.util.ArrayList;
import java.util.List;
+import androidx.recyclerview.widget.ThemeColorRecyclerView;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
diff --git a/app/src/main/java/org/autojs/autojs/ui/widget/ExpandableRecyclerView.java b/app/src/main/java/org/autojs/autojs/ui/widget/ExpandableRecyclerView.java
index 36069254..f61bdc1f 100644
--- a/app/src/main/java/org/autojs/autojs/ui/widget/ExpandableRecyclerView.java
+++ b/app/src/main/java/org/autojs/autojs/ui/widget/ExpandableRecyclerView.java
@@ -3,7 +3,8 @@ package org.autojs.autojs.ui.widget;
import android.content.Context;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
-import androidx.appcompat.widget.ThemeColorRecyclerView;
+import androidx.recyclerview.widget.ThemeColorRecyclerView;
+
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml
index f557815c..badc6910 100644
--- a/app/src/main/res/values-zh/strings.xml
+++ b/app/src/main/res/values-zh/strings.xml
@@ -25,9 +25,6 @@
Issues不可用,请联系软件开发者.
未知错误
OK
-
- - 描述至少要 %d 个字.
- - 描述至少要 %d 个字.
-
+
R
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 07aaf55a..2f3d7048 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -431,4 +431,8 @@
Auto.js启动时
查看使用统计权限
通过\"查看使用统计\"权限可以获取本设备过去使用应用的情况,从而使获取当前应用(currentPackage)时更准确。
+
+ - 描述至少要 %d 个字.
+ - 描述至少要 %d 个字.
+
diff --git a/autojs/src/main/assets/modules/__engines__.js b/autojs/src/main/assets/modules/__engines__.js
index af43025a..ace4493b 100644
--- a/autojs/src/main/assets/modules/__engines__.js
+++ b/autojs/src/main/assets/modules/__engines__.js
@@ -18,7 +18,7 @@ module.exports = function(__runtime__, scope){
}
engines.myEngine = function(){
- var engine = rtEngines.myEngine();
+ var engine = Object.create(rtEngines.myEngine());
if(!execArgv){
execArgv = {};
var iter = engine.getTag("execution.config").getArguments().entrySet().iterator();
@@ -26,8 +26,8 @@ module.exports = function(__runtime__, scope){
var entry = iter.next();
execArgv[entry.getKey()] = entry.getValue();
}
- engine.execArgv = execArgv;
}
+ engine.execArgv = execArgv;
return engine;
}
diff --git a/autojs/src/main/java/com/stardust/autojs/engine/RhinoJavaScriptEngine.java b/autojs/src/main/java/com/stardust/autojs/engine/RhinoJavaScriptEngine.java
index 4f63483c..4446466e 100644
--- a/autojs/src/main/java/com/stardust/autojs/engine/RhinoJavaScriptEngine.java
+++ b/autojs/src/main/java/com/stardust/autojs/engine/RhinoJavaScriptEngine.java
@@ -5,6 +5,7 @@ import android.view.View;
import com.stardust.autojs.BuildConfig;
import com.stardust.autojs.core.ui.ViewExtras;
+import com.stardust.autojs.rhino.NativeJavaObjectWithPrototype;
import com.stardust.autojs.rhino.RhinoAndroidHelper;
import com.stardust.autojs.rhino.TopLevelScope;
import com.stardust.autojs.runtime.ScriptRuntime;
diff --git a/automator/src/main/java/com/stardust/automator/UiObject.kt b/automator/src/main/java/com/stardust/automator/UiObject.kt
index e5668710..2efb7150 100644
--- a/automator/src/main/java/com/stardust/automator/UiObject.kt
+++ b/automator/src/main/java/com/stardust/automator/UiObject.kt
@@ -105,7 +105,7 @@ open class UiObject(info: Any?, private val allocator: AccessibilityNodeInfoAllo
return drawingOrder
}
- open fun id(): String {
+ open fun id(): String? {
return viewIdResourceName
}
@@ -145,21 +145,21 @@ open class UiObject(info: Any?, private val allocator: AccessibilityNodeInfoAllo
}
override fun performAction(action: Int, bundle: Bundle): Boolean {
- try {
- return super.performAction(action, bundle)
+ return try {
+ super.performAction(action, bundle)
} catch (e: IllegalStateException) {
// FIXME: 2017/5/5
- return false
+ false
}
}
override fun performAction(action: Int): Boolean {
- try {
- return super.performAction(action)
+ return try {
+ super.performAction(action)
} catch (e: IllegalStateException) {
// FIXME: 2017/5/5
- return false
+ false
}
@@ -374,7 +374,8 @@ open class UiObject(info: Any?, private val allocator: AccessibilityNodeInfoAllo
}
override fun findAccessibilityNodeInfosByViewId(viewId: String): List {
- return allocator?.findAccessibilityNodeInfosByViewId(this, viewId) ?: super.findAccessibilityNodeInfosByViewId(viewId)
+ return allocator?.findAccessibilityNodeInfosByViewId(this, viewId)
+ ?: super.findAccessibilityNodeInfosByViewId(viewId)
}
fun findByViewId(viewId: String): List {
diff --git a/automator/src/main/java/com/stardust/view/accessibility/AccessibilityInfoProvider.kt b/automator/src/main/java/com/stardust/view/accessibility/AccessibilityInfoProvider.kt
index 581293f3..8d6892a4 100644
--- a/automator/src/main/java/com/stardust/view/accessibility/AccessibilityInfoProvider.kt
+++ b/automator/src/main/java/com/stardust/view/accessibility/AccessibilityInfoProvider.kt
@@ -34,7 +34,7 @@ class AccessibilityInfoProvider(private val context: Context) : AccessibilityDel
var latestActivity = ""
private set
- var useUsageStats: Boolean = true
+ var useUsageStats: Boolean = false
override val eventTypes: Set?
get() = AccessibilityDelegate.ALL_EVENT_TYPES
@@ -59,7 +59,7 @@ class AccessibilityInfoProvider(private val context: Context) : AccessibilityDel
val current = System.currentTimeMillis()
val usageStats = usageStatsManager.queryUsageStats(UsageStatsManager.INTERVAL_BEST, current - 60 * 60 * 1000, current)
return if (usageStats.isEmpty()) {
- ""
+ mLatestPackage
} else {
usageStats.sortBy {
it.lastTimeStamp
diff --git a/common/release/output.json b/common/release/output.json
index cb815497..f9a90a91 100644
--- a/common/release/output.json
+++ b/common/release/output.json
@@ -1 +1 @@
-[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":440,"versionName":"4.0.4 Alpha11","enabled":true,"outputFile":"commonRelease-4.0.4 Alpha11.apk","fullName":"commonRelease","baseName":"common-release"},"path":"commonRelease-4.0.4 Alpha11.apk","properties":{}}]
\ No newline at end of file
+[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":441,"versionName":"4.0.4 Alpha12","enabled":true,"outputFile":"commonRelease-4.0.4 Alpha12.apk","fullName":"commonRelease","baseName":"common-release"},"path":"commonRelease-4.0.4 Alpha12.apk","properties":{}}]
\ No newline at end of file
diff --git a/project-versions.json b/project-versions.json
index fc701e30..a9f244d6 100644
--- a/project-versions.json
+++ b/project-versions.json
@@ -1,6 +1,6 @@
{
- "appVersionCode": 440,
- "appVersionName": "4.0.4 Alpha11",
+ "appVersionCode": 441,
+ "appVersionName": "4.0.4 Alpha12",
"target": 28,
"mini": 17,
"compile": 28,