[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

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



Title: GitLab

Dan Ballard pushed to branch firefox-android-115.2.1-13.5-1 at The Tor Project / Applications / firefox-android

Commits:

  • a00861a6
    by clairehurst at 2024-05-09T14:47:16-06:00
    fixup! Implement Android-native Connection Assist UI
    

4 changed files:

Changes:

  • fenix/app/src/main/java/org/mozilla/fenix/tor/ConnectAssistUiState.kt
    ... ... @@ -31,7 +31,8 @@ enum class ConnectAssistUiState(
    31 31
         val torBootstrapButton2Visible: Boolean,
    
    32 32
         @StringRes val torBootstrapButton2TextStringResource: Int? = R.string.connection_assist_configure_connection_button,
    
    33 33
         val torBootstrapButton2ShouldOpenSettings: Boolean = true,
    
    34
    -    val wordmarkLogoVisible: Boolean,
    
    34
    +    val wordmarkLogoVisible: Boolean = false,
    
    35
    +    val torBootstrapButton2ShouldRestartApp: Boolean = false,
    
    35 36
     ) {
    
    36 37
         Splash(
    
    37 38
             progressBarVisible = false,
    
    ... ... @@ -65,9 +66,8 @@ enum class ConnectAssistUiState(
    65 66
             torBootstrapButton2Visible = true,
    
    66 67
             torBootstrapButton2TextStringResource = R.string.connection_assist_configure_connection_button,
    
    67 68
             torBootstrapButton2ShouldOpenSettings = true,
    
    68
    -        wordmarkLogoVisible = false,
    
    69 69
         ),
    
    70
    -    Bootstrapping(
    
    70
    +    Connecting(
    
    71 71
             progressBarVisible = true,
    
    72 72
             progress = 0,
    
    73 73
             backButtonVisible = false,
    
    ... ... @@ -85,7 +85,6 @@ enum class ConnectAssistUiState(
    85 85
             torBootstrapButton2Visible = true,
    
    86 86
             torBootstrapButton2TextStringResource = R.string.btn_cancel,
    
    87 87
             torBootstrapButton2ShouldOpenSettings = false,
    
    88
    -        wordmarkLogoVisible = false,
    
    89 88
         ),
    
    90 89
         InternetError(
    
    91 90
             progressBarVisible = true,
    
    ... ... @@ -109,7 +108,6 @@ enum class ConnectAssistUiState(
    109 108
             torBootstrapButton2Visible = true,
    
    110 109
             torBootstrapButton2TextStringResource = R.string.connection_assist_configure_connection_button,
    
    111 110
             torBootstrapButton2ShouldOpenSettings = true,
    
    112
    -        wordmarkLogoVisible = false,
    
    113 111
         ),
    
    114 112
         TryingAgain(
    
    115 113
             progressBarVisible = true,
    
    ... ... @@ -132,9 +130,8 @@ enum class ConnectAssistUiState(
    132 130
             torBootstrapButton2Visible = true,
    
    133 131
             torBootstrapButton2TextStringResource = R.string.btn_cancel,
    
    134 132
             torBootstrapButton2ShouldOpenSettings = false,
    
    135
    -        wordmarkLogoVisible = false,
    
    136 133
         ),
    
    137
    -    TryABridge(
    
    134
    +    ConnectionAssist(
    
    138 135
             progressBarVisible = true,
    
    139 136
             progress = 100,
    
    140 137
             progressTintColorResource = R.color.warning_yellow,
    
    ... ... @@ -157,7 +154,6 @@ enum class ConnectAssistUiState(
    157 154
             torBootstrapButton2Visible = false,
    
    158 155
             torBootstrapButton2TextStringResource = null,
    
    159 156
             torBootstrapButton2ShouldOpenSettings = true,
    
    160
    -        wordmarkLogoVisible = false,
    
    161 157
         ),
    
    162 158
         TryingABridge(
    
    163 159
             progressBarVisible = true,
    
    ... ... @@ -180,7 +176,6 @@ enum class ConnectAssistUiState(
    180 176
             torBootstrapButton2Visible = true,
    
    181 177
             torBootstrapButton2TextStringResource = R.string.btn_cancel,
    
    182 178
             torBootstrapButton2ShouldOpenSettings = false,
    
    183
    -        wordmarkLogoVisible = false,
    
    184 179
         ),
    
    185 180
         LocationError(
    
    186 181
             progressBarVisible = true,
    
    ... ... @@ -207,7 +202,6 @@ enum class ConnectAssistUiState(
    207 202
             torBootstrapButton2Visible = false,
    
    208 203
             torBootstrapButton2TextStringResource = null,
    
    209 204
             torBootstrapButton2ShouldOpenSettings = true,
    
    210
    -        wordmarkLogoVisible = false,
    
    211 205
         ),
    
    212 206
         LocationCheck(
    
    213 207
             progressBarVisible = true,
    
    ... ... @@ -234,7 +228,6 @@ enum class ConnectAssistUiState(
    234 228
             torBootstrapButton2Visible = false,
    
    235 229
             torBootstrapButton2TextStringResource = null,
    
    236 230
             torBootstrapButton2ShouldOpenSettings = true,
    
    237
    -        wordmarkLogoVisible = false,
    
    238 231
         ),
    
    239 232
         LastTry(
    
    240 233
             progressBarVisible = true,
    
    ... ... @@ -258,7 +251,6 @@ enum class ConnectAssistUiState(
    258 251
             torBootstrapButton2Visible = true,
    
    259 252
             torBootstrapButton2TextStringResource = R.string.btn_cancel,
    
    260 253
             torBootstrapButton2ShouldOpenSettings = false,
    
    261
    -        wordmarkLogoVisible = false,
    
    262 254
         ),
    
    263 255
         FinalError(
    
    264 256
             progressBarVisible = true,
    
    ... ... @@ -279,10 +271,10 @@ enum class ConnectAssistUiState(
    279 271
             unblockTheInternetInCountryDescriptionVisible = false,
    
    280 272
             countryDropDownVisible = false,
    
    281 273
             torBootstrapButton1Visible = true,
    
    282
    -        torBootstrapButton1TextStringResource = R.string.connection_assist_internet_error_try_again,
    
    274
    +        torBootstrapButton1TextStringResource = R.string.connection_assist_configure_connection_button,
    
    283 275
             torBootstrapButton2Visible = true,
    
    284
    -        torBootstrapButton2TextStringResource = R.string.connection_assist_configure_connection_button,
    
    285
    -        torBootstrapButton2ShouldOpenSettings = true,
    
    286
    -        wordmarkLogoVisible = false,
    
    276
    +        torBootstrapButton2TextStringResource = R.string.mozac_lib_crash_dialog_button_restart,
    
    277
    +        torBootstrapButton2ShouldOpenSettings = false,
    
    278
    +        torBootstrapButton2ShouldRestartApp = true,
    
    287 279
         )
    
    288 280
     }

  • fenix/app/src/main/java/org/mozilla/fenix/tor/TorConnectionAssistFragment.kt
    ... ... @@ -4,6 +4,7 @@
    4 4
     
    
    5 5
     package org.mozilla.fenix.tor
    
    6 6
     
    
    7
    +import android.content.Intent
    
    7 8
     import android.graphics.Color
    
    8 9
     import android.os.Build
    
    9 10
     import android.os.Bundle
    
    ... ... @@ -25,6 +26,7 @@ import androidx.lifecycle.repeatOnLifecycle
    25 26
     import androidx.navigation.fragment.findNavController
    
    26 27
     import kotlinx.coroutines.launch
    
    27 28
     import mozilla.components.support.base.feature.UserInteractionHandler
    
    29
    +import org.mozilla.fenix.HomeActivity
    
    28 30
     import org.mozilla.fenix.R
    
    29 31
     import org.mozilla.fenix.databinding.FragmentTorConnectionAssistBinding
    
    30 32
     import org.mozilla.fenix.ext.hideToolbar
    
    ... ... @@ -33,14 +35,15 @@ class TorConnectionAssistFragment : Fragment(), UserInteractionHandler {
    33 35
     
    
    34 36
         private val TAG = "TorConnectionAssistFrag"
    
    35 37
         private val viewModel: TorConnectionAssistViewModel by viewModels()
    
    36
    -    private lateinit var binding: FragmentTorConnectionAssistBinding
    
    38
    +    private var _binding: FragmentTorConnectionAssistBinding? = null
    
    39
    +    private val binding get() = _binding!!
    
    37 40
     
    
    38 41
         override fun onCreateView(
    
    39 42
             inflater: LayoutInflater,
    
    40 43
             container: ViewGroup?,
    
    41 44
             savedInstanceState: Bundle?,
    
    42 45
         ): View {
    
    43
    -        binding = FragmentTorConnectionAssistBinding.inflate(
    
    46
    +        _binding = FragmentTorConnectionAssistBinding.inflate(
    
    44 47
                 inflater, container, false,
    
    45 48
             )
    
    46 49
     
    
    ... ... @@ -90,96 +93,148 @@ class TorConnectionAssistFragment : Fragment(), UserInteractionHandler {
    90 93
     
    
    91 94
         }
    
    92 95
     
    
    93
    -    override fun onDestroyView() {
    
    94
    -        super.onDestroyView()
    
    95
    -    }
    
    96
    -
    
    97 96
         private fun showScreen(screen: ConnectAssistUiState) {
    
    98
    -        binding.apply {
    
    99
    -            torBootstrapProgressBar.visibility = if (screen.progressBarVisible) View.VISIBLE else View.GONE
    
    100
    -            torBootstrapProgressBar.progress = screen.progress
    
    101
    -            torBootstrapProgressBar.progressTintList =
    
    102
    -                screen.progressTintColorResource?.let {
    
    103
    -                    AppCompatResources.getColorStateList(requireContext(),
    
    104
    -                        it
    
    105
    -                    )
    
    106
    -                }
    
    107
    -
    
    108
    -            settingsButton.visibility = if (screen.settingsButtonVisible) View.VISIBLE else View.GONE
    
    109
    -            settingsButton.setOnClickListener {
    
    110
    -                viewModel.cancelTorBootstrap()
    
    111
    -                openSettings()
    
    112
    -            }
    
    97
    +        setProgressBar(screen)
    
    98
    +        setSettingsButton(screen)
    
    99
    +        setBackButton(screen)
    
    100
    +        setTorConnectImage(screen)
    
    101
    +        setTitle(screen)
    
    102
    +        setQuickStart(screen)
    
    103
    +        setCountryDropDown(screen)
    
    104
    +        setButton1(screen)
    
    105
    +        setButton2(screen)
    
    106
    +        setSplashLogo(screen)
    
    107
    +    }
    
    113 108
     
    
    114
    -            backButton.visibility = if (screen.backButtonVisible) View.VISIBLE else View.INVISIBLE
    
    115
    -            backButton.setOnClickListener {
    
    116
    -                viewModel.handleBackButtonPressed()
    
    109
    +    private fun setProgressBar(screen: ConnectAssistUiState) {
    
    110
    +        binding.torBootstrapProgressBar.visibility =
    
    111
    +            if (screen.progressBarVisible) View.VISIBLE else View.GONE
    
    112
    +        binding.torBootstrapProgressBar.progress = screen.progress
    
    113
    +        binding.torBootstrapProgressBar.progressTintList =
    
    114
    +            screen.progressTintColorResource?.let {
    
    115
    +                AppCompatResources.getColorStateList(
    
    116
    +                    requireContext(),
    
    117
    +                    it,
    
    118
    +                )
    
    117 119
                 }
    
    120
    +    }
    
    118 121
     
    
    119
    -            torConnectImage.visibility = if (screen.torConnectImageVisible) View.VISIBLE else View.GONE
    
    120
    -            torConnectImage.setImageResource(screen.torConnectImageResource)
    
    121
    -
    
    122
    -            titleLargeTextView.visibility = if (screen.titleLargeTextViewVisible) View.VISIBLE else View.GONE
    
    123
    -            titleLargeTextView.text = getString(screen.titleLargeTextViewTextStringResource)
    
    124
    -            titleDescription.visibility = if (screen.titleDescriptionVisible) View.VISIBLE else View.GONE
    
    125
    -            if (screen.learnMoreStringResource != null && screen.internetErrorDescription != null) {
    
    126
    -                val learnMore: String = getString(screen.learnMoreStringResource)
    
    127
    -                val internetErrorDescription: String =
    
    128
    -                    if (screen.internetErrorDescription1 == null) {
    
    129
    -                        getString(
    
    130
    -                            screen.internetErrorDescription,
    
    131
    -                            learnMore,
    
    132
    -                        )
    
    133
    -                    } else if (screen.internetErrorDescription2 == null) {
    
    134
    -                        getString(
    
    135
    -                            screen.internetErrorDescription,
    
    136
    -                            getString(screen.internetErrorDescription1),
    
    137
    -                            learnMore,
    
    138
    -                        )
    
    139
    -                    } else {
    
    140
    -                        getString(
    
    141
    -                            screen.internetErrorDescription,
    
    142
    -                            getString(screen.internetErrorDescription1),
    
    143
    -                            getString(screen.internetErrorDescription2),
    
    144
    -                            learnMore,
    
    145
    -                        )
    
    146
    -                    }
    
    147
    -                handleDescriptionWithClickable(internetErrorDescription, learnMore)
    
    148
    -            } else if (screen.titleDescriptionTextStringResource != null) {
    
    149
    -                titleDescription.text = getString(screen.titleDescriptionTextStringResource)
    
    150
    -            }
    
    151
    -            quickstartSwitch.visibility = if (screen.quickstartSwitchVisible) View.VISIBLE else View.GONE
    
    152
    -            quickstartSwitch.isChecked = viewModel.quickstartToggle().value == true
    
    153
    -            quickstartSwitch.setOnCheckedChangeListener { _, isChecked ->
    
    154
    -                viewModel.handleQuickstartChecked(isChecked)
    
    155
    -            }
    
    122
    +    private fun setSettingsButton(screen: ConnectAssistUiState) {
    
    123
    +        binding.settingsButton.visibility = if (screen.settingsButtonVisible) View.VISIBLE else View.GONE
    
    124
    +        binding.settingsButton.setOnClickListener {
    
    125
    +            viewModel.cancelTorBootstrap()
    
    126
    +            openSettings()
    
    127
    +        }
    
    128
    +    }
    
    156 129
     
    
    157
    -            unblockTheInternetInCountryDescription.visibility = if (screen.unblockTheInternetInCountryDescriptionVisible) View.VISIBLE else View.GONE
    
    158
    -            countryDropDown.visibility = if (screen.countryDropDownVisible) View.VISIBLE else View.GONE
    
    130
    +    private fun setBackButton(screen: ConnectAssistUiState) {
    
    131
    +        binding.backButton.visibility = if (screen.backButtonVisible) View.VISIBLE else View.INVISIBLE
    
    132
    +        binding.backButton.setOnClickListener {
    
    133
    +            viewModel.handleBackButtonPressed()
    
    134
    +        }
    
    135
    +    }
    
    159 136
     
    
    160
    -            torBootstrapButton1.visibility = if (screen.torBootstrapButton1Visible) View.VISIBLE else View.GONE
    
    161
    -            torBootstrapButton1.text = getString(screen.torBootstrapButton1TextStringResource)
    
    162
    -            torBootstrapButton1.setOnClickListener { viewModel.handleButton1Pressed(screen, lifecycleScope) }
    
    137
    +    private fun setTorConnectImage(screen: ConnectAssistUiState) {
    
    138
    +        binding.torConnectImage.visibility = if (screen.torConnectImageVisible) View.VISIBLE else View.GONE
    
    139
    +        binding.torConnectImage.setImageResource(screen.torConnectImageResource)
    
    140
    +    }
    
    163 141
     
    
    164
    -            torBootstrapButton2.visibility = if (screen.torBootstrapButton2Visible) View.VISIBLE else View.GONE
    
    165
    -            torBootstrapButton2.text = screen.torBootstrapButton2TextStringResource?.let {
    
    166
    -                getString(
    
    167
    -                    it
    
    168
    -                )
    
    169
    -            }
    
    170
    -            torBootstrapButton2.setOnClickListener {
    
    171
    -                viewModel.cancelTorBootstrap()
    
    172
    -                if (screen.torBootstrapButton2ShouldOpenSettings){
    
    173
    -                    openTorConnectionSettings()
    
    142
    +    private fun setTitle(screen: ConnectAssistUiState) {
    
    143
    +        binding.titleLargeTextView.visibility =
    
    144
    +            if (screen.titleLargeTextViewVisible) View.VISIBLE else View.GONE
    
    145
    +        binding.titleLargeTextView.text = getString(screen.titleLargeTextViewTextStringResource)
    
    146
    +        binding.titleDescription.visibility =
    
    147
    +            if (screen.titleDescriptionVisible) View.VISIBLE else View.GONE
    
    148
    +        if (screen.learnMoreStringResource != null && screen.internetErrorDescription != null) {
    
    149
    +            val learnMore: String = getString(screen.learnMoreStringResource)
    
    150
    +            val internetErrorDescription: String =
    
    151
    +                if (screen.internetErrorDescription1 == null) {
    
    152
    +                    getString(
    
    153
    +                        screen.internetErrorDescription,
    
    154
    +                        learnMore,
    
    155
    +                    )
    
    156
    +                } else if (screen.internetErrorDescription2 == null) {
    
    157
    +                    getString(
    
    158
    +                        screen.internetErrorDescription,
    
    159
    +                        getString(screen.internetErrorDescription1),
    
    160
    +                        learnMore,
    
    161
    +                    )
    
    174 162
                     } else {
    
    175
    -                    showScreen(ConnectAssistUiState.Configuring)
    
    163
    +                    getString(
    
    164
    +                        screen.internetErrorDescription,
    
    165
    +                        getString(screen.internetErrorDescription1),
    
    166
    +                        getString(screen.internetErrorDescription2),
    
    167
    +                        learnMore,
    
    168
    +                    )
    
    176 169
                     }
    
    177
    -            }
    
    170
    +            handleDescriptionWithClickable(internetErrorDescription, learnMore)
    
    171
    +        } else if (screen.titleDescriptionTextStringResource != null) {
    
    172
    +            binding.titleDescription.text = getString(screen.titleDescriptionTextStringResource)
    
    173
    +        }
    
    174
    +    }
    
    175
    +
    
    176
    +    private fun setQuickStart(screen: ConnectAssistUiState) {
    
    177
    +        binding.quickstartSwitch.visibility =
    
    178
    +            if (screen.quickstartSwitchVisible) View.VISIBLE else View.GONE
    
    179
    +        binding.quickstartSwitch.isChecked = viewModel.quickstartToggle().value == true
    
    180
    +        binding.quickstartSwitch.setOnCheckedChangeListener { _, isChecked ->
    
    181
    +            viewModel.handleQuickstartChecked(isChecked)
    
    182
    +        }
    
    183
    +    }
    
    184
    +
    
    185
    +    private fun setCountryDropDown(screen: ConnectAssistUiState) {
    
    186
    +        binding.unblockTheInternetInCountryDescription.visibility =
    
    187
    +            if (screen.unblockTheInternetInCountryDescriptionVisible) View.VISIBLE else View.GONE
    
    188
    +        binding.countryDropDown.visibility = if (screen.countryDropDownVisible) View.VISIBLE else View.GONE
    
    189
    +    }
    
    178 190
     
    
    179
    -            wordmarkLogo.visibility = if(screen.wordmarkLogoVisible) View.VISIBLE else View.GONE
    
    191
    +    private fun setButton1(screen: ConnectAssistUiState) {
    
    192
    +        binding.torBootstrapButton1.visibility =
    
    193
    +            if (screen.torBootstrapButton1Visible) View.VISIBLE else View.GONE
    
    194
    +        binding.torBootstrapButton1.text = getString(screen.torBootstrapButton1TextStringResource)
    
    195
    +        binding.torBootstrapButton1.setOnClickListener {
    
    196
    +            viewModel.handleButton1Pressed(
    
    197
    +                screen,
    
    198
    +                lifecycleScope,
    
    199
    +            )
    
    200
    +        }
    
    201
    +    }
    
    202
    +
    
    203
    +    private fun setButton2(screen: ConnectAssistUiState) {
    
    204
    +        binding.torBootstrapButton2.visibility =
    
    205
    +            if (screen.torBootstrapButton2Visible) View.VISIBLE else View.GONE
    
    206
    +        if (screen.torBootstrapButton2ShouldRestartApp) {
    
    207
    +            binding.torBootstrapButton2.text =
    
    208
    +                screen.torBootstrapButton2TextStringResource?.let {
    
    209
    +                    getString(
    
    210
    +                        it,
    
    211
    +                        getString(R.string.app_name),
    
    212
    +                    )
    
    213
    +                }
    
    214
    +        } else {
    
    215
    +            binding.torBootstrapButton2.text =
    
    216
    +                screen.torBootstrapButton2TextStringResource?.let {
    
    217
    +                    getString(
    
    218
    +                        it,
    
    219
    +                    )
    
    220
    +                }
    
    221
    +        }
    
    222
    +        binding.torBootstrapButton2.setOnClickListener {
    
    223
    +            viewModel.cancelTorBootstrap()
    
    224
    +            if (screen.torBootstrapButton2ShouldOpenSettings) {
    
    225
    +                openTorConnectionSettings()
    
    226
    +            } else if (screen.torBootstrapButton2ShouldRestartApp) {
    
    227
    +                restartApplication()
    
    228
    +            } else {
    
    229
    +                showScreen(ConnectAssistUiState.Configuring)
    
    230
    +            }
    
    180 231
             }
    
    181 232
         }
    
    182 233
     
    
    234
    +    private fun setSplashLogo(screen: ConnectAssistUiState) {
    
    235
    +        binding.wordmarkLogo.visibility = if (screen.wordmarkLogoVisible) View.VISIBLE else View.GONE
    
    236
    +    }
    
    237
    +
    
    183 238
         /**
    
    184 239
          * from https://stackoverflow.com/questions/10696986/how-to-set-the-part-of-the-text-view-is-clickable
    
    185 240
          */
    
    ... ... @@ -207,6 +262,7 @@ class TorConnectionAssistFragment : Fragment(), UserInteractionHandler {
    207 262
         }
    
    208 263
     
    
    209 264
         private fun showLearnMore() {
    
    265
    +        Log.d(TAG, "showLearnMore() tapped")
    
    210 266
             //TODO("Not yet implemented")
    
    211 267
         }
    
    212 268
     
    
    ... ... @@ -231,6 +287,15 @@ class TorConnectionAssistFragment : Fragment(), UserInteractionHandler {
    231 287
             )
    
    232 288
         }
    
    233 289
     
    
    290
    +    private fun restartApplication() {
    
    291
    +        startActivity(
    
    292
    +            Intent(requireContext(), HomeActivity::class.java).addFlags(
    
    293
    +                Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK,
    
    294
    +            ),
    
    295
    +        )
    
    296
    +        Runtime.getRuntime().exit(0)
    
    297
    +    }
    
    298
    +
    
    234 299
         override fun onBackPressed(): Boolean {
    
    235 300
             return viewModel.handleBackButtonPressed()
    
    236 301
         }
    

  • fenix/app/src/main/java/org/mozilla/fenix/tor/TorConnectionAssistViewModel.kt
    ... ... @@ -124,7 +124,7 @@ class TorConnectionAssistViewModel(
    124 124
                     /** stay here */
    
    125 125
                 }
    
    126 126
     
    
    127
    -            ConnectAssistUiState.TryABridge -> {
    
    127
    +            ConnectAssistUiState.ConnectionAssist -> {
    
    128 128
                     _torConnectScreen.value = ConnectAssistUiState.TryingABridge
    
    129 129
                 }
    
    130 130
     
    
    ... ... @@ -144,7 +144,7 @@ class TorConnectionAssistViewModel(
    144 144
                     /** stay here */
    
    145 145
                 }
    
    146 146
     
    
    147
    -            else -> _torConnectScreen.value = ConnectAssistUiState.Bootstrapping
    
    147
    +            else -> _torConnectScreen.value = ConnectAssistUiState.Connecting
    
    148 148
             }
    
    149 149
         }
    
    150 150
     
    
    ... ... @@ -155,28 +155,58 @@ class TorConnectionAssistViewModel(
    155 155
                     "TorError(message = $message, details = $details, phase = $phase, reason = $reason",
    
    156 156
                 )
    
    157 157
                 // TODO better error handling
    
    158
    -            _torConnectScreen.value = ConnectAssistUiState.InternetError
    
    158
    +            when (reason) {
    
    159
    +//                "noroute" -> handleNoRoute() TODO re-add when working better
    
    160
    +                else -> handleUnknownError()
    
    161
    +            }
    
    162
    +        }
    
    163
    +    }
    
    164
    +
    
    165
    +    private fun handleNoRoute() {
    
    166
    +        Log.d(TAG, "handleNoRoute(), _torConnectScreen.value = ${_torConnectScreen.value}")
    
    167
    +        when (_torConnectScreen.value) {
    
    168
    +            ConnectAssistUiState.Connecting -> _torConnectScreen.value = ConnectAssistUiState.ConnectionAssist
    
    169
    +            ConnectAssistUiState.ConnectionAssist -> {/** no op, likely a duplicate error */}
    
    170
    +            ConnectAssistUiState.TryingABridge -> _torConnectScreen.value = ConnectAssistUiState.LocationCheck
    
    171
    +            ConnectAssistUiState.LocationCheck -> {/** no op, likely a duplicate error */}
    
    172
    +            ConnectAssistUiState.LastTry -> _torConnectScreen.value = ConnectAssistUiState.FinalError
    
    173
    +            ConnectAssistUiState.FinalError -> {/** no op, likely a duplicate error */}
    
    174
    +            else -> _torConnectScreen.value = ConnectAssistUiState.InternetError
    
    159 175
             }
    
    160 176
         }
    
    161 177
     
    
    178
    +    private fun handleUnknownError() {
    
    179
    +        // TODO should we have a dedicated screen for unknown errors?
    
    180
    +        _torConnectScreen.value = ConnectAssistUiState.InternetError
    
    181
    +    }
    
    182
    +
    
    162 183
         override fun onTorStopped() {
    
    163 184
             Log.d(TAG, "onTorStopped()")
    
    164 185
         }
    
    165 186
     
    
    166 187
         private fun tryABridge() {
    
    188
    +        if (!locationFound()) {
    
    189
    +            _torConnectScreen.value = ConnectAssistUiState.LocationError
    
    190
    +            return
    
    191
    +        }
    
    167 192
             if (!_torController.bridgesEnabled) {
    
    168 193
                 _torController.bridgesEnabled = true
    
    169 194
                 _torController.bridgeTransport =
    
    170
    -                TorBridgeTransportConfig.BUILTIN_OBFS4 // TODO select based on country
    
    195
    +                TorBridgeTransportConfig.BUILTIN_SNOWFLAKE // TODO select based on country
    
    171 196
             }
    
    172 197
             handleConnect(withDebugLogging = true)
    
    173 198
         }
    
    174 199
     
    
    200
    +    private fun locationFound(): Boolean {
    
    201
    +        // TODO try to find location
    
    202
    +        return true
    
    203
    +    }
    
    204
    +
    
    175 205
         fun handleBackButtonPressed(): Boolean {
    
    176 206
             when (torConnectScreen.value) {
    
    177 207
                 ConnectAssistUiState.Splash -> return false
    
    178 208
                 ConnectAssistUiState.Configuring -> return false
    
    179
    -            ConnectAssistUiState.Bootstrapping -> cancelTorBootstrap()
    
    209
    +            ConnectAssistUiState.Connecting -> cancelTorBootstrap()
    
    180 210
                 ConnectAssistUiState.InternetError -> {
    
    181 211
                     _torController.lastKnownError = null
    
    182 212
                     _torConnectScreen.value = ConnectAssistUiState.Configuring
    
    ... ... @@ -186,18 +216,18 @@ class TorConnectionAssistViewModel(
    186 216
                     cancelTorBootstrap()
    
    187 217
                 }
    
    188 218
     
    
    189
    -            ConnectAssistUiState.TryABridge -> {
    
    219
    +            ConnectAssistUiState.ConnectionAssist -> {
    
    190 220
                     _torController.lastKnownError = null
    
    191 221
                     _torConnectScreen.value = ConnectAssistUiState.Configuring
    
    192 222
                 }
    
    193 223
     
    
    194 224
                 ConnectAssistUiState.TryingABridge -> {
    
    195 225
                     _torController.stopTor()
    
    196
    -                _torConnectScreen.value = ConnectAssistUiState.TryABridge
    
    226
    +                _torConnectScreen.value = ConnectAssistUiState.ConnectionAssist
    
    197 227
                 }
    
    198 228
     
    
    199 229
                 ConnectAssistUiState.LocationError -> {
    
    200
    -                _torConnectScreen.value = ConnectAssistUiState.TryABridge
    
    230
    +                _torConnectScreen.value = ConnectAssistUiState.ConnectionAssist
    
    201 231
                 }
    
    202 232
     
    
    203 233
                 ConnectAssistUiState.LocationCheck -> {
    

  • fenix/app/src/main/res/layout/fragment_tor_connection_assist.xml
    ... ... @@ -126,7 +126,6 @@
    126 126
             android:layout_marginTop="8dp"
    
    127 127
             android:layout_marginEnd="24dp"
    
    128 128
             android:textColor="@color/photonLightGrey05"
    
    129
    -        android:tooltipText="@string/connection_assist_share_my_location_country_or_region"
    
    130 129
             android:visibility="gone"
    
    131 130
             app:layout_constraintEnd_toEndOf="parent"
    
    132 131
             app:layout_constraintStart_toStartOf="parent"
    

  • _______________________________________________
    tor-commits mailing list
    tor-commits@xxxxxxxxxxxxxxxxxxxx
    https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits