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
This commit is contained in:
Daniel Sandler
2012-10-18 10:33:59 -04:00
parent 8e3f8d3af5
commit c825bc8e17
3 changed files with 33 additions and 7 deletions

View File

@@ -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);
}