mirror of
https://github.com/M66B/FairEmail.git
synced 2026-03-27 19:35:10 +01:00
Thinner underline for grammar errors
This commit is contained in:
@@ -411,9 +411,13 @@ public class LanguageTool {
|
||||
if (suggestions != null)
|
||||
for (LanguageTool.Suggestion suggestion : suggestions) {
|
||||
Log.i("LT adding=" + suggestion);
|
||||
int flags = ("Spelling mistake".equals(suggestion.title)
|
||||
|| Build.VERSION.SDK_INT < Build.VERSION_CODES.S
|
||||
? SuggestionSpan.FLAG_MISSPELLED
|
||||
: SuggestionSpan.FLAG_GRAMMAR_ERROR);
|
||||
SuggestionSpan span = new SuggestionSpanEx(etBody.getContext(),
|
||||
suggestion.replacements.toArray(new String[0]),
|
||||
SuggestionSpan.FLAG_MISSPELLED);
|
||||
suggestion.replacements.toArray(new String[0]), flags);
|
||||
Log.i("MMM " + suggestion.title + ": " + flags);
|
||||
int s = start + suggestion.offset;
|
||||
int e = s + suggestion.length;
|
||||
if (s < 0 || s > edit.length() || e < 0 || e > edit.length()) {
|
||||
@@ -461,25 +465,25 @@ public class LanguageTool {
|
||||
}
|
||||
|
||||
private static class SuggestionSpanEx extends SuggestionSpan {
|
||||
private final int highlightColor;
|
||||
private final int dp3;
|
||||
private final int underlineColor;
|
||||
private final int underlineThickness;
|
||||
|
||||
public SuggestionSpanEx(Context context, String[] suggestions, int flags) {
|
||||
super(context, suggestions, flags);
|
||||
highlightColor = Helper.resolveColor(context,
|
||||
underlineColor = Helper.resolveColor(context,
|
||||
Build.VERSION.SDK_INT < Build.VERSION_CODES.Q
|
||||
? android.R.attr.textColorHighlight
|
||||
: android.R.attr.colorError);
|
||||
dp3 = Helper.dp2pixels(context, 2);
|
||||
underlineThickness = Helper.dp2pixels(context, (getFlags() & FLAG_MISSPELLED) != 0 ? 2 : 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDrawState(TextPaint tp) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q)
|
||||
tp.bgColor = highlightColor;
|
||||
tp.bgColor = underlineColor;
|
||||
else {
|
||||
tp.underlineColor = highlightColor;
|
||||
tp.underlineThickness = dp3;
|
||||
tp.underlineColor = underlineColor;
|
||||
tp.underlineThickness = underlineThickness;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user