summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2018-06-28 20:05:33 +0530
committerJason A. Donenfeld <Jason@zx2c4.com>2018-06-30 21:07:24 +0200
commit0e3e3ae37b093c8de04be2a141e7b49d708f5336 (patch)
tree802e241068af8b81b3ca7ad230590312ebe3566f
parentb41d473f645ffa9b4f349c7deec7e45693056a29 (diff)
android: Add select all button to action mode
Thanks to Jason for suggesting the not-clinically-insane method to go about this. Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
-rw-r--r--app/src/main/java/com/wireguard/android/fragment/TunnelListFragment.java4
-rw-r--r--app/src/main/res/drawable/ic_action_select_all.xml10
-rw-r--r--app/src/main/res/menu/tunnel_list_action_mode.xml6
-rw-r--r--app/src/main/res/values/strings.xml1
4 files changed, 21 insertions, 0 deletions
diff --git a/app/src/main/java/com/wireguard/android/fragment/TunnelListFragment.java b/app/src/main/java/com/wireguard/android/fragment/TunnelListFragment.java
index e244f756..72e2fbdb 100644
--- a/app/src/main/java/com/wireguard/android/fragment/TunnelListFragment.java
+++ b/app/src/main/java/com/wireguard/android/fragment/TunnelListFragment.java
@@ -305,6 +305,10 @@ public class TunnelListFragment extends BaseFragment {
.whenComplete(TunnelListFragment.this::onTunnelDeletionFinished);
mode.finish();
return true;
+ case R.id.menu_action_select_all:
+ for (int i = 0; i < tunnelList.getAdapter().getCount(); ++i)
+ tunnelList.setItemChecked(i, true);
+ return true;
default:
return false;
}
diff --git a/app/src/main/res/drawable/ic_action_select_all.xml b/app/src/main/res/drawable/ic_action_select_all.xml
new file mode 100644
index 00000000..2ddfb85a
--- /dev/null
+++ b/app/src/main/res/drawable/ic_action_select_all.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:viewportWidth="24"
+ android:viewportHeight="24"
+ android:width="24dp"
+ android:height="24dp">
+ <path
+ android:fillColor="?android:attr/colorForeground"
+ android:pathData="M3 5L5 5 5 3C3.9 3 3 3.9 3 5Zm0 8l2 0 0 -2 -2 0 0 2zm4 8l2 0 0 -2 -2 0 0 2zM3 9L5 9 5 7 3 7 3 9Zm10 -6l-2 0 0 2 2 0 0 -2zm6 0l0 2 2 0C21 3.9 20.1 3 19 3ZM5 21L5 19 3 19c0 1.1 0.9 2 2 2zm-2 -4l2 0 0 -2 -2 0 0 2zM9 3L7 3 7 5 9 5 9 3Zm2 18l2 0 0 -2 -2 0 0 2zm8 -8l2 0 0 -2 -2 0 0 2zm0 8c1.1 0 2 -0.9 2 -2l-2 0 0 2zm0 -12l2 0 0 -2 -2 0 0 2zm0 8l2 0 0 -2 -2 0 0 2zm-4 4l2 0 0 -2 -2 0 0 2zm0 -16l2 0 0 -2 -2 0 0 2zM7 17L17 17 17 7 7 7 7 17Zm2 -8l6 0 0 6 -6 0 0 -6z" />
+</vector> \ No newline at end of file
diff --git a/app/src/main/res/menu/tunnel_list_action_mode.xml b/app/src/main/res/menu/tunnel_list_action_mode.xml
index 6b03cd19..22f61943 100644
--- a/app/src/main/res/menu/tunnel_list_action_mode.xml
+++ b/app/src/main/res/menu/tunnel_list_action_mode.xml
@@ -2,6 +2,12 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
+ android:id="@+id/menu_action_select_all"
+ android:alphabeticShortcut="s"
+ android:icon="@drawable/ic_action_select_all"
+ android:title="@string/select_all"
+ app:showAsAction="always" />
+ <item
android:id="@+id/menu_action_delete"
android:alphabeticShortcut="d"
android:icon="@drawable/ic_action_delete"
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index cbf0542e..56966750 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -33,6 +33,7 @@
<string name="dark_theme_summary_on">Currently using dark night theme</string>
<string name="dark_theme_summary_off">Currently using light day theme</string>
<string name="delete">Delete</string>
+ <string name="select_all">Select all</string>
<string name="dns_servers">DNS servers</string>
<string name="edit">Edit</string>
<string name="endpoint">Endpoint</string>