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 Binary files /dev/null and b/OpenPGP-Keychain/src/main/res/drawable-hdpi/ic_action_select_all.png 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 Binary files /dev/null and b/OpenPGP-Keychain/src/main/res/drawable-mdpi/ic_action_select_all.png 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 Binary files /dev/null and b/OpenPGP-Keychain/src/main/res/drawable-xhdpi/ic_action_select_all.png 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 Binary files /dev/null and b/OpenPGP-Keychain/src/main/res/drawable-xxhdpi/ic_action_select_all.png 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 @@ -1,6 +1,10 @@