summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChia-chi Yeh <chiachi@android.com>2011-01-14 01:21:12 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-01-14 01:21:12 -0800
commite5b5f6ebe0c27942319c87065fe047f1e05f3bb8 (patch)
tree3415a5a7c7cd242a4841e33ab912bf84b8bfd50e /src
parent6f8fb436178d12d11d6ab59671168f0603bdbdcb (diff)
parent71966ce931e325f2caea0c729124160688353ba7 (diff)
downloadpackages_apps_Settings-e5b5f6ebe0c27942319c87065fe047f1e05f3bb8.zip
packages_apps_Settings-e5b5f6ebe0c27942319c87065fe047f1e05f3bb8.tar.gz
packages_apps_Settings-e5b5f6ebe0c27942319c87065fe047f1e05f3bb8.tar.bz2
Merge "Fix PhysicalKeyboardSettings by merging it into InputMethodConfig." into honeycomb
Diffstat (limited to 'src')
-rw-r--r--src/com/android/settings/PhysicalKeyboardSettings.java83
-rw-r--r--src/com/android/settings/inputmethod/InputMethodConfig.java56
2 files changed, 38 insertions, 101 deletions
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());