Dan Ballard pushed to branch firefox-android-115.2.1-13.5-1 at The Tor Project / Applications / firefox-android
Commits:
-
e2bd6fda
by clairehurst at 2024-05-14T00:00:14+00:00
2 changed files:
- fenix/app/src/main/java/org/mozilla/fenix/tor/TorConnectionAssistFragment.kt
- fenix/app/src/main/java/org/mozilla/fenix/tor/TorConnectionAssistViewModel.kt
Changes:
| ... | ... | @@ -62,6 +62,7 @@ class TorConnectionAssistFragment : Fragment(), UserInteractionHandler { |
| 62 | 62 | override fun onResume() {
|
| 63 | 63 | super.onResume()
|
| 64 | 64 | hideToolbar()
|
| 65 | + viewModel.handleTorConnectStateToScreen() // Covers the case where the app is backgrounded when the bootstrap finishes
|
|
| 65 | 66 | }
|
| 66 | 67 | |
| 67 | 68 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
| ... | ... | @@ -86,6 +87,7 @@ class TorConnectionAssistFragment : Fragment(), UserInteractionHandler { |
| 86 | 87 | viewModel.shouldOpenHome().observe(
|
| 87 | 88 | viewLifecycleOwner,
|
| 88 | 89 | ) {
|
| 90 | + Log.d(TAG, "shouldOpenHome() = $it")
|
|
| 89 | 91 | if (it) {
|
| 90 | 92 | openHome()
|
| 91 | 93 | }
|
| ... | ... | @@ -46,6 +46,7 @@ class TorConnectionAssistViewModel( |
| 46 | 46 | init {
|
| 47 | 47 | Log.d(TAG, "initiating TorConnectionAssistViewModel")
|
| 48 | 48 | _torController.registerTorListener(this)
|
| 49 | + 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
|
|
| 49 | 50 | }
|
| 50 | 51 | |
| 51 | 52 | private fun handleConnect(
|
| ... | ... | @@ -95,6 +96,10 @@ class TorConnectionAssistViewModel( |
| 95 | 96 | _progress.value = progress.toInt()
|
| 96 | 97 | }
|
| 97 | 98 | |
| 99 | + handleTorConnectStateToScreen()
|
|
| 100 | + }
|
|
| 101 | + |
|
| 102 | + fun handleTorConnectStateToScreen() {
|
|
| 98 | 103 | when (_torController.lastKnownStatus) {
|
| 99 | 104 | TorConnectState.Initial -> _torConnectScreen.value = ConnectAssistUiState.Splash
|
| 100 | 105 | TorConnectState.Configuring -> handleConfiguring()
|
| ... | ... | @@ -144,7 +149,11 @@ class TorConnectionAssistViewModel( |
| 144 | 149 | /** stay here */
|
| 145 | 150 | }
|
| 146 | 151 | |
| 147 | - else -> _torConnectScreen.value = ConnectAssistUiState.Connecting
|
|
| 152 | + else -> _torConnectScreen.value =
|
|
| 153 | + ConnectAssistUiState.Connecting.also { connectAssistUiState ->
|
|
| 154 | + // covers the case of when the bootstrap is already in progress when the UiState "catches up"
|
|
| 155 | + connectAssistUiState.progress = _progress.value ?: 0
|
|
| 156 | + }
|
|
| 148 | 157 | }
|
| 149 | 158 | }
|
| 150 | 159 |