diff options
author | Samuel Holland <samuel@sholland.org> | 2017-08-08 05:51:38 -0500 |
---|---|---|
committer | Samuel Holland <samuel@sholland.org> | 2017-08-08 05:51:38 -0500 |
commit | add6b4c1e8b11e06a68e67960a5f761b189b9401 (patch) | |
tree | 10946a6214e0641eb0581b77c9f2bfadc511029f /app/src/main/res | |
parent | df4608a9b2fd784ff03d72f4a6bc10c2da0da9c0 (diff) |
ProfileActivity: Refactor into clean layers of functionality
Diffstat (limited to 'app/src/main/res')
-rw-r--r-- | app/src/main/res/drawable/ic_action_edit.xml | 9 | ||||
-rw-r--r-- | app/src/main/res/drawable/ic_action_save.xml | 10 | ||||
-rw-r--r-- | app/src/main/res/layout-land/profile_activity.xml | 19 | ||||
-rw-r--r-- | app/src/main/res/layout/placeholder_fragment.xml | 7 | ||||
-rw-r--r-- | app/src/main/res/layout/profile_activity.xml | 22 | ||||
-rw-r--r-- | app/src/main/res/layout/profile_detail_fragment.xml | 71 | ||||
-rw-r--r-- | app/src/main/res/layout/profile_list_fragment.xml | 1 | ||||
-rw-r--r-- | app/src/main/res/menu/profile_detail.xml | 9 | ||||
-rw-r--r-- | app/src/main/res/menu/profile_detail_edit.xml | 9 | ||||
-rw-r--r-- | app/src/main/res/values/strings.xml | 5 |
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<String, com.wireguard.config.Profile>" /> 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> |