On-screen keyboard improvements (#323)
* holding a number key to type a number in text modes is now possible using the on-screen keyboard * accented letters are no longer displayed on the on-screen keyboard, just plain A-Z * the on-screen keyboard is now more compact; * improved color scheme and other small visual enhancements
This commit is contained in:
parent
d4c6467da3
commit
c6edb5a726
8 changed files with 121 additions and 87 deletions
|
|
@ -12,13 +12,11 @@ public class Language {
|
|||
protected String name;
|
||||
protected Locale locale;
|
||||
protected String dictionaryFile;
|
||||
protected boolean hasUpperCase = true;
|
||||
protected String abcString;
|
||||
protected final ArrayList<ArrayList<String>> layout = new ArrayList<>();
|
||||
private final HashMap<Character, String> characterKeyMap = new HashMap<>();
|
||||
|
||||
// settings
|
||||
protected boolean hasUpperCase = true;
|
||||
|
||||
|
||||
public static Language fromDefinition(LanguageDefinition definition) throws Exception {
|
||||
if (definition.dictionaryFile.isEmpty()) {
|
||||
|
|
@ -149,6 +147,25 @@ public class Language {
|
|||
return hasUpperCase;
|
||||
}
|
||||
|
||||
/**
|
||||
* isLatinBased
|
||||
* Returns "true" when the language is based on the Latin alphabet or "false" otherwise.
|
||||
* WARNING: This performs somewhat resource-intensive operations every time, so consider
|
||||
* caching the result.
|
||||
*/
|
||||
public boolean isLatinBased() {
|
||||
ArrayList<String> letters = getKeyCharacters(2, false);
|
||||
return letters.contains("a");
|
||||
}
|
||||
|
||||
/**
|
||||
* isGreek
|
||||
* Similar to "isLatinBased()", this returns "true" when the language is based on the Greek alphabet.
|
||||
*/
|
||||
public boolean isGreek() {
|
||||
ArrayList<String> letters = getKeyCharacters(2, false);
|
||||
return letters.contains("α");
|
||||
}
|
||||
|
||||
/* ************ utility ************ */
|
||||
|
||||
|
|
|
|||
|
|
@ -72,13 +72,19 @@ class MainLayoutNumpad extends BaseMainLayout {
|
|||
}
|
||||
}
|
||||
|
||||
ViewGroup statusBarContainer = view.findViewById(R.id.status_bar_container);
|
||||
keys.addAll(getKeysFromContainer(statusBarContainer));
|
||||
|
||||
return keys;
|
||||
}
|
||||
|
||||
protected ArrayList<View> getSeparators() {
|
||||
// it's fine... it's shorter, faster and easier to read than searching with 3 nested loops
|
||||
return new ArrayList<>(Arrays.asList(
|
||||
view.findViewById(R.id.separator_0),
|
||||
view.findViewById(R.id.separator_top),
|
||||
view.findViewById(R.id.separator_candidates_1),
|
||||
view.findViewById(R.id.separator_candidates_2),
|
||||
view.findViewById(R.id.separator_candidates_bottom),
|
||||
view.findViewById(R.id.separator_1_1),
|
||||
view.findViewById(R.id.separator_1_2),
|
||||
view.findViewById(R.id.separator_2_1),
|
||||
|
|
|
|||
|
|
@ -136,7 +136,6 @@ public class SoftKey extends androidx.appcompat.widget.AppCompatButton implement
|
|||
int keyId = getId();
|
||||
|
||||
if (keyId == R.id.soft_key_add_word) return tt9.onKeyAddWord();
|
||||
if (keyId == R.id.soft_key_clear_filter) return tt9.onKeyFilterClear();
|
||||
if (keyId == R.id.soft_key_filter_suggestions) return tt9.onKeyFilterSuggestions(repeat);
|
||||
if (keyId == R.id.soft_key_left_arrow) return tt9.onKeyPreviousSuggestion();
|
||||
if (keyId == R.id.soft_key_right_arrow) return tt9.onKeyNextSuggestion();
|
||||
|
|
|
|||
|
|
@ -28,13 +28,13 @@ public class SoftNumberKey extends SoftKey {
|
|||
|
||||
@Override
|
||||
protected boolean handleHold() {
|
||||
if (tt9 == null || tt9.getInputMode() != InputMode.MODE_123 || getId() != R.id.soft_key_0) {
|
||||
if (tt9 == null) {
|
||||
return super.handleHold();
|
||||
}
|
||||
|
||||
preventRepeat();
|
||||
int zeroCode = Key.numberToCode(0);
|
||||
tt9.onKeyLongPress(zeroCode, new KeyEvent(KeyEvent.ACTION_DOWN, zeroCode));
|
||||
int keyCode = Key.numberToCode(getNumber(getId()));
|
||||
tt9.onKeyLongPress(keyCode, new KeyEvent(KeyEvent.ACTION_DOWN, keyCode));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -95,11 +95,24 @@ public class SoftNumberKey extends SoftKey {
|
|||
return "";
|
||||
}
|
||||
|
||||
boolean isLatinBased = language.isLatinBased();
|
||||
boolean isGreekBased = language.isGreek();
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
ArrayList<String> chars = language.getKeyCharacters(number, false);
|
||||
for (int i = 0; i < 5 && i < chars.size(); i++) {
|
||||
String currentLetter = chars.get(i);
|
||||
if (
|
||||
(isLatinBased && currentLetter.charAt(0) > 'z')
|
||||
|| (isGreekBased && (currentLetter.charAt(0) < 'α' || currentLetter.charAt(0) > 'ω'))
|
||||
) {
|
||||
// As suggested by the community, there is no need to display the accented letters.
|
||||
// People are used to seeing just A-Z.
|
||||
continue;
|
||||
}
|
||||
|
||||
sb.append(
|
||||
tt9.getTextCase() == InputMode.CASE_UPPER ? chars.get(i).toUpperCase(language.getLocale()) : chars.get(i)
|
||||
tt9.getTextCase() == InputMode.CASE_UPPER ? currentLetter.toUpperCase(language.getLocale()) : currentLetter
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue