Skip to content
Snippets Groups Projects
Unverified Commit 12e89f68 authored by harambasicluka's avatar harambasicluka Committed by GitHub
Browse files

Fix: Tracing clickable row switch (#787)

* added isEnabled logic like it's on the switch

* changed comment

* exchanged formatter
parent ebc75599
No related branches found
No related tags found
No related merge requests found
......@@ -21,6 +21,7 @@ import de.rki.coronawarnapp.ui.viewmodel.SettingsViewModel
import de.rki.coronawarnapp.ui.viewmodel.TracingViewModel
import de.rki.coronawarnapp.util.DialogHelper
import de.rki.coronawarnapp.util.ExternalActionHelper
import de.rki.coronawarnapp.util.formatter.formatTracingSwitchEnabled
import de.rki.coronawarnapp.worker.BackgroundWorkScheduler
import kotlinx.coroutines.launch
......@@ -102,9 +103,20 @@ class SettingsTracingFragment : Fragment(),
switch.setOnClickListener {
startStopTracing()
}
// Additional click target to toggle switch
row.setOnClickListener {
if (row.isEnabled) startStopTracing()
val isTracingEnabled =
tracingViewModel.isTracingEnabled.value ?: throw IllegalArgumentException()
val isBluetoothEnabled =
settingsViewModel.isBluetoothEnabled.value ?: throw IllegalArgumentException()
val isConnectionEnabled =
settingsViewModel.isConnectionEnabled.value ?: throw IllegalArgumentException()
// check if the row is clickable, this adds the switch behaviour
val isEnabled = formatTracingSwitchEnabled(
isTracingEnabled,
isBluetoothEnabled,
isConnectionEnabled
)
if (isEnabled) startStopTracing()
}
back.setOnClickListener {
(activity as MainActivity).goBack()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment