mirror of
https://github.com/SimpleMobileTools/Simple-File-Manager.git
synced 2025-06-05 22:09:15 +02:00
handle picking multiple items at get_content too
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
package com.simplemobiletools.filemanager.activities
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.ClipData
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
@ -30,7 +31,6 @@ import java.util.*
|
||||
class MainActivity : SimpleActivity() {
|
||||
private val BACK_PRESS_TIMEOUT = 5000
|
||||
private var wasBackJustPressed = false
|
||||
private var isGetContentIntent = false
|
||||
|
||||
private lateinit var fragment: ItemsFragment
|
||||
|
||||
@ -40,8 +40,10 @@ class MainActivity : SimpleActivity() {
|
||||
storeStoragePaths()
|
||||
|
||||
fragment = fragment_holder as ItemsFragment
|
||||
isGetContentIntent = intent.action == Intent.ACTION_GET_CONTENT
|
||||
val isGetContentIntent = intent.action == Intent.ACTION_GET_CONTENT
|
||||
val allowPickingMultiple = intent.getBooleanExtra(Intent.EXTRA_ALLOW_MULTIPLE, false)
|
||||
fragment.isGetContentIntent = isGetContentIntent
|
||||
fragment.isPickMultipleIntent = allowPickingMultiple
|
||||
|
||||
tryInitFileManager()
|
||||
checkWhatsNewDialog()
|
||||
@ -205,6 +207,20 @@ class MainActivity : SimpleActivity() {
|
||||
finish()
|
||||
}
|
||||
|
||||
fun pickedPaths(paths: ArrayList<String>) {
|
||||
val uris = paths.map { Uri.fromFile(File(it)) } as ArrayList
|
||||
val clipData = ClipData("Attachment", arrayOf(uris.getMimeType()), ClipData.Item(uris.removeAt(0)))
|
||||
|
||||
uris.forEach {
|
||||
clipData.addItem(ClipData.Item(it))
|
||||
}
|
||||
|
||||
val resultIntent = Intent()
|
||||
resultIntent.clipData = clipData
|
||||
setResult(Activity.RESULT_OK, resultIntent)
|
||||
finish()
|
||||
}
|
||||
|
||||
private fun checkWhatsNewDialog() {
|
||||
arrayListOf<Release>().apply {
|
||||
add(Release(26, R.string.release_26))
|
||||
|
Reference in New Issue
Block a user