Dan Ballard pushed to branch tor-browser-128.9.0esr-14.5-1 at The Tor Project / Applications / Tor Browser
Commits:
-
88e6b1d1
by clairehurst at 2025-04-02T10:02:04-06:00
-
ff0650aa
by clairehurst at 2025-04-02T10:02:05-06:00
5 changed files:
- mobile/android/fenix/app/src/main/java/org/mozilla/fenix/tor/ConnectAssistUiState.kt
- mobile/android/fenix/app/src/main/java/org/mozilla/fenix/tor/TorConnectionAssistFragment.kt
- mobile/android/fenix/app/src/main/java/org/mozilla/fenix/tor/TorConnectionAssistViewModel.kt
- mobile/android/geckoview/src/main/java/org/mozilla/geckoview/TorAndroidIntegration.java
- toolkit/modules/TorAndroidIntegration.sys.mjs
Changes:
| ... | ... | @@ -21,8 +21,8 @@ enum class ConnectAssistUiState( |
| 21 | 21 | @StringRes val internetErrorDescription2: Int? = null,
|
| 22 | 22 | @StringRes val titleDescriptionTextStringResource: Int? = R.string.preferences_tor_network_settings_explanation,
|
| 23 | 23 | val quickstartSwitchVisible: Boolean,
|
| 24 | - val countryDropDownVisible: Boolean,
|
|
| 25 | - @StringRes val countryDropDownDefaultItem: Int = R.string.connection_assist_automatic_country_detection,
|
|
| 24 | + val regionDropDownVisible: Boolean,
|
|
| 25 | + @StringRes val regionDropDownDefaultItem: Int = R.string.connection_assist_automatic_country_detection,
|
|
| 26 | 26 | val torBootstrapButton1Visible: Boolean,
|
| 27 | 27 | @StringRes val torBootstrapButton1TextStringResource: Int = R.string.tor_bootstrap_connect,
|
| 28 | 28 | val torBootstrapButton1ShouldTryABridge: Boolean = false,
|
| ... | ... | @@ -41,7 +41,7 @@ enum class ConnectAssistUiState( |
| 41 | 41 | titleLargeTextViewVisible = false,
|
| 42 | 42 | titleDescriptionVisible = false,
|
| 43 | 43 | quickstartSwitchVisible = false,
|
| 44 | - countryDropDownVisible = false,
|
|
| 44 | + regionDropDownVisible = false,
|
|
| 45 | 45 | torBootstrapButton1Visible = false,
|
| 46 | 46 | torBootstrapButton2Visible = false,
|
| 47 | 47 | wordmarkLogoVisible = true,
|
| ... | ... | @@ -57,7 +57,7 @@ enum class ConnectAssistUiState( |
| 57 | 57 | titleDescriptionVisible = true,
|
| 58 | 58 | titleDescriptionTextStringResource = R.string.preferences_tor_network_settings_explanation,
|
| 59 | 59 | quickstartSwitchVisible = true,
|
| 60 | - countryDropDownVisible = false,
|
|
| 60 | + regionDropDownVisible = false,
|
|
| 61 | 61 | torBootstrapButton1Visible = true,
|
| 62 | 62 | torBootstrapButton2Visible = true,
|
| 63 | 63 | torBootstrapButton2TextStringResource = R.string.connection_assist_configure_connection_button,
|
| ... | ... | @@ -74,7 +74,7 @@ enum class ConnectAssistUiState( |
| 74 | 74 | titleDescriptionVisible = true,
|
| 75 | 75 | titleDescriptionTextStringResource = R.string.preferences_tor_network_settings_explanation,
|
| 76 | 76 | quickstartSwitchVisible = true,
|
| 77 | - countryDropDownVisible = false,
|
|
| 77 | + regionDropDownVisible = false,
|
|
| 78 | 78 | torBootstrapButton1Visible = false,
|
| 79 | 79 | torBootstrapButton2Visible = true,
|
| 80 | 80 | torBootstrapButton2TextStringResource = R.string.btn_cancel,
|
| ... | ... | @@ -94,7 +94,7 @@ enum class ConnectAssistUiState( |
| 94 | 94 | internetErrorDescription = R.string.connection_assist_internet_error_description,
|
| 95 | 95 | titleDescriptionTextStringResource = null,
|
| 96 | 96 | quickstartSwitchVisible = false,
|
| 97 | - countryDropDownVisible = false,
|
|
| 97 | + regionDropDownVisible = false,
|
|
| 98 | 98 | torBootstrapButton1Visible = true,
|
| 99 | 99 | torBootstrapButton1TextStringResource = R.string.connection_assist_internet_error_try_again,
|
| 100 | 100 | torBootstrapButton2Visible = true,
|
| ... | ... | @@ -114,7 +114,7 @@ enum class ConnectAssistUiState( |
| 114 | 114 | internetErrorDescription = R.string.connection_assist_internet_error_description,
|
| 115 | 115 | titleDescriptionTextStringResource = null,
|
| 116 | 116 | quickstartSwitchVisible = false,
|
| 117 | - countryDropDownVisible = false,
|
|
| 117 | + regionDropDownVisible = false,
|
|
| 118 | 118 | torBootstrapButton1Visible = false,
|
| 119 | 119 | torBootstrapButton2Visible = true,
|
| 120 | 120 | torBootstrapButton2TextStringResource = R.string.btn_cancel,
|
| ... | ... | @@ -134,7 +134,7 @@ enum class ConnectAssistUiState( |
| 134 | 134 | internetErrorDescription = R.string.connection_assist_try_a_bridge_description,
|
| 135 | 135 | titleDescriptionTextStringResource = null,
|
| 136 | 136 | quickstartSwitchVisible = false,
|
| 137 | - countryDropDownVisible = true,
|
|
| 137 | + regionDropDownVisible = true,
|
|
| 138 | 138 | torBootstrapButton1Visible = true,
|
| 139 | 139 | torBootstrapButton1TextStringResource = R.string.connection_assist_try_a_bridge_button,
|
| 140 | 140 | torBootstrapButton1ShouldTryABridge = true,
|
| ... | ... | @@ -155,7 +155,7 @@ enum class ConnectAssistUiState( |
| 155 | 155 | internetErrorDescription = ChooseRegion.internetErrorDescription,
|
| 156 | 156 | titleDescriptionTextStringResource = null,
|
| 157 | 157 | quickstartSwitchVisible = true,
|
| 158 | - countryDropDownVisible = false,
|
|
| 158 | + regionDropDownVisible = false,
|
|
| 159 | 159 | torBootstrapButton1Visible = false,
|
| 160 | 160 | torBootstrapButton2Visible = true,
|
| 161 | 161 | torBootstrapButton2TextStringResource = R.string.btn_cancel,
|
| ... | ... | @@ -177,8 +177,8 @@ enum class ConnectAssistUiState( |
| 177 | 177 | internetErrorDescription2 = R.string.connection_assist_select_country_try_again,
|
| 178 | 178 | titleDescriptionTextStringResource = null,
|
| 179 | 179 | quickstartSwitchVisible = false,
|
| 180 | - countryDropDownVisible = true,
|
|
| 181 | - countryDropDownDefaultItem = R.string.connection_assist_select_country_or_region,
|
|
| 180 | + regionDropDownVisible = true,
|
|
| 181 | + regionDropDownDefaultItem = R.string.connection_assist_select_country_or_region,
|
|
| 182 | 182 | torBootstrapButton1Visible = true,
|
| 183 | 183 | torBootstrapButton1TextStringResource = R.string.connection_assist_try_a_bridge_button,
|
| 184 | 184 | torBootstrapButton1ShouldTryABridge = true,
|
| ... | ... | @@ -201,7 +201,7 @@ enum class ConnectAssistUiState( |
| 201 | 201 | internetErrorDescription2 = RegionNotFound.internetErrorDescription2,
|
| 202 | 202 | titleDescriptionTextStringResource = null,
|
| 203 | 203 | quickstartSwitchVisible = true,
|
| 204 | - countryDropDownVisible = false,
|
|
| 204 | + regionDropDownVisible = false,
|
|
| 205 | 205 | torBootstrapButton1Visible = false,
|
| 206 | 206 | torBootstrapButton2Visible = true,
|
| 207 | 207 | torBootstrapButton2TextStringResource = R.string.btn_cancel,
|
| ... | ... | @@ -223,8 +223,8 @@ enum class ConnectAssistUiState( |
| 223 | 223 | internetErrorDescription2 = R.string.connection_assist_select_country_try_again,
|
| 224 | 224 | titleDescriptionTextStringResource = null,
|
| 225 | 225 | quickstartSwitchVisible = false,
|
| 226 | - countryDropDownVisible = true,
|
|
| 227 | - countryDropDownDefaultItem = R.string.connection_assist_select_country_or_region,
|
|
| 226 | + regionDropDownVisible = true,
|
|
| 227 | + regionDropDownDefaultItem = R.string.connection_assist_select_country_or_region,
|
|
| 228 | 228 | torBootstrapButton1Visible = true,
|
| 229 | 229 | torBootstrapButton1TextStringResource = R.string.connection_assist_try_a_bridge_button,
|
| 230 | 230 | torBootstrapButton1ShouldTryABridge = true,
|
| ... | ... | @@ -247,7 +247,7 @@ enum class ConnectAssistUiState( |
| 247 | 247 | internetErrorDescription2 = ConfirmRegion.internetErrorDescription2,
|
| 248 | 248 | titleDescriptionTextStringResource = null,
|
| 249 | 249 | quickstartSwitchVisible = true,
|
| 250 | - countryDropDownVisible = false,
|
|
| 250 | + regionDropDownVisible = false,
|
|
| 251 | 251 | torBootstrapButton1Visible = false,
|
| 252 | 252 | torBootstrapButton2Visible = true,
|
| 253 | 253 | torBootstrapButton2TextStringResource = R.string.btn_cancel,
|
| ... | ... | @@ -268,7 +268,7 @@ enum class ConnectAssistUiState( |
| 268 | 268 | internetErrorDescription2 = R.string.connection_assist_select_country_try_again,
|
| 269 | 269 | titleDescriptionTextStringResource = null,
|
| 270 | 270 | quickstartSwitchVisible = true,
|
| 271 | - countryDropDownVisible = false,
|
|
| 271 | + regionDropDownVisible = false,
|
|
| 272 | 272 | torBootstrapButton1Visible = false,
|
| 273 | 273 | torBootstrapButton2Visible = true,
|
| 274 | 274 | torBootstrapButton2TextStringResource = R.string.btn_cancel,
|
| ... | ... | @@ -289,7 +289,7 @@ enum class ConnectAssistUiState( |
| 289 | 289 | internetErrorDescription1 = R.string.connection_assist_final_error_troubleshoot_connection_link,
|
| 290 | 290 | titleDescriptionTextStringResource = null,
|
| 291 | 291 | quickstartSwitchVisible = false,
|
| 292 | - countryDropDownVisible = false,
|
|
| 292 | + regionDropDownVisible = false,
|
|
| 293 | 293 | torBootstrapButton1Visible = true,
|
| 294 | 294 | torBootstrapButton1TextStringResource = R.string.connection_assist_configure_connection_button,
|
| 295 | 295 | torBootstrapButton1ShouldOpenSettings = true,
|
| ... | ... | @@ -60,7 +60,7 @@ class TorConnectionAssistFragment : Fragment(), UserInteractionHandler { |
| 60 | 60 | override fun onReceive(context: Context, intent: Intent) {
|
| 61 | 61 | if (intent.action === Intent.ACTION_LOCALE_CHANGED) {
|
| 62 | 62 | Log.v("LocaleReceiver", "received ACTION_LOCALE_CHANGED")
|
| 63 | - torConnectionAssistViewModel.fetchCountryNamesGet()
|
|
| 63 | + torConnectionAssistViewModel.fetchRegionNames()
|
|
| 64 | 64 | }
|
| 65 | 65 | }
|
| 66 | 66 | }
|
| ... | ... | @@ -204,14 +204,14 @@ class TorConnectionAssistFragment : Fragment(), UserInteractionHandler { |
| 204 | 204 | }
|
| 205 | 205 | |
| 206 | 206 | private fun setCountryDropDown(screen: ConnectAssistUiState) {
|
| 207 | - if (screen.countryDropDownVisible) {
|
|
| 207 | + if (screen.regionDropDownVisible) {
|
|
| 208 | 208 | val spinnerAdapter: ArrayAdapter<String> = initializeSpinner()
|
| 209 | 209 | if (binding.countryDropDown.isEmpty()) {
|
| 210 | - populateCountryDropDown(spinnerAdapter)
|
|
| 210 | + populateRegionDropDown(spinnerAdapter)
|
|
| 211 | 211 | setOnItemSelectedListener()
|
| 212 | 212 | }
|
| 213 | 213 | |
| 214 | - setFirstItemInCountryDropDown(spinnerAdapter, getString(screen.countryDropDownDefaultItem))
|
|
| 214 | + setFirstItemInCountryDropDown(spinnerAdapter, getString(screen.regionDropDownDefaultItem))
|
|
| 215 | 215 | |
| 216 | 216 | if (screen == ConnectAssistUiState.ChooseRegion || screen == ConnectAssistUiState.ConfirmRegion || screen == ConnectAssistUiState.RegionNotFound) {
|
| 217 | 217 | torConnectionAssistViewModel.selectDefaultRegion()
|
| ... | ... | @@ -248,15 +248,15 @@ class TorConnectionAssistFragment : Fragment(), UserInteractionHandler { |
| 248 | 248 | return spinnerAdapter
|
| 249 | 249 | }
|
| 250 | 250 | |
| 251 | - private fun populateCountryDropDown(spinnerAdapter: ArrayAdapter<String>) {
|
|
| 252 | - torConnectionAssistViewModel.fetchCountryNamesGet()
|
|
| 251 | + private fun populateRegionDropDown(spinnerAdapter: ArrayAdapter<String>) {
|
|
| 252 | + torConnectionAssistViewModel.fetchRegionNames()
|
|
| 253 | 253 | viewLifecycleOwner.lifecycleScope.launch {
|
| 254 | 254 | repeatOnLifecycle(Lifecycle.State.STARTED) {
|
| 255 | - torConnectionAssistViewModel.countryCodeNameMap.collect {
|
|
| 256 | - Log.d(TAG, "countryCodeNameMap: $it")
|
|
| 255 | + torConnectionAssistViewModel.regionCodeNameMap.collect {
|
|
| 256 | + Log.d(TAG, "regionCodeNameMap: $it")
|
|
| 257 | 257 | if (it != null) {
|
| 258 | 258 | spinnerAdapter.clear()
|
| 259 | - spinnerAdapter.add(getString(torConnectionAssistViewModel.torConnectScreen.value.countryDropDownDefaultItem))
|
|
| 259 | + spinnerAdapter.add(getString(torConnectionAssistViewModel.torConnectScreen.value.regionDropDownDefaultItem))
|
|
| 260 | 260 | spinnerAdapter.addAll(it.values)
|
| 261 | 261 | }
|
| 262 | 262 | }
|
| ... | ... | @@ -47,15 +47,15 @@ class TorConnectionAssistViewModel( |
| 47 | 47 | components.useCases.tabsUseCases.removeTab.invoke(components.core.store.state.tabs.find {it.getUrl() == "about:"}?.id ?: "")
|
| 48 | 48 | }
|
| 49 | 49 | |
| 50 | - fun fetchCountryNamesGet() {
|
|
| 51 | - torAndroidIntegration.countryNamesGet { countryNames : GeckoBundle? ->
|
|
| 52 | - if (countryNames != null) {
|
|
| 53 | - val codes: Array<String> = countryNames.keys()
|
|
| 50 | + fun fetchRegionNames() {
|
|
| 51 | + torAndroidIntegration.regionNamesGet { regionNames : GeckoBundle? ->
|
|
| 52 | + if (regionNames != null) {
|
|
| 53 | + val codes: Array<String> = regionNames.keys()
|
|
| 54 | 54 | val regions = mutableMapOf<String, String>()
|
| 55 | 55 | for (code in codes) {
|
| 56 | - regions[code] = countryNames.getString(code)
|
|
| 56 | + regions[code] = regionNames.getString(code)
|
|
| 57 | 57 | }
|
| 58 | - countryCodeNameMap.value = regions
|
|
| 58 | + regionCodeNameMap.value = regions
|
|
| 59 | 59 | }
|
| 60 | 60 | }
|
| 61 | 61 | }
|
| ... | ... | @@ -73,7 +73,7 @@ class TorConnectionAssistViewModel( |
| 73 | 73 | private val _torConnectScreen = MutableStateFlow(ConnectAssistUiState.Loading)
|
| 74 | 74 | internal val torConnectScreen: StateFlow<ConnectAssistUiState> = _torConnectScreen
|
| 75 | 75 | |
| 76 | - val countryCodeNameMap: MutableStateFlow<Map<String, String>?> by lazy {
|
|
| 76 | + val regionCodeNameMap: MutableStateFlow<Map<String, String>?> by lazy {
|
|
| 77 | 77 | MutableStateFlow(null)
|
| 78 | 78 | }
|
| 79 | 79 | |
| ... | ... | @@ -87,7 +87,7 @@ class TorConnectionAssistViewModel( |
| 87 | 87 | |
| 88 | 88 | fun setCountryCodeToSelectedItem(position: Int) {
|
| 89 | 89 | selectedCountryCode.value =
|
| 90 | - countryCodeNameMap.value?.keys?.toList()
|
|
| 90 | + regionCodeNameMap.value?.keys?.toList()
|
|
| 91 | 91 | ?.getOrNull(position - 1) ?: "automatic"
|
| 92 | 92 | // position - 1 since we have the default/first value of automatic
|
| 93 | 93 | Log.d(TAG, "selectedCountryCode = ${selectedCountryCode.value}")
|
| ... | ... | @@ -171,6 +171,6 @@ class TorConnectionAssistViewModel( |
| 171 | 171 | ) {}
|
| 172 | 172 | |
| 173 | 173 | fun button1ShouldBeDisabled(screen: ConnectAssistUiState): Boolean {
|
| 174 | - return selectedCountryCode.value == "automatic" && screen.countryDropDownDefaultItem == R.string.connection_assist_select_country_or_region
|
|
| 174 | + return selectedCountryCode.value == "automatic" && screen.regionDropDownDefaultItem == R.string.connection_assist_select_country_or_region
|
|
| 175 | 175 | }
|
| 176 | 176 | } |
| ... | ... | @@ -58,7 +58,7 @@ public class TorAndroidIntegration implements BundleEventListener { |
| 58 | 58 | private static final String EVENT_START_AGAIN = "GeckoView:Tor:StartAgain";
|
| 59 | 59 | private static final String EVENT_QUICKSTART_GET = "GeckoView:Tor:QuickstartGet";
|
| 60 | 60 | private static final String EVENT_QUICKSTART_SET = "GeckoView:Tor:QuickstartSet";
|
| 61 | - private static final String EVENT_COUNTRY_NAMES_GET = "GeckoView:Tor:CountryNamesGet";
|
|
| 61 | + private static final String EVENT_REGION_NAMES_GET = "GeckoView:Tor:RegionNamesGet";
|
|
| 62 | 62 | |
| 63 | 63 | private static final String CONTROL_PORT_FILE = "/control-ipc";
|
| 64 | 64 | private static final String SOCKS_FILE = "/socks-ipc";
|
| ... | ... | @@ -722,13 +722,13 @@ public class TorAndroidIntegration implements BundleEventListener { |
| 722 | 722 | return EventDispatcher.getInstance().queryVoid(EVENT_QUICKSTART_SET, bundle);
|
| 723 | 723 | }
|
| 724 | 724 | |
| 725 | - public interface CountryNamesGetter {
|
|
| 726 | - void onValue(GeckoBundle regions);
|
|
| 725 | + public interface RegionNamesGetter {
|
|
| 726 | + void onValue(GeckoBundle regionNames);
|
|
| 727 | 727 | }
|
| 728 | 728 | |
| 729 | - public void countryNamesGet(CountryNamesGetter countryNamesGetter) {
|
|
| 730 | - EventDispatcher.getInstance().queryBundle(EVENT_COUNTRY_NAMES_GET).then(countryNames -> {
|
|
| 731 | - countryNamesGetter.onValue(countryNames);
|
|
| 729 | + public void regionNamesGet(RegionNamesGetter regionNamesGetter) {
|
|
| 730 | + EventDispatcher.getInstance().queryBundle(EVENT_REGION_NAMES_GET).then(regionNames -> {
|
|
| 731 | + regionNamesGetter.onValue(regionNames);
|
|
| 732 | 732 | return new GeckoResult<Void>();
|
| 733 | 733 | });
|
| 734 | 734 | }
|
| ... | ... | @@ -45,7 +45,7 @@ const ListenedEvents = Object.freeze({ |
| 45 | 45 | startAgain: "GeckoView:Tor:StartAgain",
|
| 46 | 46 | quickstartGet: "GeckoView:Tor:QuickstartGet",
|
| 47 | 47 | quickstartSet: "GeckoView:Tor:QuickstartSet",
|
| 48 | - countryNamesGet: "GeckoView:Tor:CountryNamesGet",
|
|
| 48 | + regionNamesGet: "GeckoView:Tor:RegionNamesGet",
|
|
| 49 | 49 | });
|
| 50 | 50 | |
| 51 | 51 | class TorAndroidIntegrationImpl {
|
| ... | ... | @@ -205,7 +205,7 @@ class TorAndroidIntegrationImpl { |
| 205 | 205 | case ListenedEvents.quickstartSet:
|
| 206 | 206 | lazy.TorConnect.quickstart = data.enabled;
|
| 207 | 207 | break;
|
| 208 | - case ListenedEvents.countryNamesGet:
|
|
| 208 | + case ListenedEvents.regionNamesGet:
|
|
| 209 | 209 | callback?.onSuccess(lazy.TorConnect.getRegionNames());
|
| 210 | 210 | return;
|
| 211 | 211 | }
|