6.0.0 - 部分插件及工具版本更新
This commit is contained in:
@@ -1,23 +1,25 @@
|
||||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlin-android-extensions'
|
||||
|
||||
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
|
||||
kotlinOptions {
|
||||
jvmTarget = JavaVersion.VERSION_16
|
||||
}
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion versions.compile
|
||||
buildToolsVersion versions.buildTool
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion versions.mini
|
||||
targetSdkVersion versions.target
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
sourceCompatibility JavaVersion.VERSION_16
|
||||
targetCompatibility JavaVersion.VERSION_16
|
||||
}
|
||||
lintOptions {
|
||||
abortOnError false
|
||||
@@ -31,17 +33,11 @@ android {
|
||||
}
|
||||
|
||||
repositories {
|
||||
flatDir {
|
||||
dirs 'libs'
|
||||
}
|
||||
google()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.1-alpha01', {
|
||||
exclude group: 'com.android.support', module: 'support-annotations'
|
||||
})
|
||||
testImplementation 'junit:junit:4.12'
|
||||
api 'androidx.appcompat:appcompat:1.0.2'
|
||||
api project(path: ':common')
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
api 'androidx.appcompat:appcompat:1.4.0'
|
||||
api project(':common')
|
||||
}
|
||||
|
||||
@@ -117,18 +117,21 @@ class GlobalActionAutomator(private val mHandler: Handler?, private val serviceP
|
||||
private fun gesturesWithoutHandler(description: GestureDescription): Boolean {
|
||||
prepareLooperIfNeeded()
|
||||
val result = VolatileBox(false)
|
||||
val handler = Handler(Looper.myLooper())
|
||||
service.dispatchGesture(description, object : AccessibilityService.GestureResultCallback() {
|
||||
override fun onCompleted(gestureDescription: GestureDescription) {
|
||||
result.set(true)
|
||||
quitLoop()
|
||||
}
|
||||
val myLooper = Looper.myLooper()
|
||||
if (myLooper != null) {
|
||||
val handler = Handler(myLooper)
|
||||
service.dispatchGesture(description, object : AccessibilityService.GestureResultCallback() {
|
||||
override fun onCompleted(gestureDescription: GestureDescription) {
|
||||
result.set(true)
|
||||
quitLoop()
|
||||
}
|
||||
|
||||
override fun onCancelled(gestureDescription: GestureDescription) {
|
||||
result.set(false)
|
||||
quitLoop()
|
||||
}
|
||||
}, handler)
|
||||
override fun onCancelled(gestureDescription: GestureDescription) {
|
||||
result.set(false)
|
||||
quitLoop()
|
||||
}
|
||||
}, handler)
|
||||
}
|
||||
Looper.loop()
|
||||
return result.get()
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ object BFS : SearchAlgorithm {
|
||||
val queue = ArrayDeque<UiObject>()
|
||||
queue.add(root)
|
||||
while (!queue.isEmpty()) {
|
||||
val top = queue.poll()
|
||||
val top = queue.poll()!!
|
||||
val isTarget = filter.filter(top)
|
||||
if (isTarget) {
|
||||
result.add(top)
|
||||
|
||||
@@ -16,28 +16,28 @@ interface Able {
|
||||
|
||||
val ABLE_MAP = SparseArrayEntries<Able>()
|
||||
.entry(AccessibilityNodeInfo.ACTION_CLICK, object : Able {
|
||||
override fun isAble(nodeInfo: UiObject): Boolean {
|
||||
return nodeInfo.isClickable
|
||||
override fun isAble(node: UiObject): Boolean {
|
||||
return node.isClickable
|
||||
}
|
||||
})
|
||||
.entry(AccessibilityNodeInfo.ACTION_LONG_CLICK, object : Able {
|
||||
override fun isAble(nodeInfo: UiObject): Boolean {
|
||||
return nodeInfo.isLongClickable
|
||||
override fun isAble(node: UiObject): Boolean {
|
||||
return node.isLongClickable
|
||||
}
|
||||
})
|
||||
.entry(AccessibilityNodeInfo.ACTION_FOCUS, object : Able {
|
||||
override fun isAble(nodeInfo: UiObject): Boolean {
|
||||
return nodeInfo.isFocusable
|
||||
override fun isAble(node: UiObject): Boolean {
|
||||
return node.isFocusable
|
||||
}
|
||||
})
|
||||
.entry(AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD, object : Able {
|
||||
override fun isAble(nodeInfo: UiObject): Boolean {
|
||||
return nodeInfo.isScrollable
|
||||
override fun isAble(node: UiObject): Boolean {
|
||||
return node.isScrollable
|
||||
}
|
||||
})
|
||||
.entry(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD, object : Able {
|
||||
override fun isAble(nodeInfo: UiObject): Boolean {
|
||||
return nodeInfo.isScrollable
|
||||
override fun isAble(node: UiObject): Boolean {
|
||||
return node.isScrollable
|
||||
}
|
||||
})
|
||||
.sparseArray()
|
||||
|
||||
@@ -7,20 +7,20 @@ import com.stardust.automator.UiObject
|
||||
* Created by Stardust on 2017/1/27.
|
||||
*/
|
||||
|
||||
class SearchUpTargetAction(action: Int, filter: FilterAction.Filter) : SearchTargetAction(action, filter) {
|
||||
class SearchUpTargetAction(action: Int, filter: Filter) : SearchTargetAction(action, filter) {
|
||||
private val mAble: Able = Able.ABLE_MAP.get(action)
|
||||
|
||||
override fun searchTarget(n: UiObject?): UiObject? {
|
||||
var node = n
|
||||
override fun searchTarget(node: UiObject?): UiObject? {
|
||||
var o = node
|
||||
var i = 0
|
||||
while (node != null && !mAble.isAble(node)) {
|
||||
while (o != null && !mAble.isAble(o)) {
|
||||
i++
|
||||
if (i > LOOP_MAX) {
|
||||
return null
|
||||
}
|
||||
node = node.parent()
|
||||
o = o.parent()
|
||||
}
|
||||
return node
|
||||
return o
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
@@ -31,8 +31,6 @@ class SearchUpTargetAction(action: Int, filter: FilterAction.Filter) : SearchTar
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
private val TAG = SearchUpTargetAction::class.java!!.getSimpleName()
|
||||
private val LOOP_MAX = 20
|
||||
private const val LOOP_MAX = 20
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,8 +83,9 @@ open class AccessibilityNodeInfoAllocator {
|
||||
try {
|
||||
key.recycle()
|
||||
notRecycledCount++
|
||||
if (DEBUG)
|
||||
if (DEBUG && value !== null) {
|
||||
Log.w(TAG, value)
|
||||
}
|
||||
} catch (ignored: IllegalStateException) {
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
package com.stardust.view.accessibility
|
||||
|
||||
import android.graphics.Rect
|
||||
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat
|
||||
import android.view.accessibility.AccessibilityNodeInfo
|
||||
|
||||
import com.stardust.automator.UiObject
|
||||
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/3/6.
|
||||
@@ -20,6 +18,7 @@ object AccessibilityNodeInfoHelper {
|
||||
* @param height pixel height of the display
|
||||
* @return null if node is null, else a Rect containing visible bounds
|
||||
*/
|
||||
@Suppress("unused")
|
||||
fun getVisibleBoundsInScreen(node: AccessibilityNodeInfo?, width: Int, height: Int): Rect? {
|
||||
if (node == null) {
|
||||
return null
|
||||
@@ -33,7 +32,6 @@ object AccessibilityNodeInfoHelper {
|
||||
displayRect.left = 0
|
||||
displayRect.right = width
|
||||
displayRect.bottom = height
|
||||
val intersect = nodeRect.intersect(displayRect)
|
||||
return nodeRect
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.stardust.view.accessibility
|
||||
|
||||
import android.accessibilityservice.*
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import android.view.accessibility.AccessibilityEvent
|
||||
@@ -8,7 +7,6 @@ import android.view.accessibility.AccessibilityEvent
|
||||
import com.stardust.notification.Notification
|
||||
|
||||
import java.util.ArrayList
|
||||
import java.util.Collections
|
||||
import java.util.concurrent.CopyOnWriteArrayList
|
||||
|
||||
/**
|
||||
@@ -81,14 +79,14 @@ class AccessibilityNotificationObserver(private val mContext: Context) : Notific
|
||||
return false
|
||||
}
|
||||
if (list != null) {
|
||||
onToast(event, Toast(event.packageName.toString(), list))
|
||||
onToast(Toast(event.packageName.toString(), list))
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
private fun onToast(event: AccessibilityEvent, toast: Toast) {
|
||||
private fun onToast(toast: Toast) {
|
||||
for (listener in mToastListeners) {
|
||||
try {
|
||||
listener.onToast(toast)
|
||||
|
||||
Reference in New Issue
Block a user