diff --git a/app/src/main/java/io/legado/app/lib/theme/view/ATERadioNoButton.kt b/app/src/main/java/io/legado/app/lib/theme/view/ATERadioNoButton.kt index 1a739edb8..0a93266b6 100644 --- a/app/src/main/java/io/legado/app/lib/theme/view/ATERadioNoButton.kt +++ b/app/src/main/java/io/legado/app/lib/theme/view/ATERadioNoButton.kt @@ -5,7 +5,10 @@ import android.util.AttributeSet import androidx.appcompat.widget.AppCompatRadioButton import io.legado.app.R import io.legado.app.lib.theme.Selector -import io.legado.app.lib.theme.ThemeStore +import io.legado.app.lib.theme.accentColor +import io.legado.app.lib.theme.bottomBackground +import io.legado.app.lib.theme.getPrimaryTextColor +import io.legado.app.utils.ColorUtils import io.legado.app.utils.dp import io.legado.app.utils.getCompatColor @@ -15,13 +18,42 @@ import io.legado.app.utils.getCompatColor class ATERadioNoButton(context: Context, attrs: AttributeSet) : AppCompatRadioButton(context, attrs) { + private val isBottomBackground: Boolean + init { - background = Selector.shapeBuild() - .setCornerRadius(2.dp) - .setStrokeWidth(2.dp) - .setCheckedBgColor(ThemeStore.accentColor(context)) - .setCheckedStrokeColor(ThemeStore.accentColor(context)) - .setDefaultStrokeColor(context.getCompatColor(R.color.primaryText)) - .create() + val typedArray = context.obtainStyledAttributes(attrs, R.styleable.ATERadioNoButton) + isBottomBackground = + typedArray.getBoolean(R.styleable.ATERadioNoButton_isBottomBackground, false) + typedArray.recycle() + initTheme() } + + private fun initTheme() { + when { + isInEditMode -> Unit + isBottomBackground -> { + val isLight = ColorUtils.isColorLight(context.bottomBackground) + val textColor = context.getPrimaryTextColor(isLight) + setTextColor(textColor) + background = Selector.shapeBuild() + .setCornerRadius(2.dp) + .setStrokeWidth(2.dp) + .setCheckedBgColor(context.accentColor) + .setCheckedStrokeColor(context.accentColor) + .setDefaultStrokeColor(textColor) + .create() + } + else -> { + background = Selector.shapeBuild() + .setCornerRadius(2.dp) + .setStrokeWidth(2.dp) + .setCheckedBgColor(context.accentColor) + .setCheckedStrokeColor(context.accentColor) + .setDefaultStrokeColor(context.getCompatColor(R.color.primaryText)) + .create() + } + } + + } + } diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt index c9bccd841..6f8ac5e0f 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt @@ -1,11 +1,13 @@ package io.legado.app.ui.book.read.config import android.annotation.SuppressLint -import android.content.Context import android.content.DialogInterface import android.os.Bundle import android.util.DisplayMetrics -import android.view.* +import android.view.Gravity +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup import androidx.core.view.get import io.legado.app.R import io.legado.app.base.BaseDialogFragment @@ -17,6 +19,7 @@ import io.legado.app.lib.dialogs.alert import io.legado.app.lib.dialogs.selector import io.legado.app.lib.theme.accentColor import io.legado.app.lib.theme.bottomBackground +import io.legado.app.lib.theme.getPrimaryTextColor import io.legado.app.lib.theme.primaryColor import io.legado.app.ui.book.read.Help import io.legado.app.ui.book.read.ReadBookActivity @@ -51,16 +54,6 @@ class ReadStyleDialog : BaseDialogFragment(), FontSelectDialog.CallBack { } } - override fun onAttach(context: Context) { - val bg = requireContext().bottomBackground - val contextThemeWrapper = if (ColorUtils.isColorLight(bg)) { - ContextThemeWrapper(requireContext(), R.style.AppTheme_Light) - } else { - ContextThemeWrapper(requireContext(), R.style.AppTheme_Dark) - } - super.onAttach(contextThemeWrapper) - } - override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, @@ -81,6 +74,11 @@ class ReadStyleDialog : BaseDialogFragment(), FontSelectDialog.CallBack { } private fun initView() { + val isLight = ColorUtils.isColorLight(requireContext().bottomBackground) + val textColor = requireContext().getPrimaryTextColor(isLight) + tv_page_anim.setTextColor(textColor) + tv_bg_ts.setTextColor(textColor) + tv_share_layout.setTextColor(textColor) root_view.setBackgroundColor(requireContext().bottomBackground) dsb_text_size.valueFormat = { (it + 5).toString() diff --git a/app/src/main/res/layout/dialog_read_book_style.xml b/app/src/main/res/layout/dialog_read_book_style.xml index 513dd9eef..2b0e7fd4a 100644 --- a/app/src/main/res/layout/dialog_read_book_style.xml +++ b/app/src/main/res/layout/dialog_read_book_style.xml @@ -228,7 +228,8 @@ android:button="@null" android:gravity="center" android:singleLine="true" - android:text="@string/page_anim_cover" /> + android:text="@string/page_anim_cover" + app:isBottomBackground="true" /> + android:text="@string/page_anim_slide" + app:isBottomBackground="true" /> + android:text="@string/page_anim_simulation" + app:isBottomBackground="true" /> + android:text="@string/page_anim_scroll" + app:isBottomBackground="true" /> + android:text="@string/page_anim_none" + app:isBottomBackground="true" /> diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml index 6f38b1549..507cbc347 100644 --- a/app/src/main/res/values/attrs.xml +++ b/app/src/main/res/values/attrs.xml @@ -195,6 +195,10 @@ + + + +