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