summaryrefslogtreecommitdiffhomepage
path: root/ui/src/main/res/layout/tunnel_detail_fragment.xml
blob: 7a962509d087f1243931eee839f0aaee92f480d8 (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
<?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="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.config.Config" />
    </data>

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="?attr/colorBackground"
        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"
                        style="@style/SectionText"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/interface_title"
                        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_toBaselineOf="@+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"
                        style="@style/DetailText"
                        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}"
                        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"
                        style="@style/DetailText"
                        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.interface.keyPair.publicKey.toBase64}"
                        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.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"
                        style="@style/DetailText"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:contentDescription="@string/addresses"
                        android:nextFocusUp="@id/public_key_text"
                        android:nextFocusDown="@id/dns_servers_text"
                        android:nextFocusForward="@id/dns_servers_text"
                        android:onClick="@{ClipboardUtils::copyTextView}"
                        android:text="@{config.interface.addresses}"
                        android:visibility="@{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/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.interface.dnsServers.isEmpty() ? android.view.View.GONE : android.view.View.VISIBLE}"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toBottomOf="@id/addresses_text" />

                    <TextView
                        android:id="@+id/dns_servers_text"
                        style="@style/DetailText"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:contentDescription="@string/dns_servers"
                        android:nextFocusUp="@id/addresses_text"
                        android:nextFocusDown="@id/dns_search_domains_text"
                        android:nextFocusForward="@id/dns_search_domains_text"
                        android:onClick="@{ClipboardUtils::copyTextView}"
                        android:text="@{config.interface.dnsServers}"
                        android:visibility="@{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.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"
                        style="@style/DetailText"
                        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.interface.dnsSearchDomains}"
                        android:visibility="@{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.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"
                        style="@style/DetailText"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginBottom="8dp"
                        android:contentDescription="@string/listen_port"
                        android:nextFocusRight="@id/mtu_text"
                        android:nextFocusUp="@id/dns_search_domains_text"
                        android:nextFocusDown="@id/applications_text"
                        android:nextFocusForward="@id/mtu_text"
                        android:onClick="@{ClipboardUtils::copyTextView}"
                        android:text="@{config.interface.listenPort}"
                        android:visibility="@{!config.interface.listenPort.isPresent() ? android.view.View.GONE : android.view.View.VISIBLE}"
                        app:layout_constraintBottom_toTopOf="@id/applications_label"
                        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.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"
                        style="@style/DetailText"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginBottom="8dp"
                        android:contentDescription="@string/mtu"
                        android:nextFocusLeft="@id/listen_port_text"
                        android:nextFocusUp="@id/dns_servers_text"
                        android:nextFocusForward="@id/applications_text"
                        android:onClick="@{ClipboardUtils::copyTextView}"
                        android:text="@{config.interface.mtu}"
                        android:visibility="@{!config.interface.mtu.isPresent() ? android.view.View.GONE : android.view.View.VISIBLE}"
                        app:layout_constraintBottom_toTopOf="@id/applications_label"
                        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" />

                    <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.interface.includedApplications.isEmpty() &amp;&amp; config.interface.excludedApplications.isEmpty() ? android.view.View.GONE : android.view.View.VISIBLE}"
                        app:layout_constraintBottom_toTopOf="@id/applications_text"
                        app:layout_constraintStart_toStartOf="parent" />

                    <TextView
                        android:id="@+id/applications_text"
                        style="@style/DetailText"
                        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.interface.includedApplications.isEmpty() ? @plurals/n_excluded_applications(config.interface.excludedApplications.size(), config.interface.excludedApplications.size()) : @plurals/n_included_applications(config.interface.includedApplications.size(), config.interface.includedApplications.size())}"
                        android:visibility="@{config.interface.includedApplications.isEmpty() &amp;&amp; config.interface.excludedApplications.isEmpty() ? android.view.View.GONE : android.view.View.VISIBLE}"
                        app:layout_constraintBottom_toBottomOf="parent"
                        app:layout_constraintStart_toStartOf="parent"
                        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: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>