Fixed the appearing of the statusbar icons

The statusbar icons are now correctly appearing
in case there are no notifications instead of just
jumping.

This also fixed the general case, where the icons wouldn't
fade correctly in landscape

Change-Id: I38c6970b7663a8654a27555c2230e68de81a6da8
Test: observe fading of statusbar icons with and without notifications
Bug: 33652489
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
index 7f6322a..7500aa7 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
@@ -210,6 +210,7 @@
     private NotificationGroupManager mGroupManager;
     private boolean mOpening;
     private int mIndicationBottomPadding;
+    private boolean mIsFullWidth;
 
     public NotificationPanelView(Context context, AttributeSet attrs) {
         super(context, attrs);
@@ -302,6 +303,7 @@
     @Override
     protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
         super.onLayout(changed, left, top, right, bottom);
+        setIsFullWidth(mNotificationStackScroller.getWidth() == getWidth());
 
         // Update Clock Pivot
         mKeyguardStatusView.setPivotX(getWidth() / 2);
@@ -340,6 +342,11 @@
         updateMaxHeadsUpTranslation();
     }
 
+    private void setIsFullWidth(boolean isFullWidth) {
+        mIsFullWidth = isFullWidth;
+        mNotificationStackScroller.setIsFullWidth(isFullWidth);
+    }
+
     private void startQsSizeChangeAnimation(int oldHeight, final int newHeight) {
         if (mQsSizeChangeAnimator != null) {
             oldHeight = (int) mQsSizeChangeAnimator.getAnimatedValue();
@@ -736,7 +743,7 @@
 
     @Override
     protected float getOpeningHeight() {
-        return mNotificationStackScroller.getMinExpansionHeight();
+        return mNotificationStackScroller.getOpeningHeight();
     }
 
     @Override
@@ -2288,7 +2295,15 @@
         }
         mNotificationStackScroller.setExpandedHeight(expandedHeight);
         updateKeyguardBottomAreaAlpha();
-        setOpening(expandedHeight <= getOpeningHeight());
+        setOpening(isFullWidth() && expandedHeight < getOpeningHeight());
+    }
+
+    /**
+     * @return whether the notifications are displayed full width and don't have any margins on
+     *         the side.
+     */
+    public boolean isFullWidth() {
+        return mIsFullWidth;
     }
 
     private void setOpening(boolean opening) {
@@ -2401,12 +2416,11 @@
     }
 
     public boolean shouldHideNotificationIcons() {
-        return !mOpening && !isFullyCollapsed();
+        return !isFullWidth() || (!mOpening && !isFullyCollapsed());
     }
 
     public boolean shouldAnimateIconHiding() {
-        // TODO: handle this correctly, not completely working yet
-        return mNotificationStackScroller.getTranslationX() != 0;
+        return !isFullWidth();
     }
 
     private final FragmentListener mFragmentListener = new FragmentListener() {