Showing a Dialog and still delivering clicks to the background? - android

I want to show a small Custom Dialog on top of the current user activity, but have clicks to the area outside of my Dialog delivered to the background (which would be the launcher, or another activity). I tried to create a transparent base-activity and have the Dialog shown on top of it, but clicks are registered on the transparent activity and not on whatever is behind it...
I know that a Popup has a setOutsideTouchable-Method, but setting this to true just dismisses the popup, rather than delivering clicks to the background, to my knowledge...
Thanks for your help,
Nick

Based on this clarification comment you posted on another answer...
"I want the Dialog to be shown system-wide, no matter which App the user is using at the moment..."
I don't believe what you want to do is possible and I'm happy about that. :) If you were allowed to popup a little dialog box over anyone else's app and still have the user be able to interact with the current activity... then you could easily trick the user into thinking that the little popup belonged to the current app and not yours which is acting from the background.
Imagine all of the evil you could do with something like that. Prompting for the user to reenter their email password when they are in the Email.app.. and then just storing it for malicious purposes, etc.
It isn't possible.. and SHOULDN'T be possible. If you need to notify the user of something, then you should use the built-in notification system. That's why it is there! :)

You can use a PopupWindow "Dialog like" and show it for the user in top of your activity. The outside events will be delivered to the main Activity.

I can't see the deeper meaning of exploiting the using the given usability patterns of android by doing what you ask for?
It is recommended and meaningful to stick to common patterns so users don't have to adapt in basic apps. That is, unless you are working on a game:)

"I want the Dialog to be shown
system-wide, no matter which App the
user is using at the moment..."
That is what the notification system is for. It allows you to tell something to the user without interrupting him in whatever he was doing.
System wide dialog popup are evil and gladly not implemented in Android.
Use the notification system : http://developer.android.com/reference/android/app/Notification.html
Also if you are ok with only a dialog above YOUR app, then the simplest way to let the UI be still responsive while your dialog is up, is simply to recreate a dialog in a relativelayout view and display this instead of the common modal dialog.

You could switch places so that the popup is actually "behind" the initial screen, but then set the initial screen as transparent.
Edit: This would only be applicable within an application of course.

Related

Is there an accepted practice between Toasts and Snackbars? Displaying them?

In Android I can display short messages to the user either using Toasts or Snackbars.
Is there a particular standard as to which ones I should be using? All Toasts? All Snackbars? Toasts during DialogFragments and Snackbars otherwise? Is there a way to force a Snackbar to display on "top" of the rest of the screen (in the event that I don't want to pass a specific view to it)?
If you want to confirm to the user that something just happened, that something went ok etc. a Toast is the way to go I would say.
But if the user did something like for example removed an item from a list, you would want to give the user an option to Undo. It could probably be done with an alert dialog but that's also annoying for the user. To be forced to change focus and act to an alert dialog asking if it's really what the user wants to do, for example "Do you really want to delete that? No Yes".
With a SnackBar you can inform the user that the item was deleted but also provide an Undo-action. Which should put back the item into the list on click.
Look at this short video, she explains the usage of those better :)
https://www.youtube.com/watch?v=puhfMX8jb9c&list=PLWz5rJ2EKKc-lJo_RGGXL2Psr8vVCTWjM&index=5
Snackbar it's material feature, Toast - holo style.
If your application has material design, more better use Snackbar as material item(like physical peace of paper) instead semitransparent/shadowed Toast.
In comparison to real world:
How often do you see "text in air"? Newer)) But may be when you under some drugs it possible) Ghost is unreal) Due to material world, texts on papers, boards, another physical places is normal behavior.
In case of upper snack, discover this

What's the best practice/guideline to display a "please wait" message in Android?

I have an app where an action by the user sometimes causes the app to get data from the server before it can be displayed, like getting detail info for an item (the info is too large to preload it for all items) or refreshing all data.
While this is in process i don't want the user to do anything else. What is the guideline to display a "please wait" message? Ideally it should be possible for the user to cancel the request if he wants to.
I can do it with an alert dialog, but the operation usually takes just half a second to a second, and imo it looks really strange for an alert dialog to pop up just for a moment, maybe not even long enough to be able to read the message.
Another option i see is the snack bar, but it doesn't prevent the user from doing anything else or navigate away.
Is there a guideline or best practice what to do in this scenario?
I'm using Xamarin.Android, but i don't think that matters.
You can show a loading circle in place where the content being loaded will be displayed like this. When it finishes, replace the loading circle with the content.
Actually "i don't want the user to do anything else" is not acceptable in most Android design patterns. Android app should allow the user to take control of the app.
About canceling the request, you can add a cancel button near the loading circle, or add a cross inside the circle which will stop the process when being pressed. The latter is preferred.
For more patterns see this.
About progress dialog
As far as I know, progress dialog which block the user interaction is discouraged in the new Android. But I am sorry that I cannot find the reference yet, maybe somewhere in Material Design guidelines document. However, because you are the developer, it's all up to you :D.
Check out the documentation on AsyncTask.
I would do the long running task in an AsyncTask, show a ProgressDialog in it's onPreExecute method and hide it after it finised, in onPostExecute.
To prevent the user from closing the dialog you can use the Dialog.setCancelable() method.
You can define a custom layout for your Dialog and set it via the setContentView() method.

Android - Show more information on a popup

I'm developing an app that includes reviews of items and due to my design, I want to only show all the reviews in a popup window like in Google Play Store:
What should I use to create that white panel that appears over the current window and contains the necessary information? This should be simple but I'm a newbie and I can't seem to figure out what this "widget" is. Please help me if you are familiar with this so I can use this cool design pattern. Thanks.
It seems you want to display a layout as a popup in another activity.
If you want to do this using an Activity instead of a Dialog, you can do this by setting the activity's theme to android:theme="#android:style/Theme.Dialog" in the manifest - this will make the activity appear like a dialog (floating on top of whatever was underneath it).
A better way to do it would be using a DialogFragment. You can display information in the form of a popup and it will have its own lifecycle. That will be much better than displaying an activity like a dialog
Ram kiran's answer is a good one and one which I like to give also. But just so you have another option to look at you can consider PopupWindow
As stated in the docs, it is
A popup window that can be used to display an arbitrary view. The popup window is a floating container that appears on top of the current activity.
I've used this and it works out nicely in some situations. It really depends on what your exact needs are as to which will work best for you.

In-app only notifications / interactive toasts

Our Android app currently has a large number of dialog and alert boxes. I'd like to switch these to toasts, but there's a problem - some of them require the user to choose whether to view more info or just dismiss the popup. It doesn't look like there's a way to do this with toasts.
Is there any existing Android library that supports tappable toasts (i.e., you tap it and it triggers a function call to a listener in the app, sort of like a notification)? If not, is there a recommended alternative for this "tap-here-to-do-something-otherwise-I'll-just-vanish-in-a-few-seconds" UI pattern, or should I just roll my own fragment class for it?
I have to do something similar to my app so I wrote, DropViewNotification, a boiler plate to make it happen by animating the so-called notification into the screen. It doesn't do automatic dismiss as this should only act as a tool.
It accept any kind of view to make it versatile as I need to put at least two or three obvious view into it (TextView, ProgressBar, ImageView). You can switch it's content on the fly if you want to. Animation can also be customized for both showing and dismissing of the notification and the main content.
In real-life you might want to consider adding controller class to handle the display of the content and auto dismissal, etc. Hope it's of some use to you.

How to create animation for Alert dialogs?

I have an android application which uses a custom Alert Dialog for showing an image and its description.
I want to make this dialog
Pop up from center like in iPhone.
Push down to center when cancelling.
I know that it is possible by applying animations/styles.How can i make style for this purpose?How to use this?
Thanks in advance
Dialog, was defined in doc, is a small window that prompts the user to make a decision or enter additional information. A dialog does not fill the screen and is normally used for modal events that require users to take an action before they can proceed. With it's subclasses (AlertDialog, ProgressDialog, AppCompatDialog,...), they become a alert system in Android. For making more exciting when they appear/exit, we can set animation for them easily. In this tip, I provide a way to do this trick through styles resource.
http://www.devexchanges.info/2015/10/showing-dialog-with-animation-in-android.html

Categories

Resources