Commit b15f225e authored by clairehurst's avatar clairehurst 🌱 Committed by brizental
Browse files

fixup! [android] Implement Android-native Connection Assist UI

Bug 43576: Connection Assist on Android Fast Follows (Bug 41188)
Add frequent regions
parent ce5701e4
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -212,6 +212,7 @@ class TorConnectionAssistFragment : Fragment(), UserInteractionHandler, SystemIn
        if (screen.regionDropDownVisible) {
            if (binding.countryDropDown.isEmpty()) {
                regionDropDownSpinnerAdapter = initializeSpinner()
                torConnectionAssistViewModel.fetchFrequentRegions()
                torConnectionAssistViewModel.fetchRegionNames()
            }

@@ -285,6 +286,18 @@ class TorConnectionAssistFragment : Fragment(), UserInteractionHandler, SystemIn
            }
        }

        viewLifecycleOwner.lifecycleScope.launch {
            repeatOnLifecycle(Lifecycle.State.STARTED) {
                torConnectionAssistViewModel.frequentRegionCodes.collect {
                    if (it != null) {
                        for (region in it) {
                            Log.d(TAG, "collected region: $region")
                        }
                    }
                }
            }
        }

        return spinnerAdapter
    }

+12 −0
Original line number Diff line number Diff line
@@ -80,6 +80,14 @@ class TorConnectionAssistViewModel(
        }
    }

    fun fetchFrequentRegions() {
        torAndroidIntegration.frequentRegionNamesGet { frequentRegionNames ->
            if (frequentRegionNames != null) {
                frequentRegionCodes.value = frequentRegionNames
            }
        }
    }

    override fun onCleared() {
        torAndroidIntegration.unregisterBootstrapStateChangeListener(this)
        super.onCleared()
@@ -96,6 +104,10 @@ class TorConnectionAssistViewModel(
        MutableStateFlow(null)
    }

    val frequentRegionCodes: MutableStateFlow<Array<String>?> by lazy {
        MutableStateFlow(null)
    }

    val selectedCountryCode: MutableStateFlow<String> by lazy {
        MutableStateFlow("automatic")
    }