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 0db0b72..ef93809 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,12 +1,9 @@ package moe.chenxy.miuiextra.hooker.entity -import android.graphics.Color import android.util.Log import android.view.View -import android.widget.TextView import com.highcapable.yukihookapi.hook.entity.YukiBaseHooker import com.highcapable.yukihookapi.hook.factory.method -import com.highcapable.yukihookapi.hook.type.android.ContextClass import com.highcapable.yukihookapi.hook.type.android.ViewClass import com.highcapable.yukihookapi.hook.type.java.FloatType import com.highcapable.yukihookapi.hook.type.java.IntType @@ -15,6 +12,7 @@ import de.robv.android.xposed.XposedHelpers import moe.chenxy.miuiextra.BuildConfig import moe.chenxy.miuiextra.hooker.entity.home.AnimationEnhanceHooker import moe.chenxy.miuiextra.hooker.entity.home.IconLaunchAnimHooker +import moe.chenxy.miuiextra.hooker.entity.home.TitleShadowHooker import moe.chenxy.miuiextra.hooker.entity.home.ViewBlurHooker import moe.chenxy.miuiextra.hooker.entity.home.WallpaperZoomOptimizeLegacy import moe.chenxy.miuiextra.hooker.entity.home.WallpaperZoomOptimizeOS1NewArch @@ -22,7 +20,7 @@ import moe.chenxy.miuiextra.utils.ChenUtils object MiuiHomeHook : YukiBaseHooker() { - private val mainPrefs = XSharedPreferences(BuildConfig.APPLICATION_ID, "chen_main_settings") + val mainPrefs = XSharedPreferences(BuildConfig.APPLICATION_ID, "chen_main_settings") val zoomPrefs = XSharedPreferences(BuildConfig.APPLICATION_ID, "chen_wallpaper_zoom_settings") enum class AnimType { @@ -55,6 +53,7 @@ object MiuiHomeHook : YukiBaseHooker() { } loadHooker(ViewBlurHooker) + loadHooker(TitleShadowHooker) "com.miui.home.launcher.compat.UserPresentAnimationCompatV12Phone".toClass().apply { @@ -95,29 +94,5 @@ object MiuiHomeHook : YukiBaseHooker() { } } } - - "com.miui.home.launcher.DeviceConfig".toClass().apply { - method { - name = "checkDarkenWallpaperSupport" - param(ContextClass) - }.hook { - replaceTo(!mainPrefs.getBoolean("disable_wallpaper_auto_darken", false)) - } - } - - "com.miui.home.launcher.common.Utilities".toClass().apply { - method { - name = "setTitleShadow" - paramCount = 3 - }.hook { - after { - val textView = this.args[1] as TextView -// val color = this.args[2] as Int - textView.setShadowLayer(30.0f, 0f, 0f, Color.rgb(10,10,10)) - } - } - } - - } } \ No newline at end of file diff --git a/app/src/main/java/moe/chenxy/miuiextra/hooker/entity/home/TitleShadowHooker.kt b/app/src/main/java/moe/chenxy/miuiextra/hooker/entity/home/TitleShadowHooker.kt new file mode 100644 index 0000000..d348cdd --- /dev/null +++ b/app/src/main/java/moe/chenxy/miuiextra/hooker/entity/home/TitleShadowHooker.kt @@ -0,0 +1,44 @@ +package moe.chenxy.miuiextra.hooker.entity.home + +import android.graphics.Color +import android.widget.TextView +import androidx.core.graphics.blue +import androidx.core.graphics.green +import androidx.core.graphics.red +import com.highcapable.yukihookapi.hook.entity.YukiBaseHooker +import com.highcapable.yukihookapi.hook.factory.method +import com.highcapable.yukihookapi.hook.type.android.ContextClass +import moe.chenxy.miuiextra.hooker.entity.MiuiHomeHook.mainPrefs +import kotlin.math.abs + +object TitleShadowHooker : YukiBaseHooker() { + override fun onHook() { + val enableShadow = mainPrefs.getBoolean("disable_wallpaper_auto_darken", false) + "com.miui.home.launcher.DeviceConfig".toClass().apply { + method { + name = "checkDarkenWallpaperSupport" + param(ContextClass) + }.hook { + replaceTo(!enableShadow) + } + } + + "com.miui.home.launcher.common.Utilities".toClass().apply { + method { + name = "setTitleShadow" + paramCount = 3 + }.hook { + replaceUnit { + if (!enableShadow) return@replaceUnit + + val textView = this.args[1] as TextView +// val color = this.args[2] as Int + val textColor = textView.currentTextColor + val reversedColor = Color.rgb(abs(245 - textColor.red),abs(245 - textColor.green),abs(245 - textColor.blue)) + textView.setShadowLayer(30.0f, 0f, 0f, reversedColor) + } + } + } + + } +} \ No newline at end of file