mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-21 15:31:49 +01:00
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?
This commit is contained in:
parent
86a3fc77c6
commit
1668be8587
@ -1,13 +1,13 @@
|
|||||||
package eu.kanade.tachiyomi.ui.download
|
package eu.kanade.tachiyomi.ui.download
|
||||||
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.compose.animation.AnimatedVisibility
|
import androidx.compose.animation.AnimatedVisibility
|
||||||
import androidx.compose.animation.fadeIn
|
import androidx.compose.animation.fadeIn
|
||||||
import androidx.compose.animation.fadeOut
|
import androidx.compose.animation.fadeOut
|
||||||
import androidx.compose.foundation.isSystemInDarkTheme
|
import androidx.compose.foundation.isSystemInDarkTheme
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.PlayArrow
|
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.unit.sp
|
||||||
import androidx.compose.ui.viewinterop.AndroidView
|
import androidx.compose.ui.viewinterop.AndroidView
|
||||||
import androidx.core.view.ViewCompat
|
import androidx.core.view.ViewCompat
|
||||||
import androidx.core.view.updateLayoutParams
|
|
||||||
import androidx.core.view.updatePadding
|
import androidx.core.view.updatePadding
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import cafe.adriel.voyager.core.model.rememberScreenModel
|
import cafe.adriel.voyager.core.model.rememberScreenModel
|
||||||
@ -243,6 +242,7 @@ object DownloadQueueScreen : Screen() {
|
|||||||
)
|
)
|
||||||
return@Scaffold
|
return@Scaffold
|
||||||
}
|
}
|
||||||
|
|
||||||
val density = LocalDensity.current
|
val density = LocalDensity.current
|
||||||
val layoutDirection = LocalLayoutDirection.current
|
val layoutDirection = LocalLayoutDirection.current
|
||||||
val left = with(density) { contentPadding.calculateLeftPadding(layoutDirection).toPx().roundToInt() }
|
val left = with(density) { contentPadding.calculateLeftPadding(layoutDirection).toPx().roundToInt() }
|
||||||
@ -252,13 +252,13 @@ object DownloadQueueScreen : Screen() {
|
|||||||
|
|
||||||
Box(modifier = Modifier.nestedScroll(nestedScrollConnection)) {
|
Box(modifier = Modifier.nestedScroll(nestedScrollConnection)) {
|
||||||
AndroidView(
|
AndroidView(
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
factory = { context ->
|
factory = { context ->
|
||||||
screenModel.controllerBinding = DownloadListBinding.inflate(LayoutInflater.from(context))
|
screenModel.controllerBinding = DownloadListBinding.inflate(LayoutInflater.from(context))
|
||||||
screenModel.adapter = DownloadAdapter(screenModel.listener)
|
screenModel.adapter = DownloadAdapter(screenModel.listener)
|
||||||
screenModel.controllerBinding.recycler.adapter = screenModel.adapter
|
screenModel.controllerBinding.root.adapter = screenModel.adapter
|
||||||
screenModel.adapter?.isHandleDragEnabled = true
|
screenModel.adapter?.isHandleDragEnabled = true
|
||||||
screenModel.adapter?.fastScroller = screenModel.controllerBinding.fastScroller
|
screenModel.controllerBinding.root.layoutManager = LinearLayoutManager(context)
|
||||||
screenModel.controllerBinding.recycler.layoutManager = LinearLayoutManager(context)
|
|
||||||
|
|
||||||
ViewCompat.setNestedScrollingEnabled(screenModel.controllerBinding.root, true)
|
ViewCompat.setNestedScrollingEnabled(screenModel.controllerBinding.root, true)
|
||||||
|
|
||||||
@ -274,7 +274,7 @@ object DownloadQueueScreen : Screen() {
|
|||||||
screenModel.controllerBinding.root
|
screenModel.controllerBinding.root
|
||||||
},
|
},
|
||||||
update = {
|
update = {
|
||||||
screenModel.controllerBinding.recycler
|
screenModel.controllerBinding.root
|
||||||
.updatePadding(
|
.updatePadding(
|
||||||
left = left,
|
left = left,
|
||||||
top = top,
|
top = top,
|
||||||
@ -282,14 +282,6 @@ object DownloadQueueScreen : Screen() {
|
|||||||
bottom = bottom,
|
bottom = bottom,
|
||||||
)
|
)
|
||||||
|
|
||||||
screenModel.controllerBinding.fastScroller
|
|
||||||
.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
|
||||||
leftMargin = left
|
|
||||||
topMargin = top
|
|
||||||
rightMargin = right
|
|
||||||
bottomMargin = bottom
|
|
||||||
}
|
|
||||||
|
|
||||||
screenModel.adapter?.updateDataSet(downloadList)
|
screenModel.adapter?.updateDataSet(downloadList)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -258,6 +258,6 @@ class DownloadQueueScreenModel(
|
|||||||
* @return the holder of the download or null if it's not bound.
|
* @return the holder of the download or null if it's not bound.
|
||||||
*/
|
*/
|
||||||
private fun getHolder(download: Download): DownloadHolder? {
|
private fun getHolder(download: Download): DownloadHolder? {
|
||||||
return controllerBinding.recycler.findViewHolderForItemId(download.chapter.id) as? DownloadHolder
|
return controllerBinding.root.findViewHolderForItemId(download.chapter.id) as? DownloadHolder
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,7 @@ package eu.kanade.tachiyomi.util.system
|
|||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
import android.content.res.Resources
|
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.view.View
|
|
||||||
import eu.kanade.domain.ui.UiPreferences
|
import eu.kanade.domain.ui.UiPreferences
|
||||||
import eu.kanade.domain.ui.model.TabletUiMode
|
import eu.kanade.domain.ui.model.TabletUiMode
|
||||||
import uy.kohesive.injekt.Injekt
|
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
|
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.).
|
* Checks whether if the device has a display cutout (i.e. notch, camera cutout, etc.).
|
||||||
*
|
*
|
||||||
|
@ -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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
<item android:state_selected="true">
|
|
||||||
<shape android:shape="rectangle">
|
|
||||||
<corners android:radius="8dp" />
|
|
||||||
<solid android:color="?attr/colorAccent" />
|
|
||||||
<size android:width="6dp" android:height="54dp" />
|
|
||||||
</shape>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<shape android:shape="rectangle">
|
|
||||||
<corners android:radius="8dp" />
|
|
||||||
<solid android:color="@color/fast_scroller_handle_idle" />
|
|
||||||
<size android:width="6dp" android:height="54dp" />
|
|
||||||
</shape>
|
|
||||||
</item>
|
|
||||||
</selector>
|
|
@ -1,24 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:id="@+id/frame_container"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent"
|
||||||
|
android:clipToPadding="false"
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
tools:listitem="@layout/download_item" />
|
||||||
android:id="@+id/recycler"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:clipToPadding="false"
|
|
||||||
tools:listitem="@layout/download_item" />
|
|
||||||
|
|
||||||
<eu.kanade.tachiyomi.widget.MaterialFastScroll
|
|
||||||
android:id="@+id/fast_scroller"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_gravity="end"
|
|
||||||
app:fastScrollerBubbleEnabled="false"
|
|
||||||
tools:visibility="visible" />
|
|
||||||
|
|
||||||
</FrameLayout>
|
|
||||||
|
@ -1,43 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
|
|
||||||
<View
|
|
||||||
android:id="@+id/fast_scroller_bar"
|
|
||||||
android:layout_width="7dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_gravity="end"
|
|
||||||
android:background="@null" />
|
|
||||||
|
|
||||||
<RelativeLayout
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="end">
|
|
||||||
|
|
||||||
<!-- No margin, use padding at the handle -->
|
|
||||||
<com.google.android.material.textview.MaterialTextView
|
|
||||||
android:id="@+id/fast_scroller_bubble"
|
|
||||||
style="@style/FloatingTextView"
|
|
||||||
android:layout_gravity="end|center_vertical"
|
|
||||||
android:layout_toStartOf="@+id/fast_scroller_handle"
|
|
||||||
android:gravity="center"
|
|
||||||
android:visibility="gone"
|
|
||||||
tools:text="A"
|
|
||||||
tools:visibility="visible" />
|
|
||||||
|
|
||||||
<!-- Padding is here to have better grab -->
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/fast_scroller_handle"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignParentEnd="true"
|
|
||||||
android:contentDescription="@null"
|
|
||||||
android:paddingStart="6dp"
|
|
||||||
android:paddingEnd="4dp"
|
|
||||||
android:src="@drawable/material_thumb_drawable" />
|
|
||||||
|
|
||||||
</RelativeLayout>
|
|
||||||
|
|
||||||
</merge>
|
|
@ -56,21 +56,6 @@
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
||||||
<!--============-->
|
|
||||||
<!--FastScroller-->
|
|
||||||
<!--============-->
|
|
||||||
<style name="FloatingTextView" parent="TextAppearance.AppCompat">
|
|
||||||
<item name="android:layout_height">wrap_content</item>
|
|
||||||
<item name="android:layout_width">wrap_content</item>
|
|
||||||
<item name="android:elevation">5dp</item>
|
|
||||||
<item name="android:paddingStart">12dp</item>
|
|
||||||
<item name="android:paddingEnd">12dp</item>
|
|
||||||
<item name="android:paddingTop">8dp</item>
|
|
||||||
<item name="android:paddingBottom">8dp</item>
|
|
||||||
<item name="android:textColor">?attr/colorOnPrimary</item>
|
|
||||||
<item name="android:textSize">15sp</item>
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<!--===========-->
|
<!--===========-->
|
||||||
<!--Preferences-->
|
<!--Preferences-->
|
||||||
<!--===========-->
|
<!--===========-->
|
||||||
|
Loading…
Reference in New Issue
Block a user