add some menu buttons for quickly moving a folder to the top or bottom
This commit is contained in:
parent
acc6890a08
commit
da47c199d9
|
@ -78,7 +78,7 @@ android {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.github.SimpleMobileTools:Simple-Commons:94718a76cb'
|
implementation 'com.github.SimpleMobileTools:Simple-Commons:5c4094baf8'
|
||||||
implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
|
implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
|
||||||
implementation 'it.sephiroth.android.exif:library:1.0.1'
|
implementation 'it.sephiroth.android.exif:library:1.0.1'
|
||||||
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.22'
|
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.22'
|
||||||
|
|
|
@ -67,7 +67,7 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
||||||
private var groupDirectSubfolders = config.groupDirectSubfolders
|
private var groupDirectSubfolders = config.groupDirectSubfolders
|
||||||
private var currentDirectoriesHash = dirs.hashCode()
|
private var currentDirectoriesHash = dirs.hashCode()
|
||||||
private var lockedFolderPaths = ArrayList<String>()
|
private var lockedFolderPaths = ArrayList<String>()
|
||||||
private var isChangingOrder = false
|
private var isDragAndDropping = false
|
||||||
private var startReorderDragListener: StartReorderDragListener
|
private var startReorderDragListener: StartReorderDragListener
|
||||||
|
|
||||||
private var showMediaCount = config.showFolderMediaCount
|
private var showMediaCount = config.showFolderMediaCount
|
||||||
|
@ -111,6 +111,7 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
||||||
override fun getItemCount() = dirs.size
|
override fun getItemCount() = dirs.size
|
||||||
|
|
||||||
override fun prepareActionMode(menu: Menu) {
|
override fun prepareActionMode(menu: Menu) {
|
||||||
|
mydebug("prepareaction")
|
||||||
val selectedPaths = getSelectedPaths()
|
val selectedPaths = getSelectedPaths()
|
||||||
if (selectedPaths.isEmpty()) {
|
if (selectedPaths.isEmpty()) {
|
||||||
return
|
return
|
||||||
|
@ -118,6 +119,9 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
||||||
|
|
||||||
val isOneItemSelected = isOneItemSelected()
|
val isOneItemSelected = isOneItemSelected()
|
||||||
menu.apply {
|
menu.apply {
|
||||||
|
findItem(R.id.cab_move_to_top).isVisible = isDragAndDropping
|
||||||
|
findItem(R.id.cab_move_to_bottom).isVisible = isDragAndDropping
|
||||||
|
|
||||||
findItem(R.id.cab_rename).isVisible = !selectedPaths.contains(FAVORITES) && !selectedPaths.contains(RECYCLE_BIN)
|
findItem(R.id.cab_rename).isVisible = !selectedPaths.contains(FAVORITES) && !selectedPaths.contains(RECYCLE_BIN)
|
||||||
findItem(R.id.cab_change_cover_image).isVisible = isOneItemSelected
|
findItem(R.id.cab_change_cover_image).isVisible = isOneItemSelected
|
||||||
|
|
||||||
|
@ -140,6 +144,8 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
||||||
}
|
}
|
||||||
|
|
||||||
when (id) {
|
when (id) {
|
||||||
|
R.id.cab_move_to_top -> moveSelectedItemsToTop()
|
||||||
|
R.id.cab_move_to_bottom -> moveSelectedItemsToBottom()
|
||||||
R.id.cab_properties -> showProperties()
|
R.id.cab_properties -> showProperties()
|
||||||
R.id.cab_rename -> renameDir()
|
R.id.cab_rename -> renameDir()
|
||||||
R.id.cab_pin -> pinFolders(true)
|
R.id.cab_pin -> pinFolders(true)
|
||||||
|
@ -173,7 +179,7 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
||||||
override fun onActionModeCreated() {}
|
override fun onActionModeCreated() {}
|
||||||
|
|
||||||
override fun onActionModeDestroyed() {
|
override fun onActionModeDestroyed() {
|
||||||
if (isChangingOrder) {
|
if (isDragAndDropping) {
|
||||||
notifyDataSetChanged()
|
notifyDataSetChanged()
|
||||||
|
|
||||||
val reorderedFoldersList = dirs.map { it.path }
|
val reorderedFoldersList = dirs.map { it.path }
|
||||||
|
@ -181,7 +187,7 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
||||||
config.directorySorting = SORT_BY_CUSTOM
|
config.directorySorting = SORT_BY_CUSTOM
|
||||||
}
|
}
|
||||||
|
|
||||||
isChangingOrder = false
|
isDragAndDropping = false
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onViewRecycled(holder: ViewHolder) {
|
override fun onViewRecycled(holder: ViewHolder) {
|
||||||
|
@ -202,6 +208,28 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
||||||
menu.findItem(R.id.cab_unpin).isVisible = selectedPaths.any { pinnedFolders.contains(it) }
|
menu.findItem(R.id.cab_unpin).isVisible = selectedPaths.any { pinnedFolders.contains(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun moveSelectedItemsToTop() {
|
||||||
|
selectedKeys.reversed().forEach { key ->
|
||||||
|
val position = dirs.indexOfFirst { it.path.hashCode() == key }
|
||||||
|
val tempItem = dirs[position]
|
||||||
|
dirs.removeAt(position)
|
||||||
|
dirs.add(0, tempItem)
|
||||||
|
}
|
||||||
|
|
||||||
|
notifyDataSetChanged()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun moveSelectedItemsToBottom() {
|
||||||
|
selectedKeys.forEach { key ->
|
||||||
|
val position = dirs.indexOfFirst { it.path.hashCode() == key }
|
||||||
|
val tempItem = dirs[position]
|
||||||
|
dirs.removeAt(position)
|
||||||
|
dirs.add(dirs.size, tempItem)
|
||||||
|
}
|
||||||
|
|
||||||
|
notifyDataSetChanged()
|
||||||
|
}
|
||||||
|
|
||||||
private fun showProperties() {
|
private fun showProperties() {
|
||||||
if (selectedKeys.size <= 1) {
|
if (selectedKeys.size <= 1) {
|
||||||
val path = getFirstSelectedItemPath() ?: return
|
val path = getFirstSelectedItemPath() ?: return
|
||||||
|
@ -463,8 +491,9 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun changeOrder() {
|
private fun changeOrder() {
|
||||||
isChangingOrder = true
|
isDragAndDropping = true
|
||||||
notifyDataSetChanged()
|
notifyDataSetChanged()
|
||||||
|
actMode?.invalidate()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun moveFilesTo() {
|
private fun moveFilesTo() {
|
||||||
|
@ -800,12 +829,12 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
||||||
dir_path.setTextColor(textColor)
|
dir_path.setTextColor(textColor)
|
||||||
dir_pin.applyColorFilter(textColor)
|
dir_pin.applyColorFilter(textColor)
|
||||||
dir_location.applyColorFilter(textColor)
|
dir_location.applyColorFilter(textColor)
|
||||||
dir_drag_handle.beVisibleIf(isChangingOrder)
|
dir_drag_handle.beVisibleIf(isDragAndDropping)
|
||||||
} else {
|
} else {
|
||||||
dir_drag_handle_wrapper.beVisibleIf(isChangingOrder)
|
dir_drag_handle_wrapper.beVisibleIf(isDragAndDropping)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isChangingOrder) {
|
if (isDragAndDropping) {
|
||||||
dir_drag_handle.applyColorFilter(textColor)
|
dir_drag_handle.applyColorFilter(textColor)
|
||||||
dir_drag_handle.setOnTouchListener { v, event ->
|
dir_drag_handle.setOnTouchListener { v, event ->
|
||||||
if (event.action == MotionEvent.ACTION_DOWN) {
|
if (event.action == MotionEvent.ACTION_DOWN) {
|
||||||
|
|
|
@ -1,6 +1,16 @@
|
||||||
<?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_move_to_top"
|
||||||
|
android:icon="@drawable/ic_move_to_top_vector"
|
||||||
|
android:title="@string/move_to_top"
|
||||||
|
app:showAsAction="ifRoom"/>
|
||||||
|
<item
|
||||||
|
android:id="@+id/cab_move_to_bottom"
|
||||||
|
android:icon="@drawable/ic_move_to_bottom_vector"
|
||||||
|
android:title="@string/move_to_bottom"
|
||||||
|
app:showAsAction="ifRoom"/>
|
||||||
<item
|
<item
|
||||||
android:id="@+id/cab_delete"
|
android:id="@+id/cab_delete"
|
||||||
android:icon="@drawable/ic_delete_vector"
|
android:icon="@drawable/ic_delete_vector"
|
||||||
|
|
Loading…
Reference in New Issue