From 639c93f43bc51a8328d7dc11a09a3bd77974aeae Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Fri, 18 Jul 2014 18:48:17 -0700 Subject: [PATCH] Remove unused Key.keyLabelFlags' values Change-Id: Iae3cd6674448f258ee0a4bf2966bf3c347876b4f --- java/res/values-land/config.xml | 2 - java/res/values-sw600dp-land/config.xml | 2 - java/res/values-sw600dp/config.xml | 2 - java/res/values-sw768dp-land/config.xml | 2 - java/res/values-sw768dp/config.xml | 2 - java/res/values/attrs.xml | 8 --- java/res/values/config.xml | 1 - java/res/values/themes-common.xml | 1 - java/res/xml/key_styles_number.xml | 1 - .../com/android/inputmethod/keyboard/Key.java | 25 --------- .../inputmethod/keyboard/KeyboardView.java | 54 ++----------------- 11 files changed, 4 insertions(+), 96 deletions(-) diff --git a/java/res/values-land/config.xml b/java/res/values-land/config.xml index 9ee430014..5eea4c1c6 100644 --- a/java/res/values-land/config.xml +++ b/java/res/values-land/config.xml @@ -49,8 +49,6 @@ 52% 40% 40.000% - - 8dp 3.20%p diff --git a/java/res/values-sw600dp-land/config.xml b/java/res/values-sw600dp-land/config.xml index ba8b52f0b..6368eef41 100644 --- a/java/res/values-sw600dp-land/config.xml +++ b/java/res/values-sw600dp-land/config.xml @@ -39,8 +39,6 @@ 34% 29% 30.0% - - 18dp 4dp diff --git a/java/res/values-sw600dp/config.xml b/java/res/values-sw600dp/config.xml index d97538de0..9d16e2cb9 100644 --- a/java/res/values-sw600dp/config.xml +++ b/java/res/values-sw600dp/config.xml @@ -52,8 +52,6 @@ 28% 22% 28.0% - - 6dp 3dp 3dp diff --git a/java/res/values-sw768dp-land/config.xml b/java/res/values-sw768dp-land/config.xml index 63f86ba81..a1659b45a 100644 --- a/java/res/values-sw768dp-land/config.xml +++ b/java/res/values-sw768dp-land/config.xml @@ -41,8 +41,6 @@ 28% 24% 24.00% - - 18dp 2.65%p diff --git a/java/res/values-sw768dp/config.xml b/java/res/values-sw768dp/config.xml index 94b38d850..635061d24 100644 --- a/java/res/values-sw768dp/config.xml +++ b/java/res/values-sw768dp/config.xml @@ -50,8 +50,6 @@ 28% 26% 29.03% - - 6dp 3dp 3dp diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml index 64879551f..5434106c5 100644 --- a/java/res/values/attrs.xml +++ b/java/res/values/attrs.xml @@ -50,8 +50,6 @@ {@link StateListDrawable}, with the following possible states: normal, pressed. --> - - @@ -291,9 +289,6 @@ - - - @@ -306,9 +301,6 @@ - - - diff --git a/java/res/values/config.xml b/java/res/values/config.xml index 709121392..d748c9179 100644 --- a/java/res/values/config.xml +++ b/java/res/values/config.xml @@ -54,7 +54,6 @@ 44% 35% 33.735% - 4dp 1dp 2dp diff --git a/java/res/values/themes-common.xml b/java/res/values/themes-common.xml index 2b2a80aed..b139110ca 100644 --- a/java/res/values/themes-common.xml +++ b/java/res/values/themes-common.xml @@ -39,7 +39,6 @@ @fraction/config_key_hint_label_ratio @fraction/config_key_shifted_letter_hint_ratio normal - @dimen/config_key_label_horizontal_padding @dimen/config_key_hint_letter_padding @dimen/config_key_popup_hint_letter_padding @dimen/config_key_shifted_letter_hint_padding diff --git a/java/res/xml/key_styles_number.xml b/java/res/xml/key_styles_number.xml index 8a76fe397..df4448c25 100644 --- a/java/res/xml/key_styles_number.xml +++ b/java/res/xml/key_styles_number.xml @@ -120,7 +120,6 @@ diff --git a/java/src/com/android/inputmethod/keyboard/Key.java b/java/src/com/android/inputmethod/keyboard/Key.java index 665d9f7a1..af54fb674 100644 --- a/java/src/com/android/inputmethod/keyboard/Key.java +++ b/java/src/com/android/inputmethod/keyboard/Key.java @@ -58,9 +58,6 @@ public class Key implements Comparable { private final String mHintLabel; /** Flags of the label */ private final int mLabelFlags; - private static final int LABEL_FLAGS_ALIGN_LEFT = 0x01; - private static final int LABEL_FLAGS_ALIGN_RIGHT = 0x02; - private static final int LABEL_FLAGS_ALIGN_BUTTOM = 0x04; private static final int LABEL_FLAGS_ALIGN_LEFT_OF_CENTER = 0x08; // Font typeface specification. private static final int LABEL_FLAGS_FONT_MASK = 0x30; @@ -78,8 +75,6 @@ public class Key implements Comparable { private static final int LABEL_FLAGS_HAS_POPUP_HINT = 0x200; private static final int LABEL_FLAGS_HAS_SHIFTED_LETTER_HINT = 0x400; private static final int LABEL_FLAGS_HAS_HINT_LABEL = 0x800; - private static final int LABEL_FLAGS_WITH_ICON_LEFT = 0x1000; - private static final int LABEL_FLAGS_WITH_ICON_RIGHT = 0x2000; // The bit to calculate the ratio of key label width against key width. If autoXScale bit is on // and autoYScale bit is off, the key label may be shrunk only for X-direction. // If both autoXScale and autoYScale bits are on, the key label text size may be auto scaled. @@ -646,18 +641,6 @@ public class Key implements Comparable { return Typeface.DEFAULT_BOLD; } - public final boolean isAlignLeft() { - return (mLabelFlags & LABEL_FLAGS_ALIGN_LEFT) != 0; - } - - public final boolean isAlignRight() { - return (mLabelFlags & LABEL_FLAGS_ALIGN_RIGHT) != 0; - } - - public final boolean isAlignButtom() { - return (mLabelFlags & LABEL_FLAGS_ALIGN_BUTTOM) != 0; - } - public final boolean isAlignLeftOfCenter() { return (mLabelFlags & LABEL_FLAGS_ALIGN_LEFT_OF_CENTER) != 0; } @@ -675,14 +658,6 @@ public class Key implements Comparable { return (mLabelFlags & LABEL_FLAGS_HAS_HINT_LABEL) != 0; } - public final boolean hasLabelWithIconLeft() { - return (mLabelFlags & LABEL_FLAGS_WITH_ICON_LEFT) != 0; - } - - public final boolean hasLabelWithIconRight() { - return (mLabelFlags & LABEL_FLAGS_WITH_ICON_RIGHT) != 0; - } - public final boolean needsAutoXScale() { return (mLabelFlags & LABEL_FLAGS_AUTO_X_SCALE) != 0; } diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java index c4ca1c495..f967f620a 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java @@ -47,7 +47,6 @@ import java.util.HashSet; * @attr ref R.styleable#KeyboardView_functionalKeyBackground * @attr ref R.styleable#KeyboardView_spacebarBackground * @attr ref R.styleable#KeyboardView_spacebarIconWidthRatio - * @attr ref R.styleable#KeyboardView_keyLabelHorizontalPadding * @attr ref R.styleable#KeyboardView_keyHintLetterPadding * @attr ref R.styleable#KeyboardView_keyPopupHintLetterPadding * @attr ref R.styleable#KeyboardView_keyShiftedLetterHintPadding @@ -74,7 +73,6 @@ import java.util.HashSet; public class KeyboardView extends View { // XML attributes private final KeyVisualAttributes mKeyVisualAttributes; - private final int mKeyLabelHorizontalPadding; private final float mKeyHintLetterPadding; private final float mKeyPopupHintLetterPadding; private final float mKeyShiftedLetterHintPadding; @@ -90,11 +88,6 @@ public class KeyboardView extends View { // HORIZONTAL ELLIPSIS "...", character for popup hint. private static final String POPUP_HINT_CHAR = "\u2026"; - // Margin between the label and the icon on a key that has both of them. - // Specified by the fraction of the key width. - // TODO: Use resource parameter for this value. - private static final float LABEL_ICON_MARGIN = 0.05f; - // The maximum key label width in the proportion to the key width. private static final float MAX_LABEL_RATIO = 0.90f; @@ -137,8 +130,6 @@ public class KeyboardView extends View { mSpacebarBackground = (spacebarBackground != null) ? spacebarBackground : mKeyBackground; mSpacebarIconWidthRatio = keyboardViewAttr.getFloat( R.styleable.KeyboardView_spacebarIconWidthRatio, 1.0f); - mKeyLabelHorizontalPadding = keyboardViewAttr.getDimensionPixelOffset( - R.styleable.KeyboardView_keyLabelHorizontalPadding, 0); mKeyHintLetterPadding = keyboardViewAttr.getDimension( R.styleable.KeyboardView_keyHintLetterPadding, 0.0f); mKeyPopupHintLetterPadding = keyboardViewAttr.getDimension( @@ -376,27 +367,10 @@ public class KeyboardView extends View { final float baseline = centerY + labelCharHeight / 2.0f; // Horizontal label text alignment - float labelWidth = 0.0f; - if (key.isAlignLeft()) { - positionX = mKeyLabelHorizontalPadding; - paint.setTextAlign(Align.LEFT); - } else if (key.isAlignRight()) { - positionX = keyWidth - mKeyLabelHorizontalPadding; - paint.setTextAlign(Align.RIGHT); - } else if (key.isAlignLeftOfCenter()) { + if (key.isAlignLeftOfCenter()) { // TODO: Parameterise this? positionX = centerX - labelCharWidth * 7.0f / 4.0f; paint.setTextAlign(Align.LEFT); - } else if (key.hasLabelWithIconLeft() && icon != null) { - labelWidth = TypefaceUtils.getStringWidth(label, paint) + icon.getIntrinsicWidth() - + LABEL_ICON_MARGIN * keyWidth; - positionX = centerX + labelWidth / 2.0f; - paint.setTextAlign(Align.RIGHT); - } else if (key.hasLabelWithIconRight() && icon != null) { - labelWidth = TypefaceUtils.getStringWidth(label, paint) + icon.getIntrinsicWidth() - + LABEL_ICON_MARGIN * keyWidth; - positionX = centerX - labelWidth / 2.0f; - paint.setTextAlign(Align.LEFT); } else { positionX = centerX; paint.setTextAlign(Align.CENTER); @@ -430,19 +404,6 @@ public class KeyboardView extends View { // Turn off drop shadow and reset x-scale. paint.clearShadowLayer(); paint.setTextScaleX(1.0f); - - if (icon != null) { - final int iconWidth = icon.getIntrinsicWidth(); - final int iconHeight = icon.getIntrinsicHeight(); - final int iconY = (keyHeight - iconHeight) / 2; - if (key.hasLabelWithIconLeft()) { - final int iconX = (int)(centerX - labelWidth / 2.0f); - drawIcon(canvas, icon, iconX, iconY, iconWidth, iconHeight); - } else if (key.hasLabelWithIconRight()) { - final int iconX = (int)(centerX + labelWidth / 2.0f - iconWidth); - drawIcon(canvas, icon, iconX, iconY, iconWidth, iconHeight); - } - } } // Draw hint label. @@ -493,16 +454,9 @@ public class KeyboardView extends View { iconWidth = Math.min(icon.getIntrinsicWidth(), keyWidth); } final int iconHeight = icon.getIntrinsicHeight(); - final int iconY = key.isAlignButtom() ? keyHeight - iconHeight - : (keyHeight - iconHeight) / 2; - final int iconX; - if (key.isAlignLeft()) { - iconX = mKeyLabelHorizontalPadding; - } else if (key.isAlignRight()) { - iconX = keyWidth - mKeyLabelHorizontalPadding - iconWidth; - } else { // Align center - iconX = (keyWidth - iconWidth) / 2; - } + // Align center. + final int iconY = (keyHeight - iconHeight) / 2; + final int iconX = (keyWidth - iconWidth) / 2; drawIcon(canvas, icon, iconX, iconY, iconWidth, iconHeight); }