diff options
author | Eric Kuck <eric@bluelinelabs.com> | 2018-07-04 16:47:55 -0500 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-07-06 04:14:19 +0200 |
commit | 500a705531a3210aa98b17b77085cf1ea86c274d (patch) | |
tree | 8eee63dc202e5e1414354f5827873a1e9c642be9 /app/src/main/res | |
parent | 5729947d6ca3aa99d3811ca0e6624ad0ce0f969d (diff) |
AppListDialogFragment: add implementation for excluding applications
Signed-off-by: Eric Kuck <eric@bluelinelabs.com>
Diffstat (limited to 'app/src/main/res')
-rw-r--r-- | app/src/main/res/layout/app_list_dialog_fragment.xml | 43 | ||||
-rw-r--r-- | app/src/main/res/layout/app_list_item.xml | 56 | ||||
-rw-r--r-- | app/src/main/res/layout/tunnel_editor_fragment.xml | 13 | ||||
-rw-r--r-- | app/src/main/res/values/strings.xml | 6 |
4 files changed, 118 insertions, 0 deletions
diff --git a/app/src/main/res/layout/app_list_dialog_fragment.xml b/app/src/main/res/layout/app_list_dialog_fragment.xml new file mode 100644 index 00000000..25879b6b --- /dev/null +++ b/app/src/main/res/layout/app_list_dialog_fragment.xml @@ -0,0 +1,43 @@ +<?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" /> + + <import type="com.wireguard.android.model.ApplicationData" /> + + <variable + name="fragment" + type="com.wireguard.android.fragment.AppListDialogFragment" /> + + <variable + name="appData" + type="com.wireguard.android.util.ObservableKeyedList<String, ApplicationData>" /> + </data> + + <FrameLayout + android:layout_width="match_parent" + android:layout_height="match_parent" + android:minHeight="200dp" > + + <ProgressBar + android:id="@+id/progress_bar" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:indeterminate="true" + android:visibility="@{appData.isEmpty() ? View.VISIBLE : View.GONE}"/> + + <android.support.v7.widget.RecyclerView + android:id="@+id/app_list" + android:layout_width="match_parent" + android:layout_height="match_parent" + app:items="@{appData}" + app:layout="@{@layout/app_list_item}" /> + + </FrameLayout> + + +</layout> diff --git a/app/src/main/res/layout/app_list_item.xml b/app/src/main/res/layout/app_list_item.xml new file mode 100644 index 00000000..d4a41c83 --- /dev/null +++ b/app/src/main/res/layout/app_list_item.xml @@ -0,0 +1,56 @@ +<?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="com.wireguard.android.model.ApplicationData" /> + + <variable + name="collection" + type="com.wireguard.android.util.ObservableKeyedList<String, com.wireguard.android.model.ApplicationData>" /> + + <variable + name="key" + type="String" /> + + <variable + name="item" + type="com.wireguard.android.model.ApplicationData" /> + </data> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:background="@drawable/list_item_background_anim" + android:padding="16dp" + android:orientation="horizontal" + android:gravity="center_vertical" + android:onClick="@{(view) -> item.setExcludedFromTunnel(!item.excludedFromTunnel)}"> + + <ImageView + android:id="@+id/app_icon" + android:layout_width="32dp" + android:layout_height="32dp" + android:src="@{item.icon}" /> + + <TextView + android:id="@+id/app_name" + style="?android:attr/textAppearanceMedium" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_weight="1" + android:ellipsize="end" + android:maxLines="1" + android:paddingEnd="8dp" + android:paddingStart="8dp" + android:text="@{key}" /> + + <CheckBox + android:id="@+id/excluded_checkbox" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:checked="@={item.excludedFromTunnel}" /> + + </LinearLayout> +</layout> diff --git a/app/src/main/res/layout/tunnel_editor_fragment.xml b/app/src/main/res/layout/tunnel_editor_fragment.xml index 060920d6..cbdc46cf 100644 --- a/app/src/main/res/layout/tunnel_editor_fragment.xml +++ b/app/src/main/res/layout/tunnel_editor_fragment.xml @@ -14,6 +14,10 @@ <import type="com.wireguard.config.Peer" /> <variable + name="fragment" + type="com.wireguard.android.fragment.TunnelEditorFragment" /> + + <variable name="config" type="com.wireguard.config.Config.Observable" /> </data> @@ -211,6 +215,15 @@ android:inputType="number" android:text="@={config.interfaceSection.mtu}" android:textAlignment="center" /> + + <Button + style="@style/Widget.AppCompat.Button.Borderless.Colored" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginLeft="-8dp" + android:layout_below="@+id/dns_servers_text" + android:onClick="@{fragment::onRequestSetExcludedApplications}" + android:text="@{fragment.excludedApplications().length == 0 ? @string/set_excluded_applications : String.format(@string/x_excluded_applications, fragment.excludedApplications().length)}" /> </RelativeLayout> </android.support.v7.widget.CardView> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 56966750..082a7477 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -24,6 +24,7 @@ <string name="addresses">Addresses</string> <string name="allowed_ips">Allowed IPs</string> <string name="app_name">WireGuard</string> + <string name="cancel">Cancel</string> <string name="config_save_error">Unable to save configuration for ā%sā: %s</string> <string name="config_save_success">Successfully saved configuration for ā%sā</string> <string name="create_activity_title">Create WireGuard Tunnel</string> @@ -37,9 +38,11 @@ <string name="dns_servers">DNS servers</string> <string name="edit">Edit</string> <string name="endpoint">Endpoint</string> + <string name="error_fetching_apps">Error fetching apps list: %s</string> <string name="error_down">Error bringing down tunnel: %s</string> <string name="error_root">Please obtain root access and try again</string> <string name="error_up">Error bringing up tunnel: %s</string> + <string name="excluded_applications">Excluded Applications</string> <string name="generate">Generate</string> <string name="hint_automatic">(auto)</string> <string name="hint_generated">(generated)</string> @@ -66,6 +69,8 @@ <string name="restore_on_boot_summary">Bring up previously-enabled tunnels on boot</string> <string name="restore_on_boot_title">Restore on boot</string> <string name="save">Save</string> + <string name="set_excluded_applications">Set Excluded Applications</string> + <string name="set_exclusions">Set Exclusions</string> <string name="settings">Settings</string> <string name="toggle_error">Error toggling WireGuard tunnel: %s</string> <string name="tools_installer_already">wg and wg-quick are already installed</string> @@ -85,6 +90,7 @@ <string name="version_summary">%s backend v%s</string> <string name="version_summary_checking">Checking %s backend version</string> <string name="version_summary_unknown">Unknown %s version</string> + <string name="x_excluded_applications">%d Excluded Applications</string> <string name="zip_exporter_title">Export tunnels to zip file</string> <string name="zip_export_error">Unable to export tunnels: %s</string> <string name="zip_export_success">Saved to %s</string> |