Status Update
Comments
wa...@google.com <wa...@google.com>
li...@google.com <li...@google.com> #2
Forgot to add a sample code! Here it goes:
SelectionContainer {
LazyColumn {
items(100) {
Text("Line number $it")
}
}
}
A normal column works without any issues (expected since everything is composed unlike the LazyColumn).
Edit to give more details about my use case: I'm trying to show the lines of a text document in my app, so using a column is not an option as the files can be quite large.
ad...@gmail.com <ad...@gmail.com> #3
Sean, would you be able to take the first stab at it and see what's needed?
ap...@google.com <ap...@google.com> #4
This happens because the nodes containing selection are removed from the composition when they're scrolled out of view, which causes the selection container to stop tracking them. This is one of the use cases for
li...@google.com <li...@google.com> #5
BasicText
to pin itself when it's participating in selection.
ad...@gmail.com <ad...@gmail.com> #6
It'd be interesting to test how it can affect performance when selecting large number of lines.
ad...@gmail.com <ad...@gmail.com> #7
Just tried beta3. The crash is now fixed ! Thanks.
However, the Popup always appears at the top of the screen instead of at the proper location. I'll try to put together a small project on github to demonstrate/reproduce the issue.
pn...@gmail.com <pn...@gmail.com> #8
Unfortunately, this fix seems to cause EmojiPicker to crash when embedded into an IME:
android.view.WindowManager$BadTokenException: Unable to add window -- token null is not valid; is your activity running?
at android.view.ViewRootImpl.setView(ViewRootImpl.java:931)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:387)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:95)
at android.widget.PopupWindow.invokePopup(PopupWindow.java:1577)
at android.widget.PopupWindow.showAtLocation(PopupWindow.java:1343)
at android.widget.PopupWindow.showAtLocation(PopupWindow.java:1309)
at androidx.emoji2.emojipicker.EmojiViewHolder.showPopupWindow(EmojiViewHolder.kt:114)
at androidx.emoji2.emojipicker.EmojiViewHolder.onEmojiLongClickListener$lambda$0(EmojiViewHolder.kt:41)
at androidx.emoji2.emojipicker.EmojiViewHolder.$r8$lambda$4L5z_x3hpOEoRlrrYk9cvuxGptg(Unknown Source:0)
at androidx.emoji2.emojipicker.EmojiViewHolder$$ExternalSyntheticLambda0.onLongClick(Unknown Source:4)
at android.view.View.performLongClickInternal(View.java:7339)
at android.view.View.performLongClick(View.java:7297)
at android.view.View.performLongClick(View.java:7315)
at android.view.View$CheckForLongPress.run(View.java:27850)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Here's a super simple demo:
li...@google.com <li...@google.com> #9
li...@google.com <li...@google.com> #10
li...@google.com <li...@google.com> #11
To summarize the issue. Previously, we use emojiView as the parent of the popup view, this works fine with the sample app and embedding into an IME, however, this doesn't work with the nested popup view (embedding emoji picker into a popup view). After we use the inflated popupview as the parent of the popup view, this works fine with the sample app and embedding into a popup view, however, this doesn't work with embedding into an IME.
Logically, we should use the emojiView as the parent of the popup view, so we can anchor the popup view to the correct position. However, when we embed the emoji picker in the popup view, calling the #showAtLocation() with emojiView throws the WindowManagerGlobal.ADD_BAD_SUBWINDOW_TOKEN which is returned in
ap...@google.com <ap...@google.com> #12
Branch: androidx-main
commit 1e86716f0b8c73378c977e12d5c20d09fa44caad
Author: Lin Guo <linguo@google.com>
Date: Fri Jul 14 00:54:48 2023
Catch the WindowManager.BadTokenException when using EmojiPickerView
inside a popup
Test: manual
Bug: 278306916
Change-Id: I0a1443025e80328fc33f8172612689b3d9017296
M emoji2/emoji2-emojipicker/src/main/java/androidx/emoji2/emojipicker/EmojiViewHolder.kt
ad...@gmail.com <ad...@gmail.com> #13
Hi, With rc1 the feature is broken and displays 'Don't use EmojiPickerView inside a Popup'.
However using EmojiPickerView inside a popup is (in my opinion) the major and most valuable use-case for EmojiPickerView.
Docking EmojiPickerView at the bottom of the screen as a 'fake soft keyboard' leads to a bad user experience, especially on larger screens (tablets, foldables, laptops etc): When adding reactions to content, it forces the user to look away from the content.
Note that on larger screens, competing reaction-system usually allow to pick a emoji from a popup that opens near the content that is being reacted-to.
I attached a few examples of Apple implementation.
It would be awesome if Google could provide an equivalent for Android, and EmojiPickerView is almost it :) So please consider supporting EmojiPickerView in a popup, or provide guidance for a similar feature.
wa...@google.com <wa...@google.com> #14
Could you please put the picker view into a popup style view but not a Android popup widget?
The variant selection is using popup so if the picker view is in a popup then the nested popup will cause issues.
BTW, usually the picker view is a full screen or half screen UI on mobile phones. Are you building it on tablet which a popup style is understandably more suitable?
ad...@gmail.com <ad...@gmail.com> #15
Thanks for the answer :)
I put together a small project to reproduce the issue:
This small project also try to show that:
- When placed in a PopupWindow, the EmojiPickerView is gorgeous, fun and super useful !
- The native Android PopupWindow is very useful and implements a lot of logic that would be hard to get right if done by hand.
- Showing a Popup inside a popup with correct positioning in Android is possible and simple on API 26+.
The project shows that it would be easily possible for EmojiPickerView to support nested popups, at least for API 26+. Also, maybe it would make sense for the androidx support library, or at least for the EmojiPickerView, to support a nested popup fallback for API < 26 ?
Many thanks
li...@google.com <li...@google.com> #16
We will add this request to our planning.
Description
Component used: androidx.emoji2:emoji2-emojipicker Version used: androidx.emoji2:emoji2-emojipicker:1.4.0-beta01 Devices/Android versions reproduced on: 10,13
The following crash happens when using EmojiPickerView that is inside a Popup (in order to add an emoji reaction to content). The crash occurs when long-clicking on an emoji with a skin color selector available.