Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allowing Space to insert words, cleanup on setSuggestions, remove using isThereText #347

Merged
merged 2 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/io/github/sspanak/tt9/ime/TraditionalT9.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ private void determineInputMode() {
private void determineTextCase() {
mInputMode.defaultTextCase();
mInputMode.setTextFieldCase(textField.determineTextCase(inputType));
mInputMode.determineNextWordTextCase(textField.isThereText(), textField.getTextBeforeCursor());
mInputMode.determineNextWordTextCase(textField.getTextBeforeCursor());
InputModeValidator.validateTextCase(mInputMode, settings.getTextCase());
}

Expand Down Expand Up @@ -291,7 +291,7 @@ protected boolean onNumber(int key, boolean hold, int repeat) {

// Auto-adjust the text case before each word, if the InputMode supports it.
if (getComposingText().isEmpty()) {
mInputMode.determineNextWordTextCase(textField.isThereText(), textField.getTextBeforeCursor());
mInputMode.determineNextWordTextCase(textField.getTextBeforeCursor());
}

if (!mInputMode.onNumber(key, hold, repeat)) {
Expand Down Expand Up @@ -618,7 +618,7 @@ private void handleSuggestions() {
commitCurrentSuggestion(false);
mInputMode.onAcceptSuggestion(lastComposingText, true);
autoCorrectSpace(lastComposingText, false, -1);
mInputMode.determineNextWordTextCase(textField.isThereText(), textField.getTextBeforeCursor());
mInputMode.determineNextWordTextCase(textField.getTextBeforeCursor());
}

// display the word suggestions
Expand Down Expand Up @@ -714,7 +714,7 @@ else if (mInputMode.isABC() && mInputMode.getTextCase() == InputMode.CASE_LOWER
int nextModeIndex = (allowedInputModes.indexOf(mInputMode.getId()) + 1) % allowedInputModes.size();
mInputMode = InputMode.getInstance(settings, mLanguage, inputType, allowedInputModes.get(nextModeIndex));
mInputMode.setTextFieldCase(textField.determineTextCase(inputType));
mInputMode.determineNextWordTextCase(textField.isThereText(), textField.getTextBeforeCursor());
mInputMode.determineNextWordTextCase(textField.getTextBeforeCursor());

resetKeyRepeat();
}
Expand Down
2 changes: 1 addition & 1 deletion src/io/github/sspanak/tt9/ime/modes/InputMode.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public void nextTextCase() {
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.
protected String adjustSuggestionTextCase(String word, int newTextCase) { return word; }
Expand Down
4 changes: 2 additions & 2 deletions src/io/github/sspanak/tt9/ime/modes/ModePredictive.java
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,8 @@ protected String adjustSuggestionTextCase(String word, int newTextCase) {
}

@Override
public void determineNextWordTextCase(boolean isThereText, String textBeforeCursor) {
textCase = autoTextCase.determineNextWordTextCase(isThereText, textCase, textFieldTextCase, textBeforeCursor);
public void determineNextWordTextCase(String textBeforeCursor) {
textCase = autoTextCase.determineNextWordTextCase(textCase, textFieldTextCase, textBeforeCursor);
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions src/io/github/sspanak/tt9/ime/modes/helpers/AutoTextCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public String adjustSuggestionTextCase(Language language, String word, int newTe
* For example, this function will return CASE_LOWER by default, but CASE_UPPER at the beginning
* of a sentence.
*/
public int determineNextWordTextCase(boolean isThereText, int currentTextCase, int textFieldTextCase, String textBeforeCursor) {
public int determineNextWordTextCase(int currentTextCase, int textFieldTextCase, String textBeforeCursor) {
if (
// When the setting is off, don't do any changes.
!settings.getAutoTextCase()
Expand All @@ -60,7 +60,7 @@ public int determineNextWordTextCase(boolean isThereText, int currentTextCase, i
}

// start of text
if (!isThereText) {
if (textBeforeCursor.isEmpty()) {
return InputMode.CASE_CAPITALIZE;
}

Expand Down