summaryrefslogtreecommitdiffhomepage
path: root/ui/src/main/res/layout/tunnel_detail_fragment.xml
blob: 45dbcdd335a6f89467f904ba6715eb4614ff83b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools">

    <data>

        <import type="android.os.Build" />

        <import type="com.wireguard.android.backend.Tunnel.State" />

        <import type="com.wireguard.android.util.ClipboardUtils" />

        <variable
            name="fragment"
            type="com.wireguard.android.fragment.TunnelDetailFragment" />

        <variable
            name="tunnel"
            type="com.wireguard.android.model.ObservableTunnel" />

        <variable
            name="config"
            type="com.wireguard.android.viewmodel.ConfigDetail" />
    </data>

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="?attr/colorSurface"
        android:clickable="true"
        android:focusable="true">

        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <com.google.android.material.card.MaterialCardView
                android:id="@+id/tunnel_detail_card"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginStart="8dp"
                android:layout_marginTop="16dp"
                android:layout_marginEnd="8dp"
                android:layout_marginBottom="8dp"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent">

                <androidx.constraintlayout.widget.ConstraintLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">

                    <com.google.android.material.textview.MaterialTextView
                        android:id="@+id/interface_title"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/interface_title"
                        android:textAppearance="?attr/textAppearanceTitleMedium"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toTopOf="parent" />

                    <com.wireguard.android.widget.ToggleSwitch
                        android:id="@+id/tunnel_switch"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="16dp"
                        android:nextFocusDown="@id/interface_name_text"
                        android:nextFocusForward="@id/interface_name_text"
                        app:checked="@{tunnel.state == State.UP}"
                        app:layout_constraintBaseline_toBottomOf="@+id/interface_title"
                        app:layout_constraintEnd_toEndOf="parent"
                        app:onBeforeCheckedChanged="@{fragment::setTunnelState}" />

                    <TextView
                        android:id="@+id/interface_name_label"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="8dp"
                        android:labelFor="@+id/interface_name_text"
                        android:text="@string/name"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toBottomOf="@+id/interface_title" />

                    <TextView
                        android:id="@+id/interface_name_text"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:contentDescription="@string/name"
                        android:nextFocusUp="@id/tunnel_switch"
                        android:nextFocusDown="@id/public_key_text"
                        android:nextFocusForward="@id/public_key_text"
                        android:onClick="@{ClipboardUtils::copyTextView}"
                        android:text="@{tunnel.name}"
                        android:textAppearance="?attr/textAppearanceBodyLarge"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toBottomOf="@+id/interface_name_label"
                        tools:text="wg0" />

                    <TextView
                        android:id="@+id/public_key_label"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="8dp"
                        android:labelFor="@+id/public_key_text"
                        android:text="@string/public_key"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toBottomOf="@id/interface_name_text" />

                    <TextView
                        android:id="@+id/public_key_text"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:contentDescription="@string/public_key"
                        android:ellipsize="end"
                        android:maxLines="1"
                        android:nextFocusUp="@id/interface_name_text"
                        android:nextFocusDown="@id/addresses_text"
                        android:nextFocusForward="@id/addresses_text"
                        android:onClick="@{ClipboardUtils::copyTextView}"
                        android:singleLine="true"
                        android:text="@{config.config.interface.keyPair.publicKey.toBase64}"
                        android:textAppearance="?attr/textAppearanceBodyLarge"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toBottomOf="@+id/public_key_label"
                        tools:text="wOs2eguFEohqIZxlSJ1CAT9584tc6ejj9hfGFsoBVkA=" />

                    <TextView
                        android:id="@+id/addresses_label"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="8dp"
                        android:labelFor="@+id/addresses_text"
                        android:text="@string/addresses"
                        android:visibility="@{config.config.interface.addresses.isEmpty() ? android.view.View.GONE : android.view.View.VISIBLE}"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toBottomOf="@id/public_key_text" />

                    <TextView
                        android:id="@+id/addresses_text"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:contentDescription="@string/addresses"
                        android:nextFocusUp="@id/public_key_text"
                        android:nextFocusDown="@id/dynamic_addresses_text"
                        android:nextFocusForward="@id/dynamic_addresses_text"
                        android:onClick="@{ClipboardUtils::copyTextView}"
                        android:text="@{config.config.interface.addresses}"
                        android:textAppearance="?attr/textAppearanceBodyLarge"
                        android:visibility="@{config.config.interface.addresses.isEmpty() ? android.view.View.GONE : android.view.View.VISIBLE}"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toBottomOf="@+id/addresses_label"
                        tools:text="fc00:bbbb:bbbb:bb11::3:368b/128" />

                    <TextView
                        android:id="@+id/dynamic_addresses_label"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="8dp"
                        android:labelFor="@+id/dynamic_addresses_text"
                        android:text="@string/dynamic_addresses"
                        android:visibility="@{tunnel.dhcp == null ? android.view.View.GONE : android.view.View.VISIBLE}"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toBottomOf="@id/addresses_text" />

                    <TextView
                        android:id="@+id/dynamic_addresses_text"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:contentDescription="@string/dynamic_addresses"
                        android:nextFocusUp="@id/addresses_text"
                        android:nextFocusDown="@id/dns_servers_text"
                        android:nextFocusForward="@id/dns_servers_text"
                        android:onClick="@{ClipboardUtils::copyTextView}"
                        android:text="@{tunnel.dhcp.addresses}"
                        android:textAppearance="?attr/textAppearanceBodyLarge"
                        android:visibility="@{tunnel.dhcp == null ? android.view.View.GONE : android.view.View.VISIBLE}"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toBottomOf="@+id/dynamic_addresses_label"
                        tools:text="fc00:bbbb:bbbb:bb11::3:368b/128" />

                    <TextView
                        android:id="@+id/dns_servers_label"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="8dp"
                        android:labelFor="@+id/dns_servers_text"
                        android:text="@string/dns_servers"
                        android:visibility="@{config.config.interface.dnsServers.isEmpty() ? android.view.View.GONE : android.view.View.VISIBLE}"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toBottomOf="@id/dynamic_addresses_text" />

                    <TextView
                        android:id="@+id/dns_servers_text"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:contentDescription="@string/dns_servers"
                        android:nextFocusUp="@id/dynamic_addresses_text"
                        android:nextFocusDown="@id/dns_search_domains_text"
                        android:nextFocusForward="@id/dns_search_domains_text"
                        android:onClick="@{ClipboardUtils::copyTextView}"
                        android:text="@{config.config.interface.dnsServers}"
                        android:textAppearance="?attr/textAppearanceBodyLarge"
                        android:visibility="@{config.config.interface.dnsServers.isEmpty() ? android.view.View.GONE : android.view.View.VISIBLE}"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toBottomOf="@+id/dns_servers_label"
                        tools:text="8.8.8.8, 8.8.4.4" />

                    <TextView
                        android:id="@+id/dns_search_domains_label"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="8dp"
                        android:labelFor="@+id/dns_search_domain_text"
                        android:text="@string/dns_search_domains"
                        android:visibility="@{config.config.interface.dnsSearchDomains.isEmpty() ? android.view.View.GONE : android.view.View.VISIBLE}"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toBottomOf="@id/dns_servers_text" />

                    <TextView
                        android:id="@+id/dns_search_domains_text"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:contentDescription="@string/dns_search_domains"
                        android:nextFocusUp="@id/dns_servers_text"
                        android:nextFocusDown="@id/listen_port_text"
                        android:nextFocusForward="@id/listen_port_text"
                        android:onClick="@{ClipboardUtils::copyTextView}"
                        android:text="@{config.config.interface.dnsSearchDomains}"
                        android:textAppearance="?attr/textAppearanceBodyLarge"
                        android:visibility="@{config.config.interface.dnsSearchDomains.isEmpty() ? android.view.View.GONE : android.view.View.VISIBLE}"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toBottomOf="@+id/dns_search_domains_label"
                        tools:text="zx2c4.com" />

                    <TextView
                        android:id="@+id/listen_port_label"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="8dp"
                        android:labelFor="@+id/listen_port_text"
                        android:text="@string/listen_port"
                        android:visibility="@{!config.config.interface.listenPort.isPresent() ? android.view.View.GONE : android.view.View.VISIBLE}"
                        app:layout_constraintEnd_toStartOf="@id/mtu_label"
                        app:layout_constraintHorizontal_weight="0.5"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toBottomOf="@id/dns_search_domains_text" />

                    <TextView
                        android:id="@+id/listen_port_text"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:contentDescription="@string/listen_port"
                        android:nextFocusRight="@id/mtu_text"
                        android:nextFocusUp="@id/dns_search_domains_text"
                        android:nextFocusDown="@id/http_proxy_text"
                        android:nextFocusForward="@id/mtu_text"
                        android:onClick="@{ClipboardUtils::copyTextView}"
                        android:text="@{config.config.interface.listenPort}"
                        android:textAppearance="?attr/textAppearanceBodyLarge"
                        android:visibility="@{!config.config.interface.listenPort.isPresent() ? android.view.View.GONE : android.view.View.VISIBLE}"
                        app:layout_constraintEnd_toStartOf="@id/mtu_label"
                        app:layout_constraintHorizontal_weight="0.5"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toBottomOf="@+id/listen_port_label"
                        tools:text="51820" />

                    <TextView
                        android:id="@+id/mtu_label"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="8dp"
                        android:labelFor="@+id/mtu_text"
                        android:text="@string/mtu"
                        android:visibility="@{!config.config.interface.mtu.isPresent() ? android.view.View.GONE : android.view.View.VISIBLE}"
                        app:layout_constraintEnd_toEndOf="parent"
                        app:layout_constraintHorizontal_weight="0.5"
                        app:layout_constraintLeft_toRightOf="@id/listen_port_label"
                        app:layout_constraintStart_toEndOf="@id/listen_port_label"
                        app:layout_constraintTop_toBottomOf="@id/dns_search_domains_text" />

                    <TextView
                        android:id="@+id/mtu_text"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:contentDescription="@string/mtu"
                        android:nextFocusLeft="@id/listen_port_text"
                        android:nextFocusUp="@id/dns_servers_text"
                        android:nextFocusForward="@id/http_proxy_text"
                        android:onClick="@{ClipboardUtils::copyTextView}"
                        android:text="@{config.config.interface.mtu}"
                        android:textAppearance="?attr/textAppearanceBodyLarge"
                        android:visibility="@{!config.config.interface.mtu.isPresent() ? android.view.View.GONE : android.view.View.VISIBLE}"
                        app:layout_constraintEnd_toEndOf="parent"
                        app:layout_constraintHorizontal_weight="0.5"
                        app:layout_constraintStart_toEndOf="@id/listen_port_label"
                        app:layout_constraintStart_toStartOf="@+id/mtu_label"
                        app:layout_constraintTop_toBottomOf="@+id/mtu_label"
                        tools:text="1500" />

                    <androidx.constraintlayout.widget.Barrier
                        android:id="@+id/listen_port_mtu_barrier"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        app:barrierDirection="bottom"
                        app:constraint_referenced_ids="listen_port_text,mtu_text" />

                    <TextView
                        android:id="@+id/http_proxy_label"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="8dp"
                        android:labelFor="@+id/http_proxy_text"
                        android:text="@string/http_proxy"
                        android:visibility="@{(Build.VERSION.SDK_INT &lt; Build.VERSION_CODES.Q || !config.config.interface.httpProxy.isPresent()) ? android.view.View.GONE : android.view.View.VISIBLE}"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toBottomOf="@+id/listen_port_mtu_barrier" />

                    <TextView
                        android:id="@+id/http_proxy_text"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:contentDescription="@string/http_proxy"
                        android:nextFocusUp="@id/listen_port_text"
                        android:nextFocusDown="@id/applications_text"
                        android:nextFocusForward="@id/applications_text"
                        android:onClick="@{ClipboardUtils::copyTextView}"
                        android:text="@{config.config.interface.httpProxy}"
                        android:textAppearance="?attr/textAppearanceBodyLarge"
                        android:visibility="@{(Build.VERSION.SDK_INT &lt; Build.VERSION_CODES.Q || !config.config.interface.httpProxy.isPresent()) ? android.view.View.GONE : android.view.View.VISIBLE}"
                        app:layout_constraintTop_toBottomOf="@id/http_proxy_label"
                        app:layout_constraintStart_toStartOf="parent"
                        tools:text="http://example.com:8888" />

                    <TextView
                        android:id="@+id/applications_label"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="8dp"
                        android:labelFor="@+id/applications_text"
                        android:text="@string/applications"
                        android:visibility="@{config.config.interface.includedApplications.isEmpty() &amp;&amp; config.config.interface.excludedApplications.isEmpty() ? android.view.View.GONE : android.view.View.VISIBLE}"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toBottomOf="@+id/http_proxy_text" />

                    <TextView
                        android:id="@+id/applications_text"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:contentDescription="@string/applications"
                        android:nextFocusUp="@id/mtu_text"
                        android:nextFocusDown="@id/peers_layout"
                        android:nextFocusForward="@id/peers_layout"
                        android:onClick="@{ClipboardUtils::copyTextView}"
                        android:text="@{config.config.interface.includedApplications.isEmpty() ? @plurals/n_excluded_applications(config.config.interface.excludedApplications.size(), config.config.interface.excludedApplications.size()) : @plurals/n_included_applications(config.config.interface.includedApplications.size(), config.config.interface.includedApplications.size())}"
                        android:textAppearance="?attr/textAppearanceBodyLarge"
                        android:visibility="@{config.config.interface.includedApplications.isEmpty() &amp;&amp; config.config.interface.excludedApplications.isEmpty() ? android.view.View.GONE : android.view.View.VISIBLE}"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toBottomOf="@+id/applications_label"
                        tools:text="8 excluded" />
                </androidx.constraintlayout.widget.ConstraintLayout>
            </com.google.android.material.card.MaterialCardView>

            <LinearLayout
                android:id="@+id/peers_layout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="8dp"
                android:divider="@null"
                android:orientation="vertical"
                app:fragment="@{fragment}"
                app:items="@{config.peers}"
                app:layout="@{@layout/tunnel_detail_peer}"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/tunnel_detail_card"
                tools:ignore="UselessLeaf" />
        </androidx.constraintlayout.widget.ConstraintLayout>
    </ScrollView>
</layout>