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) {
new ItemSetDefaultGlobalKeyboard(defaultKeyboardItem, activity).enableClickHandler();
}
new ItemSpellCheck(activity, findPreference("global_spellchecker")).enableClickHandler();
}
private void createHacksSection(boolean isEnabled) {

View file

@ -1,6 +1,7 @@
package io.github.sspanak.tt9.ui;
import android.app.AlertDialog;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.inputmethodservice.InputMethodService;
@ -22,6 +23,25 @@ public class UI {
((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) {
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_off">%1$s е изключен</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="dictionary_loading_indeterminate">Зареждане на речник</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_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_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_channel_down">Vorheriger 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_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_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_back">Volver</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_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_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_channel_down">Chaîne précédente</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_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_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_channel_down">Canale precedente</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_off">%1$s מושבת</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_back">חזור</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_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_back">Atgal 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_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_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_channel_down">Vorige 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_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_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_back">Voltar</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_off">%1$s отключен</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_back">Назад</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_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_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_channel_down">Önceki 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_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_back">Назад</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_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_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_none" translatable="false">--</string>

View file

@ -9,6 +9,10 @@
app:key="global_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">
<SwitchPreferenceCompat