Add option to hide altText (#720)

Co-authored-by: Rocka <i@rocka.me>
This commit is contained in:
Qijia Liu 2025-05-09 10:06:38 -04:00 committed by GitHub
parent 81e04ec06b
commit aa6c3a0c82
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 17 additions and 0 deletions

View File

@ -87,6 +87,7 @@ class ThemePrefs(sharedPreferences: SharedPreferences) :
int(R.string.clipboard_entry_radius, "clipboard_entry_radius", 2, 0, 48, "dp")
enum class PunctuationPosition(override val stringRes: Int) : ManagedPreferenceEnum {
None(R.string.punctuation_pos_none),
Bottom(R.string.punctuation_pos_bottom),
TopRight(R.string.punctuation_pos_top_right);
}

View File

@ -298,6 +298,7 @@ class AltTextKeyView(ctx: Context, theme: Theme, def: KeyDef.Appearance.AltText)
topToTop = parentId
bottomToBottom = parentId
}
altText.visibility = View.VISIBLE
altText.updateLayoutParams<ConstraintLayout.LayoutParams> {
// reset
bottomToBottom = unset; bottomMargin = 0
@ -316,6 +317,7 @@ class AltTextKeyView(ctx: Context, theme: Theme, def: KeyDef.Appearance.AltText)
topToTop = parentId; topMargin = vMargin
bottomToTop = altText.existingOrNewId
}
altText.visibility = View.VISIBLE
altText.updateLayoutParams<ConstraintLayout.LayoutParams> {
// reset
topToTop = unset; topMargin = 0
@ -327,6 +329,18 @@ class AltTextKeyView(ctx: Context, theme: Theme, def: KeyDef.Appearance.AltText)
}
}
private fun applyNoAltTextPosition() {
mainText.updateLayoutParams<ConstraintLayout.LayoutParams> {
// reset
topMargin = 0
bottomToTop = unset
// set
topToTop = parentId
bottomToBottom = parentId
}
altText.visibility = View.GONE
}
private fun applyLayout(orientation: Int) {
when (ThemeManager.prefs.punctuationPosition.getValue()) {
PunctuationPosition.Bottom -> when (orientation) {
@ -334,6 +348,7 @@ class AltTextKeyView(ctx: Context, theme: Theme, def: KeyDef.Appearance.AltText)
else -> applyBottomAltTextPosition()
}
PunctuationPosition.TopRight -> applyTopRightAltTextPosition()
PunctuationPosition.None -> applyNoAltTextPosition()
}
}

View File

@ -122,6 +122,7 @@
<string name="punctuation_position">Punctuation position</string>
<string name="punctuation_pos_bottom">Bottom (Portrait only)</string>
<string name="punctuation_pos_top_right">Top Right</string>
<string name="punctuation_pos_none">None</string>
<string name="expand_toolbar_by_default">Expand toolbar by default</string>
<string name="popup_on_key_press">Popup on key press</string>
<string name="disable_animation">Disable animation</string>