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>
This commit is contained in:
Harsh Shandilya 2018-06-28 20:05:33 +05:30 committed by Jason A. Donenfeld
parent b41d473f64
commit 0e3e3ae37b
4 changed files with 21 additions and 0 deletions

View File

@ -305,6 +305,10 @@ public class TunnelListFragment extends BaseFragment {
.whenComplete(TunnelListFragment.this::onTunnelDeletionFinished); .whenComplete(TunnelListFragment.this::onTunnelDeletionFinished);
mode.finish(); mode.finish();
return true; 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: default:
return false; return false;
} }

View File

@ -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>

View File

@ -1,6 +1,12 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" <menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"> 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 <item
android:id="@+id/menu_action_delete" android:id="@+id/menu_action_delete"
android:alphabeticShortcut="d" android:alphabeticShortcut="d"

View File

@ -33,6 +33,7 @@
<string name="dark_theme_summary_on">Currently using dark night theme</string> <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="dark_theme_summary_off">Currently using light day theme</string>
<string name="delete">Delete</string> <string name="delete">Delete</string>
<string name="select_all">Select all</string>
<string name="dns_servers">DNS servers</string> <string name="dns_servers">DNS servers</string>
<string name="edit">Edit</string> <string name="edit">Edit</string>
<string name="endpoint">Endpoint</string> <string name="endpoint">Endpoint</string>