diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadBottomSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadBottomSheet.kt index 44b6e19832..cf536d3698 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadBottomSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadBottomSheet.kt @@ -6,6 +6,7 @@ import android.util.AttributeSet import android.view.Menu import android.view.MenuItem import android.widget.LinearLayout +import androidx.core.view.isVisible import com.google.android.material.bottomsheet.BottomSheetBehavior import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.download.DownloadService @@ -85,6 +86,14 @@ class DownloadBottomSheet @JvmOverloads constructor( sheetBehavior?.collapse() } } + binding.downloadFab.setOnClickListener { + if (!isRunning) { + DownloadService.start(context) + } else { + DownloadService.stop(context) + presenter.pauseDownloads() + } + } update() setInformationView() if (!controller.hasQueue()) { @@ -96,6 +105,7 @@ class DownloadBottomSheet @JvmOverloads constructor( fun update() { presenter.getItems() onQueueStatusChange(!presenter.downloadManager.isPaused()) + binding.downloadFab.isVisible = presenter.downloadQueue.isNotEmpty() } private fun updateDLTitle() { @@ -115,6 +125,7 @@ class DownloadBottomSheet @JvmOverloads constructor( private fun onQueueStatusChange(running: Boolean) { val oldRunning = isRunning isRunning = running + binding.downloadFab.isVisible = presenter.downloadQueue.isNotEmpty() if (oldRunning != running) { activity?.invalidateOptionsMenu() @@ -180,11 +191,8 @@ class DownloadBottomSheet @JvmOverloads constructor( } fun prepareMenu(menu: Menu) { - // Set start button visibility. - menu.findItem(R.id.start_queue)?.isVisible = !isRunning && !presenter.downloadQueue.isEmpty() - - // Set pause button visibility. - menu.findItem(R.id.pause_queue)?.isVisible = isRunning && !presenter.downloadQueue.isEmpty() + binding.downloadFab.text = context.getString(if (isRunning) R.string.pause else R.string.resume) + binding.downloadFab.setIconResource(if (isRunning) R.drawable.ic_pause_24dp else R.drawable.ic_play_arrow_24dp) // Set clear button visibility. menu.findItem(R.id.clear_queue)?.isVisible = !presenter.downloadQueue.isEmpty() @@ -196,11 +204,6 @@ class DownloadBottomSheet @JvmOverloads constructor( fun onOptionsItemSelected(item: MenuItem): Boolean { val context = activity ?: return false when (item.itemId) { - R.id.start_queue -> DownloadService.start(context) - R.id.pause_queue -> { - DownloadService.stop(context) - presenter.pauseDownloads() - } R.id.clear_queue -> { DownloadService.stop(context) presenter.clearQueue() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsController.kt index 7e3145c34d..6f87afdf37 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsController.kt @@ -162,9 +162,6 @@ class RecentsController(bundle: Bundle? = null) : binding.recycler.updatePaddingRelative( bottom = activityBinding?.bottomNav?.height ?: 0 ) - binding.downloadBottomSheet.dlRecycler.updatePaddingRelative( - bottom = activityBinding?.bottomNav?.height ?: 0 - ) binding.recentsEmptyView.updateLayoutParams { topMargin = headerHeight bottomMargin = activityBinding?.bottomNav?.height ?: 0 @@ -303,6 +300,13 @@ class RecentsController(bundle: Bundle? = null) : } } + if (presenter.downloadManager.hasQueue()) { + if (state == BottomSheetBehavior.STATE_EXPANDED) { + binding.downloadBottomSheet.downloadFab.show() + } else { + binding.downloadBottomSheet.downloadFab.hide() + } + } if (state == BottomSheetBehavior.STATE_HIDDEN || state == BottomSheetBehavior.STATE_COLLAPSED) { binding.shadow2.alpha = if (state == BottomSheetBehavior.STATE_COLLAPSED) 0.25f else 0f @@ -353,6 +357,13 @@ class RecentsController(bundle: Bundle? = null) : binding.downloadBottomSheet.fastScroller.updateLayoutParams { bottomMargin = -pad.toInt() } + binding.downloadBottomSheet.dlRecycler.updatePaddingRelative( + bottom = max(-pad.toInt(), view?.rootWindowInsets?.systemWindowInsetBottom ?: 0) + + binding.downloadBottomSheet.downloadFab.height + 20.dpToPx + ) + binding.downloadBottomSheet.downloadFab.updateLayoutParams { + bottomMargin = max(-pad.toInt(), view?.rootWindowInsets?.systemWindowInsetBottom ?: 0) + 16.dpToPx + } } fun setRefreshing(refresh: Boolean) { diff --git a/app/src/main/res/layout/download_bottom_sheet.xml b/app/src/main/res/layout/download_bottom_sheet.xml index b5b0996b84..6c9402399b 100644 --- a/app/src/main/res/layout/download_bottom_sheet.xml +++ b/app/src/main/res/layout/download_bottom_sheet.xml @@ -56,7 +56,7 @@ tools:text="Downloads" /> - - + + + \ No newline at end of file diff --git a/app/src/main/res/menu/download_queue.xml b/app/src/main/res/menu/download_queue.xml index 5efca39ad3..33f4e79d03 100644 --- a/app/src/main/res/menu/download_queue.xml +++ b/app/src/main/res/menu/download_queue.xml @@ -2,18 +2,6 @@ - - - -