Merge "Tweak tablet keyboard design"

main
Tadashi G. Takaoka 2010-12-01 02:07:26 -08:00 committed by Android (Google) Code Review
commit bd20db25be
22 changed files with 87 additions and 64 deletions

View File

@ -17,5 +17,4 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@drawable/btn_keyboard_key_popup_selected_holo" />
<item android:drawable="@drawable/btn_keyboard_key_light_popup_normal" />
</selector>

View File

@ -23,8 +23,8 @@
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@drawable/keyboard_popup_panel_background_holo"
android:paddingLeft="44dip"
android:paddingRight="32dip"
android:paddingLeft="40dip"
android:paddingRight="40dip"
>
<com.android.inputmethod.latin.BaseKeyboardView
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"

View File

@ -28,8 +28,7 @@
android:paddingTop="@dimen/keyboard_top_padding"
android:paddingBottom="@dimen/keyboard_bottom_padding"
android:background="@drawable/keyboard_dark_background"
android:textStyle="bold"
latin:keyBackground="@drawable/btn_keyboard_key_gingerbread"
latin:keyTextStyle="bold"
latin:keyLetterStyle="bold"
/>

View File

@ -28,10 +28,12 @@
android:paddingTop="@dimen/keyboard_top_padding"
android:paddingBottom="@dimen/keyboard_bottom_padding"
android:background="@drawable/keyboard_background_holo"
android:textStyle="bold"
latin:keyBackground="@drawable/btn_keyboard_key_honeycomb"
latin:keyPreviewLayout="@layout/key_preview_honeycomb"
latin:popupLayout="@layout/keyboard_popup_honeycomb"
latin:keyTextStyle="bold"
latin:keyTextColorDisabled="#FF353535"
latin:keyLetterStyle="bold"
latin:shadowColor="#00000000"
latin:shadowRadius="0.0"
/>

View File

@ -26,12 +26,11 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/keyboard_background"
android:textStyle="bold"
latin:keyBackground="@drawable/btn_keyboard_key_stone"
latin:keyTextColor="@color/latinkeyboard_key_color_black"
latin:shadowColor="@color/latinkeyboard_key_color_white"
latin:keyTextStyle="bold"
latin:keyLetterStyle="bold"
latin:colorScheme="black"
latin:popupLayout="@layout/input_stone_popup"
/>

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2010, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<resources>
<dimen name="key_label_text_size">18dip</dimen>
<!-- left or right padding of label alignment -->
<dimen name="key_label_horizontal_alignment_padding">18dip</dimen>
</resources>

View File

@ -23,7 +23,7 @@
<dimen name="key_height">13.0mm</dimen>
<dimen name="key_bottom_gap">1.5mm</dimen>
<dimen name="key_horizontal_gap">2.0mm</dimen>
<dimen name="popup_key_height">15.0mm</dimen>
<dimen name="popup_key_height">13.0mm</dimen>
<dimen name="keyboard_top_padding">1.0mm</dimen>
<dimen name="keyboard_bottom_padding">1.0mm</dimen>
<!-- key_height x 1.0 -->
@ -34,11 +34,11 @@
<!-- popup_key_height x -1.0 -->
<dimen name="mini_keyboard_vertical_correction">-13.0mm</dimen>
<dimen name="key_text_size">24dip</dimen>
<dimen name="key_label_text_size">18dip</dimen>
<dimen name="key_letter_size">24dip</dimen>
<dimen name="key_label_text_size">14dip</dimen>
<dimen name="key_preview_text_size_large">24dip</dimen>
<!-- left or right padding for of label alignment -->
<dimen name="key_label_horizontal_alignment_padding">18dip</dimen>
<!-- left or right padding of label alignment -->
<dimen name="key_label_horizontal_alignment_padding">4dip</dimen>
<dimen name="candidate_strip_height">46dip</dimen>
</resources>

View File

@ -25,8 +25,8 @@
checkable+checked+pressed. -->
<attr name="keyBackground" format="reference" />
<!-- Size of the text for character keys. -->
<attr name="keyTextSize" format="dimension" />
<!-- Size of the text for one letter character keys. -->
<attr name="keyLetterSize" format="dimension" />
<!-- Size of the text for custom keys with some text and no icon. -->
<attr name="labelTextSize" format="dimension" />
@ -34,6 +34,9 @@
<!-- Color to use for the label in a key. -->
<attr name="keyTextColor" format="color" />
<!-- Color to use for the label in a key when in disabled state. -->
<attr name="keyTextColorDisabled" format="color" />
<!-- Layout resource for key press feedback.-->
<attr name="keyPreviewLayout" format="reference" />
@ -56,10 +59,12 @@
<attr name="shadowRadius" format="float" />
<attr name="backgroundDimAmount" format="float" />
<attr name="keyTextStyle">
<attr name="keyLetterStyle">
<!-- This should be aligned with Typeface.NORMAL etc. -->
<enum name="normal" value="0" />
<enum name="bold" value="1" />
<enum name="italic" value="2" />
<enum name="boldItalic" value="3" />
</attr>
<attr name="colorScheme">

View File

@ -34,10 +34,10 @@
<!-- popup_key_height x -1.0 -->
<dimen name="mini_keyboard_vertical_correction">-0.325in</dimen>
<dimen name="key_text_size">0.13in</dimen>
<dimen name="key_letter_size">0.13in</dimen>
<dimen name="key_label_text_size">0.083in</dimen>
<dimen name="key_preview_text_size_large">40sp</dimen>
<!-- left or right padding for of label alignment -->
<!-- left or right padding of label alignment -->
<dimen name="key_label_horizontal_alignment_padding">0.13in</dimen>
<dimen name="key_preview_offset">0.000in</dimen>
<!-- We use "inch", not "dip" because this value tries dealing with physical distance related

View File

@ -19,8 +19,10 @@
<item name="android:background">@drawable/keyboard_background</item>
<item name="keyBackground">@drawable/btn_keyboard_key</item>
<item name="keyTextSize">@dimen/key_text_size</item>
<item name="keyLetterSize">@dimen/key_letter_size</item>
<item name="keyLetterStyle">normal</item>
<item name="keyTextColor">#FFFFFFFF</item>
<item name="keyTextColorDisabled">#FFFFFFFF</item>
<item name="keyPreviewLayout">@layout/key_preview</item>
<item name="keyPreviewOffset">@dimen/key_preview_offset</item>
<item name="keyPreviewHeight">@dimen/key_preview_height</item>

View File

@ -19,9 +19,9 @@
-->
<Keyboard xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyWidth="5.0%p"
latin:horizontalGap="@dimen/key_horizontal_gap"
latin:keyWidth="3.5%p"
latin:horizontalGap="0px"
latin:verticalGap="0px"
latin:keyHeight="@dimen/key_height"
latin:keyHeight="@dimen/popup_key_height"
>
</Keyboard>

View File

@ -20,7 +20,7 @@
<Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyWidth="5.0%p"
latin:keyWidth="4.0%p"
latin:horizontalGap="0px"
latin:verticalGap="0px"
latin:keyHeight="@dimen/popup_key_height"

View File

@ -20,7 +20,7 @@
<Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyWidth="5.0%p"
latin:keyWidth="4.0%p"
latin:horizontalGap="0px"
latin:verticalGap="0px"
latin:keyHeight="@dimen/popup_key_height"

View File

@ -65,7 +65,6 @@
<Row>
<Key
latin:keyStyle="moreKeyStyle"
latin:keyLabelOption="alignLeft"
latin:keyEdgeFlags="left" />
<!-- To match one character label size with "More", I placed spaces around the char ','
and '.'. -->

View File

@ -69,7 +69,6 @@
<Row>
<Key
latin:keyStyle="moreKeyStyle"
latin:keyLabelOption="alignLeft"
latin:keyEdgeFlags="left" />
<Spacer
latin:horizontalGap="4.458%p" />

View File

@ -19,9 +19,9 @@
-->
<Keyboard xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyWidth="7.5%p"
latin:horizontalGap="@dimen/key_horizontal_gap"
latin:keyWidth="5.0%p"
latin:horizontalGap="0px"
latin:verticalGap="0px"
latin:keyHeight="@dimen/key_height"
latin:keyHeight="@dimen/popup_key_height"
>
</Keyboard>

View File

@ -124,7 +124,6 @@
>
<Key
latin:keyStyle="moreKeyStyle"
latin:keyLabelOption="alignLeft"
latin:keyWidth="15.192%p"
latin:keyEdgeFlags="left" />
<Key
@ -155,7 +154,6 @@
latin:popupCharacters="¿" />
<Key
latin:keyStyle="moreKeyStyle"
latin:keyLabelOption="alignRight"
latin:keyWidth="12.530%p"
latin:keyEdgeFlags="right" />
</Row>

View File

@ -104,7 +104,6 @@
>
<Key
latin:keyStyle="moreKeyStyle"
latin:keyLabelOption="alignLeft"
latin:keyWidth="15.192%p"
latin:keyEdgeFlags="left" />
<Key
@ -131,7 +130,6 @@
latin:keyLabel="¿" />
<Key
latin:keyStyle="moreKeyStyle"
latin:keyLabelOption="alignRight"
latin:keyWidth="12.530%p"
latin:keyEdgeFlags="right" />
</Row>

View File

@ -20,7 +20,7 @@
<Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyWidth="15%p"
latin:keyWidth="5.5%p"
latin:horizontalGap="0px"
latin:verticalGap="0px"
latin:keyHeight="@dimen/popup_key_height"

View File

@ -20,7 +20,7 @@
<Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyWidth="7.5%p"
latin:keyWidth="5.0%p"
latin:horizontalGap="0px"
latin:verticalGap="0px"
latin:keyHeight="@dimen/popup_key_height"

View File

@ -537,7 +537,8 @@ public class BaseKeyboard {
column = 0;
}
final Key key = new Key(row);
key.x = x;
// Horizontal gap is divided equally to both sides of the key.
key.x = x + key.gap / 2;
key.y = y;
key.label = String.valueOf(c);
key.codes = new int[] { c };

View File

@ -170,9 +170,10 @@ public class BaseKeyboardView extends View implements PointerTracker.UIProxy {
private static final int HINT_ICON_VERTICAL_ADJUSTMENT_PIXEL = -1;
// XML attribute
private int mKeyTextSize;
private int mKeyLetterSize;
private int mKeyTextColor;
private Typeface mKeyTextStyle = Typeface.DEFAULT;
private int mKeyTextColorDisabled;
private Typeface mKeyLetterStyle = Typeface.DEFAULT;
private int mLabelTextSize;
private int mColorScheme = COLOR_SCHEME_WHITE;
private int mShadowColor;
@ -455,12 +456,15 @@ public class BaseKeyboardView extends View implements PointerTracker.UIProxy {
case R.styleable.BaseKeyboardView_keyPreviewHeight:
mPreviewHeight = a.getDimensionPixelSize(attr, 80);
break;
case R.styleable.BaseKeyboardView_keyTextSize:
mKeyTextSize = a.getDimensionPixelSize(attr, 18);
case R.styleable.BaseKeyboardView_keyLetterSize:
mKeyLetterSize = a.getDimensionPixelSize(attr, 18);
break;
case R.styleable.BaseKeyboardView_keyTextColor:
mKeyTextColor = a.getColor(attr, 0xFF000000);
break;
case R.styleable.BaseKeyboardView_keyTextColorDisabled:
mKeyTextColorDisabled = a.getColor(attr, 0xFF000000);
break;
case R.styleable.BaseKeyboardView_labelTextSize:
mLabelTextSize = a.getDimensionPixelSize(attr, 14);
break;
@ -477,20 +481,8 @@ public class BaseKeyboardView extends View implements PointerTracker.UIProxy {
case R.styleable.BaseKeyboardView_backgroundDimAmount:
mBackgroundDimAmount = a.getFloat(attr, 0.5f);
break;
//case android.R.styleable.
case R.styleable.BaseKeyboardView_keyTextStyle:
int textStyle = a.getInt(attr, 0);
switch (textStyle) {
case 0:
mKeyTextStyle = Typeface.DEFAULT;
break;
case 1:
mKeyTextStyle = Typeface.DEFAULT_BOLD;
break;
default:
mKeyTextStyle = Typeface.defaultFromStyle(textStyle);
break;
}
case R.styleable.BaseKeyboardView_keyLetterStyle:
mKeyLetterStyle = Typeface.defaultFromStyle(a.getInt(attr, Typeface.NORMAL));
break;
case R.styleable.BaseKeyboardView_colorScheme:
mColorScheme = a.getInt(attr, COLOR_SCHEME_WHITE);
@ -787,7 +779,6 @@ public class BaseKeyboardView extends View implements PointerTracker.UIProxy {
final boolean isManualTemporaryUpperCase = (mKeyboard instanceof LatinKeyboard
&& ((LatinKeyboard)mKeyboard).isManualTemporaryUpperCase());
paint.setColor(mKeyTextColor);
boolean drawSingleKey = false;
if (invalidKey != null && canvas.getClipBounds(clipRegion)) {
// TODO we should use Rect.inset and Rect.contains here.
@ -820,7 +811,6 @@ public class BaseKeyboardView extends View implements PointerTracker.UIProxy {
keyBackground.draw(canvas);
final int rowHeight = padding.top + key.height;
boolean drawHintIcon = true;
// Draw key label
if (label != null) {
// For characters, use large font. For labels like "Done", use small font.
@ -858,6 +848,11 @@ public class BaseKeyboardView extends View implements PointerTracker.UIProxy {
if (DEBUG_SHOW_ALIGN && label.length() > 1)
drawVerticalLine(canvas, positionX, rowHeight, 0xc0008080, new Paint());
}
if (key.manualTemporaryUpperCaseHintIcon != null && isManualTemporaryUpperCase) {
paint.setColor(mKeyTextColorDisabled);
} else {
paint.setColor(mKeyTextColor);
}
// Set a drop shadow for the text
paint.setShadowLayer(mShadowRadius, 0, 0, mShadowColor);
canvas.drawText(label, positionX, baseline, paint);
@ -892,7 +887,7 @@ public class BaseKeyboardView extends View implements PointerTracker.UIProxy {
drawRectangle(canvas, drawableX, drawableY, drawableWidth, drawableHeight,
0x80c00000, new Paint());
}
if (key.hintIcon != null && drawHintIcon) {
if (key.hintIcon != null) {
final int drawableWidth = key.width;
final int drawableHeight = key.height;
final int drawableX = 0;
@ -954,18 +949,20 @@ public class BaseKeyboardView extends View implements PointerTracker.UIProxy {
private int getLabelSizeAndSetPaint(CharSequence label, Key key, Paint paint) {
// For characters, use large font. For labels like "Done", use small font.
final int labelSize;
final Typeface labelStyle;
if (label.length() > 1 && key.codes.length < 2) {
labelSize = mLabelTextSize;
if ((key.labelOption & KEY_LABEL_OPTION_FONT_NORMAL) != 0) {
paint.setTypeface(Typeface.DEFAULT);
labelStyle = Typeface.DEFAULT;
} else {
paint.setTypeface(Typeface.DEFAULT_BOLD);
labelStyle = Typeface.DEFAULT_BOLD;
}
} else {
labelSize = mKeyTextSize;
paint.setTypeface(mKeyTextStyle);
labelSize = mKeyLetterSize;
labelStyle = mKeyLetterStyle;
}
paint.setTextSize(labelSize);
paint.setTypeface(labelStyle);
return labelSize;
}
@ -1061,11 +1058,11 @@ public class BaseKeyboardView extends View implements PointerTracker.UIProxy {
mPreviewText.setCompoundDrawables(null, null, null, null);
mPreviewText.setText(adjustCase(tracker.getPreviewText(key)));
if (key.label.length() > 1 && key.codes.length < 2) {
mPreviewText.setTextSize(TypedValue.COMPLEX_UNIT_PX, mKeyTextSize);
mPreviewText.setTextSize(TypedValue.COMPLEX_UNIT_PX, mKeyLetterSize);
mPreviewText.setTypeface(Typeface.DEFAULT_BOLD);
} else {
mPreviewText.setTextSize(TypedValue.COMPLEX_UNIT_PX, mPreviewTextSizeLarge);
mPreviewText.setTypeface(mKeyTextStyle);
mPreviewText.setTypeface(mKeyLetterStyle);
}
} else {
mPreviewText.setCompoundDrawables(null, null, null,