Browse Source

colorize/theme only the progress, don't tint the background for the progress bar

AndyScherzinger 6 years ago
parent
commit
9560402760

+ 3 - 2
src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java

@@ -305,7 +305,7 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
         mQuotaProgressBar = (ProgressBar) findQuotaViewById(R.id.drawer_quota_ProgressBar);
         mQuotaTextPercentage = (TextView) findQuotaViewById(R.id.drawer_quota_percentage);
         mQuotaTextLink = (TextView) findQuotaViewById(R.id.drawer_quota_link);
-        ThemeUtils.colorHorizontalProgressBar(mQuotaProgressBar, ThemeUtils.primaryColor(this));
+        ThemeUtils.colorProgressBar(mQuotaProgressBar, ThemeUtils.primaryColor(this));
     }
 
     /**
@@ -818,7 +818,8 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
         }
 
         mQuotaProgressBar.setProgress(relative);
-        ThemeUtils.colorHorizontalProgressBar(mQuotaProgressBar, DisplayUtils.getRelativeInfoColor(this, relative));
+
+        ThemeUtils.colorProgressBar(mQuotaProgressBar, DisplayUtils.getRelativeInfoColor(this, relative));
 
         updateQuotaLink();
         showQuota(true);

+ 17 - 1
src/main/java/com/owncloud/android/utils/ThemeUtils.java

@@ -279,7 +279,7 @@ public class ThemeUtils {
     }
 
     /**
-     * sets the coloring of the given progress bar to color_accent.
+     * sets the coloring of the given progress bar to given color.
      *
      * @param progressBar the progress bar to be colored
      * @param color       the color to be used
@@ -291,6 +291,22 @@ public class ThemeUtils {
         }
     }
 
+    /**
+     * sets the coloring of the given progress bar's progress to given color.
+     *
+     * @param progressBar the progress bar to be colored
+     * @param color       the color to be used
+     */
+    public static void colorProgressBar(ProgressBar progressBar, @ColorInt int color) {
+        if (progressBar != null) {
+            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+                progressBar.setProgressTintList(ColorStateList.valueOf(color));
+            } else {
+                ThemeUtils.colorHorizontalProgressBar(progressBar, color);
+            }
+        }
+    }
+
     /**
      * sets the coloring of the given seek bar to color_accent.
      *