aboutsummaryrefslogtreecommitdiffstats
path: root/OpenPGP-Keychain
diff options
context:
space:
mode:
authoruberspot <onexemailx@gmail.com>2014-03-06 20:32:10 +0200
committeruberspot <onexemailx@gmail.com>2014-03-06 20:32:27 +0200
commit1cf912de2b388fbe996e3014a00a0d91f22194a5 (patch)
tree108bbe0c8d08eb61cfc4b0febf0ee6f4c1058fa5 /OpenPGP-Keychain
parent0ed097a020ee433cd9cbeb4f95ea06a505f1c242 (diff)
downloadopen-keychain-1cf912de2b388fbe996e3014a00a0d91f22194a5.tar.gz
open-keychain-1cf912de2b388fbe996e3014a00a0d91f22194a5.tar.bz2
open-keychain-1cf912de2b388fbe996e3014a00a0d91f22194a5.zip
Multiselect: Create 'select all' in public and secret keylist
Diffstat (limited to 'OpenPGP-Keychain')
-rw-r--r--OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListPublicFragment.java15
-rw-r--r--OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListSecretFragment.java14
-rw-r--r--OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/KeyListPublicAdapter.java2
-rw-r--r--OpenPGP-Keychain/src/main/res/drawable-hdpi/ic_action_select_all.pngbin0 -> 507 bytes
-rw-r--r--OpenPGP-Keychain/src/main/res/drawable-mdpi/ic_action_select_all.pngbin0 -> 292 bytes
-rw-r--r--OpenPGP-Keychain/src/main/res/drawable-xhdpi/ic_action_select_all.pngbin0 -> 351 bytes
-rw-r--r--OpenPGP-Keychain/src/main/res/drawable-xxhdpi/ic_action_select_all.pngbin0 -> 563 bytes
-rw-r--r--OpenPGP-Keychain/src/main/res/menu/key_list_public_multi.xml4
-rw-r--r--OpenPGP-Keychain/src/main/res/menu/key_list_secret_multi.xml4
-rw-r--r--OpenPGP-Keychain/src/main/res/values/strings.xml1
10 files changed, 28 insertions, 12 deletions
diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListPublicFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListPublicFragment.java
index 95267e01f..f2cb8a265 100644
--- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListPublicFragment.java
+++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListPublicFragment.java
@@ -144,8 +144,6 @@ public class KeyListPublicFragment extends Fragment implements SearchView.OnQuer
mStickyList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
mStickyList.getWrappedList().setMultiChoiceModeListener(new MultiChoiceModeListener() {
- private int count = 0;
-
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
android.view.MenuInflater inflater = getActivity().getMenuInflater();
@@ -179,13 +177,20 @@ public class KeyListPublicFragment extends Fragment implements SearchView.OnQuer
showDeleteKeyDialog(mode, ids);
break;
}
+ case R.id.menu_key_list_public_multi_select_all: {
+ //Select all
+ int localCount = mStickyList.getCount();
+ for(int k = 0; k < localCount; k++) {
+ mStickyList.setItemChecked(k, true);
+ }
+ break;
+ }
}
return true;
}
@Override
public void onDestroyActionMode(ActionMode mode) {
- count = 0;
mAdapter.clearSelection();
}
@@ -193,13 +198,11 @@ public class KeyListPublicFragment extends Fragment implements SearchView.OnQuer
public void onItemCheckedStateChanged(ActionMode mode, int position, long id,
boolean checked) {
if (checked) {
- count++;
mAdapter.setNewSelection(position, checked);
} else {
- count--;
mAdapter.removeSelection(position);
}
-
+ int count = mAdapter.getCurrentCheckedPosition().size();
String keysSelected = getResources().getQuantityString(
R.plurals.key_list_selected_keys, count, count);
mode.setTitle(keysSelected);
diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListSecretFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListSecretFragment.java
index 7bb77b60f..eaac6d8b1 100644
--- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListSecretFragment.java
+++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListSecretFragment.java
@@ -82,8 +82,6 @@ public class KeyListSecretFragment extends ListFragment implements
getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
getListView().setMultiChoiceModeListener(new MultiChoiceModeListener() {
- private int count = 0;
-
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
android.view.MenuInflater inflater = getActivity().getMenuInflater();
@@ -113,13 +111,20 @@ public class KeyListSecretFragment extends ListFragment implements
showDeleteKeyDialog(mode, ids);
break;
}
+ case R.id.menu_key_list_public_multi_select_all: {
+ //Select all
+ int localCount = getListView().getCount();
+ for(int k = 0; k < localCount; k++) {
+ getListView().setItemChecked(k, true);
+ }
+ break;
+ }
}
return true;
}
@Override
public void onDestroyActionMode(ActionMode mode) {
- count = 0;
mAdapter.clearSelection();
}
@@ -127,13 +132,12 @@ public class KeyListSecretFragment extends ListFragment implements
public void onItemCheckedStateChanged(ActionMode mode, int position, long id,
boolean checked) {
if (checked) {
- count++;
mAdapter.setNewSelection(position, checked);
} else {
- count--;
mAdapter.removeSelection(position);
}
+ int count = getListView().getCheckedItemCount();
String keysSelected = getResources().getQuantityString(
R.plurals.key_list_selected_keys, count, count);
mode.setTitle(keysSelected);
diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/KeyListPublicAdapter.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/KeyListPublicAdapter.java
index 257136cbd..ac505adfb 100644
--- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/KeyListPublicAdapter.java
+++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/KeyListPublicAdapter.java
@@ -223,7 +223,7 @@ public class KeyListPublicAdapter extends CursorAdapter implements StickyListHea
*/
// default color
v.setBackgroundColor(Color.TRANSPARENT);
- if (mSelection.get(position) != null) {
+ if (mSelection.get(position) != null && mSelection.get(position).booleanValue()) {
// this is a selected position, change color!
v.setBackgroundColor(parent.getResources().getColor(R.color.emphasis));
}
diff --git a/OpenPGP-Keychain/src/main/res/drawable-hdpi/ic_action_select_all.png b/OpenPGP-Keychain/src/main/res/drawable-hdpi/ic_action_select_all.png
new file mode 100644
index 000000000..fc0dd57b6
--- /dev/null
+++ b/OpenPGP-Keychain/src/main/res/drawable-hdpi/ic_action_select_all.png
Binary files differ
diff --git a/OpenPGP-Keychain/src/main/res/drawable-mdpi/ic_action_select_all.png b/OpenPGP-Keychain/src/main/res/drawable-mdpi/ic_action_select_all.png
new file mode 100644
index 000000000..da37d7a6e
--- /dev/null
+++ b/OpenPGP-Keychain/src/main/res/drawable-mdpi/ic_action_select_all.png
Binary files differ
diff --git a/OpenPGP-Keychain/src/main/res/drawable-xhdpi/ic_action_select_all.png b/OpenPGP-Keychain/src/main/res/drawable-xhdpi/ic_action_select_all.png
new file mode 100644
index 000000000..af37a3680
--- /dev/null
+++ b/OpenPGP-Keychain/src/main/res/drawable-xhdpi/ic_action_select_all.png
Binary files differ
diff --git a/OpenPGP-Keychain/src/main/res/drawable-xxhdpi/ic_action_select_all.png b/OpenPGP-Keychain/src/main/res/drawable-xxhdpi/ic_action_select_all.png
new file mode 100644
index 000000000..aa5937eab
--- /dev/null
+++ b/OpenPGP-Keychain/src/main/res/drawable-xxhdpi/ic_action_select_all.png
Binary files differ
diff --git a/OpenPGP-Keychain/src/main/res/menu/key_list_public_multi.xml b/OpenPGP-Keychain/src/main/res/menu/key_list_public_multi.xml
index 2408aabcc..d30ee5e8f 100644
--- a/OpenPGP-Keychain/src/main/res/menu/key_list_public_multi.xml
+++ b/OpenPGP-Keychain/src/main/res/menu/key_list_public_multi.xml
@@ -2,6 +2,10 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
+ android:id="@+id/menu_key_list_public_multi_select_all"
+ android:icon="@drawable/ic_action_select_all"
+ android:title="@string/menu_select_all" />
+ <item
android:id="@+id/menu_key_list_public_multi_encrypt"
android:icon="@drawable/ic_action_secure"
android:title="@string/menu_encrypt_to" />
diff --git a/OpenPGP-Keychain/src/main/res/menu/key_list_secret_multi.xml b/OpenPGP-Keychain/src/main/res/menu/key_list_secret_multi.xml
index 9cfab9fd3..a3375c7e8 100644
--- a/OpenPGP-Keychain/src/main/res/menu/key_list_secret_multi.xml
+++ b/OpenPGP-Keychain/src/main/res/menu/key_list_secret_multi.xml
@@ -2,6 +2,10 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
+ android:id="@+id/menu_key_list_public_multi_select_all"
+ android:icon="@drawable/ic_action_select_all"
+ android:title="@string/menu_select_all" />
+ <item
android:id="@+id/menu_key_list_public_multi_delete"
android:icon="@drawable/ic_action_discard"
android:title="@string/menu_delete_key" />
diff --git a/OpenPGP-Keychain/src/main/res/values/strings.xml b/OpenPGP-Keychain/src/main/res/values/strings.xml
index 9689010ed..2950b7c3f 100644
--- a/OpenPGP-Keychain/src/main/res/values/strings.xml
+++ b/OpenPGP-Keychain/src/main/res/values/strings.xml
@@ -96,6 +96,7 @@
<string name="menu_beam_preferences">Beam settings</string>
<string name="menu_key_edit_cancel">Cancel</string>
<string name="menu_encrypt_to">Encrypt to…</string>
+ <string name="menu_select_all">Select all</string>
<!-- label -->
<string name="label_sign">Sign</string>