Merge pull request #687 from mavit/fuzzy-issuer
Use an thumbnail if its name appears as a word in the TOTP issuer field
This commit is contained in:
commit
b5f5492249
2 changed files with 16 additions and 1 deletions
|
@ -493,9 +493,13 @@ public class Entry {
|
||||||
try {
|
try {
|
||||||
this.thumbnail = EntryThumbnail.EntryThumbnails.valueOfIgnoreCase(issuer);
|
this.thumbnail = EntryThumbnail.EntryThumbnails.valueOfIgnoreCase(issuer);
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
|
try {
|
||||||
|
this.thumbnail = EntryThumbnail.EntryThumbnails.valueOfFuzzy(issuer);
|
||||||
|
} catch(Exception e2) {
|
||||||
this.thumbnail = EntryThumbnail.EntryThumbnails.Default;
|
this.thumbnail = EntryThumbnail.EntryThumbnails.Default;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
|
|
||||||
package org.shadowice.flocke.andotp.Utilities;
|
package org.shadowice.flocke.andotp.Utilities;
|
||||||
|
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
|
@ -398,6 +400,15 @@ public class EntryThumbnail {
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static EntryThumbnails valueOfFuzzy(String thumbnail) {
|
||||||
|
for (EntryThumbnails entryThumbnails : values()) {
|
||||||
|
Pattern re = Pattern.compile("\\b" + Pattern.quote(entryThumbnails.name()) + "\\b", Pattern.CASE_INSENSITIVE);
|
||||||
|
if (re.matcher(thumbnail).find())
|
||||||
|
return entryThumbnails;
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
|
|
||||||
public int getResource() {
|
public int getResource() {
|
||||||
return resource;
|
return resource;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue