1
0
Fork 0

added an automatic newline capitalization setting

This commit is contained in:
sspanak 2024-04-05 17:11:26 +03:00 committed by Dimo Karaivanov
parent ca6b0badc9
commit 93f6e6003c
15 changed files with 54 additions and 5 deletions

View file

@ -41,7 +41,7 @@ public class AutoTextCase {
* For example, this function will return CASE_LOWER by default, but CASE_UPPER at the beginning
* of a sentence.
*/
public int determineNextWordTextCase(int currentTextCase, int textFieldTextCase, String textBeforeCursor) {
public int determineNextWordTextCase(int currentTextCase, int textFieldTextCase, String beforeCursor) {
if (
// When the setting is off, don't do any changes.
!settings.getAutoTextCase()
@ -57,17 +57,23 @@ public class AutoTextCase {
}
// start of text
if (textBeforeCursor != null && textBeforeCursor.isEmpty()) {
if (
beforeCursor != null
&& (
beforeCursor.isEmpty()
|| (settings.getAutoCapitalsAfterNewline() && beforeCursor.endsWith("\n"))
)
) {
return InputMode.CASE_CAPITALIZE;
}
// start of sentence, excluding after "..."
if (Text.isStartOfSentence(textBeforeCursor)) {
if (Text.isStartOfSentence(beforeCursor)) {
return InputMode.CASE_CAPITALIZE;
}
// this is mostly for English "I"
if (Text.isNextToWord(textBeforeCursor)) {
if (Text.isNextToWord(beforeCursor)) {
return InputMode.CASE_LOWER;
}

View file

@ -11,6 +11,10 @@ class SettingsTyping extends SettingsInput {
}
public boolean getAutoSpace() { return prefs.getBoolean("auto_space", true); }
public boolean getAutoTextCase() { return prefs.getBoolean("auto_text_case", true); }
public boolean getAutoCapitalsAfterNewline() {
return getAutoTextCase() && prefs.getBoolean("auto_capitals_after_newline", false);
}
public String getDoubleZeroChar() {
String character = prefs.getString("pref_double_zero_char", ".");

View file

@ -19,6 +19,8 @@
<string name="pref_layout_tray">Само списък с думи</string>
<string name="pref_help">Помощ</string>
<string name="pref_dark_theme">Тъмен облик</string>
<string name="pref_auto_capitals_after_newline">Автоматични главни букви на всеки ред</string>
<string name="pref_auto_capitals_after_newline_summary">Започвай всеки ред с главна буква, дори и да е в средата на изречение.</string>
<string name="pref_choose_languages">Езици</string>
<string name="dictionary_truncate_title">Изтрий всички</string>
<string name="pref_status_icon">Икона за режима на писане</string>

View file

@ -27,6 +27,10 @@
<string name="pref_abc_auto_accept_fast">Schnell</string>
<string name="pref_abc_auto_accept_normal">Mäßig</string>
<string name="pref_abc_auto_accept_slow">Langsam</string>
<string name="pref_auto_text_case">Automatische Großbuchstaben</string>
<string name="pref_auto_text_case_summary">Automatisch Sätze mit einem Großbuchstaben beginnen.</string>
<string name="pref_auto_capitals_after_newline">Automatische Großbuchstaben auf jeder Zeile</string>
<string name="pref_auto_capitals_after_newline_summary">Jede Zeile mit einem Großbuchstaben beginnen, auch wenn es mitten im Satz ist.</string>
<string name="pref_choose_languages">Sprachen</string>
<string name="pref_status_icon">Icon für den Schreibmodus</string>

View file

@ -26,6 +26,8 @@
<string name="pref_category_function_keys">Teclas de acceso rápido</string>
<string name="pref_category_predictive_mode">Texto predictivo</string>
<string name="pref_category_keypad">Teclado</string>
<string name="pref_auto_capitals_after_newline">Mayúsculas automáticas en cada línea</string>
<string name="pref_auto_capitals_after_newline_summary">Comenzar cada línea con una letra mayúscula, incluso si está en medio de una oración.</string>
<string name="pref_choose_languages">Idiomas</string>
<string name="pref_dark_theme">Tema oscuro</string>
<string name="char_space">Espacio</string>

View file

@ -19,6 +19,8 @@
<string name="pref_layout_tray">Seulement liste de mots</string>
<string name="pref_help">Aide</string>
<string name="pref_dark_theme">Thème sombre</string>
<string name="pref_auto_capitals_after_newline">Majuscules automatiques sur chaque ligne</string>
<string name="pref_auto_capitals_after_newline_summary">Commencer chaque ligne avec une majuscule, même si elle est au milieu d\'une phrase.</string>
<string name="pref_choose_languages">Langues</string>
<string name="dictionary_truncate_title">Supprimer tous</string>
<string name="pref_status_icon">Icône du mode de saisie</string>

View file

@ -28,6 +28,10 @@
<string name="pref_abc_auto_accept_fast">Veloce</string>
<string name="pref_abc_auto_accept_normal">Moderata</string>
<string name="pref_abc_auto_accept_slow">Lenta</string>
<string name="pref_auto_text_case">Maiuscole automatiche</string>
<string name="pref_auto_text_case_summary">Iniziare automaticamente le frasi con una lettera maiuscola.</string>
<string name="pref_auto_capitals_after_newline">Maiuscole automatiche su ogni riga</string>
<string name="pref_auto_capitals_after_newline_summary">Iniziare ogni riga con una lettera maiuscola, anche se è nel mezzo di una frase.</string>
<string name="pref_choose_languages">Lingue</string>
<string name="pref_status_icon">Icona modalità di digitazione</string>

View file

@ -35,6 +35,8 @@
<string name="pref_auto_space_summary">הוסף רווח אוטומטית לאחר סימני פיסוק או מילים.</string>
<string name="pref_auto_text_case">שימוש אוטומטי באותיות רישיות</string>
<string name="pref_auto_text_case_summary">התחל אוטומטית משפטים באות גדולה.</string>
<string name="pref_auto_capitals_after_newline">רישיות אוטומטיות בכל שורה</string>
<string name="pref_auto_capitals_after_newline_summary">להתחיל כל שורה באות ראשונה גדולה, גם אם היא באמצע משפט.</string>
<string name="pref_choose_languages">שפות</string>
<string name="pref_dark_theme">ערכת נושא שחורה</string>
<string name="pref_double_zero_char">תו ללחיצה מרובה על מקש 0</string>

View file

@ -38,6 +38,8 @@
<string name="pref_auto_space_summary">Po žodžių ir skyrybos ženklų automatiškai pridėti tarpą.</string>
<string name="pref_auto_text_case">Automatinis didžiųjų raidžių rašymas</string>
<string name="pref_auto_text_case_summary">Automatiškai pradėti sakinius didžiąja raide.</string>
<string name="pref_auto_capitals_after_newline">Automatiniai didžiosios raidės kiekvienoje eilutėje</string>
<string name="pref_auto_capitals_after_newline_summary">Pradėti kiekvieną eilutę didžiąja raide, net jei ji yra sakinio viduryje.</string>
<string name="pref_choose_languages">Kalbos</string>
<string name="pref_dark_theme">Tamsi išvaizda</string>
<string name="pref_dark_theme_yes">Taip</string>

View file

@ -26,6 +26,10 @@
<string name="pref_abc_auto_accept_fast">Snel</string>
<string name="pref_abc_auto_accept_normal">Gematigd</string>
<string name="pref_abc_auto_accept_slow">Langzaam</string>
<string name="pref_auto_text_case">Automatische hoofdletters</string>
<string name="pref_auto_text_case_summary">Automatisch zinnen beginnen met een hoofdletter.</string>
<string name="pref_auto_capitals_after_newline">Automatische hoofdletters op elke regel</string>
<string name="pref_auto_capitals_after_newline_summary">Elke regel beginnen met een hoofdletter, zelfs als het midden van een zin is.</string>
<string name="pref_choose_languages">Talen</string>
<string name="pref_status_icon">Typemodus-icoon</string>
<string name="pref_status_icon_summary">Geef de huidige typmodus aan met een icoon.</string>

View file

@ -35,7 +35,9 @@
<string name="pref_auto_space">Espaçamento Automático</string>
<string name="pref_auto_space_summary">Insere um espaçamento após ponto final.</string>
<string name="pref_auto_text_case">Maiúsculas Automáticas</string>
<string name="pref_auto_text_case_summary">Inicia automaticamente com letras maiúsculas.</string>
<string name="pref_auto_text_case_summary">Iniciar automaticamente as frases com letras maiúsculas.</string>
<string name="pref_auto_capitals_after_newline">etras maiúsculas automáticas em cada linha</string>
<string name="pref_auto_capitals_after_newline_summary">Começar cada linha com uma letra maiúscula, mesmo que esteja no meio de uma frase.</string>
<string name="pref_choose_languages">Idiomas</string>
<string name="pref_dark_theme">Modo Escuro</string>
<string name="pref_double_zero_char">Caractere para toque duplo na tecla 0</string>

View file

@ -19,6 +19,8 @@
<string name="pref_layout_tray">Только список слов</string>
<string name="pref_help">Помощь</string>
<string name="pref_dark_theme">Темная тема</string>
<string name="pref_auto_capitals_after_newline">Автоматические заглавные буквы на каждой строке</string>
<string name="pref_auto_capitals_after_newline_summary">Начинать каждую строку с заглавной буквы, даже если она в середине предложения.</string>
<string name="pref_choose_languages">Языки</string>
<string name="dictionary_truncate_title">Удалить все</string>
<string name="pref_status_icon">Иконка режима ввода</string>

View file

@ -40,6 +40,8 @@
<string name="pref_auto_space_summary">Автоматично додавати пробіл після розділових знаків або слів.</string>
<string name="pref_auto_text_case">Автоматична велика літера</string>
<string name="pref_auto_text_case_summary">Автоматично починати речення з великої букви</string>
<string name="pref_auto_capitals_after_newline">Автоматичні великі літери на кожному рядку</string>
<string name="pref_auto_capitals_after_newline_summary">Починати кожен рядок з великої літери, навіть якщо він у середині речення.</string>
<string name="pref_choose_languages">Мови</string>
<string name="pref_dark_theme">Темна тема</string>
<string name="pref_dark_theme_yes">Так</string>

View file

@ -46,6 +46,8 @@
<string name="pref_auto_space_summary">Automatically add a space after punctuation or words.</string>
<string name="pref_auto_text_case">Automatic Capitalization</string>
<string name="pref_auto_text_case_summary">Automatically start sentences with a capital letter.</string>
<string name="pref_auto_capitals_after_newline">Automatically Capitalize Every Line</string>
<string name="pref_auto_capitals_after_newline_summary">Start every line with a capital letter, even it is in the middle of a sentence.</string>
<string name="pref_choose_languages">Languages</string>
<string name="pref_dark_theme">Dark Theme</string>
<string name="pref_dark_theme_yes">Yes</string>

View file

@ -36,6 +36,15 @@
app:summary="@string/pref_auto_text_case_summary"
app:title="@string/pref_auto_text_case" />
<SwitchPreferenceCompat
app:defaultValue="false"
app:dependency="auto_text_case"
app:key="auto_capitals_after_newline"
app:layout="@layout/pref_switch"
app:summary="@string/pref_auto_capitals_after_newline_summary"
app:title="@string/pref_auto_capitals_after_newline" />
<DropDownPreference
app:defaultValue="."
app:iconSpaceReserved="false"