Merge "Quantum ripple for ListView selector"
diff --git a/core/java/android/service/notification/ConditionProviderService.java b/core/java/android/service/notification/ConditionProviderService.java
index 70d474e..d6ef8f5 100644
--- a/core/java/android/service/notification/ConditionProviderService.java
+++ b/core/java/android/service/notification/ConditionProviderService.java
@@ -69,8 +69,13 @@
         return mNoMan;
     }
 
-    public final void notifyConditions(Condition[] conditions) {
-        if (!isBound()) return;
+    public final void notifyCondition(Condition condition) {
+        if (condition == null) return;
+        notifyConditions(new Condition[]{ condition });
+    }
+
+    public final void notifyConditions(Condition... conditions) {
+        if (!isBound() || conditions == null) return;
         try {
             getNotificationInterface().notifyConditions(getPackageName(), mProvider, conditions);
         } catch (android.os.RemoteException ex) {
diff --git a/core/res/res/drawable/btn_borderless_quantum.xml b/core/res/res/drawable/btn_borderless_quantum.xml
index 69a891a..2e3c515 100644
--- a/core/res/res/drawable/btn_borderless_quantum.xml
+++ b/core/res/res/drawable/btn_borderless_quantum.xml
@@ -16,7 +16,6 @@
 
 <touch-feedback xmlns:android="http://schemas.android.com/apk/res/android"
     android:tint="?attr/colorButtonPressed">
-    <item android:drawable="@color/transparent" />
     <item android:id="@id/mask"
         android:drawable="@drawable/btn_qntm_alpha" />
 </touch-feedback>
diff --git a/core/res/res/drawable/dialog_background_quantum.xml b/core/res/res/drawable/dialog_background_quantum.xml
new file mode 100644
index 0000000..7e5b003
--- /dev/null
+++ b/core/res/res/drawable/dialog_background_quantum.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+    android:shape="rectangle">
+
+    <corners
+        android:radius="2dp" />
+    <solid
+        android:color="?attr/colorBackground" />
+
+</shape>
diff --git a/core/res/res/layout/alert_dialog_quantum.xml b/core/res/res/layout/alert_dialog_quantum.xml
index 537162a..80e34cb 100644
--- a/core/res/res/layout/alert_dialog_quantum.xml
+++ b/core/res/res/layout/alert_dialog_quantum.xml
@@ -20,7 +20,10 @@
     android:id="@+id/parentPanel"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
-    android:orientation="vertical">
+    android:orientation="vertical"
+    android:background="@drawable/dialog_background_quantum"
+    android:translationZ="@dimen/floating_window_z"
+    android:layout_margin="@dimen/floating_window_margin">
 
     <LinearLayout android:id="@+id/topPanel"
         android:layout_width="match_parent"
diff --git a/core/res/res/values/dimens_quantum.xml b/core/res/res/values/dimens_quantum.xml
index 02e61e2..cebee12 100644
--- a/core/res/res/values/dimens_quantum.xml
+++ b/core/res/res/values/dimens_quantum.xml
@@ -47,4 +47,6 @@
     <dimen name="text_size_menu_quantum">14sp</dimen>
     <dimen name="text_size_button_quantum">14sp</dimen>
 
+    <dimen name="floating_window_z">16dp</dimen>
+    <dimen name="floating_window_margin">32dp</dimen>
 </resources>
diff --git a/core/res/res/values/styles_quantum.xml b/core/res/res/values/styles_quantum.xml
index 5013a74..57f2443 100644
--- a/core/res/res/values/styles_quantum.xml
+++ b/core/res/res/values/styles_quantum.xml
@@ -1019,16 +1019,16 @@
     <!-- Dialog styles -->
 
     <style name="AlertDialog.Quantum" parent="AlertDialog">
-        <item name="fullDark">?attr/colorBackground</item>
-        <item name="topDark">?attr/colorBackground</item>
-        <item name="centerDark">?attr/colorBackground</item>
-        <item name="bottomDark">?attr/colorBackground</item>
-        <item name="fullBright">?attr/colorBackground</item>
-        <item name="topBright">?attr/colorBackground</item>
-        <item name="centerBright">?attr/colorBackground</item>
-        <item name="bottomBright">?attr/colorBackground</item>
-        <item name="bottomMedium">?attr/colorBackground</item>
-        <item name="centerMedium">?attr/colorBackground</item>
+        <item name="fullDark">@color/transparent</item>
+        <item name="topDark">@color/transparent</item>
+        <item name="centerDark">@color/transparent</item>
+        <item name="bottomDark">@color/transparent</item>
+        <item name="fullBright">@color/transparent</item>
+        <item name="topBright">@color/transparent</item>
+        <item name="centerBright">@color/transparent</item>
+        <item name="bottomBright">@color/transparent</item>
+        <item name="bottomMedium">@color/transparent</item>
+        <item name="centerMedium">@color/transparent</item>
         <item name="layout">@layout/alert_dialog_quantum</item>
         <item name="listLayout">@layout/select_dialog_quantum</item>
         <item name="progressLayout">@layout/progress_dialog_quantum</item>
diff --git a/core/res/res/values/themes_quantum.xml b/core/res/res/values/themes_quantum.xml
index a7e286d..9f76eae 100644
--- a/core/res/res/values/themes_quantum.xml
+++ b/core/res/res/values/themes_quantum.xml
@@ -898,7 +898,7 @@
     <style name="Theme.Quantum.Dialog">
         <item name="windowFrame">@null</item>
         <item name="windowTitleStyle">@style/DialogWindowTitle.Quantum</item>
-        <item name="windowBackground">?attr/colorBackground</item>
+        <item name="windowBackground">@drawable/dialog_background_quantum</item>
         <item name="windowIsFloating">true</item>
         <item name="windowContentOverlay">@null</item>
         <item name="windowAnimationStyle">@style/Animation.Quantum.Dialog</item>
@@ -964,8 +964,6 @@
          its pixels. -->
     <style name="Theme.Quantum.Dialog.NoFrame">
         <item name="windowBackground">@color/transparent</item>
-        <item name="windowFrame">@null</item>
-        <item name="windowContentOverlay">@null</item>
         <item name="windowAnimationStyle">@null</item>
         <item name="backgroundDimEnabled">false</item>
         <item name="windowIsTranslucent">true</item>
@@ -981,7 +979,6 @@
     <style name="Theme.Quantum.Dialog.Alert">
         <item name="windowBackground">@color/transparent</item>
         <item name="windowTitleStyle">@style/DialogWindowTitle.Quantum</item>
-        <item name="windowContentOverlay">@null</item>
         <item name="windowMinWidthMajor">@dimen/dialog_min_width_major</item>
         <item name="windowMinWidthMinor">@dimen/dialog_min_width_minor</item>
     </style>
@@ -1102,7 +1099,6 @@
     <style name="Theme.Quantum.Light.Dialog.Alert">
         <item name="windowBackground">@color/transparent</item>
         <item name="windowTitleStyle">@style/DialogWindowTitle.Quantum.Light</item>
-        <item name="windowContentOverlay">@null</item>
         <item name="windowMinWidthMajor">@dimen/dialog_min_width_major</item>
         <item name="windowMinWidthMinor">@dimen/dialog_min_width_minor</item>
     </style>
@@ -1112,7 +1108,6 @@
     <style name="Theme.Quantum.Light.Dialog.TimePicker">
         <item name="windowBackground">@color/transparent</item>
         <item name="windowTitleStyle">@style/DialogWindowTitle.Quantum.Light</item>
-        <item name="windowContentOverlay">@null</item>
     </style>
 
     <!-- Theme for a presentation window on a secondary display. -->
diff --git a/services/core/java/com/android/server/notification/ConditionProviders.java b/services/core/java/com/android/server/notification/ConditionProviders.java
index 2c5d69c..29af433 100644
--- a/services/core/java/com/android/server/notification/ConditionProviders.java
+++ b/services/core/java/com/android/server/notification/ConditionProviders.java
@@ -23,6 +23,7 @@
 import android.os.IInterface;
 import android.os.RemoteException;
 import android.provider.Settings;
+import android.provider.Settings.Global;
 import android.service.notification.Condition;
 import android.service.notification.ConditionProviderService;
 import android.service.notification.IConditionListener;
@@ -51,6 +52,7 @@
             UserProfiles userProfiles, ZenModeHelper zenModeHelper) {
         super(context, handler, new Object(), userProfiles);
         mZenModeHelper = zenModeHelper;
+        mZenModeHelper.addCallback(new ZenModeHelperCallback());
     }
 
     @Override
@@ -235,4 +237,21 @@
             }
         }
     }
+
+    private class ZenModeHelperCallback extends ZenModeHelper.Callback {
+        @Override
+        void onZenModeChanged() {
+            final int mode = mZenModeHelper.getZenMode();
+            if (mode == Global.ZEN_MODE_OFF) {
+                synchronized (mMutex) {
+                    if (mCurrentConditionId != null) {
+                        if (DEBUG) Slog.d(TAG, "Zen mode off, forcing unsubscribe from "
+                                + mCurrentConditionId);
+                        unsubscribeLocked(mCurrentConditionId);
+                        mCurrentConditionId = null;
+                    }
+                }
+            }
+        }
+    }
 }
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index 96e3a9f..6e4eb565 100644
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -840,7 +840,7 @@
 
         mHandler = new WorkerHandler();
         mZenModeHelper = new ZenModeHelper(getContext(), mHandler);
-        mZenModeHelper.setCallback(new ZenModeHelper.Callback() {
+        mZenModeHelper.addCallback(new ZenModeHelper.Callback() {
             @Override
             public void onConfigChanged() {
                 savePolicyFile();
diff --git a/services/core/java/com/android/server/notification/ZenModeHelper.java b/services/core/java/com/android/server/notification/ZenModeHelper.java
index b06e0cb..137730a 100644
--- a/services/core/java/com/android/server/notification/ZenModeHelper.java
+++ b/services/core/java/com/android/server/notification/ZenModeHelper.java
@@ -46,6 +46,7 @@
 
 import java.io.IOException;
 import java.io.PrintWriter;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Calendar;
 import java.util.Date;
@@ -69,8 +70,8 @@
     private final SettingsObserver mSettingsObserver;
     private final AppOpsManager mAppOps;
     private final ZenModeConfig mDefaultConfig;
+    private final ArrayList<Callback> mCallbacks = new ArrayList<Callback>();
 
-    private Callback mCallback;
     private int mZenMode;
     private ZenModeConfig mConfig;
 
@@ -115,8 +116,8 @@
         return new ZenModeConfig();
     }
 
-    public void setCallback(Callback callback) {
-        mCallback = callback;
+    public void addCallback(Callback callback) {
+        mCallbacks.add(callback);
     }
 
     public boolean shouldIntercept(String pkg, Notification n) {
@@ -132,6 +133,10 @@
         return false;
     }
 
+    public int getZenMode() {
+        return mZenMode;
+    }
+
     public void setZenMode(int zenModeValue) {
         Global.putInt(mContext.getContentResolver(), Global.ZEN_MODE, zenModeValue);
     }
@@ -161,6 +166,7 @@
         mAppOps.setRestriction(AppOpsManager.OP_VIBRATE, AudioManager.USE_DEFAULT_STREAM_TYPE,
                 zen ? AppOpsManager.MODE_IGNORED : AppOpsManager.MODE_ALLOWED,
                 exceptionPackages);
+        dispatchOnZenModeChanged();
     }
 
     public boolean allowDisable(int what, IBinder token, String pkg) {
@@ -197,7 +203,7 @@
         if (config.equals(mConfig)) return true;
         mConfig = config;
         Slog.d(TAG, "mConfig=" + mConfig);
-        if (mCallback != null) mCallback.onConfigChanged();
+        dispatchOnConfigChanged();
         final String val = Integer.toString(mConfig.hashCode());
         Global.putString(mContext.getContentResolver(), Global.ZEN_MODE_CONFIG_ETAG, val);
         updateAlarms();
@@ -205,6 +211,18 @@
         return true;
     }
 
+    private void dispatchOnConfigChanged() {
+        for (Callback callback : mCallbacks) {
+            callback.onConfigChanged();
+        }
+    }
+
+    private void dispatchOnZenModeChanged() {
+        for (Callback callback : mCallbacks) {
+            callback.onZenModeChanged();
+        }
+    }
+
     private boolean isCall(String pkg, Notification n) {
         return CALL_PACKAGES.contains(pkg);
     }
@@ -310,7 +328,8 @@
         }
     }
 
-    public interface Callback {
-        void onConfigChanged();
+    public static class Callback {
+        void onConfigChanged() {}
+        void onZenModeChanged() {}
     }
 }