aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/app/src/main/res/layout/config_list_item.xml
blob: 578db8333064e4358ed69a93cc35a30e26b381c0 (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
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">

    <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: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}" />

        <TextView
            android:id="@+id/config_switch"
            style="?android:attr/textAppearanceButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignBaseline="@+id/config_name"
            android:layout_alignParentEnd="true"
            android:gravity="center_vertical"
            android:onClick="@{() -> item.enabled ? VpnService.instance.disable(item.name) : VpnService.instance.enable(item.name)}"
            android:text="@string/toggle"
            android:textColor="@{item.enabled ? @android:color/holo_green_dark : @android:color/holo_red_dark}" />
    </RelativeLayout>
</layout>