restore flash mode in photo mode

This commit is contained in:
darthpaul 2022-10-06 23:47:42 +01:00
parent 33e64f84a2
commit 1afd0f515c
1 changed files with 11 additions and 5 deletions

View File

@ -38,10 +38,16 @@ import com.simplemobiletools.camera.views.FocusCircleView
import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.* import com.simplemobiletools.commons.helpers.*
import com.simplemobiletools.commons.models.Release import com.simplemobiletools.commons.models.Release
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.layout_flash.*
import kotlinx.android.synthetic.main.layout_top.*
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.layout_flash.flash_auto
import kotlinx.android.synthetic.main.layout_flash.flash_off
import kotlinx.android.synthetic.main.layout_flash.flash_on
import kotlinx.android.synthetic.main.layout_flash.flash_toggle_group
import kotlinx.android.synthetic.main.layout_top.change_resolution
import kotlinx.android.synthetic.main.layout_top.default_icons
import kotlinx.android.synthetic.main.layout_top.settings
import kotlinx.android.synthetic.main.layout_top.toggle_flash
class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, CameraXPreviewListener { class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, CameraXPreviewListener {
private companion object { private companion object {
@ -342,7 +348,7 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
mTimerHandler = Handler(Looper.getMainLooper()) mTimerHandler = Handler(Looper.getMainLooper())
setupPreviewImage(true) setupPreviewImage(true)
val initialFlashlightState = FLASH_OFF val initialFlashlightState = if (mIsInPhotoMode) config.flashlightState else FLASH_OFF
mPreview!!.setFlashlightState(initialFlashlightState) mPreview!!.setFlashlightState(initialFlashlightState)
updateFlashlightState(initialFlashlightState) updateFlashlightState(initialFlashlightState)
initFlashModeTransitionNames() initFlashModeTransitionNames()
@ -395,7 +401,7 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
} }
} }
fun updateFlashlightState(state: Int) { private fun updateFlashlightState(state: Int) {
config.flashlightState = state config.flashlightState = state
val flashDrawable = when (state) { val flashDrawable = when (state) {
FLASH_OFF -> R.drawable.ic_flash_off_vector FLASH_OFF -> R.drawable.ic_flash_off_vector