Add logo header in more section

This commit is contained in:
arkon 2020-04-27 22:48:25 -04:00
parent 2ad3fa1593
commit 90ce89193d
3 changed files with 44 additions and 1 deletions

View File

@ -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/"
}

View File

@ -72,6 +72,13 @@ fun initDialog(dialogPreference: DialogPreference) {
}
}
inline fun <P : Preference> PreferenceGroup.add(p: P): P {
return p.apply {
this.isIconSpaceReserved = false
addPreference(this)
}
}
inline fun <P : Preference> PreferenceGroup.initThenAdd(p: P, block: P.() -> Unit): P {
return p.apply {
block()

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:elevation="2dp"
android:padding="48dp">
<ImageView
android:layout_width="72dp"
android:layout_height="72dp"
android:layout_gravity="center"
app:srcCompat="@drawable/ic_tachi"
app:tint="?attr/colorOnPrimary" />
</FrameLayout>