From 8b283a9b213dc868fc963515edc6dd6fc224ddac Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 10 Jul 2022 10:56:28 +0200 Subject: [PATCH] fix toggling between SOS and stroboscope with 1 click --- .../flashlight/activities/MainActivity.kt | 14 ++++++++------ .../flashlight/helpers/MyCameraImpl.kt | 6 ++++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/flashlight/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/flashlight/activities/MainActivity.kt index 17017ee..1c2a942 100644 --- a/app/src/main/kotlin/com/simplemobiletools/flashlight/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/flashlight/activities/MainActivity.kt @@ -76,7 +76,11 @@ class MainActivity : SimpleActivity() { changeIconColor(contrastColor, bright_display_btn) bright_display_btn.beVisibleIf(config.brightDisplay) sos_btn.beVisibleIf(config.sos) - sos_btn.setTextColor(contrastColor) + + if (sos_btn.currentTextColor != getProperPrimaryColor()) { + sos_btn.setTextColor(contrastColor) + } + stroboscope_btn.beVisibleIf(config.stroboscope) if (!config.stroboscope) { @@ -214,11 +218,9 @@ class MainActivity : SimpleActivity() { if (isSOS) { val isSOSRunning = mCameraImpl!!.toggleSOS() sos_btn.setTextColor(if (isSOSRunning) getProperPrimaryColor() else getContrastColor()) - } else { - if (mCameraImpl!!.toggleStroboscope()) { - stroboscope_bar.beInvisibleIf(stroboscope_bar.isVisible()) - changeIconColor(if (stroboscope_bar.isVisible()) getProperPrimaryColor() else getContrastColor(), stroboscope_btn) - } + } else if (mCameraImpl!!.toggleStroboscope()) { + stroboscope_bar.beInvisibleIf(stroboscope_bar.isVisible()) + changeIconColor(if (stroboscope_bar.isVisible()) getProperPrimaryColor() else getContrastColor(), stroboscope_btn) } } diff --git a/app/src/main/kotlin/com/simplemobiletools/flashlight/helpers/MyCameraImpl.kt b/app/src/main/kotlin/com/simplemobiletools/flashlight/helpers/MyCameraImpl.kt index e69997d..79147ff 100644 --- a/app/src/main/kotlin/com/simplemobiletools/flashlight/helpers/MyCameraImpl.kt +++ b/app/src/main/kotlin/com/simplemobiletools/flashlight/helpers/MyCameraImpl.kt @@ -55,7 +55,8 @@ class MyCameraImpl(val context: Context) { fun toggleStroboscope(): Boolean { if (isSOSRunning) { stopSOS() - return false + toggleStroboscope() + return true } isStroboSOS = false @@ -84,7 +85,8 @@ class MyCameraImpl(val context: Context) { fun toggleSOS(): Boolean { if (isStroboscopeRunning) { stopStroboscope() - return false + toggleSOS() + return true } isStroboSOS = true