X-Git-Url: https://git.ktnx.net/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Fmodel%2FTemplateDetailsItem.java;h=740806813b09456e149a798093921b4a8b36f522;hb=d9a211a52d38f24b19bf5c2d6918d2efec858a15;hp=03451c90e8da318f538b8324afca74888526d1dd;hpb=c730da219fa2fdbf803faaa29538a6d62436a374;p=mobile-ledger.git diff --git a/app/src/main/java/net/ktnx/mobileledger/model/TemplateDetailsItem.java b/app/src/main/java/net/ktnx/mobileledger/model/TemplateDetailsItem.java index 03451c90..74080681 100644 --- a/app/src/main/java/net/ktnx/mobileledger/model/TemplateDetailsItem.java +++ b/app/src/main/java/net/ktnx/mobileledger/model/TemplateDetailsItem.java @@ -47,7 +47,7 @@ import java.util.regex.PatternSyntaxException; abstract public class TemplateDetailsItem { private final Type type; protected Long id; - protected Long position; + protected long position; protected TemplateDetailsItem(Type type) { this.type = type; @@ -98,6 +98,8 @@ abstract public class TemplateDetailsItem { else header.setDateYearMatchGroup(ph.getDateYearMatchGroup()); + header.setFallback(ph.isFallback()); + return header; } else if (p instanceof TemplateAccount) { @@ -174,7 +176,7 @@ abstract public class TemplateDetailsItem { public long getPosition() { return position; } - public void setPosition(Long position) { + public void setPosition(long position) { this.position = position; } abstract public String getProblem(@NonNull Resources r, int patternGroupCount); @@ -446,6 +448,7 @@ abstract public class TemplateDetailsItem { private PossiblyMatchedValue dateMonth = PossiblyMatchedValue.withLiteralInt(null); private PossiblyMatchedValue dateDay = PossiblyMatchedValue.withLiteralInt(null); private SpannableString testMatch; + private boolean isFallback; private Header() { super(Type.HEADER); } @@ -463,12 +466,20 @@ abstract public class TemplateDetailsItem { dateYear = new PossiblyMatchedValue<>(origin.dateYear); dateMonth = new PossiblyMatchedValue<>(origin.dateMonth); dateDay = new PossiblyMatchedValue<>(origin.dateDay); + + isFallback = origin.isFallback; } private static StyleSpan capturedSpan() { return new StyleSpan(Typeface.BOLD); } private static UnderlineSpan matchedSpan() { return new UnderlineSpan(); } private static ForegroundColorSpan notMatchedSpan() { return new ForegroundColorSpan(Color.GRAY); } + public boolean isFallback() { + return isFallback; + } + public void setFallback(boolean fallback) { + this.isFallback = fallback; + } public String getName() { return name; } @@ -489,8 +500,9 @@ abstract public class TemplateDetailsItem { compiledPattern = null; testMatch = new SpannableString(testText); - testMatch.setSpan(notMatchedSpan(), 0, testText.length() - 1, - Spanned.SPAN_INCLUSIVE_INCLUSIVE); + if (!testText.isEmpty()) + testMatch.setSpan(notMatchedSpan(), 0, testText.length() - 1, + Spanned.SPAN_INCLUSIVE_INCLUSIVE); } } @NonNull @@ -603,7 +615,7 @@ abstract public class TemplateDetailsItem { return Misc.equalStrings(name, o.name) && Misc.equalStrings(pattern, o.pattern) && Misc.equalStrings(testText, o.testText) && Misc.equalStrings(patternError, o.patternError) && - Objects.equals(testMatch, o.testMatch); + Objects.equals(testMatch, o.testMatch) && isFallback == o.isFallback; } public String getMatchGroupText(int group) { if (compiledPattern != null && testText != null) { @@ -673,6 +685,8 @@ abstract public class TemplateDetailsItem { else result.setDateDayMatchGroup(dateDay.getMatchGroup()); + result.setFallback(isFallback); + return result; } public SpannableString getTestMatch() {