diff options
-rw-r--r-- | AndroidManifest.xml | 9 | ||||
-rw-r--r-- | res/xml/hard_keyboard_settings.xml | 43 | ||||
-rw-r--r-- | res/xml/keyboard_settings.xml | 39 | ||||
-rw-r--r-- | src/com/android/settings/PhysicalKeyboardSettings.java | 83 | ||||
-rw-r--r-- | src/com/android/settings/inputmethod/InputMethodConfig.java | 56 |
5 files changed, 81 insertions, 149 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 66bb1e4..bc58a7e 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -382,15 +382,6 @@ android:resource="@id/language_settings" /> </activity> - <activity android:name="PhysicalKeyboardSettings" - android:label="@string/builtin_keyboard_settings_title" - android:theme="@android:style/Theme.Holo.DialogWhenLarge"> - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.DEFAULT" /> - </intent-filter> - </activity> - <activity android:name="Settings$UserDictionarySettingsActivity" android:theme="@android:style/Theme.Holo" android:label="@string/user_dict_settings_titlebar" diff --git a/res/xml/hard_keyboard_settings.xml b/res/xml/hard_keyboard_settings.xml new file mode 100644 index 0000000..d09522e --- /dev/null +++ b/res/xml/hard_keyboard_settings.xml @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2011 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. +--> + +<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> + + <PreferenceCategory + android:key="hard_keyboard" + android:title="@string/builtin_keyboard_settings_title" + android:persistent="false"> + + <CheckBoxPreference + android:key="auto_replace" + android:title="@string/auto_replace" + android:summaryOn="@string/auto_replace_summary" + android:summaryOff="@string/auto_replace_summary" + android:persistent="false"/> + <CheckBoxPreference + android:key="auto_caps" + android:title="@string/auto_caps" + android:summaryOn="@string/auto_caps_summary" + android:summaryOff="@string/auto_caps_summary" + android:persistent="false"/> + <CheckBoxPreference + android:key="auto_punctuate" + android:title="@string/auto_punctuate" + android:summaryOn="@string/auto_punctuate_summary" + android:summaryOff="@string/auto_punctuate_summary" + android:persistent="false"/> + </PreferenceCategory> +</PreferenceScreen> diff --git a/res/xml/keyboard_settings.xml b/res/xml/keyboard_settings.xml deleted file mode 100644 index 85d90ab..0000000 --- a/res/xml/keyboard_settings.xml +++ /dev/null @@ -1,39 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2009 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. ---> - -<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"> - - <CheckBoxPreference - android:key="auto_replace" - android:title="@string/auto_replace" - android:summaryOn="@string/auto_replace_summary" - android:summaryOff="@string/auto_replace_summary" - android:persistent="false"/> - <CheckBoxPreference - android:key="auto_caps" - android:title="@string/auto_caps" - android:summaryOn="@string/auto_caps_summary" - android:summaryOff="@string/auto_caps_summary" - android:persistent="false"/> - <CheckBoxPreference - android:key="auto_punctuate" - android:title="@string/auto_punctuate" - android:summaryOn="@string/auto_punctuate_summary" - android:summaryOff="@string/auto_punctuate_summary" - android:persistent="false"/> - -</PreferenceScreen> diff --git a/src/com/android/settings/PhysicalKeyboardSettings.java b/src/com/android/settings/PhysicalKeyboardSettings.java deleted file mode 100644 index b959183..0000000 --- a/src/com/android/settings/PhysicalKeyboardSettings.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (C) 2009 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. - */ - -package com.android.settings; - -import android.content.ContentResolver; -import android.os.Bundle; -import android.preference.CheckBoxPreference; -import android.preference.Preference; -import android.preference.PreferenceScreen; -import android.provider.Settings.System; - -public class PhysicalKeyboardSettings extends SettingsPreferenceFragment { - - private final String[] mSettingsUiKey = { - "auto_caps", - "auto_replace", - "auto_punctuate", - }; - - // Note: Order of this array should correspond to the order of the above array - private final String[] mSettingsSystemId = { - System.TEXT_AUTO_CAPS, - System.TEXT_AUTO_REPLACE, - System.TEXT_AUTO_PUNCTUATE, - }; - - // Note: Order of this array should correspond to the order of the above array - private final int[] mSettingsDefault = { - 1, - 1, - 1, - }; - - @Override - public void onCreate(Bundle icicle) { - super.onCreate(icicle); - - addPreferencesFromResource(R.xml.keyboard_settings); - } - - @Override - public void onResume() { - super.onResume(); - ContentResolver resolver = getContentResolver(); - for (int i = 0; i < mSettingsUiKey.length; i++) { - CheckBoxPreference pref = (CheckBoxPreference) findPreference(mSettingsUiKey[i]); - pref.setChecked(System.getInt(resolver, mSettingsSystemId[i], - mSettingsDefault[i]) > 0); - } - } - - - @Override - public boolean onPreferenceTreeClick( - PreferenceScreen preferenceScreen, Preference preference) { - - // Physical keyboard stuff - for (int i = 0; i < mSettingsUiKey.length; i++) { - if (mSettingsUiKey[i].equals(preference.getKey())) { - System.putInt(getContentResolver(), mSettingsSystemId[i], - ((CheckBoxPreference)preference).isChecked()? 1 : 0); - return true; - } - } - - return super.onPreferenceTreeClick(preferenceScreen, preference); - } - -} diff --git a/src/com/android/settings/inputmethod/InputMethodConfig.java b/src/com/android/settings/inputmethod/InputMethodConfig.java index 4702b08..2c336db 100644 --- a/src/com/android/settings/inputmethod/InputMethodConfig.java +++ b/src/com/android/settings/inputmethod/InputMethodConfig.java @@ -20,6 +20,7 @@ import com.android.settings.R; import com.android.settings.SettingsPreferenceFragment; import android.app.AlertDialog; +import android.content.ContentResolver; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; @@ -31,6 +32,7 @@ import android.preference.Preference; import android.preference.PreferenceCategory; import android.preference.PreferenceScreen; import android.provider.Settings; +import android.provider.Settings.System; import android.text.TextUtils; import android.view.inputmethod.InputMethodInfo; import android.view.inputmethod.InputMethodManager; @@ -42,12 +44,17 @@ import java.util.List; public class InputMethodConfig extends SettingsPreferenceFragment { - private static final String KEY_PHYSICALKEYBOARD_CATEGORY = "hardkeyboard_category"; - private static final String PHYSICALKEYBOARD_SETTINGS_FRAGMENT - = "com.android.settings.PhysicalKeyboardSettings"; + private static final String[] sSystemSettingNames = { + System.TEXT_AUTO_REPLACE, System.TEXT_AUTO_CAPS, System.TEXT_AUTO_PUNCTUATE, + }; + + private static final String[] sHardKeyboardKeys = { + "auto_replace", "auto_caps", "auto_punctuate", + }; private AlertDialog mDialog = null; private boolean mHaveHardKeyboard; + private PreferenceCategory mHardKeyboardCategory; // Map of imi and its preferences final private HashMap<String, List<Preference>> mInputMethodPrefsMap = new HashMap<String, List<Preference>>(); @@ -72,8 +79,18 @@ public class InputMethodConfig extends SettingsPreferenceFragment { @Override public void onResume() { super.onResume(); + + ContentResolver resolver = getContentResolver(); + if (mHaveHardKeyboard) { + for (int i = 0; i < sHardKeyboardKeys.length; ++i) { + CheckBoxPreference chkPref = (CheckBoxPreference) + mHardKeyboardCategory.findPreference(sHardKeyboardKeys[i]); + chkPref.setChecked(System.getInt(resolver, sSystemSettingNames[i], 1) > 0); + } + } + InputMethodAndSubtypeUtil.loadInputMethodSubtypeList( - this, getContentResolver(), mInputMethodProperties, mInputMethodPrefsMap); + this, resolver, mInputMethodProperties, mInputMethodPrefsMap); updateActiveInputMethodsSummary(); } @@ -133,6 +150,17 @@ public class InputMethodConfig extends SettingsPreferenceFragment { if (preference instanceof CheckBoxPreference) { final CheckBoxPreference chkPref = (CheckBoxPreference) preference; + + if (mHaveHardKeyboard) { + for (int i = 0; i < sHardKeyboardKeys.length; ++i) { + if (chkPref == mHardKeyboardCategory.findPreference(sHardKeyboardKeys[i])) { + System.putInt(getContentResolver(), sSystemSettingNames[i], + chkPref.isChecked() ? 1 : 0); + return true; + } + } + } + final String imiId = chkPref.getKey(); if (chkPref.isChecked()) { InputMethodInfo selImi = getInputMethodInfoFromImiId(imiId); @@ -164,17 +192,6 @@ public class InputMethodConfig extends SettingsPreferenceFragment { } } - private void addHardKeyboardPreference(PreferenceScreen root) { - PreferenceCategory keyboardSettingsCategory = new PreferenceCategory(getActivity()); - keyboardSettingsCategory.setTitle(R.string.builtin_keyboard_settings_title); - root.addPreference(keyboardSettingsCategory); - PreferenceScreen prefScreen = new PreferenceScreen(getActivity(), null); - prefScreen.setKey(KEY_PHYSICALKEYBOARD_CATEGORY); - prefScreen.setTitle(R.string.builtin_keyboard_settings_title); - prefScreen.setSummary(R.string.builtin_keyboard_settings_summary); - prefScreen.setFragment(PHYSICALKEYBOARD_SETTINGS_FRAGMENT); - } - private void addInputMethodPreference(PreferenceScreen root, InputMethodInfo imi, final int imiSize) { PreferenceCategory keyboardSettingsCategory = new PreferenceCategory(getActivity()); @@ -227,10 +244,13 @@ public class InputMethodConfig extends SettingsPreferenceFragment { } private PreferenceScreen createPreferenceHierarchy() { - // Root - PreferenceScreen root = getPreferenceManager().createPreferenceScreen(getActivity()); + addPreferencesFromResource(R.xml.hard_keyboard_settings); + PreferenceScreen root = getPreferenceScreen(); + if (mHaveHardKeyboard) { - addHardKeyboardPreference(root); + mHardKeyboardCategory = (PreferenceCategory) findPreference("hard_keyboard"); + } else { + root.removeAll(); } final int N = (mInputMethodProperties == null ? 0 : mInputMethodProperties.size()); |