fixed typing the preferred instead of the selected special character, when pressing 0, scrolling the suggestions, then pressing 0 again
This commit is contained in:
parent
433d5f401a
commit
934dda0620
1 changed files with 11 additions and 2 deletions
|
|
@ -432,10 +432,19 @@ public class ModePredictive extends InputMode {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldAcceptPreviousSuggestion(int nextKey) {
|
public boolean shouldAcceptPreviousSuggestion(int nextKey) {
|
||||||
|
final char SPECIAL_CHARS_KEY = NaturalLanguage.SPECIAL_CHARS_KEY.charAt(0);
|
||||||
|
|
||||||
|
// Prevent typing the preferred character when the user has scrolled the special char suggestions.
|
||||||
|
// For example, it makes more sense to allow typing "+ " with 0 + scroll + 0, instead of clearing
|
||||||
|
// the "+" and replacing it with the preferred character.
|
||||||
|
if (!stem.isEmpty() && nextKey == SPECIAL_CHARS_KEY - '0' && digitSequence.charAt(0) == SPECIAL_CHARS_KEY) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
!digitSequence.isEmpty() && (
|
!digitSequence.isEmpty() && (
|
||||||
(nextKey == 0 && digitSequence.charAt(digitSequence.length() - 1) != '0')
|
(nextKey == 0 && digitSequence.charAt(digitSequence.length() - 1) != SPECIAL_CHARS_KEY)
|
||||||
|| (nextKey != 0 && digitSequence.charAt(digitSequence.length() - 1) == '0')
|
|| (nextKey != 0 && digitSequence.charAt(digitSequence.length() - 1) == SPECIAL_CHARS_KEY)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue