Browse Source

fix for progressbars on pre lollipop and post ics for seekbar thumbs

Andy Scherzinger 9 years ago
parent
commit
71f68b4c8c

+ 1 - 0
res/layout/file_preview.xml

@@ -59,6 +59,7 @@
    	    android:layout_width="match_parent"
    	    android:layout_height="wrap_content"
    	    android:layout_alignParentBottom="true"
+		android:layout_margin="16dp"
    	    />
 
 </RelativeLayout>

+ 4 - 0
src/com/owncloud/android/media/MediaControlView.java

@@ -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);
         }

+ 1 - 0
src/com/owncloud/android/ui/fragment/FileDetailFragment.java

@@ -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);
         }

+ 5 - 5
src/com/owncloud/android/ui/preview/FileDownloadFragment.java

@@ -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;
     }
     
 

+ 33 - 0
src/com/owncloud/android/utils/DisplayUtils.java

@@ -35,11 +35,15 @@ import java.util.Vector;
 import android.annotation.TargetApi;
 import android.app.Activity;
 import android.content.Context;
+import android.graphics.Color;
 import android.graphics.Point;
+import android.graphics.PorterDuff;
 import android.os.Build;
 import android.text.format.DateUtils;
 import android.view.Display;
 import android.webkit.MimeTypeMap;
+import android.widget.ProgressBar;
+import android.widget.SeekBar;
 
 import com.owncloud.android.MainApp;
 import com.owncloud.android.R;
@@ -373,4 +377,33 @@ public class DisplayUtils {
         return size;
     }
 
+    /**
+     * sets the coloring of the given progress bar to color_accent.
+     *
+     * @param progressBar the progress bar to be colored
+     */
+    public static void colorPreLollipopHorizontalProgressBar(ProgressBar progressBar) {
+        if (progressBar != null && Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
+            int color = progressBar.getResources().getColor(R.color.color_accent);
+            progressBar.getIndeterminateDrawable().setColorFilter(color, PorterDuff.Mode.SRC_IN);
+            progressBar.getProgressDrawable().setColorFilter(color, PorterDuff.Mode.SRC_IN);
+        }
+    }
+
+    /**
+     * sets the coloring of the given seek bar to color_accent.
+     *
+     * @param seekBar the seek bar to be colored
+     */
+    public static void colorPreLollipopHorizontalSeekBar(SeekBar seekBar) {
+        if (seekBar != null && Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
+            colorPreLollipopHorizontalProgressBar(seekBar);
+
+            if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
+                int color = seekBar.getResources().getColor(R.color.color_accent);
+                seekBar.getThumb().setColorFilter(color, PorterDuff.Mode.SRC_IN);
+                seekBar.getThumb().setColorFilter(color, PorterDuff.Mode.SRC_IN);
+            }
+        }
+    }
 }