More fixing to download listeners

Updates to filter bottom bar layout
Removed Download queue preference
This commit is contained in:
Jay 2020-02-06 21:04:43 -08:00
parent 562de30173
commit 7f1f2b7863
14 changed files with 125 additions and 165 deletions

View File

@ -96,6 +96,7 @@ class DownloadManager(val context: Context) {
fun clearQueue(isNotification: Boolean = false) { fun clearQueue(isNotification: Boolean = false) {
deletePendingDownloads(*downloader.queue.toTypedArray()) deletePendingDownloads(*downloader.queue.toTypedArray())
downloader.clearQueue(isNotification) downloader.clearQueue(isNotification)
DownloadService.callListeners(false)
} }
/** /**

View File

@ -50,10 +50,10 @@ class DownloadService : Service() {
listeners.remove(listener) listeners.remove(listener)
} }
fun callListeners() { fun callListeners(downloading: Boolean? = null) {
val downloadManager: DownloadManager by injectLazy() val downloadManager: DownloadManager by injectLazy()
listeners.forEach { listeners.forEach {
it.downloadStatusChanged(downloadManager.hasQueue()) it.downloadStatusChanged(downloading ?: downloadManager.hasQueue())
} }
} }
/** /**
@ -133,7 +133,7 @@ class DownloadService : Service() {
runningRelay.call(false) runningRelay.call(false)
subscriptions.unsubscribe() subscriptions.unsubscribe()
downloadManager.stopDownloads() downloadManager.stopDownloads()
callListeners() callListeners(downloadManager.hasQueue())
wakeLock.releaseIfNeeded() wakeLock.releaseIfNeeded()
super.onDestroy() super.onDestroy()
} }

View File

@ -14,7 +14,6 @@ import eu.kanade.tachiyomi.source.SourceManager
import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.source.model.Page
import eu.kanade.tachiyomi.source.online.HttpSource import eu.kanade.tachiyomi.source.online.HttpSource
import eu.kanade.tachiyomi.source.online.fetchAllImageUrlsFromPageList import eu.kanade.tachiyomi.source.online.fetchAllImageUrlsFromPageList
import eu.kanade.tachiyomi.ui.main.MainActivity
import eu.kanade.tachiyomi.util.lang.RetryWithDelay import eu.kanade.tachiyomi.util.lang.RetryWithDelay
import eu.kanade.tachiyomi.util.lang.plusAssign import eu.kanade.tachiyomi.util.lang.plusAssign
import eu.kanade.tachiyomi.util.storage.DiskUtil import eu.kanade.tachiyomi.util.storage.DiskUtil

View File

@ -1,13 +1,10 @@
package eu.kanade.tachiyomi.ui.library package eu.kanade.tachiyomi.ui.library
import android.content.Context import android.content.Context
import android.transition.AutoTransition
import android.transition.TransitionManager
import android.util.AttributeSet import android.util.AttributeSet
import android.view.View import android.view.View
import android.widget.LinearLayout import android.widget.LinearLayout
import com.google.android.material.bottomsheet.BottomSheetBehavior import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.bottomsheet.BottomSheetDialog
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.database.DatabaseHelper import eu.kanade.tachiyomi.data.database.DatabaseHelper
import eu.kanade.tachiyomi.data.database.models.Category import eu.kanade.tachiyomi.data.database.models.Category
@ -19,7 +16,6 @@ import eu.kanade.tachiyomi.util.system.dpToPx
import eu.kanade.tachiyomi.util.system.launchUI import eu.kanade.tachiyomi.util.system.launchUI
import eu.kanade.tachiyomi.util.view.inflate import eu.kanade.tachiyomi.util.view.inflate
import kotlinx.android.synthetic.main.filter_bottom_sheet.view.* import kotlinx.android.synthetic.main.filter_bottom_sheet.view.*
import kotlinx.android.synthetic.main.filter_buttons.view.*
import kotlinx.coroutines.CoroutineStart import kotlinx.coroutines.CoroutineStart
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.GlobalScope
@ -27,11 +23,11 @@ import kotlinx.coroutines.launch
import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get import uy.kohesive.injekt.api.get
import uy.kohesive.injekt.injectLazy import uy.kohesive.injekt.injectLazy
import java.util.Locale
import kotlin.math.roundToInt import kotlin.math.roundToInt
class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null)
: LinearLayout(context, attrs) { : LinearLayout(context, attrs),
FilterTagGroupListener {
/** /**
* Preferences helper. * Preferences helper.
@ -52,13 +48,13 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
var lastCategory:Category? = null var lastCategory:Category? = null
val filterItems:List<FilterTagGroup> by lazy { private val filterItems:MutableList<FilterTagGroup> by lazy {
val list = mutableListOf<FilterTagGroup>() val list = mutableListOf<FilterTagGroup>()
if (Injekt.get<DatabaseHelper>().getCategories().executeAsBlocking().isNotEmpty())
list.add(categories)
list.add(downloaded) list.add(downloaded)
list.add(unread) list.add(unread)
list.add(completed) list.add(completed)
if (Injekt.get<DatabaseHelper>().getCategories().executeAsBlocking().isNotEmpty())
list.add(categories)
if (Injekt.get<TrackManager>().hasLoggedServices()) if (Injekt.get<TrackManager>().hasLoggedServices())
list.add(tracked) list.add(tracked)
list list
@ -94,14 +90,18 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
title.alpha = progress title.alpha = progress
} }
override fun onStateChanged(p0: View, p1: Int) { override fun onStateChanged(p0: View, state: Int) {
if (state == BottomSheetBehavior.STATE_COLLAPSED) {
reSortViews()
}
} }
}) })
topbar.viewTreeObserver.addOnGlobalLayoutListener { topbar.viewTreeObserver.addOnGlobalLayoutListener {
sheetBehavior.peekHeight = topbar.height sheetBehavior.peekHeight = topbar.height
if (sheetBehavior.state == BottomSheetBehavior.STATE_COLLAPSED) { if (sheetBehavior.state == BottomSheetBehavior.STATE_COLLAPSED) {
pager?.setPadding(0, 0, 0, topbar.height) pager?.setPadding(0, 0, 0, topbar.height)
sortText.alpha = 1f
title.alpha = 0f
} }
else { else {
updateRootPadding() updateRootPadding()
@ -139,9 +139,10 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
} }
} }
fun moveTitleMargin(downloading: Boolean) { fun adjustTitleMargin(downloading: Boolean) {
(sortText.layoutParams as? MarginLayoutParams)?.rightMargin = val params = sortText.layoutParams as? MarginLayoutParams ?: return
(if (downloading) 40 else 8).dpToPx params.rightMargin = (if (downloading) 80 else 8).dpToPx
sortText.layoutParams = params
} }
fun updateRootPadding(progress: Float? = null) { fun updateRootPadding(progress: Float? = null) {
@ -174,6 +175,10 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
private fun getFilters(): List<Int> { private fun getFilters(): List<Int> {
val filters = mutableListOf<Int>() val filters = mutableListOf<Int>()
val categoriesOn = preferences.showCategories().getOrDefault()
if (!categoriesOn) {
filters.add(R.string.hiding_categories)
}
var filter = preferences.filterDownloaded().getOrDefault() var filter = preferences.filterDownloaded().getOrDefault()
if (filter > 0) { if (filter > 0) {
filters.add(if (filter == 1) R.string.action_filter_downloaded else R.string filters.add(if (filter == 1) R.string.action_filter_downloaded else R.string
@ -192,10 +197,6 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
filters.add(if (filter == 1) R.string.completed else R.string filters.add(if (filter == 1) R.string.completed else R.string
.ongoing) .ongoing)
} }
val categoriesOn = preferences.showCategories().getOrDefault()
if (!categoriesOn) {
filters.add(R.string.hiding_categories)
}
filter = preferences.filterTracked().getOrDefault() filter = preferences.filterTracked().getOrDefault()
if (filter > 0) { if (filter > 0) {
filters.add(if (filter == 1) R.string.action_filter_tracked else R.string filters.add(if (filter == 1) R.string.action_filter_tracked else R.string
@ -212,38 +213,28 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
fun createTags() { fun createTags() {
categories = inflate(R.layout.filter_buttons) as FilterTagGroup categories = inflate(R.layout.filter_buttons) as FilterTagGroup
categories.setup(this, R.string.hide_categories) categories.setup(this, R.string.hide_categories)
categories.firstButton.isActivated = !preferences.showCategories().getOrDefault()
categories.onItemClicked = { view, index -> onFilterClicked(view, index) }
downloaded = inflate(R.layout.filter_buttons) as FilterTagGroup downloaded = inflate(R.layout.filter_buttons) as FilterTagGroup
downloaded.setup(this, R.string.action_filter_downloaded, R.string.action_filter_not_downloaded) downloaded.setup(this, R.string.action_filter_downloaded, R.string.action_filter_not_downloaded)
downloaded.setState(preferences.filterDownloaded())
downloaded.onItemClicked = { view, index -> onFilterClicked(view, index) }
completed = inflate(R.layout.filter_buttons) as FilterTagGroup completed = inflate(R.layout.filter_buttons) as FilterTagGroup
completed.setup(this, R.string.completed, R.string.ongoing) completed.setup(this, R.string.completed, R.string.ongoing)
completed.setState(preferences.filterCompleted())
completed.onItemClicked = { view, index -> onFilterClicked(view, index) }
unread = inflate(R.layout.filter_buttons) as FilterTagGroup unread = inflate(R.layout.filter_buttons) as FilterTagGroup
unread.setup(this, R.string.action_filter_not_started, R.string.action_filter_in_progress, unread.setup(this, R.string.action_filter_not_started, R.string.action_filter_in_progress,
R.string.action_filter_read) R.string.action_filter_read)
unread.setState(preferences.filterUnread())
unread.onItemClicked = { view, index -> onFilterClicked(view, index) }
tracked = inflate(R.layout.filter_buttons) as FilterTagGroup tracked = inflate(R.layout.filter_buttons) as FilterTagGroup
tracked.setup(this, R.string.action_filter_tracked, R.string.action_filter_not_tracked) tracked.setup(this, R.string.action_filter_tracked, R.string.action_filter_not_tracked)
tracked.setState(preferences.filterTracked())
tracked.onItemClicked = { view, index -> onFilterClicked(view, index) }
filterItems.forEach { filterItems.forEach {
filterLayout.addView(it) filterLayout.addView(it)
} }
checkForWebtoons() checkForManwha()
} }
private fun checkForWebtoons() { private fun checkForManwha() {
GlobalScope.launch(Dispatchers.IO, CoroutineStart.DEFAULT) { GlobalScope.launch(Dispatchers.IO, CoroutineStart.DEFAULT) {
val db:DatabaseHelper by injectLazy() val db:DatabaseHelper by injectLazy()
val librryManga = db.getLibraryMangas().executeAsBlocking() val librryManga = db.getLibraryMangas().executeAsBlocking()
@ -255,55 +246,65 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
R.string.manga, R.string.manga,
R.string.manwha R.string.manwha
) )
mangaType.setState(preferences.filterMangaType())
mangaType.onItemClicked = { view, index -> onFilterClicked(view, index) }
this@FilterBottomSheet.mangaType = mangaType this@FilterBottomSheet.mangaType = mangaType
filterLayout.addView(mangaType) filterLayout.addView(mangaType)
filterItems.add(mangaType)
} }
} }
launchUI {
categories.setState(!preferences.showCategories().getOrDefault())
downloaded.setState(preferences.filterDownloaded())
completed.setState(preferences.filterCompleted())
unread.setState(preferences.filterUnread())
tracked.setState(preferences.filterTracked())
mangaType?.setState(preferences.filterMangaType())
reSortViews()
}
} }
} }
private fun onFilterClicked(view: View, index: Int) { override fun onFilterClicked(view: FilterTagGroup, index: Int, updatePreference:Boolean) {
/*val transition = AutoTransition() if (updatePreference) {
transition.duration = 150 when (view) {
TransitionManager.beginDelayedTransition(this, transition)*/ categories -> {
/*f (index > -1) { preferences.showCategories().set(index != 0)
filterScrollView.scrollX = 0 onGroupClicked(ACTION_REFRESH)
filterLayout.removeView(view) }
filterLayout.addView(view, 0) downloaded -> {
preferences.filterDownloaded().set(index + 1)
onGroupClicked(ACTION_FILTER)
}
unread -> {
preferences.filterUnread().set(index + 1)
onGroupClicked(ACTION_FILTER)
}
completed -> {
preferences.filterCompleted().set(index + 1)
onGroupClicked(ACTION_FILTER)
}
tracked -> {
preferences.filterTracked().set(index + 1)
onGroupClicked(ACTION_FILTER)
}
mangaType -> {
preferences.filterMangaType().set(index + 1)
onGroupClicked(ACTION_FILTER)
}
}
updateTitle()
} }
else{ }
filterLayout.removeView(view)
filterLayout.addView(view, items.indexOf(view as FilterTagGroup)) fun reSortViews() {
}*/ filterLayout.removeAllViews()
when (view) { filterItems.filter { it.isActivated }.forEach {
categories -> { filterLayout.addView(it)
preferences.showCategories().set(index != 0)
onGroupClicked(ACTION_REFRESH)
}
downloaded -> {
preferences.filterDownloaded().set(index + 1)
onGroupClicked(ACTION_FILTER)
}
unread -> {
preferences.filterUnread().set(index + 1)
onGroupClicked(ACTION_FILTER)
}
completed -> {
preferences.filterCompleted().set(index + 1)
onGroupClicked(ACTION_FILTER)
}
tracked -> {
preferences.filterTracked().set(index + 1)
onGroupClicked(ACTION_FILTER)
}
mangaType -> {
preferences.filterMangaType().set(index + 1)
onGroupClicked(ACTION_FILTER)
}
} }
updateTitle() filterItems.filterNot { it.isActivated }.forEach {
filterLayout.addView(it)
}
filterScrollView.scrollTo(0, 0)
} }
companion object { companion object {

View File

@ -1,12 +1,12 @@
package eu.kanade.tachiyomi.ui.library package eu.kanade.tachiyomi.ui.library
import android.content.Context import android.content.Context
import android.transition.AutoTransition
import android.transition.TransitionManager
import android.util.AttributeSet import android.util.AttributeSet
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.HorizontalScrollView
import android.widget.LinearLayout import android.widget.LinearLayout
import androidx.transition.Transition
import com.f2prateek.rx.preferences.Preference import com.f2prateek.rx.preferences.Preference
import eu.kanade.tachiyomi.data.preference.getOrDefault import eu.kanade.tachiyomi.data.preference.getOrDefault
import eu.kanade.tachiyomi.util.system.dpToPx import eu.kanade.tachiyomi.util.system.dpToPx
@ -17,11 +17,19 @@ import kotlinx.android.synthetic.main.filter_buttons.view.*
class FilterTagGroup@JvmOverloads constructor(context: Context, attrs: AttributeSet? = null): LinearLayout class FilterTagGroup@JvmOverloads constructor(context: Context, attrs: AttributeSet? = null): LinearLayout
(context, attrs) { (context, attrs) {
var onItemClicked: (View, Int) -> Unit = { _, _ -> } private var listener:FilterTagGroupListener? = null
var itemCount = 0
private set
private var itemCount = 0
private var root:ViewGroup? = null private var root:ViewGroup? = null
private val buttons by lazy { arrayOf(firstButton, secondButton, thirdButton) }
override fun isActivated(): Boolean {
return buttons.any { it.isActivated }
}
fun setup(root: ViewGroup, firstText: Int, secondText: Int? = null, thirdText: Int? = null) { fun setup(root: ViewGroup, firstText: Int, secondText: Int? = null, thirdText: Int? = null) {
val text1 = context.getString(firstText) val text1 = context.getString(firstText)
val text2 = if (secondText != null) context.getString(secondText) else null val text2 = if (secondText != null) context.getString(secondText) else null
@ -31,6 +39,7 @@ class FilterTagGroup@JvmOverloads constructor(context: Context, attrs: Attribute
fun setup(root: ViewGroup, firstText: String, secondText: String? = null, thirdText: String? = fun setup(root: ViewGroup, firstText: String, secondText: String? = null, thirdText: String? =
null) { null) {
listener = root as? FilterTagGroupListener
(layoutParams as? MarginLayoutParams)?.rightMargin = 5.dpToPx (layoutParams as? MarginLayoutParams)?.rightMargin = 5.dpToPx
(layoutParams as? MarginLayoutParams)?.leftMargin = 5.dpToPx (layoutParams as? MarginLayoutParams)?.leftMargin = 5.dpToPx
firstButton.text = firstText firstButton.text = firstText
@ -65,11 +74,23 @@ class FilterTagGroup@JvmOverloads constructor(context: Context, attrs: Attribute
toggleButton(index, false) toggleButton(index, false)
} }
fun setState(enabled: Boolean) {
if (enabled)
toggleButton(0, false)
}
private fun toggleButton(index: Int, callBack: Boolean = true) { private fun toggleButton(index: Int, callBack: Boolean = true) {
if (itemCount == 0) return if (itemCount == 0) return
if (callBack) {
val transition = androidx.transition.AutoTransition()
transition.duration = 150
androidx.transition.TransitionManager.beginDelayedTransition(
parent.parent as ViewGroup, transition
)
}
if (itemCount == 1) { if (itemCount == 1) {
firstButton.isActivated = !firstButton.isActivated firstButton.isActivated = !firstButton.isActivated
if (callBack) onItemClicked(this, if (firstButton.isActivated) index else -1) listener?.onFilterClicked(this, if (firstButton.isActivated) index else -1, callBack)
return return
} }
val buttons = mutableListOf(firstButton, secondButton) val buttons = mutableListOf(firstButton, secondButton)
@ -77,20 +98,18 @@ class FilterTagGroup@JvmOverloads constructor(context: Context, attrs: Attribute
buttons.add(thirdButton) buttons.add(thirdButton)
val mainButton = buttons[index] val mainButton = buttons[index]
buttons.remove(mainButton) buttons.remove(mainButton)
val transition = AutoTransition()
transition.duration = 150
TransitionManager.beginDelayedTransition(root, transition)
if (mainButton.isActivated) { if (mainButton.isActivated) {
mainButton.isActivated = false mainButton.isActivated = false
separator1.visible() separator1.visible()
if (callBack) onItemClicked(this, -1) listener?.onFilterClicked(this, -1, callBack)
if (itemCount >= 3) if (itemCount >= 3)
separator2.visible() separator2.visible()
buttons.forEach{ it.visible() } buttons.forEach{ it.visible() }
} }
else { else {
mainButton.isActivated = true mainButton.isActivated = true
if (callBack) onItemClicked(this, index) listener?.onFilterClicked(this, index, callBack)
buttons.forEach{ it.gone() } buttons.forEach{ it.gone() }
separator1.gone() separator1.gone()
if (itemCount >= 3) { if (itemCount >= 3) {
@ -99,3 +118,7 @@ class FilterTagGroup@JvmOverloads constructor(context: Context, attrs: Attribute
} }
} }
} }
interface FilterTagGroupListener {
fun onFilterClicked(view: FilterTagGroup, index: Int, updatePreference:Boolean)
}

View File

@ -238,10 +238,6 @@ class LibraryController(
shadow.gone() shadow.gone()
shadow2.gone() shadow2.gone()
} }
fab.scaleX = 0f
fab.scaleY = 0f
fab.isClickable = false
fab.isFocusable = false
} }
fun enableReorderItems(category: Category) { fun enableReorderItems(category: Category) {
@ -276,6 +272,7 @@ class LibraryController(
activity?.tabs?.setupWithViewPager(library_pager) activity?.tabs?.setupWithViewPager(library_pager)
presenter.subscribeLibrary() presenter.subscribeLibrary()
DownloadService.addListener(this) DownloadService.addListener(this)
DownloadService.callListeners()
} }
} }
@ -295,6 +292,7 @@ class LibraryController(
fab.animate().scaleX(scale).scaleY(scale).setDuration(200).start() fab.animate().scaleX(scale).scaleY(scale).setDuration(200).start()
fab.isClickable = downloading fab.isClickable = downloading
fab.isFocusable = downloading fab.isFocusable = downloading
bottom_sheet.adjustTitleMargin(downloading)
} }
} }
override fun onDetach(view: View) { override fun onDetach(view: View) {

View File

@ -536,13 +536,12 @@ open class MainActivity : BaseActivity(), DownloadServiceListener {
} }
if (bottomNav) { if (bottomNav) {
navigationView.selectedItemId = R.id.nav_drawer_settings navigationView.selectedItemId = R.id.nav_drawer_library
val newBackstack = listOf( if (router.backstack.firstOrNull()?.controller() is LibraryController)
RouterTransaction.with(SettingsMainController()), router.popToRoot()
RouterTransaction.with(SettingsDownloadController()), else
RouterTransaction.with(DownloadController())) setRoot(LibraryController(), R.id.nav_drawer_library)
router.pushController(DownloadController().withFadeTransaction())
router.setBackstack(newBackstack, FadeChangeHandler())
} }
else { else {
nav_view.setCheckedItem(R.id.nav_drawer_settings) nav_view.setCheckedItem(R.id.nav_drawer_settings)

View File

@ -4,20 +4,10 @@ import android.app.Activity
import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat
import androidx.core.graphics.drawable.DrawableCompat import androidx.core.graphics.drawable.DrawableCompat
import androidx.preference.* import androidx.preference.*
import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.list.listItems
import com.afollestad.materialdialogs.list.listItemsSingleChoice
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.data.preference.getOrDefault
import eu.kanade.tachiyomi.widget.preference.DownloadQueuePreference
import eu.kanade.tachiyomi.widget.preference.ExtensionPreference import eu.kanade.tachiyomi.widget.preference.ExtensionPreference
import eu.kanade.tachiyomi.widget.preference.IntListMatPreference import eu.kanade.tachiyomi.widget.preference.IntListMatPreference
import eu.kanade.tachiyomi.widget.preference.IntListPreference
import eu.kanade.tachiyomi.widget.preference.ListMatPreference import eu.kanade.tachiyomi.widget.preference.ListMatPreference
import eu.kanade.tachiyomi.widget.preference.MultiListMatPreference import eu.kanade.tachiyomi.widget.preference.MultiListMatPreference
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
import uy.kohesive.injekt.injectLazy
@DslMarker @DslMarker
@Target(AnnotationTarget.TYPE) @Target(AnnotationTarget.TYPE)
@ -35,11 +25,6 @@ inline fun PreferenceGroup.extensionPreference(block: (@DSL Preference).() -> Un
return initThenAdd(ExtensionPreference(context), block) return initThenAdd(ExtensionPreference(context), block)
} }
inline fun PreferenceGroup.downloadQueuePreference(block: (@DSL Preference).() -> Unit):
DownloadQueuePreference {
return initThenAdd(DownloadQueuePreference(context), block)
}
inline fun PreferenceGroup.switchPreference(block: (@DSL SwitchPreferenceCompat).() -> Unit): SwitchPreferenceCompat { inline fun PreferenceGroup.switchPreference(block: (@DSL SwitchPreferenceCompat).() -> Unit): SwitchPreferenceCompat {
return initThenAdd(SwitchPreferenceCompat(context), block) return initThenAdd(SwitchPreferenceCompat(context), block)

View File

@ -34,13 +34,6 @@ class SettingsDownloadController : SettingsController() {
override fun setupPreferenceScreen(screen: PreferenceScreen) = with(screen) { override fun setupPreferenceScreen(screen: PreferenceScreen) = with(screen) {
titleRes = R.string.pref_category_downloads titleRes = R.string.pref_category_downloads
downloadQueuePreference {
titleRes = R.string.label_download_queue
onClick {
router.pushController(DownloadController().withFadeTransaction())
}
}
preference { preference {
key = Keys.downloadsDirectory key = Keys.downloadsDirectory
titleRes = R.string.pref_download_directory titleRes = R.string.pref_download_directory

View File

@ -49,7 +49,7 @@ class SettingsMainController : SettingsController() {
titleRes = R.string.pref_category_reader titleRes = R.string.pref_category_reader
onClick { navigateTo(SettingsReaderController()) } onClick { navigateTo(SettingsReaderController()) }
} }
downloadQueuePreference { preference {
iconRes = R.drawable.ic_file_download_black_24dp iconRes = R.drawable.ic_file_download_black_24dp
iconTint = tintColor iconTint = tintColor
titleRes = R.string.pref_category_downloads titleRes = R.string.pref_category_downloads

View File

@ -1,45 +0,0 @@
package eu.kanade.tachiyomi.widget.preference
import android.content.Context
import androidx.preference.Preference
import androidx.preference.PreferenceViewHolder
import android.util.AttributeSet
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.download.DownloadManager
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.data.preference.getOrDefault
import eu.kanade.tachiyomi.util.view.gone
import eu.kanade.tachiyomi.util.view.visible
import kotlinx.android.synthetic.main.preference_update_text.view.*
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
class DownloadQueuePreference @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
Preference(context, attrs) {
init {
widgetLayoutResource = R.layout.preference_update_text
}
override fun onBindViewHolder(holder: PreferenceViewHolder) {
super.onBindViewHolder(holder)
val extUpdateText = holder.itemView.textView
val updates = Injekt.get<DownloadManager>().queue.size
if (updates > 0) {
extUpdateText.text = context.resources.getQuantityString(R.plurals
.downloads_pending, updates, updates)
extUpdateText.visible()
}
else {
extUpdateText.text = null
extUpdateText.gone()
}
}
public override fun notifyChanged() {
super.notifyChanged()
}
}

View File

@ -70,6 +70,7 @@
<androidx.core.widget.NestedScrollView <androidx.core.widget.NestedScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<LinearLayout <LinearLayout
@ -82,14 +83,14 @@
android:paddingTop="10dp" android:paddingTop="10dp"
android:paddingBottom="10dp" android:paddingBottom="10dp"
android:id="@+id/filterScrollView" android:id="@+id/filterScrollView"
android:layout_width="fill_parent" android:layout_width="wrap_content"
android:scrollbars="none" android:scrollbars="none"
android:paddingStart="20dp" android:paddingStart="20dp"
android:paddingEnd="20dp" android:paddingEnd="20dp"
android:clipToPadding="false" android:clipToPadding="false"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<LinearLayout <LinearLayout
android:layout_width="fill_parent" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/filterLayout" android:id="@+id/filterLayout"
android:gravity="center_vertical" android:gravity="center_vertical"

View File

@ -28,6 +28,10 @@
<com.google.android.material.floatingactionbutton.FloatingActionButton <com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab" android:id="@+id/fab"
android:scaleX="0"
android:scaleY="0"
android:clickable="false"
android:focusable="false"
app:layout_anchor="@id/bottom_sheet" app:layout_anchor="@id/bottom_sheet"
style="@style/Theme.Widget.FABFixed" style="@style/Theme.Widget.FABFixed"
app:layout_anchorGravity="end|top" app:layout_anchorGravity="end|top"

View File

@ -49,6 +49,7 @@
<item name="android:statusBarColor">@android:color/transparent</item> <item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:navigationBarColor">#B3000000</item> <item name="android:navigationBarColor">#B3000000</item>
<item name="android:colorEdgeEffect">@color/colorAccent</item>
<!-- Material Dialog colors --> <!-- Material Dialog colors -->
<item name="md_color_title">@color/textColorPrimary</item> <item name="md_color_title">@color/textColorPrimary</item>