Google+ Badge

Wednesday, August 30, 2017

Updating to be more in compliance with Oreo ProgressDialog deprecation

Oreo deprecated the progress dialog. That big fun thing that would dim the screen, pop-up, show the spinning circle then disappear when whatever operation was done.

The Google Material team is saying that is bad and users should be able to keep using the UI and cancel stuff. Once you target Android 26 any progress dialog usage gets flagged as a warning.

At first I was thinking "Oh man this is going to suck, I can't do that" but then I started to try getting rid of it in a few places and by damned things look a lot better. You don't have that flicker effect where the screen dims, see dialog even if for a fleeting moment, the screen brightens again. I have removed calling the progress dialog from all the places that load data so far. It is only actually referenced in one helper area. I have also replace how that helper area works and I am showing a custom dialog fragment. It looks pretty much exactly like the old ProgressDialog but now I have no warnings in my code.

The big benefit is user can cancel out of an operation if it is taking too long and move to another part of the app.

Using Retrofit was a huge advantage here as it supports cancelling network calls. Really had to tweak just a little bit of code for that to work nicely. 

Finding the proper place to put the busy indicator in the UI takes a little bit of thinking. I use Recycler Views instead of List Views so I made a very simple recycler view adapter that hosts a piece of text and the horizontal indeterminate progress indicator. I set that as the recycler view adapter while I am busy doing network stuff such as loading the details I really want to show. The user can hit the BACK button on the action bar or the button on bottom of device and I exit the activity with no issues as I just cancel network operations in onDestroy. Otherwise once I have the data I swap in the adapter that shows it.

It is really nice and clean looking and gives the user much better flexibility. Most of our network responses are pretty fast. There are a few areas we have to chain them to get all the data. It is funny watching QA hit something to start an operation then quickly try to pound the back button to make sure things cancel properly. I have some debug logging code in there so they can watch the output log to see if they truly did if fast enough. 

I am going to leave the progress dialog in place for credit card transaction processing and a few other key areas. I just can't have the user doing other things during that time. 

At first I was kind of pissed off at Google but once I got in there I totally see why they want you to stop using this UI freezer. The whole app feels cleaner and snappier. Very happy I tackled this area per the push from Google. Would love to kill it everywhere but some operations really do need to block the user from moving on.

I also cleaned up some code where the user was entering things such as an order number for look up. If they entered an order number that did not exist in the system, easy to mistype this sort of thing, they got a big pop-up "Order Not Found" dialog. I got rid of that too and just show the order was not found in the existing UI, highlight the text and have it ready for them to retry. So much less jarring to the user and it just seems so much friendlier. You are not being yelled out, just told can't find it and right back to trying again without needing to hit a CANCEL button on some dialog that is yelling at you.