|
@@ -27,37 +27,26 @@
|
|
|
|
|
|
package com.nextcloud.utils.view
|
|
package com.nextcloud.utils.view
|
|
|
|
|
|
-import android.content.Context
|
|
|
|
-import android.graphics.drawable.Drawable
|
|
|
|
import android.view.ViewGroup
|
|
import android.view.ViewGroup
|
|
-import androidx.annotation.ColorInt
|
|
|
|
-import androidx.core.content.res.ResourcesCompat
|
|
|
|
import androidx.recyclerview.widget.RecyclerView
|
|
import androidx.recyclerview.widget.RecyclerView
|
|
import com.google.android.material.appbar.AppBarLayout
|
|
import com.google.android.material.appbar.AppBarLayout
|
|
-import com.owncloud.android.utils.theme.ThemeColorUtils
|
|
|
|
-import com.owncloud.android.utils.theme.ThemeDrawableUtils
|
|
|
|
|
|
+import com.owncloud.android.utils.theme.newm3.ViewThemeUtils
|
|
import me.zhanghai.android.fastscroll.FastScroller
|
|
import me.zhanghai.android.fastscroll.FastScroller
|
|
import me.zhanghai.android.fastscroll.FastScrollerBuilder
|
|
import me.zhanghai.android.fastscroll.FastScrollerBuilder
|
|
-import me.zhanghai.android.fastscroll.PopupStyles
|
|
|
|
|
|
+import javax.inject.Inject
|
|
|
|
|
|
-object FastScroll {
|
|
|
|
-
|
|
|
|
- @JvmStatic
|
|
|
|
|
|
+class FastScrollUtils @Inject constructor(private val viewThemeUtils: ViewThemeUtils) {
|
|
@JvmOverloads
|
|
@JvmOverloads
|
|
fun applyFastScroll(
|
|
fun applyFastScroll(
|
|
- context: Context,
|
|
|
|
- themeColorUtils: ThemeColorUtils,
|
|
|
|
- themeDrawableUtils: ThemeDrawableUtils,
|
|
|
|
recyclerView: RecyclerView,
|
|
recyclerView: RecyclerView,
|
|
viewHelper: FastScroller.ViewHelper? = null
|
|
viewHelper: FastScroller.ViewHelper? = null
|
|
) {
|
|
) {
|
|
- val primaryColor = themeColorUtils.primaryColor(context)
|
|
|
|
- val builder = FastScrollerBuilder(recyclerView)
|
|
|
|
- .useMd2Style()
|
|
|
|
- .setThumbDrawable(getThumbDrawable(context, themeDrawableUtils, primaryColor))
|
|
|
|
- .setPopupStyle {
|
|
|
|
- PopupStyles.MD2.accept(it)
|
|
|
|
- it.background = FastScrollPopupBackground(context, primaryColor)
|
|
|
|
|
|
+ val builder =
|
|
|
|
+ FastScrollerBuilder(recyclerView).let {
|
|
|
|
+ viewThemeUtils.files.themeFastScrollerBuilder(
|
|
|
|
+ recyclerView.context,
|
|
|
|
+ it
|
|
|
|
+ )
|
|
}
|
|
}
|
|
if (viewHelper != null) {
|
|
if (viewHelper != null) {
|
|
builder.setViewHelper(viewHelper)
|
|
builder.setViewHelper(viewHelper)
|
|
@@ -65,22 +54,6 @@ object FastScroll {
|
|
builder.build()
|
|
builder.build()
|
|
}
|
|
}
|
|
|
|
|
|
- private fun getThumbDrawable(
|
|
|
|
- context: Context,
|
|
|
|
- themeDrawableUtils: ThemeDrawableUtils,
|
|
|
|
- @ColorInt color: Int
|
|
|
|
- ): Drawable {
|
|
|
|
- val thumbDrawable =
|
|
|
|
- ResourcesCompat.getDrawable(
|
|
|
|
- context.resources,
|
|
|
|
- me.zhanghai.android.fastscroll.R.drawable.afs_md2_thumb,
|
|
|
|
- null
|
|
|
|
- )
|
|
|
|
- themeDrawableUtils.tintDrawable(thumbDrawable, color)
|
|
|
|
- return thumbDrawable!!
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @JvmStatic
|
|
|
|
fun fixAppBarForFastScroll(appBarLayout: AppBarLayout, content: ViewGroup) {
|
|
fun fixAppBarForFastScroll(appBarLayout: AppBarLayout, content: ViewGroup) {
|
|
val contentLayoutInitialPaddingBottom = content.paddingBottom
|
|
val contentLayoutInitialPaddingBottom = content.paddingBottom
|
|
appBarLayout.addOnOffsetChangedListener(
|
|
appBarLayout.addOnOffsetChangedListener(
|