aboutsummaryrefslogtreecommitdiffstats
path: root/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/adapter/KeyListSecretAdapter.java
diff options
context:
space:
mode:
authorDominik Schürmann <dominik@dominikschuermann.de>2014-01-07 23:54:12 +0100
committerDominik Schürmann <dominik@dominikschuermann.de>2014-01-07 23:54:12 +0100
commit1970d4be6eb9d4bd09d3e4a95a344454e497be24 (patch)
tree5c755361ceb50ff0e5bce69a50f22c2a88a73c00 /OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/adapter/KeyListSecretAdapter.java
parent2ccfc09f440c3805674f34a599b42e16b430dcc6 (diff)
downloadopen-keychain-1970d4be6eb9d4bd09d3e4a95a344454e497be24.tar.gz
open-keychain-1970d4be6eb9d4bd09d3e4a95a344454e497be24.tar.bz2
open-keychain-1970d4be6eb9d4bd09d3e4a95a344454e497be24.zip
multi selection for secret key list
Diffstat (limited to 'OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/adapter/KeyListSecretAdapter.java')
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/adapter/KeyListSecretAdapter.java51
1 files changed, 50 insertions, 1 deletions
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/adapter/KeyListSecretAdapter.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/adapter/KeyListSecretAdapter.java
index 2fda8a9f7..f78eaf627 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/adapter/KeyListSecretAdapter.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/adapter/KeyListSecretAdapter.java
@@ -17,12 +17,17 @@
package org.sufficientlysecure.keychain.ui.adapter;
+import java.util.HashMap;
+import java.util.Set;
+
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.helper.OtherHelper;
import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds;
+import android.annotation.SuppressLint;
import android.content.Context;
import android.database.Cursor;
+import android.graphics.Color;
import android.support.v4.widget.CursorAdapter;
import android.view.LayoutInflater;
import android.view.View;
@@ -30,9 +35,11 @@ import android.view.ViewGroup;
import android.widget.TextView;
public class KeyListSecretAdapter extends CursorAdapter {
-
private LayoutInflater mInflater;
+ @SuppressLint("UseSparseArrays")
+ private HashMap<Integer, Boolean> mSelection = new HashMap<Integer, Boolean>();
+
public KeyListSecretAdapter(Context context, Cursor c, int flags) {
super(context, c, flags);
@@ -74,4 +81,46 @@ public class KeyListSecretAdapter extends CursorAdapter {
return mInflater.inflate(R.layout.key_list_item, null);
}
+ /** -------------------------- MULTI-SELECTION METHODS -------------- */
+ public void setNewSelection(int position, boolean value) {
+ mSelection.put(position, value);
+ notifyDataSetChanged();
+ }
+
+ public boolean isPositionChecked(int position) {
+ Boolean result = mSelection.get(position);
+ return result == null ? false : result;
+ }
+
+ public Set<Integer> getCurrentCheckedPosition() {
+ return mSelection.keySet();
+ }
+
+ public void removeSelection(int position) {
+ mSelection.remove(position);
+ notifyDataSetChanged();
+ }
+
+ public void clearSelection() {
+ mSelection.clear();
+ notifyDataSetChanged();
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ // let the adapter handle setting up the row views
+ View v = super.getView(position, convertView, parent);
+
+ /**
+ * Change color for multi-selection
+ */
+ // default color
+ v.setBackgroundColor(Color.TRANSPARENT);
+ if (mSelection.get(position) != null) {
+ // this is a selected position, change color!
+ v.setBackgroundColor(parent.getResources().getColor(R.color.emphasis));
+ }
+ return v;
+ }
+
}