Merge "Support ACTION_CHANGE_ACTIVE for network scorers."
diff --git a/res/layout/sms_preference_item.xml b/res/layout/app_preference_item.xml
similarity index 95%
rename from res/layout/sms_preference_item.xml
rename to res/layout/app_preference_item.xml
index 2146764..22ee37e 100755
--- a/res/layout/sms_preference_item.xml
+++ b/res/layout/app_preference_item.xml
@@ -21,13 +21,13 @@
android:layout_height="?android:attr/listPreferredItemHeight"
android:padding="6dip">
<ImageView
- android:id="@+id/sms_image"
+ android:id="@+id/app_image"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:padding="6dip"
/>
<CheckedTextView
- android:id="@+id/sms_text"
+ android:id="@+id/app_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeight"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 81a44b9..070a10e 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -3875,7 +3875,7 @@
<!-- Text spoken by the TTS engine as an example if the engine doesn't provide sample text [CHAR LIMIT=100] -->
<string name="tts_default_sample_string">This is an example of speech synthesis</string>
<!-- On main TTS Settings screen, title of a field explaining current TTS engine status for
- current default language [CHAR LIMIT=50] -->
+ current default language [CHAR LIMIT=50] -->
<string name="tts_status_title">Default language status</string>
<!-- On main TTS Settings screen, current TTS engine status for the current default language,
selected language is fully supported by the engine [CHAR LIMIT=150]-->
@@ -3887,7 +3887,7 @@
selected language is not supported by the engine [CHAR LIMIT=150] -->
<string name="tts_status_not_supported"><xliff:g id="locale" example="English (United States)">%1$s</xliff:g> is not supported</string>
<!-- On main TTS Settings screen, current TTS engine status for the current default language,
- tts engine is queried for status [CHAR LIMIT=150] -->
+ tts engine is queried for status [CHAR LIMIT=150] -->
<string name="tts_status_checking">Checking...</string>
<!-- On main TTS Settings screen, text for divider under which all TTS engines are listed -->
<string name="tts_engines_section">Engines</string>
@@ -4786,6 +4786,10 @@
<string name="user_add_user_menu">Add user or profile</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] -->
+ <string name="user_summary_managed_profile">Managed profile</string>
+ <!-- User settings summary for an inactive managed profile [CHAR LIMIT=50] -->
+ <string name="user_summary_managed_profile_not_enabled">Managed profile (currently inactive)</string>
<!-- User settings warning that restricted profile needs a screen lock [CHAR LIMIT=NONE] -->
<string name="user_need_lock_message">Before you can create a restricted profile, you\'ll need to set up a screen lock to protect your apps and personal data.</string>
<!-- User settings dialog button to set screen lock [CHAR LIMIT=25] -->
@@ -4794,6 +4798,8 @@
<string name="user_summary_not_set_up">Not set up</string>
<!-- User summary to indicate that restricted profile is currently not set up [CHAR LIMIT=100] -->
<string name="user_summary_restricted_not_set_up">Not set up - Restricted profile</string>
+ <!-- User summary to indicate that a managed profile is currently not set up [CHAR LIMIT=100] -->
+ <string name="user_summary_managed_profile_not_set_up">Not set up - Managed profile</string>
<!-- User information string to represent the owner of the device [CHAR LIMIT=25] -->
<string name="user_owner">Owner</string>
<!-- User settings title for current user entry "You" user. [CHAR LIMIT=30] -->
diff --git a/res/xml/dashboard_categories.xml b/res/xml/dashboard_categories.xml
new file mode 100644
index 0000000..705fd80
--- /dev/null
+++ b/res/xml/dashboard_categories.xml
@@ -0,0 +1,251 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 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.
+-->
+
+<dashboard-categories
+ xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <!-- WIRELESS and NETWORKS -->
+ <dashboard-category
+ android:id="@+id/wireless_section"
+ android:title="@string/header_category_wireless_networks" >
+
+ <!-- Wifi -->
+ <dashboard-tile
+ android:id="@+id/wifi_settings"
+ android:title="@string/wifi_settings_title"
+ android:fragment="com.android.settings.wifi.WifiSettings"
+ android:icon="@drawable/ic_settings_wireless"
+ />
+
+ <!-- Bluetooth -->
+ <dashboard-tile
+ android:id="@+id/bluetooth_settings"
+ android:title="@string/bluetooth_settings_title"
+ android:fragment="com.android.settings.bluetooth.BluetoothSettings"
+ android:icon="@drawable/ic_settings_bluetooth2"
+ />
+
+ <!-- Data Usage -->
+ <dashboard-tile
+ android:id="@+id/data_usage_settings"
+ android:title="@string/data_usage_summary_title"
+ android:fragment="com.android.settings.DataUsageSummary"
+ android:icon="@drawable/ic_settings_data_usage"
+ />
+
+ <!-- Operator hook -->
+ <dashboard-tile
+ android:id="@+id/operator_settings"
+ android:fragment="com.android.settings.WirelessSettings" >
+ <intent android:action="com.android.settings.OPERATOR_APPLICATION_SETTING" />
+ </dashboard-tile>
+
+ <!-- Other wireless and network controls -->
+ <dashboard-tile
+ android:id="@+id/wireless_settings"
+ android:title="@string/radio_controls_title"
+ android:fragment="com.android.settings.WirelessSettings"
+ />
+
+ </dashboard-category>
+
+ <!-- DEVICE -->
+ <dashboard-category
+ android:id="@+id/device_section"
+ android:title="@string/header_category_device" >
+
+ <!-- Home -->
+ <dashboard-tile
+ android:id="@+id/home_settings"
+ android:title="@string/home_settings"
+ android:fragment="com.android.settings.HomeSettings"
+ android:icon="@drawable/ic_settings_home"
+ />
+
+ <!-- Sound -->
+ <dashboard-tile
+ android:id="@+id/sound_settings"
+ android:title="@string/sound_settings"
+ android:fragment="com.android.settings.SoundSettings"
+ android:icon="@drawable/ic_settings_sound"
+ />
+
+ <!-- Display -->
+ <dashboard-tile
+ android:id="@+id/display_settings"
+ android:title="@string/display_settings"
+ android:fragment="com.android.settings.DisplaySettings"
+ android:icon="@drawable/ic_settings_display"
+ />
+
+ <!-- Notifications -->
+ <dashboard-tile
+ android:id="@+id/notification_settings"
+ android:title="@string/notification_settings"
+ android:fragment="com.android.settings.notification.NotificationSettings"
+ android:icon="@drawable/ic_settings_notifications"
+ />
+
+ <!-- Storage -->
+ <dashboard-tile
+ android:id="@+id/storage_settings"
+ android:title="@string/storage_settings"
+ android:fragment="com.android.settings.deviceinfo.Memory"
+ android:icon="@drawable/ic_settings_storage"
+ />
+
+ <!-- Battery -->
+ <dashboard-tile
+ android:id="@+id/battery_settings"
+ android:title="@string/power_usage_summary_title"
+ android:fragment="com.android.settings.fuelgauge.PowerUsageSummary"
+ android:icon="@drawable/ic_settings_battery"
+ />
+
+ <!-- Application Settings -->
+ <dashboard-tile
+ android:id="@+id/application_settings"
+ android:title="@string/applications_settings"
+ android:fragment="com.android.settings.applications.ManageApplications"
+ android:icon="@drawable/ic_settings_applications"
+ />
+
+ <!-- Manage users -->
+ <dashboard-tile
+ android:id="@+id/user_settings"
+ android:title="@string/user_settings_title"
+ android:fragment="com.android.settings.users.UserSettings"
+ android:icon="@drawable/ic_settings_multiuser"
+ />
+
+ <!-- Manage NFC payment apps -->
+ <dashboard-tile
+ android:id="@+id/nfc_payment_settings"
+ android:title="@string/nfc_payment_settings_title"
+ android:fragment="com.android.settings.nfc.PaymentSettings"
+ android:icon="@drawable/ic_settings_nfc_payment"
+ />
+
+ <!-- Manufacturer hook -->
+ <dashboard-tile
+ android:id="@+id/manufacturer_settings"
+ android:fragment="com.android.settings.WirelessSettings">
+ <intent android:action="com.android.settings.MANUFACTURER_APPLICATION_SETTING" />
+ </dashboard-tile>
+
+ </dashboard-category>
+
+ <!-- PERSONAL -->
+ <dashboard-category
+ android:id="@+id/personal_section"
+ android:title="@string/header_category_personal" >
+
+ <!-- Location -->
+ <dashboard-tile
+ android:id="@+id/location_settings"
+ android:title="@string/location_settings_title"
+ android:fragment="com.android.settings.location.LocationSettings"
+ android:icon="@drawable/ic_settings_location"
+ />
+
+ <!-- Security -->
+ <dashboard-tile
+ android:id="@+id/security_settings"
+ android:title="@string/security_settings_title"
+ android:fragment="com.android.settings.SecuritySettings"
+ android:icon="@drawable/ic_settings_security"
+ />
+
+ <!-- Language -->
+ <dashboard-tile
+ android:id="@+id/language_settings"
+ android:title="@string/language_settings"
+ android:fragment="com.android.settings.inputmethod.InputMethodAndLanguageSettings"
+ android:icon="@drawable/ic_settings_language"
+ />
+
+ <!-- Backup and reset -->
+ <dashboard-tile
+ android:id="@+id/privacy_settings"
+ android:title="@string/privacy_settings"
+ android:fragment="com.android.settings.PrivacySettings"
+ android:icon="@drawable/ic_settings_backup"
+ />
+
+ </dashboard-category>
+
+ <!-- ACCOUNTS section -->
+ <dashboard-category
+ android:id="@+id/account_settings"
+ android:title="@string/account_settings" >
+
+ <dashboard-tile
+ android:id="@+id/account_add"
+ android:title="@string/add_account_label"
+ android:icon="@drawable/ic_menu_add_dark">
+ <intent android:action="android.settings.ADD_ACCOUNT_SETTINGS"/>
+ </dashboard-tile>
+
+ </dashboard-category>
+
+ <!-- SYSTEM -->
+ <dashboard-category
+ android:id="@+id/system_section"
+ android:title="@string/header_category_system" >
+
+ <!-- Date & Time -->
+ <dashboard-tile
+ android:id="@+id/date_time_settings"
+ android:title="@string/date_and_time_settings_title"
+ android:fragment="com.android.settings.DateTimeSettings"
+ android:icon="@drawable/ic_settings_date_time"
+ />
+
+ <!-- Accessibility feedback -->
+ <dashboard-tile
+ android:id="@+id/accessibility_settings"
+ android:title="@string/accessibility_settings"
+ android:fragment="com.android.settings.accessibility.AccessibilitySettings"
+ android:icon="@drawable/ic_settings_accessibility"
+ />
+
+ <!-- Print -->
+ <dashboard-tile
+ android:id="@+id/print_settings"
+ android:title="@string/print_settings"
+ android:fragment="com.android.settings.print.PrintSettingsFragment"
+ android:icon="@*android:drawable/ic_print"
+ />
+
+ <!-- Development -->
+ <dashboard-tile
+ android:id="@+id/development_settings"
+ android:title="@string/development_settings_title"
+ android:fragment="com.android.settings.DevelopmentSettings"
+ android:icon="@drawable/ic_settings_development"
+ />
+
+ <!-- About Device -->
+ <dashboard-tile
+ android:id="@+id/about_settings"
+ android:title="@string/about_settings"
+ android:fragment="com.android.settings.DeviceInfoSettings"
+ android:icon="@drawable/ic_settings_about"
+ />
+
+ </dashboard-category>
+
+</dashboard-categories>
diff --git a/res/xml/wireless_settings.xml b/res/xml/wireless_settings.xml
index 474eeb9..bf1523e 100644
--- a/res/xml/wireless_settings.xml
+++ b/res/xml/wireless_settings.xml
@@ -23,9 +23,10 @@
android:persistent="false"
android:disableDependentsState="true" />
- <com.android.settings.SmsListPreference
+ <com.android.settings.AppListPreference
android:key="sms_application"
android:title="@string/sms_application_title"
+ android:summary="%s"
android:persistent="false" />
<CheckBoxPreference
diff --git a/src/com/android/settings/AppListPreference.java b/src/com/android/settings/AppListPreference.java
new file mode 100644
index 0000000..919720f
--- /dev/null
+++ b/src/com/android/settings/AppListPreference.java
@@ -0,0 +1,118 @@
+/*
+ * 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;
+
+import android.app.Activity;
+import android.app.AlertDialog.Builder;
+import android.content.Context;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
+import android.content.pm.PackageManager.NameNotFoundException;
+import android.graphics.drawable.Drawable;
+import android.preference.ListPreference;
+import android.util.AttributeSet;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.CheckedTextView;
+import android.widget.ImageView;
+import android.widget.ListAdapter;
+
+/**
+ * Extends ListPreference to allow us to show the icons for a given list of applications. We do this
+ * because the names of applications are very similar and the user may not be able to determine what
+ * app they are selecting without an icon.
+ */
+public class AppListPreference extends ListPreference {
+ private Drawable[] mEntryDrawables;
+
+ public class AppArrayAdapter extends ArrayAdapter<CharSequence> {
+ private Drawable[] mImageDrawables = null;
+ private int mSelectedIndex = 0;
+
+ public AppArrayAdapter(Context context, int textViewResourceId,
+ CharSequence[] objects, Drawable[] imageDrawables, int selectedIndex) {
+ super(context, textViewResourceId, objects);
+ mSelectedIndex = selectedIndex;
+ mImageDrawables = imageDrawables;
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ LayoutInflater inflater = ((Activity)getContext()).getLayoutInflater();
+ View view = inflater.inflate(R.layout.app_preference_item, parent, false);
+ CheckedTextView checkedTextView = (CheckedTextView)view.findViewById(R.id.app_label);
+ checkedTextView.setText(getItem(position));
+ if (position == mSelectedIndex) {
+ checkedTextView.setChecked(true);
+ }
+ ImageView imageView = (ImageView)view.findViewById(R.id.app_image);
+ imageView.setImageDrawable(mImageDrawables[position]);
+ return view;
+ }
+ }
+
+ public AppListPreference(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public void setPackageNames(String[] packageNames, String defaultPackageName) {
+ // Look up all package names in PackageManager. Skip ones we can't find.
+ int foundPackages = 0;
+ PackageManager pm = getContext().getPackageManager();
+ ApplicationInfo[] appInfos = new ApplicationInfo[packageNames.length];
+ for (int i = 0; i < packageNames.length; i++) {
+ try {
+ appInfos[i] = pm.getApplicationInfo(packageNames[i], 0);
+ foundPackages++;
+ } catch (NameNotFoundException e) {
+ // Leave appInfos[i] uninitialized; it will be skipped in the list.
+ }
+ }
+
+ // Show the label and icon for each application package.
+ CharSequence[] applicationNames = new CharSequence[foundPackages];
+ mEntryDrawables = new Drawable[foundPackages];
+ int index = 0;
+ int selectedIndex = -1;
+ for (ApplicationInfo appInfo : appInfos) {
+ if (appInfo != null) {
+ applicationNames[index] = appInfo.loadLabel(pm);
+ mEntryDrawables[index] = appInfo.loadIcon(pm);
+ if (appInfo.packageName.contentEquals(defaultPackageName)) {
+ selectedIndex = index;
+ }
+ index++;
+ }
+ }
+ setEntries(applicationNames);
+ setEntryValues(packageNames);
+ if (selectedIndex != -1) {
+ setValueIndex(selectedIndex);
+ }
+ }
+
+ @Override
+ protected void onPrepareDialogBuilder(Builder builder) {
+ int selectedIndex = findIndexOfValue(getValue());
+ ListAdapter adapter = new AppArrayAdapter(getContext(),
+ R.layout.app_preference_item, getEntries(), mEntryDrawables, selectedIndex);
+ builder.setAdapter(adapter, this);
+ super.onPrepareDialogBuilder(builder);
+ }
+}
diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java
index 4c3e2bc..699955a 100644
--- a/src/com/android/settings/SettingsActivity.java
+++ b/src/com/android/settings/SettingsActivity.java
@@ -76,7 +76,9 @@
import com.android.settings.applications.ManageApplications;
import com.android.settings.applications.ProcessStatsUi;
import com.android.settings.bluetooth.BluetoothSettings;
+import com.android.settings.dashboard.DashboardCategory;
import com.android.settings.dashboard.DashboardSummary;
+import com.android.settings.dashboard.DashboardTile;
import com.android.settings.dashboard.Header;
import com.android.settings.dashboard.HeaderAdapter;
import com.android.settings.dashboard.NoHomeDialogFragment;
@@ -323,10 +325,11 @@
private String mSearchQuery;
// Headers
- protected HashMap<Integer, Integer> mHeaderIndexMap = new HashMap<Integer, Integer>();
private final ArrayList<Header> mHeaders = new ArrayList<Header>();
private HeaderAdapter mHeaderAdapter;
+ private List<DashboardCategory> mCategories = new ArrayList<DashboardCategory>();
+
private static final int MSG_BUILD_HEADERS = 1;
private Handler mHandler = new Handler() {
@Override
@@ -999,7 +1002,6 @@
int i = 0;
final UserManager um = (UserManager) getSystemService(Context.USER_SERVICE);
- mHeaderIndexMap.clear();
while (i < target.size()) {
Header header = target.get(i);
// Ids are integers, so downcasting
@@ -1075,7 +1077,6 @@
// Increment if the current one wasn't removed by the Utils code.
if (i < target.size() && target.get(i) == header) {
- mHeaderIndexMap.put(id, i);
i++;
}
}
@@ -1175,6 +1176,351 @@
return true;
}
+ /**
+ * Called when the activity needs its list of categories/tiles build.
+ *
+ * @param categories The list in which to place the tiles categories.
+ */
+ private void onBuildDashboardCategories(List<DashboardCategory> categories) {
+ loadCategoriesFromResource(R.xml.dashboard_categories, categories);
+ updateTilesList(categories);
+ }
+
+ /**
+ * Parse the given XML file as a categories description, adding each
+ * parsed categories and tiles into the target list.
+ *
+ * @param resid The XML resource to load and parse.
+ * @param target The list in which the parsed categories and tiles should be placed.
+ */
+ private void loadCategoriesFromResource(int resid, List<DashboardCategory> target) {
+ XmlResourceParser parser = null;
+ try {
+ parser = getResources().getXml(resid);
+ AttributeSet attrs = Xml.asAttributeSet(parser);
+
+ int type;
+ while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
+ && type != XmlPullParser.START_TAG) {
+ // Parse next until start tag is found
+ }
+
+ String nodeName = parser.getName();
+ if (!"dashboard-categories".equals(nodeName)) {
+ throw new RuntimeException(
+ "XML document must start with <preference-categories> tag; found"
+ + nodeName + " at " + parser.getPositionDescription());
+ }
+
+ Bundle curBundle = null;
+
+ final int outerDepth = parser.getDepth();
+ while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
+ && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
+ if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
+ continue;
+ }
+
+ nodeName = parser.getName();
+ if ("dashboard-category".equals(nodeName)) {
+ DashboardCategory category = new DashboardCategory();
+
+ TypedArray sa = obtainStyledAttributes(
+ attrs, com.android.internal.R.styleable.PreferenceHeader);
+ category.id = sa.getResourceId(
+ com.android.internal.R.styleable.PreferenceHeader_id,
+ (int)DashboardCategory.CAT_ID_UNDEFINED);
+
+ TypedValue tv = sa.peekValue(
+ com.android.internal.R.styleable.PreferenceHeader_title);
+ if (tv != null && tv.type == TypedValue.TYPE_STRING) {
+ if (tv.resourceId != 0) {
+ category.titleRes = tv.resourceId;
+ } else {
+ category.title = tv.string;
+ }
+ }
+ sa.recycle();
+
+ final int innerDepth = parser.getDepth();
+ while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
+ && (type != XmlPullParser.END_TAG || parser.getDepth() > innerDepth)) {
+ if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
+ continue;
+ }
+
+ String innerNodeName = parser.getName();
+ if (innerNodeName.equals("dashboard-tile")) {
+ DashboardTile tile = new DashboardTile();
+
+ sa = obtainStyledAttributes(
+ attrs, com.android.internal.R.styleable.PreferenceHeader);
+ tile.id = sa.getResourceId(
+ com.android.internal.R.styleable.PreferenceHeader_id,
+ (int)HEADER_ID_UNDEFINED);
+ tv = sa.peekValue(
+ com.android.internal.R.styleable.PreferenceHeader_title);
+ if (tv != null && tv.type == TypedValue.TYPE_STRING) {
+ if (tv.resourceId != 0) {
+ tile.titleRes = tv.resourceId;
+ } else {
+ tile.title = tv.string;
+ }
+ }
+ tv = sa.peekValue(
+ com.android.internal.R.styleable.PreferenceHeader_summary);
+ if (tv != null && tv.type == TypedValue.TYPE_STRING) {
+ if (tv.resourceId != 0) {
+ tile.summaryRes = tv.resourceId;
+ } else {
+ tile.summary = tv.string;
+ }
+ }
+ tile.iconRes = sa.getResourceId(
+ com.android.internal.R.styleable.PreferenceHeader_icon, 0);
+ tile.fragment = sa.getString(
+ com.android.internal.R.styleable.PreferenceHeader_fragment);
+ sa.recycle();
+
+ if (curBundle == null) {
+ curBundle = new Bundle();
+ }
+
+ final int innerDepth2 = parser.getDepth();
+ while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
+ && (type != XmlPullParser.END_TAG || parser.getDepth() > innerDepth2)) {
+ if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
+ continue;
+ }
+
+ String innerNodeName2 = parser.getName();
+ if (innerNodeName2.equals("extra")) {
+ getResources().parseBundleExtra("extra", attrs, curBundle);
+ XmlUtils.skipCurrentTag(parser);
+
+ } else if (innerNodeName2.equals("intent")) {
+ tile.intent = Intent.parseIntent(getResources(), parser, attrs);
+
+ } else {
+ XmlUtils.skipCurrentTag(parser);
+ }
+ }
+
+ if (curBundle.size() > 0) {
+ tile.fragmentArguments = curBundle;
+ curBundle = null;
+ }
+
+ category.addTile(tile);
+
+ } else {
+ XmlUtils.skipCurrentTag(parser);
+ }
+ }
+
+ target.add(category);
+ } else {
+ XmlUtils.skipCurrentTag(parser);
+ }
+ }
+
+ } catch (XmlPullParserException e) {
+ throw new RuntimeException("Error parsing categories", e);
+ } catch (IOException e) {
+ throw new RuntimeException("Error parsing categories", e);
+ } finally {
+ if (parser != null) parser.close();
+ }
+ }
+
+ private void updateTilesList(List<DashboardCategory> target) {
+ final boolean showDev = mDevelopmentPreferences.getBoolean(
+ DevelopmentSettings.PREF_SHOW,
+ android.os.Build.TYPE.equals("eng"));
+
+ final UserManager um = (UserManager) getSystemService(Context.USER_SERVICE);
+
+ final int size = target.size();
+ for (int i = 0; i < size; i++) {
+
+ DashboardCategory category = target.get(i);
+
+ // Ids are integers, so downcasting is ok
+ int id = (int) category.id;
+ if (id == R.id.account_settings) {
+ insertAccountsTiles(category);
+ continue;
+ }
+ int n = category.getTilesCount() - 1;
+ while (n >= 0) {
+
+ DashboardTile tile = category.getTile(n);
+
+ id = (int) tile.id;
+ if (id == R.id.operator_settings || id == R.id.manufacturer_settings) {
+ Utils.updateTileToSpecificActivityFromMetaDataOrRemove(this, category, tile);
+ } else if (id == R.id.wifi_settings) {
+ // Remove WiFi Settings if WiFi service is not available.
+ if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_WIFI)) {
+ category.removeTile(n);
+ }
+ } else if (id == R.id.bluetooth_settings) {
+ // Remove Bluetooth Settings if Bluetooth service is not available.
+ if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)) {
+ category.removeTile(n);
+ }
+ } else if (id == R.id.data_usage_settings) {
+ // Remove data usage when kernel module not enabled
+ final INetworkManagementService netManager = INetworkManagementService.Stub
+ .asInterface(ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE));
+ try {
+ if (!netManager.isBandwidthControlEnabled()) {
+ category.removeTile(n);
+ }
+ } catch (RemoteException e) {
+ // ignored
+ }
+ } else if (id == R.id.battery_settings) {
+ // Remove battery settings when battery is not available. (e.g. TV)
+
+ if (!mBatteryPresent) {
+ category.removeTile(n);
+ }
+ } else if (id == R.id.home_settings) {
+ if (!updateHomeSettingTiles(tile)) {
+ category.removeTile(n);
+ }
+ } else if (id == R.id.user_settings) {
+ if (!UserHandle.MU_ENABLED
+ || !UserManager.supportsMultipleUsers()
+ || Utils.isMonkeyRunning()) {
+ category.removeTile(n);
+ }
+ } else if (id == R.id.nfc_payment_settings) {
+ if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_NFC)) {
+ category.removeTile(n);
+ } else {
+ // Only show if NFC is on and we have the HCE feature
+ NfcAdapter adapter = NfcAdapter.getDefaultAdapter(this);
+ if (!adapter.isEnabled() || !getPackageManager().hasSystemFeature(
+ PackageManager.FEATURE_NFC_HOST_CARD_EMULATION)) {
+ category.removeTile(n);
+ }
+ }
+ } else if (id == R.id.development_settings) {
+ if (!showDev) {
+ category.removeTile(n);
+ }
+ } else if (id == R.id.account_add) {
+ if (um.hasUserRestriction(UserManager.DISALLOW_MODIFY_ACCOUNTS)) {
+ category.removeTile(n);
+ }
+ }
+
+ if (UserHandle.MU_ENABLED && UserHandle.myUserId() != 0
+ && !ArrayUtils.contains(SETTINGS_FOR_RESTRICTED, id)) {
+ category.removeTile(n);
+ }
+
+ n--;
+ }
+ }
+ }
+
+ private boolean updateHomeSettingTiles(DashboardTile tile) {
+ // Once we decide to show Home settings, keep showing it forever
+ SharedPreferences sp = getSharedPreferences(HomeSettings.HOME_PREFS, Context.MODE_PRIVATE);
+ if (sp.getBoolean(HomeSettings.HOME_PREFS_DO_SHOW, false)) {
+ return true;
+ }
+
+ try {
+ final ArrayList<ResolveInfo> homeApps = new ArrayList<ResolveInfo>();
+ getPackageManager().getHomeActivities(homeApps);
+ if (homeApps.size() < 2) {
+ // When there's only one available home app, omit this settings
+ // category entirely at the top level UI. If the user just
+ // uninstalled the penultimate home app candidiate, we also
+ // now tell them about why they aren't seeing 'Home' in the list.
+ if (sShowNoHomeNotice) {
+ sShowNoHomeNotice = false;
+ NoHomeDialogFragment.show(this);
+ }
+ return false;
+ } else {
+ // Okay, we're allowing the Home settings category. Tell it, when
+ // invoked via this front door, that we'll need to be told about the
+ // case when the user uninstalls all but one home app.
+ if (tile.fragmentArguments == null) {
+ tile.fragmentArguments = new Bundle();
+ }
+ tile.fragmentArguments.putBoolean(HomeSettings.HOME_SHOW_NOTICE, true);
+ }
+ } catch (Exception e) {
+ // Can't look up the home activity; bail on configuring the icon
+ Log.w(LOG_TAG, "Problem looking up home activity!", e);
+ }
+
+ sp.edit().putBoolean(HomeSettings.HOME_PREFS_DO_SHOW, true).apply();
+ return true;
+ }
+
+ private void insertAccountsTiles(DashboardCategory target) {
+ String[] accountTypes = mAuthenticatorHelper.getEnabledAccountTypes();
+ List<DashboardTile> dashboardTiles = new ArrayList<DashboardTile>(accountTypes.length);
+ for (String accountType : accountTypes) {
+ CharSequence label = mAuthenticatorHelper.getLabelForType(this, accountType);
+ if (label == null) {
+ continue;
+ }
+
+ Account[] accounts = AccountManager.get(this).getAccountsByType(accountType);
+ boolean skipToAccount = accounts.length == 1
+ && !mAuthenticatorHelper.hasAccountPreferences(accountType);
+ DashboardTile accountTile = new DashboardTile();
+ accountTile.title = label;
+ if (accountTile.extras == null) {
+ accountTile.extras = new Bundle();
+ }
+ if (skipToAccount) {
+ accountTile.fragment = AccountSyncSettings.class.getName();
+ accountTile.fragmentArguments = new Bundle();
+ // Need this for the icon
+ accountTile.extras.putString(ManageAccountsSettings.KEY_ACCOUNT_TYPE, accountType);
+ accountTile.extras.putParcelable(AccountSyncSettings.ACCOUNT_KEY, accounts[0]);
+ accountTile.fragmentArguments.putParcelable(AccountSyncSettings.ACCOUNT_KEY,
+ accounts[0]);
+ } else {
+ accountTile.fragment = ManageAccountsSettings.class.getName();
+ accountTile.fragmentArguments = new Bundle();
+ accountTile.extras.putString(ManageAccountsSettings.KEY_ACCOUNT_TYPE, accountType);
+ accountTile.fragmentArguments.putString(ManageAccountsSettings.KEY_ACCOUNT_TYPE,
+ accountType);
+ accountTile.fragmentArguments.putString(ManageAccountsSettings.KEY_ACCOUNT_LABEL,
+ label.toString());
+ }
+ dashboardTiles.add(accountTile);
+ mAuthenticatorHelper.preloadDrawableForType(this, accountType);
+ }
+
+ // Sort by label
+ Collections.sort(dashboardTiles, new Comparator<DashboardTile>() {
+ @Override
+ public int compare(DashboardTile t1, DashboardTile t2) {
+ return t1.title.toString().compareTo(t2.title.toString());
+ }
+ });
+ int index = 0;
+ for (DashboardTile tile : dashboardTiles) {
+ target.addTile(index, tile);
+ index++;
+ }
+ if (!mListeningToAccountUpdates) {
+ AccountManager.get(this).addOnAccountsUpdatedListener(this, null, true);
+ mListeningToAccountUpdates = true;
+ }
+ }
+
private void getMetaData() {
try {
ActivityInfo ai = getPackageManager().getActivityInfo(getComponentName(),
diff --git a/src/com/android/settings/SettingsPreferenceFragment.java b/src/com/android/settings/SettingsPreferenceFragment.java
index f32f8ba..2c290b1 100644
--- a/src/com/android/settings/SettingsPreferenceFragment.java
+++ b/src/com/android/settings/SettingsPreferenceFragment.java
@@ -113,16 +113,24 @@
@Override
protected void onBindPreferences() {
+ registerObserverIfNeeded();
+ }
+
+ @Override
+ public void onStop() {
+ super.onStop();
+
+ unregisterObserverIfNeeded();
+ }
+
+ public void registerObserverIfNeeded() {
if (!mIsDataSetObserverRegistered) {
getPreferenceScreen().getRootAdapter().registerDataSetObserver(mDataSetObserver);
mIsDataSetObserverRegistered = true;
}
}
- @Override
- public void onDestroy() {
- super.onDestroy();
-
+ public void unregisterObserverIfNeeded() {
if (mIsDataSetObserverRegistered) {
getPreferenceScreen().getRootAdapter().unregisterDataSetObserver(mDataSetObserver);
mIsDataSetObserverRegistered = false;
diff --git a/src/com/android/settings/SmsListPreference.java b/src/com/android/settings/SmsListPreference.java
deleted file mode 100644
index 15df776..0000000
--- a/src/com/android/settings/SmsListPreference.java
+++ /dev/null
@@ -1,86 +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;
-
-import android.app.Activity;
-import android.app.AlertDialog.Builder;
-import android.content.Context;
-import android.graphics.drawable.Drawable;
-import android.preference.ListPreference;
-import android.util.AttributeSet;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ArrayAdapter;
-import android.widget.CheckedTextView;
-import android.widget.ImageView;
-import android.widget.ListAdapter;
-
-/**
- * Extends ListPreference to allow us to show the icons for the available SMS applications. We do
- * this because the names of SMS applications are very similar and the user may not be able to
- * determine what app they are selecting without an icon.
- */
-public class SmsListPreference extends ListPreference {
- private Drawable[] mEntryDrawables;
-
- public class SmsArrayAdapter extends ArrayAdapter<CharSequence> {
- private Drawable[] mImageDrawables = null;
- private int mSelectedIndex = 0;
-
- public SmsArrayAdapter(Context context, int textViewResourceId,
- CharSequence[] objects, Drawable[] imageDrawables, int selectedIndex) {
- super(context, textViewResourceId, objects);
- mSelectedIndex = selectedIndex;
- mImageDrawables = imageDrawables;
- }
-
- public View getView(int position, View convertView, ViewGroup parent) {
- LayoutInflater inflater = ((Activity)getContext()).getLayoutInflater();
- View view = inflater.inflate(R.layout.sms_preference_item, parent, false);
- CheckedTextView checkedTextView = (CheckedTextView)view.findViewById(R.id.sms_text);
- checkedTextView.setText(getItem(position));
- if (position == mSelectedIndex) {
- checkedTextView.setChecked(true);
- }
- ImageView imageView = (ImageView)view.findViewById(R.id.sms_image);
- imageView.setImageDrawable(mImageDrawables[position]);
- return view;
- }
- }
-
- public SmsListPreference(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- public void setEntryDrawables(Drawable[] entries) {
- mEntryDrawables = entries;
- }
-
- public Drawable[] getEntryDrawables() {
- return mEntryDrawables;
- }
-
- @Override
- protected void onPrepareDialogBuilder(Builder builder) {
- int selectedIndex = findIndexOfValue(getValue());
- ListAdapter adapter = new SmsArrayAdapter(getContext(),
- R.layout.sms_preference_item, getEntries(), mEntryDrawables, selectedIndex);
- builder.setAdapter(adapter, this);
- super.onPrepareDialogBuilder(builder);
- }
-}
\ No newline at end of file
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index 1ae0829..d743b6f 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -55,6 +55,8 @@
import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.TabWidget;
+import com.android.settings.dashboard.DashboardCategory;
+import com.android.settings.dashboard.DashboardTile;
import com.android.settings.dashboard.Header;
import java.io.IOException;
@@ -297,6 +299,66 @@
return false;
}
+ public static boolean updateTileToSpecificActivityFromMetaDataOrRemove(Context context,
+ DashboardCategory target, DashboardTile tile) {
+
+ Intent intent = tile.intent;
+ if (intent != null) {
+ // Find the activity that is in the system image
+ PackageManager pm = context.getPackageManager();
+ List<ResolveInfo> list = pm.queryIntentActivities(intent, PackageManager.GET_META_DATA);
+ int listSize = list.size();
+ for (int i = 0; i < listSize; i++) {
+ ResolveInfo resolveInfo = list.get(i);
+ if ((resolveInfo.activityInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM)
+ != 0) {
+ Drawable icon = null;
+ String title = null;
+ String summary = null;
+
+ // Get the activity's meta-data
+ try {
+ Resources res = pm.getResourcesForApplication(
+ resolveInfo.activityInfo.packageName);
+ Bundle metaData = resolveInfo.activityInfo.metaData;
+
+ if (res != null && metaData != null) {
+ icon = res.getDrawable(metaData.getInt(META_DATA_PREFERENCE_ICON));
+ title = res.getString(metaData.getInt(META_DATA_PREFERENCE_TITLE));
+ summary = res.getString(metaData.getInt(META_DATA_PREFERENCE_SUMMARY));
+ }
+ } catch (NameNotFoundException e) {
+ // Ignore
+ } catch (NotFoundException e) {
+ // Ignore
+ }
+
+ // Set the preference title to the activity's label if no
+ // meta-data is found
+ if (TextUtils.isEmpty(title)) {
+ title = resolveInfo.loadLabel(pm).toString();
+ }
+
+ // Set icon, title and summary for the preference
+ // TODO:
+ //tile.icon = icon;
+ tile.title = title;
+ tile.summary = summary;
+ // Replace the intent with this specific activity
+ tile.intent = new Intent().setClassName(resolveInfo.activityInfo.packageName,
+ resolveInfo.activityInfo.name);
+
+ return true;
+ }
+ }
+ }
+
+ // Did not find a matching activity, so remove the preference
+ target.removeTile(tile);
+
+ return false;
+ }
+
/**
* Returns true if Monkey is running.
*/
diff --git a/src/com/android/settings/WirelessSettings.java b/src/com/android/settings/WirelessSettings.java
index b36b03c..fd2e945 100644
--- a/src/com/android/settings/WirelessSettings.java
+++ b/src/com/android/settings/WirelessSettings.java
@@ -26,9 +26,7 @@
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
-import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Resources;
-import android.graphics.drawable.Drawable;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.nfc.NfcAdapter;
@@ -85,7 +83,7 @@
private static final int MANAGE_MOBILE_PLAN_DIALOG_ID = 1;
private static final String SAVED_MANAGE_MOBILE_PLAN_MSG = "mManageMobilePlanMessage";
- private SmsListPreference mSmsApplicationPreference;
+ private AppListPreference mSmsApplicationPreference;
public WirelessSettings() {
super(null);
@@ -174,23 +172,6 @@
}
}
- private void updateSmsApplicationSetting() {
- log("updateSmsApplicationSetting:");
- ComponentName appName = SmsApplication.getDefaultSmsApplication(getActivity(), true);
- if (appName != null) {
- String packageName = appName.getPackageName();
-
- CharSequence[] values = mSmsApplicationPreference.getEntryValues();
- for (int i = 0; i < values.length; i++) {
- if (packageName.contentEquals(values[i])) {
- mSmsApplicationPreference.setValueIndex(i);
- mSmsApplicationPreference.setSummary(mSmsApplicationPreference.getEntries()[i]);
- break;
- }
- }
- }
- }
-
private void initSmsApplicationSetting() {
log("initSmsApplicationSetting:");
Collection<SmsApplicationData> smsApplications =
@@ -198,25 +179,18 @@
// If the list is empty the dialog will be empty, but we will not crash.
int count = smsApplications.size();
- CharSequence[] entries = new CharSequence[count];
- CharSequence[] entryValues = new CharSequence[count];
- Drawable[] entryImages = new Drawable[count];
-
+ String[] packageNames = new String[count];
int i = 0;
for (SmsApplicationData smsApplicationData : smsApplications) {
- entries[i] = smsApplicationData.mApplicationName;
- entryValues[i] = smsApplicationData.mPackageName;
- try {
- entryImages[i] = mPm.getApplicationIcon(smsApplicationData.mPackageName);
- } catch (NameNotFoundException e) {
- entryImages[i] = mPm.getDefaultActivityIcon();
- }
+ packageNames[i] = smsApplicationData.mPackageName;
i++;
}
- mSmsApplicationPreference.setEntries(entries);
- mSmsApplicationPreference.setEntryValues(entryValues);
- mSmsApplicationPreference.setEntryDrawables(entryImages);
- updateSmsApplicationSetting();
+ String defaultPackageName = null;
+ ComponentName appName = SmsApplication.getDefaultSmsApplication(getActivity(), true);
+ if (appName != null) {
+ defaultPackageName = appName.getPackageName();
+ }
+ mSmsApplicationPreference.setPackageNames(packageNames, defaultPackageName);
}
@Override
@@ -284,7 +258,7 @@
mAirplaneModeEnabler = new AirplaneModeEnabler(activity, mAirplaneModePreference);
mNfcEnabler = new NfcEnabler(activity, nfc, androidBeam);
- mSmsApplicationPreference = (SmsListPreference) findPreference(KEY_SMS_APPLICATION);
+ mSmsApplicationPreference = (AppListPreference) findPreference(KEY_SMS_APPLICATION);
mSmsApplicationPreference.setOnPreferenceChangeListener(this);
initSmsApplicationSetting();
@@ -468,7 +442,6 @@
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (preference == mSmsApplicationPreference && newValue != null) {
SmsApplication.setDefaultApplication(newValue.toString(), getActivity());
- updateSmsApplicationSetting();
return true;
}
return false;
diff --git a/src/com/android/settings/dashboard/DashboardCategory.java b/src/com/android/settings/dashboard/DashboardCategory.java
new file mode 100644
index 0000000..2d08599
--- /dev/null
+++ b/src/com/android/settings/dashboard/DashboardCategory.java
@@ -0,0 +1,130 @@
+/*
+ * Copyright (C) 2014 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.dashboard;
+
+import android.content.res.Resources;
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.text.TextUtils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class DashboardCategory implements Parcelable {
+
+ /**
+ * Default value for {@link com.android.settings.dashboard.DashboardCategory#id DashboardCategory.id}
+ * indicating that no identifier value is set. All other values (including those below -1)
+ * are valid.
+ */
+ public static final long CAT_ID_UNDEFINED = -1;
+
+ /**
+ * Identifier for this tile, to correlate with a new list when
+ * it is updated. The default value is
+ * {@link com.android.settings.dashboard.DashboardTile#TILE_ID_UNDEFINED}, meaning no id.
+ * @attr ref android.R.styleable#PreferenceHeader_id
+ */
+ public long id = CAT_ID_UNDEFINED;
+
+ /**
+ * Resource ID of title of the category that is shown to the user.
+ */
+ public int titleRes;
+
+ /**
+ * Title of the category that is shown to the user.
+ */
+ public CharSequence title;
+
+ /**
+ * List of the category's children
+ */
+ public List<DashboardTile> tiles = new ArrayList<DashboardTile>();
+
+
+ public DashboardCategory() {
+ // Empty
+ }
+
+ public void addTile(DashboardTile tile) {
+ tiles.add(tile);
+ }
+
+ public void addTile(int n, DashboardTile tile) {
+ tiles.add(n, tile);
+ }
+
+ public void removeTile(DashboardTile tile) {
+ tiles.remove(tile);
+ }
+
+ public void removeTile(int n) {
+ tiles.remove(n);
+ }
+
+ public int getTilesCount() {
+ return tiles.size();
+ }
+
+ public DashboardTile getTile(int n) {
+ return tiles.get(n);
+ }
+
+ /**
+ * Return the currently set title. If {@link #titleRes} is set,
+ * this resource is loaded from <var>res</var> and returned. Otherwise
+ * {@link #title} is returned.
+ */
+ public CharSequence getTitle(Resources res) {
+ if (titleRes != 0) {
+ return res.getText(titleRes);
+ }
+ return title;
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeInt(titleRes);
+ TextUtils.writeToParcel(title, dest, flags);
+
+ final int count = tiles.size();
+ dest.writeInt(count);
+
+ for (int n = 0; n < count; n++) {
+ DashboardTile tile = tiles.get(n);
+ tile.writeToParcel(dest, flags);
+ }
+ }
+
+ public void readFromParcel(Parcel in) {
+ titleRes = in.readInt();
+ title = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
+
+ final int count = in.readInt();
+
+ for (int n = 0; n < count; n++) {
+ DashboardTile tile = DashboardTile.CREATOR.createFromParcel(in);
+ tiles.add(tile);
+ }
+ }
+}
diff --git a/src/com/android/settings/dashboard/DashboardTile.java b/src/com/android/settings/dashboard/DashboardTile.java
new file mode 100644
index 0000000..1f1d9c2
--- /dev/null
+++ b/src/com/android/settings/dashboard/DashboardTile.java
@@ -0,0 +1,177 @@
+/*
+ * Copyright (C) 2014 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.dashboard;
+
+import android.content.Intent;
+import android.content.res.Resources;
+import android.os.Bundle;
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.text.TextUtils;
+
+/**
+ * Description of a single dashboard tile that the user can select.
+ */
+public class DashboardTile implements Parcelable {
+ /**
+ * Default value for {@link com.android.settings.dashboard.DashboardTile#id DashboardTile.id}
+ * indicating that no identifier value is set. All other values (including those below -1)
+ * are valid.
+ */
+ public static final long TILE_ID_UNDEFINED = -1;
+
+ /**
+ * Identifier for this tile, to correlate with a new list when
+ * it is updated. The default value is
+ * {@link com.android.settings.dashboard.DashboardTile#TILE_ID_UNDEFINED}, meaning no id.
+ * @attr ref android.R.styleable#PreferenceHeader_id
+ */
+ public long id = TILE_ID_UNDEFINED;
+
+ /**
+ * Resource ID of title of the tile that is shown to the user.
+ * @attr ref android.R.styleable#PreferenceHeader_title
+ */
+ public int titleRes;
+
+ /**
+ * Title of the tile that is shown to the user.
+ * @attr ref android.R.styleable#PreferenceHeader_title
+ */
+ public CharSequence title;
+
+ /**
+ * Resource ID of optional summary describing what this tile controls.
+ * @attr ref android.R.styleable#PreferenceHeader_summary
+ */
+ public int summaryRes;
+
+ /**
+ * Optional summary describing what this tile controls.
+ * @attr ref android.R.styleable#PreferenceHeader_summary
+ */
+ public CharSequence summary;
+
+ /**
+ * Optional icon resource to show for this tile.
+ * @attr ref android.R.styleable#PreferenceHeader_icon
+ */
+ public int iconRes;
+
+ /**
+ * Full class name of the fragment to display when this tile is
+ * selected.
+ * @attr ref android.R.styleable#PreferenceHeader_fragment
+ */
+ public String fragment;
+
+ /**
+ * Optional arguments to supply to the fragment when it is
+ * instantiated.
+ */
+ public Bundle fragmentArguments;
+
+ /**
+ * Intent to launch when the preference is selected.
+ */
+ public Intent intent;
+
+ /**
+ * Optional additional data for use by subclasses of the activity
+ */
+ public Bundle extras;
+
+ public DashboardTile() {
+ // Empty
+ }
+
+ /**
+ * Return the currently set title. If {@link #titleRes} is set,
+ * this resource is loaded from <var>res</var> and returned. Otherwise
+ * {@link #title} is returned.
+ */
+ public CharSequence getTitle(Resources res) {
+ if (titleRes != 0) {
+ return res.getText(titleRes);
+ }
+ return title;
+ }
+
+ /**
+ * Return the currently set summary. If {@link #summaryRes} is set,
+ * this resource is loaded from <var>res</var> and returned. Otherwise
+ * {@link #summary} is returned.
+ */
+ public CharSequence getSummary(Resources res) {
+ if (summaryRes != 0) {
+ return res.getText(summaryRes);
+ }
+ return summary;
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeLong(id);
+ dest.writeInt(titleRes);
+ TextUtils.writeToParcel(title, dest, flags);
+ dest.writeInt(summaryRes);
+ TextUtils.writeToParcel(summary, dest, flags);
+ dest.writeInt(iconRes);
+ dest.writeString(fragment);
+ dest.writeBundle(fragmentArguments);
+ if (intent != null) {
+ dest.writeInt(1);
+ intent.writeToParcel(dest, flags);
+ } else {
+ dest.writeInt(0);
+ }
+ dest.writeBundle(extras);
+ }
+
+ public void readFromParcel(Parcel in) {
+ id = in.readLong();
+ titleRes = in.readInt();
+ title = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
+ summaryRes = in.readInt();
+ summary = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
+ iconRes = in.readInt();
+ fragment = in.readString();
+ fragmentArguments = in.readBundle();
+ if (in.readInt() != 0) {
+ intent = Intent.CREATOR.createFromParcel(in);
+ }
+ extras = in.readBundle();
+ }
+
+ DashboardTile(Parcel in) {
+ readFromParcel(in);
+ }
+
+ public static final Creator<DashboardTile> CREATOR = new Creator<DashboardTile>() {
+ public DashboardTile createFromParcel(Parcel source) {
+ return new DashboardTile(source);
+ }
+ public DashboardTile[] newArray(int size) {
+ return new DashboardTile[size];
+ }
+ };
+}
diff --git a/src/com/android/settings/users/UserSettings.java b/src/com/android/settings/users/UserSettings.java
index d8213ff..0a66046 100644
--- a/src/com/android/settings/users/UserSettings.java
+++ b/src/com/android/settings/users/UserSettings.java
@@ -639,11 +639,23 @@
pref.setTitle(user.name);
}
if (!isInitialized(user)) {
- pref.setSummary(user.isRestricted()
- ? R.string.user_summary_restricted_not_set_up
- : R.string.user_summary_not_set_up);
+ if (user.isRestricted()) {
+ pref.setSummary(R.string.user_summary_restricted_not_set_up);
+ } else if (user.isManagedProfile()) {
+ pref.setSummary(R.string.user_summary_managed_profile_not_set_up);
+ } else {
+ pref.setSummary(R.string.user_summary_not_set_up);
+ }
} else if (user.isRestricted()) {
pref.setSummary(R.string.user_summary_restricted_profile);
+ } else if (user.isManagedProfile()) {
+ DevicePolicyManager dpm = (DevicePolicyManager)
+ getActivity().getSystemService(Context.DEVICE_POLICY_SERVICE);
+ if (dpm.isProfileEnabled(user.id)) {
+ pref.setSummary(R.string.user_summary_managed_profile);
+ } else {
+ pref.setSummary(R.string.user_summary_managed_profile_not_enabled);
+ }
}
if (user.iconPath != null) {
if (mUserIcons.get(user.id) == null) {