Browse Source

159新版

xiongzhu 1 year ago
parent
commit
a393a2c7d3

+ 1 - 1
app/build.gradle

@@ -24,7 +24,7 @@ android {
         applicationId "com.example.modifier"
         minSdk 29
         targetSdk 34
-        versionCode 158
+        versionCode 159
         versionName "1.0.1"
         archivesBaseName = "modifier-${versionCode}"
 

+ 17 - 9
app/src/main/java/com/example/modifier/service/ScreenInspector.kt

@@ -27,12 +27,12 @@ class ScreenInspector(val context: AccessibilityService) {
         )
         val className = node.className?.toString()
         val name = node.viewIdResourceName
-        val text = Optional.ofNullable(node.text).map { obj: CharSequence -> obj.toString() }
-            .orElse(null)
+        val text = node.text?.toString() ?: ""
         val id = node.viewIdResourceName
+        val desc = node.contentDescription?.toString() ?: ""
 
         if (log) {
-            Log.d(TAG, "Node: class=$className, text=$text, name=$name, id=$id")
+            Log.d(TAG, "Node: class=$className, text=$text, dec=$desc, name=$name, id=$id")
         }
 
         if ("Compose:Draft:Send" == name) {
@@ -43,9 +43,10 @@ class ScreenInspector(val context: AccessibilityService) {
             result.sendBtn = node
         }
 
-        if (text != null && (text.contains("RCS 聊天") || text.contains("RCS chat") || text.contains(
-                "Chat with"
-            ))
+        if (text.contains("RCS 聊天")
+            || text.contains("聊天对话")
+            || text.contains("RCS chat")
+            || text.contains("Chat with")
         ) {
             result.isRcsCapable = true
         }
@@ -54,8 +55,10 @@ class ScreenInspector(val context: AccessibilityService) {
             result.isRcsCapable = text.contains("聊天") || text.contains("Chatting with")
         }
 
-        if (text != null && (text.contains("Turn on RCS chats") || text.contains("开启 RCS 聊天功能")
-                    || text.contains("Enable chat features") || text.contains("启用聊天功能"))
+        if (text.contains("Turn on RCS chats")
+            || text.contains("开启 RCS 聊天功能")
+            || text.contains("Enable chat features")
+            || text.contains("启用聊天功能")
         ) {
             fun findSwitch(node: AccessibilityNodeInfo): Boolean {
                 if ("com.google.android.apps.messaging:id/switchWidget" == node.viewIdResourceName) {
@@ -86,7 +89,12 @@ class ScreenInspector(val context: AccessibilityService) {
             }
         }
 
-        if (text != null && (text.contains("end-to-end encrypted") || text.contains("已经过端到端加密"))) {
+        if (text.contains("end-to-end encrypted")
+            || desc.contains("Send encrypted message")
+            || text.contains("已经过端到端加密")
+            || desc.contains("发送加密信息")
+        ) {
+            result.isRcsCapable = true
             result.encrypted = true
         }
 

+ 1 - 4
app/src/test/java/com/example/modifier/ExampleUnitTest.kt

@@ -17,10 +17,7 @@ class ExampleUnitTest {
     @Test
     fun test1() {
         println(
-            FileUtils.readLines(File("/Users/drew/Downloads/pif.json"), "UTF-8")
-                .joinToString("\n") {
-                    it.replace(Regex("^\\s*//.*"), "")
-                }
+            Regex("与.*的聊天对话").matches(null ?: "")
         )
     }