diff --git a/app/build.gradle.kts b/app/build.gradle.kts index a37630ed..b7210c9c 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -17,8 +17,8 @@ android { applicationId = "statusbar.lyric" minSdk = 26 targetSdk = 34 - versionCode = 205 - versionName = "6.1.2" + versionCode = 206 + versionName = "6.1.3" aaptOptions.cruncherEnabled = false aaptOptions.useNewCruncher = false buildConfigField("long", "BUILD_TIME", "$buildTime") @@ -58,7 +58,7 @@ android { } } buildFeatures { - viewBinding = true + viewBinding = false } applicationVariants.all { outputs.all { diff --git a/app/src/main/java/statusbar/lyric/activity/page/ExtendPage.kt b/app/src/main/java/statusbar/lyric/activity/page/ExtendPage.kt index 3d2a6c82..f3cef611 100644 --- a/app/src/main/java/statusbar/lyric/activity/page/ExtendPage.kt +++ b/app/src/main/java/statusbar/lyric/activity/page/ExtendPage.kt @@ -26,7 +26,6 @@ class ExtendPage : BasePage() { TextSw(textId = R.string.hide_notification_icon, key = "hideNotificationIcon", onClickListener = { changeConfig() }) TextSSw(textId = R.string.limit_visibility_change, tipsId = R.string.limit_visibility_change_tips, key = "limitVisibilityChange") TextSw(textId = R.string.hide_lyric_when_lock_screen, key = "hideLyricWhenLockScreen", defValue = true) - TextSw(textId = R.string.hide_carrier, key = "hideCarrier") val lyricColorScheme: LinkedHashMap = LinkedHashMap().apply { this[0] = getString(R.string.color_scheme1) this[1] = getString(R.string.color_scheme2) diff --git a/app/src/main/java/statusbar/lyric/activity/page/SystemSpecialPage.kt b/app/src/main/java/statusbar/lyric/activity/page/SystemSpecialPage.kt index 84ffbf90..40f2a84e 100644 --- a/app/src/main/java/statusbar/lyric/activity/page/SystemSpecialPage.kt +++ b/app/src/main/java/statusbar/lyric/activity/page/SystemSpecialPage.kt @@ -1,5 +1,6 @@ package statusbar.lyric.activity.page +import android.os.Build import cn.fkj233.ui.activity.annotation.BMPage import cn.fkj233.ui.activity.data.BasePage import statusbar.lyric.R @@ -11,6 +12,7 @@ class SystemSpecialPage : BasePage() { if (isMIUI) { TextSw(textId = R.string.miui_hide_network_speed, key = "mMIUIHideNetworkSpeed") TextSw(textId = R.string.miui_pad_optimize, key = "mMiuiPadOptimize") + if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.TIRAMISU) TextSw(textId = R.string.hide_carrier, key = "hideCarrier") } Line() TitleText("Wait for More...") diff --git a/app/src/main/java/statusbar/lyric/config/Config.kt b/app/src/main/java/statusbar/lyric/config/Config.kt index 03622fd8..be5f34f8 100644 --- a/app/src/main/java/statusbar/lyric/config/Config.kt +++ b/app/src/main/java/statusbar/lyric/config/Config.kt @@ -415,6 +415,8 @@ class Config { this["com.tencent.qqmusic"] = qQMusicIcon this["com.miui.player"] = miPlayerIcon this["com.netease.cloudmusic"] = neteaseIcon + this["com.netease.cloudmusic.lite"] = neteaseIcon + this["com.hihonor.cloudmusic"] = neteaseIcon this["com.kugou.android"] = kuGouIcon this["com.kugou.android.lite"] = kuGouIcon this["cn.kuwo.player"] = kuWoIcon diff --git a/app/src/main/java/statusbar/lyric/hook/app/SystemUILyric.kt b/app/src/main/java/statusbar/lyric/hook/app/SystemUILyric.kt index 4d2c5812..590424cd 100644 --- a/app/src/main/java/statusbar/lyric/hook/app/SystemUILyric.kt +++ b/app/src/main/java/statusbar/lyric/hook/app/SystemUILyric.kt @@ -117,6 +117,7 @@ class SystemUILyric : BaseHook() { private var isHiding: Boolean = false private var themeMode: Int by observableChange(0) { oldValue, _ -> if (oldValue == 0) return@observableChange + "onConfigurationChanged".log() canLoad = true hideLyric() } @@ -169,7 +170,7 @@ class SystemUILyric : BaseHook() { private lateinit var mMIUINetworkSpeedView: TextView - val isReally by lazy { this@SystemUILyric::targetView.isInitialized } + val isReally by lazy { this@SystemUILyric::clockView.isInitialized } //////////////////////////////Hook////////////////////////////////////// @SuppressLint("DiscouragedApi") @@ -211,8 +212,7 @@ class SystemUILyric : BaseHook() { } } } - - "${moduleRes.getString(R.string.lyric_color_scheme)}:${moduleRes.getString(R.string.lyric_color_scheme)}".log() + "${moduleRes.getString(R.string.lyric_color_scheme)}:${config.lyricColorScheme}".log() when (config.lyricColorScheme) { 0 -> { loadClassOrNull("com.android.systemui.statusbar.phone.DarkIconDispatcherImpl").isNotNull { @@ -243,21 +243,31 @@ class SystemUILyric : BaseHook() { if (config.hideNotificationIcon) { moduleRes.getString(R.string.hide_notification_icon).log() loadClassOrNull("com.android.systemui.statusbar.phone.NotificationIconAreaController").isNotNull { - it.methodFinder().filterByName("initializeNotificationAreaViews").first().createHook { - after { hookParam -> - val clazz = hookParam.thisObject::class.java - if (clazz.simpleName == "NotificationIconAreaController") { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + it.constructorFinder().first().createHook { + after { hookParam -> hookParam.thisObject.objectHelper { mNotificationIconArea = this.getObjectOrNullAs("mNotificationIconArea")!! } - } else { - mNotificationIconArea = clazz.superclass.getField("mNotificationIconArea").get(hookParam.thisObject) as View + } + } + } else { + it.methodFinder().filterByName("initializeNotificationAreaViews").first().createHook { + after { hookParam -> + val clazz = hookParam.thisObject::class.java + if (clazz.simpleName == "NotificationIconAreaController") { + hookParam.thisObject.objectHelper { + mNotificationIconArea = this.getObjectOrNullAs("mNotificationIconArea")!! + } + } else { + mNotificationIconArea = clazz.superclass.getField("mNotificationIconArea").get(hookParam.thisObject) as View + } } } } } } - if (config.hideCarrier) { + if (config.hideCarrier && Build.VERSION.SDK_INT <= Build.VERSION_CODES.TIRAMISU) { moduleRes.getString(R.string.hide_carrier).log() loadClassOrNull("com.android.systemui.statusbar.phone.KeyguardStatusBarView").isNotNull { it.methodFinder().filterByName("onFinishInflate").first().createHook { @@ -268,7 +278,7 @@ class SystemUILyric : BaseHook() { mCarrierLabel = this.getObjectOrNullAs("mCarrierLabel")!! } } else { - mCarrierLabel = clazz.superclass.getField("mCarrierLabel").get(hookParam.thisObject) as TextView + mCarrierLabel = clazz.superclass.getField("mCarrierLabel").get(hookParam.thisObject) as View } } } @@ -566,9 +576,39 @@ class SystemUILyric : BaseHook() { }).roundToInt() } + private fun Class<*>.hasMethod(methodName: String): Boolean { + val methods = declaredMethods + for (method in methods) { + if (method.name == methodName) { + return true + } + } + return false + } inner class SystemUISpecial { init { + if (isMIUI) { + for (i in 0..10) { + val clazz = loadClassOrNull("com.android.keyguard.wallpaper.MiuiKeyguardWallPaperManager\$$i") + if (clazz.isNotNull()) { + if (clazz!!.hasMethod("onWallpaperChanged")) { + clazz.methodFinder().filterByName("onWallpaperChanged").first().createHook { + after { + if (this@SystemUILyric::clockView.isInitialized) { + "onWallpaperChanged".log() + canLoad = true + hideLyric() + } + } + } + } + break + } + } + } + + if (togglePrompts) { loadClassOrNull("com.android.systemui.SystemUIApplication").isNotNull { clazz -> clazz.methodFinder().filterByName("onConfigurationChanged").first().createHook { @@ -583,10 +623,16 @@ class SystemUILyric : BaseHook() { after { if (isPad) { loadClassOrNull("com.android.systemui.statusbar.phone.MiuiCollapsedStatusBarFragment").isNotNull { - it.methodFinder().filterByName("initMiuiViewsOnViewCreated").first().createHook { - after { hookParam -> - hookParam.thisObject.objectHelper { - mPadClockView = this.getObjectOrNullAs("mPadClockView")!! + if (it.hasMethod("initMiuiViewsOnViewCreated")) { + it.methodFinder().filterByName("initMiuiViewsOnViewCreated").first() + } else { + it.methodFinder().filterByName("onViewCreated").first() + }.let { method -> + method.createHook { + after { hookParam -> + hookParam.thisObject.objectHelper { + mPadClockView = this.getObjectOrNullAs("mPadClockView")!! + } } } } diff --git a/build.gradle.kts b/build.gradle.kts index 575dd634..8c337337 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -4,8 +4,8 @@ buildscript { mavenCentral() } dependencies { + classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.22") classpath("com.android.tools.build:gradle:8.1.3") - classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.20") } }