From 1668be85875522721ee971afac4b46aa7da343c6 Mon Sep 17 00:00:00 2001 From: arkon Date: Fri, 8 Sep 2023 17:38:14 -0400 Subject: [PATCH] Remove old FastScroller Not sure if this will return to the download queue screen, you really shouldn't be downloading a ton of stuff at once anyway? --- .../ui/download/DownloadQueueScreen.kt | 20 ++-- .../ui/download/DownloadQueueScreenModel.kt | 2 +- .../util/system/DisplayExtensions.kt | 14 --- .../tachiyomi/widget/MaterialFastScroll.kt | 92 ------------------- .../res/drawable/material_thumb_drawable.xml | 17 ---- app/src/main/res/layout/download_list.xml | 25 +---- .../main/res/layout/material_fastscroll.xml | 43 --------- app/src/main/res/values/styles.xml | 15 --- 8 files changed, 11 insertions(+), 217 deletions(-) delete mode 100644 app/src/main/java/eu/kanade/tachiyomi/widget/MaterialFastScroll.kt delete mode 100644 app/src/main/res/drawable/material_thumb_drawable.xml delete mode 100644 app/src/main/res/layout/material_fastscroll.xml diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadQueueScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadQueueScreen.kt index 143185634b..dcbb4536fc 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadQueueScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadQueueScreen.kt @@ -1,13 +1,13 @@ package eu.kanade.tachiyomi.ui.download import android.view.LayoutInflater -import android.view.ViewGroup import androidx.compose.animation.AnimatedVisibility import androidx.compose.animation.fadeIn import androidx.compose.animation.fadeOut import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.PlayArrow @@ -42,7 +42,6 @@ import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import androidx.compose.ui.viewinterop.AndroidView import androidx.core.view.ViewCompat -import androidx.core.view.updateLayoutParams import androidx.core.view.updatePadding import androidx.recyclerview.widget.LinearLayoutManager import cafe.adriel.voyager.core.model.rememberScreenModel @@ -243,6 +242,7 @@ object DownloadQueueScreen : Screen() { ) return@Scaffold } + val density = LocalDensity.current val layoutDirection = LocalLayoutDirection.current val left = with(density) { contentPadding.calculateLeftPadding(layoutDirection).toPx().roundToInt() } @@ -252,13 +252,13 @@ object DownloadQueueScreen : Screen() { Box(modifier = Modifier.nestedScroll(nestedScrollConnection)) { AndroidView( + modifier = Modifier.fillMaxWidth(), factory = { context -> screenModel.controllerBinding = DownloadListBinding.inflate(LayoutInflater.from(context)) screenModel.adapter = DownloadAdapter(screenModel.listener) - screenModel.controllerBinding.recycler.adapter = screenModel.adapter + screenModel.controllerBinding.root.adapter = screenModel.adapter screenModel.adapter?.isHandleDragEnabled = true - screenModel.adapter?.fastScroller = screenModel.controllerBinding.fastScroller - screenModel.controllerBinding.recycler.layoutManager = LinearLayoutManager(context) + screenModel.controllerBinding.root.layoutManager = LinearLayoutManager(context) ViewCompat.setNestedScrollingEnabled(screenModel.controllerBinding.root, true) @@ -274,7 +274,7 @@ object DownloadQueueScreen : Screen() { screenModel.controllerBinding.root }, update = { - screenModel.controllerBinding.recycler + screenModel.controllerBinding.root .updatePadding( left = left, top = top, @@ -282,14 +282,6 @@ object DownloadQueueScreen : Screen() { bottom = bottom, ) - screenModel.controllerBinding.fastScroller - .updateLayoutParams { - leftMargin = left - topMargin = top - rightMargin = right - bottomMargin = bottom - } - screenModel.adapter?.updateDataSet(downloadList) }, ) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadQueueScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadQueueScreenModel.kt index 711985887b..8eed7a915d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadQueueScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadQueueScreenModel.kt @@ -258,6 +258,6 @@ class DownloadQueueScreenModel( * @return the holder of the download or null if it's not bound. */ private fun getHolder(download: Download): DownloadHolder? { - return controllerBinding.recycler.findViewHolderForItemId(download.chapter.id) as? DownloadHolder + return controllerBinding.root.findViewHolderForItemId(download.chapter.id) as? DownloadHolder } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/system/DisplayExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/system/DisplayExtensions.kt index 50f45ae85b..3e2834fd23 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/system/DisplayExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/system/DisplayExtensions.kt @@ -3,9 +3,7 @@ package eu.kanade.tachiyomi.util.system import android.app.Activity import android.content.Context import android.content.res.Configuration -import android.content.res.Resources import android.os.Build -import android.view.View import eu.kanade.domain.ui.UiPreferences import eu.kanade.domain.ui.model.TabletUiMode import uy.kohesive.injekt.Injekt @@ -64,18 +62,6 @@ fun Context.isNightMode(): Boolean { return resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK == Configuration.UI_MODE_NIGHT_YES } -val Resources.isLTR - get() = configuration.layoutDirection == View.LAYOUT_DIRECTION_LTR - -/** - * Converts to px and takes into account LTR/RTL layout. - */ -val Float.dpToPxEnd: Float - get() = ( - this * Resources.getSystem().displayMetrics.density * - if (Resources.getSystem().isLTR) 1 else -1 - ) - /** * Checks whether if the device has a display cutout (i.e. notch, camera cutout, etc.). * diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/MaterialFastScroll.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/MaterialFastScroll.kt deleted file mode 100644 index 29e9e43e37..0000000000 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/MaterialFastScroll.kt +++ /dev/null @@ -1,92 +0,0 @@ -package eu.kanade.tachiyomi.widget - -import android.annotation.SuppressLint -import android.content.Context -import android.util.AttributeSet -import android.view.MotionEvent -import androidx.core.view.ViewCompat -import dev.chrisbanes.insetter.applyInsetter -import eu.davidea.fastscroller.FastScroller -import eu.kanade.tachiyomi.R -import eu.kanade.tachiyomi.util.system.dpToPxEnd -import eu.kanade.tachiyomi.util.system.isLTR - -class MaterialFastScroll @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : - FastScroller(context, attrs) { - - init { - setViewsToUse( - R.layout.material_fastscroll, - R.id.fast_scroller_bubble, - R.id.fast_scroller_handle, - ) - autoHideEnabled = true - ignoreTouchesOutsideHandle = true - - applyInsetter { - type(navigationBars = true) { - margin() - } - } - } - - // Overridden to handle RTL - @SuppressLint("ClickableViewAccessibility") - override fun onTouchEvent(event: MotionEvent): Boolean { - if (recyclerView.computeVerticalScrollRange() <= recyclerView.computeVerticalScrollExtent()) { - return super.onTouchEvent(event) - } - - when (event.action) { - MotionEvent.ACTION_DOWN -> { - // start: handle RTL differently - if ( - if (context.resources.isLTR) { - event.x < handle.x - ViewCompat.getPaddingStart(handle) - } else { - event.x > handle.width + ViewCompat.getPaddingStart(handle) - } - ) { - return false - } - // end - - if (ignoreTouchesOutsideHandle && - (event.y < handle.y || event.y > handle.y + handle.height) - ) { - return false - } - handle.isSelected = true - notifyScrollStateChange(true) - showBubble() - showScrollbar() - val y = event.y - setBubbleAndHandlePosition(y) - setRecyclerViewPosition(y) - return true - } - MotionEvent.ACTION_MOVE -> { - val y = event.y - setBubbleAndHandlePosition(y) - setRecyclerViewPosition(y) - return true - } - MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> { - handle.isSelected = false - notifyScrollStateChange(false) - hideBubble() - if (autoHideEnabled) hideScrollbar() - return true - } - } - return super.onTouchEvent(event) - } - - override fun setBubbleAndHandlePosition(y: Float) { - super.setBubbleAndHandlePosition(y) - if (bubbleEnabled) { - bubble.y = handle.y - bubble.height / 2f + handle.height / 2f - bubble.translationX = (-45f).dpToPxEnd - } - } -} diff --git a/app/src/main/res/drawable/material_thumb_drawable.xml b/app/src/main/res/drawable/material_thumb_drawable.xml deleted file mode 100644 index 2e550c0dff..0000000000 --- a/app/src/main/res/drawable/material_thumb_drawable.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/download_list.xml b/app/src/main/res/layout/download_list.xml index e2c96ff122..ec3e3bab90 100644 --- a/app/src/main/res/layout/download_list.xml +++ b/app/src/main/res/layout/download_list.xml @@ -1,24 +1,7 @@ - - - - - - - + android:layout_height="match_parent" + android:clipToPadding="false" + tools:listitem="@layout/download_item" /> diff --git a/app/src/main/res/layout/material_fastscroll.xml b/app/src/main/res/layout/material_fastscroll.xml deleted file mode 100644 index 56b16a1b84..0000000000 --- a/app/src/main/res/layout/material_fastscroll.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 14dc1a13ab..22313ff427 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -56,21 +56,6 @@ - - - - -