pull/32/head
gedoor 6 years ago
parent 44307e3701
commit b36058dedf
  1. 40
      app/src/main/java/io/legado/app/lib/theme/TintHelper.kt

@ -134,25 +134,18 @@ object TintHelper {
view: View, @ColorInt color: Int, view: View, @ColorInt color: Int,
background: Boolean, isDark: Boolean background: Boolean, isDark: Boolean
) { ) {
var background = background var isBg = background
if (!background) { if (!isBg) {
if (view is RadioButton) when (view) {
setTint(view, color, isDark) is RadioButton -> setTint(view, color, isDark)
else if (view is SeekBar) is SeekBar -> setTint(view, color, isDark)
setTint(view, color, isDark) is ProgressBar -> setTint(view, color)
else if (view is ProgressBar) is AppCompatEditText -> setTint(view, color, isDark)
setTint(view, color) is CheckBox -> setTint(view, color, isDark)
else if (view is AppCompatEditText) is ImageView -> setTint(view, color)
setTint(view, color, isDark) is Switch -> setTint(view, color, isDark)
else if (view is CheckBox) is SwitchCompat -> setTint(view, color, isDark)
setTint(view, color, isDark) is SearchView -> {
else if (view is ImageView)
setTint(view, color)
else if (view is Switch)
setTint(view, color, isDark)
else if (view is SwitchCompat)
setTint(view, color, isDark)
else if (view is SearchView) {
val iconIdS = val iconIdS =
intArrayOf(androidx.appcompat.R.id.search_button, androidx.appcompat.R.id.search_close_btn) intArrayOf(androidx.appcompat.R.id.search_button, androidx.appcompat.R.id.search_close_btn)
for (iconId in iconIdS) { for (iconId in iconIdS) {
@ -161,13 +154,12 @@ object TintHelper {
setTint(icon, color) setTint(icon, color)
} }
} }
}
} else { else -> isBg = true
background = true
} }
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP &&
!background && view.background is RippleDrawable !isBg && view.background is RippleDrawable
) { ) {
// Ripples for the above views (e.g. when you tap and hold a switch or checkbox) // Ripples for the above views (e.g. when you tap and hold a switch or checkbox)
val rd = view.background as RippleDrawable val rd = view.background as RippleDrawable
@ -187,7 +179,7 @@ object TintHelper {
rd.setColor(sl) rd.setColor(sl)
} }
} }
if (background) { if (isBg) {
// Need to tint the background of a view // Need to tint the background of a view
if (view is FloatingActionButton || view is Button) { if (view is FloatingActionButton || view is Button) {
setTintSelector(view, color, false, isDark) setTintSelector(view, color, false, isDark)

Loading…
Cancel
Save