mirror of
https://github.com/fcitx5-android/fcitx5-android.git
synced 2026-08-02 20:16:06 +08:00
feat: add sharedpreference for solid border switch
This commit is contained in:
parent
9635ed042b
commit
6c90e06d7d
@ -36,8 +36,11 @@ class ThemePrefs(sharedPreferences: SharedPreferences) :
|
||||
|
||||
val keyBorder = switch(R.string.key_border, "key_border", false)
|
||||
|
||||
val keySolidBorder = switch(R.string.key_solid_border, "key_solid_border", false)
|
||||
|
||||
val keyRippleEffect = switch(R.string.key_ripple_effect, "key_ripple_effect", false)
|
||||
|
||||
|
||||
val keyHorizontalMargin: ManagedPreference.PInt
|
||||
val keyHorizontalMarginLandscape: ManagedPreference.PInt
|
||||
|
||||
|
||||
@ -48,13 +48,30 @@ fun borderedKeyBackgroundDrawable(
|
||||
radius: Float,
|
||||
shadowWidth: Int,
|
||||
hMargin: Int,
|
||||
vMargin: Int
|
||||
vMargin: Int,
|
||||
shouldDrawBorder: Boolean = false
|
||||
): Drawable = LayerDrawable(
|
||||
arrayOf(
|
||||
radiusDrawable(radius, shadowColor),
|
||||
radiusDrawable(radius, bkgColor),
|
||||
)
|
||||
).apply {
|
||||
setLayerInset(0, hMargin - shadowWidth, vMargin - shadowWidth, hMargin - shadowWidth, vMargin - shadowWidth)
|
||||
if (shouldDrawBorder) {
|
||||
setLayerInset(
|
||||
0,
|
||||
hMargin - shadowWidth,
|
||||
vMargin - shadowWidth,
|
||||
hMargin - shadowWidth,
|
||||
vMargin - shadowWidth
|
||||
)
|
||||
} else {
|
||||
setLayerInset(
|
||||
0,
|
||||
hMargin,
|
||||
vMargin,
|
||||
hMargin,
|
||||
vMargin- shadowWidth
|
||||
)
|
||||
}
|
||||
setLayerInset(1, hMargin, vMargin, hMargin, vMargin)
|
||||
}
|
||||
|
||||
@ -56,6 +56,7 @@ abstract class KeyView(ctx: Context, val theme: Theme, val def: KeyDef.Appearanc
|
||||
|
||||
val bordered: Boolean
|
||||
val rippled: Boolean
|
||||
val solidBordered: Boolean
|
||||
val radius: Float
|
||||
val hMargin: Int
|
||||
val vMargin: Int
|
||||
@ -64,6 +65,7 @@ abstract class KeyView(ctx: Context, val theme: Theme, val def: KeyDef.Appearanc
|
||||
val prefs = ThemeManager.prefs
|
||||
bordered = prefs.keyBorder.getValue()
|
||||
rippled = prefs.keyRippleEffect.getValue()
|
||||
solidBordered = prefs.keySolidBorder.getValue()
|
||||
radius = dp(prefs.keyRadius.getValue().toFloat())
|
||||
val landscape = resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE
|
||||
val hMarginPref =
|
||||
@ -126,7 +128,7 @@ abstract class KeyView(ctx: Context, val theme: Theme, val def: KeyDef.Appearanc
|
||||
// background: key border
|
||||
appearanceView.background = borderedKeyBackgroundDrawable(
|
||||
bkgColor, theme.keyShadowColor,
|
||||
radius, shadowWidth, hMargin, vMargin
|
||||
radius, shadowWidth, hMargin, vMargin, solidBordered
|
||||
)
|
||||
// foreground: press highlight or ripple
|
||||
setupPressHighlight()
|
||||
|
||||
@ -315,4 +315,5 @@
|
||||
<string name="emoji_skin_tone_type_5">🏾 Type-5</string>
|
||||
<string name="emoji_skin_tone_type_6">🏿 Type-6</string>
|
||||
<string name="hide_unsupported_emojis">Hide unsupported Emojis</string>
|
||||
<string name="key_solid_border">Enable solid border instead of shadow</string>
|
||||
</resources>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user