diff --git a/app/build.gradle b/app/build.gradle index 0288c3fd..c50f58bf 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -63,7 +63,7 @@ android { } dependencies { - implementation 'com.github.SimpleMobileTools:Simple-Commons:e7d5ba6864' + implementation 'com.github.SimpleMobileTools:Simple-Commons:fad9b2cdb0' implementation 'androidx.documentfile:documentfile:1.0.1' implementation "androidx.exifinterface:exifinterface:1.3.5" implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.5.1" diff --git a/app/src/main/kotlin/com/simplemobiletools/camera/helpers/MediaActionSound.kt b/app/src/main/kotlin/com/simplemobiletools/camera/helpers/MediaActionSound.kt index ad0836d3..94d8aefe 100644 --- a/app/src/main/kotlin/com/simplemobiletools/camera/helpers/MediaActionSound.kt +++ b/app/src/main/kotlin/com/simplemobiletools/camera/helpers/MediaActionSound.kt @@ -82,6 +82,7 @@ class MediaActionSound(private val context: Context) { soundToBePlayed = sound sound.state = STATE_LOADED } + else -> Log.e(TAG, "OnLoadCompleteListener() called in wrong state: ${sound.state} for sound: ${sound.mediaSound}") } } @@ -112,6 +113,7 @@ class MediaActionSound(private val context: Context) { break } } + is MediaSound.RawResSound -> { id = soundPool!!.load(context, sound.mediaSound.resId, 1) } @@ -127,7 +129,7 @@ class MediaActionSound(private val context: Context) { } fun load(mediaSound: MediaSound) { - val sound = sounds.first { it.mediaSound == mediaSound } + val sound = sounds.firstOrNull() { it.mediaSound == mediaSound } ?: return synchronized(sound) { when (sound.state) { STATE_NOT_LOADED -> { @@ -137,6 +139,7 @@ class MediaActionSound(private val context: Context) { } } } + else -> Log.e(TAG, "load() called in wrong state: $sound for sound: $mediaSound") } } @@ -161,10 +164,12 @@ class MediaActionSound(private val context: Context) { sound.state = STATE_LOADING_PLAY_REQUESTED } } + STATE_LOADING -> sound.state = STATE_LOADING_PLAY_REQUESTED STATE_LOADED -> { playWithSoundPool(sound) } + else -> Log.e(TAG, "play() called in wrong state: ${sound.state} for sound: $mediaSound") } } @@ -195,6 +200,7 @@ class MediaActionSound(private val context: Context) { STATE_LOADED -> { soundPool!!.stop(sound.streamId) } + else -> Log.w(TAG, "stop() should be called after sound is loaded for sound: $mediaSound") } } diff --git a/app/src/main/kotlin/com/simplemobiletools/camera/implementations/CameraXPreview.kt b/app/src/main/kotlin/com/simplemobiletools/camera/implementations/CameraXPreview.kt index b80cf496..b641097f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/camera/implementations/CameraXPreview.kt +++ b/app/src/main/kotlin/com/simplemobiletools/camera/implementations/CameraXPreview.kt @@ -463,14 +463,12 @@ class CameraXPreview( when (flashMode) { FLASH_MODE_OFF -> FLASH_MODE_ON FLASH_MODE_ON -> FLASH_MODE_AUTO - FLASH_MODE_AUTO -> FLASH_MODE_OFF - else -> throw IllegalArgumentException("Unknown mode: $flashMode") + else -> FLASH_MODE_OFF } } else { when (flashMode) { FLASH_MODE_OFF -> FLASH_MODE_ON - FLASH_MODE_ON -> FLASH_MODE_OFF - else -> throw IllegalArgumentException("Unknown mode: $flashMode") + else -> FLASH_MODE_OFF } } setFlashlightState(newFlashMode.toAppFlashMode())