feat: 优化

pull/277/head
kunfei 5 years ago
parent f9e9f7c29a
commit e7c50cf125
  1. 6
      app/src/main/java/io/legado/app/ui/widget/prefs/PreferenceCategory.kt
  2. 2
      app/src/main/java/io/legado/app/ui/widget/prefs/SwitchPreference.kt
  3. 1
      app/src/main/res/layout/view_preference_category.xml
  4. 9
      app/src/main/res/xml/pref_config_read.xml

@ -12,7 +12,6 @@ import io.legado.app.help.AppConfig
import io.legado.app.lib.theme.ColorUtils import io.legado.app.lib.theme.ColorUtils
import io.legado.app.lib.theme.accentColor import io.legado.app.lib.theme.accentColor
import io.legado.app.lib.theme.backgroundColor import io.legado.app.lib.theme.backgroundColor
import io.legado.app.utils.getCompatColor
class PreferenceCategory(context: Context, attrs: AttributeSet) : PreferenceCategory(context, attrs) { class PreferenceCategory(context: Context, attrs: AttributeSet) : PreferenceCategory(context, attrs) {
@ -28,12 +27,9 @@ class PreferenceCategory(context: Context, attrs: AttributeSet) : PreferenceCate
val view = it.findViewById(R.id.preference_title) val view = it.findViewById(R.id.preference_title)
if (view is TextView) { // && !view.isInEditMode if (view is TextView) { // && !view.isInEditMode
view.text = title view.text = title
if (view.isInEditMode) { if (view.isInEditMode) return
view.setTextColor(context.getCompatColor(R.color.colorAccent))
} else {
view.setBackgroundColor(context.backgroundColor) view.setBackgroundColor(context.backgroundColor)
view.setTextColor(context.accentColor) view.setTextColor(context.accentColor)
}
view.isVisible = title != null && title.isNotEmpty() view.isVisible = title != null && title.isNotEmpty()
val da = it.findViewById(R.id.preference_divider_above) val da = it.findViewById(R.id.preference_divider_above)

@ -26,7 +26,7 @@ class SwitchPreference(context: Context, attrs: AttributeSet) :
widgetLayoutResource, widgetLayoutResource,
R.id.switchWidget R.id.switchWidget
) )
if (v is SwitchCompat) { if (v is SwitchCompat && !v.isInEditMode) {
ATH.setTint(v, context.accentColor) ATH.setTint(v, context.accentColor)
} }
super.onBindViewHolder(holder) super.onBindViewHolder(holder)

@ -19,6 +19,7 @@
android:paddingLeft="16dp" android:paddingLeft="16dp"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textColor="@color/colorAccent"
tools:ignore="RtlHardcoded,RtlSymmetry" /> tools:ignore="RtlHardcoded,RtlSymmetry" />
<View <View

@ -2,6 +2,12 @@
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" <androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"> xmlns:app="http://schemas.android.com/apk/res-auto">
<io.legado.app.ui.widget.prefs.PreferenceCategory
android:title="@string/setting"
app:allowDividerAbove="false"
app:allowDividerBelow="false"
app:iconSpaceReserved="false">
<io.legado.app.ui.widget.prefs.NameListPreference <io.legado.app.ui.widget.prefs.NameListPreference
android:key="@string/pk_requested_direction" android:key="@string/pk_requested_direction"
android:defaultValue="0" android:defaultValue="0"
@ -77,4 +83,7 @@
android:title="@string/custom_page_key" android:title="@string/custom_page_key"
app:iconSpaceReserved="false" /> app:iconSpaceReserved="false" />
</io.legado.app.ui.widget.prefs.PreferenceCategory>
</androidx.preference.PreferenceScreen> </androidx.preference.PreferenceScreen>
Loading…
Cancel
Save