1
0
Fork 0

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

This commit is contained in:
sspanak 2024-07-16 14:42:02 +03:00 committed by Dimo Karaivanov
parent 96045cacc7
commit 768efb6ada
3 changed files with 13 additions and 4 deletions

View file

@ -21,6 +21,7 @@ import io.github.sspanak.tt9.ime.modes.ModePredictive;
import io.github.sspanak.tt9.languages.Language;
import io.github.sspanak.tt9.languages.LanguageCollection;
import io.github.sspanak.tt9.ui.UI;
import io.github.sspanak.tt9.util.SystemSettings;
import io.github.sspanak.tt9.util.Text;
public abstract class TypingHandler extends KeyPadHandler {
@ -30,6 +31,7 @@ public abstract class TypingHandler extends KeyPadHandler {
@NonNull protected InputType inputType = new InputType(null, null);
@NonNull protected TextField textField = new TextField(null, null);
protected SuggestionOps suggestionOps;
boolean isEnabled = false;
// input
protected ArrayList<Integer> allowedInputModes = new ArrayList<>();
@ -47,11 +49,19 @@ public abstract class TypingHandler extends KeyPadHandler {
protected boolean shouldBeOff() {
return currentInputConnection == null || mInputMode.isPassthrough();
return !isEnabled || currentInputConnection == null || mInputMode.isPassthrough();
}
@Override
protected void onInit() {
super.onInit();
isEnabled = SystemSettings.isTT9Enabled(this);
}
@Override
protected boolean onStart(InputConnection connection, EditorInfo field) {
isEnabled = SystemSettings.isTT9Enabled(this);
boolean restart = textField.equals(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.
*/
protected void forceShowWindow() {
if (isInputViewShown() || !shouldBeVisible()) {
if (isInputViewShown() || !shouldBeVisible() || shouldBeOff()) {
return;
}

View file

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