pull/1395/head
gedoor 3 years ago
parent 61a9a40292
commit a7e676038d
  1. 20
      app/src/main/java/io/legado/app/lib/theme/ATH.kt
  2. 10
      app/src/main/java/io/legado/app/lib/theme/MaterialValueHelper.kt
  3. 4
      app/src/main/java/io/legado/app/ui/about/AboutActivity.kt
  4. 4
      app/src/main/java/io/legado/app/ui/widget/prefs/EditTextPreferenceDialog.kt
  5. 4
      app/src/main/java/io/legado/app/ui/widget/prefs/ListPreferenceDialog.kt
  6. 4
      app/src/main/java/io/legado/app/ui/widget/prefs/MultiSelectListPreferenceDialog.kt
  7. 4
      app/src/main/java/io/legado/app/utils/AlertDialogExtensions.kt

@ -1,20 +0,0 @@
package io.legado.app.lib.theme
import android.graphics.drawable.GradientDrawable
import io.legado.app.utils.dp
import splitties.init.appCtx
/**
* @author Karim Abou Zeid (kabouzeid)
*/
@Suppress("unused", "MemberVisibilityCanBePrivate")
object ATH {
fun getDialogBackground(): GradientDrawable {
val background = GradientDrawable()
background.cornerRadius = 3F.dp
background.setColor(appCtx.backgroundColor)
return background
}
}

@ -4,11 +4,13 @@ package io.legado.app.lib.theme
import android.annotation.SuppressLint
import android.content.Context
import android.graphics.drawable.GradientDrawable
import androidx.annotation.ColorInt
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import io.legado.app.R
import io.legado.app.utils.ColorUtils
import io.legado.app.utils.dp
/**
* @author Karim Abou Zeid (kabouzeid)
@ -114,3 +116,11 @@ val Fragment.isDarkTheme: Boolean
val Context.elevation: Float
get() = ThemeStore.elevation(this)
val Context.filletBackground: GradientDrawable
get() {
val background = GradientDrawable()
background.cornerRadius = 3F.dp
background.setColor(backgroundColor)
return background
}

@ -9,8 +9,8 @@ import android.view.MenuItem
import io.legado.app.R
import io.legado.app.base.BaseActivity
import io.legado.app.databinding.ActivityAboutBinding
import io.legado.app.lib.theme.ATH
import io.legado.app.lib.theme.accentColor
import io.legado.app.lib.theme.filletBackground
import io.legado.app.utils.openUrl
import io.legado.app.utils.share
import io.legado.app.utils.viewbindingdelegate.viewBinding
@ -21,7 +21,7 @@ class AboutActivity : BaseActivity<ActivityAboutBinding>() {
override val binding by viewBinding(ActivityAboutBinding::inflate)
override fun onActivityCreated(savedInstanceState: Bundle?) {
binding.llAbout.background = ATH.getDialogBackground()
binding.llAbout.background = filletBackground
val fTag = "aboutFragment"
var aboutFragment = supportFragmentManager.findFragmentByTag(fTag)
if (aboutFragment == null) aboutFragment = AboutFragment()

@ -4,7 +4,7 @@ import android.app.Dialog
import android.os.Bundle
import androidx.preference.EditTextPreferenceDialogFragmentCompat
import androidx.preference.PreferenceDialogFragmentCompat
import io.legado.app.lib.theme.ATH
import io.legado.app.lib.theme.filletBackground
class EditTextPreferenceDialog : EditTextPreferenceDialogFragmentCompat() {
@ -22,7 +22,7 @@ class EditTextPreferenceDialog : EditTextPreferenceDialogFragmentCompat() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val dialog = super.onCreateDialog(savedInstanceState)
dialog.window?.setBackgroundDrawable(ATH.getDialogBackground())
dialog.window?.setBackgroundDrawable(requireContext().filletBackground)
return dialog
}

@ -4,7 +4,7 @@ import android.app.Dialog
import android.os.Bundle
import androidx.preference.ListPreferenceDialogFragmentCompat
import androidx.preference.PreferenceDialogFragmentCompat
import io.legado.app.lib.theme.ATH
import io.legado.app.lib.theme.filletBackground
class ListPreferenceDialog : ListPreferenceDialogFragmentCompat() {
@ -22,7 +22,7 @@ class ListPreferenceDialog : ListPreferenceDialogFragmentCompat() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val dialog = super.onCreateDialog(savedInstanceState)
dialog.window?.setBackgroundDrawable(ATH.getDialogBackground())
dialog.window?.setBackgroundDrawable(requireContext().filletBackground)
return dialog
}

@ -4,7 +4,7 @@ import android.app.Dialog
import android.os.Bundle
import androidx.preference.MultiSelectListPreferenceDialogFragmentCompat
import androidx.preference.PreferenceDialogFragmentCompat
import io.legado.app.lib.theme.ATH
import io.legado.app.lib.theme.filletBackground
class MultiSelectListPreferenceDialog : MultiSelectListPreferenceDialogFragmentCompat() {
@ -24,7 +24,7 @@ class MultiSelectListPreferenceDialog : MultiSelectListPreferenceDialogFragmentC
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val dialog = super.onCreateDialog(savedInstanceState)
dialog.window?.setBackgroundDrawable(ATH.getDialogBackground())
dialog.window?.setBackgroundDrawable(requireContext().filletBackground)
return dialog
}

@ -2,12 +2,12 @@ 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
import io.legado.app.lib.theme.filletBackground
fun AlertDialog.applyTint(): AlertDialog {
window?.setBackgroundDrawable(ATH.getDialogBackground())
window?.setBackgroundDrawable(context.filletBackground)
val colorStateList = Selector.colorBuild()
.setDefaultColor(ThemeStore.accentColor(context))
.setPressedColor(ColorUtils.darkenColor(ThemeStore.accentColor(context)))

Loading…
Cancel
Save