From d623d8a4df1d2b9cbf3237cd95d6131c13663f53 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 8 Sep 2019 13:55:12 +0800 Subject: [PATCH] up --- .../main/java/io/legado/app/lib/theme/ATH.kt | 29 ++++++++++++++----- .../io/legado/app/lib/theme/TintHelper.kt | 8 ----- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/io/legado/app/lib/theme/ATH.kt b/app/src/main/java/io/legado/app/lib/theme/ATH.kt index a09750b2a..0fafab3b3 100644 --- a/app/src/main/java/io/legado/app/lib/theme/ATH.kt +++ b/app/src/main/java/io/legado/app/lib/theme/ATH.kt @@ -17,6 +17,7 @@ import androidx.viewpager.widget.ViewPager import com.google.android.material.bottomnavigation.BottomNavigationView import io.legado.app.R import io.legado.app.utils.getCompatColor +import io.legado.app.utils.isNightTheme import io.legado.app.utils.isTransparentStatusBar import kotlinx.android.synthetic.main.activity_main.view.* import org.jetbrains.anko.backgroundColor @@ -67,9 +68,11 @@ object ATH { val decorView = activity.window.decorView val systemUiVisibility = decorView.systemUiVisibility if (enabled) { - decorView.systemUiVisibility = systemUiVisibility or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR + decorView.systemUiVisibility = + systemUiVisibility or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR } else { - decorView.systemUiVisibility = systemUiVisibility and View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR.inv() + decorView.systemUiVisibility = + systemUiVisibility and View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR.inv() } } } @@ -111,16 +114,28 @@ object ATH { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { color1 = ColorUtils.stripAlpha(color) @Suppress("DEPRECATION") - activity.setTaskDescription(ActivityManager.TaskDescription(activity.title as String, null, color1)) + activity.setTaskDescription( + ActivityManager.TaskDescription( + activity.title as String, + null, + color1 + ) + ) } } - fun setTint(view: View, @ColorInt color: Int) { - TintHelper.setTintAuto(view, color, false) + fun setTint( + view: View, @ColorInt color: Int, isDark: + Boolean = view.context.isNightTheme + ) { + TintHelper.setTintAuto(view, color, false, isDark) } - fun setBackgroundTint(view: View, @ColorInt color: Int) { - TintHelper.setTintAuto(view, color, true) + fun setBackgroundTint( + view: View, @ColorInt color: Int, + isDark: Boolean = view.context.isNightTheme + ) { + TintHelper.setTintAuto(view, color, true, isDark) } fun setAlertDialogTint(dialog: AlertDialog): AlertDialog { diff --git a/app/src/main/java/io/legado/app/lib/theme/TintHelper.kt b/app/src/main/java/io/legado/app/lib/theme/TintHelper.kt index c33d1e163..7b3653eb2 100644 --- a/app/src/main/java/io/legado/app/lib/theme/TintHelper.kt +++ b/app/src/main/java/io/legado/app/lib/theme/TintHelper.kt @@ -18,7 +18,6 @@ import androidx.core.content.ContextCompat import androidx.core.graphics.drawable.DrawableCompat import com.google.android.material.floatingactionbutton.FloatingActionButton import io.legado.app.R -import io.legado.app.utils.isNightTheme /** * @author afollestad, plusCubed @@ -124,13 +123,6 @@ object TintHelper { } } - fun setTintAuto( - view: View, @ColorInt color: Int, - isBackground: Boolean - ) { - setTintAuto(view, color, isBackground, view.context.isNightTheme) - } - fun setTintAuto( view: View, @ColorInt color: Int, isBackground: Boolean, isDark: Boolean