From ee2937941d4e9a4d2cd94d504ddaa9685bcca090 Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Mon, 1 Nov 2010 12:32:33 -0700 Subject: [PATCH 1/3] Further manage apps fragmentization. All of the UI under manage apps should now be working. Various cleanup through new framework APIs. Fragmentized developer settings. Change-Id: I2b42a2dd0d015e0fdcde497579ddad3dceea9da2 --- AndroidManifest.xml | 19 +-- res/xml/application_settings.xml | 17 +- .../android/settings/DevelopmentSettings.java | 34 ++-- src/com/android/settings/Settings.java | 4 +- .../applications/InstalledAppDetails.java | 15 +- .../applications/ManageApplications.java | 103 ++++++----- .../applications/RunningProcessesView.java | 30 +++- .../applications/RunningServiceDetails.java | 161 ++++++++++-------- 8 files changed, 220 insertions(+), 163 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 66c9bfd2163..4729785db31 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -457,7 +457,7 @@ + android:targetActivity="Settings"> @@ -470,7 +470,7 @@ + android:targetActivity="Settings"> @@ -480,11 +480,6 @@ - - - - + - - + diff --git a/res/xml/application_settings.xml b/res/xml/application_settings.xml index 6cd0b620732..76fa0bcd50a 100644 --- a/res/xml/application_settings.xml +++ b/res/xml/application_settings.xml @@ -44,25 +44,24 @@ + android:fragment="com.android.settings.applications.ManageApplications" + android:title="@string/manageapplications_settings_title" + android:summary="@string/manageapplications_settings_summary"> - + - + Date: Mon, 1 Nov 2010 14:23:25 -0700 Subject: [PATCH 2/3] Remove channel control from debug builds We dont need this in the UI now that channel settings is gone. The country code setting can be done from CLI for debug purposes. Bug: 2936741 Change-Id: Ic61abac30af99611af4d67662355068cea6dd4ed --- res/values/strings.xml | 8 -- res/xml/wifi_advanced_settings.xml | 7 -- .../settings/wifi/AdvancedSettings.java | 87 +------------------ 3 files changed, 4 insertions(+), 98 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index d51001838c2..2d1a599a4a7 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -999,14 +999,6 @@ Advanced - - Regulatory domain - - Set the number of channels to use - - There was a problem setting the regulatory domain. - - %1$d channels Wi-Fi sleep policy diff --git a/res/xml/wifi_advanced_settings.xml b/res/xml/wifi_advanced_settings.xml index 84964285757..7ccd58803c1 100644 --- a/res/xml/wifi_advanced_settings.xml +++ b/res/xml/wifi_advanced_settings.xml @@ -17,13 +17,6 @@ - - = 0) { - pref.setValue(String.valueOf(numChannels)); - } - } - private void initSleepPolicyPreference() { ListPreference pref = (ListPreference) findPreference(KEY_SLEEP_POLICY); pref.setOnPreferenceChangeListener(this); @@ -133,21 +68,7 @@ public class AdvancedSettings extends SettingsPreferenceFragment String key = preference.getKey(); if (key == null) return true; - if (key.equals(KEY_NUM_CHANNELS)) { - try { - int numChannels = Integer.parseInt((String) newValue); - WifiManager wifiManager = (WifiManager) getSystemService(Activity.WIFI_SERVICE); - if (!wifiManager.setNumAllowedChannels(numChannels, true)) { - Toast.makeText(getActivity(), R.string.wifi_setting_num_channels_error, - Toast.LENGTH_SHORT).show(); - } - } catch (NumberFormatException e) { - Toast.makeText(getActivity(), R.string.wifi_setting_num_channels_error, - Toast.LENGTH_SHORT).show(); - return false; - } - - } else if (key.equals(KEY_SLEEP_POLICY)) { + if (key.equals(KEY_SLEEP_POLICY)) { try { Settings.System.putInt(getContentResolver(), Settings.System.WIFI_SLEEP_POLICY, Integer.parseInt(((String) newValue))); @@ -157,7 +78,7 @@ public class AdvancedSettings extends SettingsPreferenceFragment return false; } } - + return true; } @@ -167,7 +88,7 @@ public class AdvancedSettings extends SettingsPreferenceFragment Preference wifiMacAddressPref = findPreference(KEY_MAC_ADDRESS); String macAddress = wifiInfo == null ? null : wifiInfo.getMacAddress(); - wifiMacAddressPref.setSummary(!TextUtils.isEmpty(macAddress) ? macAddress + wifiMacAddressPref.setSummary(!TextUtils.isEmpty(macAddress) ? macAddress : getActivity().getString(R.string.status_unavailable)); Preference wifiIpAddressPref = findPreference(KEY_CURRENT_IP_ADDRESS); From 3de7021756efd7fc9082b8768bc9a38fa310e7d8 Mon Sep 17 00:00:00 2001 From: satok Date: Mon, 1 Nov 2010 22:30:29 +0900 Subject: [PATCH 3/3] Save and update enabled Subtypes in InputMethodAndSubtypeEnabler Change-Id: I01ce22b7cc17457dde34967957a27658067ec674 --- .../InputMethodAndSubtypeUtil.java | 188 ++++++++++++++---- 1 file changed, 144 insertions(+), 44 deletions(-) diff --git a/src/com/android/settings/inputmethod/InputMethodAndSubtypeUtil.java b/src/com/android/settings/inputmethod/InputMethodAndSubtypeUtil.java index 72a17658c83..e98b1e90adb 100644 --- a/src/com/android/settings/inputmethod/InputMethodAndSubtypeUtil.java +++ b/src/com/android/settings/inputmethod/InputMethodAndSubtypeUtil.java @@ -23,97 +23,173 @@ import android.content.pm.ApplicationInfo; import android.preference.CheckBoxPreference; import android.preference.PreferenceScreen; import android.provider.Settings; +import android.provider.Settings.SettingNotFoundException; import android.text.TextUtils; +import android.util.Log; import android.view.inputmethod.InputMethodInfo; import android.view.inputmethod.InputMethodSubtype; +import java.util.HashMap; import java.util.HashSet; import java.util.List; public class InputMethodAndSubtypeUtil { - private static final TextUtils.SimpleStringSplitter sStringColonSplitter - = new TextUtils.SimpleStringSplitter(':'); + private static final boolean DEBUG = false; + static final String TAG = "InputMethdAndSubtypeUtil"; + + private static final char INPUT_METHOD_SEPARATER = ':'; + private static final char INPUT_METHOD_SUBTYPE_SEPARATER = ';'; + private static final int NOT_A_SUBTYPE_ID = -1; + + private static final TextUtils.SimpleStringSplitter sStringInputMethodSplitter + = new TextUtils.SimpleStringSplitter(INPUT_METHOD_SEPARATER); + + private static final TextUtils.SimpleStringSplitter sStringInputMethodSubtypeSplitter + = new TextUtils.SimpleStringSplitter(INPUT_METHOD_SUBTYPE_SEPARATER); + + private static boolean isInputMethodSubtypeSelected(ContentResolver resolver) { + try { + return Settings.Secure.getInt(resolver, + Settings.Secure.SELECTED_INPUT_METHOD_SUBTYPE) != NOT_A_SUBTYPE_ID; + } catch (SettingNotFoundException e) { + return false; + } + } + + private static void putSelectedInputMethodSubtype(ContentResolver resolver, int hashCode) { + Settings.Secure.putInt(resolver, Settings.Secure.SELECTED_INPUT_METHOD_SUBTYPE, hashCode); + } + + // Needs to modify InputMethodManageService if you want to change the format of saved string. + private static HashMap> getEnabledInputMethodsAndSubtypeList( + ContentResolver resolver) { + final String enabledInputMethodsStr = Settings.Secure.getString( + resolver, Settings.Secure.ENABLED_INPUT_METHODS); + HashMap> imsList + = new HashMap>(); + if (DEBUG) { + Log.d(TAG, "--- Load enabled input methods: " + enabledInputMethodsStr); + } + + if (TextUtils.isEmpty(enabledInputMethodsStr)) { + return imsList; + } + sStringInputMethodSplitter.setString(enabledInputMethodsStr); + while (sStringInputMethodSplitter.hasNext()) { + String nextImsStr = sStringInputMethodSplitter.next(); + sStringInputMethodSubtypeSplitter.setString(nextImsStr); + if (sStringInputMethodSubtypeSplitter.hasNext()) { + HashSet subtypeHashes = new HashSet(); + // The first element is ime id. + String imeId = sStringInputMethodSubtypeSplitter.next(); + while (sStringInputMethodSubtypeSplitter.hasNext()) { + subtypeHashes.add(sStringInputMethodSubtypeSplitter.next()); + } + imsList.put(imeId, subtypeHashes); + } + } + return imsList; + } public static void saveInputMethodSubtypeList( SettingsPreferenceFragment context, ContentResolver resolver, List inputMethodProperties, boolean hasHardKeyboard, String lastTickedInputMethodId) { - String lastInputMethodId = Settings.Secure.getString(resolver, + String currentInputMethodId = Settings.Secure.getString(resolver, Settings.Secure.DEFAULT_INPUT_METHOD); StringBuilder builder = new StringBuilder(); StringBuilder disabledSysImes = new StringBuilder(); + InputMethodInfo firstEnabledIMI = null; + int firstSubtypeHashCode = NOT_A_SUBTYPE_ID; - int firstEnabled = -1; - int N = inputMethodProperties.size(); - for (int i = 0; i < N; ++i) { - final InputMethodInfo property = inputMethodProperties.get(i); + final boolean onlyOneIME = inputMethodProperties.size() == 1; + for (InputMethodInfo property : inputMethodProperties) { final String id = property.getId(); CheckBoxPreference pref = (CheckBoxPreference) context.findPreference(id); - boolean currentInputMethod = id.equals(lastInputMethodId); + boolean isCurrentInputMethod = id.equals(currentInputMethodId); boolean systemIme = isSystemIme(property); // TODO: Append subtypes by using the separator ";" - if (((N == 1 || systemIme) && !hasHardKeyboard) + if (((onlyOneIME || systemIme) && !hasHardKeyboard) || (pref != null && pref.isChecked())) { - if (builder.length() > 0) builder.append(':'); + if (builder.length() > 0) builder.append(INPUT_METHOD_SEPARATER); builder.append(id); - if (firstEnabled < 0) { - firstEnabled = i; + if (firstEnabledIMI == null) { + firstEnabledIMI = property; } - } else if (currentInputMethod) { - lastInputMethodId = lastTickedInputMethodId; + for (InputMethodSubtype subtype : property.getSubtypes()) { + CheckBoxPreference subtypePref = (CheckBoxPreference) context.findPreference( + id + subtype.hashCode()); + if (subtypePref != null && subtypePref.isChecked()) { + builder.append(INPUT_METHOD_SUBTYPE_SEPARATER).append(subtype.hashCode()); + if (firstSubtypeHashCode == NOT_A_SUBTYPE_ID) { + firstSubtypeHashCode = subtype.hashCode(); + } + } + } + } 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, selects last ticked IME + currentInputMethodId = lastTickedInputMethodId; } // 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(":"); + if (disabledSysImes.length() > 0) disabledSysImes.append(INPUT_METHOD_SEPARATER); disabledSysImes.append(id); } } // If the last input method is unset, set it as the first enabled one. - if (TextUtils.isEmpty(lastInputMethodId)) { - if (firstEnabled >= 0) { - lastInputMethodId = inputMethodProperties.get(firstEnabled).getId(); + if (TextUtils.isEmpty(currentInputMethodId)) { + if (firstEnabledIMI != null) { + currentInputMethodId = firstEnabledIMI.getId(); } else { - lastInputMethodId = null; + currentInputMethodId = null; } } + if (DEBUG) { + Log.d(TAG, "--- Save enabled inputmethod settings. :" + builder.toString()); + Log.d(TAG, "--- Save disable system inputmethod settings. :" + + disabledSysImes.toString()); + Log.d(TAG, "--- Save default inputmethod settings. :" + currentInputMethodId); + } + + // redefines SelectedSubtype when all subtypes are unchecked or there is no subtype + // selected. + if (firstSubtypeHashCode == NOT_A_SUBTYPE_ID || !isInputMethodSubtypeSelected(resolver)) { + if (DEBUG) { + Log.d(TAG, "--- Set inputmethod subtype because it's not defined." + + firstSubtypeHashCode); + } + putSelectedInputMethodSubtype(resolver, firstSubtypeHashCode); + } + Settings.Secure.putString(resolver, Settings.Secure.ENABLED_INPUT_METHODS, builder.toString()); Settings.Secure.putString(resolver, Settings.Secure.DISABLED_SYSTEM_INPUT_METHODS, disabledSysImes.toString()); Settings.Secure.putString(resolver, Settings.Secure.DEFAULT_INPUT_METHOD, - lastInputMethodId != null ? lastInputMethodId : ""); + currentInputMethodId != null ? currentInputMethodId : ""); } public static void loadInputMethodSubtypeList( SettingsPreferenceFragment context, ContentResolver resolver, List inputMethodProperties) { - final HashSet enabled = new HashSet(); - String enabledStr = Settings.Secure.getString(resolver, - Settings.Secure.ENABLED_INPUT_METHODS); - if (enabledStr != null) { - final TextUtils.SimpleStringSplitter splitter = sStringColonSplitter; - splitter.setString(enabledStr); - while (splitter.hasNext()) { - enabled.add(splitter.next()); - } - } + HashMap> enabledSubtypes = + getEnabledInputMethodsAndSubtypeList(resolver); - // Update the statuses of the Check Boxes. - int N = inputMethodProperties.size(); - // TODO: Use iterator. - for (int i = 0; i < N; ++i) { - final String id = inputMethodProperties.get(i).getId(); - CheckBoxPreference pref = (CheckBoxPreference) context.findPreference( - inputMethodProperties.get(i).getId()); + for (InputMethodInfo property : inputMethodProperties) { + final String id = property.getId(); + CheckBoxPreference pref = (CheckBoxPreference) context.findPreference(id); if (pref != null) { - boolean isEnabled = enabled.contains(id); + boolean isEnabled = enabledSubtypes.containsKey(id); pref.setChecked(isEnabled); setSubtypesPreferenceEnabled(context, inputMethodProperties, id, isEnabled); + updateSubtypesPreferenceChecked(context, inputMethodProperties, enabledSubtypes); } } } @@ -121,17 +197,41 @@ public class InputMethodAndSubtypeUtil { public static void setSubtypesPreferenceEnabled(SettingsPreferenceFragment context, List inputMethodProperties, String id, boolean enabled) { PreferenceScreen preferenceScreen = context.getPreferenceScreen(); - final int N = inputMethodProperties.size(); - // TODO: Use iterator. - for (int i = 0; i < N; i++) { - InputMethodInfo imi = inputMethodProperties.get(i); + for (InputMethodInfo imi : inputMethodProperties) { if (id.equals(imi.getId())) { - for (InputMethodSubtype subtype: imi.getSubtypes()) { - preferenceScreen.findPreference(id + subtype.hashCode()).setEnabled(enabled); + for (InputMethodSubtype subtype : imi.getSubtypes()) { + CheckBoxPreference pref = (CheckBoxPreference) preferenceScreen.findPreference( + id + subtype.hashCode()); + if (pref != null) { + pref.setEnabled(enabled); + } } } } } + + public static void updateSubtypesPreferenceChecked(SettingsPreferenceFragment context, + List inputMethodProperties, + HashMap> enabledSubtypes) { + PreferenceScreen preferenceScreen = context.getPreferenceScreen(); + for (InputMethodInfo imi : inputMethodProperties) { + String id = imi.getId(); + HashSet enabledSubtypesSet = enabledSubtypes.get(id); + for (InputMethodSubtype subtype : imi.getSubtypes()) { + String hashCode = String.valueOf(subtype.hashCode()); + if (DEBUG) { + Log.d(TAG, "--- Set checked state: " + "id" + ", " + hashCode + ", " + + enabledSubtypesSet.contains(hashCode)); + } + CheckBoxPreference pref = (CheckBoxPreference) preferenceScreen.findPreference( + id + hashCode); + if (pref != null) { + pref.setChecked(enabledSubtypesSet.contains(hashCode)); + } + } + } + } + public static boolean isSystemIme(InputMethodInfo property) { return (property.getServiceInfo().applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0;