Merge "Add config_default_keyboard_theme_id resource"

main
Tadashi G. Takaoka 2010-12-28 04:33:02 -08:00 committed by Android (Google) Code Review
commit 07357f33db
4 changed files with 21 additions and 11 deletions

View File

@ -27,6 +27,8 @@
<bool name="config_sliding_key_input_enabled">false</bool> <bool name="config_sliding_key_input_enabled">false</bool>
<!-- Whether or not Popup on key press is enabled by default --> <!-- Whether or not Popup on key press is enabled by default -->
<bool name="config_default_popup_preview">false</bool> <bool name="config_default_popup_preview">false</bool>
<!-- This configuration is the index of the array {@link KeyboardSwitcher.KEYBOARD_THEMES}. -->
<string name="config_default_keyboard_theme_id">5</string>
<string name="config_text_size_of_language_on_spacebar">medium</string> <string name="config_text_size_of_language_on_spacebar">medium</string>
<integer name="config_max_popup_keyboard_column">9</integer> <integer name="config_max_popup_keyboard_column">9</integer>
</resources> </resources>

View File

@ -44,6 +44,8 @@
<integer name="config_long_press_shift_key_timeout">1200</integer> <integer name="config_long_press_shift_key_timeout">1200</integer>
<integer name="config_touch_noise_threshold_millis">40</integer> <integer name="config_touch_noise_threshold_millis">40</integer>
<dimen name="config_touch_noise_threshold_distance">2.0mm</dimen> <dimen name="config_touch_noise_threshold_distance">2.0mm</dimen>
<!-- This configuration is the index of the array {@link KeyboardSwitcher.KEYBOARD_THEMES}. -->
<string name="config_default_keyboard_theme_id">4</string>
<string name="config_text_size_of_language_on_spacebar">small</string> <string name="config_text_size_of_language_on_spacebar">small</string>
<integer name="config_max_popup_keyboard_column">9</integer> <integer name="config_max_popup_keyboard_column">9</integer>
<!-- Whether or not auto-correction should be enabled by default --> <!-- Whether or not auto-correction should be enabled by default -->

View File

@ -32,7 +32,7 @@
android:persistent="true" android:persistent="true"
android:entryValues="@array/keyboard_layout_modes_values" android:entryValues="@array/keyboard_layout_modes_values"
android:entries="@array/keyboard_layout_modes" android:entries="@array/keyboard_layout_modes"
android:defaultValue="5" android:defaultValue="@string/config_default_keyboard_theme_id"
/> />
<CheckBoxPreference <CheckBoxPreference

View File

@ -39,16 +39,15 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
private static final boolean DEBUG = false; private static final boolean DEBUG = false;
public static final boolean DEBUG_STATE = false; public static final boolean DEBUG_STATE = false;
// Changing DEFAULT_LAYOUT_ID also requires prefs_for_debug.xml to be matched with. private static String sConfigDefaultKeyboardThemeId;
public static final String DEFAULT_LAYOUT_ID = "5";
public static final String PREF_KEYBOARD_LAYOUT = "pref_keyboard_layout_20100902"; public static final String PREF_KEYBOARD_LAYOUT = "pref_keyboard_layout_20100902";
private static final int[] THEMES = new int [] { private static final int[] KEYBOARD_THEMES = {
R.layout.input_basic, R.layout.input_basic,
R.layout.input_basic_highcontrast, R.layout.input_basic_highcontrast,
R.layout.input_stone_normal, R.layout.input_stone_normal,
R.layout.input_stone_bold, R.layout.input_stone_bold,
R.layout.input_gingerbread, R.layout.input_gingerbread,
R.layout.input_honeycomb, // DEFAULT_LAYOUT_ID R.layout.input_honeycomb,
}; };
private SubtypeSwitcher mSubtypeSwitcher; private SubtypeSwitcher mSubtypeSwitcher;
@ -111,8 +110,15 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
sInstance.mPrefs = prefs; sInstance.mPrefs = prefs;
sInstance.mSubtypeSwitcher = SubtypeSwitcher.getInstance(); sInstance.mSubtypeSwitcher = SubtypeSwitcher.getInstance();
sInstance.mLayoutId = Integer.valueOf( try {
prefs.getString(PREF_KEYBOARD_LAYOUT, DEFAULT_LAYOUT_ID)); sConfigDefaultKeyboardThemeId = ims.getString(
R.string.config_default_keyboard_theme_id);
sInstance.mLayoutId = Integer.valueOf(
prefs.getString(PREF_KEYBOARD_LAYOUT, sConfigDefaultKeyboardThemeId));
} catch (NumberFormatException e) {
sConfigDefaultKeyboardThemeId = "0";
sInstance.mLayoutId = 0;
}
prefs.registerOnSharedPreferenceChangeListener(sInstance); prefs.registerOnSharedPreferenceChangeListener(sInstance);
} }
@ -609,8 +615,8 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
if (mInputView != null) { if (mInputView != null) {
mInputView.closing(); mInputView.closing();
} }
if (THEMES.length <= layoutId) { if (KEYBOARD_THEMES.length <= layoutId) {
layoutId = Integer.valueOf(DEFAULT_LAYOUT_ID); layoutId = Integer.valueOf(sConfigDefaultKeyboardThemeId);
} }
Utils.GCUtils.getInstance().reset(); Utils.GCUtils.getInstance().reset();
@ -618,7 +624,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
for (int i = 0; i < Utils.GCUtils.GC_TRY_LOOP_MAX && tryGC; ++i) { for (int i = 0; i < Utils.GCUtils.GC_TRY_LOOP_MAX && tryGC; ++i) {
try { try {
mInputView = (LatinKeyboardView) mInputMethodService.getLayoutInflater( mInputView = (LatinKeyboardView) mInputMethodService.getLayoutInflater(
).inflate(THEMES[layoutId], null); ).inflate(KEYBOARD_THEMES[layoutId], null);
tryGC = false; tryGC = false;
} catch (OutOfMemoryError e) { } catch (OutOfMemoryError e) {
Log.w(TAG, "load keyboard failed: " + e); Log.w(TAG, "load keyboard failed: " + e);
@ -651,7 +657,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if (PREF_KEYBOARD_LAYOUT.equals(key)) { if (PREF_KEYBOARD_LAYOUT.equals(key)) {
final int layoutId = Integer.valueOf( final int layoutId = Integer.valueOf(
sharedPreferences.getString(key, DEFAULT_LAYOUT_ID)); sharedPreferences.getString(key, sConfigDefaultKeyboardThemeId));
createInputViewInternal(layoutId, false); createInputViewInternal(layoutId, false);
postSetInputView(); postSetInputView();
} else if (Settings.PREF_SETTINGS_KEY.equals(key)) { } else if (Settings.PREF_SETTINGS_KEY.equals(key)) {