mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-12-25 00:18:51 -05:00
Multiselect: Create 'select all' in public and secret keylist
This commit is contained in:
parent
0ed097a020
commit
1cf912de2b
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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));
|
||||
}
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 507 B |
Binary file not shown.
After Width: | Height: | Size: 292 B |
Binary file not shown.
After Width: | Height: | Size: 351 B |
Binary file not shown.
After Width: | Height: | Size: 563 B |
@ -1,6 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<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"
|
||||
|
@ -1,6 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<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"
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user