Summer bugs (#401)
* removed isActive and fixed a startup crash in onEvaluateInputViewShown() (#364, #385, #389) * fixed the MainView is visible in dropdowns or other non-text inputs (#367) * fixed logging settings not being applied at startup sometimes * code cleanup: remove using isThereText (#347) * removed the Messenger Lite hacks, since the app has been discontinued and no longer works --------- Co-authored-by: alexknop <knopalex@msu.edu> Co-authored-by: Alex Knop <alexknoptech@protonmail.com>
This commit is contained in:
parent
c02b4149e2
commit
7cde9ecd00
11 changed files with 58 additions and 80 deletions
|
|
@ -29,7 +29,7 @@
|
||||||
<string name="pref_category_appearance">Облик</string>
|
<string name="pref_category_appearance">Облик</string>
|
||||||
<string name="pref_category_function_keys">Бутони за бърз достъп</string>
|
<string name="pref_category_function_keys">Бутони за бърз достъп</string>
|
||||||
<string name="pref_hack_fb_messenger">Изпращай съобщения с ОК в Messenger</string>
|
<string name="pref_hack_fb_messenger">Изпращай съобщения с ОК в Messenger</string>
|
||||||
<string name="pref_hack_fb_messenger_summary">Позволява изпращането на съобщения с бутона ОК във Facebook Messenger и Messenger Lite.</string>
|
<string name="pref_hack_fb_messenger_summary">Позволява изпращането на съобщения с бутона ОК във Facebook Messenger.</string>
|
||||||
<string name="pref_show_soft_function_keys">Бутони на екрана</string>
|
<string name="pref_show_soft_function_keys">Бутони на екрана</string>
|
||||||
<string name="key_back">Назад</string>
|
<string name="key_back">Назад</string>
|
||||||
<string name="key_call">Зелена слушалка</string>
|
<string name="key_call">Зелена слушалка</string>
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@
|
||||||
<string name="dictionary_load_bad_char">Echec du chargement. Mot inadmissible «%1$s» à la ligne %2$d de langue «%3$s».</string>
|
<string name="dictionary_load_bad_char">Echec du chargement. Mot inadmissible «%1$s» à la ligne %2$d de langue «%3$s».</string>
|
||||||
<string name="dictionary_truncated">Le dictionaire est supprimé avec succès.</string>
|
<string name="dictionary_truncated">Le dictionaire est supprimé avec succès.</string>
|
||||||
<string name="pref_hack_fb_messenger">Envoyer des messages avec OK dans Messenger</string>
|
<string name="pref_hack_fb_messenger">Envoyer des messages avec OK dans Messenger</string>
|
||||||
<string name="pref_hack_fb_messenger_summary">La touche OK servira pour envoyer des messages dans Facebook Messenger et Messenger Lite.</string>
|
<string name="pref_hack_fb_messenger_summary">La touche OK servira pour envoyer des messages dans Facebook Messenger.</string>
|
||||||
<string name="pref_show_soft_function_keys">Boutons à l\'écran</string>
|
<string name="pref_show_soft_function_keys">Boutons à l\'écran</string>
|
||||||
<string name="dictionary_loading_indeterminate">Chargement du dictionnaire</string>
|
<string name="dictionary_loading_indeterminate">Chargement du dictionnaire</string>
|
||||||
<string name="dictionary_load_cancelled">Chargement est annulé.</string>
|
<string name="dictionary_load_cancelled">Chargement est annulé.</string>
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@
|
||||||
<string name="pref_auto_text_case_summary">Автоматически начинать предложение с заглавной буквы.</string>
|
<string name="pref_auto_text_case_summary">Автоматически начинать предложение с заглавной буквы.</string>
|
||||||
<string name="pref_double_zero_char">Символ при двойном нажатии клавиши 0</string>
|
<string name="pref_double_zero_char">Символ при двойном нажатии клавиши 0</string>
|
||||||
<string name="pref_hack_fb_messenger">Отправка сообщения с «ОК» в Messenger</string>
|
<string name="pref_hack_fb_messenger">Отправка сообщения с «ОК» в Messenger</string>
|
||||||
<string name="pref_hack_fb_messenger_summary">Позволяет отправлять сообщения с помощью кнопки «ОК» в Facebook Messenger и Messenger Lite.</string>
|
<string name="pref_hack_fb_messenger_summary">Позволяет отправлять сообщения с помощью кнопки «ОК» в Facebook Messenger.</string>
|
||||||
<string name="pref_show_soft_function_keys">Кнопки на экране</string>
|
<string name="pref_show_soft_function_keys">Кнопки на экране</string>
|
||||||
<string name="dictionary_load_bad_char">Не удалось загрузить словарь. Проблема в слове «%1$s» в строке %2$d для языка «%3$s».</string>
|
<string name="dictionary_load_bad_char">Не удалось загрузить словарь. Проблема в слове «%1$s» в строке %2$d для языка «%3$s».</string>
|
||||||
<string name="dictionary_missing_go_load_it">Отсутствует словарь для языка «%1$s». Вы можете загрузить его в Настройках.</string>
|
<string name="dictionary_missing_go_load_it">Отсутствует словарь для языка «%1$s». Вы можете загрузить его в Настройках.</string>
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@
|
||||||
<string name="pref_auto_text_case_summary">Автоматично починати речення з заголовної букви.</string>
|
<string name="pref_auto_text_case_summary">Автоматично починати речення з заголовної букви.</string>
|
||||||
<string name="pref_double_zero_char">Символ при подвійному натисканні клавіші 0</string>
|
<string name="pref_double_zero_char">Символ при подвійному натисканні клавіші 0</string>
|
||||||
<string name="pref_hack_fb_messenger">Надсилати повідомлення з «ОК» до Messenger</string>
|
<string name="pref_hack_fb_messenger">Надсилати повідомлення з «ОК» до Messenger</string>
|
||||||
<string name="pref_hack_fb_messenger_summary">Дозволяє надсилати повідомлення за допомогою клавіші «ОК» у Facebook Messenger і Messenger Lite.</string>
|
<string name="pref_hack_fb_messenger_summary">Дозволяє надсилати повідомлення за допомогою клавіші «ОК» у Facebook Messenger.</string>
|
||||||
<string name="pref_show_soft_function_keys">Кнопки на екрані</string>
|
<string name="pref_show_soft_function_keys">Кнопки на екрані</string>
|
||||||
<string name="key_back">Назад</string>
|
<string name="key_back">Назад</string>
|
||||||
<string name="key_call">Виклик</string>
|
<string name="key_call">Виклик</string>
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@
|
||||||
<string name="pref_system_logs" translatable="false">System Logs</string>
|
<string name="pref_system_logs" translatable="false">System Logs</string>
|
||||||
<string name="pref_double_zero_char">Character for Double 0-key Press</string>
|
<string name="pref_double_zero_char">Character for Double 0-key Press</string>
|
||||||
<string name="pref_hack_fb_messenger">Send messages with OK in Messenger</string>
|
<string name="pref_hack_fb_messenger">Send messages with OK in Messenger</string>
|
||||||
<string name="pref_hack_fb_messenger_summary">Allows sending messages with the OK key in Facebook Messenger and Messenger Lite.</string>
|
<string name="pref_hack_fb_messenger_summary">Allows sending messages with the OK key in Facebook Messenger.</string>
|
||||||
<string name="pref_show_soft_function_keys">Show On-Screen Keys</string>
|
<string name="pref_show_soft_function_keys">Show On-Screen Keys</string>
|
||||||
<string name="pref_show_soft_numpad">Show On-Screen Numpad</string>
|
<string name="pref_show_soft_numpad">Show On-Screen Numpad</string>
|
||||||
<string name="pref_show_soft_numpad_summary" translatable="false">(BETA)</string>
|
<string name="pref_show_soft_numpad_summary" translatable="false">(BETA)</string>
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,6 @@ import io.github.sspanak.tt9.preferences.SettingsStore;
|
||||||
|
|
||||||
|
|
||||||
abstract class KeyPadHandler extends InputMethodService {
|
abstract class KeyPadHandler extends InputMethodService {
|
||||||
protected InputConnection currentInputConnection = null;
|
|
||||||
|
|
||||||
protected SettingsStore settings;
|
protected SettingsStore settings;
|
||||||
|
|
||||||
// temporal key handling
|
// temporal key handling
|
||||||
|
|
@ -44,7 +42,7 @@ abstract class KeyPadHandler extends InputMethodService {
|
||||||
@Override
|
@Override
|
||||||
public boolean onEvaluateInputViewShown() {
|
public boolean onEvaluateInputViewShown() {
|
||||||
super.onEvaluateInputViewShown();
|
super.onEvaluateInputViewShown();
|
||||||
onRestart(getCurrentInputEditorInfo());
|
setInputField(getCurrentInputConnection(), getCurrentInputEditorInfo());
|
||||||
return shouldBeVisible();
|
return shouldBeVisible();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -79,15 +77,13 @@ abstract class KeyPadHandler extends InputMethodService {
|
||||||
"KeyPadHandler",
|
"KeyPadHandler",
|
||||||
"===> Start Up; packageName: " + inputField.packageName + " inputType: " + inputField.inputType + " fieldId: " + inputField.fieldId + " fieldName: " + inputField.fieldName + " privateImeOptions: " + inputField.privateImeOptions + " imeOptions: " + inputField.imeOptions + " extras: " + inputField.extras
|
"===> Start Up; packageName: " + inputField.packageName + " inputType: " + inputField.inputType + " fieldId: " + inputField.fieldId + " fieldName: " + inputField.fieldName + " privateImeOptions: " + inputField.privateImeOptions + " imeOptions: " + inputField.imeOptions + " extras: " + inputField.extras
|
||||||
);
|
);
|
||||||
currentInputConnection = getCurrentInputConnection();
|
onStart(getCurrentInputConnection(), inputField);
|
||||||
onStart(inputField);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStartInputView(EditorInfo inputField, boolean restarting) {
|
public void onStartInputView(EditorInfo inputField, boolean restarting) {
|
||||||
currentInputConnection = getCurrentInputConnection();
|
onStart(getCurrentInputConnection(), inputField);
|
||||||
onRestart(inputField);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -294,10 +290,10 @@ abstract class KeyPadHandler extends InputMethodService {
|
||||||
|
|
||||||
// helpers
|
// helpers
|
||||||
abstract protected void onInit();
|
abstract protected void onInit();
|
||||||
abstract protected void onStart(EditorInfo inputField);
|
abstract protected void onStart(InputConnection inputConnection, EditorInfo inputField);
|
||||||
abstract protected void onRestart(EditorInfo inputField);
|
|
||||||
abstract protected void onFinishTyping();
|
abstract protected void onFinishTyping();
|
||||||
abstract protected void onStop();
|
abstract protected void onStop();
|
||||||
|
abstract protected void setInputField(InputConnection inputConnection, EditorInfo inputField);
|
||||||
|
|
||||||
// UI
|
// UI
|
||||||
abstract protected View createSoftKeyView();
|
abstract protected View createSoftKeyView();
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import android.os.Looper;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
|
import android.view.inputmethod.InputConnection;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
@ -34,18 +35,16 @@ import io.github.sspanak.tt9.ui.tray.StatusBar;
|
||||||
import io.github.sspanak.tt9.ui.tray.SuggestionsBar;
|
import io.github.sspanak.tt9.ui.tray.SuggestionsBar;
|
||||||
|
|
||||||
public class TraditionalT9 extends KeyPadHandler {
|
public class TraditionalT9 extends KeyPadHandler {
|
||||||
|
private InputConnection currentInputConnection = null;
|
||||||
// internal settings/data
|
// internal settings/data
|
||||||
@NonNull private AppHacks appHacks = new AppHacks(null,null, null, null);
|
@NonNull private AppHacks appHacks = new AppHacks(null,null, null, null);
|
||||||
@NonNull private TextField textField = new TextField(null, null);
|
@NonNull private TextField textField = new TextField(null, null);
|
||||||
@NonNull private InputType inputType = new InputType(null, null);
|
@NonNull private InputType inputType = new InputType(null, null);
|
||||||
@NonNull private final Handler autoAcceptHandler = new Handler(Looper.getMainLooper());
|
@NonNull private final Handler autoAcceptHandler = new Handler(Looper.getMainLooper());
|
||||||
|
|
||||||
@Deprecated // migrate to "ModePassthrough" when "isActive" == "false"
|
|
||||||
private boolean isActive = false;
|
|
||||||
|
|
||||||
// input mode
|
// input mode
|
||||||
private ArrayList<Integer> allowedInputModes = new ArrayList<>();
|
private ArrayList<Integer> allowedInputModes = new ArrayList<>();
|
||||||
private InputMode mInputMode;
|
@NonNull private InputMode mInputMode = InputMode.getInstance(null, null, null, InputMode.MODE_PASSTHROUGH);
|
||||||
|
|
||||||
// language
|
// language
|
||||||
protected ArrayList<Integer> mEnabledLanguages;
|
protected ArrayList<Integer> mEnabledLanguages;
|
||||||
|
|
@ -66,23 +65,23 @@ public class TraditionalT9 extends KeyPadHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInputModeNumeric() {
|
public boolean isInputModeNumeric() {
|
||||||
return mInputMode != null && mInputMode.is123();
|
return mInputMode.is123();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isNumericModeStrict() {
|
public boolean isNumericModeStrict() {
|
||||||
return mInputMode != null && mInputMode.is123() && inputType.isNumeric() && !inputType.isPhoneNumber();
|
return mInputMode.is123() && inputType.isNumeric() && !inputType.isPhoneNumber();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isNumericModeSigned() {
|
public boolean isNumericModeSigned() {
|
||||||
return mInputMode != null && mInputMode.is123() && inputType.isSignedNumber();
|
return mInputMode.is123() && inputType.isSignedNumber();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInputModePhone() {
|
public boolean isInputModePhone() {
|
||||||
return mInputMode != null && mInputMode.is123() && inputType.isPhoneNumber();
|
return mInputMode.is123() && inputType.isPhoneNumber();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getTextCase() {
|
public int getTextCase() {
|
||||||
return mInputMode != null ? mInputMode.getTextCase() : InputMode.CASE_UNDEFINED;
|
return mInputMode.getTextCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -103,14 +102,18 @@ public class TraditionalT9 extends KeyPadHandler {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* determineInputMode
|
* getInputMode
|
||||||
* Restore the last input mode or choose a more appropriate one.
|
* Load the last input mode or choose a more appropriate one.
|
||||||
* Some input fields support only numbers or are not suited for predictions (e.g. password fields)
|
* Some input fields support only numbers or are not suited for predictions (e.g. password fields)
|
||||||
*/
|
*/
|
||||||
private void determineInputMode() {
|
private InputMode getInputMode() {
|
||||||
|
if (!inputType.isValid() || (inputType.isLimited() && !appHacks.isTermux())) {
|
||||||
|
return InputMode.getInstance(settings, mLanguage, inputType, InputMode.MODE_PASSTHROUGH);
|
||||||
|
}
|
||||||
|
|
||||||
allowedInputModes = textField.determineInputModes(inputType);
|
allowedInputModes = textField.determineInputModes(inputType);
|
||||||
int validModeId = InputModeValidator.validateMode(settings.getInputMode(), allowedInputModes);
|
int validModeId = InputModeValidator.validateMode(settings.getInputMode(), allowedInputModes);
|
||||||
mInputMode = InputMode.getInstance(settings, mLanguage, inputType, validModeId);
|
return InputMode.getInstance(settings, mLanguage, inputType, validModeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -123,7 +126,7 @@ public class TraditionalT9 extends KeyPadHandler {
|
||||||
private void determineTextCase() {
|
private void determineTextCase() {
|
||||||
mInputMode.defaultTextCase();
|
mInputMode.defaultTextCase();
|
||||||
mInputMode.setTextFieldCase(textField.determineTextCase(inputType));
|
mInputMode.setTextFieldCase(textField.determineTextCase(inputType));
|
||||||
mInputMode.determineNextWordTextCase(textField.isThereText(), textField.getTextBeforeCursor());
|
mInputMode.determineNextWordTextCase(textField.getTextBeforeCursor());
|
||||||
InputModeValidator.validateTextCase(mInputMode, settings.getTextCase());
|
InputModeValidator.validateTextCase(mInputMode, settings.getTextCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -144,6 +147,7 @@ public class TraditionalT9 extends KeyPadHandler {
|
||||||
|
|
||||||
protected void onInit() {
|
protected void onInit() {
|
||||||
self = this;
|
self = this;
|
||||||
|
Logger.enableDebugLevel(settings.getDebugLogsEnabled());
|
||||||
|
|
||||||
DictionaryDb.init(this);
|
DictionaryDb.init(this);
|
||||||
DictionaryDb.normalizeWordFrequencies(settings);
|
DictionaryDb.normalizeWordFrequencies(settings);
|
||||||
|
|
@ -157,6 +161,14 @@ public class TraditionalT9 extends KeyPadHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected void setInputField(InputConnection connection, EditorInfo field) {
|
||||||
|
currentInputConnection = connection;
|
||||||
|
inputType = new InputType(currentInputConnection, field);
|
||||||
|
textField = new TextField(currentInputConnection, field);
|
||||||
|
appHacks = new AppHacks(settings, connection, field, textField);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void initTyping() {
|
private void initTyping() {
|
||||||
// in case we are back from Settings screen, update the language list
|
// in case we are back from Settings screen, update the language list
|
||||||
mEnabledLanguages = settings.getEnabledLanguageIds();
|
mEnabledLanguages = settings.getEnabledLanguageIds();
|
||||||
|
|
@ -165,7 +177,7 @@ public class TraditionalT9 extends KeyPadHandler {
|
||||||
|
|
||||||
resetKeyRepeat();
|
resetKeyRepeat();
|
||||||
setSuggestions(null);
|
setSuggestions(null);
|
||||||
determineInputMode();
|
mInputMode = getInputMode();
|
||||||
determineTextCase();
|
determineTextCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -188,41 +200,33 @@ public class TraditionalT9 extends KeyPadHandler {
|
||||||
if (mainView.createView()) {
|
if (mainView.createView()) {
|
||||||
initTray();
|
initTray();
|
||||||
}
|
}
|
||||||
statusBar.setText(mInputMode != null ? mInputMode.toString() : "");
|
statusBar.setText(mInputMode.toString());
|
||||||
setDarkTheme();
|
setDarkTheme();
|
||||||
mainView.render();
|
mainView.render();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void onStart(EditorInfo input) {
|
protected void onStart(InputConnection connection, EditorInfo field) {
|
||||||
inputType = new InputType(currentInputConnection, input);
|
Logger.enableDebugLevel(settings.getDebugLogsEnabled());
|
||||||
textField = new TextField(currentInputConnection, input);
|
|
||||||
appHacks = new AppHacks(settings, currentInputConnection, input, textField);
|
|
||||||
|
|
||||||
if (!inputType.isValid() || (inputType.isLimited() && !appHacks.isTermux())) {
|
setInputField(connection, field);
|
||||||
|
initTyping();
|
||||||
|
|
||||||
|
if (mInputMode.isPassthrough()) {
|
||||||
// When the input is invalid or simple, let Android handle it.
|
// When the input is invalid or simple, let Android handle it.
|
||||||
onStop();
|
onStop();
|
||||||
|
updateInputViewShown();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
initTyping();
|
|
||||||
initUi();
|
initUi();
|
||||||
Logger.enableDebugLevel(settings.getDebugLogsEnabled());
|
updateInputViewShown();
|
||||||
|
|
||||||
isActive = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected void onRestart(EditorInfo inputField) {
|
|
||||||
if (!isActive) {
|
|
||||||
onStart(inputField);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void onFinishTyping() {
|
protected void onFinishTyping() {
|
||||||
cancelAutoAccept();
|
cancelAutoAccept();
|
||||||
isActive = false;
|
mInputMode = InputMode.getInstance(null, null, null, InputMode.MODE_PASSTHROUGH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -286,7 +290,7 @@ public class TraditionalT9 extends KeyPadHandler {
|
||||||
|
|
||||||
// Auto-adjust the text case before each word, if the InputMode supports it.
|
// Auto-adjust the text case before each word, if the InputMode supports it.
|
||||||
if (getComposingText().isEmpty()) {
|
if (getComposingText().isEmpty()) {
|
||||||
mInputMode.determineNextWordTextCase(textField.isThereText(), textField.getTextBeforeCursor());
|
mInputMode.determineNextWordTextCase(textField.getTextBeforeCursor());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mInputMode.onNumber(key, hold, repeat)) {
|
if (!mInputMode.onNumber(key, hold, repeat)) {
|
||||||
|
|
@ -613,7 +617,7 @@ public class TraditionalT9 extends KeyPadHandler {
|
||||||
commitCurrentSuggestion(false);
|
commitCurrentSuggestion(false);
|
||||||
mInputMode.onAcceptSuggestion(lastComposingText, true);
|
mInputMode.onAcceptSuggestion(lastComposingText, true);
|
||||||
autoCorrectSpace(lastComposingText, false, -1);
|
autoCorrectSpace(lastComposingText, false, -1);
|
||||||
mInputMode.determineNextWordTextCase(textField.isThereText(), textField.getTextBeforeCursor());
|
mInputMode.determineNextWordTextCase(textField.getTextBeforeCursor());
|
||||||
}
|
}
|
||||||
|
|
||||||
// display the word suggestions
|
// display the word suggestions
|
||||||
|
|
@ -709,7 +713,7 @@ public class TraditionalT9 extends KeyPadHandler {
|
||||||
int nextModeIndex = (allowedInputModes.indexOf(mInputMode.getId()) + 1) % allowedInputModes.size();
|
int nextModeIndex = (allowedInputModes.indexOf(mInputMode.getId()) + 1) % allowedInputModes.size();
|
||||||
mInputMode = InputMode.getInstance(settings, mLanguage, inputType, allowedInputModes.get(nextModeIndex));
|
mInputMode = InputMode.getInstance(settings, mLanguage, inputType, allowedInputModes.get(nextModeIndex));
|
||||||
mInputMode.setTextFieldCase(textField.determineTextCase(inputType));
|
mInputMode.setTextFieldCase(textField.determineTextCase(inputType));
|
||||||
mInputMode.determineNextWordTextCase(textField.isThereText(), textField.getTextBeforeCursor());
|
mInputMode.determineNextWordTextCase(textField.getTextBeforeCursor());
|
||||||
|
|
||||||
resetKeyRepeat();
|
resetKeyRepeat();
|
||||||
}
|
}
|
||||||
|
|
@ -779,12 +783,12 @@ public class TraditionalT9 extends KeyPadHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean shouldBeVisible() {
|
protected boolean shouldBeVisible() {
|
||||||
return !mInputMode.isPassthrough() && isActive;
|
return !getInputMode().isPassthrough();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean shouldBeOff() {
|
protected boolean shouldBeOff() {
|
||||||
return currentInputConnection == null || !isActive || mInputMode.isPassthrough();
|
return currentInputConnection == null || mInputMode.isPassthrough();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -59,19 +59,6 @@ public class AppHacks {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* isMessengerLite
|
|
||||||
* Facebook Messenger Lite does not support sending messages with OK/ENTER. To enable that, we
|
|
||||||
* detect the chat field and apply the proper series of commands to it. See "onFbMessengerEnter()" for info how the hack works.
|
|
||||||
*/
|
|
||||||
private boolean isMessengerLite() {
|
|
||||||
return isAppField(
|
|
||||||
"com.facebook.mlite",
|
|
||||||
EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE | EditorInfo.TYPE_TEXT_FLAG_CAP_SENTENCES | EditorInfo.TYPE_TEXT_FLAG_AUTO_CORRECT
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* isAppField
|
* isAppField
|
||||||
* Detects a particular input field of a particular application.
|
* Detects a particular input field of a particular application.
|
||||||
|
|
@ -125,7 +112,7 @@ public class AppHacks {
|
||||||
if (isTermux()) {
|
if (isTermux()) {
|
||||||
sendDownUpKeyEvents(KeyEvent.KEYCODE_ENTER);
|
sendDownUpKeyEvents(KeyEvent.KEYCODE_ENTER);
|
||||||
return true;
|
return true;
|
||||||
} else if (isMessenger() || isMessengerLite()) {
|
} else if (isMessenger()) {
|
||||||
return onEnterFbMessenger();
|
return onEnterFbMessenger();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -196,17 +183,8 @@ public class AppHacks {
|
||||||
// Messenger responds only to ENTER, but not DPAD_CENTER, so we make sure to send the correct code,
|
// Messenger responds only to ENTER, but not DPAD_CENTER, so we make sure to send the correct code,
|
||||||
// no matter how the hardware key is implemented.
|
// no matter how the hardware key is implemented.
|
||||||
sendDownUpKeyEvents(KeyEvent.KEYCODE_ENTER);
|
sendDownUpKeyEvents(KeyEvent.KEYCODE_ENTER);
|
||||||
} else {
|
|
||||||
// Messenger Lite responds to no key codes, so we trick it by going right to the Send button, pressing it,
|
|
||||||
// then going back to the chat field.
|
|
||||||
sendDownUpKeyEvents(KeyEvent.KEYCODE_DPAD_RIGHT);
|
|
||||||
sendDownUpKeyEvents(KeyEvent.KEYCODE_DPAD_RIGHT);
|
|
||||||
sendDownUpKeyEvents(KeyEvent.KEYCODE_DPAD_CENTER);
|
|
||||||
sendDownUpKeyEvents(KeyEvent.KEYCODE_DPAD_LEFT);
|
|
||||||
sendDownUpKeyEvents(KeyEvent.KEYCODE_DPAD_LEFT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,7 @@ abstract public class InputMode {
|
||||||
textCase = allowedTextCases.get(nextIndex);
|
textCase = allowedTextCases.get(nextIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void determineNextWordTextCase(boolean isThereText, String textBeforeCursor) {}
|
public void determineNextWordTextCase(String textBeforeCursor) {}
|
||||||
|
|
||||||
// Based on the internal logic of the mode (punctuation or grammar rules), re-adjust the text case for when getSuggestions() is called.
|
// Based on the internal logic of the mode (punctuation or grammar rules), re-adjust the text case for when getSuggestions() is called.
|
||||||
protected String adjustSuggestionTextCase(String word, int newTextCase) { return word; }
|
protected String adjustSuggestionTextCase(String word, int newTextCase) { return word; }
|
||||||
|
|
|
||||||
|
|
@ -295,8 +295,8 @@ public class ModePredictive extends InputMode {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void determineNextWordTextCase(boolean isThereText, String textBeforeCursor) {
|
public void determineNextWordTextCase(String textBeforeCursor) {
|
||||||
textCase = autoTextCase.determineNextWordTextCase(isThereText, textCase, textFieldTextCase, textBeforeCursor);
|
textCase = autoTextCase.determineNextWordTextCase(textCase, textFieldTextCase, textBeforeCursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ public class AutoTextCase {
|
||||||
* For example, this function will return CASE_LOWER by default, but CASE_UPPER at the beginning
|
* For example, this function will return CASE_LOWER by default, but CASE_UPPER at the beginning
|
||||||
* of a sentence.
|
* of a sentence.
|
||||||
*/
|
*/
|
||||||
public int determineNextWordTextCase(boolean isThereText, int currentTextCase, int textFieldTextCase, String textBeforeCursor) {
|
public int determineNextWordTextCase(int currentTextCase, int textFieldTextCase, String textBeforeCursor) {
|
||||||
if (
|
if (
|
||||||
// When the setting is off, don't do any changes.
|
// When the setting is off, don't do any changes.
|
||||||
!settings.getAutoTextCase()
|
!settings.getAutoTextCase()
|
||||||
|
|
@ -60,7 +60,7 @@ public class AutoTextCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
// start of text
|
// start of text
|
||||||
if (!isThereText) {
|
if (textBeforeCursor.isEmpty()) {
|
||||||
return InputMode.CASE_CAPITALIZE;
|
return InputMode.CASE_CAPITALIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue