diff --git a/app/src/main/java/org/shadowice/flocke/andotp/Database/Entry.java b/app/src/main/java/org/shadowice/flocke/andotp/Database/Entry.java index 32acedb3..a1c824e5 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/Database/Entry.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/Database/Entry.java @@ -493,7 +493,11 @@ public class Entry { try { this.thumbnail = EntryThumbnail.EntryThumbnails.valueOfIgnoreCase(issuer); } catch(Exception e) { - this.thumbnail = EntryThumbnail.EntryThumbnails.Default; + try { + this.thumbnail = EntryThumbnail.EntryThumbnails.valueOfFuzzy(issuer); + } catch(Exception e2) { + this.thumbnail = EntryThumbnail.EntryThumbnails.Default; + } } } diff --git a/app/src/main/java/org/shadowice/flocke/andotp/Utilities/EntryThumbnail.java b/app/src/main/java/org/shadowice/flocke/andotp/Utilities/EntryThumbnail.java index 548bf532..7c55a480 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/Utilities/EntryThumbnail.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/Utilities/EntryThumbnail.java @@ -23,6 +23,8 @@ package org.shadowice.flocke.andotp.Utilities; +import java.util.regex.Pattern; + import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; @@ -398,6 +400,15 @@ public class EntryThumbnail { 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() { return resource; }