mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 14:11:50 +01:00
Add logo header in more section
This commit is contained in:
parent
2ad3fa1593
commit
90ce89193d
@ -1,14 +1,19 @@
|
|||||||
package eu.kanade.tachiyomi.ui.more
|
package eu.kanade.tachiyomi.ui.more
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.util.AttributeSet
|
||||||
|
import androidx.preference.Preference
|
||||||
import androidx.preference.PreferenceScreen
|
import androidx.preference.PreferenceScreen
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
|
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.RootController
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
||||||
import eu.kanade.tachiyomi.ui.download.DownloadController
|
import eu.kanade.tachiyomi.ui.download.DownloadController
|
||||||
import eu.kanade.tachiyomi.ui.migration.MigrationController
|
import eu.kanade.tachiyomi.ui.migration.MigrationController
|
||||||
import eu.kanade.tachiyomi.ui.setting.SettingsController
|
import eu.kanade.tachiyomi.ui.setting.SettingsController
|
||||||
import eu.kanade.tachiyomi.ui.setting.SettingsMainController
|
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.iconRes
|
||||||
import eu.kanade.tachiyomi.util.preference.iconTint
|
import eu.kanade.tachiyomi.util.preference.iconTint
|
||||||
import eu.kanade.tachiyomi.util.preference.onClick
|
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 eu.kanade.tachiyomi.util.system.openInBrowser
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
|
|
||||||
class MoreController : SettingsController(), RootController {
|
class MoreController :
|
||||||
|
SettingsController(),
|
||||||
|
RootController,
|
||||||
|
NoToolbarElevationController {
|
||||||
|
|
||||||
override fun setupPreferenceScreen(screen: PreferenceScreen) = with(screen) {
|
override fun setupPreferenceScreen(screen: PreferenceScreen) = with(screen) {
|
||||||
titleRes = R.string.label_more
|
titleRes = R.string.label_more
|
||||||
|
|
||||||
val tintColor = context.getResourceColor(R.attr.colorAccent)
|
val tintColor = context.getResourceColor(R.attr.colorAccent)
|
||||||
|
|
||||||
|
add(MoreHeaderPreference(context))
|
||||||
|
|
||||||
switchPreference {
|
switchPreference {
|
||||||
key = Keys.downloadedOnly
|
key = Keys.downloadedOnly
|
||||||
titleRes = R.string.label_downloaded_only
|
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 {
|
companion object {
|
||||||
private const val URL_HELP = "https://tachiyomi.org/help/"
|
private const val URL_HELP = "https://tachiyomi.org/help/"
|
||||||
}
|
}
|
||||||
|
@ -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 {
|
inline fun <P : Preference> PreferenceGroup.initThenAdd(p: P, block: P.() -> Unit): P {
|
||||||
return p.apply {
|
return p.apply {
|
||||||
block()
|
block()
|
||||||
|
17
app/src/main/res/layout/pref_more_header.xml
Normal file
17
app/src/main/res/layout/pref_more_header.xml
Normal 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>
|
Loading…
Reference in New Issue
Block a user