Skip to content

Commit

Permalink
WallpaperDarkenDisabler: split home text shadow feature toggle
Browse files Browse the repository at this point in the history
Signed-off-by: Art_Chen <[email protected]>
  • Loading branch information
Art-Chen committed Aug 20, 2024
1 parent 91a645a commit 0e08a28
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ object IconLaunchAnimHooker : YukiBaseHooker() {

// Don't run PerformClickRunnable early
"com.miui.home.launcher.ItemIcon".toClass().method {
name = "initPerformClickRunnable"
name = "initPerformClickRunnable"
}.hook {
replaceUnit {
XposedHelpers.setObjectField(instance, "mPerformClickRunnable", mRunnable)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import kotlin.math.abs

object TitleShadowHooker : YukiBaseHooker() {
override fun onHook() {
val enableShadow = mainPrefs.getBoolean("disable_wallpaper_auto_darken", false)
val enableShadow = mainPrefs.getBoolean("disable_wallpaper_auto_darken", false) && mainPrefs.getBoolean("enable_home_text_shadow", false)
"com.miui.home.launcher.DeviceConfig".toClass().apply {
method {
name = "checkDarkenWallpaperSupport"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ class SettingsActivity : AppCompatActivity() {
override fun onPreferenceTreeClick(preference: Preference): Boolean {
if (preference is TwoStatePreference) {
when (preference.key) {
"override_linkage_wallpaper_anim", "disable_wallpaper_auto_darken" -> {
"override_linkage_wallpaper_anim", "enable_home_text_shadow" -> {
this.context?.let { ChenUtils.performVibrateHeavyClick(it) }
return true
}
}
Expand Down Expand Up @@ -199,7 +200,7 @@ class SettingsActivity : AppCompatActivity() {
return@setOnPreferenceChangeListener true
}

findPreference<SwitchPreferenceCompat>("disable_wallpaper_auto_darken")?.setOnPreferenceChangeListener { _, _ ->
findPreference<SwitchPreferenceCompat>("enable_home_text_shadow")?.setOnPreferenceChangeListener { _, _ ->
// MiuiHome use this feature toggle to inject hook when on load, Wallpaper app check this feature toggle on every call
showRebootSnackBar(null, SHELL_RESTART_MIUI_HOME)
return@setOnPreferenceChangeListener true
Expand Down
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 @@ -247,4 +247,5 @@
<string name="disable_wallpaper_auto_darken_summary">This will also add a beautiful text shadow on miui home icon title to enhance text visibility</string>
<string name="lineage_aod_wallpaper_anim_title">Lineage Aod and Chen Wallpaper Anim</string>
<string name="lineage_aod_wallpaper_anim_summary">WARNING: May cause screen burn if AOD Always mode</string>
<string name="enable_home_text_shadow_title">Enable Home Text Shadow</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 @@ -134,4 +134,5 @@
<string name="override_linkage_wallpaper_anim_title">覆盖联动息屏壁纸动画参数</string>
<string name="lineage_aod_wallpaper_anim_title">联动息屏和琛的壁纸动画</string>
<string name="lineage_aod_wallpaper_anim_summary">警告:长亮AOD时有烧屏风险</string>
<string name="enable_home_text_shadow_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 @@ -136,4 +136,5 @@
<string name="disable_wallpaper_auto_darken_summary">This will also add a beautiful text shadow on miui home icon title to enhance text visibility</string>
<string name="lineage_aod_wallpaper_anim_title">Lineage Aod and Chen Wallpaper Anim</string>
<string name="lineage_aod_wallpaper_anim_summary">WARNING: May cause screen burn if AOD Always mode</string>
<string name="enable_home_text_shadow_title">Enable Home Text Shadow</string>
</resources>
7 changes: 6 additions & 1 deletion app/src/main/res/xml/chen_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,12 @@

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

<rikka.material.preference.MaterialSwitchPreference
app:key="enable_home_text_shadow"
app:dependency="disable_wallpaper_auto_darken"
app:title="@string/enable_home_text_shadow_title"
app:summary="@string/disable_wallpaper_auto_darken_summary" />

<!-- <rikka.material.preference.MaterialSwitchPreference-->
Expand Down

0 comments on commit 0e08a28

Please sign in to comment.