diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/more/MoreController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/more/MoreController.kt index 457220789..713dd612b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/more/MoreController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/more/MoreController.kt @@ -1,14 +1,19 @@ package eu.kanade.tachiyomi.ui.more +import android.content.Context +import android.util.AttributeSet +import androidx.preference.Preference import androidx.preference.PreferenceScreen import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys +import eu.kanade.tachiyomi.ui.base.controller.NoToolbarElevationController import eu.kanade.tachiyomi.ui.base.controller.RootController import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction import eu.kanade.tachiyomi.ui.download.DownloadController import eu.kanade.tachiyomi.ui.migration.MigrationController import eu.kanade.tachiyomi.ui.setting.SettingsController import eu.kanade.tachiyomi.ui.setting.SettingsMainController +import eu.kanade.tachiyomi.util.preference.add import eu.kanade.tachiyomi.util.preference.iconRes import eu.kanade.tachiyomi.util.preference.iconTint import eu.kanade.tachiyomi.util.preference.onClick @@ -21,13 +26,18 @@ import eu.kanade.tachiyomi.util.system.getResourceColor import eu.kanade.tachiyomi.util.system.openInBrowser import uy.kohesive.injekt.api.get -class MoreController : SettingsController(), RootController { +class MoreController : + SettingsController(), + RootController, + NoToolbarElevationController { override fun setupPreferenceScreen(screen: PreferenceScreen) = with(screen) { titleRes = R.string.label_more val tintColor = context.getResourceColor(R.attr.colorAccent) + add(MoreHeaderPreference(context)) + switchPreference { key = Keys.downloadedOnly titleRes = R.string.label_downloaded_only @@ -83,6 +93,15 @@ class MoreController : SettingsController(), RootController { } } + private class MoreHeaderPreference @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : + Preference(context, attrs) { + + init { + layoutResource = R.layout.pref_more_header + isSelectable = false + } + } + companion object { private const val URL_HELP = "https://tachiyomi.org/help/" } diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/preference/PreferenceDSL.kt b/app/src/main/java/eu/kanade/tachiyomi/util/preference/PreferenceDSL.kt index 03ead952b..db7b40e4d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/preference/PreferenceDSL.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/preference/PreferenceDSL.kt @@ -72,6 +72,13 @@ fun initDialog(dialogPreference: DialogPreference) { } } +inline fun

PreferenceGroup.add(p: P): P { + return p.apply { + this.isIconSpaceReserved = false + addPreference(this) + } +} + inline fun

PreferenceGroup.initThenAdd(p: P, block: P.() -> Unit): P { return p.apply { block() diff --git a/app/src/main/res/layout/pref_more_header.xml b/app/src/main/res/layout/pref_more_header.xml new file mode 100644 index 000000000..4ddcc1f1b --- /dev/null +++ b/app/src/main/res/layout/pref_more_header.xml @@ -0,0 +1,17 @@ + + + + + +