Commits:
6 changed files:
Changes:
fenix/app/src/main/java/org/mozilla/fenix/tor/ConnectAssistUiState.kt
|
1
|
+package org.mozilla.fenix.tor
|
|
2
|
+
|
|
3
|
+import androidx.annotation.ColorRes
|
|
4
|
+import androidx.annotation.DrawableRes
|
|
5
|
+import androidx.annotation.IntRange
|
|
6
|
+import androidx.annotation.StringRes
|
|
7
|
+import org.mozilla.fenix.R
|
|
8
|
+
|
|
9
|
+enum class ConnectAssistUiState(
|
|
10
|
+ val progressBarVisible: Boolean,
|
|
11
|
+ @IntRange(0, 100) var progress: Int = 0,
|
|
12
|
+ @ColorRes val progressTintColorResource: Int? = null,
|
|
13
|
+ val backButtonVisible: Boolean,
|
|
14
|
+ val settingsButtonVisible: Boolean,
|
|
15
|
+ val torConnectImageVisible: Boolean,
|
|
16
|
+ @DrawableRes val torConnectImageResource: Int = R.drawable.connect,
|
|
17
|
+ val titleLargeTextViewVisible: Boolean,
|
|
18
|
+ @StringRes val titleLargeTextViewTextStringResource: Int = R.string.connection_assist_tor_connect_title,
|
|
19
|
+ val titleDescriptionVisible: Boolean,
|
|
20
|
+ @StringRes val learnMoreStringResource: Int? = null,
|
|
21
|
+ @StringRes val internetErrorDescription: Int? = null,
|
|
22
|
+ @StringRes val internetErrorDescription1: Int? = null,
|
|
23
|
+ @StringRes val internetErrorDescription2: Int? = null,
|
|
24
|
+ @StringRes val titleDescriptionTextStringResource: Int? = R.string.preferences_tor_network_settings_explanation,
|
|
25
|
+ val quickstartSwitchVisible: Boolean,
|
|
26
|
+ val unblockTheInternetInCountryDescriptionVisible: Boolean,
|
|
27
|
+ val countryDropDownVisible: Boolean,
|
|
28
|
+ val torBootstrapButton1Visible: Boolean,
|
|
29
|
+ @StringRes val torBootstrapButton1TextStringResource: Int = R.string.tor_bootstrap_connect,
|
|
30
|
+ val torBootstrapButton1ShouldShowTryingABridge: Boolean = false,
|
|
31
|
+ val torBootstrapButton2Visible: Boolean,
|
|
32
|
+ @StringRes val torBootstrapButton2TextStringResource: Int? = R.string.connection_assist_configure_connection_button,
|
|
33
|
+ val torBootstrapButton2ShouldOpenSettings: Boolean = true,
|
|
34
|
+ val wordmarkLogoVisible: Boolean,
|
|
35
|
+) {
|
|
36
|
+ Splash(
|
|
37
|
+ progressBarVisible = false,
|
|
38
|
+ backButtonVisible = false,
|
|
39
|
+ settingsButtonVisible = false,
|
|
40
|
+ torConnectImageVisible = false,
|
|
41
|
+ titleLargeTextViewVisible = false,
|
|
42
|
+ titleDescriptionVisible = false,
|
|
43
|
+ quickstartSwitchVisible = false,
|
|
44
|
+ unblockTheInternetInCountryDescriptionVisible = false,
|
|
45
|
+ countryDropDownVisible = false,
|
|
46
|
+ torBootstrapButton1Visible = false,
|
|
47
|
+ torBootstrapButton2Visible = false,
|
|
48
|
+ wordmarkLogoVisible = true,
|
|
49
|
+ ),
|
|
50
|
+ Configuring(
|
|
51
|
+ progressBarVisible = false,
|
|
52
|
+ progress = 0,
|
|
53
|
+ backButtonVisible = false,
|
|
54
|
+ settingsButtonVisible = true,
|
|
55
|
+ torConnectImageVisible = true,
|
|
56
|
+ torConnectImageResource = R.drawable.connect,
|
|
57
|
+ titleLargeTextViewVisible = true,
|
|
58
|
+ titleLargeTextViewTextStringResource = R.string.connection_assist_tor_connect_title,
|
|
59
|
+ titleDescriptionVisible = true,
|
|
60
|
+ titleDescriptionTextStringResource = R.string.preferences_tor_network_settings_explanation,
|
|
61
|
+ quickstartSwitchVisible = true,
|
|
62
|
+ unblockTheInternetInCountryDescriptionVisible = false,
|
|
63
|
+ countryDropDownVisible = false,
|
|
64
|
+ torBootstrapButton1Visible = true,
|
|
65
|
+ torBootstrapButton2Visible = true,
|
|
66
|
+ torBootstrapButton2TextStringResource = R.string.connection_assist_configure_connection_button,
|
|
67
|
+ torBootstrapButton2ShouldOpenSettings = true,
|
|
68
|
+ wordmarkLogoVisible = false,
|
|
69
|
+ ),
|
|
70
|
+ Bootstrapping(
|
|
71
|
+ progressBarVisible = true,
|
|
72
|
+ progress = 0,
|
|
73
|
+ backButtonVisible = false,
|
|
74
|
+ settingsButtonVisible = true,
|
|
75
|
+ torConnectImageVisible = true,
|
|
76
|
+ torConnectImageResource = R.drawable.connect,
|
|
77
|
+ titleLargeTextViewVisible = true,
|
|
78
|
+ titleLargeTextViewTextStringResource = R.string.connection_assist_connecting_title,
|
|
79
|
+ titleDescriptionVisible = true,
|
|
80
|
+ titleDescriptionTextStringResource = R.string.preferences_tor_network_settings_explanation,
|
|
81
|
+ quickstartSwitchVisible = true,
|
|
82
|
+ unblockTheInternetInCountryDescriptionVisible = false,
|
|
83
|
+ countryDropDownVisible = false,
|
|
84
|
+ torBootstrapButton1Visible = false,
|
|
85
|
+ torBootstrapButton2Visible = true,
|
|
86
|
+ torBootstrapButton2TextStringResource = R.string.btn_cancel,
|
|
87
|
+ torBootstrapButton2ShouldOpenSettings = false,
|
|
88
|
+ wordmarkLogoVisible = false,
|
|
89
|
+ ),
|
|
90
|
+ InternetError(
|
|
91
|
+ progressBarVisible = true,
|
|
92
|
+ progress = 100,
|
|
93
|
+ progressTintColorResource = R.color.warning_yellow,
|
|
94
|
+ backButtonVisible = true,
|
|
95
|
+ settingsButtonVisible = true,
|
|
96
|
+ torConnectImageVisible = true,
|
|
97
|
+ torConnectImageResource = R.drawable.globe_broken,
|
|
98
|
+ titleLargeTextViewVisible = true,
|
|
99
|
+ titleLargeTextViewTextStringResource = R.string.connection_assist_internet_error_title,
|
|
100
|
+ titleDescriptionVisible = true,
|
|
101
|
+ learnMoreStringResource = R.string.connection_assist_internet_error_learn_more,
|
|
102
|
+ internetErrorDescription = R.string.connection_assist_internet_error_description,
|
|
103
|
+ titleDescriptionTextStringResource = null,
|
|
104
|
+ quickstartSwitchVisible = false,
|
|
105
|
+ unblockTheInternetInCountryDescriptionVisible = false,
|
|
106
|
+ countryDropDownVisible = false,
|
|
107
|
+ torBootstrapButton1Visible = true,
|
|
108
|
+ torBootstrapButton1TextStringResource = R.string.connection_assist_internet_error_try_again,
|
|
109
|
+ torBootstrapButton2Visible = true,
|
|
110
|
+ torBootstrapButton2TextStringResource = R.string.connection_assist_configure_connection_button,
|
|
111
|
+ torBootstrapButton2ShouldOpenSettings = true,
|
|
112
|
+ wordmarkLogoVisible = false,
|
|
113
|
+ ),
|
|
114
|
+ TryingAgain(
|
|
115
|
+ progressBarVisible = true,
|
|
116
|
+ progress = 0,
|
|
117
|
+ progressTintColorResource = null,
|
|
118
|
+ backButtonVisible = true,
|
|
119
|
+ settingsButtonVisible = true,
|
|
120
|
+ torConnectImageVisible = true,
|
|
121
|
+ torConnectImageResource = R.drawable.connect,
|
|
122
|
+ titleLargeTextViewVisible = true,
|
|
123
|
+ titleLargeTextViewTextStringResource = R.string.connection_assist_trying_again_waiting_title,
|
|
124
|
+ titleDescriptionVisible = true,
|
|
125
|
+ learnMoreStringResource = R.string.connection_assist_internet_error_learn_more,
|
|
126
|
+ internetErrorDescription = R.string.connection_assist_internet_error_description,
|
|
127
|
+ titleDescriptionTextStringResource = null,
|
|
128
|
+ quickstartSwitchVisible = false,
|
|
129
|
+ unblockTheInternetInCountryDescriptionVisible = false,
|
|
130
|
+ countryDropDownVisible = false,
|
|
131
|
+ torBootstrapButton1Visible = false,
|
|
132
|
+ torBootstrapButton2Visible = true,
|
|
133
|
+ torBootstrapButton2TextStringResource = R.string.btn_cancel,
|
|
134
|
+ torBootstrapButton2ShouldOpenSettings = false,
|
|
135
|
+ wordmarkLogoVisible = false,
|
|
136
|
+ ),
|
|
137
|
+ TryABridge(
|
|
138
|
+ progressBarVisible = true,
|
|
139
|
+ progress = 100,
|
|
140
|
+ progressTintColorResource = R.color.warning_yellow,
|
|
141
|
+ backButtonVisible = true,
|
|
142
|
+ settingsButtonVisible = true,
|
|
143
|
+ torConnectImageVisible = true,
|
|
144
|
+ torConnectImageResource = R.drawable.connect_broken,
|
|
145
|
+ titleLargeTextViewVisible = true,
|
|
146
|
+ titleLargeTextViewTextStringResource = R.string.connection_assist_cant_connect_to_tor_title,
|
|
147
|
+ titleDescriptionVisible = true,
|
|
148
|
+ learnMoreStringResource = R.string.connection_assist_internet_error_learn_more,
|
|
149
|
+ internetErrorDescription = R.string.connection_assist_try_a_bridge_description,
|
|
150
|
+ titleDescriptionTextStringResource = null,
|
|
151
|
+ quickstartSwitchVisible = false,
|
|
152
|
+ unblockTheInternetInCountryDescriptionVisible = true,
|
|
153
|
+ countryDropDownVisible = true,
|
|
154
|
+ torBootstrapButton1Visible = true,
|
|
155
|
+ torBootstrapButton1TextStringResource = R.string.connection_assist_try_a_bridge_button,
|
|
156
|
+ torBootstrapButton1ShouldShowTryingABridge = true,
|
|
157
|
+ torBootstrapButton2Visible = false,
|
|
158
|
+ torBootstrapButton2TextStringResource = null,
|
|
159
|
+ torBootstrapButton2ShouldOpenSettings = true,
|
|
160
|
+ wordmarkLogoVisible = false,
|
|
161
|
+ ),
|
|
162
|
+ TryingABridge(
|
|
163
|
+ progressBarVisible = true,
|
|
164
|
+ progress = 0,
|
|
165
|
+ progressTintColorResource = null,
|
|
166
|
+ backButtonVisible = true,
|
|
167
|
+ settingsButtonVisible = true,
|
|
168
|
+ torConnectImageVisible = true,
|
|
169
|
+ torConnectImageResource = R.drawable.connect,
|
|
170
|
+ titleLargeTextViewVisible = true,
|
|
171
|
+ titleLargeTextViewTextStringResource = R.string.connection_assist_trying_a_bridge_title,
|
|
172
|
+ titleDescriptionVisible = true,
|
|
173
|
+ learnMoreStringResource = R.string.connection_assist_internet_error_learn_more,
|
|
174
|
+ internetErrorDescription = R.string.connection_assist_try_a_bridge_description,
|
|
175
|
+ titleDescriptionTextStringResource = null,
|
|
176
|
+ quickstartSwitchVisible = true,
|
|
177
|
+ unblockTheInternetInCountryDescriptionVisible = false,
|
|
178
|
+ countryDropDownVisible = false,
|
|
179
|
+ torBootstrapButton1Visible = false,
|
|
180
|
+ torBootstrapButton2Visible = true,
|
|
181
|
+ torBootstrapButton2TextStringResource = R.string.btn_cancel,
|
|
182
|
+ torBootstrapButton2ShouldOpenSettings = false,
|
|
183
|
+ wordmarkLogoVisible = false,
|
|
184
|
+ ),
|
|
185
|
+ LocationError(
|
|
186
|
+ progressBarVisible = true,
|
|
187
|
+ progress = 100,
|
|
188
|
+ progressTintColorResource = R.color.warning_yellow,
|
|
189
|
+ backButtonVisible = true,
|
|
190
|
+ settingsButtonVisible = true,
|
|
191
|
+ torConnectImageVisible = true,
|
|
192
|
+ torConnectImageResource = R.drawable.browser_location,
|
|
193
|
+ titleLargeTextViewVisible = true,
|
|
194
|
+ titleLargeTextViewTextStringResource = R.string.connection_assist_location_error_title,
|
|
195
|
+ titleDescriptionVisible = true,
|
|
196
|
+ learnMoreStringResource = R.string.connection_assist_location_error_learn_more_link,
|
|
197
|
+ internetErrorDescription = R.string.connection_assist_location_error_description,
|
|
198
|
+ internetErrorDescription1 = R.string.connection_assist_find_bridge_location_description,
|
|
199
|
+ internetErrorDescription2 = R.string.connection_assist_select_country_try_again,
|
|
200
|
+ titleDescriptionTextStringResource = null,
|
|
201
|
+ quickstartSwitchVisible = false,
|
|
202
|
+ unblockTheInternetInCountryDescriptionVisible = true,
|
|
203
|
+ countryDropDownVisible = true,
|
|
204
|
+ torBootstrapButton1Visible = true,
|
|
205
|
+ torBootstrapButton1TextStringResource = R.string.connection_assist_try_a_bridge_button,
|
|
206
|
+ torBootstrapButton1ShouldShowTryingABridge = true,
|
|
207
|
+ torBootstrapButton2Visible = false,
|
|
208
|
+ torBootstrapButton2TextStringResource = null,
|
|
209
|
+ torBootstrapButton2ShouldOpenSettings = true,
|
|
210
|
+ wordmarkLogoVisible = false,
|
|
211
|
+ ),
|
|
212
|
+ LocationCheck(
|
|
213
|
+ progressBarVisible = true,
|
|
214
|
+ progress = 100,
|
|
215
|
+ progressTintColorResource = R.color.warning_yellow,
|
|
216
|
+ backButtonVisible = true,
|
|
217
|
+ settingsButtonVisible = true,
|
|
218
|
+ torConnectImageVisible = true,
|
|
219
|
+ torConnectImageResource = R.drawable.browser_location,
|
|
220
|
+ titleLargeTextViewVisible = true,
|
|
221
|
+ titleLargeTextViewTextStringResource = R.string.connection_assist_location_check_title,
|
|
222
|
+ titleDescriptionVisible = true,
|
|
223
|
+ learnMoreStringResource = R.string.connection_assist_location_error_learn_more_link,
|
|
224
|
+ internetErrorDescription = R.string.connection_assist_location_error_description,
|
|
225
|
+ internetErrorDescription1 = R.string.connection_assist_find_bridge_location_description,
|
|
226
|
+ internetErrorDescription2 = R.string.connection_assist_select_country_try_again,
|
|
227
|
+ titleDescriptionTextStringResource = null,
|
|
228
|
+ quickstartSwitchVisible = false,
|
|
229
|
+ unblockTheInternetInCountryDescriptionVisible = true,
|
|
230
|
+ countryDropDownVisible = true,
|
|
231
|
+ torBootstrapButton1Visible = true,
|
|
232
|
+ torBootstrapButton1TextStringResource = R.string.connection_assist_try_a_bridge_button,
|
|
233
|
+ torBootstrapButton1ShouldShowTryingABridge = true,
|
|
234
|
+ torBootstrapButton2Visible = false,
|
|
235
|
+ torBootstrapButton2TextStringResource = null,
|
|
236
|
+ torBootstrapButton2ShouldOpenSettings = true,
|
|
237
|
+ wordmarkLogoVisible = false,
|
|
238
|
+ ),
|
|
239
|
+ LastTry(
|
|
240
|
+ progressBarVisible = true,
|
|
241
|
+ progress = 0,
|
|
242
|
+ backButtonVisible = true,
|
|
243
|
+ settingsButtonVisible = true,
|
|
244
|
+ torConnectImageVisible = true,
|
|
245
|
+ torConnectImageResource = R.drawable.connect,
|
|
246
|
+ titleLargeTextViewVisible = true,
|
|
247
|
+ titleLargeTextViewTextStringResource = R.string.connection_assist_last_try_title,
|
|
248
|
+ titleDescriptionVisible = true,
|
|
249
|
+ learnMoreStringResource = R.string.connection_assist_location_error_learn_more_link,
|
|
250
|
+ internetErrorDescription = R.string.connection_assist_location_error_description,
|
|
251
|
+ internetErrorDescription1 = R.string.connection_assist_find_bridge_location_description,
|
|
252
|
+ internetErrorDescription2 = R.string.connection_assist_select_country_try_again,
|
|
253
|
+ titleDescriptionTextStringResource = null,
|
|
254
|
+ quickstartSwitchVisible = true,
|
|
255
|
+ unblockTheInternetInCountryDescriptionVisible = false,
|
|
256
|
+ countryDropDownVisible = false,
|
|
257
|
+ torBootstrapButton1Visible = false,
|
|
258
|
+ torBootstrapButton2Visible = true,
|
|
259
|
+ torBootstrapButton2TextStringResource = R.string.btn_cancel,
|
|
260
|
+ torBootstrapButton2ShouldOpenSettings = false,
|
|
261
|
+ wordmarkLogoVisible = false,
|
|
262
|
+ ),
|
|
263
|
+ FinalError(
|
|
264
|
+ progressBarVisible = true,
|
|
265
|
+ progress = 100,
|
|
266
|
+ progressTintColorResource = R.color.warning_yellow,
|
|
267
|
+ backButtonVisible = true,
|
|
268
|
+ settingsButtonVisible = true,
|
|
269
|
+ torConnectImageVisible = true,
|
|
270
|
+ torConnectImageResource = R.drawable.connect_broken,
|
|
271
|
+ titleLargeTextViewVisible = true,
|
|
272
|
+ titleLargeTextViewTextStringResource = R.string.connection_assist_final_error_title,
|
|
273
|
+ titleDescriptionVisible = true,
|
|
274
|
+ learnMoreStringResource = R.string.connection_assist_final_error_learn_more_link,
|
|
275
|
+ internetErrorDescription = R.string.connection_assist_final_error_description1,
|
|
276
|
+ internetErrorDescription1 = R.string.connection_assist_final_error_troubleshoot_connection_link,
|
|
277
|
+ titleDescriptionTextStringResource = null,
|
|
278
|
+ quickstartSwitchVisible = false,
|
|
279
|
+ unblockTheInternetInCountryDescriptionVisible = false,
|
|
280
|
+ countryDropDownVisible = false,
|
|
281
|
+ torBootstrapButton1Visible = true,
|
|
282
|
+ torBootstrapButton1TextStringResource = R.string.connection_assist_internet_error_try_again,
|
|
283
|
+ torBootstrapButton2Visible = true,
|
|
284
|
+ torBootstrapButton2TextStringResource = R.string.connection_assist_configure_connection_button,
|
|
285
|
+ torBootstrapButton2ShouldOpenSettings = true,
|
|
286
|
+ wordmarkLogoVisible = false,
|
|
287
|
+ )
|
|
288
|
+} |
fenix/app/src/main/java/org/mozilla/fenix/tor/TorConnectionAssistFragment.kt
... |
... |
@@ -24,27 +24,35 @@ import androidx.lifecycle.lifecycleScope |
24
|
24
|
import androidx.lifecycle.repeatOnLifecycle
|
25
|
25
|
import androidx.navigation.fragment.findNavController
|
26
|
26
|
import kotlinx.coroutines.launch
|
|
27
|
+import mozilla.components.support.base.feature.UserInteractionHandler
|
27
|
28
|
import org.mozilla.fenix.R
|
28
|
29
|
import org.mozilla.fenix.databinding.FragmentTorConnectionAssistBinding
|
29
|
30
|
import org.mozilla.fenix.ext.hideToolbar
|
30
|
31
|
|
31
|
|
-class TorConnectionAssistFragment : Fragment() {
|
|
32
|
+class TorConnectionAssistFragment : Fragment(), UserInteractionHandler {
|
32
|
33
|
|
33
|
34
|
private val TAG = "TorConnectionAssistFrag"
|
34
|
|
- private var _binding: FragmentTorConnectionAssistBinding? = null
|
35
|
|
- private val binding get() = _binding!!
|
36
|
|
-
|
37
|
35
|
private val viewModel: TorConnectionAssistViewModel by viewModels()
|
|
36
|
+ private lateinit var binding: FragmentTorConnectionAssistBinding
|
38
|
37
|
|
39
|
38
|
override fun onCreateView(
|
40
|
39
|
inflater: LayoutInflater,
|
41
|
40
|
container: ViewGroup?,
|
42
|
41
|
savedInstanceState: Bundle?,
|
43
|
42
|
): View {
|
44
|
|
- _binding = FragmentTorConnectionAssistBinding.inflate(
|
|
43
|
+ binding = FragmentTorConnectionAssistBinding.inflate(
|
45
|
44
|
inflater, container, false,
|
46
|
45
|
)
|
47
|
46
|
|
|
47
|
+ viewLifecycleOwner.lifecycleScope.launch {
|
|
48
|
+ repeatOnLifecycle(Lifecycle.State.STARTED) {
|
|
49
|
+ viewModel.torConnectScreen.collect { screen ->
|
|
50
|
+ Log.d(TAG, "torConnectScreen is $screen")
|
|
51
|
+ showScreen(screen)
|
|
52
|
+ }
|
|
53
|
+ }
|
|
54
|
+ }
|
|
55
|
+
|
48
|
56
|
return binding.root
|
49
|
57
|
}
|
50
|
58
|
|
... |
... |
@@ -56,23 +64,6 @@ class TorConnectionAssistFragment : Fragment() { |
56
|
64
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
57
|
65
|
super.onViewCreated(view, savedInstanceState)
|
58
|
66
|
|
59
|
|
- lifecycleScope.launch {
|
60
|
|
- repeatOnLifecycle(Lifecycle.State.STARTED) {
|
61
|
|
- viewModel.torConnectState.collect { torConnectState ->
|
62
|
|
- Log.d(TAG, "torConnectState is ${torConnectState.state}")
|
63
|
|
- when (torConnectState) {
|
64
|
|
- TorConnectState.Initial -> showSplash()
|
65
|
|
- TorConnectState.Configuring -> showConfiguring()
|
66
|
|
- TorConnectState.AutoBootstrapping -> showBootstrapping()
|
67
|
|
- TorConnectState.Bootstrapping -> showBootstrapping()
|
68
|
|
- TorConnectState.Error -> showError()
|
69
|
|
- TorConnectState.Bootstrapped -> openHome()
|
70
|
|
- TorConnectState.Disabled -> openHome()
|
71
|
|
- }
|
72
|
|
- }
|
73
|
|
- }
|
74
|
|
- }
|
75
|
|
-
|
76
|
67
|
viewModel.progress().observe(
|
77
|
68
|
viewLifecycleOwner,
|
78
|
69
|
) { progress ->
|
... |
... |
@@ -88,243 +79,96 @@ class TorConnectionAssistFragment : Fragment() { |
88
|
79
|
) {
|
89
|
80
|
binding.quickstartSwitch.isChecked = it == true
|
90
|
81
|
}
|
91
|
|
-
|
92
|
|
- binding.quickstartSwitch.setOnCheckedChangeListener { _, isChecked ->
|
93
|
|
- viewModel.handleQuickstartChecked(isChecked)
|
94
|
|
- }
|
95
|
82
|
}
|
96
|
83
|
|
97
|
|
-
|
98
|
|
- private fun showSplash() {
|
99
|
|
- binding.torBootstrapProgressBar.visibility = View.GONE
|
100
|
|
- binding.settingsButton.visibility = View.GONE
|
101
|
|
- binding.backButton.visibility = View.GONE
|
102
|
|
- binding.torConnectImage.visibility = View.GONE
|
103
|
|
- binding.titleLargeTextView.visibility = View.GONE
|
104
|
|
- binding.titleDescription.visibility = View.GONE
|
105
|
|
- binding.quickstartSwitch.visibility = View.GONE
|
106
|
|
- binding.torBootstrapButton1.visibility = View.GONE
|
107
|
|
- binding.torBootstrapButton2.visibility = View.GONE
|
108
|
|
- binding.wordmarkLogo.visibility = View.VISIBLE
|
|
84
|
+ override fun onDestroyView() {
|
|
85
|
+ super.onDestroyView()
|
109
|
86
|
}
|
110
|
87
|
|
|
88
|
+ private fun showScreen(screen: ConnectAssistUiState) {
|
|
89
|
+ binding.apply {
|
|
90
|
+ torBootstrapProgressBar.visibility = if (screen.progressBarVisible) View.VISIBLE else View.GONE
|
|
91
|
+ torBootstrapProgressBar.progress = screen.progress
|
|
92
|
+ torBootstrapProgressBar.progressTintList =
|
|
93
|
+ screen.progressTintColorResource?.let {
|
|
94
|
+ AppCompatResources.getColorStateList(requireContext(),
|
|
95
|
+ it
|
|
96
|
+ )
|
|
97
|
+ }
|
111
|
98
|
|
112
|
|
- private fun showConfiguring() {
|
113
|
|
- binding.wordmarkLogo.visibility = View.GONE
|
114
|
|
-
|
115
|
|
- binding.torBootstrapProgressBar.visibility = View.INVISIBLE
|
116
|
|
- binding.torBootstrapProgressBar.progress = 0
|
117
|
|
- binding.backButton.visibility = View.INVISIBLE
|
118
|
|
- binding.settingsButton.visibility = View.VISIBLE
|
119
|
|
- binding.settingsButton.setOnClickListener {
|
120
|
|
- viewModel.cancelTorBootstrap()
|
121
|
|
- openSettings()
|
122
|
|
- }
|
123
|
|
- binding.torConnectImage.visibility = View.VISIBLE
|
124
|
|
- binding.torConnectImage.setImageResource(R.drawable.connect)
|
125
|
|
- binding.titleLargeTextView.visibility = View.VISIBLE
|
126
|
|
- binding.titleLargeTextView.text = getString(R.string.connection_assist_tor_connect_title)
|
127
|
|
- binding.titleDescription.visibility = View.VISIBLE
|
128
|
|
- binding.titleDescription.text =
|
129
|
|
- getString(R.string.preferences_tor_network_settings_explanation)
|
130
|
|
- binding.quickstartSwitch.visibility = View.VISIBLE
|
131
|
|
- binding.quickstartSwitch.isChecked = viewModel.quickstartToggle().value == true
|
132
|
|
-
|
133
|
|
- binding.unblockTheInternetInCountryDescription.visibility = View.GONE
|
134
|
|
- binding.countryDropDown.visibility = View.GONE
|
|
99
|
+ settingsButton.visibility = if (screen.settingsButtonVisible) View.VISIBLE else View.GONE
|
|
100
|
+ settingsButton.setOnClickListener {
|
|
101
|
+ viewModel.cancelTorBootstrap()
|
|
102
|
+ openSettings()
|
|
103
|
+ }
|
135
|
104
|
|
136
|
|
- binding.torBootstrapButton1.visibility = View.VISIBLE
|
137
|
|
- binding.torBootstrapButton1.text = getString(R.string.tor_bootstrap_connect)
|
138
|
|
- binding.torBootstrapButton1.setOnClickListener {
|
139
|
|
- viewModel.handleConnect(lifecycleScope = lifecycleScope)
|
140
|
|
- showBootstrapping()
|
141
|
|
- }
|
|
105
|
+ backButton.visibility = if (screen.backButtonVisible) View.VISIBLE else View.INVISIBLE
|
|
106
|
+ backButton.setOnClickListener {
|
|
107
|
+ viewModel.handleBackButtonPressed()
|
|
108
|
+ }
|
142
|
109
|
|
143
|
|
- binding.torBootstrapButton2.visibility = View.VISIBLE
|
144
|
|
- binding.torBootstrapButton2.text =
|
145
|
|
- getString(R.string.connection_assist_configure_connection_button)
|
146
|
|
- binding.torBootstrapButton2.setOnClickListener {
|
147
|
|
- viewModel.cancelTorBootstrap()
|
148
|
|
- openTorConnectionSettings()
|
149
|
|
- }
|
150
|
|
- }
|
|
110
|
+ torConnectImage.visibility = if (screen.torConnectImageVisible) View.VISIBLE else View.GONE
|
|
111
|
+ torConnectImage.setImageResource(screen.torConnectImageResource)
|
|
112
|
+
|
|
113
|
+ titleLargeTextView.visibility = if (screen.titleLargeTextViewVisible) View.VISIBLE else View.GONE
|
|
114
|
+ titleLargeTextView.text = getString(screen.titleLargeTextViewTextStringResource)
|
|
115
|
+ titleDescription.visibility = if (screen.titleDescriptionVisible) View.VISIBLE else View.GONE
|
|
116
|
+ if (screen.learnMoreStringResource != null && screen.internetErrorDescription != null) {
|
|
117
|
+ val learnMore: String = getString(screen.learnMoreStringResource)
|
|
118
|
+ val internetErrorDescription: String =
|
|
119
|
+ if (screen.internetErrorDescription1 == null) {
|
|
120
|
+ getString(
|
|
121
|
+ screen.internetErrorDescription,
|
|
122
|
+ learnMore,
|
|
123
|
+ )
|
|
124
|
+ } else if (screen.internetErrorDescription2 == null) {
|
|
125
|
+ getString(
|
|
126
|
+ screen.internetErrorDescription,
|
|
127
|
+ getString(screen.internetErrorDescription1),
|
|
128
|
+ learnMore,
|
|
129
|
+ )
|
|
130
|
+ } else {
|
|
131
|
+ getString(
|
|
132
|
+ screen.internetErrorDescription,
|
|
133
|
+ getString(screen.internetErrorDescription1),
|
|
134
|
+ getString(screen.internetErrorDescription2),
|
|
135
|
+ learnMore,
|
|
136
|
+ )
|
|
137
|
+ }
|
|
138
|
+ handleDescriptionWithClickable(internetErrorDescription, learnMore)
|
|
139
|
+ } else if (screen.titleDescriptionTextStringResource != null) {
|
|
140
|
+ titleDescription.text = getString(screen.titleDescriptionTextStringResource)
|
|
141
|
+ }
|
|
142
|
+ quickstartSwitch.visibility = if (screen.quickstartSwitchVisible) View.VISIBLE else View.GONE
|
|
143
|
+ quickstartSwitch.isChecked = viewModel.quickstartToggle().value == true
|
|
144
|
+ quickstartSwitch.setOnCheckedChangeListener { _, isChecked ->
|
|
145
|
+ viewModel.handleQuickstartChecked(isChecked)
|
|
146
|
+ }
|
151
|
147
|
|
152
|
|
- private fun showBootstrapping() {
|
153
|
|
- binding.wordmarkLogo.visibility = View.GONE
|
|
148
|
+ unblockTheInternetInCountryDescription.visibility = if (screen.unblockTheInternetInCountryDescriptionVisible) View.VISIBLE else View.GONE
|
|
149
|
+ countryDropDown.visibility = if (screen.countryDropDownVisible) View.VISIBLE else View.GONE
|
154
|
150
|
|
155
|
|
- binding.torBootstrapProgressBar.visibility = View.VISIBLE
|
156
|
|
- binding.torBootstrapProgressBar.progress = 0
|
157
|
|
- binding.backButton.visibility = View.INVISIBLE
|
158
|
|
- binding.settingsButton.visibility = View.VISIBLE
|
159
|
|
- binding.settingsButton.setOnClickListener {
|
160
|
|
- viewModel.cancelTorBootstrap()
|
161
|
|
- openSettings()
|
162
|
|
- }
|
163
|
|
- binding.torConnectImage.visibility = View.VISIBLE
|
164
|
|
- binding.torConnectImage.setImageResource(R.drawable.connect)
|
165
|
|
- binding.titleLargeTextView.visibility = View.VISIBLE
|
166
|
|
- binding.titleLargeTextView.text = getString(R.string.connection_assist_connecting_title)
|
167
|
|
- binding.titleDescription.visibility = View.VISIBLE
|
168
|
|
- binding.titleDescription.text =
|
169
|
|
- getString(R.string.preferences_tor_network_settings_explanation)
|
170
|
|
- binding.quickstartSwitch.visibility = View.VISIBLE
|
171
|
|
- binding.quickstartSwitch.isChecked = viewModel.quickstartToggle().value == true
|
172
|
|
- binding.quickstartSwitch.jumpDrawablesToCurrentState()
|
173
|
|
- binding.torBootstrapButton1.visibility = View.INVISIBLE
|
174
|
|
- binding.torBootstrapButton2.visibility = View.VISIBLE
|
175
|
|
- binding.torBootstrapButton2.text = getString(R.string.btn_cancel)
|
176
|
|
- binding.torBootstrapButton2.setOnClickListener { viewModel.cancelTorBootstrap() }
|
177
|
|
- }
|
|
151
|
+ torBootstrapButton1.visibility = if (screen.torBootstrapButton1Visible) View.VISIBLE else View.GONE
|
|
152
|
+ torBootstrapButton1.text = getString(screen.torBootstrapButton1TextStringResource)
|
|
153
|
+ torBootstrapButton1.setOnClickListener { viewModel.handleButton1Pressed(screen, lifecycleScope) }
|
178
|
154
|
|
179
|
|
- private suspend fun showError() {
|
180
|
|
- viewModel.torError.collect {
|
181
|
|
- Log.d(
|
182
|
|
- TAG,
|
183
|
|
- "TorError: details = ${it?.details ?: "null details"}, message = ${it?.message ?: "null message"}",
|
184
|
|
- )
|
185
|
|
- when (viewModel.handleError(it)) {
|
186
|
|
- ErrorScreen.CantConnectToInternet -> showCantConnectToInternet()
|
187
|
|
- ErrorScreen.CantConnectToTorDirectly -> showCantConnectToTorDirectly()
|
188
|
|
- ErrorScreen.WeCouldntFindYourLocation -> showWeCouldntFindYourLocation()
|
189
|
|
- ErrorScreen.WereStillHavingTroubleConnecting -> showWereStillHavingTroubleConnecting()
|
190
|
|
- ErrorScreen.WeWerentAbleToConnectAutomatically -> showWeWerentAbleToConnectAutomatically()
|
191
|
|
- null -> {
|
192
|
|
- // no op
|
193
|
|
- Log.d(TAG, "ErrorScreen: null, nothing shown")
|
|
155
|
+ torBootstrapButton2.visibility = if (screen.torBootstrapButton2Visible) View.VISIBLE else View.GONE
|
|
156
|
+ torBootstrapButton2.text = screen.torBootstrapButton2TextStringResource?.let {
|
|
157
|
+ getString(
|
|
158
|
+ it
|
|
159
|
+ )
|
|
160
|
+ }
|
|
161
|
+ torBootstrapButton2.setOnClickListener {
|
|
162
|
+ viewModel.cancelTorBootstrap()
|
|
163
|
+ if (screen.torBootstrapButton2ShouldOpenSettings){
|
|
164
|
+ openTorConnectionSettings()
|
|
165
|
+ } else {
|
|
166
|
+ showScreen(ConnectAssistUiState.Configuring)
|
194
|
167
|
}
|
195
|
168
|
}
|
196
|
|
- }
|
197
|
|
- }
|
198
|
|
-
|
199
|
|
- private fun showCantConnectToInternet() {
|
200
|
|
- Log.d(TAG, "showCantConnectToInternet()")
|
201
|
|
- binding.torBootstrapProgressBar.visibility = View.VISIBLE
|
202
|
|
- binding.torBootstrapProgressBar.progressTintList =
|
203
|
|
- AppCompatResources.getColorStateList(requireContext(), R.color.warning_yellow)
|
204
|
|
- binding.torBootstrapProgressBar.progress = 100
|
205
|
|
-
|
206
|
|
- binding.backButton.visibility = View.VISIBLE
|
207
|
|
- binding.backButton.setOnClickListener {
|
208
|
|
- showConfiguring()
|
209
|
|
- }
|
210
|
|
-
|
211
|
|
- binding.torConnectImage.setImageResource(R.drawable.globe_broken)
|
212
|
|
- binding.titleLargeTextView.text = getString(R.string.connection_assist_internet_error_title)
|
213
|
169
|
|
214
|
|
- val learnMore: String = getString(R.string.connection_assist_internet_error_learn_more)
|
215
|
|
- val internetErrorDescription: String = getString(
|
216
|
|
- R.string.connection_assist_internet_error_description,
|
217
|
|
- learnMore,
|
218
|
|
- )
|
219
|
|
- handleDescriptionWithClickable(internetErrorDescription, learnMore)
|
220
|
|
-
|
221
|
|
- binding.quickstartSwitch.visibility = View.GONE
|
222
|
|
-
|
223
|
|
- binding.torBootstrapButton1.visibility = View.VISIBLE
|
224
|
|
- binding.torBootstrapButton1.text =
|
225
|
|
- getString(R.string.connection_assist_internet_error_try_again)
|
226
|
|
- binding.torBootstrapButton1.setOnClickListener {
|
227
|
|
- showTryingAgain()
|
228
|
|
- viewModel.handleConnect(lifecycleScope = lifecycleScope)
|
229
|
|
- }
|
230
|
|
-
|
231
|
|
- binding.torBootstrapButton2.text =
|
232
|
|
- getString(R.string.connection_assist_configure_connection_button)
|
233
|
|
- binding.torBootstrapButton2.setOnClickListener {
|
234
|
|
- openTorConnectionSettings()
|
235
|
|
- }
|
236
|
|
- }
|
237
|
|
-
|
238
|
|
- private fun showTryingAgain() {
|
239
|
|
- Log.d(TAG, "showTryingAgain()")
|
240
|
|
- binding.torBootstrapProgressBar.progress = 0
|
241
|
|
- binding.torBootstrapProgressBar.visibility = View.VISIBLE
|
242
|
|
- binding.torBootstrapProgressBar.progressTintList = null
|
243
|
|
- binding.torConnectImage.setImageResource(R.drawable.connect)
|
244
|
|
- binding.titleLargeTextView.text =
|
245
|
|
- getString(R.string.connection_assist_trying_again_waiting_title)
|
246
|
|
-
|
247
|
|
- binding.quickstartSwitch.visibility = View.GONE
|
248
|
|
- binding.torBootstrapButton1.visibility = View.INVISIBLE
|
249
|
|
- binding.torBootstrapButton2.visibility = View.VISIBLE
|
250
|
|
- binding.torBootstrapButton2.text = getString(R.string.btn_cancel)
|
251
|
|
- binding.torBootstrapButton2.setOnClickListener {
|
252
|
|
- viewModel.cancelTorBootstrap()
|
253
|
|
- showConfiguring()
|
254
|
|
- }
|
255
|
|
- }
|
256
|
|
-
|
257
|
|
- private fun showCantConnectToTorDirectly() {
|
258
|
|
- Log.d(TAG, "showCantConnectToTorDirectly()")
|
259
|
|
- binding.torBootstrapProgressBar.visibility = View.VISIBLE
|
260
|
|
- binding.torBootstrapProgressBar.progressTintList =
|
261
|
|
- AppCompatResources.getColorStateList(requireContext(), R.color.warning_yellow)
|
262
|
|
- binding.torBootstrapProgressBar.progress = 100
|
263
|
|
-
|
264
|
|
- binding.backButton.visibility = View.VISIBLE
|
265
|
|
- binding.backButton.setOnClickListener {
|
266
|
|
- showConfiguring()
|
267
|
|
- }
|
268
|
|
-
|
269
|
|
- binding.torConnectImage.setImageResource(R.drawable.globe_broken)
|
270
|
|
- binding.titleLargeTextView.text =
|
271
|
|
- getString(R.string.connection_assist_cant_connect_to_tor_title)
|
272
|
|
-
|
273
|
|
- val learnMore: String = getString(R.string.connection_assist_internet_error_learn_more)
|
274
|
|
- val tryABridge: String = getString(
|
275
|
|
- R.string.connection_assist_try_a_bridge_description,
|
276
|
|
- learnMore,
|
277
|
|
- )
|
278
|
|
- handleDescriptionWithClickable(tryABridge, learnMore)
|
279
|
|
-
|
280
|
|
- binding.quickstartSwitch.visibility = View.GONE
|
281
|
|
- binding.unblockTheInternetInCountryDescription.visibility = View.VISIBLE
|
282
|
|
- binding.countryDropDown.visibility = View.VISIBLE
|
283
|
|
- // TODO implement countryDropDown
|
284
|
|
-
|
285
|
|
- binding.torBootstrapButton1.visibility = View.VISIBLE
|
286
|
|
- binding.torBootstrapButton1.text = getString(R.string.connection_assist_try_a_bridge_button)
|
287
|
|
- binding.torBootstrapButton1.setOnClickListener {
|
288
|
|
- viewModel.tryABridge()
|
289
|
|
- showTryingABridge()
|
|
170
|
+ wordmarkLogo.visibility = if(screen.wordmarkLogoVisible) View.VISIBLE else View.GONE
|
290
|
171
|
}
|
291
|
|
- binding.torBootstrapButton2.visibility = View.GONE
|
292
|
|
- }
|
293
|
|
-
|
294
|
|
- private fun showTryingABridge() {
|
295
|
|
- Log.d(TAG, "showTryingABridge()")
|
296
|
|
- // TODO(Not implemented)
|
297
|
|
- binding.torBootstrapButton2.setOnClickListener {
|
298
|
|
- showTryingABridge()
|
299
|
|
- }
|
300
|
|
- }
|
301
|
|
-
|
302
|
|
- private fun showWeCouldntFindYourLocation() {
|
303
|
|
- Log.d(TAG, "showWeCouldntFindYourLocation()")
|
304
|
|
- // TODO(Not implemented)
|
305
|
|
- binding.torBootstrapButton2.setOnClickListener {
|
306
|
|
- showTryingABridge()
|
307
|
|
- }
|
308
|
|
- }
|
309
|
|
-
|
310
|
|
- private fun showWereStillHavingTroubleConnecting() {
|
311
|
|
- Log.d(TAG, "showWereStillHavingTroubleConnecting()")
|
312
|
|
- TODO("Not yet implemented")
|
313
|
|
- }
|
314
|
|
-
|
315
|
|
- private fun showTryingOneMoreTime() {
|
316
|
|
- Log.d(TAG, "showTryingOneMoreTime()")
|
317
|
|
- TODO("Not yet implemented")
|
318
|
|
- }
|
319
|
|
-
|
320
|
|
- private fun showWeWerentAbleToConnectAutomatically() {
|
321
|
|
- Log.d(TAG, "showWeWerentAbleToConnectAutomatically()")
|
322
|
|
- TODO("Not yet implemented")
|
323
|
|
- }
|
324
|
|
-
|
325
|
|
- private fun showUnknownError() {
|
326
|
|
- Log.d(TAG, "showUnknownError()")
|
327
|
|
- TODO("Not yet implemented")
|
328
|
172
|
}
|
329
|
173
|
|
330
|
174
|
/**
|
... |
... |
@@ -377,4 +221,9 @@ class TorConnectionAssistFragment : Fragment() { |
377
|
221
|
),
|
378
|
222
|
)
|
379
|
223
|
}
|
|
224
|
+
|
|
225
|
+ override fun onBackPressed(): Boolean {
|
|
226
|
+ return viewModel.handleBackButtonPressed()
|
|
227
|
+ }
|
|
228
|
+
|
380
|
229
|
} |
fenix/app/src/main/java/org/mozilla/fenix/tor/TorConnectionAssistViewModel.kt
... |
... |
@@ -23,11 +23,8 @@ class TorConnectionAssistViewModel( |
23
|
23
|
|
24
|
24
|
private val _torController: TorControllerGV = components.torController as TorControllerGV
|
25
|
25
|
|
26
|
|
- private val _torConnectState = MutableStateFlow(TorConnectState.Initial)
|
27
|
|
- internal val torConnectState: StateFlow<TorConnectState> = _torConnectState
|
28
|
|
-
|
29
|
|
- private val _torError = MutableStateFlow(_torController.getLastErrorState())
|
30
|
|
- internal val torError: StateFlow<TorError?> = _torError
|
|
26
|
+ private val _torConnectScreen = MutableStateFlow(ConnectAssistUiState.Splash)
|
|
27
|
+ internal val torConnectScreen: StateFlow<ConnectAssistUiState> = _torConnectScreen
|
31
|
28
|
|
32
|
29
|
private val _progress = MutableLiveData(0)
|
33
|
30
|
fun progress(): LiveData<Int> {
|
... |
... |
@@ -45,7 +42,7 @@ class TorConnectionAssistViewModel( |
45
|
42
|
_torController.registerTorListener(this)
|
46
|
43
|
}
|
47
|
44
|
|
48
|
|
- fun handleConnect(
|
|
45
|
+ private fun handleConnect(
|
49
|
46
|
withDebugLogging: Boolean = false,
|
50
|
47
|
lifecycleScope: LifecycleCoroutineScope? = null,
|
51
|
48
|
) {
|
... |
... |
@@ -61,6 +58,17 @@ class TorConnectionAssistViewModel( |
61
|
58
|
_quickStartToggle.value = checked
|
62
|
59
|
}
|
63
|
60
|
|
|
61
|
+ fun handleButton1Pressed(
|
|
62
|
+ screen: ConnectAssistUiState,
|
|
63
|
+ lifecycleScope: LifecycleCoroutineScope?,
|
|
64
|
+ ) {
|
|
65
|
+ if (screen.torBootstrapButton1ShouldShowTryingABridge) {
|
|
66
|
+ tryABridge()
|
|
67
|
+ } else {
|
|
68
|
+ handleConnect(lifecycleScope = lifecycleScope)
|
|
69
|
+ }
|
|
70
|
+ }
|
|
71
|
+
|
64
|
72
|
fun cancelTorBootstrap() {
|
65
|
73
|
_torController.stopTor()
|
66
|
74
|
_torController.setTorStopped()
|
... |
... |
@@ -80,33 +88,126 @@ class TorConnectionAssistViewModel( |
80
|
88
|
if (progress != null) {
|
81
|
89
|
_progress.value = progress.toInt()
|
82
|
90
|
}
|
83
|
|
- _torConnectState.value = _torController.lastKnownStatus
|
84
|
|
- _torError.value = _torController.getLastErrorState()
|
|
91
|
+
|
|
92
|
+ when (_torController.lastKnownStatus) {
|
|
93
|
+ TorConnectState.Initial -> _torConnectScreen.value = ConnectAssistUiState.Splash
|
|
94
|
+ TorConnectState.Configuring -> handleConfiguring()
|
|
95
|
+ TorConnectState.AutoBootstrapping -> handleBootstrap()
|
|
96
|
+ TorConnectState.Bootstrapping -> handleBootstrap()
|
|
97
|
+ TorConnectState.Error -> handleError()
|
|
98
|
+ else -> {}
|
|
99
|
+ }
|
|
100
|
+ }
|
|
101
|
+
|
|
102
|
+ private fun handleConfiguring() {
|
|
103
|
+ if (_torController.lastKnownError == null) {
|
|
104
|
+ _torConnectScreen.value = ConnectAssistUiState.Configuring
|
|
105
|
+ } else {
|
|
106
|
+ handleError()
|
|
107
|
+ }
|
|
108
|
+ }
|
|
109
|
+
|
|
110
|
+ private fun handleBootstrap() {
|
|
111
|
+ when (_torConnectScreen.value) {
|
|
112
|
+ ConnectAssistUiState.InternetError -> {
|
|
113
|
+ _torConnectScreen.value = ConnectAssistUiState.TryingAgain
|
|
114
|
+ }
|
|
115
|
+
|
|
116
|
+ ConnectAssistUiState.TryingAgain -> {
|
|
117
|
+ /** stay here */
|
|
118
|
+ }
|
|
119
|
+
|
|
120
|
+ ConnectAssistUiState.TryABridge -> {
|
|
121
|
+ _torConnectScreen.value = ConnectAssistUiState.TryingABridge
|
|
122
|
+ }
|
|
123
|
+
|
|
124
|
+ ConnectAssistUiState.LocationError -> {
|
|
125
|
+ _torConnectScreen.value = ConnectAssistUiState.TryingABridge
|
|
126
|
+ }
|
|
127
|
+
|
|
128
|
+ ConnectAssistUiState.TryingABridge -> {
|
|
129
|
+ /** stay here */
|
|
130
|
+ }
|
|
131
|
+
|
|
132
|
+ ConnectAssistUiState.LocationCheck -> {
|
|
133
|
+ _torConnectScreen.value = ConnectAssistUiState.LastTry
|
|
134
|
+ }
|
|
135
|
+
|
|
136
|
+ ConnectAssistUiState.LastTry -> {
|
|
137
|
+ /** stay here */
|
|
138
|
+ }
|
|
139
|
+
|
|
140
|
+ else -> _torConnectScreen.value = ConnectAssistUiState.Bootstrapping
|
|
141
|
+ }
|
|
142
|
+ }
|
|
143
|
+
|
|
144
|
+ private fun handleError() {
|
|
145
|
+ _torController.lastKnownError?.apply {
|
|
146
|
+ Log.d(
|
|
147
|
+ TAG,
|
|
148
|
+ "TorError(message = $message, details = $details, phase = $phase, reason = $reason",
|
|
149
|
+ )
|
|
150
|
+ // TODO better error handling
|
|
151
|
+ _torConnectScreen.value = ConnectAssistUiState.InternetError
|
|
152
|
+ }
|
85
|
153
|
}
|
86
|
154
|
|
87
|
155
|
override fun onTorStopped() {
|
88
|
156
|
Log.d(TAG, "onTorStopped()")
|
89
|
157
|
}
|
90
|
158
|
|
91
|
|
- internal fun handleError(it: TorError?): ErrorScreen? {
|
92
|
|
- // TODO(Only partly implemented)
|
93
|
|
- if (it?.message == null){
|
94
|
|
- return null
|
|
159
|
+ private fun tryABridge() {
|
|
160
|
+ if (!_torController.bridgesEnabled) {
|
|
161
|
+ _torController.bridgesEnabled = true
|
|
162
|
+ _torController.bridgeTransport =
|
|
163
|
+ TorBridgeTransportConfig.BUILTIN_OBFS4 // TODO select based on country
|
95
|
164
|
}
|
96
|
|
- return ErrorScreen.CantConnectToInternet
|
|
165
|
+ handleConnect(withDebugLogging = true)
|
97
|
166
|
}
|
98
|
167
|
|
99
|
|
- fun tryABridge() {
|
100
|
|
- // TODO("Try a bridge not enabled")
|
101
|
|
- // connect to bridge based on country
|
102
|
|
- // try connecting
|
|
168
|
+ fun handleBackButtonPressed(): Boolean {
|
|
169
|
+ when (torConnectScreen.value) {
|
|
170
|
+ ConnectAssistUiState.Splash -> return false
|
|
171
|
+ ConnectAssistUiState.Configuring -> return false
|
|
172
|
+ ConnectAssistUiState.Bootstrapping -> cancelTorBootstrap()
|
|
173
|
+ ConnectAssistUiState.InternetError -> {
|
|
174
|
+ _torController.lastKnownError = null
|
|
175
|
+ _torConnectScreen.value = ConnectAssistUiState.Configuring
|
|
176
|
+ }
|
|
177
|
+
|
|
178
|
+ ConnectAssistUiState.TryingAgain -> {
|
|
179
|
+ cancelTorBootstrap()
|
|
180
|
+ }
|
|
181
|
+
|
|
182
|
+ ConnectAssistUiState.TryABridge -> {
|
|
183
|
+ _torController.lastKnownError = null
|
|
184
|
+ _torConnectScreen.value = ConnectAssistUiState.Configuring
|
|
185
|
+ }
|
|
186
|
+
|
|
187
|
+ ConnectAssistUiState.TryingABridge -> {
|
|
188
|
+ _torController.stopTor()
|
|
189
|
+ _torConnectScreen.value = ConnectAssistUiState.TryABridge
|
|
190
|
+ }
|
|
191
|
+
|
|
192
|
+ ConnectAssistUiState.LocationError -> {
|
|
193
|
+ _torConnectScreen.value = ConnectAssistUiState.TryABridge
|
|
194
|
+ }
|
|
195
|
+
|
|
196
|
+ ConnectAssistUiState.LocationCheck -> {
|
|
197
|
+ _torConnectScreen.value = ConnectAssistUiState.LocationError
|
|
198
|
+ }
|
|
199
|
+
|
|
200
|
+ ConnectAssistUiState.LastTry -> {
|
|
201
|
+ _torController.stopTor()
|
|
202
|
+ _torConnectScreen.value = ConnectAssistUiState.LocationCheck
|
|
203
|
+ }
|
|
204
|
+
|
|
205
|
+ ConnectAssistUiState.FinalError -> {
|
|
206
|
+ _torConnectScreen.value = ConnectAssistUiState.LocationCheck
|
|
207
|
+ }
|
|
208
|
+ }
|
|
209
|
+ return true
|
103
|
210
|
}
|
104
|
|
-}
|
105
|
211
|
|
106
|
|
-internal enum class ErrorScreen {
|
107
|
|
- CantConnectToInternet,
|
108
|
|
- CantConnectToTorDirectly,
|
109
|
|
- WeCouldntFindYourLocation,
|
110
|
|
- WereStillHavingTroubleConnecting,
|
111
|
|
- WeWerentAbleToConnectAutomatically,
|
112
|
212
|
}
|
|
213
|
+ |
fenix/app/src/main/java/org/mozilla/fenix/tor/TorControllerGV.kt
... |
... |
@@ -285,7 +285,7 @@ class TorControllerGV( |
285
|
285
|
|
286
|
286
|
// TorEventsBootstrapStateChangeListener
|
287
|
287
|
override fun onBootstrapStateChange(newStateVal: String?) {
|
288
|
|
- Log.d(TAG, "onBootstrapStateChange($newStateVal)")
|
|
288
|
+ Log.d(TAG, "onBootstrapStateChange(newStateVal = $newStateVal)")
|
289
|
289
|
val newState: TorConnectState = TorConnectState.valueOf(newStateVal ?: "Error")
|
290
|
290
|
|
291
|
291
|
if (newState.isError() && wasTorBootstrapped) {
|
fenix/app/src/main/res/drawable/browser_location.xml
|
1
|
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
|
2
|
+ android:width="40dp"
|
|
3
|
+ android:height="40dp"
|
|
4
|
+ android:viewportWidth="40"
|
|
5
|
+ android:viewportHeight="40">
|
|
6
|
+ <group>
|
|
7
|
+ <clip-path
|
|
8
|
+ android:pathData="M0,0h40v40h-40z"/>
|
|
9
|
+ <path
|
|
10
|
+ android:pathData="M19.332,28.605C19.332,23.853 23.361,20 28.332,20C33.303,20 37.332,23.853 37.332,28.605C37.332,32.002 32.736,36.822 30.113,39.296C29.636,39.748 28.997,40 28.332,40C27.667,40 27.028,39.748 26.551,39.296C23.928,36.822 19.332,32.001 19.332,28.605ZM26.865,24.958C27.33,24.766 27.829,24.667 28.332,24.667C29.349,24.667 30.324,25.07 31.043,25.789C31.761,26.508 32.165,27.483 32.165,28.5C32.165,29.517 31.761,30.492 31.043,31.211C30.324,31.93 29.349,32.333 28.332,32.333C27.829,32.333 27.33,32.234 26.865,32.042C26.4,31.849 25.977,31.566 25.621,31.211C25.265,30.855 24.983,30.432 24.791,29.967C24.598,29.502 24.499,29.003 24.499,28.5C24.499,27.997 24.598,27.498 24.791,27.033C24.983,26.568 25.265,26.146 25.621,25.789C25.977,25.434 26.4,25.151 26.865,24.958Z"
|
|
11
|
+ android:fillColor="#FFA436"
|
|
12
|
+ android:fillType="evenOdd"/>
|
|
13
|
+ <path
|
|
14
|
+ android:pathData="M38.509,22.9C38.721,21.771 38.832,20.607 38.832,19.417C38.832,9.061 30.438,0.667 20.082,0.667C9.727,0.667 1.332,9.061 1.332,19.417C1.332,29.772 9.727,38.167 20.082,38.167C20.825,38.167 21.559,38.124 22.279,38.039C19.438,34.942 16.665,31.167 16.665,28.233C16.665,25.223 17.971,22.499 20.082,20.526V14.846C22.098,14.846 23.809,16.151 24.416,17.962C25.33,17.658 26.298,17.458 27.301,17.375C26.412,14.225 23.517,11.917 20.082,11.917L20.082,9.221C25.042,9.221 29.175,12.764 30.089,17.456C31.169,17.608 32.2,17.899 33.161,18.308C32.598,11.578 26.957,6.292 20.082,6.292V3.596C28.819,3.596 35.903,10.679 35.903,19.417C35.903,19.589 35.9,19.761 35.894,19.933C36.942,20.767 37.83,21.771 38.509,22.9Z"
|
|
15
|
+ android:fillColor="#FBFBFE"/>
|
|
16
|
+ </group>
|
|
17
|
+</vector> |
fenix/app/src/main/res/layout/fragment_tor_connection_assist.xml
... |
... |
@@ -3,7 +3,6 @@ |
3
|
3
|
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
4
|
4
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
5
|
5
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
6
|
|
- xmlns:tools="http://schemas.android.com/tools"
|
7
|
6
|
android:layout_width="match_parent"
|
8
|
7
|
android:layout_height="match_parent"
|
9
|
8
|
android:background="">"@drawable/tor_bootstrap_background_gradient"
|
|