Skip to content

Commit

Permalink
Update defaults for hotseat qsb
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperDragonXD authored and nulldrf committed Aug 24, 2024
1 parent fe5c0fa commit 59f54ba
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 26 deletions.
6 changes: 3 additions & 3 deletions lawnchair/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,6 @@
<!-- Accent color and color picker -->
<string name="colors">Colors</string>
<string name="accent_color">Accent color</string>
<string name="stroke_color">Stroke color</string>

<string name="swatches">Swatches</string>

Expand Down Expand Up @@ -529,8 +528,9 @@
<string name="hotseat_mode_lawnchair" translatable="false">Lawnchair</string>
<string name="hotseat_mode_google_search">Google Search bar</string>

<string name="search_background_transparency">Opacity</string>
<string name="stroke_width">Stroke</string>
<string name="qsb_hotseat_background_transparency">Background opacity</string>
<string name="qsb_hotseat_stroke_width">Outline width</string>
<string name="qsb_hotseat_stroke_color">Outline color</string>
<string name="corner_radius_label">Corner radius</string>
<string name="apply_accent_color_label">Apply accent color</string>
<string name="search_provider">Search provider</string>
Expand Down
4 changes: 2 additions & 2 deletions lawnchair/src/app/lawnchair/preferences/PreferenceManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 7 additions & 5 deletions lawnchair/src/app/lawnchair/qsb/LawnQsbLayout.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
Expand All @@ -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
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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)
}
}
}
}
Expand Down

0 comments on commit 59f54ba

Please sign in to comment.