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?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1921 +/- ##
============================================
+ Coverage 65.10% 65.15% +0.05%
- Complexity 3004 3023 +19
============================================
Files 237 237
Lines 15863 15903 +40
Branches 2087 2101 +14
============================================
+ Hits 10327 10362 +35
Misses 4776 4776
- Partials 760 765 +5
|
Sorry, I always forget to use the automated tests. The entirety of I'll try to fix it soon. |
I don't know if I made it clear, this works now. I fixed the bug I created with my last commit. Is there anything left to fix before merging this? |
bf7635c
to
6edc8f1
Compare
@ArenaL5 would you mind trying to rebase this? |
No problem! EDIT: Please wait a bit, somehow I lost an edit during rebase. |
This should do it. I've done all the automated tests and I tested it manually. Everything else is okay. UPDATE FROM 8TH OF MARCH: What the hell, I just clicked a button to merge changes from |
-------------------------edit---------------------------------- Hi! I was curious about this commit, so I compiled it to test it on my device. I was surprised to see how this commit breaks a symbols layout. As an example, try to use qwerty with symbols. You'll notice that none of those symbols designed for that layout will be available in the supposed order. I tried to change all the combinations with the letters If I may give you my opinion, I think I notice, though, that it doesn't afffect long press popups like this one:
So, if this PL is going to be merged, I hope there'll be a letter to preserve the current layout popup caracters order ;) |
Sorry for the late reply.
My patch is only supposed to reorder symbols in About it not working, it's possible, I haven't tested it on a long time. I'll rebase this branch and try to fix it. Thank you! I'll let you know when I know something. |
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.
ime/app/src/main/java/com/anysoftkeyboard/keyboards/AnyKeyboard.java
Outdated
Show resolved
Hide resolved
ime/app/src/main/java/com/anysoftkeyboard/keyboards/ExternalAnyKeyboard.java
Show resolved
Hide resolved
Thanks for answering back. I tested it again after rebasing. About not working. I found out it does indeed work but changes in the string do not happen straight away. They take effect after the app is cleared from recents. This can be very confusing. If someone uses some of the layouts with symbols (eg. QWERTY with symbols), after an ASK update (including this PR) he won't have easy access to those symbols on long press. And changing the settings won't work unless he clears everything in recents. With E: supposed to give I hope you find this discussion useful, otherwise just let me know and I'll leave you alone with your tests 🙂 |
@menny. Thanks for the compliment but I didn't do anything yet. I just rebased again to clean up the history. 😆 I'll try to fix those issues soon. @nicoursi: It was useful, actually. I did notice that the keyboard retained its old settings for a while, but I didn't know what to do to load the new ones. Options programmed for other people do take effect straight away, so there's probably a line of code to flush the cached keyboard. I'll investigate. |
Yes, there is a way to flush the cache. Look for other places where we react to preference changes (in the AnySoftKeyboard* classes) |
This commits also fixes a style issue at AnyKeyboardViewWithMiniKeyboard.java, and squashes two very minor bugs: - The setting for popupCharacters order was still forcibly made uppercase, interfering with the 1-character groups; - A key in a test at ExternalAnyKeyboardTest.java was not correctly checked.
Replacing info_footer.xml with actual code for an info footer that's compliant with https://developer.android.com/reference/android/preference/EditTextPreference would be appreciated.
Okay, I've been using this branch for a couple days and I see no hint of memory leakage or any breaking. I think it's good to go. @menny: Merging this branch will change how popupCharacters are laid out, as discussed earlier, but you have the final word on this. Currently, for keys on the left half on the keyboard, symbols in popupCharacters (after reordering) will be laid out in columns, bottom to top, then left to right.
For keys on the right hand, the rules are the same but the result is mirrored. If you feel another order is better or want to add a user preference just in case, please say so. If you find no problems, merge away! Merry Christmas. 🎄 |
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.
Another question: how does the reverse
value affect the currency XMLs in the app? And did you do a quick survey of if/how this will affect XMLs in various language-packs?
@@ -147,6 +147,8 @@ protected void onSharedPreferenceChange(String key) { | |||
|| key.startsWith(KeyboardExtensionFactory.BOTTOM_ROW_PREF_ID_PREFIX) | |||
|| key.startsWith(KeyboardExtensionFactory.TOP_ROW_PREF_ID_PREFIX)) { | |||
onAddOnsCriticalChange(); | |||
} else if (key.equals("settings_key_popup_characters_order")) { | |||
onAddOnsCriticalChange(); |
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
ime/app/src/main/java/com/anysoftkeyboard/keyboards/AnyKeyboard.java
Outdated
Show resolved
Hide resolved
|
||
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 comment
The 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.
Maybe in the allAddons
variant?
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.
testCodesParsing()
at ExternalAnyKeyboardTest.java
tests it indirectly.
I could add a test-unit to test this directly, but how do I test a private method?
ime/app/src/main/java/com/anysoftkeyboard/keyboards/ExternalAnyKeyboard.java
Show resolved
Hide resolved
@@ -374,6 +374,8 @@ | |||
|
|||
<string name="settings_key_allow_layouts_to_provide_generic_rows">settings_key_allow_layouts_to_provide_generic_rows</string> | |||
<string name="settings_key_apply_remote_app_colors">settings_key_apply_remote_app_colors</string> | |||
<string name="settings_key_popup_characters_order">settings_key_popup_characters_order</string> | |||
<string name="settings_key_popup_characters_order_default">NLOS</string> |
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.
the default value should be in settings_defaults_dont_translate.xml
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.
It is there. The default value is NLOS
, line 378.
Is there any other settings_defaults_dont_translate.xml
?
@@ -485,6 +485,16 @@ | |||
<string name="bottom_generic_row_dialog_title">Select row type</string> | |||
<string name="bottom_generic_row_summary">Selected bottom row: %s</string> | |||
|
|||
<string name="popup_characters_order_title">Characters shown upon long press</string> | |||
<string name="popup_characters_order_summary">Order is important. Uppercase letters represent different characters for every layout:\n |
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.
How does this long explanation look in the UI? Can you share a screenshot?
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.
Sure, here. Please excuse the Spanglish.
I don't remember the exact details, but I had to tweak a template for an info section in XML. It must be at 380af81 (“Add better instructions for the characters reordering”).
Overall, this is a great change! |
Thank you! Sorry I've been a little disappeared lately. I'll push new commits to fulfill your requests. It should take a few days to close them all. |
This commit will be squashed later.
The only difference between the Spanish and the default symbols layout is an interrobang. There should probably not be a Spanish version for the common symbols layout anyways.
…boardRxPrefs.java#L151
Answering your first question (which I didn't see at the moment):
I had only tried it with the Spanish layout, which only defines the main layout and popupCharacters (it doesn't include XML files for static popups). I'm testing now other keyboards:
I will push an extra commit to fix the emoji problem and any other layout my code breaks. |
Only two files were changed by hand in this commit: - buildSrc/src/main/java/emoji/EmojiKeyboardCreator.java - gradle/emoji_generator.gradle Every other change in this commit is the result of running ./gradlew makeEmojiKeyboards. ime/app/src/main/res/xml-v27/quick_text_unicode_uncollected.xml deleted after running that command, as it was unused.
I made more tests; apparently these commits won't break anything. The currency key in the main symbols keyboard is a normal key with popupCharacters on the left hand of the keyboard, so it doesn't even get mirrored. The main symbol is the € sign for me. The keyboards using predefined popups (most if not all of them could be changed to popupCharacters) appear correctly. Popups opened on the right half are mirrored exactly as they're supposed to do, no matter if they're defined as XML or built up from popupCharacters: Unless you remember some other popup that should not be mirrored (emojis were already taken care of), this looks good. Maybe the 16-keys keyboards, but the popups in that were already faulty (too uneven and often too wide). I propose myself to convert them to popupCharacters in a different PR; if you have a better idea, please tell me so. I think I addressed everything now. If you notice something wrong, please tell me; if you're okay with merging this, warn me first so I can clean up the history. |
2999072
to
ebc9b44
Compare
This pull request is mainly to close the issue discussed at the end of AnySoftKeyboard/LanguagePack#231. This will immediately fix #1681 and, with time, several issues in both LanguagePack and AnySoftKeyboard repos.
It's... underwhelming, because @martholomew had the perfect interface for configuring this:
But I realized I don't have the ability to implement that. The closest preference class in the Android libraries is MultiSelectListPreference, but that doesn't save the order of the checked elements. Writing event listeners for Android is already complex, and the drag-and-drop mechanism that @martholomew describes is so complex that several Maven libraries exist to implement it. And even then, we'd still have to add the checkboxes.
As I had already work half-done and I'd rather not delay this upwards of month, I implemented a very basic EditTextPreference, as seen in commit c7ba078. You can configure it from UI → Tweaks and more → Order of popup characters. I hope that this preference will be replaced for a more user-friendly one.
The instructions are very short but I think you devs will understand it pretty easily. The preference value is not case-sensitive, characters other than N, L, O, S have no effect, an empty string will disable popupCharacters altogether, and any duplicate character that would remain in the popup after reordering them all is discarded.
Besides all that, there's also fixes for some other issues, as you can see in the commit summaries (#1914, #1418, #1662) and a small addition to
README.md
.