Prototik/HoloEverywhere — pull request #537 by antonyt (2013-07-11 07:40:29+00:00)
Title: HoloEverywhere ProgressBar does not use native Android progress bar drawable ids

The native Android ProgressBar has a setProgressDrawable method (and equivalent xml attribute) that lets us specify the drawables used for the progress bar. It expects a layer-list that has drawables with particular ids (android.R.id.progress and android.R.id.secondaryProgress). To set the progress of a particular type (primary vs. secondary progress), it finds the appropriate drawable and then changes its level.

The HoloEverywhere library defines its own R.id.progress and R.id.secondaryProgress ids, and the HoloEverywhere ProgressBar class refers to these. This breaks compatibility with any drawables that use the original Android ProgressBar ids since the HoloEverywhere class does not look for them. Even the progress bar drawables included inside the HoloEverywhere library use android.R.id.progress (e.g. progress_horizontal_holo_dark.xml).

In the ProgressBar.doRefreshProgress method, if it can't find the drawable specified by the id, it falls back to the containing drawable (i.e. LayerDrawable containing all progress drawables), and then calls setLevel on that instead. Calling setLevel on a LayoutDrawable changes the level of all of the children. This is why if we only change the primary progress of a HoloEverywhere ProgressBar, it still appears to work.

The problem occurs when you try to set the secondary progress independently of the primary progress. With a HoloEverywhere ProgressBar, try the following:

progressBar.setProgress(50);
progressBar.setSecondaryProgress(75);

The expected behavior is that the primary progress drawable is at 50%, and the secondary progress drawable (usually drawn under the primary drawable) is at 75%.
The actual behavior with the HoloEverywhere ProgressBar is that both drawables are at 75%.

My suggested change is to just use the native android ids and remove the custom ones. Doing so makes the above case work correctly.