Skip to content

Commit

Permalink
opt: 优化控制中心大时钟过渡动画 (#506)
Browse files Browse the repository at this point in the history
  • Loading branch information
HChenX authored Dec 29, 2024
1 parent 9ca3b9f commit 94cf128
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions app/src/main/kotlin/statusbar/lyric/hook/module/SystemUILyric.kt
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ import statusbar.lyric.tools.Tools.isNull
import statusbar.lyric.tools.Tools.isPad
import statusbar.lyric.tools.Tools.isTargetView
import statusbar.lyric.tools.Tools.observableChange
import statusbar.lyric.tools.Tools.setObjectField
import statusbar.lyric.tools.Tools.shell
import statusbar.lyric.tools.Tools.togglePrompts
import statusbar.lyric.view.LyricSwitchView
Expand Down Expand Up @@ -531,25 +532,27 @@ class SystemUILyric : BaseHook() {
}
}
}
}

loadClassOrNull("com.android.systemui.controlcenter.shade.NotificationHeaderExpandController\$notificationCallback\$1").isNotNull {
it.methodFinder().filterByName("onExpansionChanged").first().createHook {
before { hook ->
if (isPlaying && !isHiding) {
val notificationHeaderExpandController = hook.thisObject.getObjectField("this\$0")
val headerController = notificationHeaderExpandController?.getObjectField("headerController")
val combinedHeaderController = headerController?.callMethod("get")
val notificationBigTime = combinedHeaderController?.getObjectField("notificationBigTime") as View
// val notificationDateTime = combinedHeaderController.getObjectField("notificationDateTime") as View

val f = hook.args[0] as Float
if (f < 0.8f)
notificationBigTime.visibility = View.GONE
else
notificationBigTime.visibility = View.VISIBLE

this@SystemUILyric.notificationBigTime = notificationBigTime
}
loadClassOrNull("com.android.systemui.controlcenter.shade.NotificationHeaderExpandController\$notificationCallback\$1").isNotNull {
it.methodFinder().filterByName("onExpansionChanged").first().createHook {
before { hook ->
if (isPlaying && !isHiding) {
val notificationHeaderExpandController = hook.thisObject.getObjectField("this\$0")
notificationHeaderExpandController?.setObjectField("bigTimeTranslationY", 0)
notificationHeaderExpandController?.setObjectField("notificationTranslationX", 0)
// notificationHeaderExpandController?.setObjectField("notificationTranslationY", 0)

val notificationBigTime = notificationHeaderExpandController?.getObjectField("headerController")
?.callMethod("get")?.getObjectField("notificationBigTime") as View

val f = hook.args[0] as Float
if (f < 0.75f)
notificationBigTime.visibility = View.GONE
else
notificationBigTime.visibility = View.VISIBLE

this@SystemUILyric.notificationBigTime = notificationBigTime
}
}
}
Expand Down

0 comments on commit 94cf128

Please sign in to comment.