From 8e8c0b127d1fea0a7e8a2ef7bc531ee6abeccc27 Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 27 Oct 2017 09:33:17 +0200 Subject: [PATCH] add an Open With menu button to media thumbnails view --- .../com/simplemobiletools/gallery/adapters/MediaAdapter.kt | 4 +++- app/src/main/res/menu/cab_media.xml | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt index 1be8d7856..64ea45c2a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt @@ -87,6 +87,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, R.id.cab_copy_to -> copyMoveTo(true) R.id.cab_move_to -> copyMoveTo(false) R.id.cab_select_all -> selectAll() + R.id.cab_open_with -> activity.openFile(Uri.fromFile(getCurrentFile())) R.id.cab_delete -> checkDeleteConfirmation() else -> return false } @@ -101,7 +102,8 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, } override fun onPrepareActionMode(actionMode: ActionMode?, menu: Menu): Boolean { - menu.findItem(R.id.cab_rename).isVisible = selectedPositions.size <= 1 + menu.findItem(R.id.cab_rename).isVisible = selectedPositions.size == 1 + menu.findItem(R.id.cab_open_with).isVisible = selectedPositions.size == 1 menu.findItem(R.id.cab_edit).isVisible = selectedPositions.size == 1 && media.size > selectedPositions.first() && media[selectedPositions.first()].isImage() menu.findItem(R.id.cab_confirm_selection).isVisible = isPickIntent && allowMultiplePicks && selectedPositions.size > 0 diff --git a/app/src/main/res/menu/cab_media.xml b/app/src/main/res/menu/cab_media.xml index fa787d520..bcf08f106 100644 --- a/app/src/main/res/menu/cab_media.xml +++ b/app/src/main/res/menu/cab_media.xml @@ -46,6 +46,10 @@ android:icon="@drawable/ic_select_all" android:title="@string/select_all" app:showAsAction="ifRoom"/> +