From: Andy Scherzinger Date: Fri, 14 Aug 2015 16:55:31 +0000 (+0200) Subject: fix for progressbars on pre lollipop and post ics for seekbar thumbs X-Git-Tag: oc-android-1.8~42^2~16 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/71f68b4c8c0cae48a885a67a4b0cd8ea145132da?ds=inline fix for progressbars on pre lollipop and post ics for seekbar thumbs --- diff --git a/res/layout/file_preview.xml b/res/layout/file_preview.xml index d371e10e..2068224d 100644 --- a/res/layout/file_preview.xml +++ b/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" /> \ No newline at end of file diff --git a/src/com/owncloud/android/media/MediaControlView.java b/src/com/owncloud/android/media/MediaControlView.java index 653943b9..5f2d46d4 100644 --- a/src/com/owncloud/android/media/MediaControlView.java +++ b/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); } diff --git a/src/com/owncloud/android/ui/fragment/FileDetailFragment.java b/src/com/owncloud/android/ui/fragment/FileDetailFragment.java index 9916a3d0..68ee6771 100644 --- a/src/com/owncloud/android/ui/fragment/FileDetailFragment.java +++ b/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); } diff --git a/src/com/owncloud/android/ui/preview/FileDownloadFragment.java b/src/com/owncloud/android/ui/preview/FileDownloadFragment.java index 631a8367..dd78a039 100644 --- a/src/com/owncloud/android/ui/preview/FileDownloadFragment.java +++ b/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; } diff --git a/src/com/owncloud/android/utils/DisplayUtils.java b/src/com/owncloud/android/utils/DisplayUtils.java index 7030c87f..3ae36e44 100644 --- a/src/com/owncloud/android/utils/DisplayUtils.java +++ b/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); + } + } + } }