mirror of
https://github.com/SimpleMobileTools/Simple-App-Launcher.git
synced 2025-03-06 12:17:56 +01:00
adding a menu item for launching reorder mode
This commit is contained in:
parent
1f9daf50cc
commit
4921a4f4b2
@ -56,7 +56,7 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.simplemobiletools:commons:5.31.26'
|
implementation 'com.simplemobiletools:commons:5.31.27'
|
||||||
implementation 'com.facebook.stetho:stetho:1.5.0'
|
implementation 'com.facebook.stetho:stetho:1.5.0'
|
||||||
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'
|
||||||
|
@ -13,6 +13,7 @@ import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
|||||||
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
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.extensions.beVisibleIf
|
||||||
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
|
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
|
||||||
import com.simplemobiletools.commons.views.FastScroller
|
import com.simplemobiletools.commons.views.FastScroller
|
||||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||||
@ -22,6 +23,8 @@ class LaunchersAdapter(activity: SimpleActivity, val launchers: ArrayList<AppLau
|
|||||||
recyclerView: MyRecyclerView, fastScroller: FastScroller, itemClick: (Any) -> Unit) :
|
recyclerView: MyRecyclerView, fastScroller: FastScroller, itemClick: (Any) -> Unit) :
|
||||||
MyRecyclerViewAdapter(activity, recyclerView, fastScroller, itemClick) {
|
MyRecyclerViewAdapter(activity, recyclerView, fastScroller, itemClick) {
|
||||||
|
|
||||||
|
private var isChangingOrder = false
|
||||||
|
|
||||||
init {
|
init {
|
||||||
setupDragListener(true)
|
setupDragListener(true)
|
||||||
}
|
}
|
||||||
@ -40,6 +43,7 @@ class LaunchersAdapter(activity: SimpleActivity, val launchers: ArrayList<AppLau
|
|||||||
}
|
}
|
||||||
|
|
||||||
when (id) {
|
when (id) {
|
||||||
|
R.id.cab_change_order -> changeOrder()
|
||||||
R.id.cab_edit -> showEditDialog()
|
R.id.cab_edit -> showEditDialog()
|
||||||
R.id.cab_remove -> tryRemoveLauncher()
|
R.id.cab_remove -> tryRemoveLauncher()
|
||||||
}
|
}
|
||||||
@ -69,7 +73,15 @@ class LaunchersAdapter(activity: SimpleActivity, val launchers: ArrayList<AppLau
|
|||||||
|
|
||||||
override fun onActionModeCreated() {}
|
override fun onActionModeCreated() {}
|
||||||
|
|
||||||
override fun onActionModeDestroyed() {}
|
override fun onActionModeDestroyed() {
|
||||||
|
isChangingOrder = false
|
||||||
|
notifyDataSetChanged()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun changeOrder() {
|
||||||
|
isChangingOrder = true
|
||||||
|
notifyDataSetChanged()
|
||||||
|
}
|
||||||
|
|
||||||
private fun showEditDialog() {
|
private fun showEditDialog() {
|
||||||
EditDialog(activity, getItemWithKey(selectedKeys.first())!!) {
|
EditDialog(activity, getItemWithKey(selectedKeys.first())!!) {
|
||||||
@ -121,6 +133,7 @@ class LaunchersAdapter(activity: SimpleActivity, val launchers: ArrayList<AppLau
|
|||||||
launcher_label.text = launcher.title
|
launcher_label.text = launcher.title
|
||||||
launcher_label.setTextColor(textColor)
|
launcher_label.setTextColor(textColor)
|
||||||
launcher_icon.setImageDrawable(launcher.drawable!!)
|
launcher_icon.setImageDrawable(launcher.drawable!!)
|
||||||
|
launcher_drag_handle.beVisibleIf(isChangingOrder)
|
||||||
|
|
||||||
if (isSelected) {
|
if (isSelected) {
|
||||||
launcher_check?.background?.applyColorFilter(primaryColor)
|
launcher_check?.background?.applyColorFilter(primaryColor)
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:id="@+id/launcher_holder"
|
android:id="@+id/launcher_holder"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@ -31,13 +30,22 @@
|
|||||||
android:id="@+id/launcher_check"
|
android:id="@+id/launcher_check"
|
||||||
android:layout_width="@dimen/selection_check_size"
|
android:layout_width="@dimen/selection_check_size"
|
||||||
android:layout_height="@dimen/selection_check_size"
|
android:layout_height="@dimen/selection_check_size"
|
||||||
android:layout_alignParentEnd="true"
|
|
||||||
android:layout_alignParentRight="true"
|
|
||||||
android:layout_alignParentTop="true"
|
android:layout_alignParentTop="true"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
android:layout_margin="@dimen/small_margin"
|
android:layout_margin="@dimen/small_margin"
|
||||||
android:background="@drawable/circle_background"
|
android:background="@drawable/circle_background"
|
||||||
android:padding="@dimen/tiny_margin"
|
android:padding="@dimen/tiny_margin"
|
||||||
android:src="@drawable/ic_check_vector"
|
android:src="@drawable/ic_check_vector"
|
||||||
android:visibility="invisible" />
|
android:visibility="invisible" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/launcher_drag_handle"
|
||||||
|
android:layout_width="@dimen/drag_handle_size"
|
||||||
|
android:layout_height="@dimen/drag_handle_size"
|
||||||
|
android:layout_below="@+id/launcher_check"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:padding="@dimen/small_margin"
|
||||||
|
android:src="@drawable/ic_drag_handle_vector"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
<item
|
||||||
|
android:id="@+id/cab_change_order"
|
||||||
|
android:icon="@drawable/ic_drag_handle_vector"
|
||||||
|
android:title="@string/change_order"
|
||||||
|
app:showAsAction="ifRoom" />
|
||||||
<item
|
<item
|
||||||
android:id="@+id/cab_edit"
|
android:id="@+id/cab_edit"
|
||||||
android:icon="@drawable/ic_rename_new"
|
android:icon="@drawable/ic_rename_new"
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<dimen name="launcher_icon_size">55dp</dimen>
|
<dimen name="launcher_icon_size">55dp</dimen>
|
||||||
|
<dimen name="drag_handle_size">36dp</dimen>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user