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

Tracing start/stop fix due to missing handling inside tracing (#99)

parent d965427f
No related branches found
No related tags found
No related merge requests found
...@@ -89,27 +89,16 @@ class SettingsTracingFragment : BaseFragment(), ...@@ -89,27 +89,16 @@ class SettingsTracingFragment : BaseFragment(),
exception?.localizedMessage ?: "Unknown Error", exception?.localizedMessage ?: "Unknown Error",
Toast.LENGTH_SHORT Toast.LENGTH_SHORT
).show() ).show()
tracingViewModel.refreshIsTracingEnabled()
} }
private fun setButtonOnClickListener() { private fun setButtonOnClickListener() {
val switch = binding.settingsTracingSwitchRow.settingsSwitchRowSwitch val switch = binding.settingsTracingSwitchRow.settingsSwitchRowSwitch
val row = binding.settingsTracingSwitchRow.settingsSwitchRow
internalExposureNotificationPermissionHelper = internalExposureNotificationPermissionHelper =
InternalExposureNotificationPermissionHelper(this, this) InternalExposureNotificationPermissionHelper(this, this)
switch.setOnCheckedChangeListener { _, _ -> switch.setOnCheckedChangeListener { _, _ ->
// android calls this listener also on start, so it has to be verified if the user pressed the switch // android calls this listener also on start, so it has to be verified if the user pressed the switch
if (switch.isPressed) { if (switch.isPressed) {
ViewBlocker.runAndBlockInteraction(arrayOf(row, switch)) { ViewBlocker.runAndBlockInteraction(arrayOf(switch)) {
startStopTracing()
}
}
}
row.setOnClickListener {
ViewBlocker.runAndBlockInteraction(arrayOf(row, switch)) {
// only if the switch is enabled the user is allowed to toggle it, this implements the
// same behaviour if he clicks on the row
if (switch.isEnabled) {
startStopTracing() startStopTracing()
} }
} }
...@@ -126,10 +115,9 @@ class SettingsTracingFragment : BaseFragment(), ...@@ -126,10 +115,9 @@ class SettingsTracingFragment : BaseFragment(),
} }
private fun startStopTracing() { private fun startStopTracing() {
if (tracingViewModel.isTracingEnabled.value != null) { // if tracing is enabled when listener is activated it should be disabled
// if tracing is enabled when listener is activated it should be disabled lifecycleScope.launch {
if (tracingViewModel.isTracingEnabled.value!!) { if (InternalExposureNotificationClient.asyncIsEnabled()) {
lifecycleScope.launch {
try { try {
Toast.makeText( Toast.makeText(
requireContext(), requireContext(),
...@@ -137,24 +125,20 @@ class SettingsTracingFragment : BaseFragment(), ...@@ -137,24 +125,20 @@ class SettingsTracingFragment : BaseFragment(),
Toast.LENGTH_SHORT Toast.LENGTH_SHORT
) )
.show() .show()
tracingViewModel.refreshIsTracingEnabled()
InternalExposureNotificationClient.asyncStop()
} catch (exception: Exception) { } catch (exception: Exception) {
exception.report( exception.report(
ExceptionCategory.EXPOSURENOTIFICATION, ExceptionCategory.EXPOSURENOTIFICATION,
TAG, TAG,
null null
) )
tracingViewModel.refreshIsTracingEnabled()
} }
InternalExposureNotificationClient.asyncStop()
tracingViewModel.refreshIsTracingEnabled() tracingViewModel.refreshIsTracingEnabled()
BackgroundWorkScheduler.stopWorkScheduler() BackgroundWorkScheduler.stopWorkScheduler()
}
} else { } else {
internalExposureNotificationPermissionHelper.requestPermissionToStartTracing() internalExposureNotificationPermissionHelper.requestPermissionToStartTracing()
} }
} }
tracingViewModel.refreshIsTracingEnabled()
settingsViewModel.refreshBluetoothEnabled()
} }
} }
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