am bd85efd5: Merge "Set divider icon\'s alpha value on the fly" into jb-dev

* commit 'bd85efd5fb70496b05aa7a3dd7646dca894a9464':
  Set divider icon's alpha value on the fly
main
Tadashi G. Takaoka 2012-05-16 01:57:34 -07:00 committed by Android Git Automerger
commit 50e373943d
5 changed files with 19 additions and 14 deletions

View File

@ -571,9 +571,13 @@ public class Key {
return (mMoreKeysColumnAndFlags & MORE_KEYS_FLAGS_EMBEDDED_MORE_KEY) != 0; return (mMoreKeysColumnAndFlags & MORE_KEYS_FLAGS_EMBEDDED_MORE_KEY) != 0;
} }
public Drawable getIcon(KeyboardIconsSet iconSet) { public Drawable getIcon(KeyboardIconsSet iconSet, int alpha) {
final int iconId = mEnabled ? mIconId : mDisabledIconId; final int iconId = mEnabled ? mIconId : mDisabledIconId;
return iconSet.getIconDrawable(iconId); final Drawable icon = iconSet.getIconDrawable(iconId);
if (icon != null) {
icon.setAlpha(alpha);
}
return icon;
} }
public Drawable getPreviewIcon(KeyboardIconsSet iconSet) { public Drawable getPreviewIcon(KeyboardIconsSet iconSet) {

View File

@ -560,10 +560,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
} }
// Draw key label. // Draw key label.
final Drawable icon = key.getIcon(mKeyboard.mIconsSet); final Drawable icon = key.getIcon(mKeyboard.mIconsSet, params.mAnimAlpha);
if (icon != null) {
icon.setAlpha(params.mAnimAlpha);
}
float positionX = centerX; float positionX = centerX;
if (key.mLabel != null) { if (key.mLabel != null) {
final String label = key.mLabel; final String label = key.mLabel;

View File

@ -459,7 +459,8 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
mMoreKeysPanelCache.clear(); mMoreKeysPanelCache.clear();
mSpaceKey = keyboard.getKey(Keyboard.CODE_SPACE); mSpaceKey = keyboard.getKey(Keyboard.CODE_SPACE);
mSpaceIcon = (mSpaceKey != null) ? mSpaceKey.getIcon(keyboard.mIconsSet) : null; mSpaceIcon = (mSpaceKey != null)
? mSpaceKey.getIcon(keyboard.mIconsSet, ALPHA_OPAQUE) : null;
final int keyHeight = keyboard.mMostCommonKeyHeight - keyboard.mVerticalGap; final int keyHeight = keyboard.mMostCommonKeyHeight - keyboard.mVerticalGap;
mSpacebarTextSize = keyHeight * mSpacebarTextRatio; mSpacebarTextSize = keyHeight * mSpacebarTextRatio;
if (ProductionFlag.IS_EXPERIMENTAL) { if (ProductionFlag.IS_EXPERIMENTAL) {

View File

@ -289,8 +289,6 @@ public class MoreKeysKeyboard extends Keyboard {
final int dividerWidth; final int dividerWidth;
if (parentKey.needsDividersInMoreKeys()) { if (parentKey.needsDividersInMoreKeys()) {
mDivider = mResources.getDrawable(R.drawable.more_keys_divider); mDivider = mResources.getDrawable(R.drawable.more_keys_divider);
// TODO: Drawable itself should have an alpha value.
mDivider.setAlpha(128);
dividerWidth = (int)(width * DIVIDER_RATIO); dividerWidth = (int)(width * DIVIDER_RATIO);
} else { } else {
mDivider = null; mDivider = null;
@ -333,8 +331,11 @@ public class MoreKeysKeyboard extends Keyboard {
} }
@Override @Override
public Drawable getIcon(KeyboardIconsSet iconSet) { public Drawable getIcon(KeyboardIconsSet iconSet, int alpha) {
// KeyboardIconsSet is unused. Use the icon that has been passed to the constructor. // KeyboardIconsSet and alpha are unused. Use the icon that has been passed to the
// constructor.
// TODO: Drawable itself should have an alpha value.
mIcon.setAlpha(128);
return mIcon; return mIcon;
} }
} }

View File

@ -56,8 +56,6 @@ public class MoreSuggestions extends Keyboard {
clearKeys(); clearKeys();
final Resources res = view.getContext().getResources(); final Resources res = view.getContext().getResources();
mDivider = res.getDrawable(R.drawable.more_suggestions_divider); mDivider = res.getDrawable(R.drawable.more_suggestions_divider);
// TODO: Drawable itself should have an alpha value.
mDivider.setAlpha(128);
mDividerWidth = mDivider.getIntrinsicWidth(); mDividerWidth = mDivider.getIntrinsicWidth();
final int padding = (int) res.getDimension( final int padding = (int) res.getDimension(
R.dimen.more_suggestions_key_horizontal_padding); R.dimen.more_suggestions_key_horizontal_padding);
@ -195,7 +193,11 @@ public class MoreSuggestions extends Keyboard {
} }
@Override @Override
public Drawable getIcon(KeyboardIconsSet iconSet) { public Drawable getIcon(KeyboardIconsSet iconSet, int alpha) {
// KeyboardIconsSet and alpha are unused. Use the icon that has been passed to the
// constructor.
// TODO: Drawable itself should have an alpha value.
mIcon.setAlpha(128);
return mIcon; return mIcon;
} }
} }