优化主题

pull/310/head
gedoor 4 years ago
parent 3de0cd1a77
commit f778e8dd2c
  1. 16
      app/src/main/java/io/legado/app/ui/widget/DetailSeekBar.kt
  2. 2
      app/src/main/java/io/legado/app/ui/widget/prefs/NameListPreference.kt
  3. 8
      app/src/main/java/io/legado/app/ui/widget/prefs/Preference.kt
  4. 2
      app/src/main/java/io/legado/app/ui/widget/prefs/SwitchPreference.kt
  5. 88
      app/src/main/java/io/legado/app/ui/widget/text/StrokeTextView.kt
  6. 11
      app/src/main/res/layout/dialog_read_book_style.xml
  7. 5
      app/src/main/res/values/attrs.xml
  8. 30
      app/src/main/res/xml/pref_config_read.xml

@ -6,13 +6,16 @@ import android.view.View
import android.widget.FrameLayout import android.widget.FrameLayout
import android.widget.SeekBar import android.widget.SeekBar
import io.legado.app.R import io.legado.app.R
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.progressAdd import io.legado.app.utils.progressAdd
import kotlinx.android.synthetic.main.view_detail_seek_bar.view.* import kotlinx.android.synthetic.main.view_detail_seek_bar.view.*
import org.jetbrains.anko.sdk27.listeners.onClick import org.jetbrains.anko.sdk27.listeners.onClick
class DetailSeekBar(context: Context, attrs: AttributeSet?) : FrameLayout(context, attrs), class DetailSeekBar(context: Context, attrs: AttributeSet?) : FrameLayout(context, attrs),
SeekBar.OnSeekBarChangeListener { SeekBar.OnSeekBarChangeListener {
private val isBottomBackground: Boolean
var valueFormat: ((progress: Int) -> String)? = null var valueFormat: ((progress: Int) -> String)? = null
var onChanged: ((progress: Int) -> Unit)? = null var onChanged: ((progress: Int) -> Unit)? = null
var progress: Int var progress: Int
@ -30,10 +33,19 @@ class DetailSeekBar(context: Context, attrs: AttributeSet?) : FrameLayout(contex
View.inflate(context, R.layout.view_detail_seek_bar, this) View.inflate(context, R.layout.view_detail_seek_bar, this)
val typedArray = context.obtainStyledAttributes(attrs, R.styleable.DetailSeekBar) val typedArray = context.obtainStyledAttributes(attrs, R.styleable.DetailSeekBar)
isBottomBackground =
typedArray.getBoolean(R.styleable.DetailSeekBar_isBottomBackground, false)
tv_seek_title.text = typedArray.getText(R.styleable.DetailSeekBar_title) tv_seek_title.text = typedArray.getText(R.styleable.DetailSeekBar_title)
seek_bar.max = typedArray.getInteger(R.styleable.DetailSeekBar_max, 0) seek_bar.max = typedArray.getInteger(R.styleable.DetailSeekBar_max, 0)
typedArray.recycle() typedArray.recycle()
if (isBottomBackground) {
val isLight = ColorUtils.isColorLight(context.bottomBackground)
val textColor = context.getPrimaryTextColor(isLight)
tv_seek_title.setTextColor(textColor)
iv_seek_plus.setColorFilter(textColor)
iv_seek_reduce.setColorFilter(textColor)
tv_seek_value.setTextColor(textColor)
}
iv_seek_plus.onClick { iv_seek_plus.onClick {
seek_bar.progressAdd(1) seek_bar.progressAdd(1)
onChanged?.invoke(seek_bar.progress) onChanged?.invoke(seek_bar.progress)

@ -19,7 +19,7 @@ class NameListPreference(context: Context, attrs: AttributeSet) : ListPreference
layoutResource = R.layout.view_preference layoutResource = R.layout.view_preference
widgetLayoutResource = R.layout.item_fillet_text widgetLayoutResource = R.layout.item_fillet_text
val typedArray = context.obtainStyledAttributes(attrs, R.styleable.Preference) val typedArray = context.obtainStyledAttributes(attrs, R.styleable.Preference)
isBottomBackground = typedArray.getBoolean(R.styleable.Preference_bottomBackground, false) isBottomBackground = typedArray.getBoolean(R.styleable.Preference_isBottomBackground, false)
typedArray.recycle() typedArray.recycle()
} }

@ -30,7 +30,7 @@ class Preference(context: Context, attrs: AttributeSet) :
init { init {
layoutResource = R.layout.view_preference layoutResource = R.layout.view_preference
val typedArray = context.obtainStyledAttributes(attrs, R.styleable.Preference) val typedArray = context.obtainStyledAttributes(attrs, R.styleable.Preference)
isBottomBackground = typedArray.getBoolean(R.styleable.Preference_bottomBackground, false) isBottomBackground = typedArray.getBoolean(R.styleable.Preference_isBottomBackground, false)
typedArray.recycle() typedArray.recycle()
} }
@ -58,10 +58,10 @@ class Preference(context: Context, attrs: AttributeSet) :
tvSummary.isGone = summary.isNullOrEmpty() tvSummary.isGone = summary.isNullOrEmpty()
} }
if (isBottomBackground && !tvTitle.isInEditMode) { if (isBottomBackground && !tvTitle.isInEditMode) {
val bgColor = context.bottomBackground val isLight = ColorUtils.isColorLight(context.bottomBackground)
val pTextColor = context.getPrimaryTextColor(ColorUtils.isColorLight(bgColor)) val pTextColor = context.getPrimaryTextColor(isLight)
tvTitle.setTextColor(pTextColor) tvTitle.setTextColor(pTextColor)
val sTextColor = context.getSecondaryTextColor(ColorUtils.isColorLight(bgColor)) val sTextColor = context.getSecondaryTextColor(isLight)
tvSummary?.setTextColor(sTextColor) tvSummary?.setTextColor(sTextColor)
} }
val iconView = it.findViewById(R.id.preference_icon) val iconView = it.findViewById(R.id.preference_icon)

@ -17,7 +17,7 @@ class SwitchPreference(context: Context, attrs: AttributeSet) :
init { init {
layoutResource = R.layout.view_preference layoutResource = R.layout.view_preference
val typedArray = context.obtainStyledAttributes(attrs, R.styleable.Preference) val typedArray = context.obtainStyledAttributes(attrs, R.styleable.Preference)
isBottomBackground = typedArray.getBoolean(R.styleable.Preference_bottomBackground, false) isBottomBackground = typedArray.getBoolean(R.styleable.Preference_isBottomBackground, false)
typedArray.recycle() typedArray.recycle()
} }

@ -4,8 +4,8 @@ import android.content.Context
import android.util.AttributeSet import android.util.AttributeSet
import androidx.appcompat.widget.AppCompatTextView import androidx.appcompat.widget.AppCompatTextView
import io.legado.app.R import io.legado.app.R
import io.legado.app.lib.theme.Selector import io.legado.app.lib.theme.*
import io.legado.app.lib.theme.ThemeStore import io.legado.app.utils.ColorUtils
import io.legado.app.utils.dp import io.legado.app.utils.dp
import io.legado.app.utils.getCompatColor import io.legado.app.utils.getCompatColor
@ -13,10 +13,13 @@ open class StrokeTextView(context: Context, attrs: AttributeSet?) :
AppCompatTextView(context, attrs) { AppCompatTextView(context, attrs) {
private var radius = 1.dp private var radius = 1.dp
private val isBottomBackground: Boolean
init { init {
val typedArray = context.obtainStyledAttributes(attrs, R.styleable.StrokeTextView) val typedArray = context.obtainStyledAttributes(attrs, R.styleable.StrokeTextView)
radius = typedArray.getDimensionPixelOffset(R.styleable.StrokeTextView_radius, radius) radius = typedArray.getDimensionPixelOffset(R.styleable.StrokeTextView_radius, radius)
isBottomBackground =
typedArray.getBoolean(R.styleable.StrokeTextView_isBottomBackground, false)
typedArray.recycle() typedArray.recycle()
upBackground() upBackground()
} }
@ -27,38 +30,59 @@ open class StrokeTextView(context: Context, attrs: AttributeSet?) :
} }
private fun upBackground() { private fun upBackground() {
if (isInEditMode) { when {
background = Selector.shapeBuild() isInEditMode -> {
.setCornerRadius(radius) background = Selector.shapeBuild()
.setStrokeWidth(1.dp) .setCornerRadius(radius)
.setDisabledStrokeColor(context.getCompatColor(R.color.md_grey_500)) .setStrokeWidth(1.dp)
.setDefaultStrokeColor(context.getCompatColor(R.color.secondaryText)) .setDisabledStrokeColor(context.getCompatColor(R.color.md_grey_500))
.setSelectedStrokeColor(context.getCompatColor(R.color.accent)) .setDefaultStrokeColor(context.getCompatColor(R.color.secondaryText))
.setPressedBgColor(context.getCompatColor(R.color.transparent30)) .setSelectedStrokeColor(context.getCompatColor(R.color.accent))
.create() .setPressedBgColor(context.getCompatColor(R.color.transparent30))
this.setTextColor(
Selector.colorBuild()
.setDefaultColor(context.getCompatColor(R.color.secondaryText))
.setSelectedColor(context.getCompatColor(R.color.accent))
.setDisabledColor(context.getCompatColor(R.color.md_grey_500))
.create() .create()
) this.setTextColor(
} else { Selector.colorBuild()
background = Selector.shapeBuild() .setDefaultColor(context.getCompatColor(R.color.secondaryText))
.setCornerRadius(radius) .setSelectedColor(context.getCompatColor(R.color.accent))
.setStrokeWidth(1.dp) .setDisabledColor(context.getCompatColor(R.color.md_grey_500))
.setDisabledStrokeColor(context.getCompatColor(R.color.md_grey_500)) .create()
.setDefaultStrokeColor(ThemeStore.textColorSecondary(context)) )
.setSelectedStrokeColor(ThemeStore.accentColor(context)) }
.setPressedBgColor(context.getCompatColor(R.color.transparent30)) isBottomBackground -> {
.create() val isLight = ColorUtils.isColorLight(context.bottomBackground)
this.setTextColor( background = Selector.shapeBuild()
Selector.colorBuild() .setCornerRadius(radius)
.setDefaultColor(ThemeStore.textColorSecondary(context)) .setStrokeWidth(1.dp)
.setSelectedColor(ThemeStore.accentColor(context)) .setDisabledStrokeColor(context.getCompatColor(R.color.md_grey_500))
.setDisabledColor(context.getCompatColor(R.color.md_grey_500)) .setDefaultStrokeColor(context.getPrimaryTextColor(isLight))
.setSelectedStrokeColor(context.accentColor)
.setPressedBgColor(context.getCompatColor(R.color.transparent30))
.create() .create()
) this.setTextColor(
Selector.colorBuild()
.setDefaultColor(context.getPrimaryTextColor(isLight))
.setSelectedColor(context.accentColor)
.setDisabledColor(context.getCompatColor(R.color.md_grey_500))
.create()
)
}
else -> {
background = Selector.shapeBuild()
.setCornerRadius(radius)
.setStrokeWidth(1.dp)
.setDisabledStrokeColor(context.getCompatColor(R.color.md_grey_500))
.setDefaultStrokeColor(ThemeStore.textColorSecondary(context))
.setSelectedStrokeColor(ThemeStore.accentColor(context))
.setPressedBgColor(context.getCompatColor(R.color.transparent30))
.create()
this.setTextColor(
Selector.colorBuild()
.setDefaultColor(ThemeStore.textColorSecondary(context))
.setSelectedColor(ThemeStore.accentColor(context))
.setDisabledColor(context.getCompatColor(R.color.md_grey_500))
.create()
)
}
} }
} }
} }

@ -30,6 +30,7 @@
android:text="@string/title" android:text="@string/title"
android:gravity="center" android:gravity="center"
android:textSize="14sp" android:textSize="14sp"
app:isBottomBackground="true"
app:radius="3dp" /> app:radius="3dp" />
<Space <Space
@ -47,6 +48,7 @@
android:paddingBottom="4dp" android:paddingBottom="4dp"
android:gravity="center" android:gravity="center"
android:textSize="14sp" android:textSize="14sp"
app:isBottomBackground="true"
app:radius="3dp" /> app:radius="3dp" />
<Space <Space
@ -65,6 +67,7 @@
android:text="@string/text_font" android:text="@string/text_font"
android:gravity="center" android:gravity="center"
android:textSize="14sp" android:textSize="14sp"
app:isBottomBackground="true"
app:radius="3dp" /> app:radius="3dp" />
<Space <Space
@ -83,6 +86,7 @@
android:text="@string/text_indent" android:text="@string/text_indent"
android:gravity="center" android:gravity="center"
android:textSize="14sp" android:textSize="14sp"
app:isBottomBackground="true"
app:radius="3dp" /> app:radius="3dp" />
<Space <Space
@ -100,6 +104,7 @@
android:paddingBottom="4dp" android:paddingBottom="4dp"
android:gravity="center" android:gravity="center"
android:textSize="14sp" android:textSize="14sp"
app:isBottomBackground="true"
app:radius="3dp" /> app:radius="3dp" />
<Space <Space
@ -118,6 +123,7 @@
android:text="@string/padding" android:text="@string/padding"
android:gravity="center" android:gravity="center"
android:textSize="14sp" android:textSize="14sp"
app:isBottomBackground="true"
app:radius="3dp" /> app:radius="3dp" />
<Space <Space
@ -136,6 +142,7 @@
android:text="@string/information" android:text="@string/information"
android:gravity="center" android:gravity="center"
android:textSize="14sp" android:textSize="14sp"
app:isBottomBackground="true"
app:radius="3dp" /> app:radius="3dp" />
<Space <Space
@ -152,6 +159,7 @@
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:paddingLeft="10dp" android:paddingLeft="10dp"
android:paddingRight="10dp" android:paddingRight="10dp"
app:isBottomBackground="true"
app:max="45" app:max="45"
app:title="@string/text_size" /> app:title="@string/text_size" />
@ -161,6 +169,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingLeft="10dp" android:paddingLeft="10dp"
android:paddingRight="10dp" android:paddingRight="10dp"
app:isBottomBackground="true"
app:max="100" app:max="100"
app:title="@string/text_letter_spacing" /> app:title="@string/text_letter_spacing" />
@ -170,6 +179,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingLeft="10dp" android:paddingLeft="10dp"
android:paddingRight="10dp" android:paddingRight="10dp"
app:isBottomBackground="true"
app:max="20" app:max="20"
app:title="@string/line_size" /> app:title="@string/line_size" />
@ -179,6 +189,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingLeft="10dp" android:paddingLeft="10dp"
android:paddingRight="10dp" android:paddingRight="10dp"
app:isBottomBackground="true"
app:max="20" app:max="20"
app:title="@string/paragraph_size" /> app:title="@string/paragraph_size" />

@ -2,6 +2,7 @@
<resources> <resources>
<attr name="radius" format="dimension" /> <attr name="radius" format="dimension" />
<attr name="isBottomBackground" format="boolean" />
<declare-styleable name="TitleBar"> <declare-styleable name="TitleBar">
<attr name="title" /> <attr name="title" />
@ -70,6 +71,7 @@
<declare-styleable name="DetailSeekBar"> <declare-styleable name="DetailSeekBar">
<attr name="title" format="string" /> <attr name="title" format="string" />
<attr name="max" format="integer" /> <attr name="max" format="integer" />
<attr name="isBottomBackground" />
</declare-styleable> </declare-styleable>
<declare-styleable name="SmoothCheckBox"> <declare-styleable name="SmoothCheckBox">
@ -161,6 +163,7 @@
<declare-styleable name="StrokeTextView"> <declare-styleable name="StrokeTextView">
<attr name="radius" /> <attr name="radius" />
<attr name="isBottomBackground" />
</declare-styleable> </declare-styleable>
<declare-styleable name="BadgeView"> <declare-styleable name="BadgeView">
@ -193,6 +196,6 @@
</declare-styleable> </declare-styleable>
<declare-styleable name="Preference"> <declare-styleable name="Preference">
<attr name="bottomBackground" format="boolean" /> <attr name="isBottomBackground" />
</declare-styleable> </declare-styleable>
</resources> </resources>

@ -9,7 +9,7 @@
android:entries="@array/screen_direction_title" android:entries="@array/screen_direction_title"
android:entryValues="@array/screen_direction_value" android:entryValues="@array/screen_direction_value"
app:iconSpaceReserved="false" app:iconSpaceReserved="false"
app:bottomBackground="true" /> app:isBottomBackground="true" />
<io.legado.app.ui.widget.prefs.NameListPreference <io.legado.app.ui.widget.prefs.NameListPreference
android:key="keep_light" android:key="keep_light"
@ -18,96 +18,96 @@
android:entries="@array/screen_time_out" android:entries="@array/screen_time_out"
android:title="@string/keep_light" android:title="@string/keep_light"
app:iconSpaceReserved="false" app:iconSpaceReserved="false"
app:bottomBackground="true" /> app:isBottomBackground="true" />
<io.legado.app.ui.widget.prefs.SwitchPreference <io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="false" android:defaultValue="false"
android:title="@string/pt_hide_status_bar" android:title="@string/pt_hide_status_bar"
android:key="hideStatusBar" android:key="hideStatusBar"
app:iconSpaceReserved="false" app:iconSpaceReserved="false"
app:bottomBackground="true" /> app:isBottomBackground="true" />
<io.legado.app.ui.widget.prefs.SwitchPreference <io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="true" android:defaultValue="true"
android:title="@string/read_body_to_lh" android:title="@string/read_body_to_lh"
android:key="readBodyToLh" android:key="readBodyToLh"
app:iconSpaceReserved="false" app:iconSpaceReserved="false"
app:bottomBackground="true" /> app:isBottomBackground="true" />
<io.legado.app.ui.widget.prefs.SwitchPreference <io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="false" android:defaultValue="false"
android:title="@string/pt_hide_navigation_bar" android:title="@string/pt_hide_navigation_bar"
android:key="hideNavigationBar" android:key="hideNavigationBar"
app:iconSpaceReserved="false" app:iconSpaceReserved="false"
app:bottomBackground="true" /> app:isBottomBackground="true" />
<io.legado.app.ui.widget.prefs.SwitchPreference <io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="true" android:defaultValue="true"
android:title="@string/text_full_justify" android:title="@string/text_full_justify"
android:key="textFullJustify" android:key="textFullJustify"
app:iconSpaceReserved="false" app:iconSpaceReserved="false"
app:bottomBackground="true" /> app:isBottomBackground="true" />
<io.legado.app.ui.widget.prefs.SwitchPreference <io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="true" android:defaultValue="true"
android:title="@string/text_bottom_justify" android:title="@string/text_bottom_justify"
android:key="textBottomJustify" android:key="textBottomJustify"
app:iconSpaceReserved="false" app:iconSpaceReserved="false"
app:bottomBackground="true" /> app:isBottomBackground="true" />
<io.legado.app.ui.widget.prefs.SwitchPreference <io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="true" android:defaultValue="true"
android:title="@string/volume_key_page" android:title="@string/volume_key_page"
android:key="volumeKeyPage" android:key="volumeKeyPage"
app:iconSpaceReserved="false" app:iconSpaceReserved="false"
app:bottomBackground="true" /> app:isBottomBackground="true" />
<io.legado.app.ui.widget.prefs.SwitchPreference <io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="true" android:defaultValue="true"
android:title="@string/click_turn_page" android:title="@string/click_turn_page"
android:key="clickTurnPage" android:key="clickTurnPage"
app:iconSpaceReserved="false" app:iconSpaceReserved="false"
app:bottomBackground="true" /> app:isBottomBackground="true" />
<io.legado.app.ui.widget.prefs.SwitchPreference <io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="false" android:defaultValue="false"
android:title="@string/click_all_next_page" android:title="@string/click_all_next_page"
android:key="clickAllNext" android:key="clickAllNext"
app:iconSpaceReserved="false" app:iconSpaceReserved="false"
app:bottomBackground="true" /> app:isBottomBackground="true" />
<io.legado.app.ui.widget.prefs.SwitchPreference <io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="false" android:defaultValue="false"
android:title="@string/volume_key_page_on_play" android:title="@string/volume_key_page_on_play"
android:key="volumeKeyPageOnPlay" android:key="volumeKeyPageOnPlay"
app:iconSpaceReserved="false" app:iconSpaceReserved="false"
app:bottomBackground="true" /> app:isBottomBackground="true" />
<io.legado.app.ui.widget.prefs.SwitchPreference <io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="true" android:defaultValue="true"
android:title="@string/auto_change_source" android:title="@string/auto_change_source"
android:key="autoChangeSource" android:key="autoChangeSource"
app:iconSpaceReserved="false" app:iconSpaceReserved="false"
app:bottomBackground="true" /> app:isBottomBackground="true" />
<io.legado.app.ui.widget.prefs.SwitchPreference <io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="false" android:defaultValue="false"
android:title="@string/selectText" android:title="@string/selectText"
android:key="selectText" android:key="selectText"
app:iconSpaceReserved="false" app:iconSpaceReserved="false"
app:bottomBackground="true" /> app:isBottomBackground="true" />
<io.legado.app.ui.widget.prefs.SwitchPreference <io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="true" android:defaultValue="true"
android:title="@string/show_brightness_view" android:title="@string/show_brightness_view"
android:key="showBrightnessView" android:key="showBrightnessView"
app:iconSpaceReserved="false" app:iconSpaceReserved="false"
app:bottomBackground="true" /> app:isBottomBackground="true" />
<io.legado.app.ui.widget.prefs.Preference <io.legado.app.ui.widget.prefs.Preference
android:key="customPageKey" android:key="customPageKey"
android:title="@string/custom_page_key" android:title="@string/custom_page_key"
app:iconSpaceReserved="false" app:iconSpaceReserved="false"
app:bottomBackground="true" /> app:isBottomBackground="true" />
</androidx.preference.PreferenceScreen> </androidx.preference.PreferenceScreen>
Loading…
Cancel
Save