pull/32/head
kunfei 5 years ago
parent 1f6fc5ed27
commit d623d8a4df
  1. 29
      app/src/main/java/io/legado/app/lib/theme/ATH.kt
  2. 8
      app/src/main/java/io/legado/app/lib/theme/TintHelper.kt

@ -17,6 +17,7 @@ import androidx.viewpager.widget.ViewPager
import com.google.android.material.bottomnavigation.BottomNavigationView import com.google.android.material.bottomnavigation.BottomNavigationView
import io.legado.app.R import io.legado.app.R
import io.legado.app.utils.getCompatColor import io.legado.app.utils.getCompatColor
import io.legado.app.utils.isNightTheme
import io.legado.app.utils.isTransparentStatusBar import io.legado.app.utils.isTransparentStatusBar
import kotlinx.android.synthetic.main.activity_main.view.* import kotlinx.android.synthetic.main.activity_main.view.*
import org.jetbrains.anko.backgroundColor import org.jetbrains.anko.backgroundColor
@ -67,9 +68,11 @@ object ATH {
val decorView = activity.window.decorView val decorView = activity.window.decorView
val systemUiVisibility = decorView.systemUiVisibility val systemUiVisibility = decorView.systemUiVisibility
if (enabled) { 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 { } 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) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
color1 = ColorUtils.stripAlpha(color) color1 = ColorUtils.stripAlpha(color)
@Suppress("DEPRECATION") @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) { fun setTint(
TintHelper.setTintAuto(view, color, false) view: View, @ColorInt color: Int, isDark:
Boolean = view.context.isNightTheme
) {
TintHelper.setTintAuto(view, color, false, isDark)
} }
fun setBackgroundTint(view: View, @ColorInt color: Int) { fun setBackgroundTint(
TintHelper.setTintAuto(view, color, true) view: View, @ColorInt color: Int,
isDark: Boolean = view.context.isNightTheme
) {
TintHelper.setTintAuto(view, color, true, isDark)
} }
fun setAlertDialogTint(dialog: AlertDialog): AlertDialog { fun setAlertDialogTint(dialog: AlertDialog): AlertDialog {

@ -18,7 +18,6 @@ import androidx.core.content.ContextCompat
import androidx.core.graphics.drawable.DrawableCompat import androidx.core.graphics.drawable.DrawableCompat
import com.google.android.material.floatingactionbutton.FloatingActionButton import com.google.android.material.floatingactionbutton.FloatingActionButton
import io.legado.app.R import io.legado.app.R
import io.legado.app.utils.isNightTheme
/** /**
* @author afollestad, plusCubed * @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( fun setTintAuto(
view: View, @ColorInt color: Int, view: View, @ColorInt color: Int,
isBackground: Boolean, isDark: Boolean isBackground: Boolean, isDark: Boolean

Loading…
Cancel
Save