(not so) big code cleanup (#243)
* removed some unused resources and code * removed a nonsense package.json section from .editorconfig * minimized the usage of mEditing * removed obsolete toggling of the system candidate view
This commit is contained in:
parent
1fa1e7c6e6
commit
4d67c02340
22 changed files with 40 additions and 61 deletions
|
|
@ -11,5 +11,3 @@ trim_trailing_whitespace = true
|
|||
[*.md]
|
||||
indent_style = space
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[package.json]
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@
|
|||
android:gravity="end">
|
||||
|
||||
<Button
|
||||
android:id="@+id/add_word_cancel"
|
||||
style="@style/Widget.AppCompat.Button.Borderless.Colored"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
@ -39,7 +38,6 @@
|
|||
android:text="@android:string/cancel" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/add_word_add"
|
||||
style="@style/Widget.AppCompat.Button.Borderless.Colored"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/main_numpad"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
|
@ -85,7 +84,6 @@
|
|||
style="@style/numSeparator" />
|
||||
|
||||
<io.github.sspanak.tt9.ui.main.keys.SoftBackspaceKey
|
||||
android:id="@+id/soft_key_backspace"
|
||||
style="@android:style/Widget.Holo.Button.Borderless"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/main_small"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
|
@ -68,7 +67,6 @@
|
|||
style="@style/hSeparator" />
|
||||
|
||||
<io.github.sspanak.tt9.ui.main.keys.SoftBackspaceKey
|
||||
android:id="@+id/soft_key_backspace"
|
||||
style="@android:style/Widget.Holo.Button.Borderless"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/suggestion_list_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal">
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/suggestion_list_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal">
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@
|
|||
<string name="function_reset_keys_done">Възстановени са стандартните „бързи“ бутони.</string>
|
||||
<string name="setup_keyboard_status">Състояние</string>
|
||||
<string name="setup_default_keyboard">Избор на клавиатура по подразбиране</string>
|
||||
<string name="setup_goto_main_screen">Назад към Настройки</string>
|
||||
<string name="setup_tt9_on">Traditional T9 е активен</string>
|
||||
<string name="setup_tt9_off">Traditional T9 е изключен</string>
|
||||
<string name="setup_click_here_to_enable">Натиснете тук, за да включите TT9 от настройките на Андроид.</string>
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
<string name="char_space">Espacio</string>
|
||||
<string name="setup_keyboard_status">Estado</string>
|
||||
<string name="setup_default_keyboard">Selecciona teclado predeterminado</string>
|
||||
<string name="setup_goto_main_screen">Volver a la pantalla de configuración</string>
|
||||
<string name="char_newline">Nueva línea</string>
|
||||
<string name="dictionary_load_title">Cargar diccionario</string>
|
||||
<string name="dictionary_loading_indeterminate">Cargando diccionario</string>
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@
|
|||
<string name="char_space">Espace</string>
|
||||
<string name="setup_keyboard_status">État</string>
|
||||
<string name="setup_default_keyboard">Sélectionnez le clavier par défaut</string>
|
||||
<string name="setup_goto_main_screen">Retour à l\'écran des paramètres</string>
|
||||
<string name="setup_tt9_on">Traditional T9 est activé</string>
|
||||
<string name="setup_tt9_off">Traditional T9 est désactivé</string>
|
||||
<string name="setup_click_here_to_enable">Cliquez ici pour activer TT9 dans les paramètres Android.</string>
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@
|
|||
<string name="char_space">Spazio</string>
|
||||
<string name="setup_keyboard_status">Stato</string>
|
||||
<string name="setup_default_keyboard">Scegli Tastiera predefinita</string>
|
||||
<string name="setup_goto_main_screen">Torna a Impostazioni</string>
|
||||
<string name="char_newline">Nuova riga</string>
|
||||
<string name="pref_upside_down_keys">Invertire l\'ordine delle chiavi</string>
|
||||
<string name="pref_upside_down_keys_summary">Abilita l\'impostazione se ci sono 7–8–9 sulla prima riga, invece di 1–2–3.</string>
|
||||
|
|
|
|||
|
|
@ -47,7 +47,6 @@
|
|||
<string name="function_reset_keys_done">Настройки кнопок по умолчанию восстановлены.</string>
|
||||
<string name="setup_keyboard_status">Состояние</string>
|
||||
<string name="setup_default_keyboard">Выберите клавиатуру по умолчанию</string>
|
||||
<string name="setup_goto_main_screen">Вернуться к настройкам</string>
|
||||
<string name="setup_tt9_on">Traditional T9 активен</string>
|
||||
<string name="setup_tt9_off">Traditional T9 отключен</string>
|
||||
<string name="setup_click_here_to_enable">Нажмите здесь, чтобы включить TT9 в настройках Android.</string>
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@
|
|||
<string name="key_call">Виклик</string>
|
||||
<string name="setup_keyboard_status">Стан</string>
|
||||
<string name="setup_default_keyboard">Вибрати стандартну клавіатуру</string>
|
||||
<string name="setup_goto_main_screen">Назад до налаштувань</string>
|
||||
<string name="setup_tt9_on">Traditional T9 активний</string>
|
||||
<string name="setup_tt9_off">Traditional T9 вимкнено</string>
|
||||
<string name="setup_click_here_to_enable">Натисніть тут, щоб увімкнути TT9 в налаштуваннях Android.</string>
|
||||
|
|
|
|||
|
|
@ -60,7 +60,6 @@
|
|||
|
||||
<string name="setup_keyboard_status">Status</string>
|
||||
<string name="setup_default_keyboard">Select Default Keyboard</string>
|
||||
<string name="setup_goto_main_screen">Return to Settings</string>
|
||||
<string name="setup_tt9_on">Traditional T9 is enabled</string>
|
||||
<string name="setup_tt9_off">Traditional T9 is disabled</string>
|
||||
<string name="setup_click_here_to_enable">Click here to enable TT9 from Android Settings.</string>
|
||||
|
|
|
|||
|
|
@ -216,7 +216,7 @@ public class DictionaryLoader {
|
|||
try {
|
||||
dbWords.add(stringToWord(language, word, frequency));
|
||||
} catch (InvalidLanguageCharactersException e) {
|
||||
throw new DictionaryImportException(dictionaryFile, word, lineCount);
|
||||
throw new DictionaryImportException(word, lineCount);
|
||||
}
|
||||
|
||||
if (lineCount % settings.getDictionaryImportWordChunkSize() == 0 || lineCount == totalWords - 1) {
|
||||
|
|
|
|||
|
|
@ -1,13 +1,11 @@
|
|||
package io.github.sspanak.tt9.db.exceptions;
|
||||
|
||||
public class DictionaryImportException extends Exception {
|
||||
public final String file;
|
||||
public final String word;
|
||||
public final long line;
|
||||
|
||||
public DictionaryImportException(String file, String word, long line) {
|
||||
public DictionaryImportException(String word, long line) {
|
||||
super("Dictionary import failed");
|
||||
this.file = file;
|
||||
this.word = word;
|
||||
this.line = line;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,13 +15,6 @@ abstract class KeyPadHandler extends InputMethodService {
|
|||
|
||||
protected SettingsStore settings;
|
||||
|
||||
// editing mode
|
||||
protected static final int NON_EDIT = 0;
|
||||
protected static final int EDITING = 1;
|
||||
protected static final int EDITING_STRICT_NUMERIC = 3;
|
||||
protected static final int EDITING_DIALER = 4; // see: https://github.com/sspanak/tt9/issues/46
|
||||
protected int mEditing = NON_EDIT;
|
||||
|
||||
// temporal key handling
|
||||
private boolean isBackspaceHandled = false;
|
||||
|
||||
|
|
@ -51,7 +44,7 @@ abstract class KeyPadHandler extends InputMethodService {
|
|||
public boolean onEvaluateInputViewShown() {
|
||||
super.onEvaluateInputViewShown();
|
||||
onRestart(getCurrentInputEditorInfo());
|
||||
return mEditing != EDITING_DIALER && mEditing != NON_EDIT;
|
||||
return shouldBeVisible();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -96,9 +89,7 @@ abstract class KeyPadHandler extends InputMethodService {
|
|||
@Override
|
||||
public void onFinishInputView(boolean finishingInput) {
|
||||
super.onFinishInputView(finishingInput);
|
||||
if (mEditing == EDITING || mEditing == EDITING_STRICT_NUMERIC) {
|
||||
onFinishTyping();
|
||||
}
|
||||
onFinishTyping();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -109,9 +100,7 @@ abstract class KeyPadHandler extends InputMethodService {
|
|||
public void onFinishInput() {
|
||||
super.onFinishInput();
|
||||
// Logger.d("onFinishInput", "When is this called?");
|
||||
if (mEditing == EDITING || mEditing == EDITING_STRICT_NUMERIC) {
|
||||
onStop();
|
||||
}
|
||||
onStop();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -122,7 +111,7 @@ abstract class KeyPadHandler extends InputMethodService {
|
|||
*/
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (isOff()) {
|
||||
if (shouldBeOff()) {
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
|
|
@ -161,7 +150,7 @@ abstract class KeyPadHandler extends InputMethodService {
|
|||
|
||||
@Override
|
||||
public boolean onKeyLongPress(int keyCode, KeyEvent event) {
|
||||
if (isOff()) {
|
||||
if (shouldBeOff()) {
|
||||
return super.onKeyLongPress(keyCode, event);
|
||||
}
|
||||
|
||||
|
|
@ -200,7 +189,7 @@ abstract class KeyPadHandler extends InputMethodService {
|
|||
*/
|
||||
@Override
|
||||
public boolean onKeyUp(int keyCode, KeyEvent event) {
|
||||
if (isOff()) {
|
||||
if (shouldBeOff()) {
|
||||
return super.onKeyUp(keyCode, event);
|
||||
}
|
||||
|
||||
|
|
@ -273,11 +262,6 @@ abstract class KeyPadHandler extends InputMethodService {
|
|||
}
|
||||
|
||||
|
||||
private boolean isOff() {
|
||||
return currentInputConnection == null || mEditing == NON_EDIT;
|
||||
}
|
||||
|
||||
|
||||
protected void resetKeyRepeat() {
|
||||
numKeyRepeatCounter = 0;
|
||||
keyRepeatCounter = 0;
|
||||
|
|
@ -312,5 +296,9 @@ abstract class KeyPadHandler extends InputMethodService {
|
|||
abstract protected void onRestart(EditorInfo inputField);
|
||||
abstract protected void onFinishTyping();
|
||||
abstract protected void onStop();
|
||||
|
||||
// UI
|
||||
abstract protected View createSoftKeyView();
|
||||
abstract protected boolean shouldBeVisible();
|
||||
abstract protected boolean shouldBeOff();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,13 @@ public class TraditionalT9 extends KeyPadHandler {
|
|||
private TextField textField;
|
||||
private InputType inputType;
|
||||
|
||||
// editing mode
|
||||
protected static final int NON_EDIT = 0;
|
||||
protected static final int EDITING = 1;
|
||||
protected static final int EDITING_STRICT_NUMERIC = 3;
|
||||
protected static final int EDITING_DIALER = 4; // see: https://github.com/sspanak/tt9/issues/46
|
||||
protected int mEditing = NON_EDIT;
|
||||
|
||||
// input mode
|
||||
private ArrayList<Integer> allowedInputModes = new ArrayList<>();
|
||||
private InputMode mInputMode;
|
||||
|
|
@ -365,6 +372,7 @@ public class TraditionalT9 extends KeyPadHandler {
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -505,14 +513,9 @@ public class TraditionalT9 extends KeyPadHandler {
|
|||
}
|
||||
|
||||
private void setSuggestions(List<String> suggestions, int selectedIndex) {
|
||||
if (suggestionBar == null) {
|
||||
return;
|
||||
if (suggestionBar != null) {
|
||||
suggestionBar.setSuggestions(suggestions, selectedIndex);
|
||||
}
|
||||
|
||||
boolean show = suggestions != null && suggestions.size() > 0;
|
||||
|
||||
suggestionBar.setSuggestions(suggestions, selectedIndex);
|
||||
setCandidatesViewShown(show);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -572,15 +575,10 @@ public class TraditionalT9 extends KeyPadHandler {
|
|||
|
||||
|
||||
private boolean nextLang() {
|
||||
if (mEditing == EDITING_STRICT_NUMERIC || mEditing == EDITING_DIALER) {
|
||||
if (mInputMode.is123() || mEnabledLanguages.size() < 2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// when only one language is enabled, just acknowledge the key was pressed
|
||||
if (mEnabledLanguages.size() < 2) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// select the next language
|
||||
int previous = mEnabledLanguages.indexOf(mLanguage.getId());
|
||||
int next = (previous + 1) % mEnabledLanguages.size();
|
||||
|
|
@ -743,4 +741,16 @@ public class TraditionalT9 extends KeyPadHandler {
|
|||
requestShowSelf(InputMethodManager.SHOW_IMPLICIT);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean shouldBeVisible() {
|
||||
return mEditing != EDITING_DIALER && mEditing != NON_EDIT;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean shouldBeOff() {
|
||||
return currentInputConnection == null || mEditing == NON_EDIT;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -317,6 +317,10 @@ public class TextField {
|
|||
|
||||
|
||||
public int getAction() {
|
||||
if (field == null) {
|
||||
return EditorInfo.IME_ACTION_NONE;
|
||||
}
|
||||
|
||||
if (field.actionId > 0) {
|
||||
return field.actionId; // custom action, defined by the connected app
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
package io.github.sspanak.tt9.languages;
|
||||
|
||||
public class InvalidLanguageCharactersException extends Exception {
|
||||
private final Language language;
|
||||
|
||||
public InvalidLanguageCharactersException(Language language, String extraMessage) {
|
||||
super("Some characters are not supported in language: " + language.getName() + ". " + extraMessage);
|
||||
this.language = language;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package io.github.sspanak.tt9.languages.definitions;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Locale;
|
||||
|
||||
import io.github.sspanak.tt9.languages.Characters;
|
||||
|
|
|
|||
|
|
@ -232,7 +232,6 @@ public class SettingsStore {
|
|||
public int getSuggestionSelectAnimationDuration() { return 66; }
|
||||
public int getSuggestionTranslateAnimationDuration() { return 0; }
|
||||
|
||||
public int getSoftKeyInitialDelay() { return 250; /* ms */ }
|
||||
public int getSoftKeyRepeatDelay() { return 40; /* ms */ }
|
||||
|
||||
public int getWordFrequencyMax() { return 25500; }
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ public class ItemSelectLanguage {
|
|||
}
|
||||
|
||||
item.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
HashSet<String> newLanguages = (HashSet<String>) newValue;
|
||||
@SuppressWarnings("unchecked") HashSet<String> newLanguages = (HashSet<String>) newValue;
|
||||
if (newLanguages.size() == 0) {
|
||||
newLanguages.add("1");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue