check if a Camera app is available before trying to launch it
This commit is contained in:
parent
0f0b3cfc30
commit
9a7361795f
|
@ -6,6 +6,8 @@ import android.database.Cursor
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.provider.MediaStore
|
import android.provider.MediaStore
|
||||||
import com.simplemobiletools.commons.extensions.humanizePath
|
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.activities.SettingsActivity
|
||||||
import com.simplemobiletools.gallery.helpers.Config
|
import com.simplemobiletools.gallery.helpers.Config
|
||||||
import com.simplemobiletools.gallery.helpers.IMAGES
|
import com.simplemobiletools.gallery.helpers.IMAGES
|
||||||
|
@ -13,6 +15,7 @@ import com.simplemobiletools.gallery.helpers.VIDEOS
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
|
|
||||||
fun Context.getRealPathFromURI(uri: Uri): String? {
|
fun Context.getRealPathFromURI(uri: Uri): String? {
|
||||||
var cursor: Cursor? = null
|
var cursor: Cursor? = null
|
||||||
try {
|
try {
|
||||||
|
@ -35,7 +38,12 @@ fun Context.getHumanizedFilename(path: String): String {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Context.launchCamera() {
|
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() {
|
fun Context.launchSettings() {
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
<string name="show_on_map">Show on map</string>
|
<string name="show_on_map">Show on map</string>
|
||||||
<string name="unknown_location">Unknown location</string>
|
<string name="unknown_location">Unknown location</string>
|
||||||
<string name="no_map_application">No application with maps has been found</string>
|
<string name="no_map_application">No application with maps has been found</string>
|
||||||
|
<string name="no_camera_app_found">No Camera app has been found</string>
|
||||||
|
|
||||||
<!-- Resizing -->
|
<!-- Resizing -->
|
||||||
<string name="resize">Größe ändern</string>
|
<string name="resize">Größe ändern</string>
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
<string name="show_on_map">Show on map</string>
|
<string name="show_on_map">Show on map</string>
|
||||||
<string name="unknown_location">Unknown location</string>
|
<string name="unknown_location">Unknown location</string>
|
||||||
<string name="no_map_application">No application with maps has been found</string>
|
<string name="no_map_application">No application with maps has been found</string>
|
||||||
|
<string name="no_camera_app_found">No Camera app has been found</string>
|
||||||
|
|
||||||
<!-- Resizing -->
|
<!-- Resizing -->
|
||||||
<string name="resize">Resize</string>
|
<string name="resize">Resize</string>
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
<string name="show_on_map">Show on map</string>
|
<string name="show_on_map">Show on map</string>
|
||||||
<string name="unknown_location">Unknown location</string>
|
<string name="unknown_location">Unknown location</string>
|
||||||
<string name="no_map_application">No application with maps has been found</string>
|
<string name="no_map_application">No application with maps has been found</string>
|
||||||
|
<string name="no_camera_app_found">No Camera app has been found</string>
|
||||||
|
|
||||||
<!-- Resizing -->
|
<!-- Resizing -->
|
||||||
<string name="resize">Redimensionner</string>
|
<string name="resize">Redimensionner</string>
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
<string name="show_on_map">Show on map</string>
|
<string name="show_on_map">Show on map</string>
|
||||||
<string name="unknown_location">Unknown location</string>
|
<string name="unknown_location">Unknown location</string>
|
||||||
<string name="no_map_application">No application with maps has been found</string>
|
<string name="no_map_application">No application with maps has been found</string>
|
||||||
|
<string name="no_camera_app_found">No Camera app has been found</string>
|
||||||
|
|
||||||
<!-- Resizing -->
|
<!-- Resizing -->
|
||||||
<string name="resize">Resize</string>
|
<string name="resize">Resize</string>
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
<string name="show_on_map">Show on map</string>
|
<string name="show_on_map">Show on map</string>
|
||||||
<string name="unknown_location">Unknown location</string>
|
<string name="unknown_location">Unknown location</string>
|
||||||
<string name="no_map_application">No application with maps has been found</string>
|
<string name="no_map_application">No application with maps has been found</string>
|
||||||
|
<string name="no_camera_app_found">No Camera app has been found</string>
|
||||||
|
|
||||||
<!-- Resizing -->
|
<!-- Resizing -->
|
||||||
<string name="resize">Resize</string>
|
<string name="resize">Resize</string>
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
<string name="show_on_map">Mostrar no mapa</string>
|
<string name="show_on_map">Mostrar no mapa</string>
|
||||||
<string name="unknown_location">Localização desconhecida</string>
|
<string name="unknown_location">Localização desconhecida</string>
|
||||||
<string name="no_map_application">Não existe uma aplicação adequada</string>
|
<string name="no_map_application">Não existe uma aplicação adequada</string>
|
||||||
|
<string name="no_camera_app_found">No Camera app has been found</string>
|
||||||
|
|
||||||
<!-- Resizing -->
|
<!-- Resizing -->
|
||||||
<string name="resize">Redimensionar</string>
|
<string name="resize">Redimensionar</string>
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
<string name="show_on_map">Показать место съёмки</string>
|
<string name="show_on_map">Показать место съёмки</string>
|
||||||
<string name="unknown_location">Место съёмки не указано</string>
|
<string name="unknown_location">Место съёмки не указано</string>
|
||||||
<string name="no_map_application">Не найдено приложений с картами</string>
|
<string name="no_map_application">Не найдено приложений с картами</string>
|
||||||
|
<string name="no_camera_app_found">No Camera app has been found</string>
|
||||||
|
|
||||||
<!-- Resizing -->
|
<!-- Resizing -->
|
||||||
<string name="resize">Изменить размер</string>
|
<string name="resize">Изменить размер</string>
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
<string name="show_on_map">Show on map</string>
|
<string name="show_on_map">Show on map</string>
|
||||||
<string name="unknown_location">Unknown location</string>
|
<string name="unknown_location">Unknown location</string>
|
||||||
<string name="no_map_application">No application with maps has been found</string>
|
<string name="no_map_application">No application with maps has been found</string>
|
||||||
|
<string name="no_camera_app_found">No Camera app has been found</string>
|
||||||
|
|
||||||
<!-- Resizing -->
|
<!-- Resizing -->
|
||||||
<string name="resize">Ändra storlek</string>
|
<string name="resize">Ändra storlek</string>
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
<string name="show_on_map">Show on map</string>
|
<string name="show_on_map">Show on map</string>
|
||||||
<string name="unknown_location">Unknown location</string>
|
<string name="unknown_location">Unknown location</string>
|
||||||
<string name="no_map_application">No application with maps has been found</string>
|
<string name="no_map_application">No application with maps has been found</string>
|
||||||
|
<string name="no_camera_app_found">No Camera app has been found</string>
|
||||||
|
|
||||||
<!-- Resizing -->
|
<!-- Resizing -->
|
||||||
<string name="resize">缩放</string>
|
<string name="resize">缩放</string>
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
<string name="show_on_map">Show on map</string>
|
<string name="show_on_map">Show on map</string>
|
||||||
<string name="unknown_location">Unknown location</string>
|
<string name="unknown_location">Unknown location</string>
|
||||||
<string name="no_map_application">No application with maps has been found</string>
|
<string name="no_map_application">No application with maps has been found</string>
|
||||||
|
<string name="no_camera_app_found">No Camera app has been found</string>
|
||||||
|
|
||||||
<!-- Resizing -->
|
<!-- Resizing -->
|
||||||
<string name="resize">縮放</string>
|
<string name="resize">縮放</string>
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
<string name="show_on_map">Show on map</string>
|
<string name="show_on_map">Show on map</string>
|
||||||
<string name="unknown_location">Unknown location</string>
|
<string name="unknown_location">Unknown location</string>
|
||||||
<string name="no_map_application">No application with maps has been found</string>
|
<string name="no_map_application">No application with maps has been found</string>
|
||||||
|
<string name="no_camera_app_found">No Camera app has been found</string>
|
||||||
|
|
||||||
<!-- Resizing -->
|
<!-- Resizing -->
|
||||||
<string name="resize">Resize</string>
|
<string name="resize">Resize</string>
|
||||||
|
|
Loading…
Reference in New Issue