Merge pull request #368 from KryptKode/feat/persist-torch-state
persist torch state for video and image capture
This commit is contained in:
commit
25b7521b46
|
@ -40,11 +40,11 @@ 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 java.util.concurrent.TimeUnit
|
||||||
|
import kotlin.math.abs
|
||||||
import kotlinx.android.synthetic.main.activity_main.*
|
import kotlinx.android.synthetic.main.activity_main.*
|
||||||
import kotlinx.android.synthetic.main.layout_flash.*
|
import kotlinx.android.synthetic.main.layout_flash.*
|
||||||
import kotlinx.android.synthetic.main.layout_top.*
|
import kotlinx.android.synthetic.main.layout_top.*
|
||||||
import java.util.concurrent.TimeUnit
|
|
||||||
import kotlin.math.abs
|
|
||||||
|
|
||||||
class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, CameraXPreviewListener {
|
class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, CameraXPreviewListener {
|
||||||
private companion object {
|
private companion object {
|
||||||
|
@ -345,10 +345,6 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
|
||||||
|
|
||||||
mTimerHandler = Handler(Looper.getMainLooper())
|
mTimerHandler = Handler(Looper.getMainLooper())
|
||||||
setupPreviewImage(true)
|
setupPreviewImage(true)
|
||||||
|
|
||||||
val initialFlashlightState = if (mIsInPhotoMode && config.flashlightState != FLASH_ALWAYS_ON) config.flashlightState else FLASH_OFF
|
|
||||||
mPreview!!.setFlashlightState(initialFlashlightState)
|
|
||||||
updateFlashlightState(initialFlashlightState)
|
|
||||||
initFlashModeTransitionNames()
|
initFlashModeTransitionNames()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -453,18 +449,6 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateFlashlightState(state: Int) {
|
|
||||||
config.flashlightState = state
|
|
||||||
val flashDrawable = when (state) {
|
|
||||||
FLASH_OFF -> R.drawable.ic_flash_off_vector
|
|
||||||
FLASH_ON -> R.drawable.ic_flash_on_vector
|
|
||||||
FLASH_AUTO -> R.drawable.ic_flash_auto_vector
|
|
||||||
else -> R.drawable.ic_flashlight_vector
|
|
||||||
}
|
|
||||||
toggle_flash.setShadowIcon(flashDrawable)
|
|
||||||
toggle_flash.transitionName = "${getString(R.string.toggle_flash)}$state"
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun shutterPressed() {
|
private fun shutterPressed() {
|
||||||
if (checkCameraAvailable()) {
|
if (checkCameraAvailable()) {
|
||||||
handleShutter()
|
handleShutter()
|
||||||
|
@ -727,7 +711,14 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onChangeFlashMode(flashMode: Int) {
|
override fun onChangeFlashMode(flashMode: Int) {
|
||||||
updateFlashlightState(flashMode)
|
val flashDrawable = when (flashMode) {
|
||||||
|
FLASH_OFF -> R.drawable.ic_flash_off_vector
|
||||||
|
FLASH_ON -> R.drawable.ic_flash_on_vector
|
||||||
|
FLASH_AUTO -> R.drawable.ic_flash_auto_vector
|
||||||
|
else -> R.drawable.ic_flashlight_vector
|
||||||
|
}
|
||||||
|
toggle_flash.setShadowIcon(flashDrawable)
|
||||||
|
toggle_flash.transitionName = "${getString(R.string.toggle_flash)}$flashMode"
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onVideoRecordingStarted() {
|
override fun onVideoRecordingStarted() {
|
||||||
|
|
|
@ -175,6 +175,7 @@ class CameraXPreview(
|
||||||
previewUseCase.setSurfaceProvider(previewView.surfaceProvider)
|
previewUseCase.setSurfaceProvider(previewView.surfaceProvider)
|
||||||
preview = previewUseCase
|
preview = previewUseCase
|
||||||
setupZoomAndFocus()
|
setupZoomAndFocus()
|
||||||
|
setFlashlightState(config.flashlightState)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun displaySelectedResolution(resolutionOption: ResolutionOption) {
|
private fun displaySelectedResolution(resolutionOption: ResolutionOption) {
|
||||||
|
|
Loading…
Reference in New Issue