Skip to content

Commit

Permalink
opt: add anim for dock background (#1024)
Browse files Browse the repository at this point in the history
  • Loading branch information
xzakota authored Dec 9, 2024
1 parent 693d825 commit 8ed25b0
Showing 1 changed file with 51 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ import android.app.*
import android.view.*
import android.widget.*
import com.github.kyuubiran.ezxhelper.ClassUtils.loadClass
import com.github.kyuubiran.ezxhelper.HookFactory.`-Static`.createHook
import com.github.kyuubiran.ezxhelper.HookFactory.`-Static`.createHooks
import com.github.kyuubiran.ezxhelper.finders.MethodFinder.`-Static`.methodFinder
import com.sevtinge.hyperceiler.module.base.*
import com.sevtinge.hyperceiler.module.base.dexkit.*
import com.sevtinge.hyperceiler.utils.*
import com.sevtinge.hyperceiler.utils.blur.MiBlurUtilsKt.addMiBackgroundBlendColor
import com.sevtinge.hyperceiler.utils.blur.MiBlurUtilsKt.clearMiBackgroundBlendColor
Expand All @@ -34,17 +37,39 @@ import com.sevtinge.hyperceiler.utils.blur.MiBlurUtilsKt.setMiViewBlurMode
import com.sevtinge.hyperceiler.utils.blur.MiBlurUtilsKt.setPassWindowBlurEnabled
import com.sevtinge.hyperceiler.utils.devicesdk.DisplayUtils.*
import de.robv.android.xposed.*
import org.luckypray.dexkit.query.*
import org.luckypray.dexkit.query.enums.*
import org.luckypray.dexkit.query.matchers.*
import java.lang.reflect.*
import java.util.function.*

object DockCustomNew : BaseHook() {
private val launcherClass by lazy {
loadClass("com.miui.home.launcher.Launcher")
}
private val animationCompatComplexClass by lazy {
loadClass("com.miui.home.launcher.compat.UserPresentAnimationCompatComplex")
}

private val showAnimationLambda by lazy {
DexKit.getDexKitBridge("ShowAnimationLambda") { bridge ->
bridge.findMethod(
FindMethod.create().matcher(
MethodMatcher.create()
.declaredClass("com.miui.home.launcher.compat.UserPresentAnimationCompatV12Phone")
.name("lambda\$showUserPresentAnimation", StringMatchType.StartsWith)
)
).singleOrNull()?.getMethodInstance(lpparam.classLoader)
} as Method?
}

private var mDockBlur: Any? = null

override fun init() {
launcherClass.constructors.toList().createHooks {
after {
val context = AndroidAppHelper.currentApplication().applicationContext
var mDockBlur = XposedHelpers.getAdditionalInstanceField(it.thisObject, "mDockBlur")
mDockBlur = XposedHelpers.getAdditionalInstanceField(it.thisObject, "mDockBlur")
if (mDockBlur != null) return@after
mDockBlur = FrameLayout(context)
XposedHelpers.setAdditionalInstanceField(it.thisObject, "mDockBlur", mDockBlur)
Expand All @@ -67,13 +92,8 @@ object DockCustomNew : BaseHook() {
)
if (mPrefsMap.getStringAsInt("home_dock_add_blur", 0) == 1) {
mDockBlur.setPassWindowBlurEnabled(true)
mDockBlur.setMiBackgroundBlurMode(1) //非0时截断
mDockBlur.setMiBackgroundBlurRadius(
mPrefsMap.getInt(
"custom_background_blur_degree",
200
)
)
mDockBlur.setMiBackgroundBlurMode(1) // 非0时截断
mDockBlur.setMiBackgroundBlurRadius(mPrefsMap.getInt("custom_background_blur_degree", 200))
mDockBlur.clearMiBackgroundBlendColor()
mDockBlur.addMiBackgroundBlendColor(mPrefsMap.getInt("home_dock_bg_color", 0), 101)
mDockBlur.setMiViewBlurMode(1)
Expand All @@ -92,5 +112,28 @@ object DockCustomNew : BaseHook() {
mHotSeats.addView(mDockBlur, 0)
}

// 添加动画
animationCompatComplexClass.methodFinder()
.filterByName("operateAllPresentAnimationRelatedViews")
.single()
.createHook {
after { param ->
if (mDockBlur == null) {
return@after
}

val consumer = param.args[0] as Consumer<Any>
consumer.accept(mDockBlur!!)
}
}
showAnimationLambda?.createHook {
after { param ->
val view = param.args[2] as View

if (view == mDockBlur) {
view.translationZ = 0F
}
}
} ?: logD(TAG, lpparam.packageName, "can't find lambda\$showUserPresentAnimation")
}
}

0 comments on commit 8ed25b0

Please sign in to comment.