mirror of
				https://github.com/SimpleMobileTools/Simple-App-Launcher.git
				synced 2025-06-05 21:49:21 +02:00 
			
		
		
		
	add a fastscroller if needed
This commit is contained in:
		| @@ -62,6 +62,12 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener { | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         updateTextColors(coordinator_layout) |         updateTextColors(coordinator_layout) | ||||||
|  |  | ||||||
|  |         launchers_fastscroller.apply { | ||||||
|  |             updatePrimaryColor() | ||||||
|  |             updateBubbleColors() | ||||||
|  |             allowBubbleDisplay = config.showInfoBubble | ||||||
|  |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     override fun onPause() { |     override fun onPause() { | ||||||
| @@ -100,7 +106,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener { | |||||||
|     private fun setupLaunchers() { |     private fun setupLaunchers() { | ||||||
|         displayedLaunchers = dbHelper.getLaunchers() |         displayedLaunchers = dbHelper.getLaunchers() | ||||||
|         checkInvalidApps() |         checkInvalidApps() | ||||||
|         val adapter = LaunchersAdapter(this, displayedLaunchers, this, launchers_grid) { |         val adapter = LaunchersAdapter(this, displayedLaunchers, this, launchers_grid, launchers_fastscroller) { | ||||||
|             val launchIntent = packageManager.getLaunchIntentForPackage((it as AppLauncher).packageName) |             val launchIntent = packageManager.getLaunchIntentForPackage((it as AppLauncher).packageName) | ||||||
|             if (launchIntent != null) { |             if (launchIntent != null) { | ||||||
|                 startActivity(launchIntent) |                 startActivity(launchIntent) | ||||||
| @@ -112,6 +118,12 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener { | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         launchers_grid.adapter = adapter |         launchers_grid.adapter = adapter | ||||||
|  |  | ||||||
|  |         launchers_fastscroller.allowBubbleDisplay = config.showInfoBubble | ||||||
|  |         launchers_fastscroller.setViews(launchers_grid) { | ||||||
|  |             launchers_fastscroller.updateBubbleText(displayedLaunchers.getOrNull(it)?.getBubbleText() ?: "") | ||||||
|  |         } | ||||||
|  |  | ||||||
|         fillNotDisplayedLaunchers() |         fillNotDisplayedLaunchers() | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -21,6 +21,7 @@ class SettingsActivity : SimpleActivity() { | |||||||
|         setupCustomizeColors() |         setupCustomizeColors() | ||||||
|         setupUseEnglish() |         setupUseEnglish() | ||||||
|         setupAvoidWhatsNew() |         setupAvoidWhatsNew() | ||||||
|  |         setupShowInfoBubble() | ||||||
|         updateTextColors(settings_holder) |         updateTextColors(settings_holder) | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -47,4 +48,12 @@ class SettingsActivity : SimpleActivity() { | |||||||
|             config.avoidWhatsNew = settings_avoid_whats_new.isChecked |             config.avoidWhatsNew = settings_avoid_whats_new.isChecked | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     private fun setupShowInfoBubble() { | ||||||
|  |         settings_show_info_bubble.isChecked = config.showInfoBubble | ||||||
|  |         settings_show_info_bubble_holder.setOnClickListener { | ||||||
|  |             settings_show_info_bubble.toggle() | ||||||
|  |             config.showInfoBubble = settings_show_info_bubble.isChecked | ||||||
|  |         } | ||||||
|  |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -14,12 +14,14 @@ import com.simplemobiletools.commons.dialogs.ConfirmationDialog | |||||||
| import com.simplemobiletools.commons.extensions.applyColorFilter | import com.simplemobiletools.commons.extensions.applyColorFilter | ||||||
| import com.simplemobiletools.commons.extensions.beInvisibleIf | import com.simplemobiletools.commons.extensions.beInvisibleIf | ||||||
| import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener | import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener | ||||||
|  | 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.* | ||||||
|  |  | ||||||
| class LaunchersAdapter(activity: SimpleActivity, val launchers: MutableList<AppLauncher>, val listener: RefreshRecyclerViewListener?, | class LaunchersAdapter(activity: SimpleActivity, val launchers: MutableList<AppLauncher>, val listener: RefreshRecyclerViewListener?, | ||||||
|                        recyclerView: MyRecyclerView, itemClick: (Any) -> Unit) : MyRecyclerViewAdapter(activity, recyclerView, null, itemClick) { |                        recyclerView: MyRecyclerView, fastScroller: FastScroller, itemClick: (Any) -> Unit) : | ||||||
|  |         MyRecyclerViewAdapter(activity, recyclerView, fastScroller, itemClick) { | ||||||
|  |  | ||||||
|     init { |     init { | ||||||
|         setupDragListener(true) |         setupDragListener(true) | ||||||
|   | |||||||
| @@ -4,4 +4,6 @@ import android.graphics.drawable.Drawable | |||||||
|  |  | ||||||
| data class AppLauncher(val id: Int, var name: String, val packageName: String, val drawable: Drawable? = null) { | data class AppLauncher(val id: Int, var name: String, val packageName: String, val drawable: Drawable? = null) { | ||||||
|     override fun equals(other: Any?) = packageName.equals((other as AppLauncher).packageName, true) |     override fun equals(other: Any?) = packageName.equals((other as AppLauncher).packageName, true) | ||||||
|  |  | ||||||
|  |     fun getBubbleText() = name | ||||||
| } | } | ||||||
|   | |||||||
| @@ -6,6 +6,11 @@ | |||||||
|     android:layout_width="match_parent" |     android:layout_width="match_parent" | ||||||
|     android:layout_height="match_parent"> |     android:layout_height="match_parent"> | ||||||
|  |  | ||||||
|  |     <RelativeLayout | ||||||
|  |         android:id="@+id/launchers_holder" | ||||||
|  |         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" | ||||||
| @@ -16,6 +21,22 @@ | |||||||
|             app:layoutManager="com.simplemobiletools.commons.views.MyGridLayoutManager" |             app:layoutManager="com.simplemobiletools.commons.views.MyGridLayoutManager" | ||||||
|             app:spanCount="@integer/columns"/> |             app:spanCount="@integer/columns"/> | ||||||
|  |  | ||||||
|  |         <com.simplemobiletools.commons.views.FastScroller | ||||||
|  |             android:id="@+id/launchers_fastscroller" | ||||||
|  |             android:layout_width="wrap_content" | ||||||
|  |             android:layout_height="match_parent" | ||||||
|  |             android:layout_alignBottom="@+id/launchers_grid" | ||||||
|  |             android:layout_alignParentEnd="true" | ||||||
|  |             android:layout_alignParentRight="true" | ||||||
|  |             android:layout_alignTop="@+id/launchers_grid" | ||||||
|  |             android:paddingLeft="@dimen/normal_margin" | ||||||
|  |             android:paddingStart="@dimen/normal_margin"> | ||||||
|  |  | ||||||
|  |             <include layout="@layout/fastscroller_handle_vertical"/> | ||||||
|  |  | ||||||
|  |         </com.simplemobiletools.commons.views.FastScroller> | ||||||
|  |     </RelativeLayout> | ||||||
|  |  | ||||||
|     <com.simplemobiletools.commons.views.MyFloatingActionButton |     <com.simplemobiletools.commons.views.MyFloatingActionButton | ||||||
|         android:id="@+id/fab" |         android:id="@+id/fab" | ||||||
|         android:layout_width="wrap_content" |         android:layout_width="wrap_content" | ||||||
|   | |||||||
| @@ -72,5 +72,28 @@ | |||||||
|                 android:text="@string/avoid_whats_new"/> |                 android:text="@string/avoid_whats_new"/> | ||||||
|  |  | ||||||
|         </RelativeLayout> |         </RelativeLayout> | ||||||
|  |  | ||||||
|  |         <RelativeLayout | ||||||
|  |             android:id="@+id/settings_show_info_bubble_holder" | ||||||
|  |             android:layout_width="match_parent" | ||||||
|  |             android:layout_height="wrap_content" | ||||||
|  |             android:layout_marginTop="@dimen/medium_margin" | ||||||
|  |             android:background="?attr/selectableItemBackground" | ||||||
|  |             android:paddingBottom="@dimen/activity_margin" | ||||||
|  |             android:paddingLeft="@dimen/normal_margin" | ||||||
|  |             android:paddingRight="@dimen/normal_margin" | ||||||
|  |             android:paddingTop="@dimen/activity_margin"> | ||||||
|  |  | ||||||
|  |             <com.simplemobiletools.commons.views.MySwitchCompat | ||||||
|  |                 android:id="@+id/settings_show_info_bubble" | ||||||
|  |                 android:layout_width="match_parent" | ||||||
|  |                 android:layout_height="wrap_content" | ||||||
|  |                 android:background="@null" | ||||||
|  |                 android:clickable="false" | ||||||
|  |                 android:paddingLeft="@dimen/medium_margin" | ||||||
|  |                 android:paddingStart="@dimen/medium_margin" | ||||||
|  |                 android:text="@string/show_info_bubble"/> | ||||||
|  |  | ||||||
|  |         </RelativeLayout> | ||||||
|     </LinearLayout> |     </LinearLayout> | ||||||
| </ScrollView> | </ScrollView> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user