am 6fe326ae: am 761a6812: Don\'t reuse main keyboard\'s spacebar icon for Emoji palette

* commit '6fe326ae42c084f03557d16cb098bb230494dde4':
  Don't reuse main keyboard's spacebar icon for Emoji palette
main
Tadashi G. Takaoka 2014-05-29 15:09:33 +00:00 committed by Android Git Automerger
commit f41f7a185b
2 changed files with 17 additions and 5 deletions

View File

@ -369,8 +369,14 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange
public void startEmojiPalettes(final String switchToAlphaLabel,
final KeyVisualAttributes keyVisualAttr, final KeyboardIconsSet iconSet) {
mDeleteKey.setImageDrawable(iconSet.getIconDrawable(KeyboardIconsSet.NAME_DELETE_KEY));
mSpacebar.setImageDrawable(iconSet.getIconDrawable(KeyboardIconsSet.NAME_SPACE_KEY));
final int deleteIconResId = iconSet.getIconResourceId(KeyboardIconsSet.NAME_DELETE_KEY);
if (deleteIconResId != 0) {
mDeleteKey.setImageResource(deleteIconResId);
}
final int spacebarResId = iconSet.getIconResourceId(KeyboardIconsSet.NAME_SPACE_KEY);
if (spacebarResId != 0) {
mSpacebar.setImageResource(spacebarResId);
}
final KeyDrawParams params = new KeyDrawParams();
params.updateParams(mEmojiLayoutParams.getActionBarHeight(), keyVisualAttr);
setupAlphabetKey(mAlphabetKeyLeft, switchToAlphaLabel, params);

View File

@ -89,6 +89,7 @@ public final class KeyboardIconsSet {
private static int NUM_ICONS = NAMES_AND_ATTR_IDS.length / 2;
private static final String[] ICON_NAMES = new String[NUM_ICONS];
private final Drawable[] mIcons = new Drawable[NUM_ICONS];
private final int[] mIconResourceIds = new int[NUM_ICONS];
static {
int iconId = ICON_UNDEFINED;
@ -113,6 +114,7 @@ public final class KeyboardIconsSet {
setDefaultBounds(icon);
final Integer iconId = ATTR_ID_TO_ICON_ID.get(attrId);
mIcons[iconId] = icon;
mIconResourceIds[iconId] = keyboardAttrs.getResourceId(attrId, 0);
} catch (Resources.NotFoundException e) {
Log.w(TAG, "Drawable resource for icon #"
+ keyboardAttrs.getResources().getResourceEntryName(attrId)
@ -137,8 +139,12 @@ public final class KeyboardIconsSet {
throw new RuntimeException("unknown icon name: " + name);
}
public Drawable getIconDrawable(final String name) {
return getIconDrawable(getIconId(name));
public int getIconResourceId(final String name) {
final int iconId = getIconId(name);
if (isValidIconId(iconId)) {
return mIconResourceIds[iconId];
}
throw new RuntimeException("unknown icon name: " + name);
}
public Drawable getIconDrawable(final int iconId) {