mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 22:47:59 +01:00
add an Edit button to media cab
This commit is contained in:
parent
ade06101a5
commit
74d8287333
2 changed files with 21 additions and 3 deletions
|
@ -20,6 +20,7 @@ import com.simplemobiletools.gallery.activities.SimpleActivity
|
||||||
import com.simplemobiletools.gallery.dialogs.CopyDialog
|
import com.simplemobiletools.gallery.dialogs.CopyDialog
|
||||||
import com.simplemobiletools.gallery.dialogs.RenameFileDialog
|
import com.simplemobiletools.gallery.dialogs.RenameFileDialog
|
||||||
import com.simplemobiletools.gallery.extensions.beVisibleIf
|
import com.simplemobiletools.gallery.extensions.beVisibleIf
|
||||||
|
import com.simplemobiletools.gallery.extensions.openEditor
|
||||||
import com.simplemobiletools.gallery.extensions.shareMedia
|
import com.simplemobiletools.gallery.extensions.shareMedia
|
||||||
import com.simplemobiletools.gallery.extensions.shareMedium
|
import com.simplemobiletools.gallery.extensions.shareMedium
|
||||||
import com.simplemobiletools.gallery.helpers.Config
|
import com.simplemobiletools.gallery.helpers.Config
|
||||||
|
@ -67,13 +68,17 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
||||||
renameFile()
|
renameFile()
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
R.id.cab_edit -> {
|
||||||
|
editFile()
|
||||||
|
true
|
||||||
|
}
|
||||||
R.id.cab_share -> {
|
R.id.cab_share -> {
|
||||||
shareMedia()
|
shareMedia()
|
||||||
return true
|
true
|
||||||
}
|
}
|
||||||
R.id.cab_copy_move -> {
|
R.id.cab_copy_move -> {
|
||||||
displayCopyDialog()
|
displayCopyDialog()
|
||||||
return true
|
true
|
||||||
}
|
}
|
||||||
R.id.cab_delete -> {
|
R.id.cab_delete -> {
|
||||||
askConfirmDelete()
|
askConfirmDelete()
|
||||||
|
@ -92,6 +97,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
||||||
|
|
||||||
override fun onPrepareActionMode(actionMode: ActionMode?, menu: Menu): Boolean {
|
override fun onPrepareActionMode(actionMode: ActionMode?, menu: Menu): Boolean {
|
||||||
menu.findItem(R.id.cab_rename).isVisible = multiSelector.selectedPositions.size <= 1
|
menu.findItem(R.id.cab_rename).isVisible = multiSelector.selectedPositions.size <= 1
|
||||||
|
menu.findItem(R.id.cab_edit).isVisible = multiSelector.selectedPositions.size <= 1
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -115,7 +121,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun renameFile() {
|
private fun renameFile() {
|
||||||
RenameFileDialog(activity, File(media[multiSelector.selectedPositions[0]].path)) {
|
RenameFileDialog(activity, getCurrentFile()) {
|
||||||
listener?.refreshItems()
|
listener?.refreshItems()
|
||||||
activity.runOnUiThread {
|
activity.runOnUiThread {
|
||||||
actMode?.finish()
|
actMode?.finish()
|
||||||
|
@ -123,6 +129,11 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun editFile() {
|
||||||
|
activity.openEditor(getCurrentFile())
|
||||||
|
actMode?.finish()
|
||||||
|
}
|
||||||
|
|
||||||
private fun shareMedia() {
|
private fun shareMedia() {
|
||||||
val selections = multiSelector.selectedPositions
|
val selections = multiSelector.selectedPositions
|
||||||
if (selections.size <= 1) {
|
if (selections.size <= 1) {
|
||||||
|
@ -161,6 +172,8 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getCurrentFile() = File(media[multiSelector.selectedPositions[0]].path)
|
||||||
|
|
||||||
private fun prepareForDeleting() {
|
private fun prepareForDeleting() {
|
||||||
val selections = multiSelector.selectedPositions
|
val selections = multiSelector.selectedPositions
|
||||||
val paths = ArrayList<String>(selections.size)
|
val paths = ArrayList<String>(selections.size)
|
||||||
|
|
|
@ -21,6 +21,11 @@
|
||||||
android:icon="@mipmap/rename"
|
android:icon="@mipmap/rename"
|
||||||
android:title="@string/rename"
|
android:title="@string/rename"
|
||||||
app:showAsAction="ifRoom"/>
|
app:showAsAction="ifRoom"/>
|
||||||
|
<item
|
||||||
|
android:id="@+id/cab_edit"
|
||||||
|
android:icon="@mipmap/edit"
|
||||||
|
android:title="@string/edit"
|
||||||
|
app:showAsAction="ifRoom"/>
|
||||||
<item
|
<item
|
||||||
android:id="@+id/cab_delete"
|
android:id="@+id/cab_delete"
|
||||||
android:icon="@mipmap/delete"
|
android:icon="@mipmap/delete"
|
||||||
|
|
Loading…
Reference in a new issue