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 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 ===================================== @@ -27,7 +27,6 @@ import kotlinx.coroutines.launch import mozilla.components.support.base.feature.UserInteractionHandler import org.mozilla.fenix.R import org.mozilla.fenix.databinding.FragmentTorConnectionAssistBinding -import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.hideToolbar
class TorConnectionAssistFragment : Fragment(), UserInteractionHandler { @@ -75,6 +74,20 @@ class TorConnectionAssistFragment : Fragment(), UserInteractionHandler { } }
+ viewModel.quickstartToggle().observe( + viewLifecycleOwner, + ) { + binding.quickstartSwitch.isChecked = it == true + } + + viewModel.shouldOpenHome().observe( + viewLifecycleOwner, + ) { + if (it) { + openHome() + } + } + }
override fun onDestroyView() { @@ -136,7 +149,7 @@ class TorConnectionAssistFragment : Fragment(), UserInteractionHandler { titleDescription.text = getString(screen.titleDescriptionTextStringResource) } quickstartSwitch.visibility = if (screen.quickstartSwitchVisible) View.VISIBLE else View.GONE - quickstartSwitch.isChecked = requireContext().components.torController.quickstart + quickstartSwitch.isChecked = viewModel.quickstartToggle().value == true quickstartSwitch.setOnCheckedChangeListener { _, isChecked -> viewModel.handleQuickstartChecked(isChecked) } @@ -198,7 +211,7 @@ class TorConnectionAssistFragment : Fragment(), UserInteractionHandler { }
private fun openHome() { - Log.d(TAG, "openHome()") //This doesn't seem to be ever called + Log.d(TAG, "openHome()") findNavController().navigate(TorConnectionAssistFragmentDirections.actionStartupHome()) }
===================================== fenix/app/src/main/java/org/mozilla/fenix/tor/TorConnectionAssistViewModel.kt ===================================== @@ -26,6 +26,18 @@ class TorConnectionAssistViewModel( private val _torConnectScreen = MutableStateFlow(ConnectAssistUiState.Splash) internal val torConnectScreen: StateFlow<ConnectAssistUiState> = _torConnectScreen
+ private val _quickStartToggle = MutableLiveData<Boolean>() // don't initialize with quickstart off the bat + fun quickstartToggle(): LiveData<Boolean?> { + _quickStartToggle.value = _torController.quickstart // quickstart isn't ready until torSettings is ready + return _quickStartToggle + } + + + private val _shouldOpenHome = MutableLiveData(false) + fun shouldOpenHome(): LiveData<Boolean> { + return _shouldOpenHome + } + private val _progress = MutableLiveData(0) fun progress(): LiveData<Int> { return _progress @@ -49,6 +61,7 @@ class TorConnectionAssistViewModel(
fun handleQuickstartChecked(checked: Boolean) { _torController.quickstart = checked + _quickStartToggle.value = checked }
fun handleButton1Pressed( @@ -87,8 +100,9 @@ class TorConnectionAssistViewModel( TorConnectState.Configuring -> handleConfiguring() TorConnectState.AutoBootstrapping -> handleBootstrap() TorConnectState.Bootstrapping -> handleBootstrap() + TorConnectState.Bootstrapped -> _shouldOpenHome.value = true + TorConnectState.Disabled -> _shouldOpenHome.value = true TorConnectState.Error -> handleError() - else -> {} } }
View it on GitLab: https://gitlab.torproject.org/tpo/applications/firefox-android/-/commit/fe6b...
tbb-commits@lists.torproject.org