diff --git a/org_apg/src/org/thialfihar/android/apg/ui/SelectPublicKeyActivity.java b/org_apg/src/org/thialfihar/android/apg/ui/SelectPublicKeyActivity.java index 61b72a4a2..d095222fd 100644 --- a/org_apg/src/org/thialfihar/android/apg/ui/SelectPublicKeyActivity.java +++ b/org_apg/src/org/thialfihar/android/apg/ui/SelectPublicKeyActivity.java @@ -40,7 +40,7 @@ public class SelectPublicKeyActivity extends SherlockFragmentActivity { SelectPublicKeyFragment mSelectFragment; - long selectedKeyIds[]; + long selectedMasterKeyIds[]; @Override protected void onCreate(Bundle savedInstanceState) { @@ -87,15 +87,15 @@ public class SelectPublicKeyActivity extends SherlockFragmentActivity { // } // } - // preselected master keys - selectedKeyIds = intent.getLongArrayExtra(RESULT_EXTRA_MASTER_KEY_IDS); - // if (searchString == null) { // mFilterLayout.setVisibility(View.GONE); // } else { // mFilterLayout.setVisibility(View.VISIBLE); // mFilterInfo.setText(getString(R.string.filterInfo, searchString)); // } + + // preselected master keys + selectedMasterKeyIds = intent.getLongArrayExtra(RESULT_EXTRA_MASTER_KEY_IDS); } /** @@ -104,7 +104,7 @@ public class SelectPublicKeyActivity extends SherlockFragmentActivity { * @return */ public long[] getSelectedMasterKeyIds() { - return selectedKeyIds; + return selectedMasterKeyIds; } private void cancelClicked() { diff --git a/org_apg/src/org/thialfihar/android/apg/ui/SelectPublicKeyFragment.java b/org_apg/src/org/thialfihar/android/apg/ui/SelectPublicKeyFragment.java index 389251349..ff5e22035 100644 --- a/org_apg/src/org/thialfihar/android/apg/ui/SelectPublicKeyFragment.java +++ b/org_apg/src/org/thialfihar/android/apg/ui/SelectPublicKeyFragment.java @@ -37,6 +37,7 @@ import android.os.Bundle; import android.support.v4.content.CursorLoader; import android.support.v4.content.Loader; import android.support.v4.app.LoaderManager; +import android.view.View; import android.widget.ListView; public class SelectPublicKeyFragment extends SherlockListFragment implements @@ -48,9 +49,6 @@ public class SelectPublicKeyFragment extends SherlockListFragment implements private long mSelectedMasterKeyIds[]; - public final static String PROJECTION_ROW_AVAILABLE = "available"; - public final static String PROJECTION_ROW_VALID = "valid"; - /** * Define Adapter and Loader on create of Activity */ @@ -82,6 +80,15 @@ public class SelectPublicKeyFragment extends SherlockListFragment implements getLoaderManager().initLoader(0, null, this); } + /** + * Workaround for Android 4.1. Items are not checked in layout. See + * http://code.google.com/p/android/issues/detail?id=35885 + */ + @Override + public void onListItemClick(ListView l, View v, int position, long id) { + l.setItemChecked(position, l.isItemChecked(position)); + } + /** * Selects items based on master key ids in list view * @@ -157,12 +164,12 @@ public class SelectPublicKeyFragment extends SherlockListFragment implements UserIds.USER_ID, "(SELECT COUNT(tmp." + Keys._ID + ") FROM " + Tables.KEYS + " AS tmp WHERE tmp." + Keys.IS_REVOKED + " = '0' AND tmp." + Keys.CAN_ENCRYPT + " = '1') AS " - + PROJECTION_ROW_AVAILABLE, + + SelectKeyCursorAdapter.PROJECTION_ROW_AVAILABLE, "(SELECT COUNT(tmp." + Keys._ID + ") FROM " + Tables.KEYS + " AS tmp WHERE tmp." + Keys.IS_REVOKED + " = '0' AND " + Keys.CAN_ENCRYPT + " = '1' AND tmp." + Keys.CREATION + " <= '" + now + "' AND " + "(tmp." + Keys.EXPIRY + " IS NULL OR tmp." + Keys.EXPIRY + " >= '" + now + "')) AS " - + PROJECTION_ROW_VALID, }; + + SelectKeyCursorAdapter.PROJECTION_ROW_VALID, }; String inMasterKeyList = null; if (mSelectedMasterKeyIds != null && mSelectedMasterKeyIds.length > 0) { diff --git a/org_apg/src/org/thialfihar/android/apg/ui/SelectSecretKeyFragment.java b/org_apg/src/org/thialfihar/android/apg/ui/SelectSecretKeyFragment.java index da9f4b4da..6bb0eb014 100644 --- a/org_apg/src/org/thialfihar/android/apg/ui/SelectSecretKeyFragment.java +++ b/org_apg/src/org/thialfihar/android/apg/ui/SelectSecretKeyFragment.java @@ -47,9 +47,6 @@ public class SelectSecretKeyFragment extends SherlockListFragment implements private SelectKeyCursorAdapter mAdapter; private ListView mListView; - public final static String PROJECTION_ROW_AVAILABLE = "available"; - public final static String PROJECTION_ROW_VALID = "valid"; - /** * Define Adapter and Loader on create of Activity */ @@ -101,12 +98,12 @@ public class SelectSecretKeyFragment extends SherlockListFragment implements UserIds.USER_ID, "(SELECT COUNT(tmp." + Keys._ID + ") FROM " + Tables.KEYS + " AS tmp WHERE tmp." + Keys.IS_REVOKED + " = '0' AND tmp." + Keys.CAN_SIGN + " = '1') AS " - + PROJECTION_ROW_AVAILABLE, + + SelectKeyCursorAdapter.PROJECTION_ROW_AVAILABLE, "(SELECT COUNT(tmp." + Keys._ID + ") FROM " + Tables.KEYS + " AS tmp WHERE tmp." + Keys.IS_REVOKED + " = '0' AND " + Keys.CAN_SIGN + " = '1' AND tmp." + Keys.CREATION + " <= '" + now + "' AND " + "(tmp." + Keys.EXPIRY + " IS NULL OR tmp." + Keys.EXPIRY + " >= '" + now + "')) AS " - + PROJECTION_ROW_VALID, }; + + SelectKeyCursorAdapter.PROJECTION_ROW_VALID, }; // if (searchString != null && searchString.trim().length() > 0) { // String[] chunks = searchString.trim().split(" +"); diff --git a/org_apg/src/org/thialfihar/android/apg/ui/widget/SelectKeyCursorAdapter.java b/org_apg/src/org/thialfihar/android/apg/ui/widget/SelectKeyCursorAdapter.java index 5f89a2ed1..0f6bd5f11 100644 --- a/org_apg/src/org/thialfihar/android/apg/ui/widget/SelectKeyCursorAdapter.java +++ b/org_apg/src/org/thialfihar/android/apg/ui/widget/SelectKeyCursorAdapter.java @@ -23,7 +23,6 @@ import org.thialfihar.android.apg.helper.OtherHelper; import org.thialfihar.android.apg.helper.PGPHelper; import org.thialfihar.android.apg.provider.ApgContract.KeyRings; import org.thialfihar.android.apg.provider.ApgContract.UserIds; -import org.thialfihar.android.apg.ui.SelectPublicKeyFragment; import android.content.Context; import android.database.Cursor; @@ -42,6 +41,9 @@ public class SelectKeyCursorAdapter extends CursorAdapter { private LayoutInflater mInflater; private ListView mListView; + public final static String PROJECTION_ROW_AVAILABLE = "available"; + public final static String PROJECTION_ROW_VALID = "valid"; + @SuppressWarnings("deprecation") public SelectKeyCursorAdapter(Context context, ListView listView, Cursor c, int keyType) { super(context, c); @@ -64,7 +66,7 @@ public class SelectKeyCursorAdapter extends CursorAdapter { @Override public void bindView(View view, Context context, Cursor cursor) { boolean valid = cursor.getInt(cursor - .getColumnIndex(SelectPublicKeyFragment.PROJECTION_ROW_VALID)) > 0; + .getColumnIndex(PROJECTION_ROW_VALID)) > 0; TextView mainUserId = (TextView) view.findViewById(R.id.mainUserId); mainUserId.setText(R.string.unknownUserId); @@ -100,7 +102,7 @@ public class SelectKeyCursorAdapter extends CursorAdapter { } } else { if (cursor.getInt(cursor - .getColumnIndex(SelectPublicKeyFragment.PROJECTION_ROW_AVAILABLE)) > 0) { + .getColumnIndex(PROJECTION_ROW_AVAILABLE)) > 0) { // has some CAN_ENCRYPT keys, but col(ROW_VALID) = 0, so must be revoked or // expired status.setText(R.string.expired);