fix toggling between SOS and stroboscope with 1 click

This commit is contained in:
tibbi 2022-07-10 10:56:28 +02:00
parent 21500dc9fe
commit 8b283a9b21
2 changed files with 12 additions and 8 deletions

View File

@ -76,7 +76,11 @@ class MainActivity : SimpleActivity() {
changeIconColor(contrastColor, bright_display_btn) changeIconColor(contrastColor, bright_display_btn)
bright_display_btn.beVisibleIf(config.brightDisplay) bright_display_btn.beVisibleIf(config.brightDisplay)
sos_btn.beVisibleIf(config.sos) sos_btn.beVisibleIf(config.sos)
if (sos_btn.currentTextColor != getProperPrimaryColor()) {
sos_btn.setTextColor(contrastColor) sos_btn.setTextColor(contrastColor)
}
stroboscope_btn.beVisibleIf(config.stroboscope) stroboscope_btn.beVisibleIf(config.stroboscope)
if (!config.stroboscope) { if (!config.stroboscope) {
@ -214,13 +218,11 @@ class MainActivity : SimpleActivity() {
if (isSOS) { if (isSOS) {
val isSOSRunning = mCameraImpl!!.toggleSOS() val isSOSRunning = mCameraImpl!!.toggleSOS()
sos_btn.setTextColor(if (isSOSRunning) getProperPrimaryColor() else getContrastColor()) sos_btn.setTextColor(if (isSOSRunning) getProperPrimaryColor() else getContrastColor())
} else { } else if (mCameraImpl!!.toggleStroboscope()) {
if (mCameraImpl!!.toggleStroboscope()) {
stroboscope_bar.beInvisibleIf(stroboscope_bar.isVisible()) stroboscope_bar.beInvisibleIf(stroboscope_bar.isVisible())
changeIconColor(if (stroboscope_bar.isVisible()) getProperPrimaryColor() else getContrastColor(), stroboscope_btn) changeIconColor(if (stroboscope_bar.isVisible()) getProperPrimaryColor() else getContrastColor(), stroboscope_btn)
} }
} }
}
private fun getContrastColor() = getProperBackgroundColor().getContrastColor() private fun getContrastColor() = getProperBackgroundColor().getContrastColor()

View File

@ -55,7 +55,8 @@ class MyCameraImpl(val context: Context) {
fun toggleStroboscope(): Boolean { fun toggleStroboscope(): Boolean {
if (isSOSRunning) { if (isSOSRunning) {
stopSOS() stopSOS()
return false toggleStroboscope()
return true
} }
isStroboSOS = false isStroboSOS = false
@ -84,7 +85,8 @@ class MyCameraImpl(val context: Context) {
fun toggleSOS(): Boolean { fun toggleSOS(): Boolean {
if (isStroboscopeRunning) { if (isStroboscopeRunning) {
stopStroboscope() stopStroboscope()
return false toggleSOS()
return true
} }
isStroboSOS = true isStroboSOS = true