mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-27 19:22:14 -05:00
improvements, workaround for jelly bean bug
This commit is contained in:
parent
8749569e80
commit
1ea00ef082
@ -40,7 +40,7 @@ public class SelectPublicKeyActivity extends SherlockFragmentActivity {
|
|||||||
|
|
||||||
SelectPublicKeyFragment mSelectFragment;
|
SelectPublicKeyFragment mSelectFragment;
|
||||||
|
|
||||||
long selectedKeyIds[];
|
long selectedMasterKeyIds[];
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
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) {
|
// if (searchString == null) {
|
||||||
// mFilterLayout.setVisibility(View.GONE);
|
// mFilterLayout.setVisibility(View.GONE);
|
||||||
// } else {
|
// } else {
|
||||||
// mFilterLayout.setVisibility(View.VISIBLE);
|
// mFilterLayout.setVisibility(View.VISIBLE);
|
||||||
// mFilterInfo.setText(getString(R.string.filterInfo, searchString));
|
// 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
|
* @return
|
||||||
*/
|
*/
|
||||||
public long[] getSelectedMasterKeyIds() {
|
public long[] getSelectedMasterKeyIds() {
|
||||||
return selectedKeyIds;
|
return selectedMasterKeyIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cancelClicked() {
|
private void cancelClicked() {
|
||||||
|
@ -37,6 +37,7 @@ import android.os.Bundle;
|
|||||||
import android.support.v4.content.CursorLoader;
|
import android.support.v4.content.CursorLoader;
|
||||||
import android.support.v4.content.Loader;
|
import android.support.v4.content.Loader;
|
||||||
import android.support.v4.app.LoaderManager;
|
import android.support.v4.app.LoaderManager;
|
||||||
|
import android.view.View;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
|
|
||||||
public class SelectPublicKeyFragment extends SherlockListFragment implements
|
public class SelectPublicKeyFragment extends SherlockListFragment implements
|
||||||
@ -48,9 +49,6 @@ public class SelectPublicKeyFragment extends SherlockListFragment implements
|
|||||||
|
|
||||||
private long mSelectedMasterKeyIds[];
|
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
|
* Define Adapter and Loader on create of Activity
|
||||||
*/
|
*/
|
||||||
@ -82,6 +80,15 @@ public class SelectPublicKeyFragment extends SherlockListFragment implements
|
|||||||
getLoaderManager().initLoader(0, null, this);
|
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
|
* Selects items based on master key ids in list view
|
||||||
*
|
*
|
||||||
@ -157,12 +164,12 @@ public class SelectPublicKeyFragment extends SherlockListFragment implements
|
|||||||
UserIds.USER_ID,
|
UserIds.USER_ID,
|
||||||
"(SELECT COUNT(tmp." + Keys._ID + ") FROM " + Tables.KEYS + " AS tmp WHERE tmp."
|
"(SELECT COUNT(tmp." + Keys._ID + ") FROM " + Tables.KEYS + " AS tmp WHERE tmp."
|
||||||
+ Keys.IS_REVOKED + " = '0' AND tmp." + Keys.CAN_ENCRYPT + " = '1') AS "
|
+ 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."
|
"(SELECT COUNT(tmp." + Keys._ID + ") FROM " + Tables.KEYS + " AS tmp WHERE tmp."
|
||||||
+ Keys.IS_REVOKED + " = '0' AND " + Keys.CAN_ENCRYPT + " = '1' AND tmp."
|
+ Keys.IS_REVOKED + " = '0' AND " + Keys.CAN_ENCRYPT + " = '1' AND tmp."
|
||||||
+ Keys.CREATION + " <= '" + now + "' AND " + "(tmp." + Keys.EXPIRY
|
+ Keys.CREATION + " <= '" + now + "' AND " + "(tmp." + Keys.EXPIRY
|
||||||
+ " IS NULL OR tmp." + Keys.EXPIRY + " >= '" + now + "')) AS "
|
+ " IS NULL OR tmp." + Keys.EXPIRY + " >= '" + now + "')) AS "
|
||||||
+ PROJECTION_ROW_VALID, };
|
+ SelectKeyCursorAdapter.PROJECTION_ROW_VALID, };
|
||||||
|
|
||||||
String inMasterKeyList = null;
|
String inMasterKeyList = null;
|
||||||
if (mSelectedMasterKeyIds != null && mSelectedMasterKeyIds.length > 0) {
|
if (mSelectedMasterKeyIds != null && mSelectedMasterKeyIds.length > 0) {
|
||||||
|
@ -47,9 +47,6 @@ public class SelectSecretKeyFragment extends SherlockListFragment implements
|
|||||||
private SelectKeyCursorAdapter mAdapter;
|
private SelectKeyCursorAdapter mAdapter;
|
||||||
private ListView mListView;
|
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
|
* Define Adapter and Loader on create of Activity
|
||||||
*/
|
*/
|
||||||
@ -101,12 +98,12 @@ public class SelectSecretKeyFragment extends SherlockListFragment implements
|
|||||||
UserIds.USER_ID,
|
UserIds.USER_ID,
|
||||||
"(SELECT COUNT(tmp." + Keys._ID + ") FROM " + Tables.KEYS + " AS tmp WHERE tmp."
|
"(SELECT COUNT(tmp." + Keys._ID + ") FROM " + Tables.KEYS + " AS tmp WHERE tmp."
|
||||||
+ Keys.IS_REVOKED + " = '0' AND tmp." + Keys.CAN_SIGN + " = '1') AS "
|
+ 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."
|
"(SELECT COUNT(tmp." + Keys._ID + ") FROM " + Tables.KEYS + " AS tmp WHERE tmp."
|
||||||
+ Keys.IS_REVOKED + " = '0' AND " + Keys.CAN_SIGN + " = '1' AND tmp."
|
+ Keys.IS_REVOKED + " = '0' AND " + Keys.CAN_SIGN + " = '1' AND tmp."
|
||||||
+ Keys.CREATION + " <= '" + now + "' AND " + "(tmp." + Keys.EXPIRY
|
+ Keys.CREATION + " <= '" + now + "' AND " + "(tmp." + Keys.EXPIRY
|
||||||
+ " IS NULL OR tmp." + Keys.EXPIRY + " >= '" + now + "')) AS "
|
+ " IS NULL OR tmp." + Keys.EXPIRY + " >= '" + now + "')) AS "
|
||||||
+ PROJECTION_ROW_VALID, };
|
+ SelectKeyCursorAdapter.PROJECTION_ROW_VALID, };
|
||||||
|
|
||||||
// if (searchString != null && searchString.trim().length() > 0) {
|
// if (searchString != null && searchString.trim().length() > 0) {
|
||||||
// String[] chunks = searchString.trim().split(" +");
|
// String[] chunks = searchString.trim().split(" +");
|
||||||
|
@ -23,7 +23,6 @@ import org.thialfihar.android.apg.helper.OtherHelper;
|
|||||||
import org.thialfihar.android.apg.helper.PGPHelper;
|
import org.thialfihar.android.apg.helper.PGPHelper;
|
||||||
import org.thialfihar.android.apg.provider.ApgContract.KeyRings;
|
import org.thialfihar.android.apg.provider.ApgContract.KeyRings;
|
||||||
import org.thialfihar.android.apg.provider.ApgContract.UserIds;
|
import org.thialfihar.android.apg.provider.ApgContract.UserIds;
|
||||||
import org.thialfihar.android.apg.ui.SelectPublicKeyFragment;
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
@ -42,6 +41,9 @@ public class SelectKeyCursorAdapter extends CursorAdapter {
|
|||||||
private LayoutInflater mInflater;
|
private LayoutInflater mInflater;
|
||||||
private ListView mListView;
|
private ListView mListView;
|
||||||
|
|
||||||
|
public final static String PROJECTION_ROW_AVAILABLE = "available";
|
||||||
|
public final static String PROJECTION_ROW_VALID = "valid";
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public SelectKeyCursorAdapter(Context context, ListView listView, Cursor c, int keyType) {
|
public SelectKeyCursorAdapter(Context context, ListView listView, Cursor c, int keyType) {
|
||||||
super(context, c);
|
super(context, c);
|
||||||
@ -64,7 +66,7 @@ public class SelectKeyCursorAdapter extends CursorAdapter {
|
|||||||
@Override
|
@Override
|
||||||
public void bindView(View view, Context context, Cursor cursor) {
|
public void bindView(View view, Context context, Cursor cursor) {
|
||||||
boolean valid = cursor.getInt(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);
|
TextView mainUserId = (TextView) view.findViewById(R.id.mainUserId);
|
||||||
mainUserId.setText(R.string.unknownUserId);
|
mainUserId.setText(R.string.unknownUserId);
|
||||||
@ -100,7 +102,7 @@ public class SelectKeyCursorAdapter extends CursorAdapter {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (cursor.getInt(cursor
|
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
|
// has some CAN_ENCRYPT keys, but col(ROW_VALID) = 0, so must be revoked or
|
||||||
// expired
|
// expired
|
||||||
status.setText(R.string.expired);
|
status.setText(R.string.expired);
|
||||||
|
Loading…
Reference in New Issue
Block a user