Add a layout for a black-characters based theme

bug: 2838151

Change-Id: Ia7136ac7432258386a53ebec2b26251c8caae0ea
main
satok 2010-07-29 03:04:12 +09:00
parent 80aa14fd43
commit db60e6f369
4 changed files with 284 additions and 14 deletions

View File

@ -0,0 +1,106 @@
<?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="a"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="@string/alternates_for_a"
android:keyEdgeFlags="left" />
<Key android:keyLabel="b" />
<Key android:keyLabel="c"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="@string/alternates_for_c" />
<Key android:keyLabel="d" />
<Key android:keyLabel="e"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="@string/alternates_for_e" />
<Key android:keyLabel="f" />
<Key android:keyLabel="g" />
<Key android:keyLabel="h" />
<Key android:keyLabel="i"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="@string/alternates_for_i" />
<Key android:keyLabel="j" android:keyEdgeFlags="right" />
</Row>
<Row>
<Key android:keyLabel="k" android:keyEdgeFlags="left" />
<Key android:keyLabel="l" />
<Key android:keyLabel="m" />
<Key android:keyLabel="n"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="@string/alternates_for_n" />
<Key android:keyLabel="o"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="@string/alternates_for_o" />
<Key android:keyLabel="p" />
<Key android:keyLabel="q" />
<Key android:keyLabel="r" />
<Key android:keyLabel="s"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="@string/alternates_for_s" />
<Key android:keyLabel="t" android:keyEdgeFlags="right" />
</Row>
<Row>
<Key android:codes="-1" android:keyIcon="@drawable/sym_bkeyboard_shift"
android:keyWidth="15%p" android:isModifier="true"
android:iconPreview="@drawable/sym_keyboard_feedback_shift"
android:isSticky="true" android:keyEdgeFlags="left"/>
<Key android:keyLabel="u"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="@string/alternates_for_u" />
<Key android:keyLabel="v"/>
<Key android:keyLabel="w"/>
<Key android:keyLabel="x"/>
<Key android:keyLabel="y"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="@string/alternates_for_y"
/>
<Key android:keyLabel="z"/>
<Key android:keyLabel=","/>
<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="-3" android:keyIcon="@drawable/sym_bkeyboard_done"
android:iconPreview="@drawable/sym_keyboard_feedback_done"
android:keyWidth="20%p" android:keyEdgeFlags="left"/>
<Key android:codes="-2" android:keyLabel="123" android:keyWidth="15%p"/>
<Key android:codes="32" android:keyIcon="@drawable/sym_bkeyboard_space"
android:iconPreview="@drawable/sym_keyboard_feedback_space"
android:keyWidth="30%p" android:isRepeatable="true"/>
<Key android:codes="46" android:keyLabel="."
android:popupKeyboard="@xml/popup_punctuation"
android:keyWidth="15%p"/>
<Key android:codes="10" android:keyIcon="@drawable/sym_bkeyboard_return"
android:iconPreview="@drawable/sym_keyboard_feedback_return"
android:keyWidth="20%p" android:keyEdgeFlags="right"/>
</Row>
</Keyboard>

View File

@ -0,0 +1,67 @@
<?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="26.67%p"
android:horizontalGap="0px"
android:verticalGap="0px"
android:keyHeight="@dimen/key_height"
>
<Row>
<Key android:codes="49" android:keyIcon="@drawable/sym_bkeyboard_num1" android:keyEdgeFlags="left"/>
<Key android:codes="50" android:keyIcon="@drawable/sym_bkeyboard_num2"/>
<Key android:codes="51" android:keyIcon="@drawable/sym_bkeyboard_num3"/>
<Key android:keyLabel="-" android:keyWidth="20%p" android:keyEdgeFlags="right"/>
</Row>
<Row>
<Key android:codes="52" android:keyIcon="@drawable/sym_bkeyboard_num4" android:keyEdgeFlags="left"/>
<Key android:codes="53" android:keyIcon="@drawable/sym_bkeyboard_num5"/>
<Key android:codes="54" android:keyIcon="@drawable/sym_bkeyboard_num6"/>
<Key android:keyLabel="." android:keyWidth="20%p" android:keyEdgeFlags="right"/>
</Row>
<Row>
<Key android:codes="55" android:keyIcon="@drawable/sym_bkeyboard_num7" android:keyEdgeFlags="left"/>
<Key android:codes="56" android:keyIcon="@drawable/sym_bkeyboard_num8"/>
<Key android:codes="57" android:keyIcon="@drawable/sym_bkeyboard_num9"/>
<Key android:codes="-5" android:keyIcon="@drawable/sym_bkeyboard_delete"
android:iconPreview="@drawable/sym_keyboard_feedback_delete"
android:keyWidth="20%p"
android:isRepeatable="true" android:keyEdgeFlags="right"/>
</Row>
<Row android:rowEdgeFlags="bottom">
<Key android:codes="-2" android:keyIcon="@drawable/sym_bkeyboard_numalt"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="_"
android:iconPreview="@drawable/sym_keyboard_feedback_numalt"/>
<Key android:codes="48" android:keyIcon="@drawable/sym_bkeyboard_num0"/>
<Key android:codes="32" android:keyIcon="@drawable/sym_bkeyboard_space"
android:iconPreview="@drawable/sym_keyboard_feedback_space"
android:isRepeatable="true"/>
<Key android:codes="10" android:keyIcon="@drawable/sym_bkeyboard_return"
android:keyWidth="20%p"
android:keyEdgeFlags="right"/>
</Row>
</Keyboard>

View File

@ -0,0 +1,70 @@
<?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="26.67%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:keyWidth="20%p" android:keyEdgeFlags="right"/>
</Row>
<Row>
<Key android:keyLabel="N" android:keyEdgeFlags="left"/>
<!-- Pause is a comma.
Check PhoneNumberUtils.java to see if this has changed. -->
<Key android:codes="44" android:keyLabel="Pause"/>
<Key android:keyLabel=","/>
<Key android:keyLabel="." android:keyWidth="20%p" android:keyEdgeFlags="right"/>
</Row>
<Row>
<Key android:codes="42" android:keyIcon="@drawable/sym_bkeyboard_numstar"
android:keyEdgeFlags="left"/>
<!-- Wait is a semicolon. -->
<Key android:codes="59" android:keyLabel="Wait"/>
<Key android:codes="35" android:keyIcon="@drawable/sym_bkeyboard_numpound"/>
<Key android:codes="-5" android:keyIcon="@drawable/sym_bkeyboard_delete"
android:iconPreview="@drawable/sym_keyboard_feedback_delete"
android:keyWidth="20%p"
android:isRepeatable="true" android:keyEdgeFlags="right"/>
</Row>
<Row android:rowEdgeFlags="bottom">
<Key android:codes="-2" android:keyLabel="@string/label_phone_key"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="_"
android:keyEdgeFlags="left"/>
<Key android:keyLabel="+"/>
<Key android:codes="32" android:keyIcon="@drawable/sym_bkeyboard_space"
android:iconPreview="@drawable/sym_keyboard_feedback_space"
android:isRepeatable="true"/>
<Key android:codes="10" android:keyIcon="@drawable/sym_bkeyboard_return"
android:keyWidth="20%p"
android:keyEdgeFlags="right"/>
</Row>
</Keyboard>

View File

@ -50,10 +50,25 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
public static final String DEFAULT_LAYOUT_ID = "3";
public static final String PREF_KEYBOARD_LAYOUT = "keyboard_layout";
private static final int[] LAYOUTS = new int [] {
private static final int[] THEMES = new int [] {
R.layout.input_basic, R.layout.input_basic_highcontrast, R.layout.input_stone_normal,
R.layout.input_stone_bold};
// Ids for each characters' color in the keyboard
private static final int CHAR_THEME_COLOR_WHITE = 0;
private static final int CHAR_THEME_COLOR_BLACK = 1;
// Tables which contains resource ids for each character theme color
private static final int[] KBD_ALPHA = new int[] {R.xml.kbd_alpha, R.xml.kbd_alpha_black};
private static final int[] KBD_PHONE = new int[] {R.xml.kbd_phone, R.xml.kbd_phone_black};
private static final int[] KBD_PHONE_SYMBOLS = new int[] {
R.xml.kbd_phone_symbols, R.xml.kbd_phone_symbols_black};
private static final int[] KBD_SYMBOLS = new int[] {
R.xml.kbd_symbols, R.xml.kbd_symbols_black};
private static final int[] KBD_SYMBOLS_SHIFT = new int[] {
R.xml.kbd_symbols_shift, R.xml.kbd_symbols_shift_black};
private static final int[] KBD_QWERTY = new int[] {R.xml.kbd_qwerty, R.xml.kbd_qwerty_black};
private static final int SYMBOLS_MODE_STATE_NONE = 0;
private static final int SYMBOLS_MODE_STATE_BEGIN = 1;
private static final int SYMBOLS_MODE_STATE_SYMBOL = 2;
@ -119,13 +134,11 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
}
private KeyboardId makeSymbolsId(boolean hasVoice) {
return new KeyboardId(
isBlackSym() ? R.xml.kbd_symbols_black : R.xml.kbd_symbols, hasVoice);
return new KeyboardId(KBD_SYMBOLS[getCharColorId()], hasVoice);
}
private KeyboardId makeSymbolsShiftedId(boolean hasVoice) {
return new KeyboardId(
isBlackSym() ? R.xml.kbd_symbols_shift_black : R.xml.kbd_symbols_shift, hasVoice);
return new KeyboardId(KBD_SYMBOLS_SHIFT[getCharColorId()], hasVoice);
}
void makeKeyboards(boolean forceCreate) {
@ -270,11 +283,15 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
private KeyboardId getKeyboardId(int mode, int imeOptions, boolean isSymbols) {
boolean hasVoice = hasVoiceButton(isSymbols);
int charColorId = getCharColorId();
// TODO: generalize for any KeyboardId
int keyboardRowsResId = isBlackSym() ? R.xml.kbd_qwerty_black : R.xml.kbd_qwerty;
int keyboardRowsResId = KBD_QWERTY[charColorId];
if (isSymbols) {
return (mode == MODE_PHONE)
? new KeyboardId(R.xml.kbd_phone_symbols, hasVoice) : makeSymbolsId(hasVoice);
if (mode == MODE_PHONE) {
return new KeyboardId(KBD_PHONE_SYMBOLS[charColorId], hasVoice);
} else {
return new KeyboardId(KBD_SYMBOLS[charColorId], hasVoice);
}
}
switch (mode) {
case MODE_NONE:
@ -283,14 +300,15 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
/* fall through */
case MODE_TEXT:
if (mTextMode == MODE_TEXT_ALPHA) {
return new KeyboardId(R.xml.kbd_alpha, KEYBOARDMODE_NORMAL, true, hasVoice);
return new KeyboardId(
KBD_ALPHA[charColorId], KEYBOARDMODE_NORMAL, true, hasVoice);
}
// Normally mTextMode should be MODE_TEXT_QWERTY.
return new KeyboardId(keyboardRowsResId, KEYBOARDMODE_NORMAL, true, hasVoice);
case MODE_SYMBOLS:
return makeSymbolsId(hasVoice);
return new KeyboardId(KBD_SYMBOLS[charColorId], hasVoice);
case MODE_PHONE:
return new KeyboardId(R.xml.kbd_phone, hasVoice);
return new KeyboardId(KBD_PHONE[charColorId], hasVoice);
case MODE_URL:
return new KeyboardId(keyboardRowsResId, KEYBOARDMODE_URL, true, hasVoice);
case MODE_EMAIL:
@ -387,7 +405,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
if (mInputView != null) {
mInputView.closing();
}
if (LAYOUTS.length <= newLayout) {
if (THEMES.length <= newLayout) {
newLayout = Integer.valueOf(DEFAULT_LAYOUT_ID);
}
@ -396,7 +414,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
for (int i = 0; i < LatinIMEUtil.GCUtils.GC_TRY_LOOP_MAX && tryGC; ++i) {
try {
mInputView = (LatinKeyboardView) mInputMethodService.getLayoutInflater(
).inflate(LAYOUTS[newLayout], null);
).inflate(THEMES[newLayout], null);
tryGC = false;
} catch (OutOfMemoryError e) {
tryGC = LatinIMEUtil.GCUtils.getInstance().tryGCOrWait(
@ -406,7 +424,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
mLayoutId + "," + newLayout, e);
}
}
mInputView.setExtentionLayoutResId(LAYOUTS[newLayout]);
mInputView.setExtentionLayoutResId(THEMES[newLayout]);
mInputView.setOnKeyboardActionListener(mInputMethodService);
mLayoutId = newLayout;
}
@ -432,4 +450,13 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
}
return false;
}
private int getCharColorId () {
if (isBlackSym()) {
return CHAR_THEME_COLOR_BLACK;
} else {
return CHAR_THEME_COLOR_WHITE;
}
}
}