Dan Ballard pushed to branch firefox-android-115.2.1-13.5-1 at The Tor Project / Applications / firefox-android
Commits:
-
fe6b5622
by clairehurst at 2024-05-08T15:01:58-06: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:
... | ... | @@ -27,7 +27,6 @@ import kotlinx.coroutines.launch |
27 | 27 | import mozilla.components.support.base.feature.UserInteractionHandler
|
28 | 28 | import org.mozilla.fenix.R
|
29 | 29 | import org.mozilla.fenix.databinding.FragmentTorConnectionAssistBinding
|
30 | -import org.mozilla.fenix.ext.components
|
|
31 | 30 | import org.mozilla.fenix.ext.hideToolbar
|
32 | 31 | |
33 | 32 | class TorConnectionAssistFragment : Fragment(), UserInteractionHandler {
|
... | ... | @@ -75,6 +74,20 @@ class TorConnectionAssistFragment : Fragment(), UserInteractionHandler { |
75 | 74 | }
|
76 | 75 | }
|
77 | 76 | |
77 | + viewModel.quickstartToggle().observe(
|
|
78 | + viewLifecycleOwner,
|
|
79 | + ) {
|
|
80 | + binding.quickstartSwitch.isChecked = it == true
|
|
81 | + }
|
|
82 | + |
|
83 | + viewModel.shouldOpenHome().observe(
|
|
84 | + viewLifecycleOwner,
|
|
85 | + ) {
|
|
86 | + if (it) {
|
|
87 | + openHome()
|
|
88 | + }
|
|
89 | + }
|
|
90 | + |
|
78 | 91 | }
|
79 | 92 | |
80 | 93 | override fun onDestroyView() {
|
... | ... | @@ -136,7 +149,7 @@ class TorConnectionAssistFragment : Fragment(), UserInteractionHandler { |
136 | 149 | titleDescription.text = getString(screen.titleDescriptionTextStringResource)
|
137 | 150 | }
|
138 | 151 | quickstartSwitch.visibility = if (screen.quickstartSwitchVisible) View.VISIBLE else View.GONE
|
139 | - quickstartSwitch.isChecked = requireContext().components.torController.quickstart
|
|
152 | + quickstartSwitch.isChecked = viewModel.quickstartToggle().value == true
|
|
140 | 153 | quickstartSwitch.setOnCheckedChangeListener { _, isChecked ->
|
141 | 154 | viewModel.handleQuickstartChecked(isChecked)
|
142 | 155 | }
|
... | ... | @@ -198,7 +211,7 @@ class TorConnectionAssistFragment : Fragment(), UserInteractionHandler { |
198 | 211 | }
|
199 | 212 | |
200 | 213 | private fun openHome() {
|
201 | - Log.d(TAG, "openHome()") //This doesn't seem to be ever called
|
|
214 | + Log.d(TAG, "openHome()")
|
|
202 | 215 | findNavController().navigate(TorConnectionAssistFragmentDirections.actionStartupHome())
|
203 | 216 | }
|
204 | 217 |
... | ... | @@ -26,6 +26,18 @@ class TorConnectionAssistViewModel( |
26 | 26 | private val _torConnectScreen = MutableStateFlow(ConnectAssistUiState.Splash)
|
27 | 27 | internal val torConnectScreen: StateFlow<ConnectAssistUiState> = _torConnectScreen
|
28 | 28 | |
29 | + private val _quickStartToggle = MutableLiveData<Boolean>() // don't initialize with quickstart off the bat
|
|
30 | + fun quickstartToggle(): LiveData<Boolean?> {
|
|
31 | + _quickStartToggle.value = _torController.quickstart // quickstart isn't ready until torSettings is ready
|
|
32 | + return _quickStartToggle
|
|
33 | + }
|
|
34 | + |
|
35 | + |
|
36 | + private val _shouldOpenHome = MutableLiveData(false)
|
|
37 | + fun shouldOpenHome(): LiveData<Boolean> {
|
|
38 | + return _shouldOpenHome
|
|
39 | + }
|
|
40 | + |
|
29 | 41 | private val _progress = MutableLiveData(0)
|
30 | 42 | fun progress(): LiveData<Int> {
|
31 | 43 | return _progress
|
... | ... | @@ -49,6 +61,7 @@ class TorConnectionAssistViewModel( |
49 | 61 | |
50 | 62 | fun handleQuickstartChecked(checked: Boolean) {
|
51 | 63 | _torController.quickstart = checked
|
64 | + _quickStartToggle.value = checked
|
|
52 | 65 | }
|
53 | 66 | |
54 | 67 | fun handleButton1Pressed(
|
... | ... | @@ -87,8 +100,9 @@ class TorConnectionAssistViewModel( |
87 | 100 | TorConnectState.Configuring -> handleConfiguring()
|
88 | 101 | TorConnectState.AutoBootstrapping -> handleBootstrap()
|
89 | 102 | TorConnectState.Bootstrapping -> handleBootstrap()
|
103 | + TorConnectState.Bootstrapped -> _shouldOpenHome.value = true
|
|
104 | + TorConnectState.Disabled -> _shouldOpenHome.value = true
|
|
90 | 105 | TorConnectState.Error -> handleError()
|
91 | - else -> {}
|
|
92 | 106 | }
|
93 | 107 | }
|
94 | 108 |