summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Christoph Studer <chstuder@google.com> 2014-06-24 16:29:37 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2014-06-23 21:44:43 +0000
commit775a159e80ad9c174dab656b4e23032d525e5bd2 (patch)
tree7a42ad88765dec91fbf80011ea626fca08bf1f4e
parent3faf67c9b3aac71794cbafee91f8ecc4ab454bc3 (diff)
parent6cb9e0f1f9b8b7902f3c451eb86db447af4a4ebf (diff)
Merge "Remove suppression of ZEN'd notifications"
-rw-r--r--packages/SystemUI/res/drawable/ic_notify_zen.xml28
-rw-r--r--packages/SystemUI/res/values/strings.xml8
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/InterceptedNotifications.java143
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java31
4 files changed, 0 insertions, 210 deletions
diff --git a/packages/SystemUI/res/drawable/ic_notify_zen.xml b/packages/SystemUI/res/drawable/ic_notify_zen.xml
deleted file mode 100644
index c46455b3f7ae..000000000000
--- a/packages/SystemUI/res/drawable/ic_notify_zen.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<!--
-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.
--->
-<vector xmlns:android="http://schemas.android.com/apk/res/android" >
- <size
- android:width="24dp"
- android:height="24dp"/>
-
- <viewport
- android:viewportWidth="48.0"
- android:viewportHeight="48.0"/>
-
- <path
- android:fill="#FFFFFFFF"
- android:pathData="M4.0,24.0c0.0,11.0 9.0,20.0 20.0,20.0s20.0,-9.0 20.0,-20.0S35.0,4.0 24.0,4.0S4.0,13.0 4.0,24.0zM36.6,33.8L14.2,11.4C16.9,9.3 20.3,8.0 24.0,8.0c8.8,0.0 16.0,7.2 16.0,16.0C40.0,27.7 38.7,31.1 36.6,33.8zM8.0,24.0c0.0,-3.7 1.3,-7.1 3.4,-9.8L33.8,36.6C31.1,38.7 27.7,40.0 24.0,40.0C15.2,40.0 8.0,32.8 8.0,24.0z"/>
-</vector>
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index e5499eef19c2..f0212533d080 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -577,14 +577,6 @@
<!-- Description of the left direction in which one can to slide the handle in the Slide unlock screen. [CHAR LIMIT=NONE] -->
<string name="description_direction_left">"Slide left for <xliff:g id="target_description" example="Unlock">%s</xliff:g>.</string>
- <!-- Zen mode: Summary notification content title. [CHAR LIMIT=NONE] -->
- <plurals name="zen_mode_notification_title">
- <item quantity="one">Notification hidden</item>
- <item quantity="other">%d notifications hidden</item>
- </plurals>
- <!-- Zen mode: Summary notification content text. [CHAR LIMIT=NONE] -->
- <string name="zen_mode_notification_text">Touch to show</string>
-
<!-- Zen mode: Short title. [CHAR LIMIT=40] -->
<string name="zen_mode_title">Do not disturb</string>
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/InterceptedNotifications.java b/packages/SystemUI/src/com/android/systemui/statusbar/InterceptedNotifications.java
deleted file mode 100644
index bba49a7f5d20..000000000000
--- a/packages/SystemUI/src/com/android/systemui/statusbar/InterceptedNotifications.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * 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.systemui.statusbar;
-
-import android.app.Notification;
-import android.content.Context;
-import android.os.Process;
-import android.provider.Settings;
-import android.service.notification.NotificationListenerService.Ranking;
-import android.service.notification.NotificationListenerService.RankingMap;
-import android.service.notification.StatusBarNotification;
-import android.util.ArrayMap;
-import android.util.ArraySet;
-import android.view.View;
-
-import com.android.systemui.R;
-import com.android.systemui.statusbar.NotificationData.Entry;
-import com.android.systemui.statusbar.phone.PhoneStatusBar;
-
-public class InterceptedNotifications {
- private static final String TAG = "InterceptedNotifications";
- private static final String SYNTHETIC_KEY = "InterceptedNotifications.SYNTHETIC_KEY";
-
- private final Context mContext;
- private final PhoneStatusBar mBar;
- private final ArrayMap<String, StatusBarNotification> mIntercepted
- = new ArrayMap<String, StatusBarNotification>();
- private final ArraySet<String> mReleased = new ArraySet<String>();
-
- private String mSynKey;
-
- public InterceptedNotifications(Context context, PhoneStatusBar bar) {
- mContext = context;
- mBar = bar;
- }
-
- public void releaseIntercepted() {
- final int n = mIntercepted.size();
- for (int i = 0; i < n; i++) {
- final StatusBarNotification sbn = mIntercepted.valueAt(i);
- mReleased.add(sbn.getKey());
- mBar.displayNotification(sbn, null);
- }
- mIntercepted.clear();
- updateSyntheticNotification();
- }
-
- public boolean tryIntercept(StatusBarNotification notification, RankingMap rankingMap) {
- if (rankingMap == null) return false;
- if (shouldDisplayIntercepted()) return false;
- if (mReleased.contains(notification.getKey())) return false;
- Ranking ranking = rankingMap.getRanking(notification.getKey());
- if (!ranking.isInterceptedByDoNotDisturb()) return false;
- mIntercepted.put(notification.getKey(), notification);
- updateSyntheticNotification();
- return true;
- }
-
- public void retryIntercepts(RankingMap ranking) {
- if (ranking == null) return;
-
- final int N = mIntercepted.size();
- final ArraySet<String> removed = new ArraySet<String>(N);
- for (int i = 0; i < N; i++) {
- final StatusBarNotification sbn = mIntercepted.valueAt(i);
- if (!tryIntercept(sbn, ranking)) {
- removed.add(sbn.getKey());
- mBar.displayNotification(sbn, ranking);
- }
- }
- if (!removed.isEmpty()) {
- mIntercepted.removeAll(removed);
- updateSyntheticNotification();
- }
- }
-
- public void remove(String key) {
- if (mIntercepted.remove(key) != null) {
- updateSyntheticNotification();
- }
- mReleased.remove(key);
- }
-
- public boolean isSyntheticEntry(Entry ent) {
- return ent.key.equals(mSynKey);
- }
-
- private boolean shouldDisplayIntercepted() {
- return Settings.Secure.getInt(mContext.getContentResolver(),
- Settings.Secure.DISPLAY_INTERCEPTED_NOTIFICATIONS, 0) != 0;
- }
-
- private void updateSyntheticNotification() {
- if (mIntercepted.isEmpty()) {
- if (mSynKey != null) {
- mBar.removeNotification(mSynKey, null);
- mSynKey = null;
- }
- return;
- }
- final Notification n = new Notification.Builder(mContext)
- .setSmallIcon(R.drawable.ic_notify_zen)
- .setContentTitle(mContext.getResources().getQuantityString(
- R.plurals.zen_mode_notification_title,
- mIntercepted.size(), mIntercepted.size()))
- .setContentText(mContext.getString(R.string.zen_mode_notification_text))
- .setOngoing(true)
- .build();
- final StatusBarNotification sbn = new StatusBarNotification(mContext.getPackageName(),
- mContext.getBasePackageName(),
- TAG.hashCode(), TAG, Process.myUid(), Process.myPid(), 0, n,
- mBar.getCurrentUserHandle());
- if (mSynKey == null) {
- mSynKey = sbn.getKey();
- mBar.displayNotification(sbn, null);
- } else {
- mBar.updateNotification(sbn, null);
- }
- final NotificationData.Entry entry = mBar.mNotificationData.findByKey(mSynKey);
- entry.row.setOnClickListener(mSynClickListener);
- }
-
- private final View.OnClickListener mSynClickListener = new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- releaseIntercepted();
- }
- };
-}
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 2c67aa9e100a..00951b28d130 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -110,7 +110,6 @@ import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.DragDownHelper;
import com.android.systemui.statusbar.ExpandableNotificationRow;
import com.android.systemui.statusbar.GestureRecorder;
-import com.android.systemui.statusbar.InterceptedNotifications;
import com.android.systemui.statusbar.KeyguardIndicationController;
import com.android.systemui.statusbar.NotificationData;
import com.android.systemui.statusbar.NotificationData.Entry;
@@ -399,7 +398,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
}};
private Runnable mOnFlipRunnable;
- private InterceptedNotifications mIntercepted;
private VelocityTracker mSettingsTracker;
private float mSettingsDownY;
private boolean mSettingsStarted;
@@ -510,19 +508,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
};
@Override
- public void setZenMode(int mode) {
- super.setZenMode(mode);
- if (!isDeviceProvisioned()) return;
- final boolean zen = mode != Settings.Global.ZEN_MODE_OFF;
- if (!zen) {
- mIntercepted.releaseIntercepted();
- }
- if (mIconPolicy != null) {
- mIconPolicy.setZenMode(zen);
- }
- }
-
- @Override
protected void setShowLockscreenNotifications(boolean show) {
super.setShowLockscreenNotifications(show);
updateStackScrollerState();
@@ -533,7 +518,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
mDisplay = ((WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE))
.getDefaultDisplay();
updateDisplaySize();
- mIntercepted = new InterceptedNotifications(mContext, this);
super.start(); // calls createAndAddWindows()
addNavigationBar();
@@ -1074,16 +1058,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
@Override
public void addNotification(StatusBarNotification notification, RankingMap ranking) {
if (DEBUG) Log.d(TAG, "addNotification key=" + notification.getKey());
- if (mZenMode != Global.ZEN_MODE_OFF && mIntercepted.tryIntercept(notification, ranking)) {
- // Forward the ranking so we can sort the new notification.
- mNotificationData.updateRanking(ranking);
- return;
- }
- mIntercepted.remove(notification.getKey());
- displayNotification(notification, ranking);
- }
-
- public void displayNotification(StatusBarNotification notification, RankingMap ranking) {
if (mUseHeadsUp && shouldInterrupt(notification)) {
if (DEBUG) Log.d(TAG, "launching notification in heads up mode");
Entry interruptionCandidate = new Entry(notification, null);
@@ -1167,7 +1141,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
@Override
protected void updateNotificationRanking(RankingMap ranking) {
mNotificationData.updateRanking(ranking);
- mIntercepted.retryIntercepts(ranking);
updateNotifications();
}
@@ -1195,7 +1168,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
animateCollapsePanels();
}
}
- mIntercepted.remove(key);
setAreThereNotifications();
}
@@ -1351,9 +1323,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
// in "public" mode (atop a secure keyguard), secret notifs are totally hidden
continue;
}
- if (mIntercepted.isSyntheticEntry(ent)) {
- continue;
- }
toShow.add(ent.icon);
}