diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/home/dock/DockCustomNew.kt b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/home/dock/DockCustomNew.kt index ecaae0601..f00c111c6 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/home/dock/DockCustomNew.kt +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/home/dock/DockCustomNew.kt @@ -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 @@ -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) @@ -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) @@ -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 + 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") } }