Skip to content

Commit aebff92

Browse files
committed
YouTube: Fix notification tab missing the filled icon
1 parent dd4e098 commit aebff92

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

app/src/main/java/io/github/chsbuffer/revancedxposed/youtube/misc/NavigationBarHook.kt

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import io.github.chsbuffer.revancedxposed.AccessFlags
1010
import io.github.chsbuffer.revancedxposed.ScopedHook
1111
import io.github.chsbuffer.revancedxposed.accessFlags
1212
import io.github.chsbuffer.revancedxposed.fingerprint
13+
import io.github.chsbuffer.revancedxposed.isStatic
1314
import io.github.chsbuffer.revancedxposed.literal
1415
import io.github.chsbuffer.revancedxposed.returns
1516
import io.github.chsbuffer.revancedxposed.youtube.YoutubeHook
@@ -103,4 +104,41 @@ fun YoutubeHook.NavigationBarHook() {
103104
initializeButtonsFingerprint.hookMethod(ScopedHook(pivotBarButtonsCreateResourceViewFingerprint.toMethod()) {
104105
after { NavigationBar.navigationImageResourceTabLoaded(param.result as View) }
105106
})
107+
108+
// Fix YT bug of notification tab missing the filled icon.
109+
val tabActivityCairo =
110+
navigationEnumClass.toClass().enumConstants?.firstOrNull { (it as? Enum<*>)?.name == "TAB_ACTIVITY_CAIRO" } as? Enum<*>
111+
if (tabActivityCairo != null) {
112+
val setEnumMapFingerprint = getDexMethod("setEnumMapFingerprint") {
113+
fingerprint {
114+
returns("V")
115+
literal {
116+
Utils.getResourceIdentifier("yt_fill_bell_black_24", "drawable")
117+
}
118+
}
119+
}
120+
121+
val processFields: (Any?, Class<*>) -> Unit = { obj, clazz ->
122+
clazz.declaredFields.forEach { field ->
123+
field.isAccessible = true
124+
if (obj == null && !field.isStatic) return@forEach
125+
val enumMap = field.get(obj) as? EnumMap<*, *> ?: return@forEach
126+
// check is valueType int (resource id)
127+
val valueType = enumMap.values.firstOrNull()?.javaClass ?: return@forEach
128+
if (valueType != Int::class.javaObjectType) return@forEach
129+
if (!enumMap.containsKey(tabActivityCairo))
130+
NavigationBar.setCairoNotificationFilledIcon(enumMap, tabActivityCairo)
131+
}
132+
}
133+
134+
if (setEnumMapFingerprint.isStaticInitializer) {
135+
processFields(null, classLoader.loadClass(setEnumMapFingerprint.declaredClassName))
136+
} else {
137+
setEnumMapFingerprint.hookMethod(object : XC_MethodHook() {
138+
override fun afterHookedMethod(param: MethodHookParam) {
139+
processFields(param.thisObject, param.thisObject.javaClass)
140+
}
141+
})
142+
}
143+
}
106144
}

0 commit comments

Comments
 (0)