diff --git a/app/src/main/java/moe/chenxy/miuiextra/hooker/entity/MiWallpaperHook.kt b/app/src/main/java/moe/chenxy/miuiextra/hooker/entity/MiWallpaperHook.kt
index 2e74dbd..991caf0 100644
--- a/app/src/main/java/moe/chenxy/miuiextra/hooker/entity/MiWallpaperHook.kt
+++ b/app/src/main/java/moe/chenxy/miuiextra/hooker/entity/MiWallpaperHook.kt
@@ -12,6 +12,7 @@ import android.util.Log
import android.view.WindowManager
import android.view.animation.PathInterpolator
import com.highcapable.yukihookapi.hook.entity.YukiBaseHooker
+import com.highcapable.yukihookapi.hook.factory.constructor
import com.highcapable.yukihookapi.hook.factory.field
import com.highcapable.yukihookapi.hook.factory.method
import com.highcapable.yukihookapi.hook.type.android.ValueAnimatorClass
@@ -26,92 +27,91 @@ import java.lang.reflect.Method
object MiWallpaperHook : YukiBaseHooker() {
val mainPrefs = XSharedPreferences(BuildConfig.APPLICATION_ID, "chen_main_settings")
private val mUseChenScreenOnAnim = mainPrefs.getBoolean("use_chen_screen_on_anim", false)
- var currentRevealValue = -1f
+ private var currentRevealValue = -1f
override fun onHook() {
var mIsShowingRevealBlack = false
var mClassName = ""
- "com.miui.miwallpaper.container.openGL.AnimImageWallpaperRenderer".hook {
- injectMember {
- method {
- name = "startRevealAnim"
- param(BooleanType)
- }
- replaceUnit {
- mainPrefs.reload()
- val awake = this.args[0] as Boolean
- val mRevealAnimator = XposedHelpers.findField(
- this.instance.javaClass.superclass,
- "mRevealAnimator"
- ).get(this.instance) as ValueAnimator
- val i: Int
- val f: Float
-
- if (!mIsShowingRevealBlack == awake && mClassName == this.instance.javaClass.name) {
- Log.i("Art_Chen", "awake animation already started! ignored this start")
- XposedHelpers.callMethod(this.instance, "refresh")
- return@replaceUnit
- }
- mClassName = this.instance.javaClass.name
-
- if (mRevealAnimator.isRunning) {
- mRevealAnimator.cancel()
- }
-
- if (awake) {
- i = mainPrefs.getInt("screen_on_color_fade_anim_val", 800)
- f = 0.0f
- } else {
- i = if (mUseChenScreenOnAnim) {
- 80
- } else {
- 400
- }
- f = 1.0f
- }
- mIsShowingRevealBlack = !awake
- val mRevealValue = XposedHelpers.getFloatField(this.instance, "mRevealValue")
- if (mRevealValue == f) {
- Log.i(
- "Art_Chen",
- "startRevealAnim: mCurrentValue == targetValue, no anim, mCurrentValue $mRevealValue, mClass: ${this.instance.javaClass}"
- )
-// XposedHelpers.setFloatField(
-// param.thisObject,
-// "mRevealValue",
-// if (f == 1f) 0f else 1f
+ "com.miui.miwallpaper.container.openGL.AnimImageWallpaperRenderer".toClass().apply {
+// injectMember {
+// method {
+// name = "startRevealAnim"
+// param(BooleanType)
+// }
+// replaceUnit {
+// mainPrefs.reload()
+// val awake = this.args[0] as Boolean
+// val mRevealAnimator = XposedHelpers.findField(
+// this.instance.javaClass.superclass,
+// "mRevealAnimator"
+// ).get(this.instance) as ValueAnimator
+// val i: Int
+// val f: Float
+//
+// if (!mIsShowingRevealBlack == awake && mClassName == this.instance.javaClass.name) {
+// Log.i("Art_Chen", "awake animation already started! ignored this start")
+// XposedHelpers.callMethod(this.instance, "refresh")
+// return@replaceUnit
+// }
+// mClassName = this.instance.javaClass.name
+//
+// if (mRevealAnimator.isRunning) {
+// mRevealAnimator.cancel()
+// }
+//
+// if (awake) {
+// i = mainPrefs.getInt("screen_on_color_fade_anim_val", 800)
+// f = 0.0f
+// } else {
+// i = if (mUseChenScreenOnAnim) {
+// 80
+// } else {
+// 400
+// }
+// f = 1.0f
+// }
+// mIsShowingRevealBlack = !awake
+// val mRevealValue = XposedHelpers.getFloatField(this.instance, "mRevealValue")
+// if (mRevealValue == f) {
+// Log.i(
+// "Art_Chen",
+// "startRevealAnim: mCurrentValue == targetValue, no anim, mCurrentValue $mRevealValue, mClass: ${this.instance.javaClass}"
// )
-// mRevealValue = if (f == 1f) 0f else 1f
- XposedHelpers.callMethod(this.instance, "refresh")
- return@replaceUnit
- }
- Log.i(
- "Art_Chen",
- "startRevealAnim: awake = $awake, current duration $i, from $mRevealValue to $f"
- )
- mRevealAnimator.duration = i.toLong()
- mRevealAnimator.setFloatValues(mRevealValue, f)
- if (mUseChenScreenOnAnim) {
- mRevealAnimator.interpolator =
- if (awake)
- PathInterpolator(0.54f, 0f, 0f, 1f)
- else
- PathInterpolator(0f, 0f, 0.11f, 1f)
- }
- mRevealAnimator.start()
- currentRevealValue = f
- Log.i("Art_Chen", "startRevealAnim: run!")
- Exception().printStackTrace()
- }
- }
+//// XposedHelpers.setFloatField(
+//// param.thisObject,
+//// "mRevealValue",
+//// if (f == 1f) 0f else 1f
+//// )
+//// mRevealValue = if (f == 1f) 0f else 1f
+// XposedHelpers.callMethod(this.instance, "refresh")
+// return@replaceUnit
+// }
+// Log.i(
+// "Art_Chen",
+// "startRevealAnim: awake = $awake, current duration $i, from $mRevealValue to $f"
+// )
+// mRevealAnimator.duration = i.toLong()
+// mRevealAnimator.setFloatValues(mRevealValue, f)
+// if (mUseChenScreenOnAnim) {
+// mRevealAnimator.interpolator =
+// if (awake)
+// PathInterpolator(0.54f, 0f, 0f, 1f)
+// else
+// PathInterpolator(0f, 0f, 0.11f, 1f)
+// }
+// mRevealAnimator.start()
+// currentRevealValue = f
+// Log.i("Art_Chen", "startRevealAnim: run!")
+// Exception().printStackTrace()
+// }
+// }
- injectMember {
- method {
- name = "updateMaskLayerStatus"
- param(BooleanType, BooleanType)
- }
- beforeHook {
+ method {
+ name = "updateMaskLayerStatus"
+ param(BooleanType, BooleanType)
+ }.hook {
+ before {
mainPrefs.reload()
if (mainPrefs.getBoolean("disable_wallpaper_auto_darken", false)) {
this.args[1] = false
@@ -142,132 +142,124 @@ object MiWallpaperHook : YukiBaseHooker() {
}
if (mainPrefs.getBoolean("miui_unlock_wallpaper_anim_fade", false)) {
- "com.miui.miwallpaper.wallpaperservice.impl.keyguard.KeyguardImageEngineImpl".hook {
- injectMember {
- method {
- name = "hideKeyguardWallpaper"
- }
- beforeHook {
- val mWorkerHandler = XposedHelpers.getObjectField(
- this.instance,
- "mWorkerHandler"
- ) as Handler
- if (mLayoutParams?.alpha == 1f && !mIsShowingRevealBlack) {
- Log.i(
- "Art_Chen",
- "pre start alpha animation, alpha ${mLayoutParams!!.alpha}, mIsShowingRevealBlack $mIsShowingRevealBlack"
- )
- mainPrefs.reload()
- mWorkerHandler.post {
- val valueAnimation = ValueAnimator()
- valueAnimation.duration = mainPrefs.getInt(
- "miui_unlock_wallpaper_anim_fade_anim_val",
- 450
- ).toLong()
- valueAnimation.setFloatValues(1.0f, 0.0f)
- valueAnimation.setInterpolator {
- val f2: Float = it - 1.0f
- f2 * f2 * f2 + 1.0f
- }
- valueAnimation.addUpdateListener {
- updateAlpha(it.animatedValue as Float)
- }
- valueAnimation.start()
+ "com.miui.miwallpaper.wallpaperservice.impl.keyguard.KeyguardImageEngineImpl".toClass().method {
+ name = "hideKeyguardWallpaper"
+ }.hook {
+ before {
+ val mWorkerHandler = XposedHelpers.getObjectField(
+ this.instance,
+ "mWorkerHandler"
+ ) as Handler
+ if (mLayoutParams?.alpha == 1f && !mIsShowingRevealBlack) {
+ Log.i(
+ "Art_Chen",
+ "pre start alpha animation, alpha ${mLayoutParams!!.alpha}, mIsShowingRevealBlack $mIsShowingRevealBlack"
+ )
+ mainPrefs.reload()
+ mWorkerHandler.post {
+ val valueAnimation = ValueAnimator()
+ valueAnimation.duration = mainPrefs.getInt(
+ "miui_unlock_wallpaper_anim_fade_anim_val",
+ 450
+ ).toLong()
+ valueAnimation.setFloatValues(1.0f, 0.0f)
+ valueAnimation.setInterpolator {
+ val f2: Float = it - 1.0f
+ f2 * f2 * f2 + 1.0f
}
- this.result = null
- }
- }
- }
- }
-
- "com.miui.miwallpaper.wallpaperservice.MiuiKeyguardPictorialWallpaper\$KeyguardEngine".hook {
- injectMember {
- constructor {
- param("com.miui.miwallpaper.wallpaperservice.MiuiKeyguardPictorialWallpaper")
- }
- afterHook {
- mLayoutParams = XposedHelpers.getObjectField(
- this.instance,
- "mLayoutParams"
- ) as WindowManager.LayoutParams
- updateSurface = XposedHelpers.getObjectField(
- this.instance,
- "updateSurface"
- ) as Method
- mMiuiKeyguardPictorialWallpaper = this.instance
- }
- }
- }
-
- "com.miui.miwallpaper.container.openGL.DesktopAnimImageWallpaperRenderer".hook {
- injectMember {
- method {
- name = "startScaleAnim"
- }
- beforeHook {
- if (mLayoutParams?.alpha == 1f && !mIsShowingRevealBlack) {
- this.result = null
+ valueAnimation.addUpdateListener {
+ updateAlpha(it.animatedValue as Float)
+ }
+ valueAnimation.start()
}
+ this.result = null
}
}
}
- }
-
- "com.miui.miwallpaper.wallpaperservice.impl.desktop.DesktopImageEngineImpl".hook {
- injectMember {
- method {
- name = "lambda\$hideKeyguardWallpaper$11\$DesktopImageEngineImpl"
- }
- beforeHook {
- this.result = null
- }
- }.ignoredAllFailure()
- injectMember {
- method {
- name = "lambda\$hideKeyguardWallpaper$3\$DesktopImageEngineImpl"
- }
- beforeHook {
- this.result = null
- }
- }.ignoredAllFailure()
-
- injectMember {
- method {
- name = "onScreenTurningOff"
- }
- beforeHook {
- val mDesktopWallpaperRenderer = XposedHelpers.getObjectField(
+ "com.miui.miwallpaper.wallpaperservice.MiuiKeyguardPictorialWallpaper\$KeyguardEngine".toClass().constructor {
+ param("com.miui.miwallpaper.wallpaperservice.MiuiKeyguardPictorialWallpaper")
+ }.hook {
+ after {
+ mLayoutParams = XposedHelpers.getObjectField(
this.instance,
- "mDesktopWallpaperRenderer"
- )
- XposedHelpers.callMethod(
- mDesktopWallpaperRenderer,
- "startRevealAnim",
- false
- )
+ "mLayoutParams"
+ ) as WindowManager.LayoutParams
+ updateSurface = XposedHelpers.getObjectField(
+ this.instance,
+ "updateSurface"
+ ) as Method
+ mMiuiKeyguardPictorialWallpaper = this.instance
}
}
- injectMember {
- method {
- name = "lambda\$onScreenTurningOn$1\$DesktopImageEngineImpl"
- }
- beforeHook {
- if (mIsShowingRevealBlack && mUseChenScreenOnAnim) {
- val mDesktopWallpaperRenderer =
- XposedHelpers.getObjectField(this.instance, "mDesktopWallpaperRenderer")
- XposedHelpers.callMethod(mDesktopWallpaperRenderer, "startRevealAnim", true)
- this.result = null
- }
- }
+ "com.miui.miwallpaper.container.openGL.DesktopAnimImageWallpaperRenderer".toClass().method {
+ name = "startScaleAnim"
+ }.hook {
+ intercept()
+// before {
+//// if (mLayoutParams?.alpha == 1f && !mIsShowingRevealBlack) {
+// this.result = null
+//// }
+// }
}
-
}
- if (mainPrefs.getBoolean("use_chen_screen_on_anim", false)) {
- loadHooker(ChenAnimation)
- }
+// "com.miui.miwallpaper.wallpaperservice.impl.desktop.DesktopImageEngineImpl".hook {
+// injectMember {
+// method {
+// name = "lambda\$hideKeyguardWallpaper$11\$DesktopImageEngineImpl"
+// }
+// beforeHook {
+// this.result = null
+// }
+// }.ignoredAllFailure()
+//
+// injectMember {
+// method {
+// name = "lambda\$hideKeyguardWallpaper$3\$DesktopImageEngineImpl"
+// }
+// beforeHook {
+// this.result = null
+// }
+// }.ignoredAllFailure()
+//
+// injectMember {
+// method {
+// name = "onScreenTurningOff"
+// }
+// beforeHook {
+// val mDesktopWallpaperRenderer = XposedHelpers.getObjectField(
+// this.instance,
+// "mDesktopWallpaperRenderer"
+// )
+// XposedHelpers.callMethod(
+// mDesktopWallpaperRenderer,
+// "startRevealAnim",
+// false
+// )
+// }
+// }
+//
+// injectMember {
+// method {
+// name = "lambda\$onScreenTurningOn$1\$DesktopImageEngineImpl"
+// }
+// beforeHook {
+// if (mIsShowingRevealBlack && mUseChenScreenOnAnim) {
+// val mDesktopWallpaperRenderer =
+// XposedHelpers.getObjectField(this.instance, "mDesktopWallpaperRenderer")
+// XposedHelpers.callMethod(mDesktopWallpaperRenderer, "startRevealAnim", true)
+// this.result = null
+// }
+// }
+// }
+//
+// }
+
+// if (mainPrefs.getBoolean("use_chen_screen_on_anim", false)) {
+// loadHooker(ChenAnimation)
+// }
// "com.miui.miwallpaper.manager.WallpaperServiceController".hook {
// injectMember {
@@ -279,133 +271,133 @@ object MiWallpaperHook : YukiBaseHooker() {
// }
}
- object ChenAnimation : YukiBaseHooker() {
- var uBlurRadius = -1
- var uBlurOffset = -1
- var uSumWeight = -1
- var uAlpha = -1
- var mScaleValue = 0f
- var mFragmentShaderId: Int = -1
- override fun onHook() {
- "com.android.systemui.glwallpaper.ImageWallpaperRenderer".hook {
- injectMember {
- method {
- name = "setGLViewport"
- }
- beforeHook {
- val mRevealValue = XposedHelpers.getFloatField(
- this.instance,
- "mRevealValue"
- )
- if (mScaleValue != 0f && mRevealValue != 0f) {
- Log.v(
- "Art_Chen",
- "need animation!! override setGLViewport! this class = ${this.instance.javaClass}"
- )
- val mSurfaceSize =
- XposedHelpers.getObjectField(
- this.instance,
- "mSurfaceSize"
- ) as Rect
- val f2 = ((1.0f - mRevealValue) * 1.0f) + (mRevealValue * 1.2f)
- val f3 = (1.0f - f2) / 2.0f
- val width = mSurfaceSize.width()
- val height = mSurfaceSize.height()
- Log.v(
- "Art_Chen",
- "mRevealValue $mRevealValue, mScaleValue $mScaleValue"
- )
- GLES20.glViewport(
- ((mSurfaceSize.left + (width * f3)).toInt()),
- ((mSurfaceSize.top + (f3 * height)).toInt()),
- ((width * f2).toInt()),
- ((height * f2).toInt())
- )
- this.result = null
- }
- }
- }
-
- injectMember {
- method {
- name = "onSurfaceCreated"
- }
- beforeHook {
- mFragmentShaderId =
- XposedHelpers.callMethod(this.instance, "getFragmentShader") as Int
- Log.d("Art_Chen", "got fragment shader res id!!")
- }
- }
- }
-
- "com.miui.miwallpaper.container.openGL.AnimImageWallpaperRenderer".hook {
- injectMember {
- method {
- name = "lambda\$new$0\$AnimImageWallpaperRenderer"
- param(ValueAnimatorClass)
- }
- beforeHook {
- val valueAnimator = this.args[0] as ValueAnimator
- mScaleValue = (valueAnimator.animatedValue as Float)
- }
- }
- }
-
- "com.android.systemui.glwallpaper.ImageGLProgram".hook {
- injectMember {
- method {
- name = "getShaderResource"
- param(IntType)
- }
- beforeHook {
- if (this.args[0] as Int == mFragmentShaderId) {
- Log.i(
- "Art_Chen",
- "mFragmentShaderId detected, return chen Fragment Shader"
- )
- this.result = AnimFragmentShaderChen.glsl
- }
- }
- }
- }
-
-
- "com.miui.miwallpaper.container.openGL.DesktopAnimImageWallpaperRenderer".toClass().apply {
-
- method {
- name = "checkIsNeedCancelAnim"
- }.hook {
- before {
- val mRevealValue =
- XposedHelpers.getFloatField(this.instance, "mRevealValue")
- if (mUseChenScreenOnAnim && mRevealValue != 0f) {
- this.result = true
- }
- }
- }
-
- method {
- name = "setGLViewport"
- }.hook {
- before {
- val mRevealValue =
- field {
- name = "mRevealValue"
- superClass()
- }.get(this.instance).any()
- if (mUseChenScreenOnAnim && mRevealValue != 0f) {
- // v1.9.0+ need set these to false to call the super method
- field {
- name("mWallpaperScaling")
- }.get(this.instance).set(false)
-
- field {
- name("mIsResetScale")
- }.get(this.instance).set(false)
- }
- }
- }
- }
- }
- }
+// object ChenAnimation : YukiBaseHooker() {
+// var uBlurRadius = -1
+// var uBlurOffset = -1
+// var uSumWeight = -1
+// var uAlpha = -1
+// var mScaleValue = 0f
+// var mFragmentShaderId: Int = -1
+// override fun onHook() {
+// "com.android.systemui.glwallpaper.ImageWallpaperRenderer".hook {
+// injectMember {
+// method {
+// name = "setGLViewport"
+// }
+// beforeHook {
+// val mRevealValue = XposedHelpers.getFloatField(
+// this.instance,
+// "mRevealValue"
+// )
+// if (mScaleValue != 0f && mRevealValue != 0f) {
+// Log.v(
+// "Art_Chen",
+// "need animation!! override setGLViewport! this class = ${this.instance.javaClass}"
+// )
+// val mSurfaceSize =
+// XposedHelpers.getObjectField(
+// this.instance,
+// "mSurfaceSize"
+// ) as Rect
+// val f2 = ((1.0f - mRevealValue) * 1.0f) + (mRevealValue * 1.2f)
+// val f3 = (1.0f - f2) / 2.0f
+// val width = mSurfaceSize.width()
+// val height = mSurfaceSize.height()
+// Log.v(
+// "Art_Chen",
+// "mRevealValue $mRevealValue, mScaleValue $mScaleValue"
+// )
+// GLES20.glViewport(
+// ((mSurfaceSize.left + (width * f3)).toInt()),
+// ((mSurfaceSize.top + (f3 * height)).toInt()),
+// ((width * f2).toInt()),
+// ((height * f2).toInt())
+// )
+// this.result = null
+// }
+// }
+// }
+//
+// injectMember {
+// method {
+// name = "onSurfaceCreated"
+// }
+// beforeHook {
+// mFragmentShaderId =
+// XposedHelpers.callMethod(this.instance, "getFragmentShader") as Int
+// Log.d("Art_Chen", "got fragment shader res id!!")
+// }
+// }
+// }
+//
+// "com.miui.miwallpaper.container.openGL.AnimImageWallpaperRenderer".hook {
+// injectMember {
+// method {
+// name = "lambda\$new$0\$AnimImageWallpaperRenderer"
+// param(ValueAnimatorClass)
+// }
+// beforeHook {
+// val valueAnimator = this.args[0] as ValueAnimator
+// mScaleValue = (valueAnimator.animatedValue as Float)
+// }
+// }
+// }
+//
+// "com.android.systemui.glwallpaper.ImageGLProgram".hook {
+// injectMember {
+// method {
+// name = "getShaderResource"
+// param(IntType)
+// }
+// beforeHook {
+// if (this.args[0] as Int == mFragmentShaderId) {
+// Log.i(
+// "Art_Chen",
+// "mFragmentShaderId detected, return chen Fragment Shader"
+// )
+// this.result = AnimFragmentShaderChen.glsl
+// }
+// }
+// }
+// }
+//
+//
+// "com.miui.miwallpaper.container.openGL.DesktopAnimImageWallpaperRenderer".toClass().apply {
+//
+// method {
+// name = "checkIsNeedCancelAnim"
+// }.hook {
+// before {
+// val mRevealValue =
+// XposedHelpers.getFloatField(this.instance, "mRevealValue")
+// if (mUseChenScreenOnAnim && mRevealValue != 0f) {
+// this.result = true
+// }
+// }
+// }
+//
+// method {
+// name = "setGLViewport"
+// }.hook {
+// before {
+// val mRevealValue =
+// field {
+// name = "mRevealValue"
+// superClass()
+// }.get(this.instance).any()
+// if (mUseChenScreenOnAnim && mRevealValue != 0f) {
+// // v1.9.0+ need set these to false to call the super method
+// field {
+// name("mWallpaperScaling")
+// }.get(this.instance).set(false)
+//
+// field {
+// name("mIsResetScale")
+// }.get(this.instance).set(false)
+// }
+// }
+// }
+// }
+// }
+// }
}
\ No newline at end of file
diff --git a/app/src/main/java/moe/chenxy/miuiextra/hooker/entity/MiuiHomeHook.kt b/app/src/main/java/moe/chenxy/miuiextra/hooker/entity/MiuiHomeHook.kt
index ae755f5..0998257 100644
--- a/app/src/main/java/moe/chenxy/miuiextra/hooker/entity/MiuiHomeHook.kt
+++ b/app/src/main/java/moe/chenxy/miuiextra/hooker/entity/MiuiHomeHook.kt
@@ -1,6 +1,7 @@
package moe.chenxy.miuiextra.hooker.entity
import android.util.Log
+import androidx.dynamicanimation.animation.SpringAnimation
import com.highcapable.yukihookapi.hook.entity.YukiBaseHooker
import com.highcapable.yukihookapi.hook.factory.method
import com.highcapable.yukihookapi.hook.type.android.ViewClass
@@ -48,13 +49,17 @@ object MiuiHomeHook : YukiBaseHooker() {
}.hook {
after {
val springAnimation = this.result
+ val springAnimationReal = XposedHelpers.getObjectField(springAnimation, "mSpringAnimation") as SpringAnimation
if (this.args[2] == -1500.0f) {
- XposedHelpers.callMethod(
- springAnimation,
- "setDampingResponse",
- 0.68f,
- 0.55f
- )
+// XposedHelpers.callMethod(
+// springAnimation,
+// "setDampingResponse",
+// 0.68f,
+// 0.55f
+// )
+ springAnimationReal.spring.stiffness = 100f
+ springAnimationReal.spring.dampingRatio = 1.5f
+ springAnimationReal.setStartVelocity(5f)
}
this.result = springAnimation
}
diff --git a/app/src/main/java/moe/chenxy/miuiextra/hooker/entity/home/AnimationEnhanceHooker.kt b/app/src/main/java/moe/chenxy/miuiextra/hooker/entity/home/AnimationEnhanceHooker.kt
index f8efb11..35a78fb 100644
--- a/app/src/main/java/moe/chenxy/miuiextra/hooker/entity/home/AnimationEnhanceHooker.kt
+++ b/app/src/main/java/moe/chenxy/miuiextra/hooker/entity/home/AnimationEnhanceHooker.kt
@@ -11,12 +11,6 @@ object AnimationEnhanceHooker : YukiBaseHooker() {
override fun onHook() {
// Force enable breakable anim support
"com.miui.home.launcher.common.DeviceLevelUtils".toClass().apply {
- method {
- name = "supportBreakOpenAnim"
- }.hook {
- replaceToTrue()
- }
-
method {
name = "isUseSimpleAnim"
}.hook {
diff --git a/app/src/main/java/moe/chenxy/miuiextra/hooker/entity/home/WallpaperZoomOptimizeHooker.kt b/app/src/main/java/moe/chenxy/miuiextra/hooker/entity/home/WallpaperZoomOptimizeHooker.kt
index 3080bed..66def50 100644
--- a/app/src/main/java/moe/chenxy/miuiextra/hooker/entity/home/WallpaperZoomOptimizeHooker.kt
+++ b/app/src/main/java/moe/chenxy/miuiextra/hooker/entity/home/WallpaperZoomOptimizeHooker.kt
@@ -1,6 +1,7 @@
package moe.chenxy.miuiextra.hooker.entity.home
-import android.R.attr.classLoader
+import android.annotation.SuppressLint
+import android.app.WallpaperManager
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
@@ -9,14 +10,20 @@ import android.util.Log
import android.view.Display
import androidx.dynamicanimation.animation.DynamicAnimation
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.android.BundleClass
import com.highcapable.yukihookapi.hook.type.android.ContextClass
import com.highcapable.yukihookapi.hook.type.android.IBinderClass
+import com.highcapable.yukihookapi.hook.type.android.IntentClass
import com.highcapable.yukihookapi.hook.type.android.ViewClass
import com.highcapable.yukihookapi.hook.type.java.BooleanType
import com.highcapable.yukihookapi.hook.type.java.FloatType
import de.robv.android.xposed.XC_MethodHook
import de.robv.android.xposed.XposedHelpers
import moe.chenxy.miuiextra.hooker.entity.MiuiHomeHook
+import moe.chenxy.miuiextra.hooker.entity.systemui.SystemUIPluginHook.hook
+import moe.chenxy.miuiextra.utils.ChenUtils
import java.util.concurrent.AbstractExecutorService
@@ -38,24 +45,25 @@ object WallpaperZoomOptimizeHooker : YukiBaseHooker() {
private var isInHome = true
private var lastScreenState = Display.STATE_ON
+ private var disableCancelWallpaperAnim = false
+ @SuppressLint("UnspecifiedRegisterReceiverFlag")
override fun onHook() {
- "com.miui.home.launcher.wallpaper.WallpaperZoomManager".hook {
- injectMember {
- method {
- name = "animateZoomOutTo"
- param(FloatType, BooleanType)
- }
+ "com.miui.home.launcher.wallpaper.WallpaperZoomManager".toClass().apply {
+ method {
+ name = "animateZoomOutTo"
+ param(FloatType, BooleanType)
+ }.hook {
replaceUnit {
wallpaperZoomThiz = this.instance
var f = this.args[0] as Float
val zoomIn = this.args[1] as Boolean
mZoomedIn = zoomIn
- val mZoomOut = XposedHelpers.getFloatField(this.instance, "mZoomOut")
- if (mZoomOut == f) {
+ if (mZoomedOut == f) {
return@replaceUnit
}
+ XposedHelpers.setObjectField(this.instance, "mZoomOut", mZoomedOut)
if (MiuiHomeHook.zoomPrefs.hasFileChanged()) {
MiuiHomeHook.zoomPrefs.reload()
@@ -66,9 +74,13 @@ object WallpaperZoomOptimizeHooker : YukiBaseHooker() {
MiuiHomeHook.zoomPrefs.getInt("wallpaper_zoomOut_stiffness_val", 3263)
.toFloat() / 100
zoomOutStartVelocity =
- MiuiHomeHook.zoomPrefs.getInt("wallpaper_zoomOut_start_velocity_val", 662)
+ MiuiHomeHook.zoomPrefs.getInt(
+ "wallpaper_zoomOut_start_velocity_val",
+ 662
+ )
.toFloat() / 1000
- zoomOut = MiuiHomeHook.zoomPrefs.getInt("wallpaper_zoomOut_val", 4).toFloat() / 10
+ zoomOut =
+ MiuiHomeHook.zoomPrefs.getInt("wallpaper_zoomOut_val", 1).toFloat() / 10
zoomInStartVelocity =
MiuiHomeHook.zoomPrefs.getInt("wallpaper_zoomIn_start_velocity_val", 0)
.toFloat() / 1000
@@ -87,7 +99,7 @@ object WallpaperZoomOptimizeHooker : YukiBaseHooker() {
XposedHelpers.callMethod(
mSpringAnimation,
"setMinimumVisibleChange",
- DynamicAnimation.MIN_VISIBLE_CHANGE_ALPHA
+ DynamicAnimation.MIN_VISIBLE_CHANGE_SCALE
)
if (zoomIn) {
XposedHelpers.callMethod(
@@ -102,7 +114,7 @@ object WallpaperZoomOptimizeHooker : YukiBaseHooker() {
"setStiffness",
zoomInStiffness
)
- XposedHelpers.callMethod(mZoomInSpringForce, "setDampingRatio", 0.99f)
+ XposedHelpers.callMethod(mZoomInSpringForce, "setDampingRatio", 1.5f)
XposedHelpers.callMethod(mZoomInSpringForce, "setFinalPosition", f)
XposedHelpers.callMethod(
@@ -125,7 +137,7 @@ object WallpaperZoomOptimizeHooker : YukiBaseHooker() {
"setStiffness",
zoomOutStiffness
)
- XposedHelpers.callMethod(mZoomOutSpringForce, "setDampingRatio", 0.99f)
+ XposedHelpers.callMethod(mZoomOutSpringForce, "setDampingRatio", 1.5f)
XposedHelpers.callMethod(mZoomOutSpringForce, "setFinalPosition", f)
XposedHelpers.callMethod(
@@ -138,9 +150,18 @@ object WallpaperZoomOptimizeHooker : YukiBaseHooker() {
"com.miui.home.recents.TouchInteractionService".toClass(),
"MAIN_THREAD_EXECUTOR"
) as AbstractExecutorService
- val runnable = "com.miui.home.launcher.wallpaper.WallpaperZoomManager\$animateZoomOutTo\$1".toClass().declaredConstructors[0]
+ val runnable =
+ "com.miui.home.launcher.wallpaper.WallpaperZoomManager\$animateZoomOutTo\$1".toClass().declaredConstructors[0]
runnable.isAccessible = true
+ val mSpringAnimation = XposedHelpers.getObjectField(this.instance, "mSpringAnimation")
+ val canStop = XposedHelpers.callMethod(mSpringAnimation, "isRunning") as Boolean
+ && XposedHelpers.callMethod(mSpringAnimation, "canSkipToEnd") as Boolean
+ if (canStop) {
+ disableCancelWallpaperAnim = false
+ XposedHelpers.callStaticMethod("com.miui.home.launcher.animate.SpringAnimationReflectUtils".toClass(), "cancel", mSpringAnimation)
+ }
+
MAIN_THREAD_EXECUTOR.execute(
runnable.newInstance(
this.instance,
@@ -150,19 +171,10 @@ object WallpaperZoomOptimizeHooker : YukiBaseHooker() {
}
}
- injectMember {
- method {
- name = "access\$getMZoomOut\$p"
- param("com.miui.home.launcher.wallpaper.WallpaperZoomManager")
- }
- replaceTo(mZoomedOut)
- }
-
- injectMember {
- constructor {
- param(ContextClass, IBinderClass)
- }
- afterHook {
+ constructor {
+ param(ContextClass, IBinderClass)
+ }.hook {
+ after {
wallpaperZoomThiz = this.instance
val mContext = this.args[0] as Context
val chenActivitySwitchFilter =
@@ -181,34 +193,47 @@ object WallpaperZoomOptimizeHooker : YukiBaseHooker() {
}
}
- injectMember {
- method {
- name = "setWallpaperZoomOut"
- param(FloatType)
- }
- afterHook {
- mZoomedOut = this.args[0] as Float
- }
- }
- }
- "androidx.dynamicanimation.animation.SpringAnimation".hook {
- injectMember {
- method {
- name = "cancel"
- }
- beforeHook {
- if (this.instance == mSpringAnimation) this.result = null
+ method {
+ name = "setWallpaperZoomOut"
+ param(FloatType)
+ }.hook {
+ replaceUnit {
+ val mSpringAnimation = XposedHelpers.getObjectField(this.instance, "mSpringAnimation")
+ disableCancelWallpaperAnim = true
+ val f = this.args[0] as Float
+ mZoomedOut = f.coerceIn(0f, 1f)
+ val mWallpaperManager = XposedHelpers.getObjectField(this.instance, "mWallpaperManager")
+ val mWindowToken = XposedHelpers.getObjectField(this.instance, "mWindowToken")
+ XposedHelpers.callMethod(mWallpaperManager, "setWallpaperZoomOut", arrayOf(IBinderClass, FloatType), mWindowToken, mZoomedOut)
+ disableCancelWallpaperAnim = false
+
+ val canStop = XposedHelpers.callMethod(mSpringAnimation, "isRunning") as Boolean
+ && XposedHelpers.callMethod(mSpringAnimation, "canSkipToEnd") as Boolean
+ if (((mZoomedIn && mZoomedOut < zoomOut + 0.0015051) || (!mZoomedIn && mZoomedOut >= 0.9999999f)) && canStop) {
+ mZoomedOut = if (mZoomedIn) zoomOut else 1f
+ XposedHelpers.callStaticMethod("com.miui.home.launcher.animate.SpringAnimationReflectUtils".toClass(), "cancel", mSpringAnimation)
+ }
}
}
}
- "com.miui.home.launcher.common.UnlockAnimationStateMachine".hook {
- injectMember {
- method {
- name = "onDisplayChange"
- }
- beforeHook {
+// "androidx.dynamicanimation.animation.SpringAnimation".hook {
+// injectMember {
+// method {
+// name = "cancel"
+// }
+// beforeHook {
+// if (this.instance == mSpringAnimation) this.result = null
+// }
+// }
+// }
+
+ "com.miui.home.launcher.common.UnlockAnimationStateMachine".toClass().apply {
+ method {
+ name = "onDisplayChange"
+ }.hook {
+ before {
MiuiHomeHook.zoomPrefs.reload()
val mLauncher = XposedHelpers.getObjectField(this.instance, "mLauncher")
val screenState = XposedHelpers.callStaticMethod(
@@ -218,8 +243,8 @@ object WallpaperZoomOptimizeHooker : YukiBaseHooker() {
)
Log.i("Art_Chen", "onDisplayChanged!! current Status: $screenState")
if (lastScreenState == screenState) {
- Log.i("Art_Chen", "screenState not changed, ignore wallpaper auto zoom")
- return@beforeHook
+ Log.v("Art_Chen", "screenState not changed, ignore wallpaper auto zoom")
+ return@before
}
if (screenState == Display.STATE_DOZE || screenState == Display.STATE_DOZE_SUSPEND || screenState == Display.STATE_OFF) {
if (mZoomedIn) {
@@ -234,11 +259,10 @@ object WallpaperZoomOptimizeHooker : YukiBaseHooker() {
}
}
- injectMember {
- method {
- name = "onUserPresent"
- }
- afterHook {
+ method {
+ name = "onUserPresent"
+ }.hook {
+ after {
// Reset Zoom State after unlock
XposedHelpers.callMethod(
wallpaperZoomThiz,
@@ -249,6 +273,16 @@ object WallpaperZoomOptimizeHooker : YukiBaseHooker() {
}
}
+ "com.miui.home.launcher.animate.SpringAnimationReflectUtils".toClass().method {
+ name = "cancel"
+ }.hook {
+ before {
+ if (disableCancelWallpaperAnim) {
+ this.result = null
+ }
+ }
+ }
+
//
// XposedHelpers.findAndHookMethod("com.miui.home.launcher.wallpaper.WallpaperZoomManager",
// lpparam!!.classLoader,
@@ -267,67 +301,81 @@ object WallpaperZoomOptimizeHooker : YukiBaseHooker() {
// var launcherThiz: Any? = null
if (MiuiHomeHook.zoomPrefs.getBoolean("sync_wallpaper_and_app_anim", true)) {
var isLaunching = false
- XposedHelpers.findAndHookMethod("com.miui.home.launcher.Launcher",
- appClassLoader,
- "animateWallpaperZoom",
- Boolean::class.javaPrimitiveType,
- object : XC_MethodHook() {
- @Throws(Throwable::class)
- override fun beforeHookedMethod(param: MethodHookParam) {
- if (isLaunching) {
- Log.i(
- "Art_Chen",
- "sync_wallpaper_and_app_anim enabled, ignore wallpaper zoom when launch"
- )
- param.result = null
- }
+ XposedHelpers.findMethodExact("com.miui.home.launcher.Launcher", appClassLoader, "animateWallpaperZoom",
+ Boolean::class.javaPrimitiveType).hook {
+ before {
+ if (isLaunching) {
+ Log.i(
+ "Art_Chen",
+ "sync_wallpaper_and_app_anim enabled, ignore wallpaper zoom when launch"
+ )
+ this.result = null
}
+ }
+ }
- @Throws(Throwable::class)
- override fun afterHookedMethod(param: MethodHookParam) {
- super.afterHookedMethod(param)
+ if (!ChenUtils.isAboveAndroidVersion(ChenUtils.Companion.AndroidVersion.U)) {
+ XposedHelpers.findMethodExact(
+ "com.miui.home.launcher.Launcher", appClassLoader, "launch",
+ "com.miui.home.launcher.ShortcutInfo".toClass(), ViewClass
+ ).hook {
+ before {
+ isLaunching = true
}
- })
-
- "com.miui.home.launcher.Launcher".hook {
- injectMember {
- method {
- name = "launch"
- param("com.miui.home.launcher.ShortcutInfo", ViewClass)
+ after {
+ isLaunching = false
}
- beforeHook {
+ }
+ } else {
+ // on U, we just skip if using startActivity
+ XposedHelpers.findMethodExact(
+ "com.miui.home.launcher.Launcher", appClassLoader, "superStartActivity",
+ IntentClass, BundleClass
+ ).hook {
+ before {
isLaunching = true
-// launcherThiz = this.instance
}
- afterHook {
+ after {
isLaunching = false
}
}
-//
-// injectMember {
-// method {
-// name = "animateWallpaperZoom"
-// param(BooleanType)
+ }
+
+// XposedHelpers.findAndHookMethod("com.miui.home.launcher.Launcher",
+// appClassLoader,
+// "animateWallpaperZoom",
+// Boolean::class.javaPrimitiveType,
+// object : XC_MethodHook() {
+// @Throws(Throwable::class)
+// override fun beforeHookedMethod(param: MethodHookParam) {
+// if (isLaunching) {
+// Log.i(
+// "Art_Chen",
+// "sync_wallpaper_and_app_anim enabled, ignore wallpaper zoom when launch"
+// )
+// param.result = null
+// }
// }
-// beforeHook {
-//// launcherThiz = this.instance
//
+// @Throws(Throwable::class)
+// override fun afterHookedMethod(param: MethodHookParam) {
+// super.afterHookedMethod(param)
// }
-// }
-// }
+// })
-// "com.miui.home.recents.LauncherAnimationRunner".hook {
-// injectMember {
-// method {
-// name = "onAnimationStart"
-// param(IntType, VagueType, VagueType, VagueType, Runnable::class.java)
-// }
-// beforeHook {
-// Log.i("Art_Chen", "onAnimationStart")
-// }
+// "com.miui.home.launcher.Launcher".toClass().apply {
+// method {
+// name = "launch"
+// param("com.miui.home.launcher.ShortcutInfo".toClass(), ViewClass)
+// }.hook {
+// before {
+// isLaunching = true
+// }
+// after {
+// isLaunching = false
// }
// }
- }
+// }
}
}
}
\ No newline at end of file
diff --git a/app/src/main/java/moe/chenxy/miuiextra/hooker/entity/systemui/HomeHandleAnimatorHooker.kt b/app/src/main/java/moe/chenxy/miuiextra/hooker/entity/systemui/HomeHandleAnimatorHooker.kt
index 6baccd9..e214511 100644
--- a/app/src/main/java/moe/chenxy/miuiextra/hooker/entity/systemui/HomeHandleAnimatorHooker.kt
+++ b/app/src/main/java/moe/chenxy/miuiextra/hooker/entity/systemui/HomeHandleAnimatorHooker.kt
@@ -80,7 +80,6 @@ object HomeHandleAnimatorHooker : YukiBaseHooker() {
var mLightColor = -1
var mDarkColor = -1
var mNavigationHandle : Any? = null
- var currentIntensity = 0f
fun animateHomeHandleZoom(zoomType: ZoomType) {
if (zoomValueAnimator == null) {
zoomValueAnimator = ValueAnimator()
@@ -174,6 +173,7 @@ object HomeHandleAnimatorHooker : YukiBaseHooker() {
mainPrefs.reload()
val autoTransparent = mainPrefs.getBoolean("chen_home_handle_auto_transparent", false)
val useScaleEffect = mainPrefs.getBoolean("home_handle_scale_on_full_transparent", false)
+ val transDegree = mainPrefs.getInt("home_handle_auto_trans_alpha_val", 30)
useMiBlur = mainPrefs.getBoolean("chen_home_handle_blur_effect", false)
val isHome = mIsInHome
if (!autoTransparent && needOpacity && !needToTransparent && !useMiBlur) {
@@ -244,7 +244,7 @@ object HomeHandleAnimatorHooker : YukiBaseHooker() {
if (needToTransparent)
0f
else if (needOpacity)
- 0.7f
+ 1 - (transDegree.toFloat() / 100)
else
1.0f
)
@@ -569,7 +569,6 @@ object HomeHandleAnimatorHooker : YukiBaseHooker() {
XposedHelpers.setIntField(this.instance, "mDarkColor", mDarkColor)
XposedHelpers.setIntField(this.instance, "mLightColor", mLightColor)
}
- currentIntensity = this.args[0] as Float
}
}
}
diff --git a/app/src/main/java/moe/chenxy/miuiextra/view/activity/SettingsActivity.kt b/app/src/main/java/moe/chenxy/miuiextra/view/activity/SettingsActivity.kt
index df04f7c..765b427 100644
--- a/app/src/main/java/moe/chenxy/miuiextra/view/activity/SettingsActivity.kt
+++ b/app/src/main/java/moe/chenxy/miuiextra/view/activity/SettingsActivity.kt
@@ -216,6 +216,7 @@ class SettingsActivity : AppCompatActivity() {
}
bindAnimationSeekBarNoEditText(findPreference("blur_scale_val"), 1)
+ bindAnimationSeekBarNoEditText(findPreference("home_handle_auto_trans_alpha_val"), 1)
}
private val setColorFadeSettings : Runnable = Runnable {
diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml
index 3945db3..44fff8b 100644
--- a/app/src/main/res/values-zh-rCN/strings.xml
+++ b/app/src/main/res/values-zh-rCN/strings.xml
@@ -112,4 +112,5 @@
位移 + 拉伸
缩放
位移 + 缩放
+ 自动透明程度
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 81184be..8d4dff4 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -114,4 +114,5 @@
Shift and Stretch
Scale
Shift and Scale
+ Auto Transparent Degree
\ No newline at end of file
diff --git a/app/src/main/res/xml/chen_preferences.xml b/app/src/main/res/xml/chen_preferences.xml
index 26dd7c2..6f3f3e2 100644
--- a/app/src/main/res/xml/chen_preferences.xml
+++ b/app/src/main/res/xml/chen_preferences.xml
@@ -89,28 +89,28 @@
app:key="wallpaper_zoom"
app:title="@string/wallpaper_scale_title" />
-
+
+
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -147,6 +147,15 @@
app:title="@string/chen_home_handle_auto_transparent_title"
app:summary="@string/chen_home_handle_auto_transparent_summary"/>
+
+