From 048dbffd036811588cd20cdb4af6913474261933 Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 16 Jun 2017 21:52:55 +0200 Subject: [PATCH] let the user know if the photo wasnt saved because he quit too early --- .../com/simplemobiletools/camera/Preview.kt | 20 +++++++++++-------- .../camera/activities/MainActivity.kt | 4 ++++ 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-lt/strings.xml | 1 + app/src/main/res/values-nl/strings.xml | 1 + app/src/main/res/values-pt-rBR/strings.xml | 1 + app/src/main/res/values-pt/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/strings.xml | 1 + 14 files changed, 28 insertions(+), 8 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/camera/Preview.kt b/app/src/main/kotlin/com/simplemobiletools/camera/Preview.kt index d451068f..78d52123 100644 --- a/app/src/main/kotlin/com/simplemobiletools/camera/Preview.kt +++ b/app/src/main/kotlin/com/simplemobiletools/camera/Preview.kt @@ -61,6 +61,8 @@ class Preview : ViewGroup, SurfaceHolder.Callback, MediaScannerConnection.OnScan private var mIsFocusing = false private var autoFocusHandler = Handler() + var isWaitingForTakePictureCallback = false + constructor(context: Context) : super(context) constructor(activity: MainActivity, surfaceView: SurfaceView, previewListener: PreviewListener) : super(activity) { @@ -275,6 +277,15 @@ class Preview : ViewGroup, SurfaceHolder.Callback, MediaScannerConnection.OnScan val selectedResolution = getSelectedResolution() mParameters!!.setPictureSize(selectedResolution.width, selectedResolution.height); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { + mCamera!!.enableShutterSound(false) + } + + mRotationAtCapture = MainActivity.mLastHandledOrientation + mCamera!!.parameters = mParameters + isWaitingForTakePictureCallback = true + mCamera!!.takePicture(null, null, takePictureCallback) + if (config.isSoundEnabled) { val audioManager = context.getSystemService(Context.AUDIO_SERVICE) as AudioManager val volume = audioManager.getStreamVolume(AudioManager.STREAM_SYSTEM) @@ -283,20 +294,13 @@ class Preview : ViewGroup, SurfaceHolder.Callback, MediaScannerConnection.OnScan mp?.start() } } - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { - mCamera!!.enableShutterSound(false) - } - - mRotationAtCapture = MainActivity.mLastHandledOrientation - mCamera!!.parameters = mParameters - mCamera!!.takePicture(null, null, takePictureCallback) } mCanTakePicture = false mIsFocusing = false } private val takePictureCallback = Camera.PictureCallback { data, cam -> + isWaitingForTakePictureCallback = false if (config.isShowPreviewEnabled) { mIsPreviewShown = true if (!config.wasPhotoPreviewHintShown) { diff --git a/app/src/main/kotlin/com/simplemobiletools/camera/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/camera/activities/MainActivity.kt index 4d194b56..86013d89 100644 --- a/app/src/main/kotlin/com/simplemobiletools/camera/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/camera/activities/MainActivity.kt @@ -501,6 +501,10 @@ class MainActivity : SimpleActivity(), PreviewListener, PhotoProcessor.MediaSave hideTimer() mPreview?.releaseCamera() mOrientationEventListener.disable() + + if (mPreview?.isWaitingForTakePictureCallback == true) { + toast(R.string.photo_not_saved) + } } private fun setupOrientationEventListener() { diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 656b52da..ea32b081 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -13,6 +13,7 @@ Wir benötigen Zugriff auf das Mirkofon um Videos aufnehmen zu können Keine Galerie App verfügbar Click on the image to resume preview + The photo could not be saved other diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 03c50b3f..d90a180a 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -13,6 +13,7 @@ Se necesita el permiso de micrófono para grabar vídeos No hay disponible una aplicación de galería Haga clic en la imagen para reanudar la vista previa + The photo could not be saved otro diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index f8da37d8..80e53999 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -13,6 +13,7 @@ Nous avons besoin de l\'autorisation sur l\'audio pour enregistrer des vidéos Pas d\'application album disponible Click on the image to resume preview + The photo could not be saved other diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index baee1e82..23d0bcbb 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -13,6 +13,7 @@ È necessario l\'accesso al microfono per registrare i video Nessuna app galleria disponibile Click on the image to resume preview + The photo could not be saved other diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 9452da09..8c4b3d69 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -13,6 +13,7 @@ ビデオを記録するためにオーディオのアクセス許可が必要です 利用可能なギャラリーアプリがありません Click on the image to resume preview + The photo could not be saved other diff --git a/app/src/main/res/values-lt/strings.xml b/app/src/main/res/values-lt/strings.xml index ff221c56..9713a228 100644 --- a/app/src/main/res/values-lt/strings.xml +++ b/app/src/main/res/values-lt/strings.xml @@ -13,6 +13,7 @@ Mums reikia audio leidimo, kad įrašyti vaizdo bylas Nėra galerijos programėlės Click on the image to resume preview + The photo could not be saved other diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index a996ed51..7323ecf5 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -14,6 +14,7 @@ Toestemming voor audio nodig is voor het opnemen van video\'s Geen gallery app beschikbaar Click on the image to resume preview + The photo could not be saved Ander diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index 9d9a1677..93e17732 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -13,6 +13,7 @@ Necessitamos da permissão de áudio para gravar os vídeos Nenhum aplicativo de galeria disponível Click on the image to resume preview + The photo could not be saved outra diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index 0616bf01..45e1e022 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -13,6 +13,7 @@ Necessitamos da permissão de áudio para gravar os vídeos Nenhuma aplicação de galeria disponível Clique na imagem para continuar com a pré-visualização + The photo could not be saved outra diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index fcca736e..170b927c 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -13,6 +13,7 @@ Нам нужно аудио разрешение для записи видео Нет доступного приложения-галереи Click on the image to resume preview + The photo could not be saved другое diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index 304fa261..a9b31912 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -13,6 +13,7 @@ För att spela in video krävs ljudrättigheter Ingen galleri-app finns tillgänglig Click on the image to resume preview + The photo could not be saved other diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4b4b4847..4298274d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -13,6 +13,7 @@ We need audio permission for recording videos No gallery app available Click on the image to resume preview + The photo could not be saved other