Skip to content

Commit

Permalink
no more unnecessary arrow key handling, when there is no hotkey assoc…
Browse files Browse the repository at this point in the history
…iation
  • Loading branch information
sspanak committed Aug 2, 2023
1 parent c6edb5a commit 6f049f0
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 31 deletions.
14 changes: 4 additions & 10 deletions src/io/github/sspanak/tt9/ime/KeyPadHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,9 @@ public boolean onKeyDown(int keyCode, KeyEvent event) {

return Key.isNumber(keyCode)
|| Key.isOK(keyCode)
|| Key.isHotkey(settings, keyCode) || Key.isHotkey(settings, -keyCode)
|| Key.isHotkey(settings, keyCode) || Key.isHotkey(settings, -keyCode) // press or hold a hotkey
|| (keyCode == KeyEvent.KEYCODE_POUND && onText("#"))
|| (keyCode == KeyEvent.KEYCODE_STAR && onText("*"))
|| ((keyCode == KeyEvent.KEYCODE_DPAD_UP || keyCode == KeyEvent.KEYCODE_DPAD_DOWN) && shouldTrackUpDown())
|| ((keyCode == KeyEvent.KEYCODE_DPAD_LEFT || keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) && shouldTrackLeftRight())
|| super.onKeyDown(keyCode, event); // let the system handle the keys we don't care about (usually, only: KEYCODE_BACK)
}

Expand Down Expand Up @@ -262,18 +260,14 @@ protected void resetKeyRepeat() {
}


// toggle handlers
abstract protected boolean shouldTrackUpDown();
abstract protected boolean shouldTrackLeftRight();

// default hardware key handlers
// hardware key handlers
abstract protected boolean onArrow(int key, boolean repeat);
abstract public boolean onBackspace();
abstract protected boolean onNumber(int key, boolean hold, int repeat);
abstract public boolean onOK();
abstract public boolean onText(String text);
abstract public boolean onText(String text); // used for "#", "*" and whatnot

// customized key handlers
// hotkey handlers
abstract protected boolean onKeyAddWord();
abstract protected boolean onKeyNextLanguage();
abstract protected boolean onKeyNextInputMode();
Expand Down
9 changes: 0 additions & 9 deletions src/io/github/sspanak/tt9/ime/TraditionalT9.java
Original file line number Diff line number Diff line change
Expand Up @@ -444,15 +444,6 @@ public boolean onKeyShowSettings() {
}


protected boolean shouldTrackUpDown() {
return !isSuggestionViewHidden() && mInputMode.shouldTrackUpDown();
}

protected boolean shouldTrackLeftRight() {
return !isSuggestionViewHidden() && mInputMode.shouldTrackLeftRight();
}


private boolean isSuggestionViewHidden() {
return suggestionBar == null || !suggestionBar.hasElements();
}
Expand Down
6 changes: 5 additions & 1 deletion src/io/github/sspanak/tt9/ime/helpers/Key.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@ public static boolean isNumber(int keyCode) {
public static boolean isHotkey(SettingsStore settings, int keyCode) {
return keyCode == settings.getKeyAddWord()
|| keyCode == settings.getKeyBackspace()
|| keyCode == settings.getKeyNextLanguage()
|| keyCode == settings.getKeyFilterClear()
|| keyCode == settings.getKeyFilterSuggestions()
|| keyCode == settings.getKeyPreviousSuggestion()
|| keyCode == settings.getKeyNextSuggestion()
|| keyCode == settings.getKeyNextInputMode()
|| keyCode == settings.getKeyNextLanguage()
|| keyCode == settings.getKeyShowSettings();
}

Expand Down
3 changes: 0 additions & 3 deletions src/io/github/sspanak/tt9/ime/modes/InputMode.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,6 @@ public void changeLanguage(Language newLanguage) {
public boolean shouldIgnoreText(String text) { return text == null || text.isEmpty(); }
public boolean shouldSelectNextSuggestion() { return false; }

public boolean shouldTrackUpDown() { return false; }
public boolean shouldTrackLeftRight() { return false; }

public void reset() {
autoAcceptTimeout = -1;
suggestions.clear();
Expand Down
6 changes: 1 addition & 5 deletions src/io/github/sspanak/tt9/ime/modes/ModeABC.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,7 @@ public void changeLanguage(Language language) {
@Override public int getSequenceLength() { return 1; }

@Override public boolean shouldAcceptPreviousSuggestion() { return autoAcceptTimeout == 0 || !shouldSelectNextLetter; }
@Override public boolean shouldTrackUpDown() { return true; }
@Override public boolean shouldTrackLeftRight() { return true; }
@Override public boolean shouldSelectNextSuggestion() {
return shouldSelectNextLetter;
}
@Override public boolean shouldSelectNextSuggestion() { return shouldSelectNextLetter; }

@Override
public void reset() {
Expand Down
3 changes: 0 additions & 3 deletions src/io/github/sspanak/tt9/ime/modes/ModePredictive.java
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,6 @@ public boolean shouldDeletePrecedingSpace(InputType inputType) {
}


@Override public boolean shouldTrackUpDown() { return true; }
@Override public boolean shouldTrackLeftRight() { return true; }

@Override public int getSequenceLength() { return digitSequence.length(); }

@NonNull
Expand Down

3 comments on commit 6f049f0

@alexknop
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this commit broke the ability to move up/down from the text box to the To: field in my messaging app. Also to move from the text box to the conversation if there was a conversation there.
Because there is no longer a check for isSuggestionViewHidden, the keyboard is going to follow onArrow()
image

@alexknop
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also cannot move left to right across text in a text box

@sspanak
Copy link
Owner Author

@sspanak sspanak commented on 6f049f0 Aug 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexknop, thanks for reporting. It's hard to test all possible scenarios when changing something. I'll fix this in the next version, I believe it's an easy one.

Meanwhile, you could go to Settings -> Keypad -> Select hotkeys and temporarily disable what is currently assigned to UP, DOWN or whichever key bothers you the most.

Edit: I have created a bug for this.

Please sign in to comment.