mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 22:47:59 +01:00
fix a different type of contact photo picking too
This commit is contained in:
parent
7358bb7cce
commit
0e38255961
1 changed files with 20 additions and 3 deletions
|
@ -28,6 +28,9 @@ import com.simplemobiletools.gallery.models.Directory
|
||||||
import com.simplemobiletools.gallery.views.MyScalableRecyclerView
|
import com.simplemobiletools.gallery.views.MyScalableRecyclerView
|
||||||
import kotlinx.android.synthetic.main.activity_main.*
|
import kotlinx.android.synthetic.main.activity_main.*
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
import java.io.FileInputStream
|
||||||
|
import java.io.InputStream
|
||||||
|
import java.io.OutputStream
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
||||||
|
@ -291,9 +294,23 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
||||||
val path = resultData.data.path
|
val path = resultData.data.path
|
||||||
val uri = Uri.fromFile(File(path))
|
val uri = Uri.fromFile(File(path))
|
||||||
if (mIsGetImageContentIntent || mIsGetVideoContentIntent || mIsGetAnyContentIntent) {
|
if (mIsGetImageContentIntent || mIsGetVideoContentIntent || mIsGetAnyContentIntent) {
|
||||||
|
if (intent.extras?.containsKey(MediaStore.EXTRA_OUTPUT) == true) {
|
||||||
|
var inputStream: InputStream? = null
|
||||||
|
var outputStream: OutputStream? = null
|
||||||
|
try {
|
||||||
|
val output = intent.extras.get(MediaStore.EXTRA_OUTPUT) as Uri
|
||||||
|
inputStream = FileInputStream(File(path))
|
||||||
|
outputStream = contentResolver.openOutputStream(output)
|
||||||
|
inputStream.copyTo(outputStream)
|
||||||
|
} finally {
|
||||||
|
inputStream?.close()
|
||||||
|
outputStream?.close()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
val type = File(path).getMimeType("image/jpeg")
|
val type = File(path).getMimeType("image/jpeg")
|
||||||
setDataAndTypeAndNormalize(uri, type)
|
setDataAndTypeAndNormalize(uri, type)
|
||||||
flags = Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION
|
flags = Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION
|
||||||
|
}
|
||||||
} else if (mIsPickImageIntent || mIsPickVideoIntent) {
|
} else if (mIsPickImageIntent || mIsPickVideoIntent) {
|
||||||
data = uri
|
data = uri
|
||||||
flags = Intent.FLAG_GRANT_READ_URI_PERMISSION
|
flags = Intent.FLAG_GRANT_READ_URI_PERMISSION
|
||||||
|
|
Loading…
Reference in a new issue