From 30e387ddcef1f65485daaba7bea267d6d8ceeb18 Mon Sep 17 00:00:00 2001 From: Selim Cinek Date: Mon, 11 Jan 2016 18:01:47 -0800 Subject: [PATCH] Fixed a bug where the dozemode wasn't working correctly There where 2 different issues which could lead to the dozemode not working correctly: 1. The new workarabout where we show the expanded notification if it has the same size as the collapsed, requires that dozemode is also called on the right notification 2. When the children were not layed out yet, this calculation could be wrong and the wrong child was selected, leading to the same issue. Bug: 26459664 Change-Id: Ib67dcaf2ba9b8b9a1bfa5ece5b7d6c4dff677939 --- .../statusbar/NotificationContentView.java | 27 ++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java index 760dd201cb63..5da0e9ce7bc6 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java @@ -55,6 +55,14 @@ public class NotificationContentView extends FrameLayout { private final int mRoundRectRadius; private final boolean mRoundRectClippingEnabled; private final int mMinContractedHeight; + private final OnLayoutChangeListener mLayoutUpdater = new OnLayoutChangeListener() { + @Override + public void onLayoutChange(View v, int left, int top, int right, int bottom, + int oldLeft, + int oldTop, int oldRight, int oldBottom) { + selectLayout(false /* animate */, false /* force */); + } + }; private View mContractedChild; @@ -235,10 +243,12 @@ public class NotificationContentView extends FrameLayout { public void setContractedChild(View child) { if (mContractedChild != null) { mContractedChild.animate().cancel(); + mContractedChild.removeOnLayoutChangeListener(mLayoutUpdater); removeView(mContractedChild); } addView(child); mContractedChild = child; + mContractedChild.addOnLayoutChangeListener(mLayoutUpdater); mContractedWrapper = NotificationViewWrapper.wrap(getContext(), child); selectLayout(false /* animate */, true /* force */); mContractedWrapper.setDark(mDark, false /* animate */, 0 /* delay */); @@ -248,10 +258,12 @@ public class NotificationContentView extends FrameLayout { public void setExpandedChild(View child) { if (mExpandedChild != null) { mExpandedChild.animate().cancel(); + mExpandedChild.removeOnLayoutChangeListener(mLayoutUpdater); removeView(mExpandedChild); } addView(child); mExpandedChild = child; + mExpandedChild.addOnLayoutChangeListener(mLayoutUpdater); mExpandedWrapper = NotificationViewWrapper.wrap(getContext(), child); selectLayout(false /* animate */, true /* force */); updateRoundRectClipping(); @@ -260,10 +272,12 @@ public class NotificationContentView extends FrameLayout { public void setHeadsUpChild(View child) { if (mHeadsUpChild != null) { mHeadsUpChild.animate().cancel(); + mHeadsUpChild.removeOnLayoutChangeListener(mLayoutUpdater); removeView(mHeadsUpChild); } addView(child); mHeadsUpChild = child; + mHeadsUpChild.addOnLayoutChangeListener(mLayoutUpdater); mHeadsUpWrapper = NotificationViewWrapper.wrap(getContext(), child); selectLayout(false /* animate */, true /* force */); updateRoundRectClipping(); @@ -483,8 +497,17 @@ public class NotificationContentView extends FrameLayout { public void setDark(boolean dark, boolean fade, long delay) { if (mDark == dark || mContractedChild == null) return; mDark = dark; - mContractedWrapper.setDark(dark && !mShowingLegacyBackground, fade, delay); - if (mSingleLineView != null) { + dark = dark && !mShowingLegacyBackground; + if (mVisibleType == VISIBLE_TYPE_CONTRACTED) { + mContractedWrapper.setDark(dark, fade, delay); + } + if (mVisibleType == VISIBLE_TYPE_EXPANDED) { + mExpandedWrapper.setDark(dark, fade, delay); + } + if (mVisibleType == VISIBLE_TYPE_HEADSUP) { + mHeadsUpWrapper.setDark(dark, fade, delay); + } + if (mSingleLineView != null && mVisibleType == VISIBLE_TYPE_SINGLELINE) { mSingleLineView.setDark(dark, fade, delay); } } -- 2.11.0