mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-04-29 02:58:07 +00:00
use instanceof instead of comparing classes
This commit is contained in:
parent
50e175509b
commit
6cac9e2512
2 changed files with 8 additions and 9 deletions
|
@ -151,7 +151,7 @@ public class KeyboardView extends View {
|
||||||
R.styleable.KeyboardView_spacebarBackground);
|
R.styleable.KeyboardView_spacebarBackground);
|
||||||
mSpacebarBackground = (spacebarBackground != null) ? spacebarBackground.mutate()
|
mSpacebarBackground = (spacebarBackground != null) ? spacebarBackground.mutate()
|
||||||
: keyboardViewAttr.getDrawable(R.styleable.KeyboardView_keyBackground).mutate();
|
: keyboardViewAttr.getDrawable(R.styleable.KeyboardView_keyBackground).mutate();
|
||||||
if (mColors.getClass() == HoloColors.class) // todo: this logic should be in Colors, not here
|
if (mColors instanceof HoloColors) // todo: this logic should be in Colors, not here
|
||||||
mActionKeyBackground = mFunctionalKeyBackground;
|
mActionKeyBackground = mFunctionalKeyBackground;
|
||||||
else
|
else
|
||||||
mActionKeyBackground = keyboardViewAttr.getDrawable(R.styleable.KeyboardView_keyBackground).mutate();
|
mActionKeyBackground = keyboardViewAttr.getDrawable(R.styleable.KeyboardView_keyBackground).mutate();
|
||||||
|
@ -180,11 +180,10 @@ public class KeyboardView extends View {
|
||||||
|
|
||||||
mPaint.setAntiAlias(true);
|
mPaint.setAntiAlias(true);
|
||||||
|
|
||||||
final Class<?> c = this.getClass();
|
if (this instanceof EmojiPageKeyboardView || this instanceof MoreSuggestionsView) {
|
||||||
if (c == MoreKeysKeyboardView.class) {
|
|
||||||
mColors.setBackgroundColor(mKeyBackground, Colors.TYPE_ADJUSTED_BACKGROUND);
|
|
||||||
} else if (c == EmojiPageKeyboardView.class || c == MoreSuggestionsView.class) {
|
|
||||||
mColors.setBackgroundColor(mKeyBackground, Colors.TYPE_BACKGROUND);
|
mColors.setBackgroundColor(mKeyBackground, Colors.TYPE_BACKGROUND);
|
||||||
|
} else if (this instanceof MoreKeysKeyboardView) {
|
||||||
|
mColors.setBackgroundColor(mKeyBackground, Colors.TYPE_ADJUSTED_BACKGROUND);
|
||||||
} else {
|
} else {
|
||||||
mColors.setBackgroundColor(mKeyBackground, Colors.TYPE_KEY);
|
mColors.setBackgroundColor(mKeyBackground, Colors.TYPE_KEY);
|
||||||
}
|
}
|
||||||
|
@ -197,7 +196,7 @@ public class KeyboardView extends View {
|
||||||
// todo: this should only be applied to specific keyboards, check original version for which one
|
// todo: this should only be applied to specific keyboards, check original version for which one
|
||||||
// and actually this again is something that maybe should be done in Colors
|
// and actually this again is something that maybe should be done in Colors
|
||||||
final Drawable keyboardBackground = mColors.getKeyboardBackground();
|
final Drawable keyboardBackground = mColors.getKeyboardBackground();
|
||||||
if (this.getClass() != MoreSuggestionsView.class && keyboardBackground != null)
|
if (this instanceof MoreSuggestionsView && keyboardBackground != null)
|
||||||
setBackground(keyboardBackground);
|
setBackground(keyboardBackground);
|
||||||
else
|
else
|
||||||
getBackground().setColorFilter(mColors.backgroundFilter);
|
getBackground().setColorFilter(mColors.backgroundFilter);
|
||||||
|
@ -621,7 +620,7 @@ public class KeyboardView extends View {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setKeyIconColor(Key key, Drawable icon, Keyboard keyboard) {
|
private void setKeyIconColor(Key key, Drawable icon, Keyboard keyboard) {
|
||||||
if (key.isAccentColored() && mColors.getClass() != HoloColors.class) { // todo: again sth that should not be here
|
if (key.isAccentColored() && !(mColors instanceof HoloColors)) { // todo: again sth that should not be here
|
||||||
icon.setColorFilter(mColors.actionKeyIconColorFilter);
|
icon.setColorFilter(mColors.actionKeyIconColorFilter);
|
||||||
} else if (key.isShift() && keyboard != null) {
|
} else if (key.isShift() && keyboard != null) {
|
||||||
// todo (idea): replace shift icon with white one and use the normal multiply filters
|
// todo (idea): replace shift icon with white one and use the normal multiply filters
|
||||||
|
@ -636,7 +635,7 @@ public class KeyboardView extends View {
|
||||||
icon.setColorFilter(mColors.keyTextFilter); // key text if not shifted
|
icon.setColorFilter(mColors.keyTextFilter); // key text if not shifted
|
||||||
} else if (key.getBackgroundType() != Key.BACKGROUND_TYPE_NORMAL) {
|
} else if (key.getBackgroundType() != Key.BACKGROUND_TYPE_NORMAL) {
|
||||||
icon.setColorFilter(mColors.keyTextFilter);
|
icon.setColorFilter(mColors.keyTextFilter);
|
||||||
} else if (this.getClass() == MoreKeysKeyboardView.class) {
|
} else if (this instanceof MoreKeysKeyboardView) {
|
||||||
// set color filter for long press comma key, should not trigger anywhere else
|
// set color filter for long press comma key, should not trigger anywhere else
|
||||||
icon.setColorFilter(mColors.keyTextFilter);
|
icon.setColorFilter(mColors.keyTextFilter);
|
||||||
}
|
}
|
||||||
|
|
|
@ -219,7 +219,7 @@ public final class MainKeyboardView extends KeyboardView implements DrawingProxy
|
||||||
mLanguageOnSpacebarTextRatio = mainKeyboardViewAttr.getFraction(
|
mLanguageOnSpacebarTextRatio = mainKeyboardViewAttr.getFraction(
|
||||||
R.styleable.MainKeyboardView_languageOnSpacebarTextRatio, 1, 1, 1.0f);
|
R.styleable.MainKeyboardView_languageOnSpacebarTextRatio, 1, 1, 1.0f);
|
||||||
final Colors colors = Settings.getInstance().getCurrent().mColors;
|
final Colors colors = Settings.getInstance().getCurrent().mColors;
|
||||||
if (colors.getClass() == HoloColors.class) // todo: this logic should be in Colors
|
if (colors instanceof HoloColors) // todo: this logic should be in Colors
|
||||||
mLanguageOnSpacebarTextColor = colors.keyText;
|
mLanguageOnSpacebarTextColor = colors.keyText;
|
||||||
else
|
else
|
||||||
mLanguageOnSpacebarTextColor = colors.keyHintText; //mainKeyboardViewAttr.getColor(R.styleable.MainKeyboardView_languageOnSpacebarTextColor, 0);
|
mLanguageOnSpacebarTextColor = colors.keyHintText; //mainKeyboardViewAttr.getColor(R.styleable.MainKeyboardView_languageOnSpacebarTextColor, 0);
|
||||||
|
|
Loading…
Add table
Reference in a new issue