auto import from //depot/cupcake/@136594
This commit is contained in:
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.android.settings;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
@@ -28,37 +27,20 @@ import android.preference.PreferenceActivity;
|
||||
import android.preference.PreferenceGroup;
|
||||
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;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
public class LanguageSettings extends PreferenceActivity {
|
||||
|
||||
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,
|
||||
};
|
||||
private boolean mHaveHardKeyboard;
|
||||
|
||||
// Note: Order of this array should correspond to the order of the above array
|
||||
private final int[] mSettingsDefault = {
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
};
|
||||
|
||||
private List<InputMethodInfo> mInputMethodProperties;
|
||||
private List<CheckBoxPreference> mCheckboxes;
|
||||
|
||||
final TextUtils.SimpleStringSplitter mStringColonSplitter
|
||||
= new TextUtils.SimpleStringSplitter(':');
|
||||
@@ -80,20 +62,15 @@ public class LanguageSettings extends PreferenceActivity {
|
||||
getPreferenceScreen().
|
||||
removePreference(findPreference("language_category"));
|
||||
}
|
||||
|
||||
|
||||
Configuration config = getResources().getConfiguration();
|
||||
if (config.keyboard != Configuration.KEYBOARD_QWERTY) {
|
||||
getPreferenceScreen().removePreference(
|
||||
getPreferenceScreen().findPreference("hardkeyboard_category"));
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
mHaveHardKeyboard = true;
|
||||
}
|
||||
|
||||
mCheckboxes = new ArrayList<CheckBoxPreference>();
|
||||
onCreateIMM();
|
||||
}
|
||||
|
||||
@@ -116,18 +93,27 @@ public class LanguageSettings extends PreferenceActivity {
|
||||
CharSequence label = property.loadLabel(getPackageManager());
|
||||
|
||||
// Add a check box.
|
||||
CheckBoxPreference chkbxPref = new CheckBoxPreference(this);
|
||||
chkbxPref.setKey(prefKey);
|
||||
chkbxPref.setTitle(label);
|
||||
textCategory.addPreference(chkbxPref);
|
||||
// Don't show the toggle if it's the only keyboard in the system
|
||||
if (mHaveHardKeyboard || N > 1) {
|
||||
CheckBoxPreference chkbxPref = new CheckBoxPreference(this);
|
||||
chkbxPref.setKey(prefKey);
|
||||
chkbxPref.setTitle(label);
|
||||
textCategory.addPreference(chkbxPref);
|
||||
mCheckboxes.add(chkbxPref);
|
||||
}
|
||||
|
||||
// If setting activity is available, add a setting screen entry.
|
||||
if (null != property.getSettingsActivity()) {
|
||||
PreferenceScreen prefScreen = new PreferenceScreen(this, null);
|
||||
prefScreen.setKey(property.getSettingsActivity());
|
||||
CharSequence settingsLabel = getResources().getString(
|
||||
R.string.input_methods_settings_label_format, label);
|
||||
prefScreen.setTitle(settingsLabel);
|
||||
prefScreen.setTitle(label);
|
||||
if (N == 1) {
|
||||
prefScreen.setSummary(getString(R.string.onscreen_keyboard_settings_summary));
|
||||
} else {
|
||||
CharSequence settingsLabel = getResources().getString(
|
||||
R.string.input_methods_settings_label_format, label);
|
||||
prefScreen.setSummary(settingsLabel);
|
||||
}
|
||||
textCategory.addPreference(prefScreen);
|
||||
}
|
||||
}
|
||||
@@ -154,8 +140,11 @@ public class LanguageSettings extends PreferenceActivity {
|
||||
final String id = mInputMethodProperties.get(i).getId();
|
||||
CheckBoxPreference pref = (CheckBoxPreference) findPreference(mInputMethodProperties
|
||||
.get(i).getId());
|
||||
pref.setChecked(enabled.contains(id));
|
||||
if (pref != null) {
|
||||
pref.setChecked(enabled.contains(id));
|
||||
}
|
||||
}
|
||||
updateCheckboxes();
|
||||
mLastTickedInputMethodId = null;
|
||||
}
|
||||
|
||||
@@ -173,7 +162,7 @@ public class LanguageSettings extends PreferenceActivity {
|
||||
final String id = mInputMethodProperties.get(i).getId();
|
||||
CheckBoxPreference pref = (CheckBoxPreference) findPreference(id);
|
||||
boolean hasIt = id.equals(mLastInputMethodId);
|
||||
if (pref.isChecked()) {
|
||||
if ((N == 1 && !mHaveHardKeyboard) || (pref != null && pref.isChecked())) {
|
||||
if (builder.length() > 0) builder.append(':');
|
||||
builder.append(id);
|
||||
if (firstEnabled < 0) {
|
||||
@@ -200,18 +189,30 @@ public class LanguageSettings extends PreferenceActivity {
|
||||
Settings.Secure.DEFAULT_INPUT_METHOD, mLastInputMethodId);
|
||||
}
|
||||
|
||||
@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;
|
||||
private void updateCheckboxes() {
|
||||
final int count = mCheckboxes.size();
|
||||
int nChecked = 0;
|
||||
int iChecked = -1;
|
||||
// See how many are checked and note the only or last checked one
|
||||
for (int i = 0; i < count; i++) {
|
||||
if (mCheckboxes.get(i).isChecked()) {
|
||||
iChecked = i;
|
||||
nChecked++;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
if (nChecked == 1) {
|
||||
mCheckboxes.get(iChecked).setEnabled(false);
|
||||
} else {
|
||||
for (int i = 0; i < count; i++) {
|
||||
mCheckboxes.get(i).setEnabled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
|
||||
|
||||
// Input Method stuff
|
||||
// Those monkeys kept committing suicide, so we add this property
|
||||
// to disable this functionality
|
||||
@@ -240,7 +241,7 @@ public class LanguageSettings extends PreferenceActivity {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
updateCheckboxes();
|
||||
return super.onPreferenceTreeClick(preferenceScreen, preference);
|
||||
}
|
||||
|
||||
|
83
src/com/android/settings/PhysicalKeyboardSettings.java
Normal file
83
src/com/android/settings/PhysicalKeyboardSettings.java
Normal file
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* 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.PreferenceActivity;
|
||||
import android.preference.PreferenceScreen;
|
||||
import android.provider.Settings.System;
|
||||
|
||||
public class PhysicalKeyboardSettings extends PreferenceActivity {
|
||||
|
||||
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
|
||||
protected void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
|
||||
addPreferencesFromResource(R.xml.keyboard_settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected 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);
|
||||
}
|
||||
|
||||
}
|
@@ -560,7 +560,7 @@ public class RadioInfo extends Activity {
|
||||
|
||||
// Get the toggle-data-on-boot menu item in the right state.
|
||||
item = menu.findItem(MENU_ITEM_TOGGLE_DATA_ON_BOOT);
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this.getApplication());
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(phone.getContext());
|
||||
boolean value = sp.getBoolean(GSMPhone.DATA_DISABLED_ON_BOOT_KEY, false);
|
||||
if (value) {
|
||||
item.setTitle(R.string.radioInfo_menu_enableDataOnBoot);
|
||||
@@ -584,7 +584,7 @@ public class RadioInfo extends Activity {
|
||||
|
||||
private void updateQxdmState(Boolean newQxdmStatus) {
|
||||
SharedPreferences sp =
|
||||
PreferenceManager.getDefaultSharedPreferences(this.getApplication());
|
||||
PreferenceManager.getDefaultSharedPreferences(phone.getContext());
|
||||
mQxdmLogEnabled = sp.getBoolean("qxdmstatus", false);
|
||||
// This is called from onCreate, onResume, and the handler when the status
|
||||
// is updated.
|
||||
@@ -602,14 +602,14 @@ public class RadioInfo extends Activity {
|
||||
}
|
||||
|
||||
private void setCiphPref(boolean value) {
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this.getApplication());
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(phone.getContext());
|
||||
SharedPreferences.Editor editor = sp.edit();
|
||||
editor.putBoolean(GSMPhone.CIPHERING_KEY, value);
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
private boolean getCiphPref() {
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this.getApplication());
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(phone.getContext());
|
||||
boolean ret = sp.getBoolean(GSMPhone.CIPHERING_KEY, true);
|
||||
return ret;
|
||||
}
|
||||
@@ -1044,7 +1044,7 @@ public class RadioInfo extends Activity {
|
||||
};
|
||||
|
||||
private void toggleDataDisabledOnBoot() {
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this.getApplication());
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(phone.getContext());
|
||||
SharedPreferences.Editor editor = sp.edit();
|
||||
boolean value = sp.getBoolean(GSMPhone.DATA_DISABLED_ON_BOOT_KEY, false);
|
||||
editor.putBoolean(GSMPhone.DATA_DISABLED_ON_BOOT_KEY, !value);
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (C) 2007 Google Inc.
|
||||
* Copyright (C) 2009 Google Inc.
|
||||
*
|
||||
* 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
|
||||
@@ -136,7 +136,7 @@ public class UserDictionarySettings extends ListActivity {
|
||||
|
||||
@Override
|
||||
protected void onListItemClick(ListView l, View v, int position, long id) {
|
||||
showAddOrEditDialog(getWord(position));
|
||||
openContextMenu(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -145,8 +145,10 @@ public class UserDictionarySettings extends ListActivity {
|
||||
|
||||
AdapterContextMenuInfo adapterMenuInfo = (AdapterContextMenuInfo) menuInfo;
|
||||
menu.setHeaderTitle(getWord(adapterMenuInfo.position));
|
||||
menu.add(0, CONTEXT_MENU_EDIT, 0, R.string.user_dict_settings_context_menu_edit_title);
|
||||
menu.add(0, CONTEXT_MENU_DELETE, 0, R.string.user_dict_settings_context_menu_delete_title);
|
||||
menu.add(0, CONTEXT_MENU_EDIT, 0,
|
||||
R.string.user_dict_settings_context_menu_edit_title);
|
||||
menu.add(0, CONTEXT_MENU_DELETE, 0,
|
||||
R.string.user_dict_settings_context_menu_delete_title);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -203,7 +205,9 @@ public class UserDictionarySettings extends ListActivity {
|
||||
| InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE);
|
||||
|
||||
return new AlertDialog.Builder(this)
|
||||
.setTitle(R.string.user_dict_settings_add_dialog_title)
|
||||
.setTitle(mDialogEditingWord != null
|
||||
? R.string.user_dict_settings_edit_dialog_title
|
||||
: R.string.user_dict_settings_add_dialog_title)
|
||||
.setView(content)
|
||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
@@ -216,10 +220,12 @@ public class UserDictionarySettings extends ListActivity {
|
||||
}})
|
||||
.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPrepareDialog(int id, Dialog d) {
|
||||
AlertDialog dialog = (AlertDialog) d;
|
||||
d.setTitle(mDialogEditingWord != null
|
||||
? R.string.user_dict_settings_edit_dialog_title
|
||||
: R.string.user_dict_settings_add_dialog_title);
|
||||
EditText editText = (EditText) dialog.findViewById(R.id.edittext);
|
||||
editText.setText(mDialogEditingWord);
|
||||
}
|
||||
|
@@ -24,6 +24,7 @@ import android.content.DialogInterface;
|
||||
import android.net.wifi.WifiInfo;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.Bundle;
|
||||
import android.text.InputType;
|
||||
import android.text.TextUtils;
|
||||
import android.text.format.Formatter;
|
||||
import android.text.method.PasswordTransformationMethod;
|
||||
@@ -589,11 +590,9 @@ public class AccessPointDialog extends AlertDialog implements DialogInterface.On
|
||||
|
||||
private void setShowPassword(boolean showPassword) {
|
||||
if (mPasswordEdit != null) {
|
||||
// Toggle password
|
||||
mPasswordEdit.setTransformationMethod(
|
||||
showPassword ?
|
||||
null :
|
||||
PasswordTransformationMethod.getInstance());
|
||||
mPasswordEdit.setInputType(InputType.TYPE_CLASS_TEXT |
|
||||
(showPassword ? InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD
|
||||
: InputType.TYPE_TEXT_VARIATION_PASSWORD));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user