Remove digit popup characters from mini keyboard of tablet

Bug: 3321376
Change-Id: I38d963952d3c6d2cf1ad19a69b32f90191f17178
This commit is contained in:
Tadashi G. Takaoka 2011-01-06 22:37:39 +09:00
parent fd8f3a3aa0
commit f16028b92e
3 changed files with 40 additions and 1 deletions

View file

@ -25,6 +25,7 @@
<bool name="config_candidate_highlight_font_color_enabled">false</bool>
<bool name="config_swipe_down_dismiss_keyboard_enabled">false</bool>
<bool name="config_sliding_key_input_enabled">false</bool>
<bool name="config_digit_popup_characters_enabled">false</bool>
<!-- Whether or not Popup on key press is enabled by default -->
<bool name="config_default_popup_preview">false</bool>
<!-- This configuration is the index of the array {@link KeyboardSwitcher.KEYBOARD_THEMES}. -->

View file

@ -28,6 +28,7 @@
<bool name="config_candidate_highlight_font_color_enabled">true</bool>
<bool name="config_swipe_down_dismiss_keyboard_enabled">true</bool>
<bool name="config_sliding_key_input_enabled">true</bool>
<bool name="config_digit_popup_characters_enabled">true</bool>
<!-- Whether or not Popup on key press is enabled by default -->
<bool name="config_default_popup_preview">true</bool>
<integer name="config_delay_before_preview">0</integer>

View file

@ -27,6 +27,8 @@ import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.util.Xml;
import java.util.ArrayList;
/**
* Class for describing the position and characteristics of a single key in the keyboard.
*/
@ -208,8 +210,13 @@ public class Key {
style = keyStyles.getEmptyKeyStyle();
}
mPopupCharacters = style.getTextArray(keyAttr,
final CharSequence[] popupCharacters = style.getTextArray(keyAttr,
R.styleable.Keyboard_Key_popupCharacters);
if (res.getBoolean(R.bool.config_digit_popup_characters_enabled)) {
mPopupCharacters = popupCharacters;
} else {
mPopupCharacters = filterOutDigitPopupCharacters(popupCharacters);
}
mMaxPopupColumn = style.getInt(keyboardAttr,
R.styleable.Keyboard_Key_maxPopupKeyboardColumn,
mKeyboard.getMaxPopupKeyboardColumn());
@ -256,6 +263,36 @@ public class Key {
}
}
private static boolean isDigitPopupCharacter(CharSequence label) {
return label.length() == 1 && Character.isDigit(label.charAt(0));
}
private static CharSequence[] filterOutDigitPopupCharacters(CharSequence[] popupCharacters) {
if (popupCharacters == null || popupCharacters.length < 1)
return null;
if (popupCharacters.length == 1 && isDigitPopupCharacter(
PopupCharactersParser.getLabel(popupCharacters[0].toString())))
return null;
ArrayList<CharSequence> filtered = null;
for (int i = 0; i < popupCharacters.length; i++) {
final CharSequence popupSpec = popupCharacters[i];
if (isDigitPopupCharacter(PopupCharactersParser.getLabel(popupSpec.toString()))) {
if (filtered == null) {
filtered = new ArrayList<CharSequence>();
for (int j = 0; j < i; j++)
filtered.add(popupCharacters[j]);
}
} else if (filtered != null) {
filtered.add(popupSpec);
}
}
if (filtered == null)
return popupCharacters;
if (filtered.size() == 0)
return null;
return filtered.toArray(new CharSequence[filtered.size()]);
}
public Drawable getIcon() {
return mIcon;
}