Skip to content
Snippets Groups Projects
Commit e2bd6fda authored by clairehurst's avatar clairehurst Committed by Dan Ballard
Browse files

fixup! Implement Android-native Connection Assist UI

parent 89ac6134
Branches
Tags
1 merge request!99Bug_42571: Fix bootstrap background issues
......@@ -62,6 +62,7 @@ class TorConnectionAssistFragment : Fragment(), UserInteractionHandler {
override fun onResume() {
super.onResume()
hideToolbar()
viewModel.handleTorConnectStateToScreen() // Covers the case where the app is backgrounded when the bootstrap finishes
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
......@@ -86,6 +87,7 @@ class TorConnectionAssistFragment : Fragment(), UserInteractionHandler {
viewModel.shouldOpenHome().observe(
viewLifecycleOwner,
) {
Log.d(TAG, "shouldOpenHome() = $it")
if (it) {
openHome()
}
......
......@@ -46,6 +46,7 @@ class TorConnectionAssistViewModel(
init {
Log.d(TAG, "initiating TorConnectionAssistViewModel")
_torController.registerTorListener(this)
handleTorConnectStateToScreen() // should cover the case of when we have an onBootStrapStateChange() event before this is initialized, which lead to being stuck on the splash screen
}
private fun handleConnect(
......@@ -95,6 +96,10 @@ class TorConnectionAssistViewModel(
_progress.value = progress.toInt()
}
handleTorConnectStateToScreen()
}
fun handleTorConnectStateToScreen() {
when (_torController.lastKnownStatus) {
TorConnectState.Initial -> _torConnectScreen.value = ConnectAssistUiState.Splash
TorConnectState.Configuring -> handleConfiguring()
......@@ -144,7 +149,11 @@ class TorConnectionAssistViewModel(
/** stay here */
}
else -> _torConnectScreen.value = ConnectAssistUiState.Connecting
else -> _torConnectScreen.value =
ConnectAssistUiState.Connecting.also { connectAssistUiState ->
// covers the case of when the bootstrap is already in progress when the UiState "catches up"
connectAssistUiState.progress = _progress.value ?: 0
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment