From c433c897b5cb6d16a1c61e0ff0022ab1c2257c6c Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 5 Oct 2016 23:36:53 +0200 Subject: [PATCH] finish the Edit activity if the image uri is invalid --- .../simplemobiletools/gallery/activities/EditActivity.kt | 7 +++++++ .../com/simplemobiletools/gallery/extensions/context.kt | 2 ++ app/src/main/res/values-de/strings.xml | 1 + app/src/main/res/values-es/strings.xml | 1 + app/src/main/res/values-it/strings.xml | 1 + app/src/main/res/values-ja/strings.xml | 1 + app/src/main/res/values-pt-rPT/strings.xml | 1 + app/src/main/res/values-sv/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 9 files changed, 16 insertions(+) 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 b167bc5a8..4269939bc 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt @@ -13,9 +13,16 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener super.onCreate(savedInstanceState) setContentView(R.layout.activity_edit) + if (intent.data == null) { + toast(R.string.invalid_image_path) + finish() + return + } + crop_image_view.apply { guidelines = CropImageView.Guidelines.OFF setOnCropImageCompleteListener(this@EditActivity) + setImageUriAsync(intent.data) } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt index bb8f3a1c8..75bd2003a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt @@ -4,3 +4,5 @@ import android.content.Context import android.widget.Toast fun Context.toast(msg: String, duration: Int = Toast.LENGTH_SHORT) = Toast.makeText(this, msg, duration).show() + +fun Context.toast(msgId: Int, duration: Int = Toast.LENGTH_SHORT) = Toast.makeText(this, resources.getString(msgId), duration).show() diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 8b1554215..caa1ee787 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -48,6 +48,7 @@ Save Rotate Image croping failed: + Invalid image path Über diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 7da7d72cc..b3c91e7e6 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -48,6 +48,7 @@ Save Rotate Image croping failed: + Invalid image path Acerca de diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index b048b0a62..21ce2b558 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -48,6 +48,7 @@ Save Rotate Image croping failed: + Invalid image path Informazioni diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 42371fa25..7e9d0c386 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -48,6 +48,7 @@ Save Rotate Image croping failed: + Invalid image path アプリについて diff --git a/app/src/main/res/values-pt-rPT/strings.xml b/app/src/main/res/values-pt-rPT/strings.xml index bd79c7d3f..f24b1d1c2 100644 --- a/app/src/main/res/values-pt-rPT/strings.xml +++ b/app/src/main/res/values-pt-rPT/strings.xml @@ -48,6 +48,7 @@ Save Rotate Image croping failed: + Invalid image path Sobre diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index a0aa69a99..c3255af01 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -48,6 +48,7 @@ Save Rotate Image croping failed: + Invalid image path Om diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0541916b6..074a9670f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -48,6 +48,7 @@ Save Rotate Image croping failed: + Invalid image path About