use the Commons way of determining mimetype of multiple uris
This commit is contained in:
parent
2969314cc9
commit
e0703acd9d
|
@ -37,7 +37,7 @@ android {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile 'com.simplemobiletools:commons:2.30.10'
|
compile 'com.simplemobiletools:commons:2.30.13'
|
||||||
compile 'com.bignerdranch.android:recyclerview-multiselect:0.2'
|
compile 'com.bignerdranch.android:recyclerview-multiselect:0.2'
|
||||||
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||||
|
|
||||||
|
|
|
@ -179,7 +179,7 @@ class ItemsAdapter(val activity: SimpleActivity, var mItems: MutableList<FileDir
|
||||||
action = Intent.ACTION_SEND_MULTIPLE
|
action = Intent.ACTION_SEND_MULTIPLE
|
||||||
putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris)
|
putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris)
|
||||||
}
|
}
|
||||||
type = getMimeType(uris)
|
type = uris.getMimeType()
|
||||||
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
|
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -200,19 +200,6 @@ class ItemsAdapter(val activity: SimpleActivity, var mItems: MutableList<FileDir
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getMimeType(uris: List<Uri>): String {
|
|
||||||
val firstMimeType = uris.first().path.getMimeTypeFromPath()
|
|
||||||
val firstMimeGroup = firstMimeType.substringBefore("/")
|
|
||||||
|
|
||||||
uris.forEach {
|
|
||||||
val mimeGroup = it.path.getMimeTypeFromPath().substringBefore("/")
|
|
||||||
if (mimeGroup != firstMimeGroup) {
|
|
||||||
return "*/*"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return firstMimeType
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun copyMoveTo(isCopyOperation: Boolean) {
|
private fun copyMoveTo(isCopyOperation: Boolean) {
|
||||||
val files = ArrayList<File>()
|
val files = ArrayList<File>()
|
||||||
selectedPositions.forEach { files.add(File(mItems[it].path)) }
|
selectedPositions.forEach { files.add(File(mItems[it].path)) }
|
||||||
|
|
Loading…
Reference in New Issue