From 59f54ba7bc63c35421c7dbccb5abe9588443cc70 Mon Sep 17 00:00:00 2001
From: SuperDragonXD <70206496+SuperDragonXD@users.noreply.github.com>
Date: Tue, 6 Aug 2024 21:03:15 +0800
Subject: [PATCH] Update defaults for hotseat qsb
Fix #4628
---
lawnchair/res/values/strings.xml | 6 ++--
.../preferences/PreferenceManager.kt | 4 +--
.../src/app/lawnchair/qsb/LawnQsbLayout.kt | 12 ++++---
.../ColorPreferenceModelList.kt | 2 +-
.../destinations/DockPreferences.kt | 34 +++++++++++--------
5 files changed, 32 insertions(+), 26 deletions(-)
diff --git a/lawnchair/res/values/strings.xml b/lawnchair/res/values/strings.xml
index 530417452d0..5dcae68586d 100644
--- a/lawnchair/res/values/strings.xml
+++ b/lawnchair/res/values/strings.xml
@@ -294,7 +294,6 @@
Colors
Accent color
- Stroke color
Swatches
@@ -529,8 +528,9 @@
Lawnchair
Google Search bar
- Opacity
- Stroke
+ Background opacity
+ Outline width
+ Outline color
Corner radius
Apply accent color
Search provider
diff --git a/lawnchair/src/app/lawnchair/preferences/PreferenceManager.kt b/lawnchair/src/app/lawnchair/preferences/PreferenceManager.kt
index 21960c1136e..ac538624395 100644
--- a/lawnchair/src/app/lawnchair/preferences/PreferenceManager.kt
+++ b/lawnchair/src/app/lawnchair/preferences/PreferenceManager.kt
@@ -94,8 +94,8 @@ class PreferenceManager private constructor(private val context: Context) : Base
val themedIcons = BoolPref("themed_icons", true, recreate)
val drawerThemedIcons = BoolPref("drawer_themed_icons", false, recreate)
val hotseatQsbCornerRadius = FloatPref("pref_hotseatQsbCornerRadius", 1F, recreate)
- val searchBackgroundHotseatTransparency = IntPref("pref_searchHotseatTranparency", 0, recreate)
- val searchStrokeWidth = FloatPref("pref_searchStrokeWidth", 1F, recreate)
+ val hotseatQsbAlpha = IntPref("pref_searchHotseatTranparency", 100, recreate)
+ val hotseatQsbStrokeWidth = FloatPref("pref_searchStrokeWidth", 0F, recreate)
val enableWallpaperBlur = BoolPref("pref_enableWallpaperBlur", false, recreate)
val wallpaperBlur = IntPref("pref_wallpaperBlur", 25, recreate)
val wallpaperBlurFactorThreshold = IntPref("pref_wallpaperBlurFactor", 25, recreate)
diff --git a/lawnchair/src/app/lawnchair/qsb/LawnQsbLayout.kt b/lawnchair/src/app/lawnchair/qsb/LawnQsbLayout.kt
index be263db77a0..359f8662e79 100644
--- a/lawnchair/src/app/lawnchair/qsb/LawnQsbLayout.kt
+++ b/lawnchair/src/app/lawnchair/qsb/LawnQsbLayout.kt
@@ -129,8 +129,8 @@ class LawnQsbLayout(context: Context, attrs: AttributeSet?) : FrameLayout(contex
subscribeGoogleSearchWidget()
}
- preferenceManager.searchBackgroundHotseatTransparency.subscribeChanges(this::setUpBackground)
- preferenceManager.searchStrokeWidth.subscribeChanges(this::setUpBackground)
+ preferenceManager.hotseatQsbAlpha.subscribeChanges(this::setUpBackground)
+ preferenceManager.hotseatQsbStrokeWidth.subscribeChanges(this::setUpBackground)
}
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
@@ -196,13 +196,13 @@ class LawnQsbLayout(context: Context, attrs: AttributeSet?) : FrameLayout(contex
}
private fun setUpBackground(themed: Boolean = false) {
- val transparency = preferenceManager.searchBackgroundHotseatTransparency.get()
+ val transparency = preferenceManager.hotseatQsbAlpha.get()
val cornerRadius = getCornerRadius(context, preferenceManager)
val baseColor = if (themed) Themes.getColorBackgroundFloating(context) else Themes.getAttrColor(context, R.attr.qsbFillColor)
val alphaValue = (transparency * 255) / 100
val color = Color.argb(alphaValue, Color.red(baseColor), Color.green(baseColor), Color.blue(baseColor))
val strokeColor = strokeColor
- val strokeWidth = preferenceManager.searchStrokeWidth.get()
+ val strokeWidth = preferenceManager.hotseatQsbStrokeWidth.get()
val backgroundDrawable = PaintDrawable(color).apply {
setCornerRadius(cornerRadius)
@@ -217,9 +217,11 @@ class LawnQsbLayout(context: Context, attrs: AttributeSet?) : FrameLayout(contex
val combinedDrawable = LayerDrawable(arrayOf(backgroundDrawable, strokeDrawable))
+ val qsbBackground = if (strokeWidth != 0f) combinedDrawable else backgroundDrawable
+
with(inner) {
clipToOutline = cornerRadius > 0
- background = combinedDrawable
+ background = qsbBackground
}
}
diff --git a/lawnchair/src/app/lawnchair/ui/preferences/components/colorpreference/ColorPreferenceModelList.kt b/lawnchair/src/app/lawnchair/ui/preferences/components/colorpreference/ColorPreferenceModelList.kt
index 99ce3858c72..222c23431fe 100644
--- a/lawnchair/src/app/lawnchair/ui/preferences/components/colorpreference/ColorPreferenceModelList.kt
+++ b/lawnchair/src/app/lawnchair/ui/preferences/components/colorpreference/ColorPreferenceModelList.kt
@@ -20,7 +20,7 @@ class ColorPreferenceModelList(context: Context) {
registerModel(
ColorPreferenceModel(
prefObject = prefs.strokeColorStyle,
- labelRes = R.string.stroke_color,
+ labelRes = R.string.qsb_hotseat_stroke_color,
dynamicEntries = dynamicColors,
),
)
diff --git a/lawnchair/src/app/lawnchair/ui/preferences/destinations/DockPreferences.kt b/lawnchair/src/app/lawnchair/ui/preferences/destinations/DockPreferences.kt
index fed3c3ae538..af7d5399428 100644
--- a/lawnchair/src/app/lawnchair/ui/preferences/destinations/DockPreferences.kt
+++ b/lawnchair/src/app/lawnchair/ui/preferences/destinations/DockPreferences.kt
@@ -67,6 +67,16 @@ fun DockPreferences(
)
ExpandAndShrink(visible = hotseatModeAdapter.state.value == LawnchairHotseat) {
DividerColumn {
+ val hotseatQsbProviderAdapter by preferenceManager2().hotseatQsbProvider.getAdapter()
+ NavigationActionPreference(
+ label = stringResource(R.string.search_provider),
+ destination = DockRoutes.SEARCH_PROVIDER,
+ subtitle = stringResource(
+ id = QsbSearchProvider.values()
+ .first { it == hotseatQsbProviderAdapter }
+ .name,
+ ),
+ )
SwitchPreference(
adapter = prefs2.themedHotseatQsb.getAdapter(),
label = stringResource(id = R.string.apply_accent_color_label),
@@ -78,31 +88,25 @@ fun DockPreferences(
valueRange = 0F..1F,
showAsPercentage = true,
)
- val hotseatQsbProviderAdapter by preferenceManager2().hotseatQsbProvider.getAdapter()
- NavigationActionPreference(
- label = stringResource(R.string.search_provider),
- destination = DockRoutes.SEARCH_PROVIDER,
- subtitle = stringResource(
- id = QsbSearchProvider.values()
- .first { it == hotseatQsbProviderAdapter }
- .name,
- ),
- )
SliderPreference(
- label = stringResource(id = R.string.search_background_transparency),
- adapter = prefs.searchBackgroundHotseatTransparency.getAdapter(),
+ label = stringResource(id = R.string.qsb_hotseat_background_transparency),
+ adapter = prefs.hotseatQsbAlpha.getAdapter(),
step = 5,
valueRange = 0..100,
showUnit = "%",
)
+ val qsbHotseatStrokeWidth = prefs.hotseatQsbStrokeWidth.getAdapter()
+
SliderPreference(
- label = stringResource(id = R.string.stroke_width),
- adapter = prefs.searchStrokeWidth.getAdapter(),
+ label = stringResource(id = R.string.qsb_hotseat_stroke_width),
+ adapter = qsbHotseatStrokeWidth,
step = 1f,
valueRange = 0f..10f,
showUnit = "vw",
)
- ColorPreference(preference = prefs2.strokeColorStyle)
+ ExpandAndShrink(visible = qsbHotseatStrokeWidth.state.value > 0f) {
+ ColorPreference(preference = prefs2.strokeColorStyle)
+ }
}
}
}