summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/java/android/provider/Settings.java13
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java65
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java2
3 files changed, 69 insertions, 11 deletions
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index e1c4361..7925d31 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -2777,6 +2777,19 @@ public final class Settings {
*/
public static final String STATUS_BAR_IME_SWITCHER = "status_bar_ime_switcher";
+ /**
+ * Whether to collapse the notification area after dismissing the last notification
+ * @hide
+ */
+ public static final String STATUS_BAR_COLLAPSE_ON_DISMISS = "status_bar_collapse_on_dismiss";
+
+ /** @hide */
+ public static final int STATUS_BAR_COLLAPSE_NEVER = 0;
+ /** @hide */
+ public static final int STATUS_BAR_COLLAPSE_IF_EMPTIED = 1;
+ /** @hide */
+ public static final int STATUS_BAR_COLLAPSE_IF_NO_CLEARABLE = 2;
+
/**
* Expanded desktop on/off state
* @hide
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
index b2d4e85..b56aa12 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
@@ -183,6 +183,7 @@ public abstract class BaseStatusBar extends SystemUI implements
protected Display mDisplay;
private boolean mDeviceProvisioned = false;
+ private int mAutoCollapseBehaviour;
public IStatusBarService getStatusBarService() {
return mBarService;
@@ -192,7 +193,7 @@ public abstract class BaseStatusBar extends SystemUI implements
return mDeviceProvisioned;
}
- private ContentObserver mProvisioningObserver = new ContentObserver(new Handler()) {
+ private ContentObserver mProvisioningObserver = new ContentObserver(mHandler) {
@Override
public void onChange(boolean selfChange) {
final boolean provisioned = 0 != Settings.Global.getInt(
@@ -204,6 +205,33 @@ public abstract class BaseStatusBar extends SystemUI implements
}
};
+ private class SettingsObserver extends ContentObserver {
+ public SettingsObserver(Handler handler) {
+ super(handler);
+ }
+
+ public void observe() {
+ ContentResolver resolver = mContext.getContentResolver();
+ resolver.registerContentObserver(Settings.System.getUriFor(
+ Settings.System.STATUS_BAR_COLLAPSE_ON_DISMISS), false, this);
+ update();
+ }
+
+ @Override
+ public void onChange(boolean selfChange) {
+ update();
+ }
+
+ private void update() {
+ ContentResolver resolver = mContext.getContentResolver();
+ mAutoCollapseBehaviour = Settings.System.getIntForUser(resolver,
+ Settings.System.STATUS_BAR_COLLAPSE_ON_DISMISS,
+ Settings.System.STATUS_BAR_COLLAPSE_IF_NO_CLEARABLE, UserHandle.USER_CURRENT);
+ }
+ };
+
+ private SettingsObserver mSettingsObserver = new SettingsObserver(mHandler);
+
private RemoteViews.OnClickHandler mOnClickHandler = new RemoteViews.OnClickHandler() {
@Override
public boolean onClickHandler(View view, PendingIntent pendingIntent, Intent fillInIntent) {
@@ -246,6 +274,8 @@ public abstract class BaseStatusBar extends SystemUI implements
Settings.Global.getUriFor(Settings.Global.DEVICE_PROVISIONED), true,
mProvisioningObserver);
+ mSettingsObserver.observe();
+
mBarService = IStatusBarService.Stub.asInterface(
ServiceManager.getService(Context.STATUS_BAR_SERVICE));
@@ -950,18 +980,33 @@ public abstract class BaseStatusBar extends SystemUI implements
if (rowParent != null) rowParent.removeView(entry.row);
updateExpansionStates();
updateNotificationIcons();
+ maybeCollapseAfterNotificationRemoval(entry.userDismissed());
- if (CLOSE_PANEL_WHEN_EMPTIED && isNotificationPanelFullyVisible()) {
- if (entry.userDismissed() && !mNotificationData.hasClearableItems()) {
- mHandler.removeCallbacks(mPanelCollapseRunnable);
- mHandler.postDelayed(mPanelCollapseRunnable, COLLAPSE_AFTER_DISMISS_DELAY);
- } else if (mNotificationData.size() == 0) {
- mHandler.removeCallbacks(mPanelCollapseRunnable);
- mHandler.postDelayed(mPanelCollapseRunnable, COLLAPSE_AFTER_REMOVE_DELAY);
- }
+ return entry.notification;
+ }
+
+ protected void maybeCollapseAfterNotificationRemoval(boolean userDismissed) {
+ if (mAutoCollapseBehaviour == Settings.System.STATUS_BAR_COLLAPSE_NEVER) {
+ return;
+ }
+ if (!isNotificationPanelFullyVisible()) {
+ return;
}
- return entry.notification;
+ boolean collapseDueToEmpty =
+ mAutoCollapseBehaviour == Settings.System.STATUS_BAR_COLLAPSE_IF_EMPTIED
+ && mNotificationData.size() == 0;
+ boolean collapseDueToNoClearable =
+ mAutoCollapseBehaviour == Settings.System.STATUS_BAR_COLLAPSE_IF_NO_CLEARABLE
+ && !mNotificationData.hasClearableItems();
+
+ if (userDismissed && (collapseDueToEmpty || collapseDueToNoClearable)) {
+ mHandler.removeCallbacks(mPanelCollapseRunnable);
+ mHandler.postDelayed(mPanelCollapseRunnable, COLLAPSE_AFTER_DISMISS_DELAY);
+ } else if (mNotificationData.size() == 0) {
+ mHandler.removeCallbacks(mPanelCollapseRunnable);
+ mHandler.postDelayed(mPanelCollapseRunnable, COLLAPSE_AFTER_REMOVE_DELAY);
+ }
}
protected StatusBarIconView addNotificationViews(IBinder key,
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index 7d98350..ad588af 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -2549,7 +2549,7 @@ public class PhoneStatusBar extends BaseStatusBar {
}
if (snapshot.isEmpty()) {
- animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE);
+ maybeCollapseAfterNotificationRemoval(true);
return;
}