Update preferences lib

This commit is contained in:
len 2016-11-27 22:02:23 +01:00
parent 12dcc2c31f
commit 44241e03da
10 changed files with 43 additions and 74 deletions

View File

@ -185,7 +185,7 @@ dependencies {
compile 'com.nononsenseapps:filepicker:2.5.2' compile 'com.nononsenseapps:filepicker:2.5.2'
compile 'com.github.amulyakhare:TextDrawable:558677e' compile 'com.github.amulyakhare:TextDrawable:558677e'
compile 'com.afollestad.material-dialogs:core:0.9.1.0' compile 'com.afollestad.material-dialogs:core:0.9.1.0'
compile 'net.xpece.android:support-preference:1.0.3' compile 'net.xpece.android:support-preference:1.2.0'
compile 'me.zhanghai.android.systemuihelper:library:1.0.0' compile 'me.zhanghai.android.systemuihelper:library:1.0.0'
compile 'de.hdodenhof:circleimageview:2.1.0' compile 'de.hdodenhof:circleimageview:2.1.0'

View File

@ -2,14 +2,10 @@ package eu.kanade.tachiyomi.ui.setting
import android.os.Bundle import android.os.Bundle
import android.support.annotation.CallSuper import android.support.annotation.CallSuper
import android.support.graphics.drawable.VectorDrawableCompat
import android.support.v4.content.ContextCompat
import android.support.v7.preference.Preference import android.support.v7.preference.Preference
import android.support.v7.preference.XpPreferenceFragment import android.support.v7.preference.XpPreferenceFragment
import android.view.View import android.view.View
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.util.getResourceId
import net.xpece.android.support.preference.PreferenceIconHelper
import net.xpece.android.support.preference.PreferenceScreenNavigationStrategy import net.xpece.android.support.preference.PreferenceScreenNavigationStrategy
import rx.subscriptions.CompositeSubscription import rx.subscriptions.CompositeSubscription
@ -25,10 +21,6 @@ open class SettingsFragment : XpPreferenceFragment() {
lateinit var subscriptions: CompositeSubscription lateinit var subscriptions: CompositeSubscription
private val iconTint by lazy { ContextCompat.getColorStateList(context,
context.theme.getResourceId(R.attr.colorAccent, 0))
}
override final fun onCreatePreferences2(savedState: Bundle?, rootKey: String?) { override final fun onCreatePreferences2(savedState: Bundle?, rootKey: String?) {
subscriptions = CompositeSubscription() subscriptions = CompositeSubscription()
@ -40,18 +32,6 @@ open class SettingsFragment : XpPreferenceFragment() {
addPreferencesFromResource(R.xml.pref_advanced) addPreferencesFromResource(R.xml.pref_advanced)
addPreferencesFromResource(R.xml.pref_about) addPreferencesFromResource(R.xml.pref_about)
// Add an icon to each subscreen
for ((screen, drawable) in getSubscreenIcons()) {
val icon = VectorDrawableCompat.create(resources, drawable, context.theme) ?: continue
PreferenceIconHelper(findPreference(screen)).apply {
isIconPaddingEnabled = true
setIcon(icon)
tintList = iconTint
isIconTintEnabled = true
}
}
// Setup root preference title. // Setup root preference title.
preferenceScreen.title = activity.title preferenceScreen.title = activity.title
@ -74,16 +54,6 @@ open class SettingsFragment : XpPreferenceFragment() {
super.onDestroyView() super.onDestroyView()
} }
private fun getSubscreenIcons() = listOf(
"general_screen" to R.drawable.ic_tune_black_24dp,
"reader_screen" to R.drawable.ic_chrome_reader_mode_black_24dp,
"downloads_screen" to R.drawable.ic_file_download_black_24dp,
"sources_screen" to R.drawable.ic_language_black_24dp,
"sync_screen" to R.drawable.ic_sync_black_24dp,
"advanced_screen" to R.drawable.ic_code_black_24dp,
"about_screen" to R.drawable.ic_help_black_24dp
)
protected inline fun <reified T : Preference> bindPref(resId: Int): Lazy<T> { protected inline fun <reified T : Preference> bindPref(resId: Int): Lazy<T> {
return lazy { findPreference(getString(resId)) as T } return lazy { findPreference(getString(resId)) as T }
} }

View File

@ -1,29 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2015 The Android Open Source Project
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License
-->
<!-- Layout used by SwitchPreference for the switch widget style. This is inflated
inside android.R.layout.preference. -->
<Switch android:id="@+id/switchWidget"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="-4dp"
android:layout_marginStart="-4dp"
android:background="@null"
android:clickable="false"
android:focusable="false"
android:showText="false"/>

View File

@ -1,10 +1,14 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<PreferenceScreen <PreferenceScreen
android:icon="@drawable/ic_help_black_24dp"
android:key="about_screen" android:key="about_screen"
android:persistent="false"
android:title="@string/pref_category_about" android:title="@string/pref_category_about"
android:persistent="false"> app:asp_tintEnabled="true">
<SwitchPreference <SwitchPreference
android:defaultValue="true" android:defaultValue="true"

View File

@ -1,10 +1,14 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<PreferenceScreen <PreferenceScreen
android:icon="@drawable/ic_code_black_24dp"
android:key="advanced_screen" android:key="advanced_screen"
android:persistent="false" android:persistent="false"
android:title="@string/pref_category_advanced"> android:title="@string/pref_category_advanced"
app:asp_tintEnabled="true">
<Preference <Preference
android:key="@string/pref_clear_chapter_cache_key" android:key="@string/pref_clear_chapter_cache_key"

View File

@ -1,10 +1,14 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<PreferenceScreen <PreferenceScreen
android:icon="@drawable/ic_file_download_black_24dp"
android:key="downloads_screen" android:key="downloads_screen"
android:persistent="false" android:persistent="false"
android:title="@string/pref_category_downloads"> android:title="@string/pref_category_downloads"
app:asp_tintEnabled="true">
<Preference <Preference
android:key="@string/pref_download_directory_key" android:key="@string/pref_download_directory_key"

View File

@ -1,10 +1,14 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<PreferenceScreen <PreferenceScreen
android:icon="@drawable/ic_tune_black_24dp"
android:key="general_screen" android:key="general_screen"
android:persistent="false" android:persistent="false"
android:title="@string/pref_category_general"> android:title="@string/pref_category_general"
app:asp_tintEnabled="true">
<eu.kanade.tachiyomi.widget.preference.IntListPreference <eu.kanade.tachiyomi.widget.preference.IntListPreference
android:defaultValue="1" android:defaultValue="1"

View File

@ -1,10 +1,14 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<PreferenceScreen <PreferenceScreen
android:icon="@drawable/ic_chrome_reader_mode_black_24dp"
android:key="reader_screen" android:key="reader_screen"
android:persistent="false" android:persistent="false"
android:title="@string/pref_category_reader"> android:title="@string/pref_category_reader"
app:asp_tintEnabled="true">
<eu.kanade.tachiyomi.widget.preference.IntListPreference <eu.kanade.tachiyomi.widget.preference.IntListPreference
android:title="@string/pref_viewer_type" android:title="@string/pref_viewer_type"

View File

@ -1,10 +1,14 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<PreferenceScreen <PreferenceScreen
android:icon="@drawable/ic_language_black_24dp"
android:key="sources_screen" android:key="sources_screen"
android:persistent="false" android:persistent="false"
android:title="@string/pref_category_sources"> android:title="@string/pref_category_sources"
app:asp_tintEnabled="true">
<!-- Dummy preference, it's needed at least one --> <!-- Dummy preference, it's needed at least one -->
<Preference/> <Preference/>

View File

@ -1,10 +1,14 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<PreferenceScreen <PreferenceScreen
android:icon="@drawable/ic_sync_black_24dp"
android:key="sync_screen" android:key="sync_screen"
android:persistent="false" android:persistent="false"
android:title="@string/pref_category_sync"> android:title="@string/pref_category_sync"
app:asp_tintEnabled="true">
<SwitchPreference <SwitchPreference
android:key="@string/pref_auto_update_manga_sync_key" android:key="@string/pref_auto_update_manga_sync_key"