am 7a5ca998: Revert "Fix key letter size of 5-rows Thai keyboard"

* commit '7a5ca9982fae2c17df4e597d2c54c81782946ed1':
  Revert "Fix key letter size of 5-rows Thai keyboard"
This commit is contained in:
Ken Wakasa 2012-08-29 05:07:43 -07:00 committed by Android Git Automerger
commit 33ea73d3b0
13 changed files with 22 additions and 97 deletions

View file

@ -53,8 +53,6 @@
<fraction name="key_uppercase_letter_ratio">40%</fraction>
<fraction name="key_preview_text_ratio">90%</fraction>
<fraction name="spacebar_text_ratio">40.000%</fraction>
<fraction name="key_letter_ratio_5rows">78%</fraction>
<fraction name="key_uppercase_letter_ratio_5rows">48%</fraction>
<dimen name="key_preview_offset">0.0dp</dimen>
<dimen name="key_preview_offset_ics">1.6dp</dimen>

View file

@ -51,8 +51,6 @@
<fraction name="key_hint_label_ratio">34%</fraction>
<fraction name="key_uppercase_letter_ratio">29%</fraction>
<fraction name="spacebar_text_ratio">30.0%</fraction>
<fraction name="key_letter_ratio_5rows">62%</fraction>
<fraction name="key_uppercase_letter_ratio_5rows">36%</fraction>
<dimen name="key_uppercase_letter_padding">4dp</dimen>
<dimen name="suggestions_strip_padding">252.0dp</dimen>

View file

@ -63,8 +63,6 @@
<fraction name="key_uppercase_letter_ratio">22%</fraction>
<fraction name="key_preview_text_ratio">50%</fraction>
<fraction name="spacebar_text_ratio">28.0%</fraction>
<fraction name="key_letter_ratio_5rows">52%</fraction>
<fraction name="key_uppercase_letter_ratio_5rows">27%</fraction>
<dimen name="key_preview_height">94.5dp</dimen>
<dimen name="key_preview_offset">16.0dp</dimen>

View file

@ -53,8 +53,6 @@
<fraction name="key_hint_label_ratio">28%</fraction>
<fraction name="key_uppercase_letter_ratio">24%</fraction>
<fraction name="spacebar_text_ratio">24.00%</fraction>
<fraction name="key_letter_ratio_5rows">53%</fraction>
<fraction name="key_uppercase_letter_ratio_5rows">30%</fraction>
<dimen name="key_preview_height">107.1dp</dimen>
<dimen name="key_preview_offset_ics">8.0dp</dimen>

View file

@ -64,8 +64,6 @@
<fraction name="key_uppercase_letter_ratio">26%</fraction>
<fraction name="key_preview_text_ratio">50%</fraction>
<fraction name="spacebar_text_ratio">29.03%</fraction>
<fraction name="key_letter_ratio_5rows">51%</fraction>
<fraction name="key_uppercase_letter_ratio_5rows">33%</fraction>
<dimen name="key_preview_height">94.5dp</dimen>
<dimen name="key_preview_offset">16.0dp</dimen>

View file

@ -65,8 +65,6 @@
<fraction name="key_uppercase_letter_ratio">35%</fraction>
<fraction name="key_preview_text_ratio">82%</fraction>
<fraction name="spacebar_text_ratio">33.735%</fraction>
<fraction name="key_letter_ratio_5rows">64%</fraction>
<fraction name="key_uppercase_letter_ratio_5rows">41%</fraction>
<dimen name="key_preview_height">80dp</dimen>
<dimen name="key_preview_offset">-8.0dp</dimen>

View file

@ -23,8 +23,6 @@
latin:rowHeight="20%p"
latin:verticalGap="3.20%p"
latin:keyTypeface="normal"
latin:keyLetterSize="@fraction/key_letter_ratio_5rows"
latin:keyShiftedLetterHintRatio="@fraction/key_uppercase_letter_ratio_5rows"
latin:touchPositionCorrectionData="@null"
>
<include

View file

@ -23,8 +23,6 @@
latin:rowHeight="20%p"
latin:verticalGap="3.20%p"
latin:keyTypeface="normal"
latin:keyLetterSize="@fraction/key_letter_ratio_5rows"
latin:keyShiftedLetterHintRatio="@fraction/key_uppercase_letter_ratio_5rows"
latin:touchPositionCorrectionData="@null"
>
<include

View file

@ -23,8 +23,6 @@
latin:rowHeight="20%p"
latin:verticalGap="2.65%p"
latin:keyTypeface="normal"
latin:keyLetterSize="@fraction/key_letter_ratio_5rows"
latin:keyShiftedLetterHintRatio="@fraction/key_uppercase_letter_ratio_5rows"
latin:touchPositionCorrectionData="@null"
>
<include

View file

@ -23,8 +23,6 @@
latin:rowHeight="20%p"
latin:verticalGap="2.95%p"
latin:keyTypeface="normal"
latin:keyLetterSize="@fraction/key_letter_ratio_5rows"
latin:keyShiftedLetterHintRatio="@fraction/key_uppercase_letter_ratio_5rows"
latin:touchPositionCorrectionData="@null"
>
<include

View file

@ -124,10 +124,6 @@ public class Keyboard {
/** Per keyboard key visual parameters */
public final Typeface mKeyTypeface;
public final float mKeyLetterRatio;
public final int mKeyLetterSize;
public final float mKeyHintLetterRatio;
public final float mKeyShiftedLetterHintRatio;
public final int mMostCommonKeyHeight;
public final int mMostCommonKeyWidth;
@ -160,10 +156,6 @@ public class Keyboard {
mMaxMoreKeysKeyboardColumn = params.mMaxMoreKeysKeyboardColumn;
mKeyTypeface = params.mKeyTypeface;
mKeyLetterRatio = params.mKeyLetterRatio;
mKeyLetterSize = params.mKeyLetterSize;
mKeyHintLetterRatio = params.mKeyHintLetterRatio;
mKeyShiftedLetterHintRatio = params.mKeyShiftedLetterHintRatio;
mTopPadding = params.mTopPadding;
mVerticalGap = params.mVerticalGap;
@ -261,10 +253,6 @@ public class Keyboard {
public int mHorizontalCenterPadding;
public Typeface mKeyTypeface = null;
public float mKeyLetterRatio = ResourceUtils.UNDEFINED_RATIO;
public int mKeyLetterSize = ResourceUtils.UNDEFINED_DIMENSION;
public float mKeyHintLetterRatio = ResourceUtils.UNDEFINED_RATIO;;
public float mKeyShiftedLetterHintRatio = ResourceUtils.UNDEFINED_RATIO;
public int mDefaultRowHeight;
public int mDefaultKeyWidth;
@ -825,14 +813,6 @@ public class Keyboard {
params.mKeyTypeface = Typeface.defaultFromStyle(keyboardViewAttr.getInt(
R.styleable.KeyboardView_keyTypeface, Typeface.NORMAL));
}
params.mKeyLetterRatio = ResourceUtils.getFraction(keyboardViewAttr,
R.styleable.KeyboardView_keyLetterSize);
params.mKeyLetterSize = ResourceUtils.getDimensionPixelSize(keyboardViewAttr,
R.styleable.KeyboardView_keyLetterSize);
params.mKeyHintLetterRatio = ResourceUtils.getFraction(keyboardViewAttr,
R.styleable.KeyboardView_keyHintLetterRatio);
params.mKeyShiftedLetterHintRatio = ResourceUtils.getFraction(keyboardViewAttr,
R.styleable.KeyboardView_keyShiftedLetterHintRatio);
params.mMoreKeysTemplate = keyboardAttr.getResourceId(
R.styleable.Keyboard_moreKeysTemplate, 0);

View file

@ -85,7 +85,6 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
// Miscellaneous constants
private static final int[] LONG_PRESSABLE_STATE_SET = { android.R.attr.state_long_pressable };
// XML attributes
protected final float mVerticalCorrection;
protected final int mMoreKeysLayout;
@ -198,7 +197,6 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
private final Typeface mKeyTypefaceFromKeyboardView;
private final float mKeyLetterRatio;
private final int mKeyLetterSizeFromKeyboardView;
private final float mKeyLargeLetterRatio;
private final float mKeyLabelRatio;
private final float mKeyLargeLabelRatio;
@ -219,12 +217,16 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
public KeyDrawParams(final TypedArray a) {
mKeyBackground = a.getDrawable(R.styleable.KeyboardView_keyBackground);
mKeyLetterRatio = ResourceUtils.getFraction(a, R.styleable.KeyboardView_keyLetterSize);
mKeyLetterSizeFromKeyboardView = ResourceUtils.getDimensionPixelSize(a,
R.styleable.KeyboardView_keyLetterSize);
mKeyLabelRatio = ResourceUtils.getFraction(a, R.styleable.KeyboardView_keyLabelSize);
mKeyLabelSize = ResourceUtils.getDimensionPixelSize(a,
R.styleable.KeyboardView_keyLabelSize);
if (!ResourceUtils.isValidFraction(mKeyLetterRatio = ResourceUtils.getFraction(a,
R.styleable.KeyboardView_keyLetterSize))) {
mKeyLetterSize = ResourceUtils.getDimensionPixelSize(a,
R.styleable.KeyboardView_keyLetterSize);
}
if (!ResourceUtils.isValidFraction(mKeyLabelRatio = ResourceUtils.getFraction(a,
R.styleable.KeyboardView_keyLabelSize))) {
mKeyLabelSize = ResourceUtils.getDimensionPixelSize(a,
R.styleable.KeyboardView_keyLabelSize);
}
mKeyLargeLabelRatio = ResourceUtils.getFraction(a,
R.styleable.KeyboardView_keyLargeLabelRatio);
mKeyLargeLetterRatio = ResourceUtils.getFraction(a,
@ -243,23 +245,19 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
R.styleable.KeyboardView_keyPopupHintLetterPadding, 0);
mKeyShiftedLetterHintPadding = a.getDimension(
R.styleable.KeyboardView_keyShiftedLetterHintPadding, 0);
mKeyTextColor = a.getColor(
R.styleable.KeyboardView_keyTextColor, Color.WHITE);
mKeyTextColor = a.getColor(R.styleable.KeyboardView_keyTextColor, 0xFF000000);
mKeyTextInactivatedColor = a.getColor(
R.styleable.KeyboardView_keyTextInactivatedColor, Color.WHITE);
mKeyHintLetterColor = a.getColor(
R.styleable.KeyboardView_keyHintLetterColor, Color.TRANSPARENT);
mKeyHintLabelColor = a.getColor(
R.styleable.KeyboardView_keyHintLabelColor, Color.TRANSPARENT);
R.styleable.KeyboardView_keyTextInactivatedColor, 0xFF000000);
mKeyHintLetterColor = a.getColor(R.styleable.KeyboardView_keyHintLetterColor, 0);
mKeyHintLabelColor = a.getColor(R.styleable.KeyboardView_keyHintLabelColor, 0);
mKeyShiftedLetterHintInactivatedColor = a.getColor(
R.styleable.KeyboardView_keyShiftedLetterHintInactivatedColor,
Color.TRANSPARENT);
R.styleable.KeyboardView_keyShiftedLetterHintInactivatedColor, 0);
mKeyShiftedLetterHintActivatedColor = a.getColor(
R.styleable.KeyboardView_keyShiftedLetterHintActivatedColor, Color.TRANSPARENT);
R.styleable.KeyboardView_keyShiftedLetterHintActivatedColor, 0);
mKeyTypefaceFromKeyboardView = Typeface.defaultFromStyle(
a.getInt(R.styleable.KeyboardView_keyTypeface, Typeface.NORMAL));
mKeyTypeface = mKeyTypefaceFromKeyboardView;
mShadowColor = a.getColor(R.styleable.KeyboardView_shadowColor, Color.TRANSPARENT);
mShadowColor = a.getColor(R.styleable.KeyboardView_shadowColor, 0);
mShadowRadius = a.getFloat(R.styleable.KeyboardView_shadowRadius, 0f);
mKeyBackground.getPadding(mPadding);
@ -269,42 +267,19 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
mKeyTypeface = (keyboard.mKeyTypeface != null)
? keyboard.mKeyTypeface : mKeyTypefaceFromKeyboardView;
final int keyHeight = keyboard.mMostCommonKeyHeight - keyboard.mVerticalGap;
mKeyLetterSize = selectTextSizeFromDimensionOrRatio(keyHeight,
mKeyLetterSizeFromKeyboardView, mKeyLetterRatio,
mKeyLetterSizeFromKeyboardView);
// Override if size/ratio is specified in Keyboard.
mKeyLetterSize = selectTextSizeFromDimensionOrRatio(keyHeight, keyboard.mKeyLetterSize,
keyboard.mKeyLetterRatio, mKeyLetterSize);
if (ResourceUtils.isValidFraction(mKeyLetterRatio)) {
mKeyLetterSize = (int)(keyHeight * mKeyLetterRatio);
}
if (ResourceUtils.isValidFraction(mKeyLabelRatio)) {
mKeyLabelSize = (int)(keyHeight * mKeyLabelRatio);
}
mKeyLargeLabelSize = (int)(keyHeight * mKeyLargeLabelRatio);
mKeyLargeLetterSize = (int)(keyHeight * mKeyLargeLetterRatio);
mKeyHintLetterSize = selectTextSizeFromKeyboardOrView(keyHeight,
keyboard.mKeyHintLetterRatio, mKeyHintLetterRatio);
mKeyShiftedLetterHintSize = selectTextSizeFromKeyboardOrView(keyHeight,
keyboard.mKeyShiftedLetterHintRatio, mKeyShiftedLetterHintRatio);
mKeyHintLetterSize = (int)(keyHeight * mKeyHintLetterRatio);
mKeyShiftedLetterHintSize = (int)(keyHeight * mKeyShiftedLetterHintRatio);
mKeyHintLabelSize = (int)(keyHeight * mKeyHintLabelRatio);
}
private static final int selectTextSizeFromDimensionOrRatio(final int keyHeight,
final int dimens, final float ratio, final int defaultDimens) {
if (ResourceUtils.isValidDimensionPixelSize(dimens)) {
return dimens;
}
if (ResourceUtils.isValidFraction(ratio)) {
return (int)(keyHeight * ratio);
}
return defaultDimens;
}
private static final int selectTextSizeFromKeyboardOrView(final int keyHeight,
final float ratioFromKeyboard, final float ratioFromView) {
final float ratio = ResourceUtils.isValidFraction(ratioFromKeyboard)
? ratioFromKeyboard : ratioFromView;
return (int)(keyHeight * ratio);
}
public void blendAlpha(final Paint paint) {
final int color = paint.getColor();
paint.setARGB((paint.getAlpha() * mAnimAlpha) / Constants.Color.ALPHA_OPAQUE,

View file

@ -55,16 +55,6 @@ public final class ResourceUtils {
return fraction >= 0.0f;
}
// {@link Resources#getDimensionPixelSize(int)} returns at least one pixel size.
public static boolean isValidDimensionPixelSize(final int dimension) {
return dimension > 0;
}
// {@link Resources#getDimensionPixelOffset(int)} may return zero pixel offset.
public static boolean isValidDimensionPixelOffset(final int dimension) {
return dimension >= 0;
}
public static float getFraction(final TypedArray a, final int index, final float defValue) {
final TypedValue value = a.peekValue(index);
if (value == null || !isFractionValue(value)) {