.getTemplateDAO()
.getTemplates();
allTemplates.observe(getViewLifecycleOwner(), templateHeaders -> {
+ ArrayList<TemplateHeader> matchingFallbackTemplates = new ArrayList<>();
ArrayList<TemplateHeader> matchingTemplates = new ArrayList<>();
for (TemplateHeader ph : templateHeaders) {
Logger.debug("pattern",
String.format("Pattern '%s' [%s] matches '%s'", ph.getName(),
patternSource, text));
- matchingTemplates.add(ph);
+ if (ph.isFallback())
+ matchingFallbackTemplates.add(ph);
+ else
+ matchingTemplates.add(ph);
}
catch (ParcelFormatException e) {
// ignored
}
}
+ if (matchingTemplates.isEmpty())
+ matchingTemplates = matchingFallbackTemplates;
+
if (matchingTemplates.isEmpty())
alertNoTemplateMatch(text);
else if (matchingTemplates.size() == 1)