From e198f7e67120d7b3b56e7d5268ee9dde26421deb Mon Sep 17 00:00:00 2001 From: len Date: Sat, 2 Jul 2016 22:14:04 +0200 Subject: [PATCH] Add icons for settings --- .../ui/catalogue/CataloguePresenter.kt | 1 + .../tachiyomi/ui/setting/SettingsFragment.kt | 30 +++++++++++++++++++ .../ic_chrome_reader_mode_black_24dp.xml | 9 ++++++ .../main/res/drawable/ic_code_black_24dp.xml | 9 ++++++ .../main/res/drawable/ic_help_black_24dp.xml | 9 ++++++ .../res/drawable/ic_language_black_24dp.xml | 9 ++++++ .../main/res/drawable/ic_sync_black_24dp.xml | 9 ++++++ .../main/res/drawable/ic_tune_black_24dp.xml | 9 ++++++ 8 files changed, 85 insertions(+) create mode 100644 app/src/main/res/drawable/ic_chrome_reader_mode_black_24dp.xml create mode 100644 app/src/main/res/drawable/ic_code_black_24dp.xml create mode 100644 app/src/main/res/drawable/ic_help_black_24dp.xml create mode 100644 app/src/main/res/drawable/ic_language_black_24dp.xml create mode 100644 app/src/main/res/drawable/ic_sync_black_24dp.xml create mode 100644 app/src/main/res/drawable/ic_tune_black_24dp.xml diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CataloguePresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CataloguePresenter.kt index 6d1b9426a..359c1c04c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CataloguePresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CataloguePresenter.kt @@ -229,6 +229,7 @@ class CataloguePresenter : BasePresenter() { source.fetchSearchManga(nextMangasPage, query) return observable.subscribeOn(Schedulers.io()) + .doOnNext { if (it.mangas.isEmpty()) throw Exception("Empty page") } .doOnNext { lastMangasPage = it } .flatMap { Observable.from(it.mangas) } .map { networkToLocalManga(it) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsFragment.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsFragment.kt index da3d7aca3..8c74375c6 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsFragment.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsFragment.kt @@ -2,10 +2,14 @@ package eu.kanade.tachiyomi.ui.setting import android.os.Bundle import android.support.annotation.CallSuper +import android.support.graphics.drawable.VectorDrawableCompat +import android.support.v4.content.ContextCompat import android.support.v7.preference.XpPreferenceFragment import android.view.View import eu.kanade.tachiyomi.R +import net.xpece.android.support.preference.PreferenceIconHelper import net.xpece.android.support.preference.PreferenceScreenNavigationStrategy +import net.xpece.android.support.preference.Util import rx.subscriptions.CompositeSubscription open class SettingsFragment : XpPreferenceFragment() { @@ -20,6 +24,10 @@ open class SettingsFragment : XpPreferenceFragment() { lateinit var subscriptions: CompositeSubscription + private val iconTint by lazy { ContextCompat.getColorStateList( + context, Util.resolveResourceId(context, R.attr.colorAccent, 0)) + } + override final fun onCreatePreferences2(savedState: Bundle?, rootKey: String?) { subscriptions = CompositeSubscription() @@ -31,6 +39,18 @@ open class SettingsFragment : XpPreferenceFragment() { addPreferencesFromResource(R.xml.pref_advanced) 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. preferenceScreen.title = activity.title @@ -52,4 +72,14 @@ open class SettingsFragment : XpPreferenceFragment() { 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 + ) + } \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_chrome_reader_mode_black_24dp.xml b/app/src/main/res/drawable/ic_chrome_reader_mode_black_24dp.xml new file mode 100644 index 000000000..99b5867b3 --- /dev/null +++ b/app/src/main/res/drawable/ic_chrome_reader_mode_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_code_black_24dp.xml b/app/src/main/res/drawable/ic_code_black_24dp.xml new file mode 100644 index 000000000..6f1ccb6e4 --- /dev/null +++ b/app/src/main/res/drawable/ic_code_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_help_black_24dp.xml b/app/src/main/res/drawable/ic_help_black_24dp.xml new file mode 100644 index 000000000..1517747d0 --- /dev/null +++ b/app/src/main/res/drawable/ic_help_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_language_black_24dp.xml b/app/src/main/res/drawable/ic_language_black_24dp.xml new file mode 100644 index 000000000..d07324c87 --- /dev/null +++ b/app/src/main/res/drawable/ic_language_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_sync_black_24dp.xml b/app/src/main/res/drawable/ic_sync_black_24dp.xml new file mode 100644 index 000000000..ce8796cb7 --- /dev/null +++ b/app/src/main/res/drawable/ic_sync_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_tune_black_24dp.xml b/app/src/main/res/drawable/ic_tune_black_24dp.xml new file mode 100644 index 000000000..a15149da2 --- /dev/null +++ b/app/src/main/res/drawable/ic_tune_black_24dp.xml @@ -0,0 +1,9 @@ + + +