feat: 优化

pull/277/head
kunfei 5 years ago
parent f9e9f7c29a
commit e7c50cf125
  1. 10
      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. 157
      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)) view.setBackgroundColor(context.backgroundColor)
} else { view.setTextColor(context.accentColor)
view.setBackgroundColor(context.backgroundColor)
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,79 +2,88 @@
<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.NameListPreference <io.legado.app.ui.widget.prefs.PreferenceCategory
android:key="@string/pk_requested_direction" android:title="@string/setting"
android:defaultValue="0" app:allowDividerAbove="false"
android:title="@string/screen_direction" app:allowDividerBelow="false"
android:entries="@array/screen_direction_title" app:iconSpaceReserved="false">
android:entryValues="@array/screen_direction_value"
app:iconSpaceReserved="false" /> <io.legado.app.ui.widget.prefs.NameListPreference
android:key="@string/pk_requested_direction"
<io.legado.app.ui.widget.prefs.NameListPreference android:defaultValue="0"
android:key="keep_light" android:title="@string/screen_direction"
android:defaultValue="0" android:entries="@array/screen_direction_title"
android:entryValues="@array/screen_time_out_value" android:entryValues="@array/screen_direction_value"
android:entries="@array/screen_time_out" app:iconSpaceReserved="false" />
android:title="@string/keep_light"
app:iconSpaceReserved="false" /> <io.legado.app.ui.widget.prefs.NameListPreference
android:key="keep_light"
<io.legado.app.ui.widget.prefs.SwitchPreference android:defaultValue="0"
android:defaultValue="false" android:entryValues="@array/screen_time_out_value"
android:title="@string/pt_hide_status_bar" android:entries="@array/screen_time_out"
android:key="hideStatusBar" android:title="@string/keep_light"
app:iconSpaceReserved="false" /> app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.SwitchPreference <io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="true" android:defaultValue="false"
android:title="@string/read_body_to_lh" android:title="@string/pt_hide_status_bar"
android:key="readBodyToLh" android:key="hideStatusBar"
app:iconSpaceReserved="false" /> app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.SwitchPreference <io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="false" android:defaultValue="true"
android:title="@string/pt_hide_navigation_bar" android:title="@string/read_body_to_lh"
android:key="hideNavigationBar" android:key="readBodyToLh"
app:iconSpaceReserved="false" /> app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.SwitchPreference <io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="true" android:defaultValue="false"
android:title="@string/volume_key_page" android:title="@string/pt_hide_navigation_bar"
android:key="volumeKeyPage" android:key="hideNavigationBar"
app:iconSpaceReserved="false" /> app:iconSpaceReserved="false" />
<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/volume_key_page"
android:key="clickTurnPage" android:key="volumeKeyPage"
app:iconSpaceReserved="false" /> app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.SwitchPreference <io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="false" android:defaultValue="true"
android:title="@string/click_all_next_page" android:title="@string/click_turn_page"
android:key="clickAllNext" android:key="clickTurnPage"
app:iconSpaceReserved="false" /> app:iconSpaceReserved="false" />
<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/click_all_next_page"
android:key="volumeKeyPageOnPlay" android:key="clickAllNext"
app:iconSpaceReserved="false" /> app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.SwitchPreference <io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="true" android:defaultValue="false"
android:title="@string/auto_change_source" android:title="@string/volume_key_page_on_play"
android:key="autoChangeSource" android:key="volumeKeyPageOnPlay"
app:iconSpaceReserved="false" /> app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.SwitchPreference <io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="false" android:defaultValue="true"
android:title="@string/selectText" android:title="@string/auto_change_source"
android:key="selectText" android:key="autoChangeSource"
app:iconSpaceReserved="false" /> app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.Preference <io.legado.app.ui.widget.prefs.SwitchPreference
android:key="customPageKey" android:defaultValue="false"
android:title="@string/custom_page_key" android:title="@string/selectText"
app:iconSpaceReserved="false" /> android:key="selectText"
app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.Preference
android:key="customPageKey"
android:title="@string/custom_page_key"
app:iconSpaceReserved="false" />
</io.legado.app.ui.widget.prefs.PreferenceCategory>
</androidx.preference.PreferenceScreen> </androidx.preference.PreferenceScreen>
Loading…
Cancel
Save