Merge "Add black resources"

main
satok 2010-05-31 04:40:40 -07:00 committed by Gerrit Code Review
commit 37340b3fb4
4 changed files with 270 additions and 16 deletions

View File

@ -0,0 +1,141 @@
<?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.
*/
-->
<Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
android:keyWidth="10%p"
android:horizontalGap="0px"
android:verticalGap="0px"
android:keyHeight="@dimen/key_height"
>
<Row>
<Key android:codes="49" android:keyLabel="1" android:keyEdgeFlags="left"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="¹½⅓¼⅛"
/>
<Key android:codes="50" android:keyLabel="2"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="²⅔"
/>
<Key android:codes="51" android:keyLabel="3"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="³¾⅜"
/>
<Key android:codes="52" android:keyLabel="4"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="⁴"
/>
<Key android:codes="53" android:keyLabel="5"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="⅝"
/>
<Key android:codes="54" android:keyLabel="6"/>
<Key android:codes="55" android:keyLabel="7"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="⅞"
/>
<Key android:codes="56" android:keyLabel="8"/>
<Key android:codes="57" android:keyLabel="9"/>
<Key android:codes="48" android:keyLabel="0"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="ⁿ∅"
android:keyEdgeFlags="right"/>
</Row>
<Row>
<Key android:codes="64" android:keyLabel="\@" android:keyEdgeFlags="left"/>
<Key android:codes="35" android:keyLabel="\#"/>
<Key android:codes="36" android:keyLabel="$"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="¢£€¥₣₤₱"
/>
<Key android:codes="37" android:keyLabel="%"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="‰"
/>
<Key android:codes="38" android:keyLabel="&amp;"/>
<Key android:codes="42" android:keyLabel="*"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="†‡★"
/>
<Key android:codes="45" android:keyLabel="-"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="_—"
/>
<Key android:keyLabel="+"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="±"
/>
<Key android:codes="40" android:keyLabel="("
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="[{&lt;"
/>
<Key android:codes="41" android:keyLabel=")" android:keyEdgeFlags="right"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="]}&gt;"
/>
</Row>
<Row>
<Key android:codes="-1" android:keyLabel="@string/label_alt_key"
android:keyWidth="15%p" android:isModifier="true"
android:isSticky="true" android:keyEdgeFlags="left"/>
<Key android:codes="33" android:keyLabel="!"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="¡"
/>
<Key android:codes="34" android:keyLabel="&quot;"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="“”«»˝"
/>
<Key android:codes="39" android:keyLabel="\'"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters=""
/>
<Key android:codes="58" android:keyLabel=":"/>
<Key android:codes="59" android:keyLabel=";"/>
<Key android:codes="47" android:keyLabel="/" />
<Key android:codes="63" android:keyLabel="\?"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="¿"
/>
<Key android:codes="-5" android:keyIcon="@drawable/sym_bkeyboard_delete" android:keyWidth="15%p" android:keyEdgeFlags="right"
android:iconPreview="@drawable/sym_keyboard_feedback_delete"
android:isRepeatable="true"/>
</Row>
<Row android:rowEdgeFlags="bottom">
<Key android:codes="-2" android:keyLabel="@string/label_alpha_key"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="_"
android:keyWidth="20%p" android:keyEdgeFlags="left"/>
<Key android:codes="@integer/key_f1" android:keyWidth="10%p"/>
<Key android:codes="32" android:keyIcon="@drawable/sym_bkeyboard_space"
android:keyWidth="40%p"
android:iconPreview="@drawable/sym_keyboard_feedback_space"
android:isRepeatable="true"/>
<Key android:codes="46" android:keyLabel="."
android:popupKeyboard="@xml/popup_punctuation"
android:keyWidth="10%p"/>
<Key android:codes="10" android:keyIcon="@drawable/sym_bkeyboard_return" android:keyWidth="20%p" android:keyEdgeFlags="right"
android:iconPreview="@drawable/sym_keyboard_feedback_return"
/>
</Row>
</Keyboard>

View File

@ -0,0 +1,104 @@
<?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.
*/
-->
<Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
android:keyWidth="10%p"
android:horizontalGap="0px"
android:verticalGap="0px"
android:keyHeight="@dimen/key_height"
>
<Row>
<Key android:keyLabel="~" android:keyEdgeFlags="left"/>
<Key android:keyLabel="`"/>
<Key android:keyLabel="|"/>
<Key android:keyLabel="•"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="♪♥♠♦♣"
/>
<Key android:keyLabel="√"/>
<Key android:keyLabel="π"/>
<Key android:keyLabel="÷"/>
<Key android:keyLabel="×"/>
<Key android:keyLabel="{"/>
<Key android:keyLabel="}" android:keyEdgeFlags="right"/>
</Row>
<Row>
<Key android:codes="9" android:keyLabel="\u21E5" android:keyEdgeFlags="left"/>
<Key android:keyLabel="£"/>
<Key android:keyLabel="¢"/>
<Key android:keyLabel="€"/>
<Key android:keyLabel="°"/>
<Key android:keyLabel="^"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="↑↓←→"
/>
<Key android:keyLabel="_"/>
<Key android:keyLabel="="
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="≠≈∞"
/>
<Key android:keyLabel="["/>
<Key android:keyLabel="]" android:keyEdgeFlags="right"/>
</Row>
<Row>
<Key android:codes="-1" android:keyLabel="@string/label_alt_key"
android:keyWidth="15%p" android:isModifier="true"
android:isSticky="true" android:keyEdgeFlags="left"/>
<Key android:keyLabel="™"/>
<Key android:keyLabel="®"/>
<Key android:keyLabel="©"/>
<Key android:keyLabel="¶"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="§"
/>
<Key android:keyLabel="\\"/>
<Key android:keyLabel="&lt;"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="≤«‹"
/>
<Key android:keyLabel="&gt;"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="≥»›"
/>
<Key android:codes="-5" android:keyIcon="@drawable/sym_bkeyboard_delete" android:keyWidth="15%p" android:keyEdgeFlags="right"
android:iconPreview="@drawable/sym_keyboard_feedback_delete"
android:isRepeatable="true"/>
</Row>
<Row android:rowEdgeFlags="bottom">
<Key android:codes="-2" android:keyLabel="@string/label_alpha_key" android:keyWidth="20%p"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="_"
android:keyEdgeFlags="left"/>
<Key android:keyLabel="„" android:keyWidth="10%p" />
<Key android:codes="32" android:keyIcon="@drawable/sym_bkeyboard_space"
android:keyWidth="40%p"
android:iconPreview="@drawable/sym_keyboard_feedback_space"
android:isRepeatable="true"/>
<Key android:keyLabel="…" android:keyWidth="10%p" />
<Key android:codes="10" android:keyIcon="@drawable/sym_bkeyboard_return"
android:keyWidth="20%p" android:keyEdgeFlags="right"
android:iconPreview="@drawable/sym_keyboard_feedback_return"
/>
</Row>
</Keyboard>

View File

@ -91,14 +91,15 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
KeyboardSwitcher(Context context, LatinIME ims) { KeyboardSwitcher(Context context, LatinIME ims) {
mContext = context; mContext = context;
mKeyboards = new HashMap<KeyboardId, LatinKeyboard>();
mSymbolsId = new KeyboardId(R.xml.kbd_symbols, false);
mSymbolsShiftedId = new KeyboardId(R.xml.kbd_symbols_shift, false);
mInputMethodService = ims;
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ims); final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ims);
int mLayoutId = Integer.valueOf(prefs.getString(PREF_KEYBOARD_LAYOUT, DEFAULT_LAYOUT_ID)); mLayoutId = Integer.valueOf(prefs.getString(PREF_KEYBOARD_LAYOUT, DEFAULT_LAYOUT_ID));
prefs.registerOnSharedPreferenceChangeListener(this); prefs.registerOnSharedPreferenceChangeListener(this);
mKeyboards = new HashMap<KeyboardId, LatinKeyboard>();
mSymbolsId = makeSymbolsId(false);
mSymbolsShiftedId = makeSymbolsShiftedId(false);
mInputMethodService = ims;
changeLatinKeyboardView(mLayoutId, false); changeLatinKeyboardView(mLayoutId, false);
} }
@ -117,6 +118,16 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
mInputView = inputView; mInputView = inputView;
} }
private KeyboardId makeSymbolsId(boolean hasVoice) {
return new KeyboardId(
isBlackSym() ? R.xml.kbd_symbols_black : R.xml.kbd_symbols, hasVoice);
}
private KeyboardId makeSymbolsShiftedId(boolean hasVoice) {
return new KeyboardId(
isBlackSym() ? R.xml.kbd_symbols_shift_black : R.xml.kbd_symbols_shift, hasVoice);
}
void makeKeyboards(boolean forceCreate) { void makeKeyboards(boolean forceCreate) {
if (forceCreate) mKeyboards.clear(); if (forceCreate) mKeyboards.clear();
// Configuration change is coming after the keyboard gets recreated. So don't rely on that. // Configuration change is coming after the keyboard gets recreated. So don't rely on that.
@ -126,9 +137,8 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
if (displayWidth == mLastDisplayWidth) return; if (displayWidth == mLastDisplayWidth) return;
mLastDisplayWidth = displayWidth; mLastDisplayWidth = displayWidth;
if (!forceCreate) mKeyboards.clear(); if (!forceCreate) mKeyboards.clear();
mSymbolsId = new KeyboardId(R.xml.kbd_symbols, mHasVoice && !mVoiceOnPrimary); mSymbolsId = makeSymbolsId(mHasVoice && !mVoiceOnPrimary);
mSymbolsShiftedId = new KeyboardId(R.xml.kbd_symbols_shift, mSymbolsShiftedId = makeSymbolsShiftedId(mHasVoice && !mVoiceOnPrimary);
mHasVoice && !mVoiceOnPrimary);
} }
/** /**
@ -227,7 +237,8 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
orig.updateConfiguration(conf, null); orig.updateConfiguration(conf, null);
LatinKeyboard keyboard = new LatinKeyboard( LatinKeyboard keyboard = new LatinKeyboard(
mContext, id.mXml, id.mKeyboardMode); mContext, id.mXml, id.mKeyboardMode);
keyboard.setVoiceMode(hasVoiceButton(id.mXml == R.xml.kbd_symbols), mHasVoice); keyboard.setVoiceMode(hasVoiceButton(id.mXml == R.xml.kbd_symbols
|| id.mXml == R.xml.kbd_symbols_black), mHasVoice);
keyboard.setLanguageSwitcher(mLanguageSwitcher); keyboard.setLanguageSwitcher(mLanguageSwitcher);
keyboard.setBlackFlag(isBlackSym()); keyboard.setBlackFlag(isBlackSym());
if (id.mKeyboardMode == KEYBOARDMODE_NORMAL if (id.mKeyboardMode == KEYBOARDMODE_NORMAL
@ -256,8 +267,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
int keyboardRowsResId = isBlackSym() ? R.xml.kbd_qwerty_black : R.xml.kbd_qwerty; int keyboardRowsResId = isBlackSym() ? R.xml.kbd_qwerty_black : R.xml.kbd_qwerty;
if (isSymbols) { if (isSymbols) {
return (mode == MODE_PHONE) return (mode == MODE_PHONE)
? new KeyboardId(R.xml.kbd_phone_symbols, hasVoice) ? new KeyboardId(R.xml.kbd_phone_symbols, hasVoice) : makeSymbolsId(hasVoice);
: new KeyboardId(R.xml.kbd_symbols, hasVoice);
} }
switch (mode) { switch (mode) {
case MODE_TEXT: case MODE_TEXT:
@ -268,7 +278,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
} }
break; break;
case MODE_SYMBOLS: case MODE_SYMBOLS:
return new KeyboardId(R.xml.kbd_symbols, hasVoice); return makeSymbolsId(hasVoice);
case MODE_PHONE: case MODE_PHONE:
return new KeyboardId(R.xml.kbd_phone, hasVoice); return new KeyboardId(R.xml.kbd_phone, hasVoice);
case MODE_URL: case MODE_URL:
@ -404,8 +414,6 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
// TODO: Generalize for any theme // TODO: Generalize for any theme
public boolean isBlackSym () { public boolean isBlackSym () {
return (mLayoutId == 6 && (mLanguageSwitcher == null return (mLayoutId == 6);
|| mLanguageSwitcher.getEnabledLanguages() == null
|| mLanguageSwitcher.getInputLanguage().startsWith("en_")));
} }
} }

View File

@ -123,7 +123,8 @@ public class LatinKeyboard extends Keyboard {
setDefaultBounds(m123MicPreviewIcon); setDefaultBounds(m123MicPreviewIcon);
sSpacebarVerticalCorrection = res.getDimensionPixelOffset( sSpacebarVerticalCorrection = res.getDimensionPixelOffset(
R.dimen.spacebar_vertical_correction); R.dimen.spacebar_vertical_correction);
mIsAlphaKeyboard = xmlLayoutResId == R.xml.kbd_qwerty; mIsAlphaKeyboard = xmlLayoutResId == R.xml.kbd_qwerty
|| xmlLayoutResId == R.xml.kbd_qwerty_black;
mSpaceKeyIndex = indexOf((int) ' '); mSpaceKeyIndex = indexOf((int) ' ');
} }