Loading java/res/values/attrs.xml +13 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,8 @@ <declare-styleable name="KeyboardTheme"> <!-- Keyboard style --> <attr name="keyboardStyle" format="reference" /> <!-- LatinKeyboard style --> <attr name="latinKeyboardStyle" format="reference" /> <!-- KeyboardView style --> <attr name="keyboardViewStyle" format="reference" /> <attr name="keyPreviewStyle" format="reference" /> Loading Loading @@ -94,7 +96,6 @@ <flag name="autoCorrectBold" value="0x01" /> <flag name="autoCorrectUnderline" value="0x02" /> <flag name="autoCorrectInvert" value="0x04" /> <flag name="autoCorrectSpacebarLed" value="0x08" /> </attr> <attr name="colorTypedWord" format="color" /> <attr name="colorAutoCorrect" format="color" /> Loading Loading @@ -243,4 +244,15 @@ <attr name="styleName" format="string" /> <attr name="parentStyle" format="string" /> </declare-styleable> <declare-styleable name="LatinKeyboard"> <attr name="autoCorrectionSpacebarLedIcon" format="reference" /> <attr name="disabledShortcutIcon" format="reference" /> <attr name="spacebarTextColor" format="color" /> <attr name="spacebarTextShadowColor" format="color" /> <attr name="spacebarArrowLeftIcon" format="reference" /> <attr name="spacebarArrowRightIcon" format="reference" /> <attr name="spacebarArrowPreviewLeftIcon" format="reference" /> <attr name="spacebarArrowPreviewRightIcon" format="reference" /> </declare-styleable> </resources> java/res/values/styles.xml +20 −3 Original line number Diff line number Diff line Loading @@ -19,6 +19,16 @@ <style name="Keyboard"> <item name="popupHintIcon">@drawable/hint_popup</item> </style> <style name="LatinKeyboard"> <item name="autoCorrectionSpacebarLedIcon">@drawable/sym_keyboard_space_led</item> <item name="disabledShortcutIcon">@drawable/sym_keyboard_voice_off_holo</item> <item name="spacebarTextColor">@color/latinkeyboard_bar_language_text</item> <item name="spacebarTextShadowColor">@color/latinkeyboard_bar_language_shadow_white</item> <item name="spacebarArrowLeftIcon">@drawable/sym_keyboard_language_arrows_left</item> <item name="spacebarArrowRightIcon">@drawable/sym_keyboard_language_arrows_right</item> <item name="spacebarArrowPreviewLeftIcon">@drawable/sym_keyboard_feedback_language_arrows_left</item> <item name="spacebarArrowPreviewRightIcon">@drawable/sym_keyboard_feedback_language_arrows_right</item> </style> <style name="KeyboardView"> <item name="android:background">@drawable/keyboard_background</item> <item name="keyBackground">@drawable/btn_keyboard_key</item> Loading Loading @@ -61,8 +71,6 @@ <item name="android:background">@drawable/candidate_feedback_background</item> </style> <style name="CandidateViewStyle" parent="SuggestionsStripBackgroundStyle"> <!-- TODO: autoCorrectSpacebarLed should be in style for LatinKeyboard. --> <item name="autoCorrectHighlight">autoCorrectBold|autoCorrectSpacebarLed</item> <item name="colorTypedWord">#FFFFFFFF</item> <item name="colorAutoCorrect">#FFFCAE00</item> <item name="colorSuggested">#FFFCAE00</item> Loading @@ -75,6 +83,11 @@ <item name="keyBackground">@drawable/btn_keyboard_key3</item> </style> <!-- Theme "Stone" --> <style name="LatinKeyboard.Stone" patent="LatinKeyboard"> <item name="spacebarTextColor">#FF444444</item> <item name="spacebarTextShadowColor">@color/latinkeyboard_bar_language_shadow_black</item> <item name="disabledShortcutIcon">@drawable/sym_bkeyboard_voice_off</item> </style> <style name="KeyboardView.Stone" parent="KeyboardView"> <item name="keyBackground">@drawable/btn_keyboard_key_stone</item> <item name="keyTextColor">@color/latinkeyboard_key_color_black</item> Loading Loading @@ -104,6 +117,10 @@ <style name="Keyboard.Honeycomb" parent="Keyboard" > <item name="popupHintIcon">@drawable/hint_popup_holo</item> </style> <style name="LatinKeyboard.Honeycomb" parent="LatinKeyboard"> <item name="autoCorrectionSpacebarLedIcon">@null</item> <item name="disabledShortcutIcon">@drawable/sym_keyboard_voice_off_holo</item> </style> <style name="KeyboardView.Honeycomb" parent="KeyboardView"> <item name="android:background">@drawable/keyboard_background_holo</item> <item name="keyBackground">@drawable/btn_keyboard_key_honeycomb</item> Loading java/res/values/themes.xml +6 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ <resources> <style name="KeyboardTheme" parent="android:Theme"> <item name="keyboardStyle">@style/Keyboard</item> <item name="latinKeyboardStyle">@style/LatinKeyboard</item> <item name="keyboardViewStyle">@style/KeyboardView</item> <item name="keyPreviewStyle">@style/KeyPreviewStyle</item> <item name="popupMiniKeyboardViewStyle">@style/PopupMiniKeyboardView</item> Loading @@ -28,6 +29,7 @@ </style> <style name="KeyboardTheme.HighContrast" parent="android:Theme"> <item name="keyboardStyle">@style/Keyboard</item> <item name="latinKeyboardStyle">@style/LatinKeyboard</item> <item name="keyboardViewStyle">@style/KeyboardView.HighContrast</item> <item name="keyPreviewStyle">@style/KeyPreviewStyle</item> <item name="popupMiniKeyboardViewStyle">@style/PopupMiniKeyboardView</item> Loading @@ -38,6 +40,7 @@ </style> <style name="KeyboardTheme.Stone" parent="android:Theme.Light"> <item name="keyboardStyle">@style/Keyboard</item> <item name="latinKeyboardStyle">@style/LatinKeyboard.Stone</item> <item name="keyboardViewStyle">@style/KeyboardView.Stone</item> <item name="keyPreviewStyle">@style/KeyPreviewStyle</item> <item name="popupMiniKeyboardViewStyle">@style/PopupMiniKeyboardView.Stone</item> Loading @@ -48,6 +51,7 @@ </style> <style name="KeyboardTheme.Stone.Bold" parent="android:Theme.Light"> <item name="keyboardStyle">@style/Keyboard</item> <item name="latinKeyboardStyle">@style/LatinKeyboard.Stone</item> <item name="keyboardViewStyle">@style/KeyboardView.Stone.Bold</item> <item name="keyPreviewStyle">@style/KeyPreviewStyle</item> <item name="popupMiniKeyboardViewStyle">@style/PopupMiniKeyboardView.Stone</item> Loading @@ -58,6 +62,7 @@ </style> <style name="KeyboardTheme.Gingerbread" parent="android:Theme.Black"> <item name="keyboardStyle">@style/Keyboard</item> <item name="latinKeyboardStyle">@style/LatinKeyboard</item> <item name="keyboardViewStyle">@style/KeyboardView.Gingerbread</item> <item name="keyPreviewStyle">@style/KeyPreviewStyle</item> <item name="popupMiniKeyboardViewStyle">@style/PopupMiniKeyboardView.Gingerbread</item> Loading @@ -68,6 +73,7 @@ </style> <style name="KeyboardTheme.Honeycomb" parent="android:Theme.Holo"> <item name="keyboardStyle">@style/Keyboard.Honeycomb</item> <item name="latinKeyboardStyle">@style/LatinKeyboard.Honeycomb</item> <item name="keyboardViewStyle">@style/KeyboardView.Honeycomb</item> <item name="keyPreviewStyle">@style/KeyPreviewStyle.Honeycomb</item> <item name="popupMiniKeyboardViewStyle">@style/PopupMiniKeyboardView.Honeycomb</item> Loading java/src/com/android/inputmethod/keyboard/LatinKeyboard.java +29 −25 Original line number Diff line number Diff line Loading @@ -57,9 +57,9 @@ public class LatinKeyboard extends Keyboard { private final Drawable mSpaceIcon; private final Drawable mSpacePreviewIcon; private final int mSpaceKeyIndex; private final Drawable mSpaceAutoCorrectionIndicator; private final Drawable mButtonArrowLeftIcon; private final Drawable mButtonArrowRightIcon; private final Drawable mAutoCorrectionSpacebarLedIcon; private final Drawable mSpacebarArrowLeftIcon; private final Drawable mSpacebarArrowRightIcon; private final int mSpacebarTextColor; private final int mSpacebarTextShadowColor; private float mSpacebarTextFadeFactor = 0.0f; Loading Loading @@ -90,7 +90,6 @@ public class LatinKeyboard extends Keyboard { public LatinKeyboard(Context context, KeyboardId id, int width) { super(context, id.getXmlId(), id, width); final Resources res = context.getResources(); mContext = context; final List<Key> keys = getKeys(); Loading Loading @@ -118,19 +117,20 @@ public class LatinKeyboard extends Keyboard { mShortcutKey = (shortcutKeyIndex >= 0) ? keys.get(shortcutKeyIndex) : null; mEnabledShortcutIcon = (mShortcutKey != null) ? mShortcutKey.getIcon() : null; mSpacebarTextColor = res.getColor(R.color.latinkeyboard_bar_language_text); if (id.mColorScheme == KeyboardView.COLOR_SCHEME_BLACK) { mSpacebarTextShadowColor = res.getColor( R.color.latinkeyboard_bar_language_shadow_black); mDisabledShortcutIcon = res.getDrawable(R.drawable.sym_bkeyboard_voice_off); } else { // default color scheme is KeyboardView.COLOR_SCHEME_WHITE mSpacebarTextShadowColor = res.getColor( R.color.latinkeyboard_bar_language_shadow_white); mDisabledShortcutIcon = res.getDrawable(R.drawable.sym_keyboard_voice_off_holo); } mSpaceAutoCorrectionIndicator = res.getDrawable(R.drawable.sym_keyboard_space_led); mButtonArrowLeftIcon = res.getDrawable(R.drawable.sym_keyboard_language_arrows_left); mButtonArrowRightIcon = res.getDrawable(R.drawable.sym_keyboard_language_arrows_right); final TypedArray a = context.obtainStyledAttributes( null, R.styleable.LatinKeyboard, R.attr.latinKeyboardStyle, R.style.LatinKeyboard); mAutoCorrectionSpacebarLedIcon = a.getDrawable( R.styleable.LatinKeyboard_autoCorrectionSpacebarLedIcon); mDisabledShortcutIcon = a.getDrawable(R.styleable.LatinKeyboard_disabledShortcutIcon); mSpacebarTextColor = a.getColor(R.styleable.LatinKeyboard_spacebarTextColor, 0); mSpacebarTextShadowColor = a.getColor( R.styleable.LatinKeyboard_spacebarTextShadowColor, 0); mSpacebarArrowLeftIcon = a.getDrawable( R.styleable.LatinKeyboard_spacebarArrowLeftIcon); mSpacebarArrowRightIcon = a.getDrawable( R.styleable.LatinKeyboard_spacebarArrowRightIcon); a.recycle(); // The threshold is "key width" x 1.25 mSpacebarLanguageSwitchThreshold = (getMostCommonKeyWidth() * 5) / 4; } Loading Loading @@ -163,6 +163,10 @@ public class LatinKeyboard extends Keyboard { view.invalidateKey(mShortcutKey); } public boolean needsAutoCorrectionSpacebarLed() { return mAutoCorrectionSpacebarLedIcon != null; } /** * @return a key which should be invalidated. */ Loading Loading @@ -282,7 +286,7 @@ public class LatinKeyboard extends Keyboard { } final String language = layoutSpacebar(paint, inputLocale, mButtonArrowLeftIcon, mButtonArrowRightIcon, width, height, mSpacebarArrowLeftIcon, mSpacebarArrowRightIcon, width, height, getTextSizeFromTheme(mContext.getTheme(), textStyle, defaultTextSize)); // Draw language text with shadow Loading @@ -303,21 +307,21 @@ public class LatinKeyboard extends Keyboard { if (mSubtypeSwitcher.useSpacebarLanguageSwitcher() && mSubtypeSwitcher.getEnabledKeyboardLocaleCount() > 1 && !(isPhoneKeyboard() || isNumberKeyboard())) { mButtonArrowLeftIcon.setColorFilter(getSpacebarDrawableFilter(textFadeFactor)); mButtonArrowRightIcon.setColorFilter(getSpacebarDrawableFilter(textFadeFactor)); mButtonArrowLeftIcon.draw(canvas); mButtonArrowRightIcon.draw(canvas); mSpacebarArrowLeftIcon.setColorFilter(getSpacebarDrawableFilter(textFadeFactor)); mSpacebarArrowRightIcon.setColorFilter(getSpacebarDrawableFilter(textFadeFactor)); mSpacebarArrowLeftIcon.draw(canvas); mSpacebarArrowRightIcon.draw(canvas); } } // Draw the spacebar icon at the bottom if (isAutoCorrection) { final int iconWidth = width * SPACE_LED_LENGTH_PERCENT / 100; final int iconHeight = mSpaceAutoCorrectionIndicator.getIntrinsicHeight(); final int iconHeight = mAutoCorrectionSpacebarLedIcon.getIntrinsicHeight(); int x = (width - iconWidth) / 2; int y = height - iconHeight; mSpaceAutoCorrectionIndicator.setBounds(x, y, x + iconWidth, y + iconHeight); mSpaceAutoCorrectionIndicator.draw(canvas); mAutoCorrectionSpacebarLedIcon.setBounds(x, y, x + iconWidth, y + iconHeight); mAutoCorrectionSpacebarLedIcon.draw(canvas); } else if (mSpaceIcon != null) { final int iconWidth = mSpaceIcon.getIntrinsicWidth(); final int iconHeight = mSpaceIcon.getIntrinsicHeight(); Loading java/src/com/android/inputmethod/keyboard/SlidingLocaleDrawable.java +20 −19 Original line number Diff line number Diff line Loading @@ -16,22 +16,21 @@ package com.android.inputmethod.keyboard; import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.SubtypeSwitcher; import android.content.Context; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.ColorFilter; import android.graphics.Paint; import android.graphics.PixelFormat; import android.graphics.Paint.Align; import android.graphics.PixelFormat; import android.graphics.drawable.Drawable; import android.text.TextPaint; import android.view.ViewConfiguration; import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.SubtypeSwitcher; /** * Animation to be displayed on the spacebar preview popup when switching languages by swiping the * spacebar. It draws the current, previous and next languages and moves them by the delta of touch Loading @@ -39,16 +38,16 @@ import android.view.ViewConfiguration; */ public class SlidingLocaleDrawable extends Drawable { private static final int SLIDE_SPEED_MULTIPLIER_RATIO = 150; private final Context mContext; private final Resources mRes; private final int mWidth; private final int mHeight; private final Drawable mBackground; private final int mSpacebarTextColor; private final TextPaint mTextPaint; private final int mMiddleX; private final Drawable mLeftDrawable; private final Drawable mRightDrawable; private final int mThreshold; private int mDiff; private boolean mHitThreshold; private String mCurrentLanguage; Loading @@ -56,29 +55,31 @@ public class SlidingLocaleDrawable extends Drawable { private String mPrevLanguage; public SlidingLocaleDrawable(Context context, Drawable background, int width, int height) { mContext = context; mRes = context.getResources(); mBackground = background; Keyboard.setDefaultBounds(mBackground); mWidth = width; mHeight = height; final TextPaint textPaint = new TextPaint(); textPaint.setTextSize(getTextSizeFromTheme(android.R.style.TextAppearance_Medium, 18)); textPaint.setTextSize(getTextSizeFromTheme( context, android.R.style.TextAppearance_Medium, 18)); textPaint.setColor(Color.TRANSPARENT); textPaint.setTextAlign(Align.CENTER); textPaint.setAntiAlias(true); mTextPaint = textPaint; mMiddleX = (mWidth - mBackground.getIntrinsicWidth()) / 2; final Resources res = mRes; mLeftDrawable = res.getDrawable( R.drawable.sym_keyboard_feedback_language_arrows_left); mRightDrawable = res.getDrawable( R.drawable.sym_keyboard_feedback_language_arrows_right); mThreshold = ViewConfiguration.get(mContext).getScaledTouchSlop(); final TypedArray a = context.obtainStyledAttributes( null, R.styleable.LatinKeyboard, R.attr.latinKeyboardStyle, R.style.LatinKeyboard); mSpacebarTextColor = a.getColor(R.styleable.LatinKeyboard_spacebarTextColor, 0); mLeftDrawable = a.getDrawable(R.styleable.LatinKeyboard_spacebarArrowPreviewLeftIcon); mRightDrawable = a.getDrawable(R.styleable.LatinKeyboard_spacebarArrowPreviewRightIcon); a.recycle(); mThreshold = ViewConfiguration.get(context).getScaledTouchSlop(); } private int getTextSizeFromTheme(int style, int defValue) { TypedArray array = mContext.getTheme().obtainStyledAttributes( private static int getTextSizeFromTheme(Context context, int style, int defValue) { TypedArray array = context.getTheme().obtainStyledAttributes( style, new int[] { android.R.attr.textSize }); int textSize = array.getDimensionPixelSize(array.getResourceId(0, 0), defValue); return textSize; Loading Loading @@ -118,7 +119,7 @@ public class SlidingLocaleDrawable extends Drawable { // Draw language text with shadow final float baseline = mHeight * LatinKeyboard.SPACEBAR_LANGUAGE_BASELINE - paint.descent(); paint.setColor(mRes.getColor(R.color.latinkeyboard_feedback_language_text)); paint.setColor(mSpacebarTextColor); canvas.drawText(mCurrentLanguage, width / 2 + diff, baseline, paint); canvas.drawText(mNextLanguage, diff - width / 2, baseline, paint); canvas.drawText(mPrevLanguage, diff + width + width / 2, baseline, paint); Loading Loading
java/res/values/attrs.xml +13 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,8 @@ <declare-styleable name="KeyboardTheme"> <!-- Keyboard style --> <attr name="keyboardStyle" format="reference" /> <!-- LatinKeyboard style --> <attr name="latinKeyboardStyle" format="reference" /> <!-- KeyboardView style --> <attr name="keyboardViewStyle" format="reference" /> <attr name="keyPreviewStyle" format="reference" /> Loading Loading @@ -94,7 +96,6 @@ <flag name="autoCorrectBold" value="0x01" /> <flag name="autoCorrectUnderline" value="0x02" /> <flag name="autoCorrectInvert" value="0x04" /> <flag name="autoCorrectSpacebarLed" value="0x08" /> </attr> <attr name="colorTypedWord" format="color" /> <attr name="colorAutoCorrect" format="color" /> Loading Loading @@ -243,4 +244,15 @@ <attr name="styleName" format="string" /> <attr name="parentStyle" format="string" /> </declare-styleable> <declare-styleable name="LatinKeyboard"> <attr name="autoCorrectionSpacebarLedIcon" format="reference" /> <attr name="disabledShortcutIcon" format="reference" /> <attr name="spacebarTextColor" format="color" /> <attr name="spacebarTextShadowColor" format="color" /> <attr name="spacebarArrowLeftIcon" format="reference" /> <attr name="spacebarArrowRightIcon" format="reference" /> <attr name="spacebarArrowPreviewLeftIcon" format="reference" /> <attr name="spacebarArrowPreviewRightIcon" format="reference" /> </declare-styleable> </resources>
java/res/values/styles.xml +20 −3 Original line number Diff line number Diff line Loading @@ -19,6 +19,16 @@ <style name="Keyboard"> <item name="popupHintIcon">@drawable/hint_popup</item> </style> <style name="LatinKeyboard"> <item name="autoCorrectionSpacebarLedIcon">@drawable/sym_keyboard_space_led</item> <item name="disabledShortcutIcon">@drawable/sym_keyboard_voice_off_holo</item> <item name="spacebarTextColor">@color/latinkeyboard_bar_language_text</item> <item name="spacebarTextShadowColor">@color/latinkeyboard_bar_language_shadow_white</item> <item name="spacebarArrowLeftIcon">@drawable/sym_keyboard_language_arrows_left</item> <item name="spacebarArrowRightIcon">@drawable/sym_keyboard_language_arrows_right</item> <item name="spacebarArrowPreviewLeftIcon">@drawable/sym_keyboard_feedback_language_arrows_left</item> <item name="spacebarArrowPreviewRightIcon">@drawable/sym_keyboard_feedback_language_arrows_right</item> </style> <style name="KeyboardView"> <item name="android:background">@drawable/keyboard_background</item> <item name="keyBackground">@drawable/btn_keyboard_key</item> Loading Loading @@ -61,8 +71,6 @@ <item name="android:background">@drawable/candidate_feedback_background</item> </style> <style name="CandidateViewStyle" parent="SuggestionsStripBackgroundStyle"> <!-- TODO: autoCorrectSpacebarLed should be in style for LatinKeyboard. --> <item name="autoCorrectHighlight">autoCorrectBold|autoCorrectSpacebarLed</item> <item name="colorTypedWord">#FFFFFFFF</item> <item name="colorAutoCorrect">#FFFCAE00</item> <item name="colorSuggested">#FFFCAE00</item> Loading @@ -75,6 +83,11 @@ <item name="keyBackground">@drawable/btn_keyboard_key3</item> </style> <!-- Theme "Stone" --> <style name="LatinKeyboard.Stone" patent="LatinKeyboard"> <item name="spacebarTextColor">#FF444444</item> <item name="spacebarTextShadowColor">@color/latinkeyboard_bar_language_shadow_black</item> <item name="disabledShortcutIcon">@drawable/sym_bkeyboard_voice_off</item> </style> <style name="KeyboardView.Stone" parent="KeyboardView"> <item name="keyBackground">@drawable/btn_keyboard_key_stone</item> <item name="keyTextColor">@color/latinkeyboard_key_color_black</item> Loading Loading @@ -104,6 +117,10 @@ <style name="Keyboard.Honeycomb" parent="Keyboard" > <item name="popupHintIcon">@drawable/hint_popup_holo</item> </style> <style name="LatinKeyboard.Honeycomb" parent="LatinKeyboard"> <item name="autoCorrectionSpacebarLedIcon">@null</item> <item name="disabledShortcutIcon">@drawable/sym_keyboard_voice_off_holo</item> </style> <style name="KeyboardView.Honeycomb" parent="KeyboardView"> <item name="android:background">@drawable/keyboard_background_holo</item> <item name="keyBackground">@drawable/btn_keyboard_key_honeycomb</item> Loading
java/res/values/themes.xml +6 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ <resources> <style name="KeyboardTheme" parent="android:Theme"> <item name="keyboardStyle">@style/Keyboard</item> <item name="latinKeyboardStyle">@style/LatinKeyboard</item> <item name="keyboardViewStyle">@style/KeyboardView</item> <item name="keyPreviewStyle">@style/KeyPreviewStyle</item> <item name="popupMiniKeyboardViewStyle">@style/PopupMiniKeyboardView</item> Loading @@ -28,6 +29,7 @@ </style> <style name="KeyboardTheme.HighContrast" parent="android:Theme"> <item name="keyboardStyle">@style/Keyboard</item> <item name="latinKeyboardStyle">@style/LatinKeyboard</item> <item name="keyboardViewStyle">@style/KeyboardView.HighContrast</item> <item name="keyPreviewStyle">@style/KeyPreviewStyle</item> <item name="popupMiniKeyboardViewStyle">@style/PopupMiniKeyboardView</item> Loading @@ -38,6 +40,7 @@ </style> <style name="KeyboardTheme.Stone" parent="android:Theme.Light"> <item name="keyboardStyle">@style/Keyboard</item> <item name="latinKeyboardStyle">@style/LatinKeyboard.Stone</item> <item name="keyboardViewStyle">@style/KeyboardView.Stone</item> <item name="keyPreviewStyle">@style/KeyPreviewStyle</item> <item name="popupMiniKeyboardViewStyle">@style/PopupMiniKeyboardView.Stone</item> Loading @@ -48,6 +51,7 @@ </style> <style name="KeyboardTheme.Stone.Bold" parent="android:Theme.Light"> <item name="keyboardStyle">@style/Keyboard</item> <item name="latinKeyboardStyle">@style/LatinKeyboard.Stone</item> <item name="keyboardViewStyle">@style/KeyboardView.Stone.Bold</item> <item name="keyPreviewStyle">@style/KeyPreviewStyle</item> <item name="popupMiniKeyboardViewStyle">@style/PopupMiniKeyboardView.Stone</item> Loading @@ -58,6 +62,7 @@ </style> <style name="KeyboardTheme.Gingerbread" parent="android:Theme.Black"> <item name="keyboardStyle">@style/Keyboard</item> <item name="latinKeyboardStyle">@style/LatinKeyboard</item> <item name="keyboardViewStyle">@style/KeyboardView.Gingerbread</item> <item name="keyPreviewStyle">@style/KeyPreviewStyle</item> <item name="popupMiniKeyboardViewStyle">@style/PopupMiniKeyboardView.Gingerbread</item> Loading @@ -68,6 +73,7 @@ </style> <style name="KeyboardTheme.Honeycomb" parent="android:Theme.Holo"> <item name="keyboardStyle">@style/Keyboard.Honeycomb</item> <item name="latinKeyboardStyle">@style/LatinKeyboard.Honeycomb</item> <item name="keyboardViewStyle">@style/KeyboardView.Honeycomb</item> <item name="keyPreviewStyle">@style/KeyPreviewStyle.Honeycomb</item> <item name="popupMiniKeyboardViewStyle">@style/PopupMiniKeyboardView.Honeycomb</item> Loading
java/src/com/android/inputmethod/keyboard/LatinKeyboard.java +29 −25 Original line number Diff line number Diff line Loading @@ -57,9 +57,9 @@ public class LatinKeyboard extends Keyboard { private final Drawable mSpaceIcon; private final Drawable mSpacePreviewIcon; private final int mSpaceKeyIndex; private final Drawable mSpaceAutoCorrectionIndicator; private final Drawable mButtonArrowLeftIcon; private final Drawable mButtonArrowRightIcon; private final Drawable mAutoCorrectionSpacebarLedIcon; private final Drawable mSpacebarArrowLeftIcon; private final Drawable mSpacebarArrowRightIcon; private final int mSpacebarTextColor; private final int mSpacebarTextShadowColor; private float mSpacebarTextFadeFactor = 0.0f; Loading Loading @@ -90,7 +90,6 @@ public class LatinKeyboard extends Keyboard { public LatinKeyboard(Context context, KeyboardId id, int width) { super(context, id.getXmlId(), id, width); final Resources res = context.getResources(); mContext = context; final List<Key> keys = getKeys(); Loading Loading @@ -118,19 +117,20 @@ public class LatinKeyboard extends Keyboard { mShortcutKey = (shortcutKeyIndex >= 0) ? keys.get(shortcutKeyIndex) : null; mEnabledShortcutIcon = (mShortcutKey != null) ? mShortcutKey.getIcon() : null; mSpacebarTextColor = res.getColor(R.color.latinkeyboard_bar_language_text); if (id.mColorScheme == KeyboardView.COLOR_SCHEME_BLACK) { mSpacebarTextShadowColor = res.getColor( R.color.latinkeyboard_bar_language_shadow_black); mDisabledShortcutIcon = res.getDrawable(R.drawable.sym_bkeyboard_voice_off); } else { // default color scheme is KeyboardView.COLOR_SCHEME_WHITE mSpacebarTextShadowColor = res.getColor( R.color.latinkeyboard_bar_language_shadow_white); mDisabledShortcutIcon = res.getDrawable(R.drawable.sym_keyboard_voice_off_holo); } mSpaceAutoCorrectionIndicator = res.getDrawable(R.drawable.sym_keyboard_space_led); mButtonArrowLeftIcon = res.getDrawable(R.drawable.sym_keyboard_language_arrows_left); mButtonArrowRightIcon = res.getDrawable(R.drawable.sym_keyboard_language_arrows_right); final TypedArray a = context.obtainStyledAttributes( null, R.styleable.LatinKeyboard, R.attr.latinKeyboardStyle, R.style.LatinKeyboard); mAutoCorrectionSpacebarLedIcon = a.getDrawable( R.styleable.LatinKeyboard_autoCorrectionSpacebarLedIcon); mDisabledShortcutIcon = a.getDrawable(R.styleable.LatinKeyboard_disabledShortcutIcon); mSpacebarTextColor = a.getColor(R.styleable.LatinKeyboard_spacebarTextColor, 0); mSpacebarTextShadowColor = a.getColor( R.styleable.LatinKeyboard_spacebarTextShadowColor, 0); mSpacebarArrowLeftIcon = a.getDrawable( R.styleable.LatinKeyboard_spacebarArrowLeftIcon); mSpacebarArrowRightIcon = a.getDrawable( R.styleable.LatinKeyboard_spacebarArrowRightIcon); a.recycle(); // The threshold is "key width" x 1.25 mSpacebarLanguageSwitchThreshold = (getMostCommonKeyWidth() * 5) / 4; } Loading Loading @@ -163,6 +163,10 @@ public class LatinKeyboard extends Keyboard { view.invalidateKey(mShortcutKey); } public boolean needsAutoCorrectionSpacebarLed() { return mAutoCorrectionSpacebarLedIcon != null; } /** * @return a key which should be invalidated. */ Loading Loading @@ -282,7 +286,7 @@ public class LatinKeyboard extends Keyboard { } final String language = layoutSpacebar(paint, inputLocale, mButtonArrowLeftIcon, mButtonArrowRightIcon, width, height, mSpacebarArrowLeftIcon, mSpacebarArrowRightIcon, width, height, getTextSizeFromTheme(mContext.getTheme(), textStyle, defaultTextSize)); // Draw language text with shadow Loading @@ -303,21 +307,21 @@ public class LatinKeyboard extends Keyboard { if (mSubtypeSwitcher.useSpacebarLanguageSwitcher() && mSubtypeSwitcher.getEnabledKeyboardLocaleCount() > 1 && !(isPhoneKeyboard() || isNumberKeyboard())) { mButtonArrowLeftIcon.setColorFilter(getSpacebarDrawableFilter(textFadeFactor)); mButtonArrowRightIcon.setColorFilter(getSpacebarDrawableFilter(textFadeFactor)); mButtonArrowLeftIcon.draw(canvas); mButtonArrowRightIcon.draw(canvas); mSpacebarArrowLeftIcon.setColorFilter(getSpacebarDrawableFilter(textFadeFactor)); mSpacebarArrowRightIcon.setColorFilter(getSpacebarDrawableFilter(textFadeFactor)); mSpacebarArrowLeftIcon.draw(canvas); mSpacebarArrowRightIcon.draw(canvas); } } // Draw the spacebar icon at the bottom if (isAutoCorrection) { final int iconWidth = width * SPACE_LED_LENGTH_PERCENT / 100; final int iconHeight = mSpaceAutoCorrectionIndicator.getIntrinsicHeight(); final int iconHeight = mAutoCorrectionSpacebarLedIcon.getIntrinsicHeight(); int x = (width - iconWidth) / 2; int y = height - iconHeight; mSpaceAutoCorrectionIndicator.setBounds(x, y, x + iconWidth, y + iconHeight); mSpaceAutoCorrectionIndicator.draw(canvas); mAutoCorrectionSpacebarLedIcon.setBounds(x, y, x + iconWidth, y + iconHeight); mAutoCorrectionSpacebarLedIcon.draw(canvas); } else if (mSpaceIcon != null) { final int iconWidth = mSpaceIcon.getIntrinsicWidth(); final int iconHeight = mSpaceIcon.getIntrinsicHeight(); Loading
java/src/com/android/inputmethod/keyboard/SlidingLocaleDrawable.java +20 −19 Original line number Diff line number Diff line Loading @@ -16,22 +16,21 @@ package com.android.inputmethod.keyboard; import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.SubtypeSwitcher; import android.content.Context; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.ColorFilter; import android.graphics.Paint; import android.graphics.PixelFormat; import android.graphics.Paint.Align; import android.graphics.PixelFormat; import android.graphics.drawable.Drawable; import android.text.TextPaint; import android.view.ViewConfiguration; import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.SubtypeSwitcher; /** * Animation to be displayed on the spacebar preview popup when switching languages by swiping the * spacebar. It draws the current, previous and next languages and moves them by the delta of touch Loading @@ -39,16 +38,16 @@ import android.view.ViewConfiguration; */ public class SlidingLocaleDrawable extends Drawable { private static final int SLIDE_SPEED_MULTIPLIER_RATIO = 150; private final Context mContext; private final Resources mRes; private final int mWidth; private final int mHeight; private final Drawable mBackground; private final int mSpacebarTextColor; private final TextPaint mTextPaint; private final int mMiddleX; private final Drawable mLeftDrawable; private final Drawable mRightDrawable; private final int mThreshold; private int mDiff; private boolean mHitThreshold; private String mCurrentLanguage; Loading @@ -56,29 +55,31 @@ public class SlidingLocaleDrawable extends Drawable { private String mPrevLanguage; public SlidingLocaleDrawable(Context context, Drawable background, int width, int height) { mContext = context; mRes = context.getResources(); mBackground = background; Keyboard.setDefaultBounds(mBackground); mWidth = width; mHeight = height; final TextPaint textPaint = new TextPaint(); textPaint.setTextSize(getTextSizeFromTheme(android.R.style.TextAppearance_Medium, 18)); textPaint.setTextSize(getTextSizeFromTheme( context, android.R.style.TextAppearance_Medium, 18)); textPaint.setColor(Color.TRANSPARENT); textPaint.setTextAlign(Align.CENTER); textPaint.setAntiAlias(true); mTextPaint = textPaint; mMiddleX = (mWidth - mBackground.getIntrinsicWidth()) / 2; final Resources res = mRes; mLeftDrawable = res.getDrawable( R.drawable.sym_keyboard_feedback_language_arrows_left); mRightDrawable = res.getDrawable( R.drawable.sym_keyboard_feedback_language_arrows_right); mThreshold = ViewConfiguration.get(mContext).getScaledTouchSlop(); final TypedArray a = context.obtainStyledAttributes( null, R.styleable.LatinKeyboard, R.attr.latinKeyboardStyle, R.style.LatinKeyboard); mSpacebarTextColor = a.getColor(R.styleable.LatinKeyboard_spacebarTextColor, 0); mLeftDrawable = a.getDrawable(R.styleable.LatinKeyboard_spacebarArrowPreviewLeftIcon); mRightDrawable = a.getDrawable(R.styleable.LatinKeyboard_spacebarArrowPreviewRightIcon); a.recycle(); mThreshold = ViewConfiguration.get(context).getScaledTouchSlop(); } private int getTextSizeFromTheme(int style, int defValue) { TypedArray array = mContext.getTheme().obtainStyledAttributes( private static int getTextSizeFromTheme(Context context, int style, int defValue) { TypedArray array = context.getTheme().obtainStyledAttributes( style, new int[] { android.R.attr.textSize }); int textSize = array.getDimensionPixelSize(array.getResourceId(0, 0), defValue); return textSize; Loading Loading @@ -118,7 +119,7 @@ public class SlidingLocaleDrawable extends Drawable { // Draw language text with shadow final float baseline = mHeight * LatinKeyboard.SPACEBAR_LANGUAGE_BASELINE - paint.descent(); paint.setColor(mRes.getColor(R.color.latinkeyboard_feedback_language_text)); paint.setColor(mSpacebarTextColor); canvas.drawText(mCurrentLanguage, width / 2 + diff, baseline, paint); canvas.drawText(mNextLanguage, diff - width / 2, baseline, paint); canvas.drawText(mPrevLanguage, diff + width + width / 2, baseline, paint); Loading