summaryrefslogtreecommitdiffhomepage
path: root/app/src/main/res
diff options
context:
space:
mode:
authorSamuel Holland <samuel@sholland.org>2017-08-08 05:51:38 -0500
committerSamuel Holland <samuel@sholland.org>2017-08-08 05:51:38 -0500
commit0685d4a1591cac4683e3c6e73024414fdb1739f0 (patch)
tree10946a6214e0641eb0581b77c9f2bfadc511029f /app/src/main/res
parent3076fd8c4159aa1ecfcc4860b4bed9a60f4093e9 (diff)
ProfileActivity: Refactor into clean layers of functionality
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'app/src/main/res')
-rw-r--r--app/src/main/res/drawable/ic_action_edit.xml9
-rw-r--r--app/src/main/res/drawable/ic_action_save.xml10
-rw-r--r--app/src/main/res/layout-land/profile_activity.xml19
-rw-r--r--app/src/main/res/layout/placeholder_fragment.xml7
-rw-r--r--app/src/main/res/layout/profile_activity.xml22
-rw-r--r--app/src/main/res/layout/profile_detail_fragment.xml71
-rw-r--r--app/src/main/res/layout/profile_list_fragment.xml1
-rw-r--r--app/src/main/res/menu/profile_detail.xml9
-rw-r--r--app/src/main/res/menu/profile_detail_edit.xml9
-rw-r--r--app/src/main/res/values/strings.xml5
10 files changed, 132 insertions, 30 deletions
diff --git a/app/src/main/res/drawable/ic_action_edit.xml b/app/src/main/res/drawable/ic_action_edit.xml
new file mode 100644
index 00000000..c910949f
--- /dev/null
+++ b/app/src/main/res/drawable/ic_action_edit.xml
@@ -0,0 +1,9 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="48dp"
+ android:height="48dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0">
+ <path
+ android:pathData="M3,17.25V21h3.75L17.81,9.94l-3.75,-3.75L3,17.25zM20.71,7.04c0.39,-0.39 0.39,-1.02 0,-1.41l-2.34,-2.34c-0.39,-0.39 -1.02,-0.39 -1.41,0l-1.83,1.83 3.75,3.75 1.83,-1.83z"
+ android:fillColor="#FFFFFF"/>
+</vector>
diff --git a/app/src/main/res/drawable/ic_action_save.xml b/app/src/main/res/drawable/ic_action_save.xml
new file mode 100644
index 00000000..08280124
--- /dev/null
+++ b/app/src/main/res/drawable/ic_action_save.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="48dp"
+ android:height="48dp"
+ android:viewportHeight="24.0"
+ android:viewportWidth="24.0">
+ <path
+ android:fillColor="#FFFFFF"
+ android:pathData="M17,3L5,3c-1.11,0 -2,0.9 -2,2v14c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2L21,7l-4,-4zM12,19c-1.66,0 -3,-1.34 -3,-3s1.34,-3 3,-3 3,1.34 3,3 -1.34,3 -3,3zM15,9L5,9L5,5h10v4z" />
+</vector>
diff --git a/app/src/main/res/layout-land/profile_activity.xml b/app/src/main/res/layout-land/profile_activity.xml
deleted file mode 100644
index acc56925..00000000
--- a/app/src/main/res/layout-land/profile_activity.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:baselineAligned="false"
- android:orientation="horizontal">
-
- <FrameLayout
- android:id="@+id/list_fragment_container"
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:layout_weight="1" />
-
- <FrameLayout
- android:id="@+id/detail_fragment_container"
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:layout_weight="2" />
-</LinearLayout>
diff --git a/app/src/main/res/layout/placeholder_fragment.xml b/app/src/main/res/layout/placeholder_fragment.xml
deleted file mode 100644
index 8a321c6b..00000000
--- a/app/src/main/res/layout/placeholder_fragment.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<TextView xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/text"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:gravity="center"
- android:text="@string/placeholder_text" />
diff --git a/app/src/main/res/layout/profile_activity.xml b/app/src/main/res/layout/profile_activity.xml
index d9b6a1f6..2645552b 100644
--- a/app/src/main/res/layout/profile_activity.xml
+++ b/app/src/main/res/layout/profile_activity.xml
@@ -1,5 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/list_fragment_container"
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
- android:layout_height="match_parent" />
+ android:layout_height="match_parent"
+ android:baselineAligned="false"
+ android:orientation="horizontal">
+
+ <fragment
+ android:name="com.wireguard.android.ProfileListFragment"
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:tag="list" />
+
+ <fragment
+ android:name="com.wireguard.android.ProfileDetailFragment"
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:layout_weight="2"
+ android:tag="detail" />
+</LinearLayout>
diff --git a/app/src/main/res/layout/profile_detail_fragment.xml b/app/src/main/res/layout/profile_detail_fragment.xml
new file mode 100644
index 00000000..248f11a1
--- /dev/null
+++ b/app/src/main/res/layout/profile_detail_fragment.xml
@@ -0,0 +1,71 @@
+<?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.view.View" />
+
+ <variable
+ name="profile"
+ type="com.wireguard.config.Profile" />
+ </data>
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:padding="16dp">
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:gravity="center"
+ android:text="@string/placeholder_text"
+ android:visibility="@{profile == null ? View.VISIBLE : View.GONE}" />
+
+ <ScrollView
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:visibility="@{profile == null ? View.GONE : View.VISIBLE}">
+
+ <RelativeLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+
+ <TextView
+ android:id="@+id/profile_name_label"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignParentTop="true"
+ android:labelFor="@+id/profile_name_text"
+ android:text="@string/profile_name" />
+
+ <TextView
+ android:id="@+id/profile_name_text"
+ style="?android:attr/textAppearanceMedium"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_below="@+id/profile_name_label"
+ android:text="@{profile.name}" />
+
+ <TextView
+ android:id="@+id/public_key_label"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_below="@+id/profile_name_text"
+ 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="@{profile.interface.publicKey}" />
+ </RelativeLayout>
+ </ScrollView>
+ </FrameLayout>
+</layout>
diff --git a/app/src/main/res/layout/profile_list_fragment.xml b/app/src/main/res/layout/profile_list_fragment.xml
index c0edd444..f5954092 100644
--- a/app/src/main/res/layout/profile_list_fragment.xml
+++ b/app/src/main/res/layout/profile_list_fragment.xml
@@ -4,6 +4,7 @@
<data>
+ <!--suppress AndroidDomInspection -->
<variable
name="profiles"
type="android.databinding.ObservableArrayMap&lt;String, com.wireguard.config.Profile&gt;" />
diff --git a/app/src/main/res/menu/profile_detail.xml b/app/src/main/res/menu/profile_detail.xml
new file mode 100644
index 00000000..499adcdb
--- /dev/null
+++ b/app/src/main/res/menu/profile_detail.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+ <item
+ android:alphabeticShortcut="e"
+ android:icon="@drawable/ic_action_edit"
+ android:onClick="onMenuEdit"
+ android:showAsAction="always"
+ android:title="@string/edit" />
+</menu>
diff --git a/app/src/main/res/menu/profile_detail_edit.xml b/app/src/main/res/menu/profile_detail_edit.xml
new file mode 100644
index 00000000..ad97fcbf
--- /dev/null
+++ b/app/src/main/res/menu/profile_detail_edit.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+ <item
+ android:alphabeticShortcut="s"
+ android:icon="@drawable/ic_action_save"
+ android:onClick="onMenuSave"
+ android:showAsAction="always"
+ android:title="@string/save" />
+</menu>
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index cbedef43..4010e776 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -3,6 +3,9 @@
<string name="app_name">WireGuard</string>
<string name="connected">Connected</string>
<string name="disconnected">Disconnected</string>
- <string name="placeholder_text">No profile selected.</string>
+ <string name="placeholder_text">No profile selected</string>
+ <string name="profile_name">Profile name</string>
+ <string name="public_key">Public key</string>
+ <string name="save">Save</string>
<string name="settings">Settings</string>
</resources>