From: Andy Scherzinger Date: Fri, 14 Aug 2015 16:55:58 +0000 (+0200) Subject: Merge branch 'material_toolbar' of https://github.com/owncloud/android into material_... X-Git-Tag: beta-20151128~7^2~48 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/267179ef2eeb427d59be82f7ba591fbd2740014d?ds=inline;hp=-c Merge branch 'material_toolbar' of https://github.com/owncloud/android into material_buttons --- 267179ef2eeb427d59be82f7ba591fbd2740014d diff --combined res/layout/file_preview.xml index 3c4e6192,2068224d..dd44ed5e --- a/res/layout/file_preview.xml +++ b/res/layout/file_preview.xml @@@ -39,7 -39,7 +39,7 @@@ android:id="@+id/image_preview" android:layout_width="match_parent" android:layout_height="match_parent" - android:layout_margin="16dp" + android:layout_margin="@dimen/standard_margin" android:layout_gravity="center" android:contentDescription="@string/preview_image_description" android:src="@drawable/logo" /> @@@ -59,6 -59,7 +59,7 @@@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" + android:layout_margin="16dp" /> diff --combined src/com/owncloud/android/utils/DisplayUtils.java index d81fe786,3ae36e44..236a05f5 --- a/src/com/owncloud/android/utils/DisplayUtils.java +++ b/src/com/owncloud/android/utils/DisplayUtils.java @@@ -22,7 -22,6 +22,7 @@@ package com.owncloud.android.utils; +import java.math.BigDecimal; import java.net.IDN; import java.text.DateFormat; import java.util.Arrays; @@@ -36,11 -35,15 +36,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; @@@ -56,7 -59,6 +60,7 @@@ public class DisplayUtils //private static String TAG = DisplayUtils.class.getSimpleName(); private static final String[] sizeSuffixes = { "B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" }; + private static final int[] sizeScales = { 0, 0, 0, 1, 1, 2, 2, 2, 2 }; private static HashMap mimeType2HUmanReadable; static { @@@ -116,11 -118,7 +120,11 @@@ /** * Converts the file size in bytes to human readable output. - * + * + * * @param bytes Input file size * @return Like something readable like "12 MB" */ @@@ -131,9 -129,8 +135,9 @@@ result /= 1024.; attachedsuff++; } - result = ((int) (result * 100)) / 100.; - return result + " " + sizeSuffixes[attachedsuff]; + + return new BigDecimal(result).setScale( + sizeScales[attachedsuff], BigDecimal.ROUND_HALF_UP) + " " + sizeSuffixes[attachedsuff]; } /** @@@ -380,4 -377,33 +384,33 @@@ 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); + } + } + } }