mirror of
https://github.com/SimpleMobileTools/Simple-Flashlight.git
synced 2025-02-21 14:20:51 +01:00
Merge pull request #200 from Dejvino/bugfix/159
Fix #159: Button remains in pressed state if you turn screen lock on/off
This commit is contained in:
commit
6a351fe3c5
@ -194,6 +194,7 @@ class MainActivity : SimpleActivity() {
|
||||
private fun setupCameraImpl() {
|
||||
mCameraImpl = MyCameraImpl.newInstance(this, object : CameraTorchListener {
|
||||
override fun onTorchEnabled(isEnabled: Boolean) {
|
||||
mCameraImpl!!.onTorchEnabled(isEnabled)
|
||||
if (mCameraImpl!!.supportsBrightnessControl()) {
|
||||
brightness_bar.beVisibleIf(isEnabled)
|
||||
}
|
||||
|
@ -182,6 +182,15 @@ class MyCameraImpl private constructor(val context: Context, private var cameraT
|
||||
stateChanged(false)
|
||||
}
|
||||
|
||||
fun onTorchEnabled(isEnabled: Boolean) {
|
||||
if (isStroboscopeRunning || isSOSRunning) {
|
||||
return
|
||||
}
|
||||
if (isFlashlightOn != isEnabled) {
|
||||
stateChanged(isEnabled)
|
||||
}
|
||||
}
|
||||
|
||||
private fun stateChanged(isEnabled: Boolean) {
|
||||
isFlashlightOn = isEnabled
|
||||
EventBus.getDefault().post(Events.StateChanged(isEnabled))
|
||||
|
Loading…
x
Reference in New Issue
Block a user