[tor-commits] [Git][tpo/applications/firefox-android][firefox-android-115.2.1-13.5-1] fixup! Implement Android-native Connection Assist UI

Dan Ballard (@dan) git at gitlab.torproject.org
Tue May 14 00:01:02 UTC 2024



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
fixup! Implement Android-native Connection Assist UI

- - - - -


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:

=====================================
fenix/app/src/main/java/org/mozilla/fenix/tor/TorConnectionAssistFragment.kt
=====================================
@@ -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()
             }


=====================================
fenix/app/src/main/java/org/mozilla/fenix/tor/TorConnectionAssistViewModel.kt
=====================================
@@ -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
+                }
         }
     }
 



View it on GitLab: https://gitlab.torproject.org/tpo/applications/firefox-android/-/commit/e2bd6fda09cb8b199c1211d22f696c644251f99f

-- 
This project does not include diff previews in email notifications.
View it on GitLab: https://gitlab.torproject.org/tpo/applications/firefox-android/-/commit/e2bd6fda09cb8b199c1211d22f696c644251f99f
You're receiving this email because of your account on gitlab.torproject.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.torproject.org/pipermail/tor-commits/attachments/20240514/56f4b3f4/attachment-0001.htm>


More information about the tor-commits mailing list