Merge branch 'master' into honeycomb-release

* master:
  Implement new design for settings of InputMethods
  Tweak Privacy settings to match latest mocks
  fix wifi checkbox status update
  Change BT pairing UI PIN dialog string for clarity.
  Show "not configurable" screen in EAP
  Use different text in unsecured network.
This commit is contained in:
The Android Automerger
2010-12-17 13:44:53 -08:00
16 changed files with 622 additions and 364 deletions

View File

@@ -332,7 +332,6 @@
android:clearTaskOnLaunch="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.settings.INPUT_METHOD_SETTINGS" />
<action android:name="com.android.settings.VOICE_INPUT_OUTPUT_SETTINGS" />
<category android:name="android.intent.category.VOICE_LAUNCH" />
<category android:name="android.intent.category.DEFAULT" />
@@ -365,6 +364,23 @@
android:value="com.android.settings.Settings$InputMethodAndLanguageSettingsActivity" />
</activity>
<activity android:name="Settings$InputMethodConfigActivity"
android:theme="@android:style/Theme.Holo"
android:label="@string/configure_input_method"
android:clearTaskOnLaunch="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.settings.INPUT_METHOD_SETTINGS" />
<category android:name="android.intent.category.VOICE_LAUNCH" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="com.android.settings.SHORTCUT" />
</intent-filter>
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
android:value="com.android.settings.inputmethod.InputMethodConfig" />
<meta-data android:name="com.android.settings.TOP_LEVEL_HEADER_ID"
android:resource="@id/language_settings" />
</activity>
<activity android:name="PhysicalKeyboardSettings"
android:label="@string/builtin_keyboard_settings_title"
android:theme="@android:style/Theme.Holo.DialogWhenLarge">

View File

@@ -1,62 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2007 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.
-->
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scroll_content"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/bluetooth_device_info_alias" />
<TextView android:id="@+id/deviceAlias"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/bluetooth_device_info_no_alias" />
<Button android:id="@+id/connectButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/bluetooth_device_info_connectButton_text" />
<Button android:id="@+id/deleteButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/bluetooth_device_info_delete" />
<Button android:id="@+id/querySDP"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/bluetooth_device_info_sdp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/bluetooth_device_info" />
<TextView android:id="@+id/deviceInfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/bluetooth_device_info_deviceInfo_text" />
</LinearLayout>
</ScrollView>

View File

@@ -105,6 +105,18 @@
android:entries="@array/wifi_security" />
</LinearLayout> <!-- android:id="@+id/type" -->
<LinearLayout android:id="@+id/eap_not_supported"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dip"
android:orientation="vertical"
android:visibility="gone">
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="22sp"
android:text="@string/wifi_setup_eap_not_supported" />
</LinearLayout>
<!-- All the views below are "gone".
We want them as data storage, not as UI components. -->
<LinearLayout

View File

@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2010, 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.
*/
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string-array name="input_method_selector_titles">
<item>@string/input_method_selector_show_automatically_title</item>
<item>@string/input_method_selector_always_show_title</item>
<item>@string/input_method_selector_always_hide_title</item>
</string-array>
<!-- values for input method selector should be corresponding to the array index of titles -->
<string name="input_method_selector_show_automatically_value">0</string>
<string name="input_method_selector_always_show_value">1</string>
<string name="input_method_selector_always_hide_value">2</string>
<string name="input_method_selector_visibility_default_value">0</string>
<string-array name="input_method_selector_values">
<item>@string/input_method_selector_show_automatically_value</item>
<item>@string/input_method_selector_always_show_value</item>
<item>@string/input_method_selector_always_hide_value</item>
</string-array>
</resources>

View File

@@ -254,11 +254,6 @@
<!-- Strings for msg to display to user while bluetooth is turning on -->
<string name="bluetooth_turning_on">"Turning on Bluetooth\u2026"</string>
<!-- Do not translate. Used for diagnostic screens, precise translation is not necessary -->
<string name="bluetooth_device_info_connectButton_text">Turn on Bluetooth</string>
<!-- Do not translate. Used for diagnostic screens, precise translation is not necessary -->
<string name="bluetooth_device_info_deviceInfo_text" />
<!-- Date & time settings screen title -->
<string name="date_and_time">Date &amp; time settings</string>
<!-- Date/time settings. Summary of the checkbox for choosing between 12 hour time or 24 hour time. Sample of 12-hour time -->
@@ -745,12 +740,10 @@
<!-- Title for the dialog to enter PIN. -->
<string name="bluetooth_pairing_request">Bluetooth pairing request</string>
<!-- Title for the bluetooth device info screen. -->
<string name="bluetooth_device_info">Bluetooth device info</string>
<!-- Message when bluetooth dialog for pin entry is showing -->
<string name="bluetooth_enter_pin_msg">\nType PIN to pair with \u0022<xliff:g id="device_name">%1$s</xliff:g>\u0022. (Try 0000 or 1234.)</string>
<string name="bluetooth_enter_pin_msg">\nEnter PIN to pair with \u0022<xliff:g id="device_name">%1$s</xliff:g>\u0022. (Try 0000 or 1234.) You may need to enter the same PIN on the Bluetooth device.</string>
<!-- Message when bluetooth dialog for passkey entry is showing -->
<string name="bluetooth_enter_passkey_msg">\nType passkey to pair with \u0022<xliff:g id="device_name">%1$s</xliff:g>\u0022.</string>
<string name="bluetooth_enter_passkey_msg">\nEnter passkey to pair with \u0022<xliff:g id="device_name">%1$s</xliff:g>\u0022.</string>
<!-- Message when bluetooth dialog for confirmation of passkey is showing -->
<string name="bluetooth_confirm_passkey_msg">To pair with \u0022<xliff:g id="device_name">%1$s</xliff:g>\u0022, confirm that it is showing the passkey: <xliff:g id="passkey">%2$s</xliff:g>.</string>
<!-- Message when bluetooth incoming pairing request for (2.1 devices) dialog is showing -->
@@ -779,15 +772,6 @@
<!-- Message for the error dialog when BT connecting operation fails generically. -->
<string name="bluetooth_connecting_error_message">There was a problem connecting to <xliff:g id="device_name">%1$s</xliff:g>.</string>
<!-- Do not translate -->
<string name="bluetooth_device_info_alias">Device alias</string>
<!-- Do not translate -->
<string name="bluetooth_device_info_no_alias">Type alias here\u2026</string>
<!-- Do not translate -->
<string name="bluetooth_device_info_delete">Remove this device</string>
<!-- Do not translate -->
<string name="bluetooth_device_info_sdp">List supported services</string>
<!-- Bluetooth settings: The title of the preference (list item) that initiates a scan for devices -->
<string name="bluetooth_preference_scan_title">Scan for devices</string>
<!-- Bluetooth settings: The title of the preference (list item) that finds nearby devices [CHAR LIMIT=30] -->
@@ -2270,13 +2254,30 @@ found in the list of installed applications.</string>
<string name="input_methods_settings_title">Text input</string>
<!-- Setting name for Input Method chooser -->
<string name="input_method">Input method</string>
<!-- Title for selecting the current input method -->
<string name="current_input_method">Current input method</string>
<!-- Title for setting the visibility of input method selector-->
<string name="input_method_selector">Input method selector</string>
<!-- An option to always show input method selector automatically when needed -->
<string name="input_method_selector_show_automatically_title">Automatic</string>
<!-- An option to always show input method selector -->
<string name="input_method_selector_always_show_title">Always show</string>
<!-- An option to always hide input method selector -->
<string name="input_method_selector_always_hide_title">Always hide</string>
<!-- Title for configuring input method settings -->
<string name="configure_input_method">Configure input methods</string>
<!-- Title for settings of each IME -->
<string name="input_method_settings">Settings</string>
<!-- Title for settings of active input methods in each IME -->
<string name="active_input_method_subtypes">Active input methods</string>
<string name="input_methods_settings_summary">Manage text input options</string>
<!-- Input Methods Settings localized format string for generating the appropriate "Foo settings" menu label for the Input Method named "Foo" -->
<string name="input_methods_settings_label_format"><xliff:g id="ime_name">%1$s</xliff:g> settings</string>
<!-- The title for the item to manage the settings of enabled the input methods and subtypes. -->
<string name="input_methods_and_subtype_enabler_title">Manage Input Methods</string>
<!-- Label for selecting the input methods and subtypes to use -->
<string name="input_methods_and_subtype_enabler_title_format">Manage input methods in <xliff:g id="ime_application_name">%1$s</xliff:g></string>
<!-- Title for the settings of selecting active input methods of an IME -->
<string name="input_methods_and_subtype_enabler_title">Select active input methods</string>
<!-- Title format for active input methods. "Active input methods in Foo" menu label for the IME named "Foo" -->
<string name="input_methods_and_subtype_enabler_title_format">Active input methods in <xliff:g id="ime_application_name">%1$s</xliff:g></string>
<!-- Summary for on-screen keyboard settings -->
<string name="onscreen_keyboard_settings_summary">Onscreen keyboard settings</string>
<!-- Title for built-in keyboard settings -->
@@ -2889,10 +2890,10 @@ found in the list of installed applications.</string>
<string name="backup_data_title">Back up my data</string>
<!-- Summary text of the "back up data" setting -->
<string name="backup_data_summary">Back up application data, Wi-Fi passwords, and other settings to Google servers</string>
<!-- Configure backup options menu title [CHAR LIMIT=25]-->
<string name="backup_configure_transport_title">Configure backup</string>
<!-- Default summary text of the "Configure backup" setting [CHAR LIMIT=80]-->
<string name="backup_configure_transport_default_summary">No backup destination is available.</string>
<!-- Configure backup account options menu title [CHAR LIMIT=25]-->
<string name="backup_configure_account_title">Backup account</string>
<!-- Default summary text of the "Configure backup account" setting [CHAR LIMIT=80]-->
<string name="backup_configure_account_default_summary">No account is currently storing backed up data</string>
<!-- Auto-restore menu title -->
<string name="auto_restore_title">Automatic restore</string>
<!-- Summary text of the "automatic restore" setting -->
@@ -2984,22 +2985,34 @@ found in the list of installed applications.</string>
networks and the UI is showing one possible existing network.
Used in Wifi Setup. -->
<string name="wifi_setup_status_existing_network">Connect to existing network</string>
<!-- Message shown above available networks when a user clicked one of available
networks and the network doesn't require configuration (e.g. password)
Used in Wifi Setup with XL screen. [CHAR LIMIT=35] -->
<string name="wifi_setup_status_unsecured_network">Connect to unsecured network</string>
<!-- Message shown above available networks when a user clicked one of available
networks and the UI is prompting the user to edit the network configuration
if needed. Used in Wifi Setup with XL screen. [CHAR LIMIT=35] -->
<string name="wifi_setup_status_edit_network">Enter network configuration</string>
<!-- The message shown above available networks when a user clicked "Add network"
button. Used in Wifi Setup For Setup Wizard with XL screen. -->
button. Used in Wifi Setup For Setup Wizard with XL screen. [CHAR LIMIT=35] -->
<string name="wifi_setup_status_new_network">Connect to new network</string>
<!-- The message shown above available networks when a user clicked one of available
networks or created another profile and he/she is waiting for the connection
is established.
Used in Wifi Setup For Setup Wizard with XL screen. -->
Used in Wifi Setup For Setup Wizard with XL screen. [CHAR LIMIT=35] -->
<string name="wifi_setup_status_connecting">Connecting...</string>
<!-- The message shown above available networks when connection is established,
letting a user to proceed to the next step of the SetupWizard.
Used in Wifi Setup For Setup Wizard with XL screen. [CHAR LIMIT=35] -->
<string name="wifi_setup_status_proceed_to_next">Proceed to the next step</string>
<!-- The message shown above available networks when a user clicked a network secured by
EAP. We don't allow the user to connect it.
Used in Wifi Setup For Setup Wizard with XL screen. [CHAR LIMIT=35] -->
<string name="wifi_setup_status_eap_not_supported">EAP not supported</string>
<!-- Message shown when users select EAP in WiFi settings for SetupWizard,
saying EAP can't be configured in SetupWizard flow.
[CHAR LIMIT=NONE] -->
<string name="wifi_setup_eap_not_supported">You can\u0027t configure an EAP Wi-Fi connection during setup. After setup, you can do that in Settings, under Wireless &amp; Networks.</string>
<!-- Do not translate. This is a stub which will be removed soon. -->
<string name="time_zone_auto_stub" translatable="false">Select Time Zone</string>

View File

@@ -57,18 +57,20 @@
<PreferenceCategory android:key="keyboard_settings_category"
android:title="@string/keyboard_settings_category">
<PreferenceScreen android:key="input_method"
android:title="@string/input_method"
<PreferenceScreen android:key="current_input_method"
android:title="@string/current_input_method"
android:widgetLayout="@*android:layout/preference_dialog" />
<ListPreference android:key="input_method_selector"
android:title="@string/input_method_selector"
android:persistent="true"
android:entryValues="@array/input_method_selector_values"
android:entries="@array/input_method_selector_titles"
android:defaultValue="@string/input_method_selector_visibility_default_value"/>
<PreferenceScreen android:key="configure_input_method"
android:title="@string/configure_input_method">
<intent android:action="android.settings.INPUT_METHOD_SETTINGS"/>
</PreferenceScreen>
</PreferenceCategory>
<PreferenceScreen
android:fragment="com.android.settings.PhysicalKeyboardSettings"
android:key="hardkeyboard_category"
android:title="@string/builtin_keyboard_settings_title"
android:summary="@string/builtin_keyboard_settings_summary">
</PreferenceScreen>
</PreferenceScreen>

View File

@@ -26,11 +26,11 @@
android:summary="@string/backup_data_summary"
android:persistent="false" />
<PreferenceScreen
android:key="configure_transport"
android:dependency="backup_data"
android:layout="?android:attr/preferenceLayoutChild"
android:title="@string/backup_configure_transport_title"
android:summary="@string/backup_configure_transport_default_summary">
android:key="configure_account"
android:title="@string/backup_configure_account_title"
android:summary="@string/backup_configure_account_default_summary"
android:persistent="false">
<!-- the Intent declared here is always overwritten by a real one -->
<intent android:action="dummy" />
</PreferenceScreen>
<CheckBoxPreference

View File

@@ -42,7 +42,7 @@ public class PrivacySettings extends SettingsPreferenceFragment implements
private static final String BACKUP_CATEGORY = "backup_category";
private static final String BACKUP_DATA = "backup_data";
private static final String AUTO_RESTORE = "auto_restore";
private static final String CONFIGURE_TRANSPORT = "configure_transport";
private static final String CONFIGURE_ACCOUNT = "configure_account";
private IBackupManager mBackupManager;
private CheckBoxPreference mBackup;
private CheckBoxPreference mAutoRestore;
@@ -63,7 +63,7 @@ public class PrivacySettings extends SettingsPreferenceFragment implements
mBackup = (CheckBoxPreference) screen.findPreference(BACKUP_DATA);
mAutoRestore = (CheckBoxPreference) screen.findPreference(AUTO_RESTORE);
mConfigure = (PreferenceScreen) screen.findPreference(CONFIGURE_TRANSPORT);
mConfigure = (PreferenceScreen) screen.findPreference(CONFIGURE_ACCOUNT);
// Vendor specific
if (getActivity().getPackageManager().
@@ -152,7 +152,7 @@ public class PrivacySettings extends SettingsPreferenceFragment implements
if (configSummary != null) {
mConfigure.setSummary(configSummary);
} else {
mConfigure.setSummary(R.string.backup_configure_transport_default_summary);
mConfigure.setSummary(R.string.backup_configure_account_default_summary);
}
}

View File

@@ -302,6 +302,7 @@ public class Settings extends PreferenceActivity {
public static class StorageSettingsActivity extends Settings { }
public static class WifiSettingsActivity extends Settings { }
public static class InputMethodAndLanguageSettingsActivity extends Settings { }
public static class InputMethodConfigActivity extends Settings { }
public static class InputMethodAndSubtypeEnablerActivity extends Settings { }
public static class LocalePickerActivity extends Settings { }
public static class UserDictionarySettingsActivity extends Settings { }

View File

@@ -26,127 +26,74 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceGroup;
import android.preference.PreferenceScreen;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodManager;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment {
public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment
implements Preference.OnPreferenceChangeListener{
private static final String KEY_PHONE_LANGUAGE = "phone_language";
private static final String KEY_INPUT_METHOD = "input_method";
private static final String KEY_KEYBOARD_SETTINGS_CATEGORY = "keyboard_settings_category";
private static final String KEY_HARDKEYBOARD_CATEGORY = "hardkeyboard_category";
private boolean mHaveHardKeyboard;
private static final String KEY_CURRENT_INPUT_METHOD = "current_input_method";
private static final String KEY_INPUT_METHOD_SELECTOR = "input_method_selector";
private List<InputMethodInfo> mInputMethodProperties;
private List<CheckBoxPreference> mCheckboxes;
private int mDefaultInputMethodSelectorVisibility = 0;
private ListPreference mShowInputMethodSelectorPref;
private Preference mLanguagePref;
final TextUtils.SimpleStringSplitter mStringColonSplitter
= new TextUtils.SimpleStringSplitter(':');
private AlertDialog mDialog = null;
static public String getInputMethodIdFromKey(String key) {
return key;
}
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
addPreferencesFromResource(R.xml.language_settings);
try {
mDefaultInputMethodSelectorVisibility = Integer.valueOf(
getString(R.string.input_method_selector_visibility_default_value));
} catch (NumberFormatException e) {
}
if (getActivity().getAssets().getLocales().length == 1) {
getPreferenceScreen().
removePreference(findPreference(KEY_PHONE_LANGUAGE));
// No "Select language" pref if there's only one system locale available.
getPreferenceScreen().removePreference(findPreference(KEY_PHONE_LANGUAGE));
} else {
mLanguagePref = findPreference(KEY_PHONE_LANGUAGE);
}
Configuration config = getResources().getConfiguration();
if (config.keyboard != Configuration.KEYBOARD_QWERTY) {
getPreferenceScreen().removePreference(
getPreferenceScreen().findPreference(KEY_HARDKEYBOARD_CATEGORY));
} else {
mHaveHardKeyboard = true;
}
mCheckboxes = new ArrayList<CheckBoxPreference>();
onCreateIMM();
mShowInputMethodSelectorPref = (ListPreference)findPreference(
KEY_INPUT_METHOD_SELECTOR);
mShowInputMethodSelectorPref.setOnPreferenceChangeListener(this);
// TODO: Update current input method name on summary
updateInputMethodSelectorSummary(loadInputMethodSelectorVisibility());
new VoiceInputOutputSettings(this).onCreate();
}
private boolean isSystemIme(InputMethodInfo property) {
return (property.getServiceInfo().applicationInfo.flags
& ApplicationInfo.FLAG_SYSTEM) != 0;
}
private void onCreateIMM() {
InputMethodManager imm = (InputMethodManager) getSystemService(
Context.INPUT_METHOD_SERVICE);
mInputMethodProperties = imm.getInputMethodList();
PreferenceGroup keyboardSettingsCategory = (PreferenceGroup) findPreference(
KEY_KEYBOARD_SETTINGS_CATEGORY);
int N = (mInputMethodProperties == null ? 0 : mInputMethodProperties
.size());
for (int i = 0; i < N; ++i) {
InputMethodInfo property = mInputMethodProperties.get(i);
String prefKey = property.getId();
CharSequence label = property.loadLabel(getActivity().getPackageManager());
boolean systemIME = isSystemIme(property);
// Add a check box.
// Don't show the toggle if it's the only keyboard in the system, or it's a system IME.
if (mHaveHardKeyboard || (N > 1 && !systemIME)) {
CheckBoxPreference chkbxPref = new CheckBoxPreference(getActivity());
chkbxPref.setKey(prefKey);
chkbxPref.setTitle(label);
keyboardSettingsCategory.addPreference(chkbxPref);
mCheckboxes.add(chkbxPref);
}
// If setting activity is available, add a setting screen entry.
if (null != property.getSettingsActivity()) {
PreferenceScreen prefScreen = new PreferenceScreen(getActivity(), null);
String settingsActivity = property.getSettingsActivity();
if (settingsActivity.lastIndexOf("/") < 0) {
settingsActivity = property.getPackageName() + "/" + settingsActivity;
}
prefScreen.setKey(settingsActivity);
prefScreen.setTitle(label);
if (N == 1) {
prefScreen.setSummary(getResources().getString(
R.string.onscreen_keyboard_settings_summary));
} else {
CharSequence settingsLabel = getResources().getString(
R.string.input_methods_settings_label_format, label);
prefScreen.setSummary(settingsLabel);
}
keyboardSettingsCategory.addPreference(prefScreen);
}
private void updateInputMethodSelectorSummary(int value) {
String[] inputMethodSelectorTitles = getResources().getStringArray(
R.array.input_method_selector_titles);
if (inputMethodSelectorTitles.length > value) {
mShowInputMethodSelectorPref.setSummary(inputMethodSelectorTitles[value]);
mShowInputMethodSelectorPref.setValue(String.valueOf(value));
}
}
@Override
public void onResume() {
super.onResume();
InputMethodAndSubtypeUtil.loadInputMethodSubtypeList(
this, getContentResolver(), mInputMethodProperties);
if (mLanguagePref != null) {
Configuration conf = getResources().getConfiguration();
String locale = conf.locale.getDisplayName(conf.locale);
@@ -155,107 +102,58 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment {
mLanguagePref.setSummary(locale);
}
}
mShowInputMethodSelectorPref.setOnPreferenceChangeListener(this);
}
@Override
public void onPause() {
super.onPause();
InputMethodAndSubtypeUtil.saveInputMethodSubtypeList(this, getContentResolver(),
mInputMethodProperties, mHaveHardKeyboard);
mShowInputMethodSelectorPref.setOnPreferenceChangeListener(null);
}
@Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
// Input Method stuff
if (Utils.isMonkeyRunning()) {
return false;
}
if (preference instanceof CheckBoxPreference) {
final CheckBoxPreference chkPref = (CheckBoxPreference) preference;
final String id = getInputMethodIdFromKey(chkPref.getKey());
if (chkPref.isChecked()) {
InputMethodInfo selImi = null;
final int N = mInputMethodProperties.size();
for (int i=0; i<N; i++) {
InputMethodInfo imi = mInputMethodProperties.get(i);
if (id.equals(imi.getId())) {
selImi = imi;
if (isSystemIme(imi)) {
// This is a built-in IME, so no need to warn.
return super.onPreferenceTreeClick(preferenceScreen, preference);
}
}
}
chkPref.setChecked(false);
if (selImi == null) {
return super.onPreferenceTreeClick(preferenceScreen, preference);
}
if (mDialog == null) {
// TODO: DialogFragment?
mDialog = (new AlertDialog.Builder(getActivity()))
.setTitle(android.R.string.dialog_alert_title)
.setIcon(android.R.drawable.ic_dialog_alert)
.setCancelable(true)
.setPositiveButton(android.R.string.ok,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
chkPref.setChecked(true);
}
})
.setNegativeButton(android.R.string.cancel,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
})
.create();
} else {
if (mDialog.isShowing()) {
mDialog.dismiss();
}
}
mDialog.setMessage(getResources().getString(
R.string.ime_security_warning,
selImi.getServiceInfo().applicationInfo.loadLabel(getPackageManager())));
mDialog.show();
}
} else if (preference instanceof PreferenceScreen) {
if (preference instanceof PreferenceScreen) {
if (preference.getFragment() != null) {
// Fragment will be handled correctly by the super class.
} else if (KEY_INPUT_METHOD.equals(preference.getKey())) {
} else if (KEY_CURRENT_INPUT_METHOD.equals(preference.getKey())) {
final InputMethodManager imm = (InputMethodManager)
getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showInputMethodPicker();
} else if (preference.getIntent() == null) {
PreferenceScreen pref = (PreferenceScreen) preference;
String activityName = pref.getKey();
String packageName = activityName.substring(0, activityName
.lastIndexOf("."));
int slash = activityName.indexOf("/");
if (slash > 0) {
packageName = activityName.substring(0, slash);
activityName = activityName.substring(slash + 1);
}
if (activityName.length() > 0) {
Intent i = new Intent(Intent.ACTION_MAIN);
i.setClassName(packageName, activityName);
startActivity(i);
}
}
}
return super.onPreferenceTreeClick(preferenceScreen, preference);
}
@Override
public void onDestroy() {
super.onDestroy();
if (mDialog != null) {
mDialog.dismiss();
mDialog = null;
private void saveInputMethodSelectorVisibility(String value) {
try {
int intValue = Integer.valueOf(value);
Settings.Secure.putInt(getContentResolver(),
Settings.Secure.INPUT_METHOD_SELECTOR_VISIBILITY, intValue);
updateInputMethodSelectorSummary(intValue);
} catch(NumberFormatException e) {
}
}
private int loadInputMethodSelectorVisibility() {
return Settings.Secure.getInt(getContentResolver(),
Settings.Secure.INPUT_METHOD_SELECTOR_VISIBILITY,
mDefaultInputMethodSelectorVisibility);
}
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
if (preference == mShowInputMethodSelectorPref) {
if (value instanceof String) {
saveInputMethodSelectorVisibility((String)value);
}
}
return false;
}
}

View File

@@ -29,26 +29,32 @@ import android.preference.CheckBoxPreference;
import android.preference.Preference;
import android.preference.PreferenceCategory;
import android.preference.PreferenceScreen;
import android.text.TextUtils;
import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodManager;
import android.view.inputmethod.InputMethodSubtype;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class InputMethodAndSubtypeEnabler extends SettingsPreferenceFragment {
private boolean mHaveHardKeyboard;
private List<InputMethodInfo> mInputMethodProperties;
public static final String EXTRA_INPUT_METHOD_ID = "input_method_id";
private AlertDialog mDialog = null;
private boolean mHaveHardKeyboard;
final private HashMap<String, List<Preference>> mInputMethodPrefsMap =
new HashMap<String, List<Preference>>();
private List<InputMethodInfo> mInputMethodProperties;
private String mInputMethodId;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
Configuration config = getResources().getConfiguration();
mHaveHardKeyboard = (config.keyboard == Configuration.KEYBOARD_QWERTY);
mInputMethodId = getActivity().getIntent().getStringExtra(EXTRA_INPUT_METHOD_ID);
onCreateIMM();
setPreferenceScreen(createPreferenceHierarchy());
}
@@ -57,7 +63,7 @@ public class InputMethodAndSubtypeEnabler extends SettingsPreferenceFragment {
public void onResume() {
super.onResume();
InputMethodAndSubtypeUtil.loadInputMethodSubtypeList(
this, getContentResolver(), mInputMethodProperties);
this, getContentResolver(), mInputMethodProperties, mInputMethodPrefsMap);
}
@Override
@@ -156,53 +162,48 @@ public class InputMethodAndSubtypeEnabler extends SettingsPreferenceFragment {
PreferenceScreen root = getPreferenceManager().createPreferenceScreen(getActivity());
int N = (mInputMethodProperties == null ? 0 : mInputMethodProperties.size());
// TODO: Use iterator.
for (int i = 0; i < N; ++i) {
final InputMethodInfo imi = mInputMethodProperties.get(i);
if (imi.getSubtypes().size() <= 1) continue;
String imiId = imi.getId();
// Add to this subtype the list when no IME is specified or when the IME of this
// subtype is the specified IME.
if (!TextUtils.isEmpty(mInputMethodId) && !mInputMethodId.equals(imiId)) {
continue;
}
PreferenceCategory keyboardSettingsCategory = new PreferenceCategory(getActivity());
root.addPreference(keyboardSettingsCategory);
InputMethodInfo property = mInputMethodProperties.get(i);
String prefKey = property.getId();
PackageManager pm = getPackageManager();
CharSequence label = property.loadLabel(pm);
boolean systemIME = InputMethodAndSubtypeUtil.isSystemIme(property);
CharSequence label = imi.loadLabel(pm);
keyboardSettingsCategory.setTitle(label);
keyboardSettingsCategory.setTitle(getResources().getString(
R.string.input_methods_and_subtype_enabler_title_format, label));
keyboardSettingsCategory.setKey(imiId);
// Add a check box.
// Don't show the toggle if it's the only keyboard in the system, or it's a system IME.
if (mHaveHardKeyboard || (N > 1 && !systemIME)) {
CheckBoxPreference chkbxPref = new CheckBoxPreference(getActivity());
chkbxPref.setKey(prefKey);
chkbxPref.setTitle(label);
keyboardSettingsCategory.addPreference(chkbxPref);
}
ArrayList<InputMethodSubtype> subtypes = property.getSubtypes();
ArrayList<InputMethodSubtype> subtypes = imi.getSubtypes();
ArrayList<Preference> subtypePreferences = new ArrayList<Preference>();
if (subtypes.size() > 0) {
PreferenceCategory subtypesCategory = new PreferenceCategory(getActivity());
subtypesCategory.setTitle(getResources().getString(
R.string.input_methods_and_subtype_enabler_title_format, label));
root.addPreference(subtypesCategory);
for (InputMethodSubtype subtype: subtypes) {
CharSequence subtypeLabel;
int nameResId = subtype.getNameResId();
if (nameResId != 0) {
subtypeLabel = pm.getText(property.getPackageName(), nameResId,
property.getServiceInfo().applicationInfo);
subtypeLabel = pm.getText(imi.getPackageName(), nameResId,
imi.getServiceInfo().applicationInfo);
} else {
String mode = subtype.getMode();
CharSequence language = subtype.getLocale();
// TODO: Use more friendly Title and UI
subtypeLabel = (mode == null ? "" : mode) + ","
+ (language == null ? "" : language);
}
CheckBoxPreference chkbxPref = new CheckBoxPreference(getActivity());
chkbxPref.setKey(prefKey + subtype.hashCode());
chkbxPref.setKey(imiId + subtype.hashCode());
chkbxPref.setTitle(subtypeLabel);
chkbxPref.setSummary(label);
subtypesCategory.addPreference(chkbxPref);
keyboardSettingsCategory.addPreference(chkbxPref);
subtypePreferences.add(chkbxPref);
}
mInputMethodPrefsMap.put(imiId, subtypePreferences);
}
}
return root;

View File

@@ -21,6 +21,7 @@ import com.android.settings.SettingsPreferenceFragment;
import android.content.ContentResolver;
import android.content.pm.ApplicationInfo;
import android.preference.CheckBoxPreference;
import android.preference.Preference;
import android.preference.PreferenceScreen;
import android.provider.Settings;
import android.provider.Settings.SettingNotFoundException;
@@ -32,6 +33,7 @@ import android.view.inputmethod.InputMethodSubtype;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
public class InputMethodAndSubtypeUtil {
@@ -48,6 +50,42 @@ public class InputMethodAndSubtypeUtil {
private static final TextUtils.SimpleStringSplitter sStringInputMethodSubtypeSplitter
= new TextUtils.SimpleStringSplitter(INPUT_METHOD_SUBTYPE_SEPARATER);
private static void buildEnabledInputMethodsString(
StringBuilder builder, String imi, HashSet<String> subtypes) {
builder.append(imi);
// Inputmethod and subtypes are saved in the settings as follows:
// ime0;subtype0;subtype1:ime1;subtype0:ime2:ime3;subtype0;subtype1
for (String subtypeId: subtypes) {
builder.append(INPUT_METHOD_SUBTYPE_SEPARATER).append(subtypeId);
}
}
public static void buildInputMethodsAndSubtypesString(
StringBuilder builder, HashMap<String, HashSet<String>> imsList) {
boolean needsAppendSeparator = false;
for (String imi: imsList.keySet()) {
if (needsAppendSeparator) {
builder.append(INPUT_METHOD_SEPARATER);
} else {
needsAppendSeparator = true;
}
buildEnabledInputMethodsString(builder, imi, imsList.get(imi));
}
}
public static void buildDisabledSystemInputMethods(
StringBuilder builder, HashSet<String> imes) {
boolean needsAppendSeparator = false;
for (String ime: imes) {
if (needsAppendSeparator) {
builder.append(INPUT_METHOD_SEPARATER);
} else {
needsAppendSeparator = true;
}
builder.append(ime);
}
}
private static int getInputMethodSubtypeSelected(ContentResolver resolver) {
try {
return Settings.Secure.getInt(resolver,
@@ -96,82 +134,117 @@ public class InputMethodAndSubtypeUtil {
return imsList;
}
public static void saveInputMethodSubtypeList(
SettingsPreferenceFragment context, ContentResolver resolver,
List<InputMethodInfo> inputMethodProperties, boolean hasHardKeyboard) {
private static HashSet<String> getDisabledSystemIMEs(ContentResolver resolver) {
HashSet<String> set = new HashSet<String>();
String disabledIMEsStr = Settings.Secure.getString(
resolver, Settings.Secure.DISABLED_SYSTEM_INPUT_METHODS);
sStringInputMethodSplitter.setString(disabledIMEsStr);
while(sStringInputMethodSplitter.hasNext()) {
set.add(sStringInputMethodSplitter.next());
}
return set;
}
public static void saveInputMethodSubtypeList(SettingsPreferenceFragment context,
ContentResolver resolver, List<InputMethodInfo> inputMethodInfos,
boolean hasHardKeyboard) {
String currentInputMethodId = Settings.Secure.getString(resolver,
Settings.Secure.DEFAULT_INPUT_METHOD);
final int selectedInputMethodSubtype = getInputMethodSubtypeSelected(resolver);
HashMap<String, HashSet<String>> enabledIMEAndSubtypesMap =
getEnabledInputMethodsAndSubtypeList(resolver);
HashSet<String> disabledSystemIMEs = getDisabledSystemIMEs(resolver);
StringBuilder builder = new StringBuilder();
StringBuilder disabledSysImes = new StringBuilder();
int firstSubtypeHashCode = NOT_A_SUBTYPE_ID;
final boolean onlyOneIME = inputMethodProperties.size() == 1;
boolean existsSelectedIME = false;
for (InputMethodInfo property : inputMethodProperties) {
final String id = property.getId();
CheckBoxPreference pref = (CheckBoxPreference) context.findPreference(id);
boolean isCurrentInputMethod = id.equals(currentInputMethodId);
boolean systemIme = isSystemIme(property);
// TODO: Append subtypes by using the separator ";"
if (((onlyOneIME || systemIme) && !hasHardKeyboard)
|| (pref != null && pref.isChecked())) {
if (builder.length() > 0) builder.append(INPUT_METHOD_SEPARATER);
builder.append(id);
for (InputMethodSubtype subtype : property.getSubtypes()) {
final boolean onlyOneIME = inputMethodInfos.size() == 1;
boolean existsSelectedSubtype = false;
for (InputMethodInfo imi : inputMethodInfos) {
final String imiId = imi.getId();
Preference pref = context.findPreference(imiId);
if (pref == null) continue;
// In the Configure input method screen or in the subtype enabler screen.
// pref is instance of CheckBoxPreference in the Configure input method screen.
final boolean isImeChecked = (pref instanceof CheckBoxPreference) ?
((CheckBoxPreference) pref).isChecked()
: enabledIMEAndSubtypesMap.containsKey(imiId);
boolean isCurrentInputMethod = imiId.equals(currentInputMethodId);
boolean systemIme = isSystemIme(imi);
if (((onlyOneIME || systemIme) && !hasHardKeyboard) || isImeChecked) {
if (!enabledIMEAndSubtypesMap.containsKey(imiId)) {
// imiId has just been enabled
enabledIMEAndSubtypesMap.put(imiId, new HashSet<String>());
}
HashSet<String> subtypesSet = enabledIMEAndSubtypesMap.get(imiId);
for (InputMethodSubtype subtype : imi.getSubtypes()) {
final String subtypeHashCodeStr = String.valueOf(subtype.hashCode());
CheckBoxPreference subtypePref = (CheckBoxPreference) context.findPreference(
id + subtype.hashCode());
if (subtypePref != null && subtypePref.isChecked()) {
builder.append(INPUT_METHOD_SUBTYPE_SEPARATER).append(subtype.hashCode());
imiId + subtypeHashCodeStr);
// In the Configure input method screen which does not have subtype preferences.
if (subtypePref == null) continue;
if (subtypePref.isChecked()) {
subtypesSet.add(subtypeHashCodeStr);
if (isCurrentInputMethod) {
if (selectedInputMethodSubtype == subtype.hashCode()) {
existsSelectedIME = true;
} else if (firstSubtypeHashCode == NOT_A_SUBTYPE_ID) {
firstSubtypeHashCode = subtype.hashCode();
existsSelectedSubtype = true;
}
}
} else {
subtypesSet.remove(subtypeHashCodeStr);
}
}
} else if (isCurrentInputMethod) {
// We are processing the current input method, but found that it's not enabled.
// This means that the current input method has been uninstalled.
// If currentInputMethod is already uninstalled, InputMethodManagerService will
// find the applicable IME from the history and the system locale.
if (DEBUG) {
Log.d(TAG, "Current IME was uninstalled or disabled.");
} else {
enabledIMEAndSubtypesMap.remove(imiId);
if (isCurrentInputMethod) {
// We are processing the current input method, but found that it's not enabled.
// This means that the current input method has been uninstalled.
// If currentInputMethod is already uninstalled, InputMethodManagerService will
// find the applicable IME from the history and the system locale.
if (DEBUG) {
Log.d(TAG, "Current IME was uninstalled or disabled.");
}
}
}
// If it's a disabled system ime, add it to the disabled list so that it
// doesn't get enabled automatically on any changes to the package list
if (pref != null && !pref.isChecked() && systemIme && hasHardKeyboard) {
if (disabledSysImes.length() > 0) disabledSysImes.append(INPUT_METHOD_SEPARATER);
disabledSysImes.append(id);
if (systemIme && hasHardKeyboard) {
if (disabledSystemIMEs.contains(imiId)) {
if (isImeChecked) {
disabledSystemIMEs.remove(imiId);
}
} else {
if (!isImeChecked) {
disabledSystemIMEs.add(imiId);
}
}
}
}
StringBuilder builder = new StringBuilder();
buildInputMethodsAndSubtypesString(builder, enabledIMEAndSubtypesMap);
StringBuilder disabledSysImesBuilder = new StringBuilder();
buildDisabledSystemInputMethods(disabledSysImesBuilder, disabledSystemIMEs);
if (DEBUG) {
Log.d(TAG, "--- Save enabled inputmethod settings. :" + builder.toString());
Log.d(TAG, "--- Save disable system inputmethod settings. :"
+ disabledSysImes.toString());
+ disabledSysImesBuilder.toString());
Log.d(TAG, "--- Save default inputmethod settings. :" + currentInputMethodId);
}
// Redefines SelectedSubtype when all subtypes are unchecked or there is no subtype
// selected. And if the selected subtype of the current input method was disabled,
// We should reset the selected input method's subtype.
if (!existsSelectedIME || !isInputMethodSubtypeSelected(resolver)) {
if (!existsSelectedSubtype || !isInputMethodSubtypeSelected(resolver)) {
if (DEBUG) {
Log.d(TAG, "--- Set inputmethod subtype because it's not defined."
+ firstSubtypeHashCode);
Log.d(TAG, "--- Reset inputmethod subtype because it's not defined.");
}
putSelectedInputMethodSubtype(resolver, firstSubtypeHashCode);
putSelectedInputMethodSubtype(resolver, NOT_A_SUBTYPE_ID);
}
Settings.Secure.putString(resolver,
Settings.Secure.ENABLED_INPUT_METHODS, builder.toString());
Settings.Secure.putString(resolver,
Settings.Secure.DISABLED_SYSTEM_INPUT_METHODS, disabledSysImes.toString());
if (disabledSysImesBuilder.length() > 0) {
Settings.Secure.putString(resolver, Settings.Secure.DISABLED_SYSTEM_INPUT_METHODS,
disabledSysImesBuilder.toString());
}
// If the current input method is unset, InputMethodManagerService will find the applicable
// IME from the history and the system locale.
Settings.Secure.putString(resolver, Settings.Secure.DEFAULT_INPUT_METHOD,
@@ -180,18 +253,25 @@ public class InputMethodAndSubtypeUtil {
public static void loadInputMethodSubtypeList(
SettingsPreferenceFragment context, ContentResolver resolver,
List<InputMethodInfo> inputMethodProperties) {
List<InputMethodInfo> inputMethodInfos,
final Map<String, List<Preference>> inputMethodPrefsMap) {
HashMap<String, HashSet<String>> enabledSubtypes =
getEnabledInputMethodsAndSubtypeList(resolver);
getEnabledInputMethodsAndSubtypeList(resolver);
for (InputMethodInfo property : inputMethodProperties) {
final String id = property.getId();
CheckBoxPreference pref = (CheckBoxPreference) context.findPreference(id);
if (pref != null) {
boolean isEnabled = enabledSubtypes.containsKey(id);
pref.setChecked(isEnabled);
setSubtypesPreferenceEnabled(context, inputMethodProperties, id, isEnabled);
updateSubtypesPreferenceChecked(context, inputMethodProperties, enabledSubtypes);
for (InputMethodInfo imi : inputMethodInfos) {
final String imiId = imi.getId();
Preference pref = context.findPreference(imiId);
if (pref != null && pref instanceof CheckBoxPreference) {
CheckBoxPreference checkBoxPreference = (CheckBoxPreference) pref;
boolean isEnabled = enabledSubtypes.containsKey(imiId);
checkBoxPreference.setChecked(isEnabled);
if (inputMethodPrefsMap != null) {
for (Preference childPref: inputMethodPrefsMap.get(imiId)) {
childPref.setEnabled(isEnabled);
}
}
setSubtypesPreferenceEnabled(context, inputMethodInfos, imiId, isEnabled);
updateSubtypesPreferenceChecked(context, inputMethodInfos, enabledSubtypes);
}
}
}

View File

@@ -0,0 +1,237 @@
/*
* Copyright (C) 2010 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.inputmethod;
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.Preference;
import android.preference.PreferenceCategory;
import android.preference.PreferenceScreen;
import android.provider.Settings;
import android.text.TextUtils;
import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodManager;
import java.util.ArrayList;
import java.util.HashMap;
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 AlertDialog mDialog = null;
private boolean mHaveHardKeyboard;
// Map of imi and its preferences
final private HashMap<String, List<Preference>> mInputMethodPrefsMap =
new HashMap<String, List<Preference>>();
private List<InputMethodInfo> mInputMethodProperties;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
Configuration config = getResources().getConfiguration();
mHaveHardKeyboard = (config.keyboard == Configuration.KEYBOARD_QWERTY);
InputMethodManager imm = (InputMethodManager) getSystemService(
Context.INPUT_METHOD_SERVICE);
// TODO: Change mInputMethodProperties to Map
mInputMethodProperties = imm.getInputMethodList();
setPreferenceScreen(createPreferenceHierarchy());
}
@Override
public void onResume() {
super.onResume();
InputMethodAndSubtypeUtil.loadInputMethodSubtypeList(
this, getContentResolver(), mInputMethodProperties, mInputMethodPrefsMap);
}
@Override
public void onPause() {
super.onPause();
InputMethodAndSubtypeUtil.saveInputMethodSubtypeList(this, getContentResolver(),
mInputMethodProperties, mHaveHardKeyboard);
}
private void showSecurityWarnDialog(InputMethodInfo imi, final CheckBoxPreference chkPref,
final String imiId) {
if (mDialog == null) {
mDialog = (new AlertDialog.Builder(getActivity()))
.setTitle(android.R.string.dialog_alert_title)
.setIcon(android.R.drawable.ic_dialog_alert)
.setCancelable(true)
.setPositiveButton(android.R.string.ok,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
chkPref.setChecked(true);
for (Preference pref: mInputMethodPrefsMap.get(imiId)) {
pref.setEnabled(true);
}
}
})
.setNegativeButton(android.R.string.cancel,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
})
.create();
} else {
if (mDialog.isShowing()) {
mDialog.dismiss();
}
}
mDialog.setMessage(getResources().getString(R.string.ime_security_warning,
imi.getServiceInfo().applicationInfo.loadLabel(getPackageManager())));
mDialog.show();
}
private InputMethodInfo getInputMethodInfoFromImiId(String imiId) {
final int N = mInputMethodProperties.size();
for (int i = 0; i < N; ++i) {
InputMethodInfo imi = mInputMethodProperties.get(i);
if (imiId.equals(imi.getId())) {
return imi;
}
}
return null;
}
@Override
public boolean onPreferenceTreeClick(
PreferenceScreen preferenceScreen, Preference preference) {
if (preference instanceof CheckBoxPreference) {
final CheckBoxPreference chkPref = (CheckBoxPreference) preference;
final String imiId = chkPref.getKey();
if (chkPref.isChecked()) {
InputMethodInfo selImi = getInputMethodInfoFromImiId(imiId);
if (selImi != null) {
if (InputMethodAndSubtypeUtil.isSystemIme(selImi)) {
// This is a built-in IME, so no need to warn.
return super.onPreferenceTreeClick(preferenceScreen, preference);
}
} else {
return super.onPreferenceTreeClick(preferenceScreen, preference);
}
chkPref.setChecked(false);
showSecurityWarnDialog(selImi, chkPref, imiId);
} else {
for (Preference pref: mInputMethodPrefsMap.get(imiId)) {
pref.setEnabled(false);
}
}
}
return super.onPreferenceTreeClick(preferenceScreen, preference);
}
@Override
public void onDestroy() {
super.onDestroy();
if (mDialog != null) {
mDialog.dismiss();
mDialog = null;
}
}
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());
root.addPreference(keyboardSettingsCategory);
final String imiId = imi.getId();
mInputMethodPrefsMap.put(imiId, new ArrayList<Preference>());
PackageManager pm = getPackageManager();
CharSequence label = imi.loadLabel(pm);
keyboardSettingsCategory.setTitle(label);
final boolean isSystemIME = InputMethodAndSubtypeUtil.isSystemIme(imi);
// Add a check box for enabling/disabling IME
CheckBoxPreference chkbxPref = new CheckBoxPreference(getActivity());
chkbxPref.setKey(imiId);
chkbxPref.setTitle(label);
keyboardSettingsCategory.addPreference(chkbxPref);
// Disable the toggle if it's the only keyboard in the system, or it's a system IME.
if (!mHaveHardKeyboard && (imiSize <= 1 || isSystemIME)) {
chkbxPref.setEnabled(false);
}
Intent intent;
// Add subtype settings when this IME has two or more subtypes.
PreferenceScreen prefScreen = new PreferenceScreen(getActivity(), null);
prefScreen.setTitle(R.string.active_input_method_subtypes);
if (imi.getSubtypes().size() > 1) {
intent = new Intent(Settings.ACTION_INPUT_METHOD_AND_SUBTYPE_ENABLER);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
| Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra(InputMethodAndSubtypeEnabler.EXTRA_INPUT_METHOD_ID, imiId);
prefScreen.setIntent(intent);
keyboardSettingsCategory.addPreference(prefScreen);
mInputMethodPrefsMap.get(imiId).add(prefScreen);
}
// Add IME settings
String settingsActivity = imi.getSettingsActivity();
if (!TextUtils.isEmpty(settingsActivity)) {
prefScreen = new PreferenceScreen(getActivity(), null);
prefScreen.setTitle(R.string.input_method_settings);
intent = new Intent(Intent.ACTION_MAIN);
intent.setClassName(imi.getPackageName(), settingsActivity);
prefScreen.setIntent(intent);
keyboardSettingsCategory.addPreference(prefScreen);
mInputMethodPrefsMap.get(imiId).add(prefScreen);
}
}
private PreferenceScreen createPreferenceHierarchy() {
// Root
PreferenceScreen root = getPreferenceManager().createPreferenceScreen(getActivity());
if (mHaveHardKeyboard) {
addHardKeyboardPreference(root);
}
final int N = (mInputMethodProperties == null ? 0 : mInputMethodProperties.size());
for (int i = 0; i < N; ++i) {
addInputMethodPreference(root, mInputMethodProperties.get(i), N);
}
return root;
}
}

View File

@@ -121,6 +121,9 @@ public class WifiConfigController implements TextWatcher,
private ProxySettings mProxySettings;
private LinkProperties mLinkProperties = new LinkProperties();
// True when this instance is used in SetupWizard XL context.
private final boolean mInXlSetupWizard;
static boolean requireKeyStore(WifiConfiguration config) {
if (config == null) {
return false;
@@ -138,6 +141,7 @@ public class WifiConfigController implements TextWatcher,
public WifiConfigController(
WifiConfigUiBase parent, View view, AccessPoint accessPoint, boolean edit) {
mConfigUi = parent;
mInXlSetupWizard = (parent instanceof WifiConfigUiForSetupWizardXL);
mView = view;
mAccessPoint = accessPoint;
@@ -474,6 +478,13 @@ public class WifiConfigController implements TextWatcher,
if (mAccessPointSecurity == AccessPoint.SECURITY_NONE) {
mView.findViewById(R.id.security_fields).setVisibility(View.GONE);
return;
} else if (mAccessPointSecurity == AccessPoint.SECURITY_EAP && mInXlSetupWizard) {
// In SetupWizard for XLarge screen, we don't have enough space for showing
// configurations needed for EAP. We instead disable the whole feature there and let
// users configure those networks after the setup.
mView.findViewById(R.id.eap_not_supported).setVisibility(View.VISIBLE);
mView.findViewById(R.id.security_fields).setVisibility(View.GONE);
return;
}
mView.findViewById(R.id.security_fields).setVisibility(View.VISIBLE);

View File

@@ -33,11 +33,15 @@ import android.provider.Settings;
import android.text.TextUtils;
import android.widget.Toast;
import java.util.concurrent.atomic.AtomicBoolean;
public class WifiEnabler implements Preference.OnPreferenceChangeListener {
private final Context mContext;
private final Context mContext;
private final CheckBoxPreference mCheckBox;
private final CharSequence mOriginalSummary;
private AtomicBoolean mConnected = new AtomicBoolean(false);
private final WifiManager mWifiManager;
private final IntentFilter mIntentFilter;
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
@@ -48,11 +52,15 @@ public class WifiEnabler implements Preference.OnPreferenceChangeListener {
handleWifiStateChanged(intent.getIntExtra(
WifiManager.EXTRA_WIFI_STATE, WifiManager.WIFI_STATE_UNKNOWN));
} else if (WifiManager.SUPPLICANT_STATE_CHANGED_ACTION.equals(action)) {
handleStateChanged(WifiInfo.getDetailedStateOf((SupplicantState)
intent.getParcelableExtra(WifiManager.EXTRA_NEW_STATE)));
if (!mConnected.get()) {
handleStateChanged(WifiInfo.getDetailedStateOf((SupplicantState)
intent.getParcelableExtra(WifiManager.EXTRA_NEW_STATE)));
}
} else if (WifiManager.NETWORK_STATE_CHANGED_ACTION.equals(action)) {
handleStateChanged(((NetworkInfo) intent.getParcelableExtra(
WifiManager.EXTRA_NETWORK_INFO)).getDetailedState());
NetworkInfo info = (NetworkInfo) intent.getParcelableExtra(
WifiManager.EXTRA_NETWORK_INFO);
mConnected.set(info.isConnected());
handleStateChanged(info.getDetailedState());
}
}
};
@@ -75,15 +83,15 @@ public class WifiEnabler implements Preference.OnPreferenceChangeListener {
mContext.registerReceiver(mReceiver, mIntentFilter);
mCheckBox.setOnPreferenceChangeListener(this);
}
public void pause() {
mContext.unregisterReceiver(mReceiver);
mCheckBox.setOnPreferenceChangeListener(null);
}
public boolean onPreferenceChange(Preference preference, Object value) {
boolean enable = (Boolean) value;
// Show toast message if Wi-Fi is not allowed in airplane mode
if (enable && !WirelessSettings
.isRadioAllowed(mContext, Settings.System.RADIO_WIFI)) {
@@ -109,7 +117,7 @@ public class WifiEnabler implements Preference.OnPreferenceChangeListener {
// Don't update UI to opposite state until we're sure
return false;
}
private void handleWifiStateChanged(int state) {
switch (state) {
case WifiManager.WIFI_STATE_ENABLING:

View File

@@ -265,7 +265,6 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis
mProgressBar.setIndeterminate(false);
mProgressBar.setProgress(0);
mStatusText.setText(stateString);
mProgressText.setText(stateString);
mAddNetworkButton.setEnabled(true);
@@ -322,7 +321,13 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis
}
// parent.addView(view);
mStatusText.setText(R.string.wifi_setup_status_edit_network);
if (selectedAccessPoint.security == AccessPoint.SECURITY_NONE) {
mStatusText.setText(R.string.wifi_setup_status_unsecured_network);
} else if (selectedAccessPoint.security == AccessPoint.SECURITY_EAP) {
mStatusText.setText(R.string.wifi_setup_status_eap_not_supported);
} else {
mStatusText.setText(R.string.wifi_setup_status_edit_network);
}
mAddNetworkButton.setVisibility(View.GONE);
mRefreshButton.setVisibility(View.GONE);
mSkipOrNextButton.setVisibility(View.GONE);