big code cleanup
This commit is contained in:
parent
0fd7a97739
commit
3e03968609
12 changed files with 17 additions and 43 deletions
|
|
@ -154,7 +154,6 @@ abstract public class CommandHandler extends TextEditingHandler {
|
|||
determineTextCase();
|
||||
}
|
||||
|
||||
suggestionOps.setInputMode(mInputMode);
|
||||
settings.saveInputMode(mInputMode.getId());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -73,7 +73,6 @@ public abstract class TypingHandler extends KeyPadHandler {
|
|||
mInputMode = determineInputMode();
|
||||
determineTextCase();
|
||||
suggestionOps.set(null);
|
||||
suggestionOps.setInputMode(mInputMode);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -91,7 +90,6 @@ public abstract class TypingHandler extends KeyPadHandler {
|
|||
// changing the TextField and notifying all interested classes is an atomic operation
|
||||
appHacks = new AppHacks(inputType, textField, textSelection);
|
||||
suggestionOps.setTextField(textField);
|
||||
suggestionOps.setInputMode(mInputMode);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ abstract class UiHandler extends AbstractHandler {
|
|||
|
||||
|
||||
protected void setStatusIcon(InputMode mode, Language language) {
|
||||
int resId = new StatusIcon(this, settings, mode, language).resourceId;
|
||||
int resId = new StatusIcon(settings, mode, language).resourceId;
|
||||
if (resId == 0) {
|
||||
hideStatusIcon();
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -8,10 +8,8 @@ import androidx.annotation.Nullable;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import io.github.sspanak.tt9.ime.modes.InputMode;
|
||||
import io.github.sspanak.tt9.languages.Language;
|
||||
import io.github.sspanak.tt9.languages.LanguageKind;
|
||||
import io.github.sspanak.tt9.languages.NullLanguage;
|
||||
import io.github.sspanak.tt9.preferences.settings.SettingsStore;
|
||||
import io.github.sspanak.tt9.ui.main.ResizableMainView;
|
||||
import io.github.sspanak.tt9.ui.tray.SuggestionsBar;
|
||||
|
|
@ -23,9 +21,6 @@ public class SuggestionOps {
|
|||
@NonNull private final Handler delayedAcceptHandler;
|
||||
@NonNull private final ConsumerCompat<String> onDelayedAccept;
|
||||
|
||||
@Nullable private InputMode inputMode;
|
||||
@NonNull private Language language;
|
||||
@Nullable private final SettingsStore settings;
|
||||
@Nullable protected SuggestionsBar suggestionBar;
|
||||
@NonNull private TextField textField;
|
||||
|
||||
|
|
@ -34,8 +29,6 @@ public class SuggestionOps {
|
|||
delayedAcceptHandler = new Handler(Looper.getMainLooper());
|
||||
this.onDelayedAccept = onDelayedAccept != null ? onDelayedAccept : s -> {};
|
||||
|
||||
language = new NullLanguage();
|
||||
this.settings = settings;
|
||||
this.textField = textField != null ? textField : new TextField(null, null, null);
|
||||
|
||||
if (settings != null && mainView != null && onSuggestionClick != null) {
|
||||
|
|
@ -43,16 +36,9 @@ public class SuggestionOps {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public void setInputMode(@Nullable InputMode inputMode) {
|
||||
this.inputMode = inputMode;
|
||||
}
|
||||
|
||||
|
||||
public void setLanguage(@Nullable Language language) {
|
||||
this.language = language == null ? new NullLanguage() : language;
|
||||
public void setLanguage(@Nullable Language newLanguage) {
|
||||
if (suggestionBar != null) {
|
||||
suggestionBar.setRTL(LanguageKind.isRTL(language));
|
||||
suggestionBar.setRTL(LanguageKind.isRTL(newLanguage));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,8 +32,4 @@ public class InputModeKind {
|
|||
mode.getId() == InputMode.MODE_KATAKANA
|
||||
);
|
||||
}
|
||||
|
||||
public static boolean isCheonjiin(InputMode mode) {
|
||||
return mode != null && mode.getClass().equals(ModeCheonjiin.class);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package io.github.sspanak.tt9.ime.modes;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
|
@ -56,15 +55,15 @@ class Mode123 extends ModePassthrough {
|
|||
private void setDefaultSpecialCharacters() {
|
||||
Language english = LanguageCollection.getByLocale("en");
|
||||
KEY_CHARACTERS.add(
|
||||
TextTools.removeLettersFromList(orderCharsForNumericField(settings.getOrderedKeyChars(english, 0), null))
|
||||
TextTools.removeLettersFromList(orderCharsForNumericField(settings.getOrderedKeyChars(english, 0)))
|
||||
);
|
||||
KEY_CHARACTERS.add(
|
||||
TextTools.removeLettersFromList(orderCharsForNumericField(settings.getOrderedKeyChars(english, 1), null))
|
||||
TextTools.removeLettersFromList(orderCharsForNumericField(settings.getOrderedKeyChars(english, 1)))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
private ArrayList<String> orderCharsForNumericField(@NonNull ArrayList<String> unordered, @Nullable ArrayList<String> o) {
|
||||
private ArrayList<String> orderCharsForNumericField(@NonNull ArrayList<String> unordered) {
|
||||
ArrayList<String> ordered = new ArrayList<>();
|
||||
|
||||
if (unordered.contains(".")) {
|
||||
|
|
|
|||
|
|
@ -135,8 +135,6 @@ public class AutoSpace {
|
|||
* Similar to "shouldAddAfterPunctuation()", but determines whether to add a space after words.
|
||||
*/
|
||||
private boolean shouldAddAfterWord(boolean isWordAcceptedManually, String previousChars, Text nextChars, int nextKey) {
|
||||
char firstNextChar = nextChars.isEmpty() ? 0 : nextChars.toString().charAt(0);
|
||||
|
||||
return
|
||||
isWordAcceptedManually // Do not add space when auto-accepting words, because it feels very confusing when typing.
|
||||
&& isLanguageWithAlphabet
|
||||
|
|
|
|||
|
|
@ -115,8 +115,12 @@ public class PopupBuilder {
|
|||
}
|
||||
|
||||
|
||||
public Dialog show() {
|
||||
return DeviceInfo.AT_LEAST_ANDROID_12 ? builder12.show() : builderLegacy.show();
|
||||
public void show() {
|
||||
if (DeviceInfo.AT_LEAST_ANDROID_12) {
|
||||
builder12.show();
|
||||
} else {
|
||||
builderLegacy.show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -3,10 +3,6 @@ package io.github.sspanak.tt9.util.colors;
|
|||
public class SystemColor {
|
||||
protected int color;
|
||||
|
||||
protected SystemColor(int color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public SystemColor() {
|
||||
color = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ public class SystemSettings {
|
|||
/**
|
||||
* Even though the background changes automatically on Android 15, thanks to edge-to-edge,
|
||||
* the text/icon color remains the device default. This function allows us to change it.
|
||||
* @see: <a href="https://stackoverflow.com/a/77240330">the only working solution</a>.
|
||||
* {@code @see:} <a href="https://stackoverflow.com/a/77240330">the only working solution</a>.
|
||||
*/
|
||||
public static void setNavigationBarDarkTheme(@Nullable Window window, boolean dark) {
|
||||
if (!DeviceInfo.AT_LEAST_ANDROID_11) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue