优化主题

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. 32
      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.SeekBar
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 kotlinx.android.synthetic.main.view_detail_seek_bar.view.*
import org.jetbrains.anko.sdk27.listeners.onClick
class DetailSeekBar(context: Context, attrs: AttributeSet?) : FrameLayout(context, attrs),
SeekBar.OnSeekBarChangeListener {
private val isBottomBackground: Boolean
var valueFormat: ((progress: Int) -> String)? = null
var onChanged: ((progress: Int) -> Unit)? = null
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)
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)
seek_bar.max = typedArray.getInteger(R.styleable.DetailSeekBar_max, 0)
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 {
seek_bar.progressAdd(1)
onChanged?.invoke(seek_bar.progress)

@ -19,7 +19,7 @@ class NameListPreference(context: Context, attrs: AttributeSet) : ListPreference
layoutResource = R.layout.view_preference
widgetLayoutResource = R.layout.item_fillet_text
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()
}

@ -30,7 +30,7 @@ class Preference(context: Context, attrs: AttributeSet) :
init {
layoutResource = R.layout.view_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()
}
@ -58,10 +58,10 @@ class Preference(context: Context, attrs: AttributeSet) :
tvSummary.isGone = summary.isNullOrEmpty()
}
if (isBottomBackground && !tvTitle.isInEditMode) {
val bgColor = context.bottomBackground
val pTextColor = context.getPrimaryTextColor(ColorUtils.isColorLight(bgColor))
val isLight = ColorUtils.isColorLight(context.bottomBackground)
val pTextColor = context.getPrimaryTextColor(isLight)
tvTitle.setTextColor(pTextColor)
val sTextColor = context.getSecondaryTextColor(ColorUtils.isColorLight(bgColor))
val sTextColor = context.getSecondaryTextColor(isLight)
tvSummary?.setTextColor(sTextColor)
}
val iconView = it.findViewById(R.id.preference_icon)

@ -17,7 +17,7 @@ class SwitchPreference(context: Context, attrs: AttributeSet) :
init {
layoutResource = R.layout.view_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()
}

@ -4,8 +4,8 @@ import android.content.Context
import android.util.AttributeSet
import androidx.appcompat.widget.AppCompatTextView
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.*
import io.legado.app.utils.ColorUtils
import io.legado.app.utils.dp
import io.legado.app.utils.getCompatColor
@ -13,10 +13,13 @@ open class StrokeTextView(context: Context, attrs: AttributeSet?) :
AppCompatTextView(context, attrs) {
private var radius = 1.dp
private val isBottomBackground: Boolean
init {
val typedArray = context.obtainStyledAttributes(attrs, R.styleable.StrokeTextView)
radius = typedArray.getDimensionPixelOffset(R.styleable.StrokeTextView_radius, radius)
isBottomBackground =
typedArray.getBoolean(R.styleable.StrokeTextView_isBottomBackground, false)
typedArray.recycle()
upBackground()
}
@ -27,7 +30,8 @@ open class StrokeTextView(context: Context, attrs: AttributeSet?) :
}
private fun upBackground() {
if (isInEditMode) {
when {
isInEditMode -> {
background = Selector.shapeBuild()
.setCornerRadius(radius)
.setStrokeWidth(1.dp)
@ -43,7 +47,26 @@ open class StrokeTextView(context: Context, attrs: AttributeSet?) :
.setDisabledColor(context.getCompatColor(R.color.md_grey_500))
.create()
)
} else {
}
isBottomBackground -> {
val isLight = ColorUtils.isColorLight(context.bottomBackground)
background = Selector.shapeBuild()
.setCornerRadius(radius)
.setStrokeWidth(1.dp)
.setDisabledStrokeColor(context.getCompatColor(R.color.md_grey_500))
.setDefaultStrokeColor(context.getPrimaryTextColor(isLight))
.setSelectedStrokeColor(context.accentColor)
.setPressedBgColor(context.getCompatColor(R.color.transparent30))
.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)
@ -61,4 +84,5 @@ open class StrokeTextView(context: Context, attrs: AttributeSet?) :
)
}
}
}
}

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

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

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