1
0
Fork 0

Revert "attempting to fix the 'priviliged options must be set at most once' problem"

This reverts commit 768efb6ada.
This commit is contained in:
sspanak 2024-07-18 14:55:20 +03:00 committed by Dimo Karaivanov
parent 35c956d50e
commit 71fd37e1ac
3 changed files with 4 additions and 13 deletions

View file

@ -22,7 +22,6 @@ import io.github.sspanak.tt9.ime.modes.ModePredictive;
import io.github.sspanak.tt9.languages.Language; import io.github.sspanak.tt9.languages.Language;
import io.github.sspanak.tt9.languages.LanguageCollection; import io.github.sspanak.tt9.languages.LanguageCollection;
import io.github.sspanak.tt9.ui.UI; import io.github.sspanak.tt9.ui.UI;
import io.github.sspanak.tt9.util.SystemSettings;
import io.github.sspanak.tt9.util.Text; import io.github.sspanak.tt9.util.Text;
public abstract class TypingHandler extends KeyPadHandler { public abstract class TypingHandler extends KeyPadHandler {
@ -33,7 +32,6 @@ public abstract class TypingHandler extends KeyPadHandler {
@NonNull protected TextField textField = new TextField(null, null); @NonNull protected TextField textField = new TextField(null, null);
@NonNull protected TextSelection textSelection = new TextSelection(this,null); @NonNull protected TextSelection textSelection = new TextSelection(this,null);
protected SuggestionOps suggestionOps; protected SuggestionOps suggestionOps;
boolean isEnabled = false;
// input // input
protected ArrayList<Integer> allowedInputModes = new ArrayList<>(); protected ArrayList<Integer> allowedInputModes = new ArrayList<>();
@ -51,19 +49,11 @@ public abstract class TypingHandler extends KeyPadHandler {
protected boolean shouldBeOff() { protected boolean shouldBeOff() {
return !isEnabled || currentInputConnection == null || mInputMode.isPassthrough(); return currentInputConnection == null || mInputMode.isPassthrough();
}
@Override
protected void onInit() {
super.onInit();
isEnabled = SystemSettings.isTT9Enabled(this);
} }
@Override @Override
protected boolean onStart(InputConnection connection, EditorInfo field) { protected boolean onStart(InputConnection connection, EditorInfo field) {
isEnabled = SystemSettings.isTT9Enabled(this);
boolean restart = textField.equals(connection, field); boolean restart = textField.equals(connection, field);
setInputField(connection, field); setInputField(connection, field);

View file

@ -78,7 +78,7 @@ abstract class UiHandler extends AbstractHandler {
* on how much time the restart takes, this may erase the current user input. * on how much time the restart takes, this may erase the current user input.
*/ */
protected void forceShowWindow() { protected void forceShowWindow() {
if (isInputViewShown() || !shouldBeVisible() || shouldBeOff()) { if (isInputViewShown() || !shouldBeVisible()) {
return; return;
} }

View file

@ -1,5 +1,6 @@
package io.github.sspanak.tt9.util; package io.github.sspanak.tt9.util;
import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.os.Build; import android.os.Build;
import android.os.LocaleList; import android.os.LocaleList;
@ -13,7 +14,7 @@ public class SystemSettings {
private static InputMethodManager inputManager; private static InputMethodManager inputManager;
private static String packageName; private static String packageName;
public static boolean isTT9Enabled(Context context) { public static boolean isTT9Enabled(Activity context) {
inputManager = inputManager == null ? (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE) : inputManager; inputManager = inputManager == null ? (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE) : inputManager;
packageName = packageName == null ? context.getPackageName() : packageName; packageName = packageName == null ? context.getPackageName() : packageName;