aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/app/src/main/res/layout/config_list_item.xml
blob: 90e696a47b7655921d9e201e0da5a15c39fd9274 (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
<?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">

    <data>

        <import type="android.graphics.Typeface" />

        <import type="com.wireguard.android.backends.VpnService" />

        <variable
            name="key"
            type="String" />

        <variable
            name="item"
            type="com.wireguard.config.Config" />
    </data>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/list_item_background_anim"
        android:descendantFocusability="blocksDescendants"
        android:padding="16dp">

        <TextView
            android:id="@+id/config_name"
            style="?android:attr/textAppearanceMedium"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentStart="true"
            android:layout_toStartOf="@+id/config_switch"
            android:ellipsize="end"
            android:maxLines="1"
            android:text="@{key}"
            android:textStyle="@{item.primary ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT}" />

        <com.wireguard.android.widget.ToggleSwitch
            android:id="@+id/config_switch"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignBaseline="@+id/config_name"
            android:layout_alignParentEnd="true"
            app:checked="@{item.enabled}"
            app:onBeforeCheckedChanged="@{(v, checked) -> checked ? VpnService.instance.enable(item.name) : VpnService.instance.disable(item.name)}" />
    </RelativeLayout>
</layout>