Merge "Fix bug #14323469 Settings crash on selecting keyword from recent searches ... after changing orientation"
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index b84075a..2794d9d 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -987,21 +987,6 @@
android:resource="@id/accessibility_settings" />
</activity>
- <activity android:name="Settings$AccessibilityContrastSettingsActivity"
- android:label="@string/accessibility_display_contrast_preference_title"
- android:taskAffinity="com.android.settings"
- android:parentActivityName="Settings$AccessibilitySettingsActivity">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <action android:name="com.android.settings.ACCESSIBILITY_CONTRAST_SETTINGS" />
- <category android:name="android.intent.category.DEFAULT" />
- </intent-filter>
- <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
- android:value="com.android.settings.accessibility.ToggleContrastPreferenceFragment" />
- <meta-data android:name="com.android.settings.TOP_LEVEL_HEADER_ID"
- android:resource="@id/accessibility_settings" />
- </activity>
-
<activity android:name="Settings$AccessibilityDaltonizerSettingsActivity"
android:label="@string/accessibility_display_daltonizer_preference_title"
android:taskAffinity="com.android.settings"
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index 6d0cd76..5d1a9b6 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -1171,20 +1171,6 @@
<item>critical</item>
</string-array>
- <!-- Display color inversion modes for accessibility -->
- <string-array name="inversion_type_entries">
- <item>Standard</item>
- <item>Hue only</item>
- <item>Value only</item>
- </string-array>
-
- <!-- Values for display color inversion modes -->
- <string-array name="inversion_type_values" translatable="false">
- <item>0</item>
- <item>1</item>
- <item>2</item>
- </string-array>
-
<!-- Display color space adjustment modes for accessibility -->
<string-array name="daltonizer_type_entries" translatable="false">
<item>@string/daltonizer_mode_deuteranomaly</item>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 4c605a4..06f89bf 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -3362,8 +3362,6 @@
<string name="accessibility_toggle_speak_password_preference_title">Speak passwords</string>
<!-- Title for accessibility preference to choose long-press delay i.e. timeout before it is detected. [CHAR LIMIT=35] -->
<string name="accessibility_long_press_timeout_preference_title">Touch & hold delay</string>
- <!-- Title for the accessibility preference to configure display contrast enhancement. [CHAR LIMIT=NONE] -->
- <string name="accessibility_display_contrast_preference_title">Contrast enhancement</string>
<!-- Title for the accessibility preference to configure display color inversion. [CHAR LIMIT=NONE] -->
<string name="accessibility_display_inversion_preference_title">Color inversion</string>
<!-- Title for the accessibility preference to configure display color space correction. [CHAR LIMIT=NONE] -->
@@ -3371,12 +3369,6 @@
<!-- Title for the preference to show a tile for a particular feature in the Quick Settings pane. [CHAR LIMIT=NONE] -->
<string name="enable_quick_setting">Show in Quick Settings</string>
- <!-- Title for the preference to configure contrast enhancement's brightness level. [CHAR LIMIT=NONE] -->
- <string name="contrast_brightness">Brightness</string>
- <!-- Title for the preference to configure contrast enhancement's contrast level. [CHAR LIMIT=NONE] -->
- <string name="contrast_contrast">Contrast</string>
- <!-- Title for the preference to configure the type of color inversion to apply. [CHAR LIMIT=NONE] -->
- <string name="inversion_type">Inversion mode</string>
<!-- Title for the preference to configure the type of color space correction to apply. [CHAR LIMIT=NONE] -->
<string name="daltonizer_type">Correction mode</string>
<!-- Summary shown for color space correction preference when its value is overridden by another preference [CHAR LIMIT=35] -->
@@ -4842,8 +4834,10 @@
<string name="user_settings_title">Users</string>
<!-- User settings header for list of users and profiles [CHAR LIMIT=40] -->
<string name="user_list_title">Users & profiles</string>
+ <!-- User settings add user or restricted profile menu [CHAR LIMIT=35] -->
+ <string name="user_add_user_or_profile_menu">Add user or profile</string>
<!-- User settings add user menu [CHAR LIMIT=35] -->
- <string name="user_add_user_menu">Add user or profile</string>
+ <string name="user_add_user_menu">Add user</string>
<!-- User settings summary for a restricted profile [CHAR LIMIT=50] -->
<string name="user_summary_restricted_profile">Restricted profile</string>
<!-- User settings summary for a managed profile [CHAR LIMIT=50] -->
diff --git a/res/xml/accessibility_contrast_settings.xml b/res/xml/accessibility_contrast_settings.xml
deleted file mode 100644
index 6d08932..0000000
--- a/res/xml/accessibility_contrast_settings.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2013 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
- android:title="@string/accessibility_display_contrast_preference_title" >
-
- <CheckBoxPreference
- android:key="enable_quick_setting"
- android:persistent="false"
- android:title="@string/enable_quick_setting" />
-
- <SeekBarPreference
- android:key="contrast"
- android:persistent="false"
- android:title="@string/contrast_contrast" />
- <SeekBarPreference
- android:key="brightness"
- android:persistent="false"
- android:title="@string/contrast_brightness" />
-
-</PreferenceScreen>
diff --git a/res/xml/accessibility_inversion_settings.xml b/res/xml/accessibility_inversion_settings.xml
index a20c4db..6aa3869 100644
--- a/res/xml/accessibility_inversion_settings.xml
+++ b/res/xml/accessibility_inversion_settings.xml
@@ -22,12 +22,4 @@
android:persistent="false"
android:title="@string/enable_quick_setting" />
- <ListPreference
- android:entries="@array/inversion_type_entries"
- android:entryValues="@array/inversion_type_values"
- android:key="type"
- android:persistent="false"
- android:summary="%s"
- android:title="@string/inversion_type" />
-
</PreferenceScreen>
diff --git a/res/xml/accessibility_settings.xml b/res/xml/accessibility_settings.xml
index 9bbb670..3ce5f1b 100644
--- a/res/xml/accessibility_settings.xml
+++ b/res/xml/accessibility_settings.xml
@@ -78,10 +78,6 @@
android:key="display_category"
android:title="@string/accessibility_display_title" >
<PreferenceScreen
- android:fragment="com.android.settings.accessibility.ToggleContrastPreferenceFragment"
- android:key="contrast_preference_screen"
- android:title="@string/accessibility_display_contrast_preference_title" />
- <PreferenceScreen
android:fragment="com.android.settings.accessibility.ToggleInversionPreferenceFragment"
android:key="inversion_preference_screen"
android:title="@string/accessibility_display_inversion_preference_title" />
diff --git a/res/xml/user_settings.xml b/res/xml/user_settings.xml
index 3a0ab74..6bbeffa 100644
--- a/res/xml/user_settings.xml
+++ b/res/xml/user_settings.xml
@@ -25,7 +25,7 @@
<Preference
android:key="user_add"
- android:title="@string/user_add_user_menu"
+ android:title="@string/user_add_user_or_profile_menu"
android:icon="@drawable/ic_menu_add_dark" />
</PreferenceScreen>
diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java
index 314b3c9..2b580e4 100644
--- a/src/com/android/settings/SettingsActivity.java
+++ b/src/com/android/settings/SettingsActivity.java
@@ -256,7 +256,6 @@
AccessibilitySettings.class.getName(),
CaptionPropertiesFragment.class.getName(),
com.android.settings.accessibility.ToggleInversionPreferenceFragment.class.getName(),
- com.android.settings.accessibility.ToggleContrastPreferenceFragment.class.getName(),
com.android.settings.accessibility.ToggleDaltonizerPreferenceFragment.class.getName(),
TextToSpeechSettings.class.getName(),
Memory.class.getName(),
diff --git a/src/com/android/settings/accessibility/AccessibilitySettings.java b/src/com/android/settings/accessibility/AccessibilitySettings.java
index 9aa822e..b116290 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettings.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettings.java
@@ -525,8 +525,6 @@
mDisplayMagnificationPreferenceScreen);
updateFeatureSummary(Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED,
mDisplayInversionPreferenceScreen);
- updateFeatureSummary(Settings.Secure.ACCESSIBILITY_DISPLAY_CONTRAST_ENABLED,
- mDisplayContrastPreferenceScreen);
updateFeatureSummary(Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED,
mDisplayDaltonizerPreferenceScreen);
diff --git a/src/com/android/settings/accessibility/ListDialogPreference.java b/src/com/android/settings/accessibility/ListDialogPreference.java
index a252454..2140d91 100644
--- a/src/com/android/settings/accessibility/ListDialogPreference.java
+++ b/src/com/android/settings/accessibility/ListDialogPreference.java
@@ -82,6 +82,10 @@
*/
public void setValues(int[] values) {
mEntryValues = values;
+
+ if (mValueSet && mValueIndex == AbsListView.INVALID_POSITION) {
+ mValueIndex = getIndexForValue(mValue);
+ }
}
/**
@@ -172,10 +176,12 @@
*/
protected int getIndexForValue(int value) {
final int[] values = mEntryValues;
- final int count = values.length;
- for (int i = 0; i < count; i++) {
- if (values[i] == value) {
- return i;
+ if (values != null) {
+ final int count = values.length;
+ for (int i = 0; i < count; i++) {
+ if (values[i] == value) {
+ return i;
+ }
}
}
diff --git a/src/com/android/settings/accessibility/ToggleContrastPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleContrastPreferenceFragment.java
deleted file mode 100644
index d1e30f8..0000000
--- a/src/com/android/settings/accessibility/ToggleContrastPreferenceFragment.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright (C) 2013 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.accessibility;
-
-import android.os.Bundle;
-import android.preference.CheckBoxPreference;
-import android.preference.Preference;
-import android.preference.PreferenceScreen;
-import android.preference.SeekBarPreference;
-import android.provider.Settings;
-import android.view.View;
-import android.widget.CompoundButton;
-import android.widget.CompoundButton.OnCheckedChangeListener;
-
-import com.android.settings.R;
-import com.android.settings.accessibility.ToggleSwitch.OnBeforeCheckedChangeListener;
-
-public class ToggleContrastPreferenceFragment extends ToggleFeaturePreferenceFragment
- implements Preference.OnPreferenceChangeListener {
- private static final String ENABLED = Settings.Secure.ACCESSIBILITY_DISPLAY_CONTRAST_ENABLED;
- private static final String QUICK_SETTING_ENABLED =
- Settings.Secure.ACCESSIBILITY_DISPLAY_CONTRAST_QUICK_SETTING_ENABLED;
-
- private CheckBoxPreference mEnableQuickSetting;
- private SeekBarPreference mBrightness;
- private SeekBarPreference mContrast;
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- addPreferencesFromResource(R.xml.accessibility_contrast_settings);
-
- mEnableQuickSetting = (CheckBoxPreference) findPreference("enable_quick_setting");
- mBrightness = (SeekBarPreference) findPreference("brightness");
- mBrightness.setMax(1000);
- mContrast = (SeekBarPreference) findPreference("contrast");
- mContrast.setMax(1000);
-
- initPreferences();
- }
-
- @Override
- protected void onPreferenceToggled(String preferenceKey, boolean enabled) {
- Settings.Secure.putInt(getContentResolver(), ENABLED, enabled ? 1 : 0);
- }
-
- @Override
- public boolean onPreferenceChange(Preference preference, Object newValue) {
- if (preference == mEnableQuickSetting) {
- Settings.Secure.putInt(
- getContentResolver(), QUICK_SETTING_ENABLED, ((Boolean) newValue) ? 1 : 0);
- } else if (preference == mBrightness) {
- final int progress = (Integer) newValue;
- final float value = progress / 1000f - 0.5f;
- Settings.Secure.putFloat(
- getContentResolver(), Settings.Secure.ACCESSIBILITY_DISPLAY_BRIGHTNESS, value);
- } else if (preference == mContrast) {
- final int progress = (Integer) newValue;
- final float value = progress / 1000f * 10f + 1f;
- Settings.Secure.putFloat(
- getContentResolver(), Settings.Secure.ACCESSIBILITY_DISPLAY_CONTRAST, value);
- }
-
- return true;
- }
-
- @Override
- public void onViewCreated(View view, Bundle savedInstanceState) {
- super.onViewCreated(view, savedInstanceState);
-
- setTitle(getString(R.string.accessibility_display_contrast_preference_title));
- }
-
- @Override
- protected void onInstallActionBarToggleSwitch() {
- super.onInstallActionBarToggleSwitch();
-
- mToggleSwitch.setCheckedInternal(
- Settings.Secure.getInt(getContentResolver(), ENABLED, 0) == 1);
- mToggleSwitch.setOnCheckedChangeListener(new OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton button, boolean checked) {
- onPreferenceToggled(mPreferenceKey, checked);
- }
- });
- }
-
- private void initPreferences() {
- mEnableQuickSetting.setChecked(
- Settings.Secure.getInt(getContentResolver(), QUICK_SETTING_ENABLED, 0) == 1);
- mEnableQuickSetting.setOnPreferenceChangeListener(this);
-
- final float brightness = Settings.Secure.getFloat(
- getContentResolver(), Settings.Secure.ACCESSIBILITY_DISPLAY_BRIGHTNESS, 0);
- final float contrast = Settings.Secure.getFloat(
- getContentResolver(), Settings.Secure.ACCESSIBILITY_DISPLAY_CONTRAST, 2);
-
- // Available brightness range is -0.5 to 0.5.
- mBrightness.setProgress((int) (1000 * (brightness + 0.5f)));
- mBrightness.setOnPreferenceChangeListener(this);
-
- // Available contrast range is 1 to 10.
- mContrast.setProgress((int) (1000 * (contrast - 1f) / 10f));
- mContrast.setOnPreferenceChangeListener(this);
- }
-}
diff --git a/src/com/android/settings/accessibility/ToggleInversionPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleInversionPreferenceFragment.java
index bfb2500..92a778e 100644
--- a/src/com/android/settings/accessibility/ToggleInversionPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleInversionPreferenceFragment.java
@@ -35,13 +35,10 @@
public class ToggleInversionPreferenceFragment extends ToggleFeaturePreferenceFragment
implements Preference.OnPreferenceChangeListener {
private static final String ENABLED = Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED;
- private static final String TYPE = Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION;
private static final String QUICK_SETTING_ENABLED =
Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_QUICK_SETTING_ENABLED;
- private static final int DEFAULT_TYPE = AccessibilityManager.INVERSION_STANDARD;
private CheckBoxPreference mEnableQuickSetting;
- private ListPreference mType;
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -50,7 +47,6 @@
addPreferencesFromResource(R.xml.accessibility_inversion_settings);
mEnableQuickSetting = (CheckBoxPreference) findPreference("enable_quick_setting");
- mType = (ListPreference) findPreference("type");
initPreferences();
}
@@ -65,8 +61,6 @@
if (preference == mEnableQuickSetting) {
Settings.Secure.putInt(
getContentResolver(), QUICK_SETTING_ENABLED, ((Boolean) newValue) ? 1 : 0);
- } else if (preference == mType) {
- Settings.Secure.putInt(getContentResolver(), TYPE, Integer.parseInt((String) newValue));
}
return true;
@@ -97,9 +91,5 @@
mEnableQuickSetting.setChecked(
Settings.Secure.getInt(getContentResolver(), QUICK_SETTING_ENABLED, 0) == 1);
mEnableQuickSetting.setOnPreferenceChangeListener(this);
-
- mType.setValue(
- Integer.toString(Settings.Secure.getInt(getContentResolver(), TYPE, DEFAULT_TYPE)));
- mType.setOnPreferenceChangeListener(this);
}
}
diff --git a/src/com/android/settings/notification/NotificationStation.java b/src/com/android/settings/notification/NotificationStation.java
index d8a3efb..69a7a89 100644
--- a/src/com/android/settings/notification/NotificationStation.java
+++ b/src/com/android/settings/notification/NotificationStation.java
@@ -36,6 +36,7 @@
import android.os.ServiceManager;
import android.os.UserHandle;
import android.service.notification.INotificationListener;
+import android.service.notification.NotificationOrderUpdate;
import android.service.notification.StatusBarNotification;
import android.util.Log;
import android.view.LayoutInflater;
@@ -74,11 +75,12 @@
private INotificationListener.Stub mListener = new INotificationListener.Stub() {
@Override
- public void onListenerConnected(String[] notificationKeys) throws RemoteException {
+ public void onListenerConnected(NotificationOrderUpdate update) throws RemoteException {
// noop
}
@Override
- public void onNotificationPosted(StatusBarNotification notification) throws RemoteException {
+ public void onNotificationPosted(StatusBarNotification notification,
+ NotificationOrderUpdate update) throws RemoteException {
Log.v(TAG, "onNotificationPosted: " + notification);
final Handler h = getListView().getHandler();
h.removeCallbacks(mRefreshListRunnable);
@@ -86,11 +88,17 @@
}
@Override
- public void onNotificationRemoved(StatusBarNotification notification) throws RemoteException {
+ public void onNotificationRemoved(StatusBarNotification notification,
+ NotificationOrderUpdate update) throws RemoteException {
final Handler h = getListView().getHandler();
h.removeCallbacks(mRefreshListRunnable);
h.postDelayed(mRefreshListRunnable, 100);
}
+
+ @Override
+ public void onNotificationOrderUpdate(NotificationOrderUpdate update)
+ throws RemoteException {
+ }
};
private NotificationHistoryAdapter mAdapter;
diff --git a/src/com/android/settings/tts/TtsEngineSettingsFragment.java b/src/com/android/settings/tts/TtsEngineSettingsFragment.java
index 25ec1fd..f6314dd 100644
--- a/src/com/android/settings/tts/TtsEngineSettingsFragment.java
+++ b/src/com/android/settings/tts/TtsEngineSettingsFragment.java
@@ -52,6 +52,10 @@
private static final String KEY_ENGINE_SETTINGS = "tts_engine_settings";
private static final String KEY_INSTALL_DATA = "tts_install_data";
+ private static final String STATE_KEY_LOCALE_ENTRIES = "locale_entries";
+ private static final String STATE_KEY_LOCALE_ENTRY_VALUES= "locale_entry_values";
+ private static final String STATE_KEY_LOCALE_VALUE = "locale_value";
+
private static final int VOICE_DATA_INTEGRITY_CHECK = 1977;
private TtsEngines mEnginesHelper;
@@ -120,10 +124,26 @@
mEngineSettingsPreference.setEnabled(false);
}
mInstallVoicesPreference.setEnabled(false);
- mLocalePreference.setEnabled(false);
- mLocalePreference.setEntries(new CharSequence[0]);
- mLocalePreference.setEntryValues(new CharSequence[0]);
+ if (savedInstanceState == null) {
+ mLocalePreference.setEnabled(false);
+ mLocalePreference.setEntries(new CharSequence[0]);
+ mLocalePreference.setEntryValues(new CharSequence[0]);
+ } else {
+ // Repopulate mLocalePreference with saved state. Will be updated later with
+ // up-to-date values when checkTtsData() calls back with results.
+ final CharSequence[] entries =
+ savedInstanceState.getCharSequenceArray(STATE_KEY_LOCALE_ENTRIES);
+ final CharSequence[] entryValues =
+ savedInstanceState.getCharSequenceArray(STATE_KEY_LOCALE_ENTRY_VALUES);
+ final CharSequence value =
+ savedInstanceState.getCharSequence(STATE_KEY_LOCALE_VALUE);
+
+ mLocalePreference.setEntries(entries);
+ mLocalePreference.setEntryValues(entryValues);
+ mLocalePreference.setValue(value.toString());
+ mLocalePreference.setEnabled(entries.length > 0);
+ }
mVoiceDataDetails = getArguments().getParcelable(TtsEnginePreference.FRAGMENT_ARGS_VOICES);
@@ -144,6 +164,19 @@
super.onDestroy();
}
+ @Override
+ public void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+
+ // Save the mLocalePreference values, so we can repopulate it with entries.
+ outState.putCharSequenceArray(STATE_KEY_LOCALE_ENTRIES,
+ mLocalePreference.getEntries());
+ outState.putCharSequenceArray(STATE_KEY_LOCALE_ENTRY_VALUES,
+ mLocalePreference.getEntryValues());
+ outState.putCharSequence(STATE_KEY_LOCALE_VALUE,
+ mLocalePreference.getValue());
+ }
+
private final void checkTtsData() {
Intent intent = new Intent(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
intent.setPackage(getEngineName());
diff --git a/src/com/android/settings/users/UserSettings.java b/src/com/android/settings/users/UserSettings.java
index b218bc7..a05aaa9 100644
--- a/src/com/android/settings/users/UserSettings.java
+++ b/src/com/android/settings/users/UserSettings.java
@@ -129,6 +129,7 @@
private boolean mAddingUser;
private boolean mProfileExists;
private boolean mEnabled = true;
+ private boolean mCanAddRestrictedProfile = true;
private final Object mUserLock = new Object();
private UserManager mUserManager;
@@ -183,15 +184,16 @@
mRemovingUserId = icicle.getInt(SAVE_REMOVING_USER);
}
}
-
- mUserManager = (UserManager) getActivity().getSystemService(Context.USER_SERVICE);
+ final Context context = getActivity();
+ mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
if (!mUserManager.supportsMultipleUsers() || Utils.isMonkeyRunning()) {
mEnabled = false;
return;
}
+
addPreferencesFromResource(R.xml.user_settings);
mUserListCategory = (PreferenceGroup) findPreference(KEY_USER_LIST);
- mMePreference = new UserPreference(getActivity(), null, UserHandle.myUserId(),
+ mMePreference = new UserPreference(context, null, UserHandle.myUserId(),
mUserManager.isLinkedUser() ? null : this, null);
mMePreference.setKey(KEY_USER_ME);
mMePreference.setOnPreferenceClickListener(this);
@@ -199,9 +201,16 @@
mMePreference.setSummary(R.string.user_owner);
}
mAddUser = findPreference(KEY_ADD_USER);
- mAddUser.setOnPreferenceClickListener(this);
if (!mIsOwner || UserManager.getMaxSupportedUsers() < 2) {
removePreference(KEY_ADD_USER);
+ } else {
+ mAddUser.setOnPreferenceClickListener(this);
+ DevicePolicyManager dpm = (DevicePolicyManager) context.getSystemService(
+ Context.DEVICE_POLICY_SERVICE);
+ if (dpm.getDeviceOwner() != null) {
+ mCanAddRestrictedProfile = false;
+ mAddUser.setTitle(R.string.user_add_user_menu);
+ }
}
loadProfile();
setHasOptionsMenu(true);
@@ -771,7 +780,13 @@
}
}
} else if (pref == mAddUser) {
- showDialog(DIALOG_CHOOSE_USER_TYPE);
+ // If we allow both types, show a picker, otherwise directly go to
+ // flow for full user.
+ if (mCanAddRestrictedProfile) {
+ showDialog(DIALOG_CHOOSE_USER_TYPE);
+ } else {
+ onAddUserClicked(USER_TYPE_USER);
+ }
}
return false;
}