make search in uidList case insensitive in all places
This commit is contained in:
@@ -29,6 +29,7 @@ public abstract class SubKey implements KeysModel {
|
||||
@AutoValue
|
||||
public static abstract class UnifiedKeyInfo implements KeysModel.UnifiedKeyViewModel {
|
||||
private List<String> autocryptPackageNames;
|
||||
private String cachedUidSearchString;
|
||||
|
||||
public boolean is_expired() {
|
||||
Long expiry = expiry();
|
||||
@@ -64,5 +65,16 @@ public abstract class SubKey implements KeysModel {
|
||||
public boolean has_encrypt_key() {
|
||||
return has_encrypt_key_int() != 0;
|
||||
}
|
||||
|
||||
public String uidSearchString() {
|
||||
if (cachedUidSearchString == null) {
|
||||
cachedUidSearchString = user_id_list();
|
||||
if (cachedUidSearchString == null) {
|
||||
cachedUidSearchString = "";
|
||||
}
|
||||
cachedUidSearchString = cachedUidSearchString.toLowerCase();
|
||||
}
|
||||
return cachedUidSearchString;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,8 +112,8 @@ class RemoteSelectIdentityKeyPresenter {
|
||||
}
|
||||
|
||||
private void goToSelectLayout() {
|
||||
List<UnifiedKeyInfo> filteredKeyInfoData =
|
||||
viewModel.isListAllKeys() || TextUtils.isEmpty(userId.email) ? keyInfoData : getFilteredKeyInfo();
|
||||
List<UnifiedKeyInfo> filteredKeyInfoData = viewModel.isListAllKeys() || TextUtils.isEmpty(userId.email) ?
|
||||
keyInfoData : getFilteredKeyInfo(userId.email.toLowerCase().trim());
|
||||
|
||||
if (filteredKeyInfoData == null) {
|
||||
view.showLayoutEmpty();
|
||||
@@ -125,12 +125,11 @@ class RemoteSelectIdentityKeyPresenter {
|
||||
}
|
||||
}
|
||||
|
||||
private List<UnifiedKeyInfo> getFilteredKeyInfo() {
|
||||
private List<UnifiedKeyInfo> getFilteredKeyInfo(String filterString) {
|
||||
if (viewModel.filteredKeyInfo == null) {
|
||||
viewModel.filteredKeyInfo = new ArrayList<>();
|
||||
for (UnifiedKeyInfo unifiedKeyInfo : keyInfoData) {
|
||||
String emailSearchList = unifiedKeyInfo.user_id_list();
|
||||
if (emailSearchList == null || emailSearchList.contains(userId.email)) {
|
||||
if (unifiedKeyInfo.uidSearchString().contains(filterString)) {
|
||||
viewModel.filteredKeyInfo.add(unifiedKeyInfo);
|
||||
}
|
||||
}
|
||||
@@ -185,7 +184,7 @@ class RemoteSelectIdentityKeyPresenter {
|
||||
}
|
||||
|
||||
void onKeyItemClick(int position) {
|
||||
selectedMasterKeyId = getFilteredKeyInfo().get(position).master_key_id();
|
||||
selectedMasterKeyId = getFilteredKeyInfo(userId.email.toLowerCase()).get(position).master_key_id();
|
||||
view.highlightKey(position);
|
||||
}
|
||||
|
||||
|
||||
@@ -66,8 +66,7 @@ public class FlexibleKeyDetailsItem extends FlexibleSectionableKeyItem<FlexibleK
|
||||
|
||||
@Override
|
||||
public boolean filter(String constraint) {
|
||||
String uidList = keyInfo.user_id_list();
|
||||
return constraint == null || (uidList != null && uidList.contains(constraint));
|
||||
return constraint == null || keyInfo.uidSearchString().contains(constraint);
|
||||
}
|
||||
|
||||
class FlexibleKeyItemViewHolder extends FlexibleViewHolder {
|
||||
|
||||
@@ -42,8 +42,7 @@ public class EncryptRecipientChipsInput extends ChipsInput<EncryptRecipientChip>
|
||||
|
||||
@Override
|
||||
public boolean isKeptForConstraint(CharSequence constraint) {
|
||||
String uidList = keyInfo.user_id_list();
|
||||
return uidList == null || uidList.contains(constraint);
|
||||
return keyInfo.uidSearchString().contains(constraint);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user