Skip to content

Commit

Permalink
SystemUI: Support Override Time Based Linkage Wallpaper Anim
Browse files Browse the repository at this point in the history
Signed-off-by: Art_Chen <[email protected]>
  • Loading branch information
Art-Chen committed Jul 31, 2024
1 parent 538aac7 commit 1251868
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package moe.chenxy.miuiextra.hooker.entity.systemui

import android.util.Log
import android.view.SurfaceControl
import com.highcapable.yukihookapi.hook.entity.YukiBaseHooker
import com.highcapable.yukihookapi.hook.factory.constructor
import com.highcapable.yukihookapi.hook.factory.method
import com.highcapable.yukihookapi.hook.type.java.BooleanType
import com.highcapable.yukihookapi.hook.type.java.IntType
import com.highcapable.yukihookapi.hook.type.java.ObjectsClass
import de.robv.android.xposed.XposedHelpers
import moe.chenxy.miuiextra.hooker.entity.MiWallpaperHook
import java.util.Objects


object LinkageAnimCustomer : YukiBaseHooker() {

override fun onHook() {
// "com.android.systemui.shade.MiuiNotificationPanelViewController".toClass().apply {
// method {
// name = "linkageViewAnim"
// param(BooleanType)
// }.hook {
// before {
// MiWallpaperHook.mainPrefs.reload()
// val on = MiWallpaperHook.mainPrefs.getInt("screen_on_color_fade_anim_val", 800)
// val off = MiWallpaperHook.mainPrefs.getInt("screen_off_color_fade_anim_val", 450)
// val blackHideEase = XposedHelpers.getObjectField(this.instance, "blackHideEase")
//
//
// XposedHelpers.callMethod(blackHideEase, "setDuration", off.toLong())
// }
// }
// }

"com.android.keyguard.clock.animation.ClockBaseAnimation".toClass().apply {
var listener: Any? = null
var animConfig: Any? = null
var showEase: Any? = null
fun initAnim() {
if (listener != null) return

listener = "com.android.keyguard.clock.animation.ClockBaseAnimation\$1".toClass().getDeclaredConstructor(
SurfaceControl.Transaction::class.java, IntType).newInstance(SurfaceControl.Transaction(), 1 /* toLock */)
showEase = "miuix.animation.utils.EaseManager\$InterpolateEaseStyle".toClass().declaredConstructors[0].newInstance(20, floatArrayOf(1.0f))

animConfig = "miuix.animation.base.AnimConfig".toClass().declaredConstructors[0].newInstance()
val listeners = XposedHelpers.getObjectField(animConfig, "listeners") as HashSet<Any>
listeners.add(listener!!)
}

method {
name = "doAnimationToAod"
paramCount = 3
}.hook {
before {
val fromKeyguard = this.args[2] as Boolean
if (!fromKeyguard) return@before

val toAod = this.args[0] as Boolean
val hasNotification = this.args[1] as Boolean


MiWallpaperHook.mainPrefs.reload()
val on = MiWallpaperHook.mainPrefs.getInt("screen_on_color_fade_anim_val", 800)
val off =
MiWallpaperHook.mainPrefs.getInt("screen_off_color_fade_anim_val", 450)

if (toAod) {
val mWallpaperHideEase =
XposedHelpers.getObjectField(this.instance, "mWallpaperHideEase")
XposedHelpers.callMethod(mWallpaperHideEase, "setDuration", off.toLong())
} else {
initAnim()

XposedHelpers.callMethod(showEase, "setDuration", on.toLong())
val stateStyle = XposedHelpers.callStaticMethod("miuix.animation.Folme".toClass(), "useValue", arrayOf("WallpaperParam"))
XposedHelpers.callMethod(animConfig, "setEase", showEase)
XposedHelpers.callMethod(stateStyle, "to", arrayOf("wallpaperBlack", 0f, animConfig))

XposedHelpers.callMethod(this.instance, "doAnimationToAod", false, true)
this.result = null
}
}

}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,9 @@ object SystemUIMainHooker : YukiBaseHooker() {
}

loadHooker(StatusBarBlurUtilsHooker)

if (mainPrefs.getBoolean("override_linkage_wallpaper_anim", false)) {
loadHooker(LinkageAnimCustomer)
}
}
}
1 change: 1 addition & 0 deletions app/src/main/res/values-ja/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -242,4 +242,5 @@
<string name="xposed_desc">HyperOS の世界へ出かけよう! @ Art_Chen</string>
<string name="wallpaper_zoomIn_damping_ratio_summary">Zoom In Animation Damping Ratio</string>
<string name="wallpaper_zoomOut_damping_ratio_summary">Zoom Out Animation Damping Ratio</string>
<string name="override_linkage_wallpaper_anim_title">Override Linkage Wallpaper Anim</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,5 @@
<string name="wallpaper_accuracy_title">动画精度等级</string>
<string name="wallpaper_zoomIn_damping_ratio_summary">放大动画回弹系数</string>
<string name="wallpaper_zoomOut_damping_ratio_summary">缩小动画回弹系数</string>
<string name="override_linkage_wallpaper_anim_title">覆盖联动息屏壁纸动画参数</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,5 @@
<string name="wallpaper_accuracy_title">Animation Accuracy Level</string>
<string name="wallpaper_zoomIn_damping_ratio_summary">Zoom In Animation Damping Ratio</string>
<string name="wallpaper_zoomOut_damping_ratio_summary">Zoom Out Animation Damping Ratio</string>
<string name="override_linkage_wallpaper_anim_title">Override Linkage Wallpaper Anim</string>
</resources>
4 changes: 4 additions & 0 deletions app/src/main/res/xml/chen_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@
app:updatesContinuously="true"
app:title="@string/screen_off_color_fade_anim_val_title" />

<rikka.material.preference.MaterialSwitchPreference
app:key="override_linkage_wallpaper_anim"
app:title="@string/override_linkage_wallpaper_anim_title" />

<rikka.material.preference.MaterialSwitchPreference
app:key="do_not_override_pending_transition"
app:title="@string/do_not_override_pending_transition_title"
Expand Down

0 comments on commit 1251868

Please sign in to comment.