diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt
index 8c6b7ac98..d5b2de823 100644
--- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt
@@ -18,6 +18,7 @@ import java.io.IOException
class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener {
val TAG: String = EditActivity::class.java.simpleName
+ lateinit var uri: Uri
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@@ -29,6 +30,13 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
return
}
+ uri = intent.data
+ if (uri.scheme != "file" && uri.scheme != "content") {
+ toast(R.string.unknown_file_location)
+ finish()
+ return
+ }
+
crop_image_view.apply {
guidelines = CropImageView.Guidelines.OFF
setOnCropImageCompleteListener(this@EditActivity)
@@ -57,27 +65,36 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
override fun onCropImageComplete(view: CropImageView, result: CropImageView.CropResult) {
if (result.error == null) {
- val path = intent.data.path
- val file = File(path)
- var out: FileOutputStream? = null
- try {
- out = FileOutputStream(file)
- result.bitmap.compress(getCompressionFormat(file), 100, out)
- setResult(Activity.RESULT_OK, intent)
- } catch (e: Exception) {
- Log.e(TAG, "Crop compressing failed $e")
- toast(R.string.image_editing_failed)
- } finally {
+ if (uri.scheme == "file") {
+ val path = uri.path
+ val file = File(path)
+ var out: FileOutputStream? = null
try {
- out?.close()
- } catch (e: IOException) {
- Log.e(TAG, "FileOutputStream closing failed $e")
+ out = FileOutputStream(file)
+ result.bitmap.compress(getCompressionFormat(file), 100, out)
+ setResult(Activity.RESULT_OK, intent)
+ } catch (e: Exception) {
+ Log.e(TAG, "Crop compressing failed $e")
+ toast(R.string.image_editing_failed)
+ finish()
+ } finally {
+ try {
+ out?.close()
+ } catch (e: IOException) {
+ Log.e(TAG, "FileOutputStream closing failed $e")
+ }
}
- }
- MediaScannerConnection.scanFile(applicationContext, arrayOf(path), null, { path: String, uri: Uri ->
+ MediaScannerConnection.scanFile(applicationContext, arrayOf(path), null, { path: String, uri: Uri ->
+ setResult(Activity.RESULT_OK, intent)
+ finish()
+ })
+ } else if (uri.scheme == "content") {
+
+ } else {
+ toast(R.string.unknown_file_location)
finish()
- })
+ }
} else {
toast("${getString(R.string.image_croping_failed)} ${result.error.message}")
}
diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml
index b974f4f72..5c84e553e 100644
--- a/app/src/main/res/values-de/strings.xml
+++ b/app/src/main/res/values-de/strings.xml
@@ -52,6 +52,7 @@
Image editing failed
Edit image with:
No image editor found
+ Unknown file location
Über
diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml
index 4c7932d59..e8ae1c246 100644
--- a/app/src/main/res/values-es/strings.xml
+++ b/app/src/main/res/values-es/strings.xml
@@ -52,6 +52,7 @@
Image editing failed
Edit image with:
No image editor found
+ Unknown file location
Acerca de
diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml
index 979dcc113..b8d900149 100644
--- a/app/src/main/res/values-it/strings.xml
+++ b/app/src/main/res/values-it/strings.xml
@@ -52,6 +52,7 @@
Image editing failed
Edit image with:
No image editor found
+ Unknown file location
Informazioni
diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml
index ed892d33a..1531c5dc7 100644
--- a/app/src/main/res/values-ja/strings.xml
+++ b/app/src/main/res/values-ja/strings.xml
@@ -52,6 +52,7 @@
Image editing failed
Edit image with:
No image editor found
+ Unknown file location
アプリについて
diff --git a/app/src/main/res/values-pt-rPT/strings.xml b/app/src/main/res/values-pt-rPT/strings.xml
index 12c26f151..a98944baa 100644
--- a/app/src/main/res/values-pt-rPT/strings.xml
+++ b/app/src/main/res/values-pt-rPT/strings.xml
@@ -52,6 +52,7 @@
Image editing failed
Edit image with:
No image editor found
+ Unknown file location
Sobre
diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml
index fee317844..dd7dee951 100644
--- a/app/src/main/res/values-sv/strings.xml
+++ b/app/src/main/res/values-sv/strings.xml
@@ -52,6 +52,7 @@
Image editing failed
Edit image with:
No image editor found
+ Unknown file location
Om
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index acfb84816..f378b8529 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -52,6 +52,7 @@
Image editing failed
Edit image with:
No image editor found
+ Unknown file location
About