Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable width #690

Merged
merged 2 commits into from
Dec 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/src/main/java/io/github/sspanak/tt9/hacks/DeviceInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ public static boolean isLandscapeOrientation(Context context) {
return context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
}

public static int getScreenWidth(Context context) {
return context.getResources().getDisplayMetrics().widthPixels;
}

public static int getScreenHeight(Context context) {
return context.getResources().getDisplayMetrics().heightPixels;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ private void createMainSection() {

ItemNumpadAlignment numpadAlignment = new ItemNumpadAlignment(findPreference(ItemNumpadAlignment.NAME), activity.getSettings());
ItemNumpadKeyHeight numpadKeyHeight = new ItemNumpadKeyHeight(findPreference(ItemNumpadKeyHeight.NAME), activity.getSettings());
ItemNumpadWidth numpadWidth = new ItemNumpadWidth(findPreference(ItemNumpadWidth.NAME), activity.getSettings());

ItemDropDown[] items = {
new ItemSelectTheme(findPreference(ItemSelectTheme.NAME), activity),
Expand All @@ -36,10 +37,13 @@ private void createMainSection() {
(layout) -> {
numpadKeyHeight.onLayoutChange(layout);
numpadAlignment.onLayoutChange(layout);
}),
numpadWidth.onLayoutChange(layout);
}
),
new ItemSelectSettingsFontSize(findPreference(ItemSelectSettingsFontSize.NAME), this),
numpadKeyHeight,
numpadAlignment
numpadAlignment,
numpadWidth
};

for (ItemDropDown item : items) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package io.github.sspanak.tt9.preferences.screens.appearance;

import androidx.preference.DropDownPreference;

import java.util.LinkedHashMap;

import io.github.sspanak.tt9.preferences.items.ItemDropDown;
import io.github.sspanak.tt9.preferences.settings.SettingsStore;

public class ItemNumpadWidth extends ItemDropDown {
public static final String NAME = "pref_numpad_width";

private final SettingsStore settings;

public ItemNumpadWidth(DropDownPreference item, SettingsStore settings) {
super(item);
this.settings = settings;
}

@Override
public ItemDropDown populate() {
LinkedHashMap<Integer, String> options = new LinkedHashMap<>();
options.put(70, "70 %");
options.put(75, "75 %");
options.put(80, "80 %");
options.put(85, "85 %");
options.put(90, "90 %");
options.put(95, "95 %");
options.put(100, "100 %");
super.populateIntegers(options);

float currentValue = 100f * settings.getNumpadWidth() / settings.getNumpadMaxWidth();
currentValue = Math.round(currentValue / 5f) * 5f;
currentValue = Math.max(Math.min(currentValue, 100f), 50f);

super.setValue((int) currentValue + "");
onLayoutChange(settings.getMainViewLayout());

return this;
}

void onLayoutChange(int mainViewLayout) {
if (item != null) {
item.setEnabled(mainViewLayout == SettingsStore.LAYOUT_NUMPAD);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ public int getNumpadKeyHeight() {
return getStringifiedInt("pref_numpad_key_height", getNumpadKeyDefaultHeight());
}

public int getNumpadMaxWidth() {
return Math.min(context.getResources().getDimensionPixelSize(R.dimen.numpad_max_width), DeviceInfo.getScreenWidth(context));
}

public int getNumpadWidth() {
return getStringifiedInt("pref_numpad_width", 100) * getNumpadMaxWidth() / 100;
}

public int getSettingsFontSize() {
int defaultSize = DeviceInfo.isQinF21() || DeviceInfo.isLgX100S() ? FONT_SIZE_LARGE : FONT_SIZE_DEFAULT;
return getStringifiedInt("pref_font_size", defaultSize);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,30 @@ int getHeight(boolean forceRecalculate) {
}


private void setWidth(int width) {
if (view == null || width <= 0) {
return;
}

View widthConstraintWrapper = view.findViewById(R.id.numpad_width_constraint_wrapper);
if (widthConstraintWrapper == null) {
return;
}

ViewGroup.LayoutParams layout = widthConstraintWrapper.getLayoutParams();
if (layout != null) {
layout.width = width;
widthConstraintWrapper.setLayoutParams(layout);
}
}


@Override
void render() {
getView();
alignView();
setKeyHeight(getKeyHeightCompat());
setWidth(tt9.getSettings().getNumpadWidth());
enableClickHandlers();
for (SoftKey key : getKeys()) {
key.render();
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/main_numpad.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
android:gravity="center_horizontal">

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/numpad_width_constraint_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxWidth="@dimen/numpad_max_width"
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/res/values-bg/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<string name="pref_backspace_recomposing_summary">Връщай списъка с предложения при натискане на Backspace на края на дума. (Не работи в някои приложения.)</string>
<string name="pref_choose_languages">Езици</string>
<string name="dictionary_truncate_title">Изтрий всички</string>
<string name="pref_numpad_width">Ширина</string>
<string name="pref_predict_word_pairs">Запомняне на двойки думи</string>
<string name="pref_predict_word_pairs_summary">Запомняй често ползвани фрази, за по-точно подсказване на думи. (Причинява минимално забавяне на устройства с &lt; 2GB RAM)</string>
<string name="pref_status_icon">Икона за състояние</string>
Expand Down Expand Up @@ -140,7 +141,7 @@
<string name="dictionary_export_generating_csv">Експортиране на CSV…</string>
<string name="dictionary_export_generating_csv_for_language">Експортиране на CSV (%1$s)…</string>
<string name="pref_layout">Екранна подредба</string>
<string name="pref_numpad_key_height">Размер на екранните клавиши</string>
<string name="pref_numpad_key_height">Височина</string>
<string name="pref_font_size">Размер на шрифта в настройките</string>
<string name="pref_font_size_default">По подразбиране</string>
<string name="key_red">Червен бутон</string>
Expand All @@ -159,7 +160,7 @@
<string name="voice_input_stopping">Изключване на микрофона…</string>
<string name="pref_haptic_feedback_summary">Вибрация при натискане на виртуален клавиш.</string>
<string name="pref_haptic_feedback">Вибрация</string>
<string name="pref_numpad_alignment">Подравняване в пейзажен режим</string>
<string name="pref_numpad_alignment">Подравняване</string>
<string name="virtual_numpad_alignment_center">В средата</string>
<string name="virtual_numpad_alignment_left">Вляво</string>
<string name="virtual_numpad_alignment_right">Вдясно</string>
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<string name="pref_backspace_recomposing">Wortnachbearbeitung</string>
<string name="pref_backspace_recomposing_summary">Die Vorschlagsliste zurückbringen, indem Sie am Ende eines Wortes die Rücktaste drücken. (Nicht in allen Apps unterstützt)</string>
<string name="pref_choose_languages">Sprachen</string>
<string name="pref_numpad_width">Breite</string>
<string name="pref_predict_word_pairs">Wortpaare lernen</string>
<string name="pref_predict_word_pairs_summary">Häufig verwendete Phrasen merken, um die Genauigkeit der Vorschläge zu verbessern. (Verursacht minimale Verzögerung auf Geräten mit &lt; 2GB RAM)</string>
<string name="pref_status_icon">Statusicon</string>
Expand Down Expand Up @@ -128,7 +129,7 @@
<string name="pref_layout">Layout auf dem Bildschirm</string>
<string name="dictionary_no_notifications">Wörterbuchbenachrichtigungen</string>
<string name="dictionary_no_notifications_summary">Benachrichtigen über Wörterbuchaktualisierungen und den Ladevorgang.</string>
<string name="pref_numpad_key_height">Größe der Bildschirmtasten</string>
<string name="pref_numpad_key_height">Höhe</string>
<string name="pref_font_size">Schriftgröße der Einstellungen</string>
<string name="pref_font_size_default">Standard</string>
<string name="function_show_command_palette">Befehlsliste anzeigen</string>
Expand All @@ -147,7 +148,7 @@
<string name="voice_input_error_not_available">Spracheingabe ist nicht verfügbar</string>
<string name="voice_input_stopping">Mikrofon ausschalten…</string>
<string name="pref_haptic_feedback">Vibration</string>
<string name="pref_numpad_alignment">Ausrichtung im Querformatmodus</string>
<string name="pref_numpad_alignment">Ausrichtung</string>
<string name="virtual_numpad_alignment_center">In der Mitte</string>
<string name="virtual_numpad_alignment_left">Links</string>
<string name="virtual_numpad_alignment_right">Rechts</string>
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
<string name="dictionary_truncate_title">Borrar todos</string>
<string name="dictionary_truncate_unselected">Borrar no seleccionados</string>
<string name="dictionary_truncated">Diccionario eliminado con éxito.</string>
<string name="pref_numpad_width">Anchura</string>
<string name="pref_predict_word_pairs">Aprender pares de palabras</string>
<string name="pref_predict_word_pairs_summary">Recordar frases de uso común para mejorar las sugerencias de palabras. (Causa retraso mínimo en dispositivos con &lt; 2 GB de RAM)</string>
<string name="pref_status_icon">Icono de estado</string>
Expand Down Expand Up @@ -140,7 +141,7 @@
<string name="dictionary_export_generating_csv">Exportando CSV…</string>
<string name="dictionary_export_generating_csv_for_language">Exportando CSV (%1$s)…</string>
<string name="pref_layout">Distribución del teclado en pantalla</string>
<string name="pref_numpad_key_height">Tamaño de las teclas en pantalla</string>
<string name="pref_numpad_key_height">Altura</string>
<string name="pref_font_size">Tamaño de fuente de configuración</string>
<string name="pref_font_size_default">Predeterminado</string>
<string name="key_red">Botón rojo</string>
Expand All @@ -158,7 +159,7 @@
<string name="voice_input_error_not_available">La entrada de voz no está disponible</string>
<string name="voice_input_stopping">Apagando el micrófono…</string>
<string name="pref_haptic_feedback">Vibración</string>
<string name="pref_numpad_alignment">Alineación en modo paisaje</string>
<string name="pref_numpad_alignment">Alineación</string>
<string name="virtual_numpad_alignment_center">En el centro</string>
<string name="virtual_numpad_alignment_left">A la izquierda</string>
<string name="virtual_numpad_alignment_right">A la derecha</string>
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<string name="pref_backspace_recomposing_summary">Ramener la liste de suggestions en appuyant sur Retour arrière à la fin d\'un mot. (Non pris en charge dans certaines applications)</string>
<string name="pref_choose_languages">Langues</string>
<string name="dictionary_truncate_title">Supprimer tous</string>
<string name="pref_numpad_width">Largeur</string>
<string name="pref_predict_word_pairs">Mémoriser les paires de mots</string>
<string name="pref_predict_word_pairs_summary">Apprendre des phrases couramment utilisées pour améliorer les suggestions. (Cause un léger ralentissement sur les appareils avec &lt; 2GB de RAM)</string>
<string name="pref_status_icon">Icône d\'état</string>
Expand Down Expand Up @@ -138,7 +139,7 @@
<string name="dictionary_export_generating_csv">Exportation CSV en cours…</string>
<string name="dictionary_export_generating_csv_for_language">Exportation CSV en cours (%1$s)…</string>
<string name="pref_layout">Disposition à l\'écran</string>
<string name="pref_numpad_key_height">Taille des touches à l\'écran</string>
<string name="pref_numpad_key_height">Hauteur</string>
<string name="pref_font_size">Taille de la police des paramètres</string>
<string name="pref_font_size_default">Par défaut</string>
<string name="key_red">Bouton rouge</string>
Expand All @@ -156,7 +157,7 @@
<string name="voice_input_error_not_available">La saisie vocale n\'est pas disponible</string>
<string name="voice_input_stopping">Désactivation du microphone…</string>
<string name="pref_haptic_feedback">Vibration</string>
<string name="pref_numpad_alignment">Alignement en mode paysage</string>
<string name="pref_numpad_alignment">Alignement</string>
<string name="virtual_numpad_alignment_center">Au milieu</string>
<string name="virtual_numpad_alignment_left">À gauche</string>
<string name="virtual_numpad_alignment_right">À droite</string>
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<string name="pref_backspace_recomposing_summary">Riportare l\'elenco dei suggerimenti premendo Backspace alla fine di una parola. (Non supportato in alcune app)</string>
<string name="pref_choose_languages">Lingue</string>

<string name="pref_numpad_width">Larghezza</string>
<string name="pref_predict_word_pairs">Memorizzare coppie di parole</string>
<string name="pref_predict_word_pairs_summary">Ricordare frasi comunemente usate per migliorare i suggerimenti di parole. (Provoca un leggero ritardo su dispositivi con &lt; 2GB di RAM)</string>
<string name="pref_status_icon">Icona di stato</string>
Expand Down Expand Up @@ -129,7 +130,7 @@
<string name="pref_layout">Layout sullo schermo</string>
<string name="dictionary_no_notifications">Notifiche del dizionario</string>
<string name="dictionary_no_notifications_summary">Ricevere notifiche sugli aggiornamenti del dizionario e sul progresso del caricamento.</string>
<string name="pref_numpad_key_height">Dimensione dei tasti sullo schermo</string>
<string name="pref_numpad_key_height">Altezza</string>
<string name="pref_font_size">Dimensione del carattere delle impostazioni</string>
<string name="pref_font_size_default">Predefinita</string>
<string name="function_show_command_palette">Mostra elenco comandi</string>
Expand All @@ -148,7 +149,7 @@
<string name="voice_input_error_not_available">L\'input vocale non è disponibile</string>
<string name="voice_input_stopping">Spegnimento del microfono…</string>
<string name="pref_haptic_feedback">Vibrazione</string>
<string name="pref_numpad_alignment">Allineamento in modalità orizzontale</string>
<string name="pref_numpad_alignment">Allineamento</string>
<string name="virtual_numpad_alignment_center">Al centro</string>
<string name="virtual_numpad_alignment_left">A sinistra</string>
<string name="virtual_numpad_alignment_right">A destra</string>
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/res/values-iw/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
<string name="pref_haptic_feedback_summary">לרטוט בעת לחיצה על מקש וירטואלי.</string>
<string name="pref_help">עזרה</string>

<string name="pref_numpad_width">רוחב</string>
<string name="pref_predict_word_pairs">ללמוד צמדי מילים</string>
<string name="pref_predict_word_pairs_summary">לזכור ביטויים נפוצים כדי לשפר את דיוק ההצעות. (גורם לפיגור מינימלי במכשירים עם פחות מ-2GB RAM)</string>
<string name="pref_status_icon">סמל מצב</string>
Expand Down Expand Up @@ -141,7 +142,7 @@
<string name="pref_layout">תצורת המקלדת על המסך</string>
<string name="dictionary_no_notifications">התראות מילון</string>
<string name="dictionary_no_notifications_summary">לקבל התראות על עדכוני המילון ועל התקדמות הטעינה.</string>
<string name="pref_numpad_key_height">גודל המקשים על המסך</string>
<string name="pref_numpad_key_height">גובה</string>
<string name="pref_font_size">גודל הגופן בהגדרות</string>
<string name="pref_font_size_default">ברירת מחדל</string>
<string name="function_show_command_palette">הצג רשימת פקודות</string>
Expand All @@ -160,7 +161,7 @@
<string name="voice_input_error_not_available">קלט קולי אינו זמין</string>
<string name="voice_input_stopping">מכבה את המיקרופון…</string>
<string name="pref_haptic_feedback">רטט</string>
<string name="pref_numpad_alignment">יישור במצב נוף</string>
<string name="pref_numpad_alignment">יישור</string>
<string name="virtual_numpad_alignment_center">באמצע</string>
<string name="virtual_numpad_alignment_left">שמאלה</string>
<string name="virtual_numpad_alignment_right">ימינה</string>
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/res/values-lt/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
<string name="pref_upside_down_keys">Atvirkštinė klavišų tvarka</string>
<string name="pref_upside_down_keys_summary">Įjunkite šį nustatymą jei pirmoje eilutėje turite 7–8–9, o ne 1–2–3.</string>

<string name="pref_numpad_width">Plotis</string>
<string name="pref_predict_word_pairs">Išmokti žodžių poras</string>
<string name="pref_predict_word_pairs_summary">Įsiminti dažnai naudojamas frazes, kad pagerintumėte žodžių pasiūlymus. (Sukelia minimalų vėlavimą įrenginiuose, kuriuose yra &lt; 2 GB RAM)</string>
<string name="pref_status_icon">Būsenos piktograma</string>
Expand Down Expand Up @@ -149,7 +150,7 @@
<string name="donate_title">Paaukoti</string>
<string name="donate_summary">Jei jums patinka %1$s, galite pavaišinti mane alumi čia: %2$s.</string>
<string name="pref_layout">Klaviatūros išdėstymas ekrane</string>
<string name="pref_numpad_key_height">Ekrano klavišų dydis</string>
<string name="pref_numpad_key_height">Aukštis</string>
<string name="pref_font_size">Nustatymų šrifto dydis</string>
<string name="pref_font_size_default">Numatytasis</string>
<string name="key_red">Raudonas mygtukas</string>
Expand All @@ -167,7 +168,7 @@
<string name="voice_input_error_not_available">Balso įvestis nėra prieinama</string>
<string name="voice_input_stopping">Išjungiamas mikrofonas…</string>
<string name="pref_haptic_feedback">Vibracija</string>
<string name="pref_numpad_alignment">Lygiavimas gulsčiuoju režimu</string>
<string name="pref_numpad_alignment">Lygiavimas</string>
<string name="virtual_numpad_alignment_center">Centre</string>
<string name="virtual_numpad_alignment_left">Kairėje</string>
<string name="virtual_numpad_alignment_right">Dešinėje</string>
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/res/values-nl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
<string name="pref_backspace_recomposing">Woordherbewerking</string>
<string name="pref_backspace_recomposing_summary">Breng de suggestielijst terug door Backspace te drukken aan het einde van een woord. (Niet ondersteund in sommige apps)</string>
<string name="pref_choose_languages">Talen</string>
<string name="pref_numpad_width">Breedte</string>
<string name="pref_predict_word_pairs">Woordenparen leren</string>
<string name="pref_predict_word_pairs_summary">Veelgebruikte zinnen onthouden om de nauwkeurigheid van suggesties te verbeteren. (Veroorzaakt minimale vertraging op apparaten met &lt; 2GB RAM)</string>
<string name="pref_status_icon">Statusicoon</string>
Expand Down Expand Up @@ -127,7 +128,7 @@
<string name="pref_layout">Indeling op het scherm</string>
<string name="dictionary_no_notifications">Woordenboekmeldingen</string>
<string name="dictionary_no_notifications_summary">Ontvang meldingen over woordenboekupdates en de voortgang van het laden.</string>
<string name="pref_numpad_key_height">Grootte van de schermtoetsen</string>
<string name="pref_numpad_key_height">Hoogte</string>
<string name="pref_font_size">Instellingen lettergrootte</string>
<string name="pref_font_size_default">Standaard</string>
<string name="function_show_command_palette">Toon opdrachtenlijst</string>
Expand All @@ -146,7 +147,7 @@
<string name="voice_input_error_not_available">Spraakopvoer is niet beschikbaar</string>
<string name="voice_input_stopping">Microfoon uitschakelen…</string>
<string name="pref_haptic_feedback">Trilling</string>
<string name="pref_numpad_alignment">Uitlijning in landschapsmodus</string>
<string name="pref_numpad_alignment">Uitlijning</string>
<string name="virtual_numpad_alignment_center">In het midden</string>
<string name="virtual_numpad_alignment_left">Links</string>
<string name="virtual_numpad_alignment_right">Rechts</string>
Expand Down
Loading
Loading