added Change Keyboard hotkey
This commit is contained in:
parent
bd675be3a2
commit
b7a0db29df
28 changed files with 101 additions and 34 deletions
|
|
@ -113,6 +113,9 @@ Select the next language, when multiple languages have been enabled from the Set
|
|||
#### Settings Key (Default: Hold ✱):
|
||||
Open the Settings configuration screen.
|
||||
|
||||
#### Change Keyboard Key (Default: _unassigned_):
|
||||
Open the Android Change Keyboard dialog where you can select between all installed keyboards.
|
||||
|
||||
## On-screen Keypad
|
||||
On touchscreen-only phones, a fully functional on-screen keypad is available. Enable it from Settings -> Appearance -> Show On-Screen Numpad.
|
||||
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@
|
|||
android:layout_height="@dimen/numpad_key_height"
|
||||
tools:ignore="HardcodedText">
|
||||
|
||||
<io.github.sspanak.tt9.ui.main.keys.SoftKey
|
||||
<io.github.sspanak.tt9.ui.main.keys.SoftKeyInputMode
|
||||
android:id="@+id/soft_key_input_mode"
|
||||
style="@android:style/Widget.Holo.Button.Borderless"
|
||||
android:layout_width="0dp"
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@
|
|||
<string name="key_call">Зелена слушалка</string>
|
||||
<string name="function_add_word_key">Добавяне на нова дума</string>
|
||||
<string name="function_backspace_key">Триене на текст</string>
|
||||
<string name="function_change_keyboard_key">Избор на клавиатура</string>
|
||||
<string name="function_filter_clear_key">Изчистване на филтър</string>
|
||||
<string name="function_filter_suggestions_key">Филтриране на думи</string>
|
||||
<string name="function_previous_suggestion_key">Предишна дума</string>
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
<string name="dictionary_loading_indeterminate">Lade Wörterbuch</string>
|
||||
<string name="pref_category_keypad">Tastenfeld</string>
|
||||
<string name="char_space">Leerzeichen</string>
|
||||
<string name="function_change_keyboard_key">Tastaturauswahl</string>
|
||||
<string name="char_newline">Neue Zeile</string>
|
||||
<string name="pref_category_setup">Ersteinrichtung</string>
|
||||
<string name="error">Fehler</string>
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@
|
|||
<string name="pref_category_setup">Configuración inicial</string>
|
||||
<string name="pref_show_soft_numpad">Teclado numérico en pantalla</string>
|
||||
<string name="error">Error</string>
|
||||
<string name="function_change_keyboard_key">Cambiar el teclado</string>
|
||||
<string name="function_filter_clear_key">Limpiar el filtro</string>
|
||||
<string name="function_filter_suggestions_key">Filtrar sugerencias</string>
|
||||
<string name="function_previous_suggestion_key">Sugerencia previa</string>
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@
|
|||
<string name="char_space">Espace</string>
|
||||
<string name="function_add_word_key">Ajouter un mot</string>
|
||||
<string name="function_backspace_key">Retour arrière</string>
|
||||
<string name="function_change_keyboard_key">Changer le clavier</string>
|
||||
<string name="function_filter_clear_key">Supprimer le filtre</string>
|
||||
<string name="function_filter_suggestions_key">Filtrer les mots</string>
|
||||
<string name="function_previous_suggestion_key">Mot précédent</string>
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
<string name="dictionary_load_cancelled">Caricamento annullato.</string>
|
||||
<string name="pref_category_keypad">Tastiera</string>
|
||||
<string name="char_space">Spazio</string>
|
||||
<string name="function_change_keyboard_key">Cambia la tastiera</string>
|
||||
<string name="setup_keyboard_status">Stato</string>
|
||||
<string name="setup_default_keyboard">Scegli Tastiera predefinita</string>
|
||||
<string name="char_newline">Nuova riga</string>
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@
|
|||
|
||||
<string name="function_add_word_key">לחצן הוספת מילה</string>
|
||||
<string name="function_backspace_key">לחצן מחיקה</string>
|
||||
<string name="function_change_keyboard_key">בחירת מקלדת</string>
|
||||
<string name="function_next_language_key">לחצן למעבר לשפה הבאה</string>
|
||||
<string name="function_next_mode_key">לחצן מצב קלט</string>
|
||||
<string name="function_show_settings_key">לחצן הצגת הגדרות</string>
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
<string name="dictionary_loading_indeterminate">Woordenboek laden</string>
|
||||
<string name="pref_category_keypad">Toetsenbord</string>
|
||||
<string name="char_space">Spatie</string>
|
||||
<string name="function_change_keyboard_key">Toetsenbordkeuze</string>
|
||||
<string name="char_newline">Nieuwe regel</string>
|
||||
<string name="pref_category_setup">Initiële setup</string>
|
||||
<string name="dictionary_truncating">Verwijderen…</string>
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@
|
|||
|
||||
<string name="function_add_word_key">Adicionar palavra</string>
|
||||
<string name="function_backspace_key">Backspace</string>
|
||||
<string name="function_change_keyboard_key">Mude o teclado</string>
|
||||
<string name="function_next_language_key">Próximo Idioma</string>
|
||||
<string name="function_next_mode_key">Modo de Entrada</string>
|
||||
<string name="function_show_settings_key">Entrar em Configurações</string>
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@
|
|||
<string name="dictionary_missing_go_load_it">Отсутствует словарь для языка «%1$s». Вы можете загрузить его в Настройках.</string>
|
||||
<string name="function_add_word_key">Добавить новое слово</string>
|
||||
<string name="function_backspace_key">Стереть</string>
|
||||
<string name="function_change_keyboard_key">Выбор клавиатуры</string>
|
||||
<string name="function_filter_clear_key">Удалить фильтр</string>
|
||||
<string name="function_filter_suggestions_key">Фильтровать слова</string>
|
||||
<string name="function_previous_suggestion_key">Предыдущее слово</string>
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@
|
|||
<string name="key_hold_key">(затиснути)</string>
|
||||
<string name="function_add_word_key">Додати нове слово</string>
|
||||
<string name="function_backspace_key">Стерти</string>
|
||||
<string name="function_change_keyboard_key">Вибір клавіатури</string>
|
||||
<string name="function_filter_clear_key">Видалити фільтр</string>
|
||||
<string name="function_filter_suggestions_key">Фільтрувати слова</string>
|
||||
<string name="function_previous_suggestion_key">Попереднє слово</string>
|
||||
|
|
|
|||
|
|
@ -73,6 +73,7 @@
|
|||
|
||||
<string name="function_add_word_key">Add Word key</string>
|
||||
<string name="function_backspace_key">Backspace key</string>
|
||||
<string name="function_change_keyboard_key">Change Keyboard key</string>
|
||||
<string name="function_filter_clear_key">Clear Filter key</string>
|
||||
<string name="function_filter_suggestions_key">Filter Suggestions key</string>
|
||||
<string name="function_previous_suggestion_key">Previous Suggestion key</string>
|
||||
|
|
|
|||
|
|
@ -50,6 +50,12 @@
|
|||
app:layout="@layout/pref_dropdown"
|
||||
app:title="@string/function_next_mode_key" />
|
||||
|
||||
<DropDownPreference
|
||||
app:iconSpaceReserved="false"
|
||||
app:key="key_change_keyboard"
|
||||
app:layout="@layout/pref_dropdown"
|
||||
app:title="@string/function_change_keyboard_key" />
|
||||
|
||||
<DropDownPreference
|
||||
app:iconSpaceReserved="false"
|
||||
app:key="key_show_settings"
|
||||
|
|
|
|||
|
|
@ -231,6 +231,10 @@ abstract class KeyPadHandler extends InputMethodService {
|
|||
return onKeyAddWord(validateOnly);
|
||||
}
|
||||
|
||||
if (keyCode == settings.getKeyChangeKeyboard() * (hold ? -1 : 1)) {
|
||||
return onKeyChangeKeyboard(validateOnly);
|
||||
}
|
||||
|
||||
if (keyCode == settings.getKeyFilterClear() * (hold ? -1 : 1)) {
|
||||
return onKeyFilterClear(validateOnly);
|
||||
}
|
||||
|
|
@ -280,6 +284,7 @@ abstract class KeyPadHandler extends InputMethodService {
|
|||
|
||||
// hotkey handlers
|
||||
abstract protected boolean onKeyAddWord(boolean validateOnly);
|
||||
abstract protected boolean onKeyChangeKeyboard(boolean validateOnly);
|
||||
abstract protected boolean onKeyFilterClear(boolean validateOnly);
|
||||
abstract protected boolean onKeyFilterSuggestions(boolean validateOnly, boolean repeat);
|
||||
abstract protected boolean onKeyNextLanguage(boolean validateOnly);
|
||||
|
|
|
|||
|
|
@ -373,6 +373,19 @@ public class TraditionalT9 extends KeyPadHandler {
|
|||
}
|
||||
|
||||
|
||||
public boolean onKeyChangeKeyboard(boolean validateOnly) {
|
||||
if (!isInputViewShown()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!validateOnly) {
|
||||
UI.showChangeKeyboardDialog(this);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public boolean onKeyFilterClear(boolean validateOnly) {
|
||||
if (isSuggestionViewHidden()) {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ public class Key {
|
|||
public static boolean isHotkey(SettingsStore settings, int keyCode) {
|
||||
return keyCode == settings.getKeyAddWord()
|
||||
|| keyCode == settings.getKeyBackspace()
|
||||
|| keyCode == settings.getKeyChangeKeyboard()
|
||||
|| keyCode == settings.getKeyFilterClear()
|
||||
|| keyCode == settings.getKeyFilterSuggestions()
|
||||
|| keyCode == settings.getKeyPreviousSuggestion()
|
||||
|
|
|
|||
|
|
@ -167,6 +167,7 @@ public class SettingsStore {
|
|||
public void setDefaultKeys(
|
||||
int addWord,
|
||||
int backspace,
|
||||
int changeKeyboard,
|
||||
int filterClear,
|
||||
int filterSuggestions,
|
||||
int previousSuggestion,
|
||||
|
|
@ -178,6 +179,7 @@ public class SettingsStore {
|
|||
prefsEditor
|
||||
.putString(SectionKeymap.ITEM_ADD_WORD, String.valueOf(addWord))
|
||||
.putString(SectionKeymap.ITEM_BACKSPACE, String.valueOf(backspace))
|
||||
.putString(SectionKeymap.ITEM_CHANGE_KEYBOARD, String.valueOf(changeKeyboard))
|
||||
.putString(SectionKeymap.ITEM_FILTER_CLEAR, String.valueOf(filterClear))
|
||||
.putString(SectionKeymap.ITEM_FILTER_SUGGESTIONS, String.valueOf(filterSuggestions))
|
||||
.putString(SectionKeymap.ITEM_PREVIOUS_SUGGESTION, String.valueOf(previousSuggestion))
|
||||
|
|
@ -203,6 +205,9 @@ public class SettingsStore {
|
|||
public int getKeyBackspace() {
|
||||
return getFunctionKey(SectionKeymap.ITEM_BACKSPACE);
|
||||
}
|
||||
public int getKeyChangeKeyboard() {
|
||||
return getFunctionKey(SectionKeymap.ITEM_CHANGE_KEYBOARD);
|
||||
}
|
||||
public int getKeyFilterClear() {
|
||||
return getFunctionKey(SectionKeymap.ITEM_FILTER_CLEAR);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ public class Hotkeys {
|
|||
settings.setDefaultKeys(
|
||||
KeyEvent.KEYCODE_STAR,
|
||||
backspace,
|
||||
0, // "change keyboard" is unassigned by default
|
||||
clearFilter,
|
||||
filter,
|
||||
previousSuggestion,
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
package io.github.sspanak.tt9.preferences.items;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import io.github.sspanak.tt9.preferences.PreferencesActivity;
|
||||
import io.github.sspanak.tt9.ui.UI;
|
||||
|
||||
public class ItemSetDefaultGlobalKeyboard extends ItemClickable {
|
||||
private final PreferencesActivity activity;
|
||||
|
|
@ -17,7 +15,7 @@ public class ItemSetDefaultGlobalKeyboard extends ItemClickable {
|
|||
|
||||
@Override
|
||||
protected boolean onClick(Preference p) {
|
||||
((InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE)).showInputMethodPicker();
|
||||
UI.showChangeKeyboardDialog(activity);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import io.github.sspanak.tt9.preferences.helpers.Hotkeys;
|
|||
public class SectionKeymap {
|
||||
public static final String ITEM_ADD_WORD = "key_add_word";
|
||||
public static final String ITEM_BACKSPACE = "key_backspace";
|
||||
public static final String ITEM_CHANGE_KEYBOARD = "key_change_keyboard";
|
||||
public static final String ITEM_FILTER_CLEAR = "key_filter_clear";
|
||||
public static final String ITEM_FILTER_SUGGESTIONS = "key_filter_suggestions";
|
||||
public static final String ITEM_PREVIOUS_SUGGESTION = "key_previous_suggestion";
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ public class HotkeysScreen extends BaseScreenFragment {
|
|||
DropDownPreference[] dropDowns = {
|
||||
findPreference(SectionKeymap.ITEM_ADD_WORD),
|
||||
findPreference(SectionKeymap.ITEM_BACKSPACE),
|
||||
findPreference(SectionKeymap.ITEM_CHANGE_KEYBOARD),
|
||||
findPreference(SectionKeymap.ITEM_FILTER_CLEAR),
|
||||
findPreference(SectionKeymap.ITEM_FILTER_SUGGESTIONS),
|
||||
findPreference(SectionKeymap.ITEM_PREVIOUS_SUGGESTION),
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import android.app.AlertDialog;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Looper;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.Toast;
|
||||
|
||||
import io.github.sspanak.tt9.ime.TraditionalT9;
|
||||
|
|
@ -20,6 +21,11 @@ public class UI {
|
|||
}
|
||||
|
||||
|
||||
public static void showChangeKeyboardDialog(Context context) {
|
||||
((InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE)).showInputMethodPicker();
|
||||
}
|
||||
|
||||
|
||||
public static void showSettingsScreen(TraditionalT9 tt9) {
|
||||
Intent prefIntent = new Intent(tt9, PreferencesActivity.class);
|
||||
prefIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
|
|
@ -63,17 +69,11 @@ public class UI {
|
|||
Toast.makeText(context, resourceId, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
public static void toastLongFromAsync(Context context, int resourceId) {
|
||||
if (Looper.myLooper() == null) {
|
||||
Looper.prepare();
|
||||
}
|
||||
toast(context, resourceId);
|
||||
}
|
||||
|
||||
public static void toastLong(Context context, CharSequence msg) {
|
||||
Toast.makeText(context, msg, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void toastLongFromAsync(Context context, CharSequence msg) {
|
||||
if (Looper.myLooper() == null) {
|
||||
Looper.prepare();
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@ package io.github.sspanak.tt9.ui.main.keys;
|
|||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import io.github.sspanak.tt9.Logger;
|
||||
|
||||
public class SoftBackspaceKey extends SoftKey {
|
||||
|
||||
public SoftBackspaceKey(Context context) {
|
||||
|
|
@ -26,12 +24,7 @@ public class SoftBackspaceKey extends SoftKey {
|
|||
|
||||
@Override
|
||||
final protected boolean handleHold() {
|
||||
if (tt9 == null) {
|
||||
Logger.w(getClass().getCanonicalName(), "Traditional T9 handler is not set. Ignoring key press.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return tt9.onBackspace();
|
||||
return validateTT9Handler() && tt9.onBackspace();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -99,8 +99,7 @@ public class SoftKey extends androidx.appcompat.widget.AppCompatButton implement
|
|||
* Repeatedly calls "handleHold()" upon holding the respective SoftKey, to simulate physical keyboard behavior.
|
||||
*/
|
||||
private void repeatOnLongPress() {
|
||||
if (tt9 == null) {
|
||||
Logger.w(getClass().getCanonicalName(), "Traditional T9 handler is not set. Ignoring key press.");
|
||||
if (!validateTT9Handler()) {
|
||||
hold = false;
|
||||
return;
|
||||
}
|
||||
|
|
@ -132,8 +131,7 @@ public class SoftKey extends androidx.appcompat.widget.AppCompatButton implement
|
|||
}
|
||||
|
||||
protected boolean handleRelease() {
|
||||
if (tt9 == null) {
|
||||
Logger.w(getClass().getCanonicalName(), "Traditional T9 handler is not set. Ignoring key press.");
|
||||
if (!validateTT9Handler()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -145,7 +143,6 @@ public class SoftKey extends androidx.appcompat.widget.AppCompatButton implement
|
|||
if (keyId == R.id.soft_key_clear_filter) return tt9.onKeyFilterClear(false);
|
||||
if (keyId == R.id.soft_key_left_arrow) return tt9.onKeyScrollSuggestion(false, true);
|
||||
if (keyId == R.id.soft_key_right_arrow) return tt9.onKeyScrollSuggestion(false, false);
|
||||
if (keyId == R.id.soft_key_input_mode) return tt9.onKeyNextInputMode(false);
|
||||
if (keyId == R.id.soft_key_language) return tt9.onKeyNextLanguage(false);
|
||||
if (keyId == R.id.soft_key_ok) return tt9.onOK();
|
||||
if (keyId == R.id.soft_key_settings) return tt9.onKeyShowSettings(false);
|
||||
|
|
@ -153,6 +150,15 @@ public class SoftKey extends androidx.appcompat.widget.AppCompatButton implement
|
|||
return false;
|
||||
}
|
||||
|
||||
protected boolean validateTT9Handler() {
|
||||
if (tt9 == null) {
|
||||
Logger.w(getClass().getCanonicalName(), "Traditional T9 handler is not set. Ignoring key press.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* getTitle
|
||||
* Generates the name of the key, for example: "OK", "Backspace", "1", etc...
|
||||
|
|
|
|||
30
src/io/github/sspanak/tt9/ui/main/keys/SoftKeyInputMode.java
Normal file
30
src/io/github/sspanak/tt9/ui/main/keys/SoftKeyInputMode.java
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
package io.github.sspanak.tt9.ui.main.keys;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
public class SoftKeyInputMode extends SoftKey {
|
||||
public SoftKeyInputMode(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public SoftKeyInputMode(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public SoftKeyInputMode(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean handleHold() {
|
||||
preventRepeat();
|
||||
return validateTT9Handler() && tt9.onKeyChangeKeyboard(false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean handleRelease() {
|
||||
return validateTT9Handler() && tt9.onKeyNextInputMode(false);
|
||||
}
|
||||
}
|
||||
|
|
@ -40,13 +40,8 @@ public class SoftNumberKey extends SoftKey {
|
|||
|
||||
@Override
|
||||
protected boolean handleRelease() {
|
||||
if (tt9 == null) {
|
||||
Logger.w(getClass().getCanonicalName(), "Traditional T9 handler is not set. Ignoring key press.");
|
||||
return false;
|
||||
}
|
||||
|
||||
int keyCode = Key.numberToCode(getNumber(getId()));
|
||||
if (keyCode < 0) {
|
||||
if (keyCode < 0 || !validateTT9Handler()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package io.github.sspanak.tt9.ui.main.keys;
|
|||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import io.github.sspanak.tt9.Logger;
|
||||
import io.github.sspanak.tt9.R;
|
||||
import io.github.sspanak.tt9.ime.modes.InputMode;
|
||||
|
||||
|
|
@ -36,8 +35,7 @@ public class SoftPunctuationKey extends SoftKey {
|
|||
|
||||
@Override
|
||||
protected boolean handleRelease() {
|
||||
if (tt9 == null) {
|
||||
Logger.w(getClass().getCanonicalName(), "Traditional T9 handler is not set. Ignoring key press.");
|
||||
if (!validateTT9Handler()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue