pull/1352/head
gedoor 3 years ago
parent 8032a3e1d8
commit 6d286955ee
  1. 19
      app/src/main/java/io/legado/app/lib/theme/ATH.kt
  2. 6
      app/src/main/java/io/legado/app/ui/widget/prefs/ColorPreference.kt
  3. 18
      app/src/main/java/io/legado/app/utils/AlertDialogExtensions.kt

@ -14,7 +14,6 @@ import android.view.WindowManager
import android.widget.EdgeEffect
import android.widget.ScrollView
import androidx.annotation.ColorInt
import androidx.appcompat.app.AlertDialog
import androidx.recyclerview.widget.RecyclerView
import androidx.viewpager2.widget.ViewPager2
import com.google.android.material.bottomnavigation.BottomNavigationView
@ -191,24 +190,6 @@ object ATH {
TintHelper.setTintAuto(view, color, true, isDark)
}
fun setAlertDialogTint(dialog: AlertDialog): AlertDialog {
dialog.window?.setBackgroundDrawable(getDialogBackground())
val colorStateList = Selector.colorBuild()
.setDefaultColor(ThemeStore.accentColor(dialog.context))
.setPressedColor(ColorUtils.darkenColor(ThemeStore.accentColor(dialog.context)))
.create()
if (dialog.getButton(AlertDialog.BUTTON_NEGATIVE) != null) {
dialog.getButton(AlertDialog.BUTTON_NEGATIVE).setTextColor(colorStateList)
}
if (dialog.getButton(AlertDialog.BUTTON_POSITIVE) != null) {
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(colorStateList)
}
if (dialog.getButton(AlertDialog.BUTTON_NEUTRAL) != null) {
dialog.getButton(AlertDialog.BUTTON_NEUTRAL).setTextColor(colorStateList)
}
return dialog
}
fun setEdgeEffectColor(view: RecyclerView?, @ColorInt color: Int) {
view?.edgeEffectFactory = object : RecyclerView.EdgeEffectFactory() {
override fun createEdgeEffect(view: RecyclerView, direction: Int): EdgeEffect {

@ -13,8 +13,8 @@ import androidx.fragment.app.FragmentActivity
import androidx.preference.Preference
import androidx.preference.PreferenceViewHolder
import com.jaredrummler.android.colorpicker.*
import io.legado.app.lib.theme.ATH
import io.legado.app.utils.ColorUtils
import io.legado.app.utils.applyTint
@Suppress("MemberVisibilityCanBePrivate", "unused")
class ColorPreference(context: Context, attrs: AttributeSet) : Preference(context, attrs),
@ -215,9 +215,7 @@ class ColorPreference(context: Context, attrs: AttributeSet) : Preference(contex
override fun onStart() {
super.onStart()
val alertDialog = dialog as? AlertDialog
alertDialog?.let {
ATH.setAlertDialogTint(it)
}
alertDialog?.applyTint()
}

@ -3,9 +3,25 @@ package io.legado.app.utils
import android.view.WindowManager
import androidx.appcompat.app.AlertDialog
import io.legado.app.lib.theme.ATH
import io.legado.app.lib.theme.Selector
import io.legado.app.lib.theme.ThemeStore
fun AlertDialog.applyTint(): AlertDialog {
return ATH.setAlertDialogTint(this)
window?.setBackgroundDrawable(ATH.getDialogBackground())
val colorStateList = Selector.colorBuild()
.setDefaultColor(ThemeStore.accentColor(context))
.setPressedColor(ColorUtils.darkenColor(ThemeStore.accentColor(context)))
.create()
if (getButton(AlertDialog.BUTTON_NEGATIVE) != null) {
getButton(AlertDialog.BUTTON_NEGATIVE).setTextColor(colorStateList)
}
if (getButton(AlertDialog.BUTTON_POSITIVE) != null) {
getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(colorStateList)
}
if (getButton(AlertDialog.BUTTON_NEUTRAL) != null) {
getButton(AlertDialog.BUTTON_NEUTRAL).setTextColor(colorStateList)
}
return this
}
fun AlertDialog.requestInputMethod() {

Loading…
Cancel
Save