Skip to content

Commit 048dbff

Browse files
committed
let the user know if the photo wasnt saved because he quit too early
1 parent 811cfbf commit 048dbff

14 files changed

Lines changed: 28 additions & 8 deletions

File tree

app/src/main/kotlin/com/simplemobiletools/camera/Preview.kt

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ class Preview : ViewGroup, SurfaceHolder.Callback, MediaScannerConnection.OnScan
6161
private var mIsFocusing = false
6262
private var autoFocusHandler = Handler()
6363

64+
var isWaitingForTakePictureCallback = false
65+
6466
constructor(context: Context) : super(context)
6567

6668
constructor(activity: MainActivity, surfaceView: SurfaceView, previewListener: PreviewListener) : super(activity) {
@@ -275,6 +277,15 @@ class Preview : ViewGroup, SurfaceHolder.Callback, MediaScannerConnection.OnScan
275277
val selectedResolution = getSelectedResolution()
276278
mParameters!!.setPictureSize(selectedResolution.width, selectedResolution.height);
277279

280+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
281+
mCamera!!.enableShutterSound(false)
282+
}
283+
284+
mRotationAtCapture = MainActivity.mLastHandledOrientation
285+
mCamera!!.parameters = mParameters
286+
isWaitingForTakePictureCallback = true
287+
mCamera!!.takePicture(null, null, takePictureCallback)
288+
278289
if (config.isSoundEnabled) {
279290
val audioManager = context.getSystemService(Context.AUDIO_SERVICE) as AudioManager
280291
val volume = audioManager.getStreamVolume(AudioManager.STREAM_SYSTEM)
@@ -283,20 +294,13 @@ class Preview : ViewGroup, SurfaceHolder.Callback, MediaScannerConnection.OnScan
283294
mp?.start()
284295
}
285296
}
286-
287-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
288-
mCamera!!.enableShutterSound(false)
289-
}
290-
291-
mRotationAtCapture = MainActivity.mLastHandledOrientation
292-
mCamera!!.parameters = mParameters
293-
mCamera!!.takePicture(null, null, takePictureCallback)
294297
}
295298
mCanTakePicture = false
296299
mIsFocusing = false
297300
}
298301

299302
private val takePictureCallback = Camera.PictureCallback { data, cam ->
303+
isWaitingForTakePictureCallback = false
300304
if (config.isShowPreviewEnabled) {
301305
mIsPreviewShown = true
302306
if (!config.wasPhotoPreviewHintShown) {

app/src/main/kotlin/com/simplemobiletools/camera/activities/MainActivity.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,10 @@ class MainActivity : SimpleActivity(), PreviewListener, PhotoProcessor.MediaSave
501501
hideTimer()
502502
mPreview?.releaseCamera()
503503
mOrientationEventListener.disable()
504+
505+
if (mPreview?.isWaitingForTakePictureCallback == true) {
506+
toast(R.string.photo_not_saved)
507+
}
504508
}
505509

506510
private fun setupOrientationEventListener() {

app/src/main/res/values-de/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<string name="no_audio_permissions">Wir benötigen Zugriff auf das Mirkofon um Videos aufnehmen zu können</string>
1414
<string name="no_gallery_app_available">Keine Galerie App verfügbar</string>
1515
<string name="click_to_resume_preview">Click on the image to resume preview</string>
16+
<string name="photo_not_saved">The photo could not be saved</string>
1617

1718
<!-- other aspect ratio -->
1819
<string name="other">other</string>

app/src/main/res/values-es/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<string name="no_audio_permissions">Se necesita el permiso de micrófono para grabar vídeos</string>
1414
<string name="no_gallery_app_available">No hay disponible una aplicación de galería</string>
1515
<string name="click_to_resume_preview">Haga clic en la imagen para reanudar la vista previa</string>
16+
<string name="photo_not_saved">The photo could not be saved</string>
1617

1718
<!-- other aspect ratio -->
1819
<string name="other">otro</string>

app/src/main/res/values-fr/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<string name="no_audio_permissions">Nous avons besoin de l\'autorisation sur l\'audio pour enregistrer des vidéos</string>
1414
<string name="no_gallery_app_available">Pas d\'application album disponible</string>
1515
<string name="click_to_resume_preview">Click on the image to resume preview</string>
16+
<string name="photo_not_saved">The photo could not be saved</string>
1617

1718
<!-- other aspect ratio -->
1819
<string name="other">other</string>

app/src/main/res/values-it/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<string name="no_audio_permissions">È necessario l\'accesso al microfono per registrare i video</string>
1414
<string name="no_gallery_app_available">Nessuna app galleria disponibile</string>
1515
<string name="click_to_resume_preview">Click on the image to resume preview</string>
16+
<string name="photo_not_saved">The photo could not be saved</string>
1617

1718
<!-- other aspect ratio -->
1819
<string name="other">other</string>

app/src/main/res/values-ja/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<string name="no_audio_permissions">ビデオを記録するためにオーディオのアクセス許可が必要です</string>
1414
<string name="no_gallery_app_available">利用可能なギャラリーアプリがありません</string>
1515
<string name="click_to_resume_preview">Click on the image to resume preview</string>
16+
<string name="photo_not_saved">The photo could not be saved</string>
1617

1718
<!-- other aspect ratio -->
1819
<string name="other">other</string>

app/src/main/res/values-lt/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<string name="no_audio_permissions">Mums reikia audio leidimo, kad įrašyti vaizdo bylas</string>
1414
<string name="no_gallery_app_available">Nėra galerijos programėlės</string>
1515
<string name="click_to_resume_preview">Click on the image to resume preview</string>
16+
<string name="photo_not_saved">The photo could not be saved</string>
1617

1718
<!-- other aspect ratio -->
1819
<string name="other">other</string>

app/src/main/res/values-nl/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<string name="no_audio_permissions">Toestemming voor audio nodig is voor het opnemen van video\'s</string>
1515
<string name="no_gallery_app_available">Geen gallery app beschikbaar</string>
1616
<string name="click_to_resume_preview">Click on the image to resume preview</string>
17+
<string name="photo_not_saved">The photo could not be saved</string>
1718

1819
<!-- other aspect ratio -->
1920
<string name="other">Ander</string>

app/src/main/res/values-pt-rBR/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<string name="no_audio_permissions">Necessitamos da permissão de áudio para gravar os vídeos</string>
1414
<string name="no_gallery_app_available">Nenhum aplicativo de galeria disponível</string>
1515
<string name="click_to_resume_preview">Click on the image to resume preview</string>
16+
<string name="photo_not_saved">The photo could not be saved</string>
1617

1718
<!-- other aspect ratio -->
1819
<string name="other">outra</string>

0 commit comments

Comments
 (0)