From 9f9b6a154a8c7ad73cba9ca2bd459561605365bd Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 29 Oct 2017 23:41:39 +0100 Subject: [PATCH] add Set As and Open With actionmenu items --- .../filemanager/adapters/ItemsAdapter.kt | 33 ++++++++++++++----- .../filemanager/extensions/Activity.kt | 5 +++ app/src/main/res/menu/cab.xml | 8 +++++ 3 files changed, 38 insertions(+), 8 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/adapters/ItemsAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/adapters/ItemsAdapter.kt index 02dfbec1..c3ed56e1 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/adapters/ItemsAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/adapters/ItemsAdapter.kt @@ -27,10 +27,7 @@ import com.simplemobiletools.filemanager.BuildConfig import com.simplemobiletools.filemanager.R import com.simplemobiletools.filemanager.activities.SimpleActivity import com.simplemobiletools.filemanager.dialogs.CompressAsDialog -import com.simplemobiletools.filemanager.extensions.config -import com.simplemobiletools.filemanager.extensions.isPathOnRoot -import com.simplemobiletools.filemanager.extensions.isZipFile -import com.simplemobiletools.filemanager.extensions.shareUris +import com.simplemobiletools.filemanager.extensions.* import com.stericson.RootTools.RootTools import kotlinx.android.synthetic.main.list_item.view.* import java.io.Closeable @@ -111,6 +108,8 @@ class ItemsAdapter(val activity: SimpleActivity, var mItems: MutableList showProperties() R.id.cab_share -> shareFiles() R.id.cab_copy_path -> copyPath() + R.id.cab_set_as -> setAs() + R.id.cab_open_with -> openWith() R.id.cab_copy_to -> copyMoveTo(true) R.id.cab_move_to -> copyMoveTo(false) R.id.cab_compress -> compressSelection() @@ -130,10 +129,14 @@ class ItemsAdapter(val activity: SimpleActivity, var mItems: MutableList() selectedPositions.forEach { files.add(File(mItems[it].path)) } diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/extensions/Activity.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/extensions/Activity.kt index cfaee467..4ea75d7f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/extensions/Activity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/extensions/Activity.kt @@ -3,6 +3,7 @@ package com.simplemobiletools.filemanager.extensions import android.app.Activity import android.net.Uri import com.simplemobiletools.commons.extensions.openFile +import com.simplemobiletools.commons.extensions.setAs import com.simplemobiletools.commons.extensions.shareUri import com.simplemobiletools.commons.extensions.shareUris import com.simplemobiletools.filemanager.BuildConfig @@ -24,3 +25,7 @@ fun Activity.shareUris(uris: ArrayList) { fun Activity.openFile(uri: Uri, forceChooser: Boolean) { openFile(uri, forceChooser, BuildConfig.APPLICATION_ID) } + +fun Activity.setAs(uri: Uri) { + setAs(uri, BuildConfig.APPLICATION_ID) +} diff --git a/app/src/main/res/menu/cab.xml b/app/src/main/res/menu/cab.xml index 1ed08c97..ba290ac4 100644 --- a/app/src/main/res/menu/cab.xml +++ b/app/src/main/res/menu/cab.xml @@ -25,6 +25,14 @@ android:id="@+id/cab_copy_path" android:title="@string/copy_path" app:showAsAction="never"/> + +