fix for progressbars on pre lollipop and post ics for seekbar thumbs
authorAndy Scherzinger <info@andy-scherzinger.de>
Fri, 14 Aug 2015 16:55:31 +0000 (18:55 +0200)
committerAndy Scherzinger <info@andy-scherzinger.de>
Fri, 14 Aug 2015 16:55:31 +0000 (18:55 +0200)
res/layout/file_preview.xml
src/com/owncloud/android/media/MediaControlView.java
src/com/owncloud/android/ui/fragment/FileDetailFragment.java
src/com/owncloud/android/ui/preview/FileDownloadFragment.java
src/com/owncloud/android/utils/DisplayUtils.java

index d371e10..2068224 100644 (file)
@@ -59,6 +59,7 @@
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
+               android:layout_margin="16dp"
            />
 
 </RelativeLayout>
\ No newline at end of file
index 653943b..5f2d46d 100644 (file)
@@ -43,6 +43,7 @@ import java.util.Formatter;
 import java.util.Locale;
 
 import com.owncloud.android.R;
+import com.owncloud.android.utils.DisplayUtils;
 
 
 /**
@@ -220,7 +221,10 @@ public class MediaControlView extends FrameLayout /* implements OnLayoutChangeLi
         if (mProgress != null) {
             if (mProgress instanceof SeekBar) {
                 SeekBar seeker = (SeekBar) mProgress;
+                DisplayUtils.colorPreLollipopHorizontalSeekBar(seeker);
                 seeker.setOnSeekBarChangeListener(this);
+            } else {
+                DisplayUtils.colorPreLollipopHorizontalProgressBar(mProgress);
             }
             mProgress.setMax(1000);
         }
index 9916a3d..68ee677 100644 (file)
@@ -133,6 +133,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
         if (mLayout == R.layout.file_details_fragment) {
             mView.findViewById(R.id.fdFavorite).setOnClickListener(this);
             ProgressBar progressBar = (ProgressBar)mView.findViewById(R.id.fdProgressBar);
+            DisplayUtils.colorPreLollipopHorizontalProgressBar(progressBar);
             mProgressListener = new ProgressListener(progressBar);
             mView.findViewById(R.id.fdCancelBtn).setOnClickListener(this);
         }
index 631a836..dd78a03 100644 (file)
@@ -38,6 +38,7 @@ import android.widget.TextView;
 
 import com.owncloud.android.lib.common.network.OnDatatransferProgressListener;
 import com.owncloud.android.lib.common.utils.Log_OC;
+import com.owncloud.android.utils.DisplayUtils;
 
 
 /**
@@ -133,12 +134,11 @@ public class FileDownloadFragment extends FileFragment implements OnClickListene
                 mIgnoreFirstSavedState = false;
             }
         }
-        
-        View view = null;
-        view = inflater.inflate(R.layout.file_download_fragment, container, false);
-        mView = view;
+
+        mView = inflater.inflate(R.layout.file_download_fragment, container, false);
         
         ProgressBar progressBar = (ProgressBar)mView.findViewById(R.id.progressBar);
+        DisplayUtils.colorPreLollipopHorizontalProgressBar(progressBar);
         mProgressListener = new ProgressListener(progressBar);
         
         (mView.findViewById(R.id.cancelBtn)).setOnClickListener(this);
@@ -156,7 +156,7 @@ public class FileDownloadFragment extends FileFragment implements OnClickListene
             setButtonsForTransferring();
         }
         
-        return view;
+        return mView;
     }
     
 
index 7030c87..3ae36e4 100644 (file)
@@ -35,11 +35,15 @@ import java.util.Vector;
 import android.annotation.TargetApi;\r
 import android.app.Activity;\r
 import android.content.Context;\r
+import android.graphics.Color;\r
 import android.graphics.Point;\r
+import android.graphics.PorterDuff;\r
 import android.os.Build;\r
 import android.text.format.DateUtils;\r
 import android.view.Display;\r
 import android.webkit.MimeTypeMap;\r
+import android.widget.ProgressBar;\r
+import android.widget.SeekBar;\r
 \r
 import com.owncloud.android.MainApp;\r
 import com.owncloud.android.R;\r
@@ -373,4 +377,33 @@ public class DisplayUtils {
         return size;\r
     }\r
 \r
+    /**\r
+     * sets the coloring of the given progress bar to color_accent.\r
+     *\r
+     * @param progressBar the progress bar to be colored\r
+     */\r
+    public static void colorPreLollipopHorizontalProgressBar(ProgressBar progressBar) {\r
+        if (progressBar != null && Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {\r
+            int color = progressBar.getResources().getColor(R.color.color_accent);\r
+            progressBar.getIndeterminateDrawable().setColorFilter(color, PorterDuff.Mode.SRC_IN);\r
+            progressBar.getProgressDrawable().setColorFilter(color, PorterDuff.Mode.SRC_IN);\r
+        }\r
+    }\r
+\r
+    /**\r
+     * sets the coloring of the given seek bar to color_accent.\r
+     *\r
+     * @param seekBar the seek bar to be colored\r
+     */\r
+    public static void colorPreLollipopHorizontalSeekBar(SeekBar seekBar) {\r
+        if (seekBar != null && Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {\r
+            colorPreLollipopHorizontalProgressBar(seekBar);\r
+\r
+            if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {\r
+                int color = seekBar.getResources().getColor(R.color.color_accent);\r
+                seekBar.getThumb().setColorFilter(color, PorterDuff.Mode.SRC_IN);\r
+                seekBar.getThumb().setColorFilter(color, PorterDuff.Mode.SRC_IN);\r
+            }\r
+        }\r
+    }\r
 }\r