From 9a7361795f1ad1994dd1f692f66e08ee97074c24 Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 7 Feb 2017 00:08:32 +0100 Subject: [PATCH] check if a Camera app is available before trying to launch it --- .../simplemobiletools/gallery/extensions/context.kt | 10 +++++++++- app/src/main/res/values-de/strings.xml | 1 + app/src/main/res/values-es/strings.xml | 1 + app/src/main/res/values-fr/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-ru/strings.xml | 1 + app/src/main/res/values-sv/strings.xml | 1 + app/src/main/res/values-zh-rCN/strings.xml | 1 + app/src/main/res/values-zh-rTW/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 12 files changed, 20 insertions(+), 1 deletion(-) 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 3f063037c..4d1e74d41 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt @@ -6,6 +6,8 @@ import android.database.Cursor import android.net.Uri import android.provider.MediaStore import com.simplemobiletools.commons.extensions.humanizePath +import com.simplemobiletools.commons.extensions.toast +import com.simplemobiletools.gallery.R import com.simplemobiletools.gallery.activities.SettingsActivity import com.simplemobiletools.gallery.helpers.Config import com.simplemobiletools.gallery.helpers.IMAGES @@ -13,6 +15,7 @@ import com.simplemobiletools.gallery.helpers.VIDEOS import java.io.File import java.util.* + fun Context.getRealPathFromURI(uri: Uri): String? { var cursor: Cursor? = null try { @@ -35,7 +38,12 @@ fun Context.getHumanizedFilename(path: String): String { } fun Context.launchCamera() { - startActivity(Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA)) + val intent = Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA) + if (intent.resolveActivity(packageManager) != null) { + startActivity(intent) + } else { + toast(R.string.no_camera_app_found) + } } fun Context.launchSettings() { diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index db717befb..7c5d7350a 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -22,6 +22,7 @@ Show on map Unknown location No application with maps has been found + No Camera app has been found Größe ändern diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 3c6f8907e..b1ddb4c6a 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -22,6 +22,7 @@ Show on map Unknown location No application with maps has been found + No Camera app has been found Resize diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 72c7e751c..0cdb0504b 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -22,6 +22,7 @@ Show on map Unknown location No application with maps has been found + No Camera app has been found Redimensionner diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index a2273acc8..5633e05b2 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -22,6 +22,7 @@ Show on map Unknown location No application with maps has been found + No Camera app has been found Resize diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 3d357272b..76b2b3bc9 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -22,6 +22,7 @@ Show on map Unknown location No application with maps has been found + No Camera app has been found Resize diff --git a/app/src/main/res/values-pt-rPT/strings.xml b/app/src/main/res/values-pt-rPT/strings.xml index 78e963da7..01af8b4d2 100644 --- a/app/src/main/res/values-pt-rPT/strings.xml +++ b/app/src/main/res/values-pt-rPT/strings.xml @@ -22,6 +22,7 @@ Mostrar no mapa Localização desconhecida Não existe uma aplicação adequada + No Camera app has been found Redimensionar diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 89f0655a2..666e9d98f 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -22,6 +22,7 @@ Показать место съёмки Место съёмки не указано Не найдено приложений с картами + No Camera app has been found Изменить размер diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index ec6b740a6..5f3ba5e3f 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -22,6 +22,7 @@ Show on map Unknown location No application with maps has been found + No Camera app has been found Ändra storlek diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 0504b1cd8..5c4dbe7b5 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -22,6 +22,7 @@ Show on map Unknown location No application with maps has been found + No Camera app has been found 缩放 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index edad80f2b..0deab6fef 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -22,6 +22,7 @@ Show on map Unknown location No application with maps has been found + No Camera app has been found 縮放 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6a1aa6e00..f799c6dc5 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -22,6 +22,7 @@ Show on map Unknown location No application with maps has been found + No Camera app has been found Resize