fix(core): accessibility strings
Signed-off-by: rhunk <101876869+rhunk@users.noreply.github.com>
This commit is contained in:
1
app/proguard-rules.pro
vendored
1
app/proguard-rules.pro
vendored
@@ -7,6 +7,7 @@
|
||||
-keep class org.mozilla.javascript.** { *; }
|
||||
-keep class androidx.compose.material.icons.** { *; }
|
||||
-keep class androidx.compose.material3.R$* { *; }
|
||||
-keep class androidx.compose.ui.R$* { *; }
|
||||
-keep class androidx.navigation.** { *; }
|
||||
-keep class me.rhunk.snapenhance.** { *; }
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import me.rhunk.snapenhance.core.util.hook.HookAdapter
|
||||
import me.rhunk.snapenhance.core.util.hook.HookStage
|
||||
import me.rhunk.snapenhance.core.util.hook.hook
|
||||
import me.rhunk.snapenhance.core.util.hook.hookConstructor
|
||||
import kotlin.reflect.KClass
|
||||
import kotlin.system.exitProcess
|
||||
import kotlin.system.measureTimeMillis
|
||||
|
||||
@@ -95,6 +96,7 @@ class SnapEnhance {
|
||||
}.onFailure {
|
||||
appContext.log.error("Failed to init LSPatchUpdater", it)
|
||||
}
|
||||
jetpackComposeResourceHook()
|
||||
runCatching {
|
||||
measureTimeMillis {
|
||||
init(this)
|
||||
@@ -116,7 +118,6 @@ class SnapEnhance {
|
||||
if (isMainActivityNotNull || !appContext.mappings.isMappingsLoaded) return@hookMainActivity
|
||||
appContext.isMainActivityPaused = false
|
||||
onActivityCreate()
|
||||
jetpackComposeResourceHook()
|
||||
appContext.actionManager.onNewIntent(intent)
|
||||
}
|
||||
|
||||
@@ -320,16 +321,14 @@ class SnapEnhance {
|
||||
}
|
||||
|
||||
private fun jetpackComposeResourceHook() {
|
||||
val material3RString = try {
|
||||
Class.forName("androidx.compose.material3.R\$string")
|
||||
} catch (e: ClassNotFoundException) {
|
||||
return
|
||||
fun strings(vararg classes: KClass<*>): Map<Int, String> {
|
||||
return classes.fold(mapOf()) { map, clazz ->
|
||||
map + clazz.java.fields.filter {
|
||||
java.lang.reflect.Modifier.isStatic(it.modifiers) && it.type == Int::class.javaPrimitiveType
|
||||
}.associate { it.getInt(null) to it.name }
|
||||
}
|
||||
}
|
||||
|
||||
val stringResources = material3RString.fields.filter {
|
||||
java.lang.reflect.Modifier.isStatic(it.modifiers) && it.type == Int::class.javaPrimitiveType
|
||||
}.associate { it.getInt(null) to it.name }
|
||||
|
||||
val stringResources = strings(androidx.compose.material3.R.string::class, androidx.compose.ui.R.string::class)
|
||||
Resources::class.java.getMethod("getString", Int::class.javaPrimitiveType).hook(HookStage.BEFORE) { param ->
|
||||
val key = param.arg<Int>(0)
|
||||
val name = stringResources[key]?.replaceFirst("m3c_", "") ?: return@hook
|
||||
|
||||
Reference in New Issue
Block a user