From 71c695da22fd99e56ba5b267ad21b750ab1534b5 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Wed, 1 Feb 2012 19:43:58 +0900 Subject: [PATCH] Remove BIDI mirroring hack from Key This change also removes isRtlKeyboard attribute from Bug: 5948247 Change-Id: I85998f17ae146a4c8cd0f419ab820b746cb8974f --- .../values-ar/donottranslate-more-keys.xml | 43 ++++++++++++++-- java/res/values-ar/donottranslate.xml | 2 +- .../values-iw/donottranslate-more-keys.xml | 37 ++++++++++++++ java/res/values-iw/donottranslate.xml | 2 +- java/res/values/attrs.xml | 2 - java/res/values/donottranslate-more-keys.xml | 37 ++++++++++++++ java/res/xml-sw600dp/rows_azerty.xml | 5 +- java/res/xml-sw600dp/rows_symbols.xml | 24 +++------ java/res/xml-sw600dp/rows_symbols_shift.xml | 12 ++--- java/res/xml-sw768dp/rows_azerty.xml | 4 +- java/res/xml-sw768dp/rows_symbols.xml | 24 +++------ java/res/xml-sw768dp/rows_symbols_shift.xml | 12 ++--- java/res/xml/kbd_arabic.xml | 1 - java/res/xml/kbd_hebrew.xml | 1 - .../keys_curly_brackets.xml} | 15 +++--- .../keys_less_greater.xml} | 17 ++++--- .../keys_parentheses.xml} | 17 ++++--- .../keys_square_brackets.xml} | 15 +++--- java/res/xml/rows_azerty.xml | 6 ++- java/res/xml/rows_symbols.xml | 17 ++----- java/res/xml/rows_symbols_shift.xml | 22 +++----- .../com/android/inputmethod/keyboard/Key.java | 50 ++----------------- .../inputmethod/keyboard/Keyboard.java | 7 --- .../inputmethod/keyboard/MiniKeyboard.java | 1 - 24 files changed, 203 insertions(+), 170 deletions(-) rename java/res/{xml-ar/kbd_symbols.xml => xml/keys_curly_brackets.xml} (70%) rename java/res/{xml-iw/kbd_symbols.xml => xml/keys_less_greater.xml} (63%) rename java/res/{xml-iw/kbd_symbols_shift.xml => xml/keys_parentheses.xml} (62%) rename java/res/{xml-ar/kbd_symbols_shift.xml => xml/keys_square_brackets.xml} (70%) diff --git a/java/res/values-ar/donottranslate-more-keys.xml b/java/res/values-ar/donottranslate-more-keys.xml index 6a14a3c55..9a7a0267a 100644 --- a/java/res/values-ar/donottranslate-more-keys.xml +++ b/java/res/values-ar/donottranslate-more-keys.xml @@ -102,8 +102,43 @@ ★,\u066d - - [,{,<,\ufd3e - - ],},>,\ufd3f + + ) + ( + + [|],{|},<|>,\ufd3e|\ufd3f + ]|[,}|{,>|<,\ufd3f|\ufd3e + > + < + + \u2264|\u2265,\u00ab|\u00bb,\u2039|\u203a + \u2265|\u2264,\u00bb|\u00ab,\u203a|\u2039 + ] + [ + } + { + + + + \u201d,\u00ab|\u00bb,\u201c,\u00bb|\u00ab + + + + \u201d,\u00ab|\u00bb,\u201c,\u00bb|\u00ab,\u2019,\u201a,\u2018,\u201b diff --git a/java/res/values-ar/donottranslate.xml b/java/res/values-ar/donottranslate.xml index c51ac502a..a9aad4e3c 100644 --- a/java/res/values-ar/donottranslate.xml +++ b/java/res/values-ar/donottranslate.xml @@ -19,7 +19,7 @@ --> + http://www.unicode.org/Public/6.1.0/ucd/BidiMirroring.txt --> !,?,\\,,:,;,\u0022,(|),)|(,\u0027,-,/,@,_ diff --git a/java/res/values-iw/donottranslate-more-keys.xml b/java/res/values-iw/donottranslate-more-keys.xml index 829486f7b..6fc336002 100644 --- a/java/res/values-iw/donottranslate-more-keys.xml +++ b/java/res/values-iw/donottranslate-more-keys.xml @@ -20,4 +20,41 @@ ±,﬩ + + ) + ( + [|],{|},<|> + ]|[,}|{,>|< + > + < + + \u2264|\u2265,\u00ab|\u00bb,\u2039|\u203a + \u2265|\u2264,\u00bb|\u00ab,\u203a|\u2039 + ] + [ + } + { + + + + \u201d,\u00ab|\u00bb,\u201c,\u00bb|\u00ab + + + + \u201d,\u00ab|\u00bb,\u201c,\u00bb|\u00ab,\u2019,\u201a,\u2018,\u201b diff --git a/java/res/values-iw/donottranslate.xml b/java/res/values-iw/donottranslate.xml index c51ac502a..a9aad4e3c 100644 --- a/java/res/values-iw/donottranslate.xml +++ b/java/res/values-iw/donottranslate.xml @@ -19,7 +19,7 @@ --> + http://www.unicode.org/Public/6.1.0/ucd/BidiMirroring.txt --> !,?,\\,,:,;,\u0022,(|),)|(,\u0027,-,/,@,_ diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml index d859ae3ea..dd2206da8 100644 --- a/java/res/values/attrs.xml +++ b/java/res/values/attrs.xml @@ -202,8 +202,6 @@ - - diff --git a/java/res/values/donottranslate-more-keys.xml b/java/res/values/donottranslate-more-keys.xml index 07f4bf38b..07e711a02 100644 --- a/java/res/values/donottranslate-more-keys.xml +++ b/java/res/values/donottranslate-more-keys.xml @@ -112,6 +112,43 @@ ♪,♥,♠,♦,♣ †,‡,★ ± + + ( + ) [,{,< ],},> + < + > + + \u2264,\u00ab,\u2039 + \u2265,\u00bb,\u203a + [ + ] + { + } + + \u2019,\u201a,\u2018,\u201b + + + + \u201d,\u00ab,\u201c,\u00bb + + + + \u201d,\u00ab,\u201c,\u00bb,\u2019,\u201a,\u2018,\u201b diff --git a/java/res/xml-sw600dp/rows_azerty.xml b/java/res/xml-sw600dp/rows_azerty.xml index c29d291ea..aabe6b0e8 100644 --- a/java/res/xml-sw600dp/rows_azerty.xml +++ b/java/res/xml-sw600dp/rows_azerty.xml @@ -116,7 +116,10 @@ latin:keyLabel="n" latin:moreKeys="@string/more_keys_for_n" /> + latin:keyLabel="\'" + latin:keyHintLabel=":" + latin:moreKeys=":" + latin:keyStyle="hasShiftedLetterHintStyle" /> - - + - - + @@ -126,8 +118,7 @@ latin:mode="url" > + latin:keyLabel="\'" /> - - + latin:moreKeys="@string/more_keys_for_tablet_double_quote" + latin:maxMoreKeysColumn="4" /> - - + - - + + latin:moreKeys=":" + latin:keyStyle="hasShiftedLetterHintStyle" /> - - + - - + @@ -133,8 +125,7 @@ latin:mode="url" > + latin:keyLabel="\'" /> - - + latin:moreKeys="@string/more_keys_for_tablet_double_quote" + latin:maxMoreKeysColumn="4" /> diff --git a/java/res/xml-sw768dp/rows_symbols_shift.xml b/java/res/xml-sw768dp/rows_symbols_shift.xml index 80735b697..aba9c236d 100644 --- a/java/res/xml-sw768dp/rows_symbols_shift.xml +++ b/java/res/xml-sw768dp/rows_symbols_shift.xml @@ -84,10 +84,8 @@ - - + - - + diff --git a/java/res/xml/kbd_hebrew.xml b/java/res/xml/kbd_hebrew.xml index 3d574db59..74836f342 100644 --- a/java/res/xml/kbd_hebrew.xml +++ b/java/res/xml/kbd_hebrew.xml @@ -20,7 +20,6 @@ diff --git a/java/res/xml-ar/kbd_symbols.xml b/java/res/xml/keys_curly_brackets.xml similarity index 70% rename from java/res/xml-ar/kbd_symbols.xml rename to java/res/xml/keys_curly_brackets.xml index c1905b875..b43fbb1fe 100644 --- a/java/res/xml-ar/kbd_symbols.xml +++ b/java/res/xml/keys_curly_brackets.xml @@ -2,7 +2,7 @@ - - - + + + diff --git a/java/res/xml-iw/kbd_symbols.xml b/java/res/xml/keys_less_greater.xml similarity index 63% rename from java/res/xml-iw/kbd_symbols.xml rename to java/res/xml/keys_less_greater.xml index c1905b875..8e90199fe 100644 --- a/java/res/xml-iw/kbd_symbols.xml +++ b/java/res/xml/keys_less_greater.xml @@ -2,7 +2,7 @@ - - - + + + diff --git a/java/res/xml-iw/kbd_symbols_shift.xml b/java/res/xml/keys_parentheses.xml similarity index 62% rename from java/res/xml-iw/kbd_symbols_shift.xml rename to java/res/xml/keys_parentheses.xml index 820b425ea..bacb26d2f 100644 --- a/java/res/xml-iw/kbd_symbols_shift.xml +++ b/java/res/xml/keys_parentheses.xml @@ -2,7 +2,7 @@ - - - + + + diff --git a/java/res/xml-ar/kbd_symbols_shift.xml b/java/res/xml/keys_square_brackets.xml similarity index 70% rename from java/res/xml-ar/kbd_symbols_shift.xml rename to java/res/xml/keys_square_brackets.xml index 820b425ea..3525f4d5a 100644 --- a/java/res/xml-ar/kbd_symbols_shift.xml +++ b/java/res/xml/keys_square_brackets.xml @@ -2,7 +2,7 @@ - - - + + + diff --git a/java/res/xml/rows_azerty.xml b/java/res/xml/rows_azerty.xml index 142ebc0a6..533c683d6 100644 --- a/java/res/xml/rows_azerty.xml +++ b/java/res/xml/rows_azerty.xml @@ -130,9 +130,13 @@ + + + latin:moreKeys="\u2018,\u2019,\u201b,\u201a" /> - - + - - + latin:moreKeys="@string/more_keys_for_double_quote" + latin:maxMoreKeysColumn="4" /> + latin:moreKeys="@string/more_keys_for_single_quote" /> - - + - - + - - + sRtlParenthesisMap = new HashMap(); - - static { - // The all letters need to be mirrored are found at - // http://www.unicode.org/Public/6.0.0/ucd/extracted/DerivedBinaryProperties.txt - addRtlParenthesisPair('(', ')'); - addRtlParenthesisPair('[', ']'); - addRtlParenthesisPair('{', '}'); - addRtlParenthesisPair('<', '>'); - // \u00ab: LEFT-POINTING DOUBLE ANGLE QUOTATION MARK - // \u00bb: RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK - addRtlParenthesisPair('\u00ab', '\u00bb'); - // \u2039: SINGLE LEFT-POINTING ANGLE QUOTATION MARK - // \u203a: SINGLE RIGHT-POINTING ANGLE QUOTATION MARK - addRtlParenthesisPair('\u2039', '\u203a'); - // \u2264: LESS-THAN OR EQUAL TO - // \u2265: GREATER-THAN OR EQUAL TO - addRtlParenthesisPair('\u2264', '\u2265'); - } - - private static void addRtlParenthesisPair(int left, int right) { - sRtlParenthesisMap.put(left, right); - sRtlParenthesisMap.put(right, left); - } - - public static int getRtlParenthesisCode(int code, boolean isRtl) { - if (isRtl && sRtlParenthesisMap.containsKey(code)) { - return sRtlParenthesisMap.get(code); - } else { - return code; - } - } - - private static int getCode(Resources res, Keyboard.Params params, String moreKeySpec) { - return getRtlParenthesisCode( - MoreKeySpecParser.getCode(res, moreKeySpec), params.mIsRtlKeyboard); - } - private static Drawable getIcon(Keyboard.Params params, String moreKeySpec) { final int iconAttrId = MoreKeySpecParser.getIconAttrId(moreKeySpec); if (iconAttrId == KeyboardIconsSet.ICON_UNDEFINED) { @@ -183,7 +142,8 @@ public class Key { public Key(Resources res, Keyboard.Params params, String moreKeySpec, int x, int y, int width, int height) { this(params, MoreKeySpecParser.getLabel(moreKeySpec), null, getIcon(params, moreKeySpec), - getCode(res, params, moreKeySpec), MoreKeySpecParser.getOutputText(moreKeySpec), + MoreKeySpecParser.getCode(res, moreKeySpec), + MoreKeySpecParser.getOutputText(moreKeySpec), x, y, width, height); } @@ -311,16 +271,14 @@ public class Key { if (code == Keyboard.CODE_UNSPECIFIED && TextUtils.isEmpty(outputText) && !TextUtils.isEmpty(mLabel)) { if (mLabel.codePointCount(0, mLabel.length()) == 1) { - final int activatedCode; // Use the first letter of the hint label if shiftedLetterActivated flag is // specified. if (hasShiftedLetterHint() && isShiftedLetterActivated() && !TextUtils.isEmpty(mHintLabel)) { - activatedCode = mHintLabel.codePointAt(0); + mCode = mHintLabel.codePointAt(0); } else { - activatedCode = mLabel.codePointAt(0); + mCode = mLabel.codePointAt(0); } - mCode = getRtlParenthesisCode(activatedCode, params.mIsRtlKeyboard); } else { // In some locale and case, the character might be represented by multiple code // points, such as upper case Eszett of German alphabet. diff --git a/java/src/com/android/inputmethod/keyboard/Keyboard.java b/java/src/com/android/inputmethod/keyboard/Keyboard.java index 1e1f439d4..6653dec4b 100644 --- a/java/src/com/android/inputmethod/keyboard/Keyboard.java +++ b/java/src/com/android/inputmethod/keyboard/Keyboard.java @@ -121,9 +121,6 @@ public class Keyboard { /** Maximum column for mini keyboard */ public final int mMaxMiniKeyboardColumn; - /** True if Right-To-Left keyboard */ - public final boolean mIsRtlKeyboard; - /** List of keys and icons in this keyboard */ public final Set mKeys; public final Set mShiftKeys; @@ -140,7 +137,6 @@ public class Keyboard { mOccupiedWidth = params.mOccupiedWidth; mMostCommonKeyHeight = params.mMostCommonKeyHeight; mMostCommonKeyWidth = params.mMostCommonKeyWidth; - mIsRtlKeyboard = params.mIsRtlKeyboard; mMoreKeysTemplate = params.mMoreKeysTemplate; mMaxMiniKeyboardColumn = params.mMaxMiniKeyboardColumn; @@ -222,7 +218,6 @@ public class Keyboard { public int mHorizontalGap; public int mVerticalGap; - public boolean mIsRtlKeyboard; public int mMoreKeysTemplate; public int mMaxMiniKeyboardColumn; @@ -739,8 +734,6 @@ public class Keyboard { R.styleable.Keyboard_rowHeight, params.mBaseHeight, params.mBaseHeight / DEFAULT_KEYBOARD_ROWS); - params.mIsRtlKeyboard = keyboardAttr.getBoolean( - R.styleable.Keyboard_isRtlKeyboard, false); params.mMoreKeysTemplate = keyboardAttr.getResourceId( R.styleable.Keyboard_moreKeysTemplate, 0); params.mMaxMiniKeyboardColumn = keyAttr.getInt( diff --git a/java/src/com/android/inputmethod/keyboard/MiniKeyboard.java b/java/src/com/android/inputmethod/keyboard/MiniKeyboard.java index 974291373..433bd0d75 100644 --- a/java/src/com/android/inputmethod/keyboard/MiniKeyboard.java +++ b/java/src/com/android/inputmethod/keyboard/MiniKeyboard.java @@ -210,7 +210,6 @@ public class MiniKeyboard extends Keyboard { // TODO: Mini keyboard's vertical gap is currently calculated heuristically. // Should revise the algorithm. mParams.mVerticalGap = parentKeyboard.mVerticalGap / 2; - mParams.mIsRtlKeyboard = parentKeyboard.mIsRtlKeyboard; mMoreKeys = parentKey.mMoreKeys; final int previewWidth = view.mKeyPreviewDrawParams.mPreviewBackgroundWidth;