aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/app/src/main/res/layout/tunnel_detail_fragment.xml
blob: 4487c9ccf3d9aa282cf512aba6e1083a5bc431c1 (plain) (blame)
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
<?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.model.Tunnel.State" />

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

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

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="?android:attr/colorBackground">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="4dp"
                android:layout_marginEnd="8dp"
                android:layout_marginStart="8dp"
                android:layout_marginTop="8dp"
                android:background="?android:attr/colorBackground"
                android:elevation="2dp"
                android:padding="8dp">

                <TextView
                    android:id="@+id/interface_title"
                    style="?android:attr/textAppearanceMedium"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentStart="true"
                    android:layout_alignParentTop="true"
                    android:layout_toStartOf="@+id/tunnel_switch"
                    android:text="@string/iface" />

                <com.wireguard.android.widget.ToggleSwitch
                    android:id="@+id/tunnel_switch"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignBaseline="@+id/interface_title"
                    android:layout_alignParentEnd="true"
                    app:checked="@{tunnel.state == State.UP}"
                    app:onBeforeCheckedChanged="@{() -> tunnel.setState(State.TOGGLE)}" />

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

                <TextView
                    android:id="@+id/interface_name_text"
                    style="?android:attr/textAppearanceMedium"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/interface_name_label"
                    android:text="@{tunnel.name}" />

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

                <TextView
                    android:id="@+id/public_key_text"
                    style="?android:attr/textAppearanceMedium"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/public_key_label"
                    android:contentDescription="@string/public_key_description"
                    android:ellipsize="end"
                    android:maxLines="1"
                    android:onClick="@{ClipboardUtils::copyTextView}"
                    android:text="@{tunnel.config.interface.publicKey}" />
            </RelativeLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="4dp"
                android:divider="@null"
                android:orientation="vertical"
                app:items="@{tunnel.config.peers}"
                app:layout="@{@layout/tunnel_detail_peer}"
                tools:ignore="UselessLeaf" />
        </LinearLayout>
    </ScrollView>
</layout>