improvements, workaround for jelly bean bug

This commit is contained in:
Dominik 2012-11-01 22:33:21 +01:00
parent 8749569e80
commit 1ea00ef082
4 changed files with 24 additions and 18 deletions

View File

@ -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() {

View File

@ -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) {

View File

@ -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(" +");

View File

@ -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);