zawadz88 / MaterialPopupMenu

Shows Material popup menus grouped in sections & more
Apache License 2.0
645 stars 59 forks source link

Request: offer a more generic popup window #65

Open AndroidDeveloperLB opened 5 years ago

AndroidDeveloperLB commented 5 years ago

Sometimes we would like to have our own very customized view to show in the popup.

Please offer what you have today, with the nice alignment , auto-positioning etc... - for a more generic popup.

zawadz88 commented 5 years ago

Hi, You can in theory create a popup menu with a single customItem and put your custom view there. Wouldn't that work for you?

What more would you like to do?

AndroidDeveloperLB commented 5 years ago

This has multiple issues that I've found, probably not all related to here (because that's the first time I try this library in years ) :

  1. It wraps what I provide with its popup style (meaning like a CardView). Doesn't matter much. I want to have a CardView style popup anyway.
  2. I can't have a reference to the generated view, so I can't assign OnClickListener to any of its views, for example. I can't even assign a text (programmatically) to one of the TextViews in the layout.
  3. When used in a RecyclerView, I don't see how to put it near where I touched, similar to ContextMenu class (see here what I'm talking about) , and it might cause scrolling of the RecyclerView when I click at the bottom.

See attached video and sample project:

2019-08-01_16-06-13.zip MyApplication.zip

Sadly I do have to use minSdk as 16 . Why did you have a jump to 19 ? All Android libraries are for at least 16 . Not 19... :(

zawadz88 commented 5 years ago

Sadly I do have to use minSdk as 16 . Why did you have a jump to 19 ? All Android libraries are for at least 16 . Not 19... :(

Well, 4.1-4.3 accounts for 3% of users and this number is diminishing. I'm not sure that ALL Android libraries are min 16 ;) Supporting older versions also costs time. You are free to fork the library and change min SDK to 16 and see if it still works. No guarantees though.

I can't have a reference to the generated view, so I can't assign OnClickListener to any of its views, for example. I can't even assign a text (programmatically) to one of the TextViews in the layout.

You can when using customItem + viewBoundCallback. Please see the sample app for how this can be used.

When used in a RecyclerView, I don't see how to put it near where I touched, similar to ContextMenu class (see here what I'm talking about) , and it might cause scrolling of the RecyclerView when I click at the bottom.

This is actually not a feature of this library - it only binds itself to the views and not touch location. You might try calculating the offsets and using them to construct the popup menu with dropDownVerticalOffset and dropDownHorizontalOffset

AndroidDeveloperLB commented 5 years ago

Well 3% out of at least 2.5 active devices is still a lot, and the support library is from API 14. The only ones that's from 16 are of something related to Admob or other Google services. What did you need to use, that you switched to 19?

Sadly this library uses a syntax I'm not aware of, instead of normal function calls, so it's harder to see what's available this way. Anyway, I got it working this way now. Seems though that it has a minimal size allowed. It doesn't bother me much because it's quite small anyway, but this shows that it's not a good solution for a customized view. See attached video and project:

2019-08-01_16-06-13.zip MyApplication.zip

About the bugs, why do you say it's a feature? Scrolling on its own is a feature? Why should it scroll? For the touch, it's supposed to be an alternative to what we have, and what we have does handle where the touch was handled, so it's missing an important function... Imagine that when you show a context menu of a selected text, it will show relative to the TextView, and not to its content...

Please, if you think it's easy, can you please update the samples to show how to deal with those?

zawadz88 commented 5 years ago

About the bugs, why do you say it's a feature? Scrolling on its own is a feature? Why should it scroll?

I was referring to the click location, I missed the part about scrolling issue.

For the touch, it's supposed to be an alternative to what we have, and what we have does handle where the touch was handled, so it's missing an important function... Imagine that when you show a context menu of a selected text, it will show relative to the TextView, and not to its content...

I'm not sure if I understand this but basically you would like this component to behave like a ContextMenu? https://developer.android.com/guide/topics/ui/menus

I'm not sure if it's possible to have it behave like that out of the box. At least I don't see a way, but I'll welcome any contributions regarding this!

Regarding dropping support below API 19 - as explained in comment before supporting older OS version costs time. You need to test before each release on each version. The projects I'm working on are API 21+ actually and most project I know are API 19 at minimum. Again feel free to fork the library if you need API 16 support or you can use an older version of the library (3.4.0) - https://github.com/zawadz88/MaterialPopupMenu/blob/master/CHANGELOG.md

AndroidDeveloperLB commented 5 years ago

OK got it except the touch issue, using the support library and a workaround . Min API 14.

Repository here, if you want to look at: https://github.com/AndroidDeveloperLB/customized-popup-window-sample