summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFyodor Kupolov <fkupolov@google.com>2015-05-29 20:42:55 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-05-29 20:42:55 +0000
commit01f35ce46e584e0fd699c3330eba564eb6811dc5 (patch)
treed85b00eb225c0d69250eab57c2454b27b706fa9a
parent2defc457bdd0a13f6ece49a20d5120616ca3eaaf (diff)
parenta7a7bfe59fc03ffb00d2f2f0fe0fb011834bf22e (diff)
downloadpackages_apps_Settings-01f35ce46e584e0fd699c3330eba564eb6811dc5.tar.gz
packages_apps_Settings-01f35ce46e584e0fd699c3330eba564eb6811dc5.tar.bz2
packages_apps_Settings-01f35ce46e584e0fd699c3330eba564eb6811dc5.zip
Merge "Use DimmableIconPreference for Add user action" into mnc-dev
-rw-r--r--res/values/strings.xml2
-rw-r--r--res/xml/user_settings.xml2
-rw-r--r--src/com/android/settings/DimmableIconPreference.java (renamed from src/com/android/settings/location/DimmableIconPreference.java)13
-rw-r--r--src/com/android/settings/location/RecentLocationApps.java2
-rw-r--r--src/com/android/settings/location/SettingsInjector.java2
-rw-r--r--src/com/android/settings/users/UserSettings.java21
6 files changed, 30 insertions, 12 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 49aa99fe5..700ec0b87 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -5425,6 +5425,8 @@
<string name="user_nickname">Nickname</string>
<!-- Title for add user type dialog [CHAR LIMIT=45] -->
<string name="user_add_user_type_title">Add</string>
+ <!-- Summary for add user action, when it's disabled [CHAR LIMIT=100] -->
+ <string name="user_add_max_count">You can add up to <xliff:g id="user_count">%1$d</xliff:g> users</string>
<!-- Summary for add user entry in the choice dialog [CHAR LIMIT=none] -->
<string name="user_add_user_item_summary">Users have their own apps and content</string>
<!-- Summary for add restricted profile entry in the choice dialog [CHAR LIMIT=none] -->
diff --git a/res/xml/user_settings.xml b/res/xml/user_settings.xml
index 6bbeffa24..f33177c71 100644
--- a/res/xml/user_settings.xml
+++ b/res/xml/user_settings.xml
@@ -23,7 +23,7 @@
android:title="@string/user_list_title">
</PreferenceCategory>
- <Preference
+ <com.android.settings.DimmableIconPreference
android:key="user_add"
android:title="@string/user_add_user_or_profile_menu"
android:icon="@drawable/ic_menu_add_dark" />
diff --git a/src/com/android/settings/location/DimmableIconPreference.java b/src/com/android/settings/DimmableIconPreference.java
index f78599281..2d736033a 100644
--- a/src/com/android/settings/location/DimmableIconPreference.java
+++ b/src/com/android/settings/DimmableIconPreference.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.settings.location;
+package com.android.settings;
import android.annotation.Nullable;
import android.content.Context;
@@ -35,16 +35,9 @@ public class DimmableIconPreference extends Preference {
private final CharSequence mContentDescription;
- public DimmableIconPreference(Context context, AttributeSet attrs, int defStyle,
- @Nullable CharSequence contentDescription) {
- super(context, attrs, defStyle);
- mContentDescription = contentDescription;
- }
-
- public DimmableIconPreference(Context context, AttributeSet attrs,
- @Nullable CharSequence contentDescription) {
+ public DimmableIconPreference(Context context, AttributeSet attrs) {
super(context, attrs);
- mContentDescription = contentDescription;
+ mContentDescription = null;
}
public DimmableIconPreference(Context context, @Nullable CharSequence contentDescription) {
diff --git a/src/com/android/settings/location/RecentLocationApps.java b/src/com/android/settings/location/RecentLocationApps.java
index d7b62e711..66bdda51f 100644
--- a/src/com/android/settings/location/RecentLocationApps.java
+++ b/src/com/android/settings/location/RecentLocationApps.java
@@ -31,6 +31,8 @@ import android.os.UserHandle;
import android.os.UserManager;
import android.preference.Preference;
import android.util.Log;
+
+import com.android.settings.DimmableIconPreference;
import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.applications.InstalledAppDetails;
diff --git a/src/com/android/settings/location/SettingsInjector.java b/src/com/android/settings/location/SettingsInjector.java
index ef6117b2c..283430e3c 100644
--- a/src/com/android/settings/location/SettingsInjector.java
+++ b/src/com/android/settings/location/SettingsInjector.java
@@ -39,6 +39,8 @@ import android.util.AttributeSet;
import android.util.Log;
import android.util.Xml;
+import com.android.settings.DimmableIconPreference;
+
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
diff --git a/src/com/android/settings/users/UserSettings.java b/src/com/android/settings/users/UserSettings.java
index d5244d7df..4c26c5cce 100644
--- a/src/com/android/settings/users/UserSettings.java
+++ b/src/com/android/settings/users/UserSettings.java
@@ -818,10 +818,29 @@ public class UserSettings extends SettingsPreferenceFragment
// Append Add user to the end of the list
if (mUserCaps.mCanAddUser) {
boolean moreUsers = mUserManager.canAddMoreUsers();
- mAddUser.setEnabled(moreUsers);
mAddUser.setOrder(Preference.DEFAULT_ORDER);
preferenceScreen.addPreference(mAddUser);
+ mAddUser.setEnabled(moreUsers);
+ if (!moreUsers) {
+ mAddUser.setSummary(getString(R.string.user_add_max_count, getMaxRealUsers()));
+ } else {
+ mAddUser.setSummary(null);
+ }
+ }
+ }
+
+ private int getMaxRealUsers() {
+ // guest is not counted against getMaxSupportedUsers() number
+ final int maxUsersAndGuest = UserManager.getMaxSupportedUsers() + 1;
+ final List<UserInfo> users = mUserManager.getUsers();
+ // managed profiles are counted against getMaxSupportedUsers()
+ int managedProfiles = 0;
+ for (UserInfo user : users) {
+ if (user.isManagedProfile()) {
+ managedProfiles++;
+ }
}
+ return maxUsersAndGuest - managedProfiles;
}
private boolean shouldShowGuestUserPreference(List<UserInfo> users) {