-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from GuoXiCheng/dev
Dev
- Loading branch information
Showing
23 changed files
with
448 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
*.ap_ | ||
*.aab | ||
*.json | ||
|
||
!/app/src/main/res/raw/*.json | ||
# Files for the ART/Dalvik VM | ||
*.dex | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package com.android.skip | ||
|
||
import android.content.pm.PackageManager | ||
import android.graphics.drawable.Drawable | ||
import android.os.Bundle | ||
import androidx.activity.ComponentActivity | ||
import androidx.activity.compose.setContent | ||
import androidx.compose.foundation.Image | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.foundation.lazy.LazyColumn | ||
import androidx.compose.material3.Surface | ||
import androidx.compose.material3.Switch | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.asImageBitmap | ||
import androidx.compose.ui.text.font.FontWeight | ||
import androidx.compose.ui.unit.dp | ||
import androidx.compose.ui.unit.sp | ||
import androidx.core.graphics.drawable.toBitmap | ||
|
||
val mutableList = mutableListOf<AppData>() | ||
|
||
class WhitelistActivity : ComponentActivity() { | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
mutableList.clear() | ||
|
||
val packages = packageManager.getInstalledPackages(PackageManager.GET_META_DATA) | ||
packages.forEach { | ||
val appName = it.applicationInfo.loadLabel(packageManager).toString() | ||
val packageName = it.packageName | ||
|
||
if (!MyUtils.isExcludeApplication(appName, packageName, packageManager)) { | ||
mutableList.add(AppData(it.applicationInfo.loadIcon(packageManager), appName, false)) | ||
} | ||
|
||
|
||
} | ||
|
||
setContent { | ||
Whitelist(mutableList) | ||
} | ||
|
||
} | ||
} | ||
data class AppData( | ||
val icon: Drawable, | ||
val name: String, | ||
var enabled: Boolean | ||
) | ||
@Composable | ||
fun Whitelist (appList: List<AppData>) { | ||
Surface( | ||
modifier = Modifier.fillMaxSize() | ||
) { | ||
LazyColumn { | ||
|
||
items(appList.size) { index -> | ||
val item = appList[index] | ||
Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.padding(30.dp, 10.dp)) { | ||
|
||
Image( | ||
bitmap = item.icon.toBitmap().asImageBitmap(), | ||
contentDescription = "${item.name} Icon", // 添加图标的描述,通常用于辅助功能 | ||
modifier = Modifier.size(48.dp) // 可选:设置图标的大小 | ||
) | ||
|
||
Text(item.name, modifier = Modifier.weight(1f).padding(10.dp, 0.dp), fontSize = 20.sp, fontWeight = FontWeight.Bold) | ||
|
||
Switch(checked = item.enabled, onCheckedChange = { | ||
item.enabled = it | ||
}) | ||
|
||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.android.skip.dataclass | ||
|
||
data class PackageInfo( | ||
val package_name: String, val skip_text: String?, | ||
val skip_id: String?, val start_page_node: Int?, | ||
val skip_point: String? | ||
) |
20 changes: 20 additions & 0 deletions
20
app/src/main/java/com/android/skip/handler/AbstractHandler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.android.skip.handler | ||
|
||
import android.graphics.Rect | ||
import android.view.accessibility.AccessibilityNodeInfo | ||
|
||
abstract class AbstractHandler: NodeHandler { | ||
private var nextHandler: NodeHandler? = null | ||
|
||
override fun handle(node: AccessibilityNodeInfo): List<Rect> { | ||
if (nextHandler != null) { | ||
return nextHandler!!.handle(node) | ||
} | ||
return listOf() | ||
} | ||
|
||
override fun setNextHandler(handler: NodeHandler): NodeHandler { | ||
nextHandler = handler | ||
return handler | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
app/src/main/java/com/android/skip/handler/IdNodeHandler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.android.skip.handler | ||
|
||
import android.graphics.Rect | ||
import android.view.accessibility.AccessibilityNodeInfo | ||
import com.android.skip.manager.SkipConfigManager | ||
|
||
class IdNodeHandler: AbstractHandler() { | ||
override fun handle(node: AccessibilityNodeInfo): List<Rect> { | ||
val listOfRect = node.findAccessibilityNodeInfosByViewId( | ||
SkipConfigManager.getSkipId(node.packageName.toString()) | ||
).map { | ||
val rect = Rect() | ||
it.getBoundsInScreen(rect) | ||
rect | ||
} | ||
|
||
return listOfRect.ifEmpty { | ||
super.handle(node) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.android.skip.handler | ||
|
||
import android.graphics.Rect | ||
import android.view.accessibility.AccessibilityNodeInfo | ||
|
||
interface NodeHandler { | ||
fun handle(node: AccessibilityNodeInfo): List<Rect> | ||
fun setNextHandler (handler: NodeHandler): NodeHandler | ||
} |
16 changes: 16 additions & 0 deletions
16
app/src/main/java/com/android/skip/handler/PointHandler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.android.skip.handler | ||
|
||
import android.graphics.Rect | ||
import android.view.accessibility.AccessibilityNodeInfo | ||
import com.android.skip.manager.SkipConfigManager | ||
|
||
class PointHandler: AbstractHandler() { | ||
override fun handle(node: AccessibilityNodeInfo): List<Rect> { | ||
val skipPoint = SkipConfigManager.getSkipPoint(node.packageName.toString()) | ||
return if (skipPoint != null) { | ||
listOf(skipPoint) | ||
} else { | ||
super.handle(node) | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
app/src/main/java/com/android/skip/handler/TextNodeHandler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.android.skip.handler | ||
|
||
import android.graphics.Rect | ||
import android.view.accessibility.AccessibilityNodeInfo | ||
import com.android.skip.manager.SkipConfigManager | ||
|
||
class TextNodeHandler : AbstractHandler() { | ||
override fun handle(node: AccessibilityNodeInfo): List<Rect> { | ||
val listOfRect = node.findAccessibilityNodeInfosByText( | ||
SkipConfigManager.getSkipText(node.packageName.toString()) | ||
).map { | ||
val rect = Rect() | ||
it.getBoundsInScreen(rect) | ||
rect | ||
} | ||
return listOfRect.ifEmpty { | ||
super.handle(node) | ||
} | ||
} | ||
} |
Oops, something went wrong.