summaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2013-07-30 07:24:04 +0000
committerGerrit Code Review <gerrit@cyanogenmod.org>2013-07-30 07:24:04 +0000
commit199dd03f13830c56fe5a29390a8c8d034d3a9e8d (patch)
tree0acb4656587fde8f28563361e30dc51d3f5ae4f1 /packages
parentea139154bea8497f8c0d493d597cfcdb8be13477 (diff)
parent8bf2351797f2adfb444fc3356b6eb2c60c459bb7 (diff)
downloadframeworks_base-199dd03f13830c56fe5a29390a8c8d034d3a9e8d.zip
frameworks_base-199dd03f13830c56fe5a29390a8c8d034d3a9e8d.tar.gz
frameworks_base-199dd03f13830c56fe5a29390a8c8d034d3a9e8d.tar.bz2
Merge "Make notification-shade-collapse-after-dismiss behaviour configurable." into cm-10.1
Diffstat (limited to 'packages')
-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
2 files changed, 56 insertions, 11 deletions
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;
}