mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-27 11:12:15 -05:00
Cleanup code, search with preceeding %
This commit is contained in:
parent
59067f9f8b
commit
ba61e69a7d
@ -180,7 +180,7 @@ public class KeyListPublicFragment extends Fragment implements SearchView.OnQuer
|
||||
case R.id.menu_key_list_public_multi_select_all: {
|
||||
//Select all
|
||||
int localCount = mStickyList.getCount();
|
||||
for(int k = 0; k < localCount; k++) {
|
||||
for (int k = 0; k < localCount; k++) {
|
||||
mStickyList.setItemChecked(k, true);
|
||||
}
|
||||
break;
|
||||
@ -243,9 +243,9 @@ public class KeyListPublicFragment extends Fragment implements SearchView.OnQuer
|
||||
Uri baseUri = KeyRings.buildPublicKeyRingsUri();
|
||||
String where = null;
|
||||
String whereArgs[] = null;
|
||||
if(mCurQuery != null){
|
||||
if (mCurQuery != null) {
|
||||
where = KeychainContract.UserIds.USER_ID + " LIKE ?";
|
||||
whereArgs = new String[]{mCurQuery+"%"};
|
||||
whereArgs = new String[]{"%" + mCurQuery + "%"};
|
||||
}
|
||||
// Now create and return a CursorLoader that will take care of
|
||||
// creating a Cursor for the data being displayed.
|
||||
@ -291,7 +291,7 @@ public class KeyListPublicFragment extends Fragment implements SearchView.OnQuer
|
||||
viewIntent.setData(KeychainContract.KeyRings.buildPublicKeyRingsUri(Long.toString(id)));
|
||||
startActivity(viewIntent);
|
||||
}
|
||||
|
||||
|
||||
@TargetApi(11)
|
||||
public void encrypt(ActionMode mode, long[] keyRingRowIds) {
|
||||
// get master key ids from row ids
|
||||
@ -352,7 +352,6 @@ public class KeyListPublicFragment extends Fragment implements SearchView.OnQuer
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(final Menu menu, final MenuInflater inflater) {
|
||||
|
||||
// Get the searchview
|
||||
MenuItem searchItem = menu.findItem(R.id.menu_key_list_public_search);
|
||||
mSearchView = (SearchView) MenuItemCompat.getActionView(searchItem);
|
||||
@ -361,7 +360,6 @@ public class KeyListPublicFragment extends Fragment implements SearchView.OnQuer
|
||||
mSearchView.setOnQueryTextListener(this);
|
||||
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -374,8 +372,7 @@ public class KeyListPublicFragment extends Fragment implements SearchView.OnQuer
|
||||
// Called when the action bar search text has changed. Update
|
||||
// the search filter, and restart the loader to do a new query
|
||||
// with this filter.
|
||||
String newQuery = !TextUtils.isEmpty(s) ? s : null;
|
||||
mCurQuery = newQuery;
|
||||
mCurQuery = !TextUtils.isEmpty(s) ? s : null;
|
||||
getLoaderManager().restartLoader(0, null, this);
|
||||
return true;
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ public class SelectPublicKeyFragment extends ListFragmentWorkaround implements T
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
mSearchView = (EditText)getActivity().findViewById(R.id.select_public_key_search);
|
||||
mSearchView = (EditText) getActivity().findViewById(R.id.select_public_key_search);
|
||||
mSearchView.addTextChangedListener(this);
|
||||
mSelectedMasterKeyIds = getArguments().getLongArray(ARG_PRESELECTED_KEY_IDS);
|
||||
}
|
||||
@ -106,7 +106,7 @@ public class SelectPublicKeyFragment extends ListFragmentWorkaround implements T
|
||||
|
||||
/**
|
||||
* Selects items based on master key ids in list view
|
||||
*
|
||||
*
|
||||
* @param masterKeyIds
|
||||
*/
|
||||
private void preselectMasterKeyIds(long[] masterKeyIds) {
|
||||
@ -125,7 +125,7 @@ public class SelectPublicKeyFragment extends ListFragmentWorkaround implements T
|
||||
|
||||
/**
|
||||
* Returns all selected master key ids
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public long[] getSelectedMasterKeyIds() {
|
||||
@ -149,7 +149,7 @@ public class SelectPublicKeyFragment extends ListFragmentWorkaround implements T
|
||||
|
||||
/**
|
||||
* Returns all selected user ids
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String[] getSelectedUserIds() {
|
||||
@ -173,7 +173,7 @@ public class SelectPublicKeyFragment extends ListFragmentWorkaround implements T
|
||||
|
||||
// These are the rows that we will retrieve.
|
||||
long now = new Date().getTime() / 1000;
|
||||
String[] projection = new String[] {
|
||||
String[] projection = new String[]{
|
||||
KeyRings._ID,
|
||||
KeyRings.MASTER_KEY_ID,
|
||||
UserIds.USER_ID,
|
||||
@ -190,7 +190,7 @@ public class SelectPublicKeyFragment extends ListFragmentWorkaround implements T
|
||||
+ Keys.CAN_ENCRYPT + " = '1' AND valid_keys." + Keys.CREATION + " <= '"
|
||||
+ now + "' AND " + "(valid_keys." + Keys.EXPIRY + " IS NULL OR valid_keys."
|
||||
+ Keys.EXPIRY + " >= '" + now + "')) AS "
|
||||
+ SelectKeyCursorAdapter.PROJECTION_ROW_VALID, };
|
||||
+ SelectKeyCursorAdapter.PROJECTION_ROW_VALID,};
|
||||
|
||||
String inMasterKeyList = null;
|
||||
if (mSelectedMasterKeyIds != null && mSelectedMasterKeyIds.length > 0) {
|
||||
@ -204,22 +204,6 @@ public class SelectPublicKeyFragment extends ListFragmentWorkaround implements T
|
||||
inMasterKeyList += ")";
|
||||
}
|
||||
|
||||
// if (searchString != null && searchString.trim().length() > 0) {
|
||||
// String[] chunks = searchString.trim().split(" +");
|
||||
// qb.appendWhere("(EXISTS (SELECT tmp." + UserIds._ID + " FROM " + UserIds.TABLE_NAME
|
||||
// + " AS tmp WHERE " + "tmp." + UserIds.KEY_ID + " = " + Keys.TABLE_NAME + "."
|
||||
// + Keys._ID);
|
||||
// for (int i = 0; i < chunks.length; ++i) {
|
||||
// qb.appendWhere(" AND tmp." + UserIds.USER_ID + " LIKE ");
|
||||
// qb.appendWhereEscapeString("%" + chunks[i] + "%");
|
||||
// }
|
||||
// qb.appendWhere("))");
|
||||
//
|
||||
// if (inIdList != null) {
|
||||
// qb.appendWhere(" OR (" + inIdList + ")");
|
||||
// }
|
||||
// }
|
||||
|
||||
String orderBy = UserIds.USER_ID + " ASC";
|
||||
if (inMasterKeyList != null) {
|
||||
// sort by selected master keys
|
||||
@ -227,9 +211,9 @@ public class SelectPublicKeyFragment extends ListFragmentWorkaround implements T
|
||||
}
|
||||
String where = null;
|
||||
String whereArgs[] = null;
|
||||
if(mCurQuery != null){
|
||||
if (mCurQuery != null) {
|
||||
where = UserIds.USER_ID + " LIKE ?";
|
||||
whereArgs = new String[]{mCurQuery+"%"};
|
||||
whereArgs = new String[]{"%" + mCurQuery + "%"};
|
||||
}
|
||||
|
||||
// Now create and return a CursorLoader that will take care of
|
||||
@ -274,8 +258,7 @@ public class SelectPublicKeyFragment extends ListFragmentWorkaround implements T
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable editable) {
|
||||
String newQuery = !TextUtils.isEmpty(editable.toString()) ? editable.toString() : null;
|
||||
mCurQuery = newQuery;
|
||||
mCurQuery = !TextUtils.isEmpty(editable.toString()) ? editable.toString() : null;
|
||||
getLoaderManager().restartLoader(0, null, this);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user