mirror of
https://github.com/SimpleMobileTools/Simple-App-Launcher.git
synced 2025-02-02 02:16:49 +01:00
add a fastscroller if needed
This commit is contained in:
parent
0d4b93bfc2
commit
419db032ee
@ -62,6 +62,12 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
||||
}
|
||||
|
||||
updateTextColors(coordinator_layout)
|
||||
|
||||
launchers_fastscroller.apply {
|
||||
updatePrimaryColor()
|
||||
updateBubbleColors()
|
||||
allowBubbleDisplay = config.showInfoBubble
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
@ -100,7 +106,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
||||
private fun setupLaunchers() {
|
||||
displayedLaunchers = dbHelper.getLaunchers()
|
||||
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)
|
||||
if (launchIntent != null) {
|
||||
startActivity(launchIntent)
|
||||
@ -112,6 +118,12 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
||||
}
|
||||
}
|
||||
launchers_grid.adapter = adapter
|
||||
|
||||
launchers_fastscroller.allowBubbleDisplay = config.showInfoBubble
|
||||
launchers_fastscroller.setViews(launchers_grid) {
|
||||
launchers_fastscroller.updateBubbleText(displayedLaunchers.getOrNull(it)?.getBubbleText() ?: "")
|
||||
}
|
||||
|
||||
fillNotDisplayedLaunchers()
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,7 @@ class SettingsActivity : SimpleActivity() {
|
||||
setupCustomizeColors()
|
||||
setupUseEnglish()
|
||||
setupAvoidWhatsNew()
|
||||
setupShowInfoBubble()
|
||||
updateTextColors(settings_holder)
|
||||
}
|
||||
|
||||
@ -47,4 +48,12 @@ class SettingsActivity : SimpleActivity() {
|
||||
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.beInvisibleIf
|
||||
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
|
||||
import com.simplemobiletools.commons.views.FastScroller
|
||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||
import kotlinx.android.synthetic.main.item_app_launcher.view.*
|
||||
import java.util.*
|
||||
|
||||
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 {
|
||||
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) {
|
||||
override fun equals(other: Any?) = packageName.equals((other as AppLauncher).packageName, true)
|
||||
|
||||
fun getBubbleText() = name
|
||||
}
|
||||
|
@ -6,15 +6,36 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyRecyclerView
|
||||
android:id="@+id/launchers_grid"
|
||||
<RelativeLayout
|
||||
android:id="@+id/launchers_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
android:paddingBottom="@dimen/activity_margin"
|
||||
android:paddingTop="@dimen/activity_margin"
|
||||
app:layoutManager="com.simplemobiletools.commons.views.MyGridLayoutManager"
|
||||
app:spanCount="@integer/columns"/>
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyRecyclerView
|
||||
android:id="@+id/launchers_grid"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
android:paddingBottom="@dimen/activity_margin"
|
||||
android:paddingTop="@dimen/activity_margin"
|
||||
app:layoutManager="com.simplemobiletools.commons.views.MyGridLayoutManager"
|
||||
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
|
||||
android:id="@+id/fab"
|
||||
|
@ -72,5 +72,28 @@
|
||||
android:text="@string/avoid_whats_new"/>
|
||||
|
||||
</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>
|
||||
</ScrollView>
|
||||
|
Loading…
x
Reference in New Issue
Block a user