eltos / SimpleDialogFragments

An Android library to create dialogs with ease and handle user interaction reliably, using fragments and material design.
Apache License 2.0
119 stars 17 forks source link

Feature request - a "SimpleProgressDialog" - progress bar (the indeterminate type) #69

Closed mendhak closed 3 years ago

mendhak commented 3 years ago

Hello there, I like how simple and easy to use your library is.
I have a feature request, for a progress bar, but in a dialog.

I'm mainly interested in an indeterminate progress bar, so it just spins forever until I get rid of it. Just thinking out loud, we call the .show() on a SimpleProgressDialog. Then we start a long process in our code. Then later on we call .dismiss().

Some examples of circular progress bars can be seen here:

https://github.com/castorflex/SmoothProgressBar https://github.com/zhanghai/MaterialProgressBar

eltos commented 3 years ago

I like your idea, thank you for the proposal! The indeterminate type is straight forward to create - just a customViewDialog with an indeterminate progress bar.

Thinking out loud about an updating progress dialog: Some kind of connection between the asynchronous task and the dialog will be required to periodically update the progress bar. This must be persistent across orientation changes, so it will require some work to be reliable. One might even update the buttons after the task finished. Currently, the API only allows to en-/disabling the positive button, but it is e.g. not yet possible to hide a "cancel" button.
It is probably also desirable to provide a "SimpleAsyncTask" that can be linked to the dialog and automatically updates the progress and buttons or auto-dismisses the dialog as soon as the task finishes.

What do you think?

mendhak commented 3 years ago

I'm not very good at UI stuff so I tried to search around for what other progress libraries do; it seems they use the normal .setProgress() method which lets the caller update the code. Would that be easier, if the calling code just does a myProgressDialog.setProgress(40);?

Sorry I really don't know what's good design, you'll know better for sure. But I can see from what you're saying that an updating-type progress dialog has lots more considerations compared to indeterminate; enabling and disabling buttons dynamically, setting values.

eltos commented 3 years ago

I created MR #71 @mendhak what do you think about it?

mendhak commented 3 years ago

Wow that was pretty fast, you've done a lot and also made documentation for it!

I cloned your branch and tried playing with it in the sample app. It was easy to follow, I was able to create an indeterminate progress dialog, then dismiss it. I also tried out the bar type, I referenced the dialog and then 'later' updated its progress. The secondary progress is a nice touch too.

        SimpleProgressDialog spd = SimpleProgressDialog.bar()
                .title(R.string.login)
                .msg(R.string.creating_user_profile_wait)
                .percentage(true);

        spd.show(this, PROGRESS_DIALOG);
        spd.updateProgress(50,100);
        spd.updateSecondaryProgress(61);

It looks quite flexible and you've put a good amount of thought into it. Nicely done!

eltos commented 3 years ago

Great, I'll merge it then and publish a new version.