diff options
author | Daniel Sandler <dsandler@android.com> | 2012-10-18 10:33:59 -0400 |
---|---|---|
committer | Daniel Sandler <dsandler@android.com> | 2012-10-18 11:38:28 -0400 |
commit | c825bc8e17cb60cae88397ab77d1e2711c086624 (patch) | |
tree | 6f87fabd9512b8fee2e676d602f22ffa6c66c5d6 /src | |
parent | 8e3f8d3af576648cc73181d3ba2a89c107dffc75 (diff) | |
download | packages_apps_settings-c825bc8e17cb60cae88397ab77d1e2711c086624.zip packages_apps_settings-c825bc8e17cb60cae88397ab77d1e2711c086624.tar.gz packages_apps_settings-c825bc8e17cb60cae88397ab77d1e2711c086624.tar.bz2 |
More descriptive summary for "Sleep Mode" pref.
It will either show "Off" or the name of the selected dream.
Also, move "When to sleep" out onto the visible part of the
action bar if there's room, making it much easier to discover.
Bug: 7320701
Change-Id: I1d4e2c17b764b8ee054dbb17c23f559d735e3450
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/settings/DisplaySettings.java | 9 | ||||
-rw-r--r-- | src/com/android/settings/DreamBackend.java | 17 | ||||
-rw-r--r-- | src/com/android/settings/DreamSettings.java | 14 |
3 files changed, 33 insertions, 7 deletions
diff --git a/src/com/android/settings/DisplaySettings.java b/src/com/android/settings/DisplaySettings.java index a698538..6ee60b5 100644 --- a/src/com/android/settings/DisplaySettings.java +++ b/src/com/android/settings/DisplaySettings.java @@ -284,11 +284,10 @@ public class DisplaySettings extends SettingsPreferenceFragment implements } private void updateScreenSaverSummary() { - int summaryResId = DreamSettings.getSummaryResource(getActivity()); - if (summaryResId > 0) - mScreenSaverPreference.setSummary(summaryResId); - else - mScreenSaverPreference.setSummary(""); + if (mScreenSaverPreference != null) { + mScreenSaverPreference.setSummary( + DreamSettings.getSummaryTextWithDreamName(getActivity())); + } } private void updateWifiDisplaySummary() { diff --git a/src/com/android/settings/DreamBackend.java b/src/com/android/settings/DreamBackend.java index 7effe4b..a866174 100644 --- a/src/com/android/settings/DreamBackend.java +++ b/src/com/android/settings/DreamBackend.java @@ -26,6 +26,7 @@ import android.content.Intent; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.pm.PackageManager.NameNotFoundException; +import android.content.pm.ServiceInfo; import android.content.res.Resources; import android.content.res.TypedArray; import android.content.res.XmlResourceParser; @@ -116,6 +117,22 @@ public class DreamBackend { } } + public CharSequence getActiveDreamName() { + ComponentName cn = getActiveDream(); + if (cn != null) { + PackageManager pm = mContext.getPackageManager(); + try { + ServiceInfo ri = pm.getServiceInfo(cn, 0); + if (ri != null) { + return ri.loadLabel(pm); + } + } catch (PackageManager.NameNotFoundException exc) { + return null; // uninstalled? + } + } + return null; + } + public boolean isEnabled() { return getBoolean(SCREENSAVER_ENABLED); } diff --git a/src/com/android/settings/DreamSettings.java b/src/com/android/settings/DreamSettings.java index ca4415b..32328d9 100644 --- a/src/com/android/settings/DreamSettings.java +++ b/src/com/android/settings/DreamSettings.java @@ -149,7 +149,7 @@ public class DreamSettings extends SettingsPreferenceFragment { // create "when to dream" overflow menu item MenuItem whenToDream = createMenuItem(menu, R.string.screensaver_settings_when_to_dream, - MenuItem.SHOW_AS_ACTION_NEVER, + MenuItem.SHOW_AS_ACTION_IF_ROOM, isEnabled, new Runnable() { @Override @@ -245,6 +245,16 @@ public class DreamSettings extends SettingsPreferenceFragment { : 0; } + public static CharSequence getSummaryTextWithDreamName(Context context) { + DreamBackend backend = new DreamBackend(context); + boolean isEnabled = backend.isEnabled(); + if (!isEnabled) { + return context.getString(R.string.screensaver_settings_summary_off); + } else { + return backend.getActiveDreamName(); + } + } + private void refreshFromBackend() { logd("refreshFromBackend()"); mRefreshing = true; @@ -306,7 +316,7 @@ public class DreamSettings extends SettingsPreferenceFragment { ImageView settingsButton = (ImageView) row.findViewById(android.R.id.button2); settingsButton.setVisibility(showSettings ? View.VISIBLE : View.INVISIBLE); - settingsButton.setAlpha(dreamInfo.isActive ? 1f : 0.7f); + settingsButton.setAlpha(dreamInfo.isActive ? 1f : 0.33f); settingsButton.setEnabled(dreamInfo.isActive); settingsButton.setOnClickListener(new OnClickListener(){ @Override |