Skip to content

Commit

Permalink
Improve bottom offset feature (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickgold committed Jan 31, 2021
1 parent 5cbbbc2 commit 3688f8e
Show file tree
Hide file tree
Showing 20 changed files with 28 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ import android.content.Context
import android.content.res.Configuration
import android.util.AttributeSet
import android.util.DisplayMetrics
import android.util.Log
import android.widget.ImageButton
import android.widget.LinearLayout
import android.widget.ViewFlipper
import dev.patrickgold.florisboard.BuildConfig
import dev.patrickgold.florisboard.R
import dev.patrickgold.florisboard.ime.text.key.KeyVariation
import dev.patrickgold.florisboard.ime.text.keyboard.KeyboardMode
Expand Down Expand Up @@ -135,7 +133,11 @@ class InputView : LinearLayout {
// Add bottom offset for curved screens here. As the desired heights have already been set,
// adding a value to the height now will result in a bottom padding (aka offset).
baseHeight += ViewLayoutUtils.convertDpToPixel(
florisboard.prefs.keyboard.bottomOffset.toFloat(),
if (resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) {
florisboard.prefs.keyboard.bottomOffsetLandscape.toFloat()
} else {
florisboard.prefs.keyboard.bottomOffsetPortrait.toFloat()
},
context
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,8 @@ class PrefHelper(
*/
class Keyboard(private val prefHelper: PrefHelper) {
companion object {
const val BOTTOM_OFFSET = "keyboard__bottom_offset"
const val BOTTOM_OFFSET_PORTRAIT = "keyboard__bottom_offset_portrait"
const val BOTTOM_OFFSET_LANDSCAPE = "keyboard__bottom_offset_landscape"
const val FONT_SIZE_MULTIPLIER_PORTRAIT = "keyboard__font_size_multiplier_portrait"
const val FONT_SIZE_MULTIPLIER_LANDSCAPE = "keyboard__font_size_multiplier_landscape"
const val HEIGHT_FACTOR = "keyboard__height_factor"
Expand All @@ -327,8 +328,11 @@ class PrefHelper(
const val VIBRATION_STRENGTH = "keyboard__vibration_strength"
}

var bottomOffset: Int = 0
get() = prefHelper.getPref(BOTTOM_OFFSET, 0)
var bottomOffsetPortrait: Int = 0
get() = prefHelper.getPref(BOTTOM_OFFSET_PORTRAIT, 0)
private set
var bottomOffsetLandscape: Int = 0
get() = prefHelper.getPref(BOTTOM_OFFSET_LANDSCAPE, 0)
private set
var fontSizeMultiplierPortrait: Int
get() = prefHelper.getPref(FONT_SIZE_MULTIPLIER_PORTRAIT, 100)
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-ar/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@
<string name="pref__keyboard__height_factor__extra_tall" comment="Preference value">طويل جدا</string>
<string name="pref__keyboard__height_factor__custom" comment="Preference value">مخصص</string>
<string name="pref__keyboard__height_factor_custom__label" comment="Preference title">قيمة ارتفاع لوحة المفاتيح المخصصة</string>
<string name="pref__keyboard__bottom_offset__label" comment="Preference title">الإزاحة السفلية (للشاشات المقوسة)</string>
<string name="pref__keyboard__group_keypress__label" comment="Preference group title">ضغط المفتاح</string>
<string name="pref__keyboard__sound_enabled__label" comment="Preference title">الصوت عند ضغط المفتاح</string>
<string name="pref__keyboard__sound_volume__label" comment="Preference title">حجم الصوت عند ضغط المفتاح</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-cs/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@
<string name="pref__keyboard__height_factor__extra_tall" comment="Preference value">Extra vysoká</string>
<string name="pref__keyboard__height_factor__custom" comment="Preference value">Vlastní</string>
<string name="pref__keyboard__height_factor_custom__label" comment="Preference title">Vlastní hodnota výšky klávesnice</string>
<string name="pref__keyboard__bottom_offset__label" comment="Preference title">Odstup zdola (pro zahnuté displeje)</string>
<string name="pref__keyboard__group_keypress__label" comment="Preference group title">Stisk klávesy</string>
<string name="pref__keyboard__sound_enabled__label" comment="Preference title">Zvuk při stisku klávesy</string>
<string name="pref__keyboard__sound_volume__label" comment="Preference title">Hlasitost zvuku při stisku klávesy</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-da/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
<string name="pref__keyboard__height_factor__extra_tall" comment="Preference value">Extra-høj</string>
<string name="pref__keyboard__height_factor__custom" comment="Preference value">Brugerdefineret</string>
<string name="pref__keyboard__height_factor_custom__label" comment="Preference title">Brugerdefineret tastatur højde</string>
<string name="pref__keyboard__bottom_offset__label" comment="Preference title">Forskudt fra bund (for kurvede skærme)</string>
<string name="pref__keyboard__group_keypress__label" comment="Preference group title">Tastetryk</string>
<string name="pref__keyboard__sound_enabled__label" comment="Preference title">Lyd ved tastetryk</string>
<string name="pref__keyboard__sound_volume__label" comment="Preference title">Lydstryke ved tastetryk</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@
<string name="pref__keyboard__height_factor__extra_tall" comment="Preference value">Sehr groß</string>
<string name="pref__keyboard__height_factor__custom" comment="Preference value">Benutzerdefiniert</string>
<string name="pref__keyboard__height_factor_custom__label" comment="Preference title">Benutzerdefinierte Tastaturhöhe</string>
<string name="pref__keyboard__bottom_offset__label" comment="Preference title">Unteres Ende absetzen (für abgerundete Bildschirme)</string>
<string name="pref__keyboard__group_keypress__label" comment="Preference group title">Tastendruck</string>
<string name="pref__keyboard__sound_enabled__label" comment="Preference title">Ton bei Tastendruck</string>
<string name="pref__keyboard__sound_volume__label" comment="Preference title">Lautstärke der Tastendrucktöne</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-el/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@
<string name="pref__keyboard__height_factor__extra_tall" comment="Preference value">Πολύ-ψηλό</string>
<string name="pref__keyboard__height_factor__custom" comment="Preference value">Προσαρμοσμένο</string>
<string name="pref__keyboard__height_factor_custom__label" comment="Preference title">Προσαρμοσμένη τιμή ύψους πληκτρολογίου</string>
<string name="pref__keyboard__bottom_offset__label" comment="Preference title">Αντιστάθμιση βάσης (για κυρτές οθόνες)</string>
<string name="pref__keyboard__group_keypress__label" comment="Preference group title">Πάτημα πλήκτρου</string>
<string name="pref__keyboard__sound_enabled__label" comment="Preference title">Ήχος κατά το πάτημα πλήκτρου</string>
<string name="pref__keyboard__sound_volume__label" comment="Preference title">Ένταση ήχου κατά το πάτημα πλήκτρου</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@
<string name="pref__keyboard__height_factor__extra_tall" comment="Preference value">Muy alto</string>
<string name="pref__keyboard__height_factor__custom" comment="Preference value">Personalizado</string>
<string name="pref__keyboard__height_factor_custom__label" comment="Preference title">Valor de altura del teclado personalizada</string>
<string name="pref__keyboard__bottom_offset__label" comment="Preference title">Desplazamiento del fondo (para pantallas curvas)</string>
<string name="pref__keyboard__group_keypress__label" comment="Preference group title">Pulsación de tecla</string>
<string name="pref__keyboard__sound_enabled__label" comment="Preference title">Sonido al pulsar la tecla</string>
<string name="pref__keyboard__sound_volume__label" comment="Preference title">Volumen del sonido al pulsar la tecla</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-fa/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@
<string name="pref__keyboard__height_factor__extra_tall" comment="Preference value">بیشتر-بلند</string>
<string name="pref__keyboard__height_factor__custom" comment="Preference value">سفارشی</string>
<string name="pref__keyboard__height_factor_custom__label" comment="Preference title">مقدار ارتفاع سفارشی صفحه‌کلید</string>
<string name="pref__keyboard__bottom_offset__label" comment="Preference title">فاصله از کف (برای صفحه های منحنی)</string>
<string name="pref__keyboard__group_keypress__label" comment="Preference group title">فشردن کلید</string>
<string name="pref__keyboard__sound_enabled__label" comment="Preference title">صدای فشردن کلید</string>
<string name="pref__keyboard__sound_volume__label" comment="Preference title">میزان صدای فشردن کلید</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-fi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@
<string name="pref__keyboard__height_factor__extra_tall" comment="Preference value">Erittäin korkea</string>
<string name="pref__keyboard__height_factor__custom" comment="Preference value">Mukautettu</string>
<string name="pref__keyboard__height_factor_custom__label" comment="Preference title">Mukautettu näppäimistön korkeus</string>
<string name="pref__keyboard__bottom_offset__label" comment="Preference title">Alareunan sijainnin korjaus (kaareville näytöille)</string>
<string name="pref__keyboard__group_keypress__label" comment="Preference group title">Painallus</string>
<string name="pref__keyboard__sound_enabled__label" comment="Preference title">Painikeääni</string>
<string name="pref__keyboard__sound_volume__label" comment="Preference title">Painikeäänen voimakkuus</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@
<string name="pref__keyboard__height_factor__extra_tall" comment="Preference value">Très haut</string>
<string name="pref__keyboard__height_factor__custom" comment="Preference value">Personnalisée</string>
<string name="pref__keyboard__height_factor_custom__label" comment="Preference title">Valeur personnalisée de la hauteur du clavier</string>
<string name="pref__keyboard__bottom_offset__label" comment="Preference title">Décalage du fond (pour les écrans courbes)</string>
<string name="pref__keyboard__group_keypress__label" comment="Preference group title">Touche pressée</string>
<string name="pref__keyboard__sound_enabled__label" comment="Preference title">Tonalité des touches</string>
<string name="pref__keyboard__sound_volume__label" comment="Preference title">Volume sonore des touches</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-he/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@
<string name="pref__keyboard__height_factor__extra_tall" comment="Preference value">גבוה במיוחד</string>
<string name="pref__keyboard__height_factor__custom" comment="Preference value">מותאם אישית</string>
<string name="pref__keyboard__height_factor_custom__label" comment="Preference title">גובה מקלדת מותאם אישית</string>
<string name="pref__keyboard__bottom_offset__label" comment="Preference title">היסט מהתחתית (למסכים מעוקלים)</string>
<string name="pref__keyboard__group_keypress__label" comment="Preference group title">לחיצת מקש</string>
<string name="pref__keyboard__sound_enabled__label" comment="Preference title">שמע בעת לחיצה על מקש</string>
<string name="pref__keyboard__sound_volume__label" comment="Preference title">השמע צליל בעת לחיצה על מקש</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-hu/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@
<string name="pref__keyboard__height_factor__extra_tall" comment="Preference value">Nagyon magas</string>
<string name="pref__keyboard__height_factor__custom" comment="Preference value">Egyéni</string>
<string name="pref__keyboard__height_factor_custom__label" comment="Preference title">Egyéni billentyűzetmagasság értéke</string>
<string name="pref__keyboard__bottom_offset__label" comment="Preference title">Alsó eltolás (ívelt kijelzőkhöz)</string>
<string name="pref__keyboard__group_keypress__label" comment="Preference group title">Gombnyomás</string>
<string name="pref__keyboard__sound_enabled__label" comment="Preference title">Hang gombnyomásra</string>
<string name="pref__keyboard__sound_volume__label" comment="Preference title">Gombnyomás hangereje</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@
<string name="pref__keyboard__height_factor__extra_tall" comment="Preference value">Altissima</string>
<string name="pref__keyboard__height_factor__custom" comment="Preference value">Personalizzato</string>
<string name="pref__keyboard__height_factor_custom__label" comment="Preference title">Valore Altezza tastiera personalizzata</string>
<string name="pref__keyboard__bottom_offset__label" comment="Preference title">Offset dal basso (per schermi curvi)</string>
<string name="pref__keyboard__group_keypress__label" comment="Preference group title">Pressione tasti</string>
<string name="pref__keyboard__sound_enabled__label" comment="Preference title">Suono pressione tasti</string>
<string name="pref__keyboard__sound_volume__label" comment="Preference title">Volume del suono alla pressione dei tasti</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-ku/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@
<string name="pref__keyboard__height_factor__extra_tall" comment="Preference value">گەورەترین</string>
<string name="pref__keyboard__height_factor__custom" comment="Preference value">تایبەت</string>
<string name="pref__keyboard__height_factor_custom__label" comment="Preference title">ڕێژەی ئاستی قیاسی تەختەکلیل</string>
<string name="pref__keyboard__bottom_offset__label" comment="Preference title">قەبارەی بەشی خوارەوە (بۆ شاشە تەنیشت چەماوەکان)</string>
<string name="pref__keyboard__group_keypress__label" comment="Preference group title">کاریگەرییەکان</string>
<string name="pref__keyboard__sound_enabled__label" comment="Preference title">دەنگ لەکاتی نووسین</string>
<string name="pref__keyboard__sound_volume__label" comment="Preference title">ئاستی دەنگ</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-nl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@
<string name="pref__keyboard__height_factor__extra_tall" comment="Preference value">Extra Hoog</string>
<string name="pref__keyboard__height_factor__custom" comment="Preference value">Aangepast</string>
<string name="pref__keyboard__height_factor_custom__label" comment="Preference title">Aangepaste hoogte van toetsenbord</string>
<string name="pref__keyboard__bottom_offset__label" comment="Preference title">Offset onderaan (voor gebogen schermen)</string>
<string name="pref__keyboard__group_keypress__label" comment="Preference group title">Toetsdruk</string>
<string name="pref__keyboard__sound_enabled__label" comment="Preference title">Geluid bij toetsdruk</string>
<string name="pref__keyboard__sound_volume__label" comment="Preference title">Geluidsvolume bij toetsdruk</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-pt-rBR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@
<string name="pref__keyboard__height_factor__extra_tall" comment="Preference value">Muito alto</string>
<string name="pref__keyboard__height_factor__custom" comment="Preference value">Personalizado</string>
<string name="pref__keyboard__height_factor_custom__label" comment="Preference title">Valor personalizado da altura do teclado</string>
<string name="pref__keyboard__bottom_offset__label" comment="Preference title">Deslocamento inferior (para telas curvas)</string>
<string name="pref__keyboard__group_keypress__label" comment="Preference group title">Pressionar tecla</string>
<string name="pref__keyboard__sound_enabled__label" comment="Preference title">Som ao pressionar uma tecla</string>
<string name="pref__keyboard__sound_volume__label" comment="Preference title">Volume do som ao pressionar uma tecla</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-pt/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@
<string name="pref__keyboard__height_factor__extra_tall" comment="Preference value">Enorme</string>
<string name="pref__keyboard__height_factor__custom" comment="Preference value">Personalizada</string>
<string name="pref__keyboard__height_factor_custom__label" comment="Preference title">Valor para a altura do teclado</string>
<string name="pref__keyboard__bottom_offset__label" comment="Preference title">Distância desde a margem inferior (ecrãs curvos)</string>
<string name="pref__keyboard__group_keypress__label" comment="Preference group title">Pressão de teclas</string>
<string name="pref__keyboard__sound_enabled__label" comment="Preference title">Som ao premir a tecla</string>
<string name="pref__keyboard__sound_volume__label" comment="Preference title">Volume do som ao premir a tecla</string>
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@
<string name="pref__keyboard__height_factor__extra_tall" comment="Preference value">Extra-tall</string>
<string name="pref__keyboard__height_factor__custom" comment="Preference value">Custom</string>
<string name="pref__keyboard__height_factor_custom__label" comment="Preference title">Custom keyboard height value</string>
<string name="pref__keyboard__bottom_offset__label" comment="Preference title">Bottom offset (for curved screens)</string>
<string name="pref__keyboard__bottom_offset_portrait__label" comment="Preference title">Bottom offset (portrait)</string>
<string name="pref__keyboard__bottom_offset_landscape__label" comment="Preference title">Bottom offset (landscape)</string>
<string name="pref__keyboard__group_keypress__label" comment="Preference group title">Key press</string>
<string name="pref__keyboard__sound_enabled__label" comment="Preference title">Sound on key press</string>
<string name="pref__keyboard__sound_volume__label" comment="Preference title">Sound volume on key press</string>
Expand Down
17 changes: 14 additions & 3 deletions app/src/main/res/xml/prefs_keyboard.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,22 @@
<dev.patrickgold.florisboard.settings.components.DialogSeekBarPreference
app:allowDividerAbove="false"
android:defaultValue="0"
app:key="keyboard__bottom_offset"
app:key="keyboard__bottom_offset_portrait"
app:min="0"
app:max="24"
app:max="60"
app:iconSpaceReserved="false"
app:title="@string/pref__keyboard__bottom_offset__label"
app:title="@string/pref__keyboard__bottom_offset_portrait__label"
app:seekBarIncrement="1"
app:unit=" dp"/>

<dev.patrickgold.florisboard.settings.components.DialogSeekBarPreference
app:allowDividerAbove="false"
android:defaultValue="0"
app:key="keyboard__bottom_offset_landscape"
app:min="0"
app:max="60"
app:iconSpaceReserved="false"
app:title="@string/pref__keyboard__bottom_offset_landscape__label"
app:seekBarIncrement="1"
app:unit=" dp"/>

Expand Down

0 comments on commit 3688f8e

Please sign in to comment.