Merge "Add inactivatedLabel and inactivatedUppercaseLetter flags for Key.keyLabelFlags"

This commit is contained in:
Tadashi G. Takaoka 2012-01-27 01:15:01 -08:00 committed by Android (Google) Code Review
commit 32c4635ff4
3 changed files with 25 additions and 3 deletions

View file

@ -269,6 +269,10 @@
<!-- If true, character case of code, altCode, moreKeys, keyOutputText, keyLabel, <!-- If true, character case of code, altCode, moreKeys, keyOutputText, keyLabel,
or keyHintLabel will never be subject to change. --> or keyHintLabel will never be subject to change. -->
<flag name="preserveCase" value="0x8000" /> <flag name="preserveCase" value="0x8000" />
<!-- If true, use keyTextInactivatedColor for the label -->
<flag name="inactivatedLabel" value="0x10000" />
<!-- If true, use keyUppercaseLetterInactivatedColor for the uppercase letter -->
<flag name="inactivatedUppercaseLetter" value="0x20000" />
</attr> </attr>
<!-- The icon to display on the key instead of the label. --> <!-- The icon to display on the key instead of the label. -->
<attr name="keyIcon" format="enum"> <attr name="keyIcon" format="enum">

View file

@ -72,6 +72,8 @@ public class Key {
private static final int LABEL_FLAGS_WITH_ICON_RIGHT = 0x2000; private static final int LABEL_FLAGS_WITH_ICON_RIGHT = 0x2000;
private static final int LABEL_FLAGS_AUTO_X_SCALE = 0x4000; private static final int LABEL_FLAGS_AUTO_X_SCALE = 0x4000;
private static final int LABEL_FLAGS_PRESERVE_CASE = 0x8000; private static final int LABEL_FLAGS_PRESERVE_CASE = 0x8000;
private static final int LABEL_FLAGS_INACTIVATED_LABEL = 0x10000;
private static final int LABEL_FLAGS_INACTIVATED_UPPERCASE_LETTER = 0x20000;
/** Icon to display instead of a label. Icon takes precedence over a label */ /** Icon to display instead of a label. Icon takes precedence over a label */
private final int mIconAttrId; private final int mIconAttrId;
@ -509,6 +511,14 @@ public class Key {
return (mLabelFlags & LABEL_FLAGS_AUTO_X_SCALE) != 0; return (mLabelFlags & LABEL_FLAGS_AUTO_X_SCALE) != 0;
} }
public boolean isInactivatedLabel() {
return (mLabelFlags & LABEL_FLAGS_INACTIVATED_LABEL) != 0;
}
public boolean isInactivatedUppercaseLetter() {
return (mLabelFlags & LABEL_FLAGS_INACTIVATED_UPPERCASE_LETTER) != 0;
}
// TODO: Get rid of this method. // TODO: Get rid of this method.
public Drawable getIcon(KeyboardIconsSet iconSet) { public Drawable getIcon(KeyboardIconsSet iconSet) {
return mEnabled ? mIcon : iconSet.getIconByAttrId(mDisabledIconAttrId); return mEnabled ? mIcon : iconSet.getIconByAttrId(mDisabledIconAttrId);

View file

@ -571,8 +571,11 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
Math.min(1.0f, (keyWidth * MAX_LABEL_RATIO) / getLabelWidth(label, paint))); Math.min(1.0f, (keyWidth * MAX_LABEL_RATIO) / getLabelWidth(label, paint)));
} }
// TODO: Remove this first if-clause.
if (key.hasUppercaseLetter() && mKeyboard.isManualTemporaryUpperCase()) { if (key.hasUppercaseLetter() && mKeyboard.isManualTemporaryUpperCase()) {
paint.setColor(params.mKeyTextInactivatedColor); paint.setColor(params.mKeyTextInactivatedColor);
} else if (key.isInactivatedLabel()) {
paint.setColor(params.mKeyTextInactivatedColor);
} else { } else {
paint.setColor(params.mKeyTextColor); paint.setColor(params.mKeyTextColor);
} }
@ -618,9 +621,14 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
hintSize = params.mKeyHintLabelSize; hintSize = params.mKeyHintLabelSize;
paint.setTypeface(Typeface.DEFAULT); paint.setTypeface(Typeface.DEFAULT);
} else if (key.hasUppercaseLetter()) { } else if (key.hasUppercaseLetter()) {
hintColor = mKeyboard.isManualTemporaryUpperCase() // TODO: Remove this first if-clause.
? params.mKeyUppercaseLetterActivatedColor if (mKeyboard.isManualTemporaryUpperCase()) {
: params.mKeyUppercaseLetterInactivatedColor; hintColor = params.mKeyUppercaseLetterActivatedColor;
} else if (!key.isInactivatedUppercaseLetter()) {
hintColor = params.mKeyUppercaseLetterActivatedColor;
} else {
hintColor = params.mKeyUppercaseLetterInactivatedColor;
}
hintSize = params.mKeyUppercaseLetterSize; hintSize = params.mKeyUppercaseLetterSize;
} else { // key.hasHintLetter() } else { // key.hasHintLetter()
hintColor = params.mKeyHintLetterColor; hintColor = params.mKeyHintLetterColor;