AviranAbady / CookieBar2

Android library for displaying text messages, notifications and alerts at the top or bottom of the screen. A great alternative for toast and snackbar alerts.
Apache License 2.0
667 stars 74 forks source link

CookieBar does not show in a DialogFragment #31

Closed goyalish closed 3 years ago

goyalish commented 3 years ago

Hi, Great job at CookieBar.

However I am facing an issue. I have a DialogFragment that occupies full screens and when I try to show the cookieBar in it, it does not show up.

I might be wrong but I think this issue might be related to the Window of the Dialog as Dialog has its own Window, different from the Activity's, and I think you are using Activity's Window to show the CookieBar.

Looking forward to hearing from you.

AviranAbady commented 3 years ago

Hello @goyalish, I did not encouter issue with displaying cooking over Fragments, DialogFragment inherits Fragment so in principle it should work fine.

Please provide demo project if you'd like me to investigate the issue.

goyalish commented 3 years ago

@AviranAbady I agree DialogFragment extends Fragment but the issue with dialog fragments are they do not use the same window as activity or fragment. DialogFragment gets the window from Dialog instead, So there are 2 windows in case of DialogFragment, One is of Activity's and other is Dialog's. However CookieBar takes just activity. I hope this may give you some clue.

I will see If I can give you some sample, but I have tried the same in my project and getting this issue with DialogFragment and CookieBar. Hope you can try internally meanwhile. Thanks

goyalish commented 3 years ago

DialogFragmentTest.zip

AviranAbady commented 3 years ago

@goyalish it looks like DialogFragment which handles diaplay using the Dialog class is working directly with Android's WindowManager in order to place itself above all "views" (Which is understandable when displaying a pop up dialog).

In your sample project, it looks like you are misusing DialogFragment as a full screen Fragment hence forcing top layer view that covers all sub views, including Cookie views.

I would suggest using a Fragment to allow proper window management.

goyalish commented 3 years ago

Indeed DialogFragment uses another Window like I mentioned earlier. Also using DialogFragment as a full screen is a deliberate move. Yes falling back to normal fragment will use the Activity's Window and hence Cookie view will be visible. However I was expecting you to include full screen dialog case as well if possible. Anyways thanks :)

AviranAbady commented 3 years ago

@goyalish you can explore ways to get the top decor view using WindowManagerGlobal - I would not recommend it.

Issue closed.