summaryrefslogtreecommitdiffhomepage
path: root/app/src/main/res
diff options
context:
space:
mode:
authorSamuel Holland <samuel@sholland.org>2018-01-01 02:06:37 -0600
committerSamuel Holland <samuel@sholland.org>2018-01-06 04:09:29 -0600
commit609194fae2332e6f2ccd7a4464bfa492ad661a6f (patch)
tree96a7cd9846a093dfcdacfef285b0a4d77000edf0 /app/src/main/res
parent4c0869393e2d8f52b9bcf312286dca8ced2e1900 (diff)
Serviceless rewrite, part 1
Signed-off-by: Samuel Holland <samuel@sholland.org>
Diffstat (limited to 'app/src/main/res')
-rw-r--r--app/src/main/res/layout-w720dp/config_activity.xml28
-rw-r--r--app/src/main/res/layout/config_activity.xml7
-rw-r--r--app/src/main/res/layout/config_detail_fragment.xml86
-rw-r--r--app/src/main/res/layout/config_edit_fragment.xml219
-rw-r--r--app/src/main/res/layout/config_editor_fragment.xml233
-rw-r--r--app/src/main/res/layout/config_editor_peer.xml (renamed from app/src/main/res/layout/config_edit_peer.xml)8
-rw-r--r--app/src/main/res/layout/config_list_fragment.xml54
-rw-r--r--app/src/main/res/layout/main_activity.xml (renamed from app/src/main/res/layout/add_activity.xml)4
-rw-r--r--app/src/main/res/layout/not_supported_activity.xml15
-rw-r--r--app/src/main/res/layout/tunnel_detail_fragment.xml142
-rw-r--r--app/src/main/res/layout/tunnel_detail_peer.xml (renamed from app/src/main/res/layout/config_detail_peer.xml)8
-rw-r--r--app/src/main/res/layout/tunnel_list_fragment.xml59
-rw-r--r--app/src/main/res/layout/tunnel_list_item.xml (renamed from app/src/main/res/layout/config_list_item.xml)25
-rw-r--r--app/src/main/res/menu/config_editor.xml (renamed from app/src/main/res/menu/config_edit.xml)0
-rw-r--r--app/src/main/res/menu/main_activity.xml (renamed from app/src/main/res/menu/main.xml)0
-rw-r--r--app/src/main/res/menu/tunnel_detail.xml (renamed from app/src/main/res/menu/config_detail.xml)0
-rw-r--r--app/src/main/res/menu/tunnel_list_action_mode.xml (renamed from app/src/main/res/menu/config_list_delete.xml)0
-rw-r--r--app/src/main/res/values/strings.xml8
-rw-r--r--app/src/main/res/xml/preferences.xml2
19 files changed, 468 insertions, 430 deletions
diff --git a/app/src/main/res/layout-w720dp/config_activity.xml b/app/src/main/res/layout-w720dp/config_activity.xml
deleted file mode 100644
index 72792af5..00000000
--- a/app/src/main/res/layout-w720dp/config_activity.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:baselineAligned="false"
- android:orientation="horizontal">
-
- <FrameLayout
- android:id="@+id/master_fragment"
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:layout_weight="1" />
-
- <FrameLayout
- android:id="@+id/detail_fragment"
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:layout_weight="2"
- tools:ignore="InconsistentLayout">
-
- <TextView
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:gravity="center"
- android:text="@string/placeholder_text" />
- </FrameLayout>
-</LinearLayout>
diff --git a/app/src/main/res/layout/config_activity.xml b/app/src/main/res/layout/config_activity.xml
deleted file mode 100644
index 0f21e2e8..00000000
--- a/app/src/main/res/layout/config_activity.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:id="@+id/master_fragment"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- tools:ignore="MergeRootFrame" />
diff --git a/app/src/main/res/layout/config_detail_fragment.xml b/app/src/main/res/layout/config_detail_fragment.xml
deleted file mode 100644
index cf6fdaaf..00000000
--- a/app/src/main/res/layout/config_detail_fragment.xml
+++ /dev/null
@@ -1,86 +0,0 @@
-<?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.backends.VpnService" />
-
- <variable
- name="config"
- type="com.wireguard.config.Config" />
- </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/status_label"
- style="?android:attr/textAppearanceMedium"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentStart="true"
- android:layout_alignParentTop="true"
- android:layout_marginBottom="8dp"
- android:layout_toStartOf="@+id/config_switch"
- android:text="@string/status" />
-
- <com.wireguard.android.widget.ToggleSwitch
- android:id="@+id/config_switch"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignBaseline="@+id/status_label"
- android:layout_alignParentEnd="true"
- app:checked="@{config.enabled}"
- app:onBeforeCheckedChanged="@{(v, checked) -> checked ? VpnService.instance.enable(config.name) : VpnService.instance.disable(config.name)}" />
-
- <TextView
- android:id="@+id/public_key_label"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_below="@id/status_label"
- 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:ellipsize="end"
- android:maxLines="1"
- android:text="@{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="@{config.peers}"
- app:layout="@{@layout/config_detail_peer}"
- tools:ignore="UselessLeaf" />
- </LinearLayout>
- </ScrollView>
-</layout>
diff --git a/app/src/main/res/layout/config_edit_fragment.xml b/app/src/main/res/layout/config_edit_fragment.xml
deleted file mode 100644
index f7721ac1..00000000
--- a/app/src/main/res/layout/config_edit_fragment.xml
+++ /dev/null
@@ -1,219 +0,0 @@
-<?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.ConfigEditFragment" />
-
- <import type="com.wireguard.android.KeyInputFilter" />
-
- <import type="com.wireguard.android.NameInputFilter" />
-
- <variable
- name="config"
- type="com.wireguard.config.Config" />
- </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="match_parent"
- android:layout_height="wrap_content"
- android:layout_alignParentTop="true"
- android:text="@string/iface" />
-
- <TextView
- android:id="@+id/interface_name_label"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_below="@+id/interface_title"
- android:labelFor="@+id/interface_name_text"
- android:text="@string/name" />
-
- <EditText
- android:id="@+id/interface_name_text"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_below="@+id/interface_name_label"
- android:inputType="textNoSuggestions"
- android:text="@={config.name}"
- app:filter="@{NameInputFilter.newInstance()}" />
-
- <TextView
- android:id="@+id/private_key_label"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_below="@+id/interface_name_text"
- android:labelFor="@+id/private_key_text"
- android:text="@string/private_key" />
-
- <EditText
- android:id="@+id/private_key_text"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentStart="true"
- android:layout_below="@+id/private_key_label"
- android:layout_toStartOf="@+id/generate_private_key_button"
- android:inputType="textVisiblePassword"
- android:text="@={config.interface.privateKey}"
- app:filter="@{KeyInputFilter.newInstance()}" />
-
- <Button
- android:id="@+id/generate_private_key_button"
- android:layout_width="96dp"
- android:layout_height="wrap_content"
- android:layout_alignBottom="@id/private_key_text"
- android:layout_alignParentEnd="true"
- android:layout_below="@+id/private_key_label"
- android:onClick="@{() -> config.interface.generateKeypair()}"
- android:text="@string/generate" />
-
- <TextView
- android:id="@+id/public_key_label"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_below="@+id/private_key_text"
- android:labelFor="@+id/public_key_text"
- android:text="@string/public_key" />
-
- <TextView
- android:id="@+id/public_key_text"
- style="?android:attr/editTextStyle"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_below="@+id/public_key_label"
- android:ellipsize="end"
- android:focusable="false"
- android:hint="@string/hint_generated"
- android:maxLines="1"
- android:onClick="@{(view) -> ConfigEditFragment.copyPublicKey(view.getContext(), config.interface.publicKey)}"
- android:text="@{config.interface.publicKey}" />
-
- <TextView
- android:id="@+id/addresses_label"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentStart="true"
- android:layout_below="@+id/public_key_text"
- android:layout_toStartOf="@+id/listen_port_label"
- android:labelFor="@+id/addresses_text"
- android:text="@string/addresses" />
-
- <EditText
- android:id="@+id/addresses_text"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentStart="true"
- android:layout_below="@+id/addresses_label"
- android:layout_toStartOf="@+id/listen_port_text"
- android:inputType="textNoSuggestions"
- android:text="@={config.interface.address}" />
-
- <TextView
- android:id="@+id/listen_port_label"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignBaseline="@+id/addresses_label"
- android:layout_alignParentEnd="true"
- android:layout_alignStart="@+id/generate_private_key_button"
- android:labelFor="@+id/listen_port_text"
- android:text="@string/listen_port" />
-
- <EditText
- android:id="@+id/listen_port_text"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignBaseline="@+id/addresses_text"
- android:layout_alignParentEnd="true"
- android:layout_alignStart="@+id/generate_private_key_button"
- android:hint="@string/hint_random"
- android:inputType="number"
- android:text="@={config.interface.listenPort}"
- android:textAlignment="center" />
-
- <TextView
- android:id="@+id/dns_servers_label"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentStart="true"
- android:layout_below="@+id/addresses_text"
- android:layout_toStartOf="@+id/mtu_label"
- android:labelFor="@+id/dns_servers_text"
- android:text="@string/dns_servers" />
-
- <EditText
- android:id="@+id/dns_servers_text"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentStart="true"
- android:layout_below="@+id/dns_servers_label"
- android:layout_toStartOf="@+id/mtu_text"
- android:inputType="textNoSuggestions"
- android:text="@={config.interface.dns}" />
-
- <TextView
- android:id="@+id/mtu_label"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignBaseline="@+id/dns_servers_label"
- android:layout_alignParentEnd="true"
- android:layout_alignStart="@+id/generate_private_key_button"
- android:labelFor="@+id/mtu_text"
- android:text="@string/mtu" />
-
- <EditText
- android:id="@+id/mtu_text"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignBaseline="@+id/dns_servers_text"
- android:layout_alignParentEnd="true"
- android:layout_alignStart="@+id/generate_private_key_button"
- android:hint="@string/hint_automatic"
- android:inputType="number"
- android:text="@={config.interface.mtu}"
- android:textAlignment="center" />
- </RelativeLayout>
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:divider="@null"
- android:orientation="vertical"
- app:items="@{config.peers}"
- app:layout="@{@layout/config_edit_peer}"
- tools:ignore="UselessLeaf" />
-
- <Button
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginBottom="4dp"
- android:layout_marginEnd="4dp"
- android:layout_marginStart="4dp"
- android:onClick="@{() -> config.addPeer()}"
- android:text="@string/add_peer" />
- </LinearLayout>
- </ScrollView>
-</layout>
diff --git a/app/src/main/res/layout/config_editor_fragment.xml b/app/src/main/res/layout/config_editor_fragment.xml
new file mode 100644
index 00000000..c0895656
--- /dev/null
+++ b/app/src/main/res/layout/config_editor_fragment.xml
@@ -0,0 +1,233 @@
+<?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.util.ClipboardUtils" />
+
+ <import type="com.wireguard.android.widget.KeyInputFilter" />
+
+ <import type="com.wireguard.android.widget.NameInputFilter" />
+
+ <import type="com.wireguard.config.Peer" />
+
+ <variable
+ name="config"
+ type="com.wireguard.config.Config" />
+
+ <variable
+ name="name"
+ type="android.databinding.ObservableField&lt;String&gt;" />
+ </data>
+
+ <com.commonsware.cwac.crossport.design.widget.CoordinatorLayout
+ android:id="@+id/main_container"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="?android:attr/colorBackground">
+
+ <ScrollView
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <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="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignParentTop="true"
+ android:text="@string/iface" />
+
+ <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" />
+
+ <EditText
+ android:id="@+id/interface_name_text"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_below="@+id/interface_name_label"
+ android:inputType="textNoSuggestions"
+ android:text="@={name}"
+ app:filter="@{NameInputFilter.newInstance()}" />
+
+ <TextView
+ android:id="@+id/private_key_label"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_below="@+id/interface_name_text"
+ android:labelFor="@+id/private_key_text"
+ android:text="@string/private_key" />
+
+ <EditText
+ android:id="@+id/private_key_text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentStart="true"
+ android:layout_below="@+id/private_key_label"
+ android:layout_toStartOf="@+id/generate_private_key_button"
+ android:contentDescription="@string/public_key_description"
+ android:inputType="textVisiblePassword"
+ android:text="@={config.interface.privateKey}"
+ app:filter="@{KeyInputFilter.newInstance()}" />
+
+ <Button
+ android:id="@+id/generate_private_key_button"
+ android:layout_width="96dp"
+ android:layout_height="wrap_content"
+ android:layout_alignBottom="@id/private_key_text"
+ android:layout_alignParentEnd="true"
+ android:layout_below="@+id/private_key_label"
+ android:onClick="@{() -> config.interface.generateKeypair()}"
+ android:text="@string/generate" />
+
+ <TextView
+ android:id="@+id/public_key_label"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_below="@+id/private_key_text"
+ android:labelFor="@+id/public_key_text"
+ android:text="@string/public_key" />
+
+ <TextView
+ android:id="@+id/public_key_text"
+ style="?android:attr/editTextStyle"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_below="@+id/public_key_label"
+ android:ellipsize="end"
+ android:focusable="false"
+ android:hint="@string/hint_generated"
+ android:maxLines="1"
+ android:onClick="@{ClipboardUtils::copyTextView}"
+ android:text="@{config.interface.publicKey}" />
+
+ <TextView
+ android:id="@+id/addresses_label"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentStart="true"
+ android:layout_below="@+id/public_key_text"
+ android:layout_toStartOf="@+id/listen_port_label"
+ android:labelFor="@+id/addresses_text"
+ android:text="@string/addresses" />
+
+ <EditText
+ android:id="@+id/addresses_text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentStart="true"
+ android:layout_below="@+id/addresses_label"
+ android:layout_toStartOf="@+id/listen_port_text"
+ android:inputType="textNoSuggestions"
+ android:text="@={config.interface.address}" />
+
+ <TextView
+ android:id="@+id/listen_port_label"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignBaseline="@+id/addresses_label"
+ android:layout_alignParentEnd="true"
+ android:layout_alignStart="@+id/generate_private_key_button"
+ android:labelFor="@+id/listen_port_text"
+ android:text="@string/listen_port" />
+
+ <EditText
+ android:id="@+id/listen_port_text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignBaseline="@+id/addresses_text"
+ android:layout_alignParentEnd="true"
+ android:layout_alignStart="@+id/generate_private_key_button"
+ android:hint="@string/hint_random"
+ android:inputType="number"
+ android:text="@={config.interface.listenPort}"
+ android:textAlignment="center" />
+
+ <TextView
+ android:id="@+id/dns_servers_label"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentStart="true"
+ android:layout_below="@+id/addresses_text"
+ android:layout_toStartOf="@+id/mtu_label"
+ android:labelFor="@+id/dns_servers_text"
+ android:text="@string/dns_servers" />
+
+ <EditText
+ android:id="@+id/dns_servers_text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentStart="true"
+ android:layout_below="@+id/dns_servers_label"
+ android:layout_toStartOf="@+id/mtu_text"
+ android:inputType="textNoSuggestions"
+ android:text="@={config.interface.dns}" />
+
+ <TextView
+ android:id="@+id/mtu_label"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignBaseline="@+id/dns_servers_label"
+ android:layout_alignParentEnd="true"
+ android:layout_alignStart="@+id/generate_private_key_button"
+ android:labelFor="@+id/mtu_text"
+ android:text="@string/mtu" />
+
+ <EditText
+ android:id="@+id/mtu_text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignBaseline="@+id/dns_servers_text"
+ android:layout_alignParentEnd="true"
+ android:layout_alignStart="@+id/generate_private_key_button"
+ android:hint="@string/hint_automatic"
+ android:inputType="number"
+ android:text="@={config.interface.mtu}"
+ android:textAlignment="center" />
+ </RelativeLayout>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:divider="@null"
+ android:orientation="vertical"
+ app:items="@{config.peers}"
+ app:layout="@{@layout/config_editor_peer}"
+ tools:ignore="UselessLeaf" />
+
+ <Button
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="4dp"
+ android:layout_marginEnd="4dp"
+ android:layout_marginStart="4dp"
+ android:onClick="@{() -> config.peers.add(Peer.newInstance())}"
+ android:text="@string/add_peer" />
+ </LinearLayout>
+ </ScrollView>
+ </com.commonsware.cwac.crossport.design.widget.CoordinatorLayout>
+</layout>
diff --git a/app/src/main/res/layout/config_edit_peer.xml b/app/src/main/res/layout/config_editor_peer.xml
index 8e627579..a3a2a9c8 100644
--- a/app/src/main/res/layout/config_edit_peer.xml
+++ b/app/src/main/res/layout/config_editor_peer.xml
@@ -4,7 +4,11 @@
<data>
- <import type="com.wireguard.android.KeyInputFilter" />
+ <import type="com.wireguard.android.widget.KeyInputFilter" />
+
+ <variable
+ name="collection"
+ type="android.databinding.ObservableList&lt;com.wireguard.config.Peer&gt;" />
<variable
name="item"
@@ -41,7 +45,7 @@
android:layout_alignParentTop="true"
android:background="@null"
android:contentDescription="@string/delete"
- android:onClick="@{() -> item.removeSelf()}"
+ android:onClick="@{() -> collection.remove(item)}"
android:src="@drawable/ic_action_delete_black" />
<TextView
diff --git a/app/src/main/res/layout/config_list_fragment.xml b/app/src/main/res/layout/config_list_fragment.xml
deleted file mode 100644
index 627ecb86..00000000
--- a/app/src/main/res/layout/config_list_fragment.xml
+++ /dev/null
@@ -1,54 +0,0 @@
-<?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>
-
- <!--suppress AndroidDomInspection -->
- <variable
- name="configs"
- type="com.wireguard.android.databinding.ObservableSortedMap&lt;String, com.wireguard.config.Config&gt;" />
- </data>
-
- <RelativeLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <ListView
- android:id="@+id/config_list"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:choiceMode="singleChoice"
- app:items="@{configs}"
- app:layout="@{@layout/config_list_item}" />
-
- <com.getbase.floatingactionbutton.FloatingActionsMenu
- android:id="@+id/add_menu"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentBottom="true"
- android:layout_alignParentEnd="true"
- android:layout_marginBottom="8dp"
- android:layout_marginEnd="8dp"
- app:fab_labelStyle="@style/fab_label"
- app:fab_labelsPosition="left">
-
- <com.getbase.floatingactionbutton.FloatingActionButton
- android:id="@+id/add_from_file"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- app:fab_icon="@drawable/ic_action_open"
- app:fab_size="mini"
- app:fab_title="@string/add_from_file" />
-
- <com.getbase.floatingactionbutton.FloatingActionButton
- android:id="@+id/add_from_scratch"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- app:fab_icon="@drawable/ic_action_edit"
- app:fab_size="mini"
- app:fab_title="@string/add_from_scratch" />
- </com.getbase.floatingactionbutton.FloatingActionsMenu>
-
- </RelativeLayout>
-</layout>
diff --git a/app/src/main/res/layout/add_activity.xml b/app/src/main/res/layout/main_activity.xml
index 0f21e2e8..d67e64bc 100644
--- a/app/src/main/res/layout/add_activity.xml
+++ b/app/src/main/res/layout/main_activity.xml
@@ -1,7 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/master_fragment"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- tools:ignore="MergeRootFrame" />
+ android:layout_height="match_parent" />
diff --git a/app/src/main/res/layout/not_supported_activity.xml b/app/src/main/res/layout/not_supported_activity.xml
deleted file mode 100644
index ff81e7a4..00000000
--- a/app/src/main/res/layout/not_supported_activity.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<layout xmlns:android="http://schemas.android.com/apk/res/android">
-
- <ScrollView
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <TextView
- android:id="@+id/not_supported_message"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:padding="32dp"
- android:textAppearance="@android:style/TextAppearance.Material.Subhead" />
- </ScrollView>
-</layout>
diff --git a/app/src/main/res/layout/tunnel_detail_fragment.xml b/app/src/main/res/layout/tunnel_detail_fragment.xml
new file mode 100644
index 00000000..e23536a7
--- /dev/null
+++ b/app/src/main/res/layout/tunnel_detail_fragment.xml
@@ -0,0 +1,142 @@
+<?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="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignParentTop="true"
+ android:text="@string/iface" />
+
+ <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/status_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/status_text"
+ android:text="@string/status" />
+
+ <TextView
+ android:id="@+id/status_text"
+ style="?android:attr/textAppearanceMedium"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentStart="true"
+ android:layout_below="@+id/status_label"
+ android:layout_toStartOf="@+id/tunnel_switch"
+ android:text="@{tunnel.state.name}" />
+
+ <com.wireguard.android.widget.ToggleSwitch
+ android:id="@+id/tunnel_switch"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignBaseline="@+id/status_text"
+ android:layout_alignParentEnd="true"
+ android:enabled="@{tunnel.state != State.UNKNOWN}"
+ app:checked="@{tunnel.state == State.UP}"
+ app:onBeforeCheckedChanged="@{() -> tunnel.setState(State.TOGGLE)}" />
+
+ <TextView
+ android:id="@+id/last_change_label"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_below="@id/status_text"
+ android:layout_marginTop="8dp"
+ android:labelFor="@+id/last_change_text"
+ android:text="@string/last_change" />
+
+ <TextView
+ android:id="@+id/last_change_text"
+ style="?android:attr/textAppearanceMedium"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_below="@+id/last_change_label"
+ android:text="@{tunnel.lastStateChange}" />
+
+ <TextView
+ android:id="@+id/public_key_label"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_below="@id/last_change_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>
diff --git a/app/src/main/res/layout/config_detail_peer.xml b/app/src/main/res/layout/tunnel_detail_peer.xml
index 1bd1b333..0de72dea 100644
--- a/app/src/main/res/layout/config_detail_peer.xml
+++ b/app/src/main/res/layout/tunnel_detail_peer.xml
@@ -4,6 +4,10 @@
<data>
<variable
+ name="collection"
+ type="android.databinding.ObservableList&lt;com.wireguard.config.Peer&gt;" />
+
+ <variable
name="item"
type="com.wireguard.config.Peer" />
</data>
@@ -25,7 +29,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
- android:layout_marginBottom="8dp"
android:text="@string/peer" />
<TextView
@@ -33,6 +36,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/peer_title"
+ android:layout_marginTop="8dp"
android:labelFor="@+id/public_key_text"
android:text="@string/public_key" />
@@ -51,6 +55,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/public_key_text"
+ android:layout_marginTop="8dp"
android:labelFor="@+id/allowed_ips_text"
android:text="@string/allowed_ips" />
@@ -67,6 +72,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/allowed_ips_text"
+ android:layout_marginTop="8dp"
android:labelFor="@+id/endpoint_text"
android:text="@string/endpoint" />
diff --git a/app/src/main/res/layout/tunnel_list_fragment.xml b/app/src/main/res/layout/tunnel_list_fragment.xml
new file mode 100644
index 00000000..e4923d54
--- /dev/null
+++ b/app/src/main/res/layout/tunnel_list_fragment.xml
@@ -0,0 +1,59 @@
+<?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>
+
+ <variable
+ name="fragment"
+ type="com.wireguard.android.fragment.TunnelListFragment" />
+
+ <variable
+ name="tunnels"
+ type="com.wireguard.android.model.TunnelCollection" />
+ </data>
+
+ <com.commonsware.cwac.crossport.design.widget.CoordinatorLayout
+ android:id="@+id/main_container"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="?android:attr/colorBackground">
+
+ <ListView
+ android:id="@+id/tunnel_list"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:choiceMode="multipleChoiceModal"
+ app:items="@{tunnels}"
+ app:layout="@{@layout/tunnel_list_item}" />
+
+ <com.getbase.floatingactionbutton.FloatingActionsMenu
+ android:id="@+id/create_menu"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="bottom|end"
+ android:layout_margin="8dp"
+ app:fab_labelStyle="@style/fab_label"
+ app:fab_labelsPosition="left"
+ app:layout_dodgeInsetEdges="bottom">
+
+ <com.getbase.floatingactionbutton.FloatingActionButton
+ android:id="@+id/create_empty"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:onClick="@{fragment::onRequestCreateConfig}"
+ app:fab_icon="@drawable/ic_action_edit"
+ app:fab_size="mini"
+ app:fab_title="@string/create_empty" />
+
+ <com.getbase.floatingactionbutton.FloatingActionButton
+ android:id="@+id/create_from_file"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:onClick="@{fragment::onRequestImportConfig}"
+ app:fab_icon="@drawable/ic_action_open"
+ app:fab_size="mini"
+ app:fab_title="@string/create_from_file" />
+ </com.getbase.floatingactionbutton.FloatingActionsMenu>
+ </com.commonsware.cwac.crossport.design.widget.CoordinatorLayout>
+</layout>
diff --git a/app/src/main/res/layout/config_list_item.xml b/app/src/main/res/layout/tunnel_list_item.xml
index 90e696a4..c8706546 100644
--- a/app/src/main/res/layout/config_list_item.xml
+++ b/app/src/main/res/layout/tunnel_list_item.xml
@@ -4,9 +4,11 @@
<data>
- <import type="android.graphics.Typeface" />
+ <import type="com.wireguard.android.model.Tunnel.State" />
- <import type="com.wireguard.android.backends.VpnService" />
+ <variable
+ name="collection"
+ type="com.wireguard.android.model.TunnelCollection" />
<variable
name="key"
@@ -14,7 +16,7 @@
<variable
name="item"
- type="com.wireguard.config.Config" />
+ type="com.wireguard.android.model.Tunnel" />
</data>
<RelativeLayout
@@ -25,24 +27,25 @@
android:padding="16dp">
<TextView
- android:id="@+id/config_name"
+ android:id="@+id/tunnel_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:layout_alignParentTop="true"
+ android:layout_toStartOf="@+id/tunnel_switch"
android:ellipsize="end"
android:maxLines="1"
- android:text="@{key}"
- android:textStyle="@{item.primary ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT}" />
+ android:text="@{key}" />
<com.wireguard.android.widget.ToggleSwitch
- android:id="@+id/config_switch"
+ android:id="@+id/tunnel_switch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_alignBaseline="@+id/config_name"
+ android:layout_alignBaseline="@+id/tunnel_name"
android:layout_alignParentEnd="true"
- app:checked="@{item.enabled}"
- app:onBeforeCheckedChanged="@{(v, checked) -> checked ? VpnService.instance.enable(item.name) : VpnService.instance.disable(item.name)}" />
+ android:enabled="@{item.state != State.UNKNOWN}"
+ app:checked="@{item.state == State.UP}"
+ app:onBeforeCheckedChanged="@{() -> item.setState(State.TOGGLE)}" />
</RelativeLayout>
</layout>
diff --git a/app/src/main/res/menu/config_edit.xml b/app/src/main/res/menu/config_editor.xml
index 44e719c7..44e719c7 100644
--- a/app/src/main/res/menu/config_edit.xml
+++ b/app/src/main/res/menu/config_editor.xml
diff --git a/app/src/main/res/menu/main.xml b/app/src/main/res/menu/main_activity.xml
index 462558ec..462558ec 100644
--- a/app/src/main/res/menu/main.xml
+++ b/app/src/main/res/menu/main_activity.xml
diff --git a/app/src/main/res/menu/config_detail.xml b/app/src/main/res/menu/tunnel_detail.xml
index c00c1603..c00c1603 100644
--- a/app/src/main/res/menu/config_detail.xml
+++ b/app/src/main/res/menu/tunnel_detail.xml
diff --git a/app/src/main/res/menu/config_list_delete.xml b/app/src/main/res/menu/tunnel_list_action_mode.xml
index 7896d522..7896d522 100644
--- a/app/src/main/res/menu/config_list_delete.xml
+++ b/app/src/main/res/menu/tunnel_list_action_mode.xml
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 02d2ac4c..2b5d49c2 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -5,8 +5,8 @@
<item quantity="other">%d configurations selected</item>
</plurals>
<string name="add_activity_title">New WireGuard configuration</string>
- <string name="add_from_file">Add from file</string>
- <string name="add_from_scratch">Add from scratch</string>
+ <string name="create_from_file">Add from file</string>
+ <string name="create_empty">Add from scratch</string>
<string name="add_peer">Add peer</string>
<string name="addresses">Addresses</string>
<string name="allowed_ips">Allowed IPs</string>
@@ -57,7 +57,7 @@
<string name="private_key">Private key</string>
<string name="public_key">Public key</string>
<string name="public_key_copied_message">Public key copied to clipboard</string>
- <string name="public_key_description">WireGuard public key</string>
+ <string name="public_key_description">Public key</string>
<string name="restore_on_boot">Restore on boot</string>
<string name="restore_on_boot_summary">Restore previously enabled configurations on boot</string>
<string name="install_cmd_line_tools">Install command line tools</string>
@@ -70,4 +70,6 @@
<string name="settings">Settings</string>
<string name="status">Status</string>
<string name="toggle">Toggle</string>
+ <string name="last_change">Last change</string>
+ <string name="never">never</string>
</resources>
diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml
index 012e08fa..1693839b 100644
--- a/app/src/main/res/xml/preferences.xml
+++ b/app/src/main/res/xml/preferences.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
- <com.wireguard.android.ConfigListPreference
+ <com.wireguard.android.preference.TunnelListPreference
android:key="primary_config"
android:summary="@string/primary_config_summary"
android:title="@string/primary_config" />