Skip to content

Commit

Permalink
opt: change isMiui to isXiaoMi & add Deprecated tag for `toggle…
Browse files Browse the repository at this point in the history
…Prompts` (#526)
  • Loading branch information
HChenX authored Jan 19, 2025
1 parent 1adf1fc commit 0858b0c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 32 deletions.
58 changes: 29 additions & 29 deletions app/src/main/kotlin/statusbar/lyric/hook/module/SystemUILyric.kt
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ import statusbar.lyric.tools.Tools.goMainThread
import statusbar.lyric.tools.Tools.ifNotNull
import statusbar.lyric.tools.Tools.isHyperOS
import statusbar.lyric.tools.Tools.isLandscape
import statusbar.lyric.tools.Tools.isMiui
import statusbar.lyric.tools.Tools.isXiaoMi
import statusbar.lyric.tools.Tools.isNot
import statusbar.lyric.tools.Tools.isNotNull
import statusbar.lyric.tools.Tools.isNull
Expand Down Expand Up @@ -263,7 +263,7 @@ class SystemUILyric : BaseHook() {
}
canLoad = false
lyricInit()
if (!togglePrompts) hook.unhook()
// if (!togglePrompts) hook.unhook()
}
}
}
Expand Down Expand Up @@ -1027,7 +1027,7 @@ class SystemUILyric : BaseHook() {

inner class SystemUISpecial {
init {
if (isMiui) {
if (isXiaoMi) {
for (i in 0..10) {
val clazz = loadClassOrNull("com.android.keyguard.wallpaper.MiuiKeyguardWallPaperManager\$$i")
if (clazz.isNotNull()) {
Expand All @@ -1047,33 +1047,32 @@ class SystemUILyric : BaseHook() {
}
}

if (togglePrompts) {
loadClassOrNull("com.android.systemui.SystemUIApplication").isNotNull { clazz ->
clazz.methodFinder().filterByName("onConfigurationChanged").first().createHook {
after { hookParam ->
"onConfigurationChanged".log()
val newConfig = hookParam.args[0] as Configuration
themeMode = newConfig.uiMode and Configuration.UI_MODE_NIGHT_MASK
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE || newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
changeLyricStateIfInFullScreenMode()
}
// if (togglePrompts) {
loadClassOrNull("com.android.systemui.SystemUIApplication").isNotNull { clazz ->
clazz.methodFinder().filterByName("onConfigurationChanged").first().createHook {
after { hookParam ->
"onConfigurationChanged".log()
val newConfig = hookParam.args[0] as Configuration
themeMode = newConfig.uiMode and Configuration.UI_MODE_NIGHT_MASK
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE || newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
changeLyricStateIfInFullScreenMode()
}
}
if (isMiui && config.mMiuiPadOptimize) {
clazz.methodFinder().filterByName("onCreate").first().createHook {
after {
if (isPad) {
loadClassOrNull("com.android.systemui.statusbar.phone.MiuiCollapsedStatusBarFragment").isNotNull {
if (it.existMethod("initMiuiViewsOnViewCreated")) {
it.methodFinder().filterByName("initMiuiViewsOnViewCreated").first()
} else {
it.methodFinder().filterByName("onViewCreated").first()
}.let { method ->
method.createHook {
after { hookParam ->
hookParam.thisObject.objectHelper {
mPadClockView = this.getObjectOrNullAs<View>("mPadClockView")!!
}
}
if (isXiaoMi && config.mMiuiPadOptimize) {
clazz.methodFinder().filterByName("onCreate").first().createHook {
after {
if (isPad) {
loadClassOrNull("com.android.systemui.statusbar.phone.MiuiCollapsedStatusBarFragment").isNotNull {
if (it.existMethod("initMiuiViewsOnViewCreated")) {
it.methodFinder().filterByName("initMiuiViewsOnViewCreated").first()
} else {
it.methodFinder().filterByName("onViewCreated").first()
}.let { method ->
method.createHook {
after { hookParam ->
hookParam.thisObject.objectHelper {
mPadClockView = this.getObjectOrNullAs<View>("mPadClockView")!!
}
}
}
Expand All @@ -1084,8 +1083,9 @@ class SystemUILyric : BaseHook() {
}
}
}
// }

if (isMiui && config.mMiuiHideNetworkSpeed) {
if (isXiaoMi && config.mMiuiHideNetworkSpeed) {
moduleRes.getString(R.string.miui_hide_network_speed).log()
loadClassOrNull("com.android.systemui.statusbar.views.NetworkSpeedView").isNotNull {
it.constructorFinder().first().createHook {
Expand Down
7 changes: 4 additions & 3 deletions app/src/main/kotlin/statusbar/lyric/tools/Tools.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ object Tools {

private var index: Int = 0

val isMiui by lazy { isPresent("android.provider.MiuiSettings") }
val isXiaoMi by lazy { isPresent("android.provider.MiuiSettings") }

val isPad by lazy { getSystemProperties("ro.build.characteristics") == "tablet" }

Expand All @@ -70,7 +70,7 @@ object Tools {
val getPhoneName by lazy {
val marketName = getSystemProperties("ro.product.marketname")
val vivomarketName = getSystemProperties("ro.vivo.market.name")
if (bigtextone(Build.BRAND) =="Vivo" ){
if (bigtextone(Build.BRAND) == "Vivo") {
bigtextone(vivomarketName)
} else {
if (marketName.isNotEmpty()) bigtextone(marketName) else bigtextone(Build.BRAND) + " " + Build.MODEL
Expand All @@ -87,11 +87,12 @@ object Tools {
fun dp2px(context: Context, dpValue: Float): Int =
TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dpValue, context.resources.displayMetrics).toInt()

@Deprecated(message = "")
val togglePrompts: Boolean
get() {
arrayOf("com.lge.adaptive.JavaImageUtil").forEach {
if (isPresent(it)) return true
if (isMiui) return true
if (isXiaoMi) return true
}
return false
}
Expand Down

0 comments on commit 0858b0c

Please sign in to comment.