use the new fastscroller

This commit is contained in:
tibbi
2021-11-15 19:53:52 +01:00
parent 675508e4b7
commit b0663f42cb
6 changed files with 25 additions and 47 deletions

View File

@@ -56,7 +56,7 @@ android {
} }
dependencies { dependencies {
implementation 'com.github.SimpleMobileTools:Simple-Commons:cac7ba71ac' implementation 'com.github.SimpleMobileTools:Simple-Commons:0684fdde38'
implementation 'androidx.multidex:multidex:2.0.1' implementation 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0' implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
} }

View File

@@ -15,7 +15,6 @@ import com.simplemobiletools.applauncher.extensions.getAllLaunchers
import com.simplemobiletools.applauncher.extensions.isAPredefinedApp import com.simplemobiletools.applauncher.extensions.isAPredefinedApp
import com.simplemobiletools.applauncher.models.AppLauncher import com.simplemobiletools.applauncher.models.AppLauncher
import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.LICENSE_STETHO
import com.simplemobiletools.commons.helpers.ensureBackgroundThread import com.simplemobiletools.commons.helpers.ensureBackgroundThread
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
import com.simplemobiletools.commons.models.FAQItem import com.simplemobiletools.commons.models.FAQItem
@@ -69,10 +68,8 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
updateTextColors(coordinator_layout) updateTextColors(coordinator_layout)
launchers_fastscroller.apply { val adjustedPrimaryColor = getAdjustedPrimaryColor()
updatePrimaryColor() launchers_fastscroller.updateColors(adjustedPrimaryColor, adjustedPrimaryColor.getContrastColor())
updateBubbleColors()
}
} }
override fun onPause() { override fun onPause() {
@@ -130,7 +127,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
AppLauncher.sorting = config.sorting AppLauncher.sorting = config.sorting
launchers.sort() launchers.sort()
LaunchersAdapter(this, launchers, this, launchers_grid, launchers_fastscroller) { LaunchersAdapter(this, launchers, this, launchers_grid) {
val launchIntent = packageManager.getLaunchIntentForPackage((it as AppLauncher).packageName) val launchIntent = packageManager.getLaunchIntentForPackage((it as AppLauncher).packageName)
if (launchIntent != null) { if (launchIntent != null) {
try { try {
@@ -153,11 +150,6 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
launchers_grid.adapter = this launchers_grid.adapter = this
} }
launchers_fastscroller.setViews(launchers_grid) {
val item = (launchers_grid.adapter as LaunchersAdapter).launchers.getOrNull(it)
launchers_fastscroller.updateBubbleText(item?.getBubbleText() ?: "")
}
ensureBackgroundThread { ensureBackgroundThread {
allLaunchers = getAllLaunchers() allLaunchers = getAllLaunchers()
} }
@@ -183,18 +175,9 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
invalidateOptionsMenu() invalidateOptionsMenu()
getGridAdapter()?.apply { getGridAdapter()?.apply {
notifyItemRangeChanged(0, launchers.size) notifyItemRangeChanged(0, launchers.size)
calculateContentHeight(launchers)
} }
} }
private fun calculateContentHeight(directories: List<AppLauncher>) {
val layoutManager = launchers_grid.layoutManager as MyGridLayoutManager
val thumbnailHeight = layoutManager.getChildAt(0)?.height ?: 0
val fullHeight = ((directories.size - 1) / layoutManager.spanCount + 1) * thumbnailHeight
launchers_fastscroller.setContentHeight(fullHeight)
launchers_fastscroller.setScrollToY(launchers_grid.computeVerticalScrollOffset())
}
private fun setupGridLayoutManager() { private fun setupGridLayoutManager() {
val layoutManager = launchers_grid.layoutManager as MyGridLayoutManager val layoutManager = launchers_grid.layoutManager as MyGridLayoutManager
layoutManager.spanCount = config.columnCnt layoutManager.spanCount = config.columnCnt

View File

@@ -6,6 +6,7 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.recyclerview.widget.ItemTouchHelper import androidx.recyclerview.widget.ItemTouchHelper
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller
import com.simplemobiletools.applauncher.R import com.simplemobiletools.applauncher.R
import com.simplemobiletools.applauncher.activities.SimpleActivity import com.simplemobiletools.applauncher.activities.SimpleActivity
import com.simplemobiletools.applauncher.dialogs.EditDialog import com.simplemobiletools.applauncher.dialogs.EditDialog
@@ -23,15 +24,15 @@ import com.simplemobiletools.commons.interfaces.ItemMoveCallback
import com.simplemobiletools.commons.interfaces.ItemTouchHelperContract import com.simplemobiletools.commons.interfaces.ItemTouchHelperContract
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
import com.simplemobiletools.commons.interfaces.StartReorderDragListener import com.simplemobiletools.commons.interfaces.StartReorderDragListener
import com.simplemobiletools.commons.views.FastScroller
import com.simplemobiletools.commons.views.MyRecyclerView import com.simplemobiletools.commons.views.MyRecyclerView
import kotlinx.android.synthetic.main.item_app_launcher.view.* import kotlinx.android.synthetic.main.item_app_launcher.view.*
import java.util.* import java.util.*
import kotlin.collections.ArrayList import kotlin.collections.ArrayList
class LaunchersAdapter(activity: SimpleActivity, val launchers: ArrayList<AppLauncher>, val listener: RefreshRecyclerViewListener?, class LaunchersAdapter(
recyclerView: MyRecyclerView, fastScroller: FastScroller, itemClick: (Any) -> Unit) : activity: SimpleActivity, val launchers: ArrayList<AppLauncher>, val listener: RefreshRecyclerViewListener?,
MyRecyclerViewAdapter(activity, recyclerView, fastScroller, itemClick), ItemTouchHelperContract { recyclerView: MyRecyclerView, itemClick: (Any) -> Unit
) : MyRecyclerViewAdapter(activity, recyclerView, null, itemClick), ItemTouchHelperContract, RecyclerViewFastScroller.OnPopupTextUpdate {
private var isChangingOrder = false private var isChangingOrder = false
private var startReorderDragListener: StartReorderDragListener private var startReorderDragListener: StartReorderDragListener
@@ -202,4 +203,6 @@ class LaunchersAdapter(activity: SimpleActivity, val launchers: ArrayList<AppLau
override fun onRowClear(myViewHolder: ViewHolder?) {} override fun onRowClear(myViewHolder: ViewHolder?) {}
override fun onRowSelected(myViewHolder: ViewHolder?) {} override fun onRowSelected(myViewHolder: ViewHolder?) {}
override fun onChange(position: Int) = launchers.getOrNull(position)?.getBubbleText() ?: ""
} }

View File

@@ -10,28 +10,20 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller
android:id="@+id/launchers_fastscroller"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.simplemobiletools.commons.views.MyRecyclerView <com.simplemobiletools.commons.views.MyRecyclerView
android:id="@+id/launchers_grid" android:id="@+id/launchers_grid"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:clipToPadding="false" android:clipToPadding="false"
android:paddingTop="@dimen/activity_margin"
android:paddingBottom="@dimen/activity_margin"
app:layoutManager="com.simplemobiletools.commons.views.MyGridLayoutManager" app:layoutManager="com.simplemobiletools.commons.views.MyGridLayoutManager"
app:spanCount="@integer/column_count" /> app:spanCount="@integer/column_count" />
<com.simplemobiletools.commons.views.FastScroller </com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller>
android:id="@+id/launchers_fastscroller"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignTop="@+id/launchers_grid"
android:layout_alignBottom="@+id/launchers_grid"
android:layout_alignParentEnd="true"
android:paddingStart="@dimen/normal_margin">
<include layout="@layout/fastscroller_handle_vertical" />
</com.simplemobiletools.commons.views.FastScroller>
</RelativeLayout> </RelativeLayout>
<com.simplemobiletools.commons.views.MyFloatingActionButton <com.simplemobiletools.commons.views.MyFloatingActionButton

View File

@@ -34,7 +34,7 @@
<com.simplemobiletools.commons.views.MyTextView <com.simplemobiletools.commons.views.MyTextView
android:id="@+id/settings_customize_colors_label" android:id="@+id/settings_customize_colors_label"
style="@style/SettingsLeftLabelStyle" style="@style/SettingsTextLabelStyle"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/customize_colors" /> android:text="@string/customize_colors" />
@@ -66,7 +66,7 @@
<com.simplemobiletools.commons.views.MyTextView <com.simplemobiletools.commons.views.MyTextView
android:id="@+id/settings_purchase_thank_you" android:id="@+id/settings_purchase_thank_you"
style="@style/SettingsLeftLabelStyle" style="@style/SettingsTextLabelStyle"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/purchase_simple_thank_you" /> android:text="@string/purchase_simple_thank_you" />

View File

@@ -8,7 +8,7 @@
app:showAsAction="ifRoom" /> app:showAsAction="ifRoom" />
<item <item
android:id="@+id/cab_edit" android:id="@+id/cab_edit"
android:icon="@drawable/ic_rename_new_vector" android:icon="@drawable/ic_rename_vector"
android:title="@string/rename" android:title="@string/rename"
app:showAsAction="ifRoom" /> app:showAsAction="ifRoom" />
<item <item