-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Added a progress dialog while deleting the forms. #1348
Conversation
Thanks, @srv-twry! I've tagged it as It looks like |
Don't know if this pr makes a sense since it doesn't use DialogFragment. @srv-twry you may don't know but we have started work on replacing all our dialogs using DialogFragment: |
deleteInstancesTask = null; | ||
getListView().clearChoices(); // doesn't unset the checkboxes | ||
for (int i = 0; i < getListView().getCount(); ++i) { | ||
getListView().setItemChecked(i, false); | ||
} | ||
deleteButton.setEnabled(false); | ||
|
||
//Dismiss the progress dialog. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment isn't necessary as it's obvious that progressDialog.dismiss()
dismiss the progress dialog :)
* For solving #1258. | ||
* Create the progress dialog before starting the background task. | ||
* Could have been done in the DeleteInstancesTask's onPreExecute() but was unable to get the context correctly. | ||
* */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would get rid of this comment too as it's pretty obvious what we do here. We should add comments only if something is hard to understand, tricky or fixes some strange issue. If you want to keep the code clear a better solution is to move this part of code to a separate method.
* Could have been done in the DeleteInstancesTask's onPreExecute() but was unable to get the context correctly. | ||
* */ | ||
progressDialog = new ProgressDialog(getContext()); | ||
progressDialog.setMessage("Deleting selected forms..."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it shouldn't be hardcoded, you should place it in strings.xml file
@srv-twry maybe for consistency and better user experience it should be similar to the screen shot attached showing progress with amount of files that has been already deleted, because if it takes 1.5 minute people will leave application or even worse go back. If you post progress inside DeleteInstancesTask, it shouldn't be to much effort but will be great UX. |
@Yurii-Laguta I had initially planned to implement it the same way that you are suggesting , but i was unable to get the |
I think it's appropriate to match what The progress indicator is choppy on my device, it doesn't spin smoothly. Is there processing happening on the UI thread that shouldn't be by any chance? |
The Progress dialog now correctly shows the index of the form currently being deleted. Fix #1258
@lognaturel @grzesiek2010 @Yurii-Laguta Kindly review this PR. I added an interface method which would update the dialog from time to time using the |
@@ -507,4 +507,7 @@ | |||
<string name="not_supported_offline_layer_format">Selected offline layer file uses the PBF format which is not supported!</string> | |||
<string name="sort_by">Sort by</string> | |||
<string name="server">Server</string> | |||
<string name="form_delete_message">Deleting selected forms</string> | |||
<string name="deleting_form_dialog_first">Deleting form:\u0020</string> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The dialog message should be a single string and should take in the current and total number of forms as parameters. This is important because not all languages are left-to-right and translators must have the option of repositioning the two form counts relative to each other.
Nicely done, that looks like the right approach. I made a quick comment about the string. Any ideas about the choppiness of the dialog? I noticed that it has to do with the number of forms there are to delete. If there are 1000 forms, the status indicator is really slow but as the number to delete goes down the status spinner speeds up. That seems fishy to me. It doesn't need to be handled in this PR but would be good to investigate. |
@lognaturel I have changed the |
Looks great, one minor formatting related comment. I'm surprised it's not picked up by checkstyle. |
I got the following stacktrace in debugger, although no crashes:
Steps to reproduce -
Possible solution: Dismiss the progress dialog when the activity gets paused and redisplay it on resuming the activity. |
@shobhitagarwal1612 I think the stacktrace is related to Uploading the saved forms i.e. the |
Interesting one, @shobhitagarwal1612! @srv-twry is absolutely right that this should be its own issue -- could you please file it? |
@srv-twry This should be fixed separately. I must have been confused at the time of reporting this. Thanks for noticing it. |
Issue verified on Android: 4.1, 4.4, 5.1, 6.0, 7.0. User is informed that some action is in progress, which is great. I have only doubts about the appearance of this dialog. |
@opendatakit-bot unlabel "needs testing" |
FIX #1258
Although the recommended way of obtaining this result is to create the
ProgressDialog
in theAsyncTask's
onPreExecute
method but I wasn't able to get the rightContext
for theProgressDialog
. Hence I created theProgressDialog
in theDataManagerList
class itself.