mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-04-27 10:06:21 +00:00
adjust way of determining suggestion strip text colors
closer to old themes
This commit is contained in:
parent
84040a2593
commit
fc93e68425
2 changed files with 22 additions and 17 deletions
|
@ -24,6 +24,7 @@ public class Colors {
|
||||||
public final int keyText;
|
public final int keyText;
|
||||||
public final int keyHintText;
|
public final int keyHintText;
|
||||||
public int adjustedBackground;
|
public int adjustedBackground;
|
||||||
|
public int adjustedKeyText;
|
||||||
// todo (later): evaluate which colors, colorFilters and colorStateLists area actually necessary
|
// todo (later): evaluate which colors, colorFilters and colorStateLists area actually necessary
|
||||||
public ColorFilter backgroundFilter;
|
public ColorFilter backgroundFilter;
|
||||||
public ColorFilter adjustedBackgroundFilter;
|
public ColorFilter adjustedBackgroundFilter;
|
||||||
|
@ -90,6 +91,7 @@ public class Colors {
|
||||||
};
|
};
|
||||||
|
|
||||||
backgroundFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(background, BlendModeCompat.MODULATE);
|
backgroundFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(background, BlendModeCompat.MODULATE);
|
||||||
|
adjustedKeyText = brightenOrDarken(keyText, true);
|
||||||
|
|
||||||
// color to be used if exact background color would be bad contrast, e.g. more keys popup or no border space bar
|
// color to be used if exact background color would be bad contrast, e.g. more keys popup or no border space bar
|
||||||
if (isDarkColor(background)) {
|
if (isDarkColor(background)) {
|
||||||
|
|
|
@ -129,10 +129,20 @@ final class SuggestionStripLayoutHelper {
|
||||||
R.styleable.SuggestionStripView_suggestionStripOptions, 0);
|
R.styleable.SuggestionStripView_suggestionStripOptions, 0);
|
||||||
mAlphaObsoleted = ResourceUtils.getFraction(a,
|
mAlphaObsoleted = ResourceUtils.getFraction(a,
|
||||||
R.styleable.SuggestionStripView_alphaObsoleted, 1.0f);
|
R.styleable.SuggestionStripView_alphaObsoleted, 1.0f);
|
||||||
mColorValidTypedWord = a.getColor(R.styleable.SuggestionStripView_colorValidTypedWord, 0);
|
|
||||||
mColorTypedWord = a.getColor(R.styleable.SuggestionStripView_colorTypedWord, 0);
|
final Colors colors = Settings.getInstance().getCurrent().mColors;
|
||||||
mColorAutoCorrect = a.getColor(R.styleable.SuggestionStripView_colorAutoCorrect, 0);
|
if (colors.isCustom) {
|
||||||
mColorSuggested = a.getColor(R.styleable.SuggestionStripView_colorSuggested, 0);
|
mColorValidTypedWord = colors.adjustedKeyText;
|
||||||
|
mColorTypedWord = colors.adjustedKeyText;
|
||||||
|
mColorAutoCorrect = colors.keyText;
|
||||||
|
mColorSuggested = colors.adjustedKeyText;
|
||||||
|
} else {
|
||||||
|
mColorValidTypedWord = a.getColor(R.styleable.SuggestionStripView_colorValidTypedWord, 0);
|
||||||
|
mColorTypedWord = a.getColor(R.styleable.SuggestionStripView_colorTypedWord, 0);
|
||||||
|
mColorAutoCorrect = a.getColor(R.styleable.SuggestionStripView_colorAutoCorrect, 0);
|
||||||
|
mColorSuggested = a.getColor(R.styleable.SuggestionStripView_colorSuggested, 0);
|
||||||
|
}
|
||||||
|
|
||||||
mSuggestionsCountInStrip = a.getInt(
|
mSuggestionsCountInStrip = a.getInt(
|
||||||
R.styleable.SuggestionStripView_suggestionsCountInStrip,
|
R.styleable.SuggestionStripView_suggestionsCountInStrip,
|
||||||
DEFAULT_SUGGESTIONS_COUNT_IN_STRIP);
|
DEFAULT_SUGGESTIONS_COUNT_IN_STRIP);
|
||||||
|
@ -147,7 +157,8 @@ final class SuggestionStripLayoutHelper {
|
||||||
a.recycle();
|
a.recycle();
|
||||||
|
|
||||||
mMoreSuggestionsHint = getMoreSuggestionsHint(res,
|
mMoreSuggestionsHint = getMoreSuggestionsHint(res,
|
||||||
res.getDimension(R.dimen.config_more_suggestions_hint_text_size));
|
res.getDimension(R.dimen.config_more_suggestions_hint_text_size),
|
||||||
|
mColorAutoCorrect);
|
||||||
mCenterPositionInStrip = mSuggestionsCountInStrip / 2;
|
mCenterPositionInStrip = mSuggestionsCountInStrip / 2;
|
||||||
// Assuming there are at least three suggestions. Also, note that the suggestions are
|
// Assuming there are at least three suggestions. Also, note that the suggestions are
|
||||||
// laid out according to script direction, so this is left of the center for LTR scripts
|
// laid out according to script direction, so this is left of the center for LTR scripts
|
||||||
|
@ -177,14 +188,13 @@ final class SuggestionStripLayoutHelper {
|
||||||
/ mMoreSuggestionsRowHeight;
|
/ mMoreSuggestionsRowHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Drawable getMoreSuggestionsHint(final Resources res, final float textSize) {
|
private static Drawable getMoreSuggestionsHint(final Resources res, final float textSize,
|
||||||
|
final int color) {
|
||||||
final Paint paint = new Paint();
|
final Paint paint = new Paint();
|
||||||
paint.setAntiAlias(true);
|
paint.setAntiAlias(true);
|
||||||
paint.setTextAlign(Align.CENTER);
|
paint.setTextAlign(Align.CENTER);
|
||||||
paint.setTextSize(textSize);
|
paint.setTextSize(textSize);
|
||||||
final Colors colors = Settings.getInstance().getCurrent().mColors;
|
paint.setColor(color);
|
||||||
if (colors.isCustom)
|
|
||||||
paint.setColor(colors.keyText);
|
|
||||||
final Rect bounds = new Rect();
|
final Rect bounds = new Rect();
|
||||||
paint.getTextBounds(MORE_SUGGESTIONS_HINT, 0, MORE_SUGGESTIONS_HINT.length(), bounds);
|
paint.getTextBounds(MORE_SUGGESTIONS_HINT, 0, MORE_SUGGESTIONS_HINT.length(), bounds);
|
||||||
final int width = Math.round(bounds.width() + 0.5f);
|
final int width = Math.round(bounds.width() + 0.5f);
|
||||||
|
@ -509,11 +519,7 @@ final class SuggestionStripLayoutHelper {
|
||||||
// {@link SuggestionStripView#onClick(View)}.
|
// {@link SuggestionStripView#onClick(View)}.
|
||||||
wordView.setTag(indexInSuggestedWords);
|
wordView.setTag(indexInSuggestedWords);
|
||||||
wordView.setText(getStyledSuggestedWord(suggestedWords, indexInSuggestedWords));
|
wordView.setText(getStyledSuggestedWord(suggestedWords, indexInSuggestedWords));
|
||||||
final Colors colors = Settings.getInstance().getCurrent().mColors;
|
wordView.setTextColor(getSuggestionTextColor(suggestedWords, indexInSuggestedWords));
|
||||||
if (colors.isCustom)
|
|
||||||
wordView.setTextColor(colors.keyText);
|
|
||||||
else
|
|
||||||
wordView.setTextColor(getSuggestionTextColor(suggestedWords, indexInSuggestedWords));
|
|
||||||
if (SuggestionStripView.DBG) {
|
if (SuggestionStripView.DBG) {
|
||||||
mDebugInfoViews.get(positionInStrip).setText(
|
mDebugInfoViews.get(positionInStrip).setText(
|
||||||
suggestedWords.getDebugString(indexInSuggestedWords));
|
suggestedWords.getDebugString(indexInSuggestedWords));
|
||||||
|
@ -544,9 +550,6 @@ final class SuggestionStripLayoutHelper {
|
||||||
wordView.setTextColor(mColorAutoCorrect);
|
wordView.setTextColor(mColorAutoCorrect);
|
||||||
stripView.addView(wordView);
|
stripView.addView(wordView);
|
||||||
setLayoutWeight(wordView, 1.0f, mSuggestionsStripHeight);
|
setLayoutWeight(wordView, 1.0f, mSuggestionsStripHeight);
|
||||||
final Colors colors = Settings.getInstance().getCurrent().mColors;
|
|
||||||
if (colors.isCustom)
|
|
||||||
wordView.setTextColor(colors.keyText);
|
|
||||||
}
|
}
|
||||||
mMoreSuggestionsAvailable = (punctuationSuggestions.size() > countInStrip);
|
mMoreSuggestionsAvailable = (punctuationSuggestions.size() > countInStrip);
|
||||||
return countInStrip;
|
return countInStrip;
|
||||||
|
|
Loading…
Add table
Reference in a new issue