X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/7eea2ea507b41edb242cc1a2fe9eae1a9c03d280..6b84d83b3544f8de4e56186f6ecbccd3d612702b:/src/com/owncloud/android/utils/DisplayUtils.java diff --git a/src/com/owncloud/android/utils/DisplayUtils.java b/src/com/owncloud/android/utils/DisplayUtils.java index 91dfc47c..3ae36e44 100644 --- a/src/com/owncloud/android/utils/DisplayUtils.java +++ b/src/com/owncloud/android/utils/DisplayUtils.java @@ -33,10 +33,17 @@ import java.util.Set; 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; @@ -350,4 +357,53 @@ public class DisplayUtils { return path; } + + /** + * Gets the screen size in pixels in a backwards compatible way + * + * @param caller Activity calling; needed to get access to the {@link android.view.WindowManager} + * @return Size in pixels of the screen, or default {@link Point} if caller is null + */ + public static Point getScreenSize(Activity caller) { + Point size = new Point(); + if (caller != null) { + Display display = caller.getWindowManager().getDefaultDisplay(); + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB_MR2) { + display.getSize(size); + } else { + size.set(display.getWidth(), display.getHeight()); + } + } + 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); + } + } + } }