Use in immersive mode
CheckHelzio opened this issue ยท 6 comments
If you are in inmmersive mode without navigation and statusbar and show the Popupmenu the NavigationBar is display because the popup window gains foccus.
This can be prevented and the library can be used without exit the immersive mode at all... making MaterialRecyclerViewPopupWindow no focussable on the private method buildDropDown
Hi @CheckHelzio,
Thanks for reporting this. I'll have a look soon.
This is a bit more complicated I think as this probably shouldn't be the default behaviour.
In ListPopupWindow
(which MaterialRecyclerViewPopupWindow
is based on) there is this method:
/**
* Set whether this window should be modal when shown.
*
* <p>If a popup window is modal, it will receive all touch and key input.
* If the user touches outside the popup window's content area the popup window
* will be dismissed.
*
* @param modal {@code true} if the popup window should be modal, {@code false} otherwise.
*/
public void setModal(boolean modal) {
mModal = modal;
mPopup.setFocusable(modal);
}
A similar method could be added in this library. Removing popup.isFocusable = true
from init
in MaterialRecyclerViewPopupWindow
completely has the effect you desire i.e. user does not exit immersive mode. However, this has also a side effect of the popup window not having focus -> pressing TAB key changes focus in Views under the popup window and not popup window items. Also, pressing BACK key does not close the popup window but the entire Activity.
This is a general challenge I've had with immersive mode. Anything that adds a new window (e.g. PopupWindow
, Dialog
) causes immersive mode to be exited. My understanding is that the popup would either need to not be a window (but then it can't intercept the back key automatically) or it needs to set the appropriate window flags.
To use my custom MaterialRecyclerViewPopupWindow
i need to create a package android.support.v7.widget
inside my app's java files. Everything works well, but I cannot generate a signed Apk.
The error is this:
Program type already present: android.support.v7.widget.MaterialRecyclerViewPopupWindow$Companion
Can you help me with this?
If you're adding a new class named like the one used in this library then you'll have duplicates and this won't compile. I'd suggest forking this library, making the changes that suit your needs in the forked library and compile that library. Then just use that AAR file in your project instead of referencing this library.
I solved just changing the name of that class for "MaterialRecyclerViewPopupWindow2" and everything works well, but I'll use the your approach on my next release... It's the correct way to do that.
Thank you for the answer and your time @zawadz88