pull/2385/head
kunfei 2 years ago
parent a9a6d49150
commit 1f44aded5f
  1. 3
      app/src/main/java/io/legado/app/ui/book/audio/AudioPlayActivity.kt
  2. 3
      app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt
  3. 29
      app/src/main/java/io/legado/app/ui/widget/TitleBar.kt

@ -2,6 +2,7 @@ package io.legado.app.ui.book.audio
import android.annotation.SuppressLint
import android.app.Activity
import android.graphics.Color
import android.icu.text.SimpleDateFormat
import android.os.Build
import android.os.Bundle
@ -78,7 +79,7 @@ class AudioPlayActivity :
}
override fun onActivityCreated(savedInstanceState: Bundle?) {
binding.titleBar.transparent()
binding.titleBar.setBackgroundColor(Color.argb(60, 0, 0, 0))
AudioPlay.titleData.observe(this) {
binding.titleBar.title = it
}

@ -2,6 +2,7 @@ package io.legado.app.ui.book.info
import android.annotation.SuppressLint
import android.content.Intent
import android.graphics.Color
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
@ -101,7 +102,7 @@ class BookInfoActivity :
@SuppressLint("PrivateResource")
override fun onActivityCreated(savedInstanceState: Bundle?) {
binding.titleBar.transparent()
binding.titleBar.setBackgroundColor(Color.argb(60, 0, 0, 0))
binding.arcView.setBgColor(backgroundColor)
binding.llInfo.setBackgroundColor(backgroundColor)
binding.scrollView.setBackgroundColor(backgroundColor)

@ -2,9 +2,10 @@ package io.legado.app.ui.widget
import android.content.Context
import android.content.res.ColorStateList
import android.graphics.Color
import android.graphics.PorterDuff
import android.graphics.PorterDuffColorFilter
import android.graphics.drawable.ColorDrawable
import android.graphics.drawable.Drawable
import android.util.AttributeSet
import android.view.Menu
import android.view.View
@ -12,6 +13,7 @@ import android.widget.ImageView
import androidx.annotation.ColorInt
import androidx.annotation.StyleRes
import androidx.appcompat.widget.Toolbar
import androidx.core.graphics.alpha
import androidx.core.view.children
import com.google.android.material.appbar.AppBarLayout
import io.legado.app.R
@ -21,7 +23,7 @@ import io.legado.app.utils.activity
import io.legado.app.utils.navigationBarHeight
import io.legado.app.utils.statusBarHeight
@Suppress("unused")
@Suppress("unused", "MemberVisibilityCanBePrivate")
class TitleBar @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null
@ -201,19 +203,30 @@ class TitleBar @JvmOverloads constructor(
setSubTitleTextColor(color)
}
fun setColorFilter(@ColorInt color: Int){
val colorFilter = PorterDuffColorFilter(color,PorterDuff.Mode.SRC_ATOP)
fun setColorFilter(@ColorInt color: Int) {
val colorFilter = PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)
toolbar.children.firstOrNull { it is ImageView }?.background?.colorFilter = colorFilter
toolbar.navigationIcon?.colorFilter = colorFilter
toolbar.overflowIcon?.colorFilter = colorFilter
toolbar.menu.children.forEach{
toolbar.menu.children.forEach {
it.icon?.colorFilter = colorFilter
}
}
fun transparent() {
elevation = 0f
setBackgroundColor(Color.TRANSPARENT)
override fun setBackgroundColor(color: Int) {
if (color.alpha < 255) {
elevation = 0.1f
}
super.setBackgroundColor(color)
}
override fun setBackground(background: Drawable?) {
if (background is ColorDrawable) {
if (background.alpha < 255) {
elevation = 0.1f
}
}
super.setBackground(background)
}
fun onMultiWindowModeChanged(isInMultiWindowMode: Boolean, fullScreen: Boolean) {

Loading…
Cancel
Save