mirror of
https://github.com/SimpleMobileTools/Simple-Flashlight.git
synced 2025-06-05 21:59:19 +02:00
Properly reflect flash state in main screen icons
This commit is contained in:
@ -394,20 +394,7 @@ class MainActivity : SimpleActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun checkState(isEnabled: Boolean) {
|
private fun checkState(isEnabled: Boolean) {
|
||||||
if (isEnabled) {
|
_flashlightOn.value = isEnabled
|
||||||
enableFlashlight()
|
|
||||||
} else {
|
|
||||||
disableFlashlight()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
fun enableFlashlight() {
|
|
||||||
_flashlightOn.value = true
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun disableFlashlight() {
|
|
||||||
_flashlightOn.value = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
@ -428,7 +415,7 @@ class MainActivity : SimpleActivity() {
|
|||||||
@Subscribe
|
@Subscribe
|
||||||
fun cameraUnavailable(event: Events.CameraUnavailable) {
|
fun cameraUnavailable(event: Events.CameraUnavailable) {
|
||||||
getApplication<Application>().toast(R.string.camera_error)
|
getApplication<Application>().toast(R.string.camera_error)
|
||||||
disableFlashlight()
|
_flashlightOn.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCleared() {
|
override fun onCleared() {
|
||||||
|
@ -276,8 +276,10 @@ class MyCameraImpl private constructor(val context: Context, private var cameraT
|
|||||||
shouldStroboscopeStop = false
|
shouldStroboscopeStop = false
|
||||||
if (isStroboSOS) {
|
if (isStroboSOS) {
|
||||||
isSOSRunning = false
|
isSOSRunning = false
|
||||||
|
EventBus.getDefault().post(Events.StopSOS())
|
||||||
} else {
|
} else {
|
||||||
isStroboscopeRunning = false
|
isStroboscopeRunning = false
|
||||||
|
EventBus.getDefault().post(Events.StopStroboscope())
|
||||||
}
|
}
|
||||||
|
|
||||||
when {
|
when {
|
||||||
|
Reference in New Issue
Block a user