1
0
Fork 0

added a button to disable the system spell checker

This commit is contained in:
sspanak 2024-09-22 14:02:42 +03:00 committed by Dimo Karaivanov
parent 41fd7fa51b
commit 83479e373a
18 changed files with 139 additions and 1 deletions

View file

@ -0,0 +1,67 @@
package io.github.sspanak.tt9.preferences.screens.setup;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.provider.Settings;
import android.service.textservice.SpellCheckerService;
import androidx.preference.Preference;
import io.github.sspanak.tt9.R;
import io.github.sspanak.tt9.hacks.DeviceInfo;
import io.github.sspanak.tt9.preferences.PreferencesActivity;
import io.github.sspanak.tt9.preferences.items.ItemClickable;
import io.github.sspanak.tt9.ui.UI;
public class ItemSpellCheck extends ItemClickable {
public ItemSpellCheck(PreferencesActivity activity, Preference item) {
super(item);
if (DeviceInfo.noTouchScreen(activity)) {
disable();
item.setVisible(false);
} else if (isSpellCheckEnabled(activity)) {
enable();
} else {
disable();
}
}
private boolean isSpellCheckEnabled(PreferencesActivity activity) {
if (activity == null) {
return false;
}
Intent spellCheckIntent = new Intent(SpellCheckerService.SERVICE_INTERFACE);
return activity.getPackageManager().resolveService(spellCheckIntent, 0) != null;
}
@Override
public void enable() {
if (item != null) {
super.enable();
enableClickHandler();
item.setSummary(R.string.setup_spell_checker_on);
}
}
@Override
public void disable() {
if (item != null) {
super.disable();
item.setSummary(R.string.setup_spell_checker_off);
}
}
@Override
public void enableClickHandler() {
if (item != null && item.isEnabled()) {
super.enableClickHandler();
}
}
@Override
protected boolean onClick(Preference p) {
return UI.showSystemSpellCheckerSettings(p.getContext());
}
}

View file

@ -45,6 +45,8 @@ public class SetupScreen extends BaseScreenFragment {
if (defaultKeyboardItem != null) { if (defaultKeyboardItem != null) {
new ItemSetDefaultGlobalKeyboard(defaultKeyboardItem, activity).enableClickHandler(); new ItemSetDefaultGlobalKeyboard(defaultKeyboardItem, activity).enableClickHandler();
} }
new ItemSpellCheck(activity, findPreference("global_spellchecker")).enableClickHandler();
} }
private void createHacksSection(boolean isEnabled) { private void createHacksSection(boolean isEnabled) {

View file

@ -1,6 +1,7 @@
package io.github.sspanak.tt9.ui; package io.github.sspanak.tt9.ui;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.inputmethodservice.InputMethodService; import android.inputmethodservice.InputMethodService;
@ -22,6 +23,25 @@ public class UI {
((InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE)).showInputMethodPicker(); ((InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE)).showInputMethodPicker();
} }
public static boolean showSystemSpellCheckerSettings(Context context) {
ComponentName component = new ComponentName(
"com.android.settings",
"com.android.settings.Settings$SpellCheckersSettingsActivity"
);
Intent intent = new Intent();
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setComponent(component);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
try {
context.startActivity(intent);
return true;
} catch (Exception e) {
return false;
}
}
public static void showSettingsScreen(InputMethodService ims) { public static void showSettingsScreen(InputMethodService ims) {
Intent prefIntent = new Intent(ims, PreferencesActivity.class); Intent prefIntent = new Intent(ims, PreferencesActivity.class);

View file

@ -96,6 +96,9 @@
<string name="setup_tt9_on">%1$s е активен</string> <string name="setup_tt9_on">%1$s е активен</string>
<string name="setup_tt9_off">%1$s е изключен</string> <string name="setup_tt9_off">%1$s е изключен</string>
<string name="setup_click_here_to_enable">Натиснете тук, за да включите TT9 от настройките на Андроид.</string> <string name="setup_click_here_to_enable">Натиснете тук, за да включите TT9 от настройките на Андроид.</string>
<string name="setup_spell_checker">Системна проверка на правописа</string>
<string name="setup_spell_checker_on">Системната проверка на правописа може да попречи на добавянето на думи. Натиснете тук, за да я изключите.</string>
<string name="setup_spell_checker_off">Изключена</string>
<string name="key_hold_key">(задръж)</string> <string name="key_hold_key">(задръж)</string>
<string name="dictionary_loading_indeterminate">Зареждане на речник</string> <string name="dictionary_loading_indeterminate">Зареждане на речник</string>
<string name="dictionary_load_no_internet">Неуспешно изтегляне на речника за език „%1$s“. Проверете връзката с интернет.</string> <string name="dictionary_load_no_internet">Неуспешно изтегляне на речника за език „%1$s“. Проверете връзката с интернет.</string>

View file

@ -73,6 +73,9 @@
<string name="setup_tt9_on">%1$s ist aktiviert</string> <string name="setup_tt9_on">%1$s ist aktiviert</string>
<string name="setup_tt9_off">%1$s ist deaktiviert</string> <string name="setup_tt9_off">%1$s ist deaktiviert</string>
<string name="setup_click_here_to_enable">Klicken Sie hier, um TT9 in den Android-Einstellungen zu aktivieren.</string> <string name="setup_click_here_to_enable">Klicken Sie hier, um TT9 in den Android-Einstellungen zu aktivieren.</string>
<string name="setup_spell_checker">Systemrechtschreibprüfung</string>
<string name="setup_spell_checker_on">Die Systemrechtschreibprüfung kann das Hinzufügen von Wörtern beeinträchtigen. Klicken Sie hier, um sie zu deaktivieren.</string>
<string name="setup_spell_checker_off">Deaktiviert</string>
<string name="key_back">Zurück</string> <string name="key_back">Zurück</string>
<string name="key_channel_down">Vorheriger Kanal</string> <string name="key_channel_down">Vorheriger Kanal</string>
<string name="key_channel_up">Nächster Kanal</string> <string name="key_channel_up">Nächster Kanal</string>

View file

@ -93,6 +93,9 @@
<string name="setup_tt9_on">%1$s está habilitado</string> <string name="setup_tt9_on">%1$s está habilitado</string>
<string name="setup_tt9_off">%1$s está deshabilitado</string> <string name="setup_tt9_off">%1$s está deshabilitado</string>
<string name="setup_click_here_to_enable">Pulse aquí para habilitar TT9 en la configuración de Android</string> <string name="setup_click_here_to_enable">Pulse aquí para habilitar TT9 en la configuración de Android</string>
<string name="setup_spell_checker">Corrector ortográfico del sistema</string>
<string name="setup_spell_checker_on">El corrector ortográfico del sistema puede interferir con la adición de palabras. Haga clic aquí para desactivarlo.</string>
<string name="setup_spell_checker_off">Desactivado</string>
<string name="key_hold_key">(еspera)</string> <string name="key_hold_key">(еspera)</string>
<string name="key_back">Volver</string> <string name="key_back">Volver</string>
<string name="key_call">Llamar</string> <string name="key_call">Llamar</string>

View file

@ -89,6 +89,9 @@
<string name="setup_tt9_on">%1$s est activé</string> <string name="setup_tt9_on">%1$s est activé</string>
<string name="setup_tt9_off">%1$s est désactivé</string> <string name="setup_tt9_off">%1$s est désactivé</string>
<string name="setup_click_here_to_enable">Cliquez ici pour activer TT9 dans les paramètres Android.</string> <string name="setup_click_here_to_enable">Cliquez ici pour activer TT9 dans les paramètres Android.</string>
<string name="setup_spell_checker">Correcteur orthographique du système</string>
<string name="setup_spell_checker_on">Le correcteur orthographique du système peut interférer avec l\'ajout de mots. Cliquez ici pour le désactiver.</string>
<string name="setup_spell_checker_off">Désactivé</string>
<string name="key_back">Retour</string> <string name="key_back">Retour</string>
<string name="key_channel_down">Chaîne précédente</string> <string name="key_channel_down">Chaîne précédente</string>
<string name="key_channel_up">Chaîne suivante</string> <string name="key_channel_up">Chaîne suivante</string>

View file

@ -74,6 +74,9 @@
<string name="setup_tt9_on">%1$s è abilitato</string> <string name="setup_tt9_on">%1$s è abilitato</string>
<string name="setup_tt9_off">%1$s è disabilitato</string> <string name="setup_tt9_off">%1$s è disabilitato</string>
<string name="setup_click_here_to_enable">Clicca qui per abilitare TT9 dalle impostazioni di Android.</string> <string name="setup_click_here_to_enable">Clicca qui per abilitare TT9 dalle impostazioni di Android.</string>
<string name="setup_spell_checker">Controllo ortografico di sistema</string>
<string name="setup_spell_checker_on">Il controllo ortografico di sistema può interferire con l\'aggiunta di parole. Clicca qui per disabilitarlo.</string>
<string name="setup_spell_checker_off">Disabilitato</string>
<string name="key_back">Indietro</string> <string name="key_back">Indietro</string>
<string name="key_channel_down">Canale precedente</string> <string name="key_channel_down">Canale precedente</string>
<string name="key_channel_up">Prossimo canale</string> <string name="key_channel_up">Prossimo canale</string>

View file

@ -89,6 +89,9 @@
<string name="setup_tt9_on">%1$s מופעל</string> <string name="setup_tt9_on">%1$s מופעל</string>
<string name="setup_tt9_off">%1$s מושבת</string> <string name="setup_tt9_off">%1$s מושבת</string>
<string name="setup_click_here_to_enable">לחץ כאן כדי להפעיל את TT9 מהגדרות Android.</string> <string name="setup_click_here_to_enable">לחץ כאן כדי להפעיל את TT9 מהגדרות Android.</string>
<string name="setup_spell_checker">בודק איות מערכת</string>
<string name="setup_spell_checker_on">בודק האיות של המערכת עלול להפריע להוספת מילים. לחץ כאן כדי להשבית.</string>
<string name="setup_spell_checker_off">מנוטרל</string>
<string name="key_hold_key">(החזק)</string> <string name="key_hold_key">(החזק)</string>
<string name="key_back">חזור</string> <string name="key_back">חזור</string>
<string name="key_call">חיוג</string> <string name="key_call">חיוג</string>

View file

@ -100,6 +100,9 @@
<string name="setup_tt9_off">„%1$s“ yra išjungtas</string> <string name="setup_tt9_off">„%1$s“ yra išjungtas</string>
<string name="setup_click_here_to_enable">Spauskite čia norėdami įjungti „TT9“ per „Android“ nustatymus.</string> <string name="setup_click_here_to_enable">Spauskite čia norėdami įjungti „TT9“ per „Android“ nustatymus.</string>
<string name="setup_spell_checker">Sistemos rašybos tikrintuvas</string>
<string name="setup_spell_checker_on">Sistemos rašybos tikrintuvas gali trukdyti pridėti žodžius. Spustelėkite čia, kad išjungtumėte.</string>
<string name="setup_spell_checker_off">Išjungtas</string>
<string name="key_hold_key">(laikyti nusp.)</string> <string name="key_hold_key">(laikyti nusp.)</string>
<string name="key_back">Atgal mygtukas</string> <string name="key_back">Atgal mygtukas</string>
<string name="key_call">Skambinti mygtukas</string> <string name="key_call">Skambinti mygtukas</string>

View file

@ -75,6 +75,9 @@
<string name="setup_tt9_on">%1$s is ingeschakeld</string> <string name="setup_tt9_on">%1$s is ingeschakeld</string>
<string name="setup_tt9_off">%1$s is uitgeschakeld</string> <string name="setup_tt9_off">%1$s is uitgeschakeld</string>
<string name="setup_click_here_to_enable">Klik hier om TT9 in te schakelen vanuit de Android-instellingen.</string> <string name="setup_click_here_to_enable">Klik hier om TT9 in te schakelen vanuit de Android-instellingen.</string>
<string name="setup_spell_checker">Systeemspellingscontrole</string>
<string name="setup_spell_checker_on">De systeemspellingscontrole kan het toevoegen van woorden verstoren. Klik hier om uit te schakelen.</string>
<string name="setup_spell_checker_off">Uitgeschakeld</string>
<string name="key_back">Terug</string> <string name="key_back">Terug</string>
<string name="key_channel_down">Vorige kanaal</string> <string name="key_channel_down">Vorige kanaal</string>
<string name="key_channel_up">Volgende kanaal</string> <string name="key_channel_up">Volgende kanaal</string>

View file

@ -86,6 +86,9 @@
<string name="setup_tt9_on">%1$s está ativado</string> <string name="setup_tt9_on">%1$s está ativado</string>
<string name="setup_tt9_off">%1$s está desativado</string> <string name="setup_tt9_off">%1$s está desativado</string>
<string name="setup_click_here_to_enable">Clique aqui para ativar TT9 nas configurações do Android.</string> <string name="setup_click_here_to_enable">Clique aqui para ativar TT9 nas configurações do Android.</string>
<string name="setup_spell_checker">Verificador ortográfico do sistema</string>
<string name="setup_spell_checker_on">O verificador ortográfico do sistema pode interferir na adição de palavras. Clique aqui para desativá-lo.</string>
<string name="setup_spell_checker_off">Desativado</string>
<string name="key_hold_key">(segurar)</string> <string name="key_hold_key">(segurar)</string>
<string name="key_back">Voltar</string> <string name="key_back">Voltar</string>
<string name="key_call">Chamada</string> <string name="key_call">Chamada</string>

View file

@ -88,6 +88,9 @@
<string name="setup_tt9_on">%1$s активен</string> <string name="setup_tt9_on">%1$s активен</string>
<string name="setup_tt9_off">%1$s отключен</string> <string name="setup_tt9_off">%1$s отключен</string>
<string name="setup_click_here_to_enable">Нажмите здесь, чтобы включить TT9 в настройках Android.</string> <string name="setup_click_here_to_enable">Нажмите здесь, чтобы включить TT9 в настройках Android.</string>
<string name="setup_spell_checker">Системная проверка орфографии</string>
<string name="setup_spell_checker_on">Системная проверка орфографии может мешать добавлению слов. Нажмите здесь, чтобы отключить.</string>
<string name="setup_spell_checker_off">Отключена</string>
<string name="key_hold_key">(зажать)</string> <string name="key_hold_key">(зажать)</string>
<string name="key_back">Назад</string> <string name="key_back">Назад</string>
<string name="key_call">Позвонить</string> <string name="key_call">Позвонить</string>

View file

@ -72,6 +72,9 @@
<string name="setup_tt9_on">%1$s devrede</string> <string name="setup_tt9_on">%1$s devrede</string>
<string name="setup_tt9_off">%1$s devre dışı</string> <string name="setup_tt9_off">%1$s devre dışı</string>
<string name="setup_click_here_to_enable">Android ayarlarında TT9 uygulamasını etkinleştirmek için burayı tıklayın.</string> <string name="setup_click_here_to_enable">Android ayarlarında TT9 uygulamasını etkinleştirmek için burayı tıklayın.</string>
<string name="setup_spell_checker">Sistem Yazım Denetleyicisi</string>
<string name="setup_spell_checker_on">Sistem yazım denetleyicisi kelime eklemeye müdahale edebilir. Devre dışı bırakmak için buraya tıklayın.</string>
<string name="setup_spell_checker_off">Devre dışı</string>
<string name="key_back">Geri</string> <string name="key_back">Geri</string>
<string name="key_channel_down">Önceki Seçim</string> <string name="key_channel_down">Önceki Seçim</string>
<string name="key_channel_up">Sonraki Seçim</string> <string name="key_channel_up">Sonraki Seçim</string>

View file

@ -134,6 +134,9 @@
<string name="setup_tt9_off">%1$s вимкнуто</string> <string name="setup_tt9_off">%1$s вимкнуто</string>
<string name="setup_click_here_to_enable">Нажміть тут, щоб увімкнути TT9 в налаштуваннях Android.</string> <string name="setup_click_here_to_enable">Нажміть тут, щоб увімкнути TT9 в налаштуваннях Android.</string>
<string name="setup_spell_checker">Системна перевірка орфографії</string>
<string name="setup_spell_checker_on">Системна перевірка орфографії може заважати додаванню слів. Натисніть тут, щоб вимкнути.</string>
<string name="setup_spell_checker_off">Вимкнена</string>
<string name="key_hold_key">(тримати)</string> <string name="key_hold_key">(тримати)</string>
<string name="key_back">Назад</string> <string name="key_back">Назад</string>
<string name="key_call">Подзвонити</string> <string name="key_call">Подзвонити</string>

View file

@ -172,6 +172,9 @@
<string name="setup_tt9_on">%1$s is enabled</string> <string name="setup_tt9_on">%1$s is enabled</string>
<string name="setup_tt9_off">%1$s is disabled</string> <string name="setup_tt9_off">%1$s is disabled</string>
<string name="setup_click_here_to_enable">Click here to enable TT9 from Android Settings.</string> <string name="setup_click_here_to_enable">Click here to enable TT9 from Android Settings.</string>
<string name="setup_spell_checker">System Spell Checker</string>
<string name="setup_spell_checker_on">System spell checker may interfere with adding words. Click here to disable.</string>
<string name="setup_spell_checker_off">Disabled</string>
<string name="key_hold_key">(hold)</string> <string name="key_hold_key">(hold)</string>
<string name="key_none" translatable="false">--</string> <string name="key_none" translatable="false">--</string>

View file

@ -9,6 +9,10 @@
app:key="global_default_keyboard" app:key="global_default_keyboard"
app:title="@string/setup_default_keyboard" /> app:title="@string/setup_default_keyboard" />
<Preference
app:key="global_spellchecker"
app:title="@string/setup_spell_checker" />
<PreferenceCategory app:title="@string/pref_category_hacks"> <PreferenceCategory app:title="@string/pref_category_hacks">
<SwitchPreferenceCompat <SwitchPreferenceCompat

View file

@ -7,7 +7,13 @@ After installing, first, you need to enable Traditional T9 as an Android keyboar
_If you don't see the icon right after installing, restart your phone, and it should appear. It is due to Android trying to save some battery life by not refreshing the newly installed apps list._ _If you don't see the icon right after installing, restart your phone, and it should appear. It is due to Android trying to save some battery life by not refreshing the newly installed apps list._
### Using on a touchscreen-only phone ### Using on a touchscreen-only phone
If your phone does not have a hardware keypad, check out the [On-screen Keypad section](#on-screen-keypad). On touchscreen devices, it is also highly recommended to disable the system spell checker. It can not be used when typing with the number keys, so you can save some battery life by disabling it.
Another problem is, that it may show a confusing "Add Word" popup dialog, which adds words to the default system keyboard (usually, Gboard) and not to Traditional T9's dictionary. Again, to avoid such situations, the system spell checker must be disabled.
If you need to perform this step, the "System Spell Checker" item on the Initial Setup screen will be active. Click it to disable the system component. If you there is no such item, then you don't need to do anything else.
After you are done with the setup, check out the [On-screen Keypad section](#on-screen-keypad) for more tips and tricks.
### Enabling Predictive Mode ### Enabling Predictive Mode
Predictive Mode requires a language dictionary to be loaded to provide word suggestions. You can toggle the enabled languages and load their dictionaries from Settings Screen → [Languages](#language-options). In case, you have forgotten to load some dictionary, Traditional T9 will do it for you automatically when you start typing. For more information, [see below](#language-options). Predictive Mode requires a language dictionary to be loaded to provide word suggestions. You can toggle the enabled languages and load their dictionaries from Settings Screen → [Languages](#language-options). In case, you have forgotten to load some dictionary, Traditional T9 will do it for you automatically when you start typing. For more information, [see below](#language-options).