-
-
Notifications
You must be signed in to change notification settings - Fork 813
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
Ability to reorder popup characters. #1921
base: main
Are you sure you want to change the base?
Changes from 15 commits
0a5846e
1262d7d
674e1ac
1085df1
e25917c
83c3106
d097b8b
8c71e57
1afbe87
9292fcc
254add5
c3f9807
380af81
d44cebc
c16f2d5
3e71793
ece84f8
b728ef7
ceb9748
ad47846
aab7401
a0adb61
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,20 +62,11 @@ public AnyPopupKeyboard( | |
loadKeyboard(keyboardDimens); | ||
|
||
final int rowsCount = getPopupRowsCount(popupCharacters); | ||
final int popupCharactersLength = | ||
Character.codePointCount(popupCharacters, 0, popupCharacters.length()); | ||
final int keysPerRow = (int) Math.ceil((float) popupCharactersLength / (float) rowsCount); | ||
|
||
List<Key> keys = getKeys(); | ||
for (int rowIndex = rowsCount - 1; rowIndex >= 0; rowIndex--) { | ||
int baseKeyIndex = keys.size() - rowIndex - 1; | ||
addPopupKeysToList( | ||
baseKeyIndex, | ||
keyboardDimens, | ||
keys, | ||
popupCharacters, | ||
rowIndex * keysPerRow, | ||
keysPerRow); | ||
addPopupKeysToList(baseKeyIndex, keyboardDimens, keys, popupCharacters, rowIndex); | ||
} | ||
} | ||
|
||
|
@@ -84,8 +75,8 @@ private void addPopupKeysToList( | |
KeyboardDimens keyboardDimens, | ||
List<Key> keys, | ||
CharSequence popupCharacters, | ||
int characterOffset, | ||
int keysPerRow) { | ||
int characterOffset) { | ||
final int rowsCount = getPopupRowsCount(popupCharacters); | ||
int rowWidth = 0; | ||
AnyKey baseKey = (AnyKey) keys.get(baseKeyIndex); | ||
Row row = baseKey.row; | ||
|
@@ -104,10 +95,9 @@ private void addPopupKeysToList( | |
AnyKey aKey = null; | ||
final int popupCharactersLength = | ||
Character.codePointCount(popupCharacters, 0, popupCharacters.length()); | ||
for (int popupCharIndex = characterOffset + 1; | ||
popupCharIndex < characterOffset + keysPerRow | ||
&& popupCharIndex < popupCharactersLength; | ||
popupCharIndex++) { | ||
for (int popupCharIndex = characterOffset + rowsCount; | ||
popupCharIndex < popupCharactersLength; | ||
popupCharIndex += rowsCount) { | ||
x += (keyHorizontalGap / 2); | ||
|
||
aKey = new AnyKey(row, keyboardDimens); | ||
|
@@ -157,12 +147,10 @@ private static int getPopupLayout(CharSequence popupCharacters) { | |
|
||
private static int getPopupRowsCount(CharSequence popupCharacters) { | ||
final int count = Character.codePointCount(popupCharacters, 0, popupCharacters.length()); | ||
if (count <= 8) return 1; | ||
if (count <= 16) { | ||
return 2; | ||
} else { | ||
return 3; | ||
} | ||
|
||
if (count <= 3) return 1; | ||
if (count <= 12) return 2; | ||
return 3; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's strange that we do not have a unit-test for this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I could add a test-unit to test this directly, but how do I test a private method? |
||
} | ||
|
||
@Override | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any chance to add a unit-test for this?
Basically, change this setting value and see that the cached keyboards were re-created.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use the
R.string.settings_key_popup_characters_order
in the test. It is fine to use this string here in the keyboard code, but in tests we should use the value from the resources.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this enough? ad47846