diff options
author | Allan Wang <me@allanwang.ca> | 2017-11-08 22:40:06 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-08 22:40:06 -0500 |
commit | f343d0f04c9cbb210f2b56b4f0c534ac56aa76ef (patch) | |
tree | 2a261a6ed4af0c17233714af7673d5370f19edbf /core/src/main/kotlin/ca/allanwang/kau/utils/ColorUtils.kt | |
parent | 3b1cbd2f2cf211b804784bef33de85b8a889677e (diff) | |
download | kau-f343d0f04c9cbb210f2b56b4f0c534ac56aa76ef.tar.gz kau-f343d0f04c9cbb210f2b56b4f0c534ac56aa76ef.tar.bz2 kau-f343d0f04c9cbb210f2b56b4f0c534ac56aa76ef.zip |
Translations Vietnamese (#99)
* Add translations
* Lint
* Inline
* Optimize imports
* Replace ellipsis
Diffstat (limited to 'core/src/main/kotlin/ca/allanwang/kau/utils/ColorUtils.kt')
-rw-r--r-- | core/src/main/kotlin/ca/allanwang/kau/utils/ColorUtils.kt | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/ColorUtils.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/ColorUtils.kt index 16d1d01..d0e1f8f 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/utils/ColorUtils.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/utils/ColorUtils.kt @@ -149,6 +149,7 @@ fun Context.colorStateList(@ColorInt color: Int): ColorStateList { * Largely based on MDTintHelper * https://github.com/afollestad/material-dialogs/blob/master/core/src/main/java/com/afollestad/materialdialogs/internal/MDTintHelper.java */ +@SuppressLint("PrivateResource") fun RadioButton.tint(colors: ColorStateList) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { buttonTintList = colors @@ -162,6 +163,7 @@ fun RadioButton.tint(colors: ColorStateList) { fun RadioButton.tint(@ColorInt color: Int) = tint(context.colorStateList(color)) +@SuppressLint("PrivateResource") fun CheckBox.tint(colors: ColorStateList) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { buttonTintList = colors @@ -180,20 +182,13 @@ fun SeekBar.tint(@ColorInt color: Int) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { thumbTintList = s1 progressTintList = s1 - } else if (Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD_MR1) { + } else { val progressDrawable = DrawableCompat.wrap(progressDrawable) this.progressDrawable = progressDrawable DrawableCompat.setTintList(progressDrawable, s1) - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { - val thumbDrawable = DrawableCompat.wrap(thumb) - DrawableCompat.setTintList(thumbDrawable, s1) - thumb = thumbDrawable - } - } else { - val mode: PorterDuff.Mode = if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) - PorterDuff.Mode.MULTIPLY else PorterDuff.Mode.SRC_IN - indeterminateDrawable?.setColorFilter(color, mode) - progressDrawable?.setColorFilter(color, mode) + val thumbDrawable = DrawableCompat.wrap(thumb) + DrawableCompat.setTintList(thumbDrawable, s1) + thumb = thumbDrawable } } @@ -204,8 +199,7 @@ fun ProgressBar.tint(@ColorInt color: Int, skipIndeterminate: Boolean = false) { secondaryProgressTintList = sl if (!skipIndeterminate) indeterminateTintList = sl } else { - val mode: PorterDuff.Mode = if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) - PorterDuff.Mode.MULTIPLY else PorterDuff.Mode.SRC_IN + val mode: PorterDuff.Mode = PorterDuff.Mode.SRC_IN indeterminateDrawable?.setColorFilter(color, mode) progressDrawable?.setColorFilter(color, mode) } |