Merge "Forcibly recalculate size of the notification expanded view."
diff --git a/packages/SystemUI/res/layout/status_bar_expanded.xml b/packages/SystemUI/res/layout/status_bar_expanded.xml
index 82f41e6..dbbaf96 100644
--- a/packages/SystemUI/res/layout/status_bar_expanded.xml
+++ b/packages/SystemUI/res/layout/status_bar_expanded.xml
@@ -103,9 +103,9 @@
                 <TextView android:id="@+id/noNotificationsTitle"
                     android:layout_width="match_parent"
                     android:layout_height="wrap_content"
-                    android:background="@drawable/title_bar_portrait"
-                    android:paddingLeft="5dp"
-                    android:textAppearance="@style/TextAppearance.StatusBar.Title"
+                    android:textAppearance="@android:style/TextAppearance.Large"
+                    android:padding="8dp"
+                    android:gravity="center"
                     android:text="@string/status_bar_no_notifications_title"
                     />
 
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ExpandedView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ExpandedView.java
index 3276e1f..2d3ecae 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ExpandedView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ExpandedView.java
@@ -18,6 +18,7 @@
 
 import android.content.Context;
 import android.util.AttributeSet;
+import android.util.Slog;
 import android.widget.LinearLayout;
 
 public class ExpandedView extends LinearLayout {
@@ -44,8 +45,10 @@
          super.onLayout(changed, left, top, right, bottom);
          int height = bottom - top;
          if (height != mPrevHeight) {
-             //Slog.d(StatusBar.TAG, "height changed old=" + mPrevHeight
-             //     + " new=" + height);
+             if (PhoneStatusBar.DEBUG) {
+                 Slog.d(PhoneStatusBar.TAG, "ExpandedView height changed old=" + mPrevHeight
+                      + " new=" + height);
+             }
              mPrevHeight = height;
              mService.updateExpandedViewPos(PhoneStatusBar.EXPANDED_LEAVE_ALONE);
          }
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 d3671ed..e14317b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -255,6 +255,9 @@
 
         ExpandedView expanded = (ExpandedView)View.inflate(context,
                 R.layout.status_bar_expanded, null);
+        if (DEBUG) {
+            expanded.setBackgroundColor(0x6000FF80);
+        }
         expanded.mService = this;
 
         mIntruderAlertView = View.inflate(context, R.layout.intruder_alert, null);
@@ -1267,6 +1270,10 @@
             Slog.d(TAG, "panel: beginning to track the user's touch, y=" + y + " opening=" + opening);
         }
 
+        // there are some race conditions that cause this to be inaccurate; let's recalculate it any
+        // time we're about to drag the panel
+        updateExpandedSize();
+
         mTracking = true;
         mVelocityTracker = VelocityTracker.obtain();
         if (opening) {
@@ -1780,7 +1787,7 @@
     void updateExpandedViewPos(int expandedPosition) {
         if (SPEW) {
             Slog.d(TAG, "updateExpandedViewPos before expandedPosition=" + expandedPosition
-                    + " mTrackingParams.y=" + mTrackingParams.y
+                    + " mTrackingParams.y=" + ((mTrackingParams == null) ? "?" : mTrackingParams.y)
                     + " mTrackingPosition=" + mTrackingPosition);
         }
 
@@ -1824,6 +1831,16 @@
 
                 mExpandedParams.y = pos + mTrackingView.getHeight()
                         - (mTrackingParams.height-closePos) - contentsBottom;
+
+                if (SPEW) {
+                    Slog.d(PhoneStatusBar.TAG, 
+                            "pos=" + pos +
+                            " trackingHeight=" + mTrackingView.getHeight() +
+                            " (trackingParams.height - closePos)=" + 
+                                (mTrackingParams.height - closePos) +
+                            " contentsBottom=" + contentsBottom);
+                }
+
             } else {
                 // If the tracking view is not yet visible, then we can't have
                 // a good value of the close view location.  We need to wait for
@@ -1866,6 +1883,10 @@
     }
 
     int getExpandedHeight(int disph) {
+        if (DEBUG) {
+            Slog.d(TAG, "getExpandedHeight(" + disph + "): sbView="
+                    + mStatusBarView.getHeight() + " closeView=" + mCloseView.getHeight());
+        }
         return disph - mStatusBarView.getHeight() - mCloseView.getHeight();
     }
 
@@ -1875,6 +1896,9 @@
     }
 
     void updateExpandedSize() {
+        if (DEBUG) {
+            Slog.d(TAG, "updateExpandedSize()");
+        }
         if (mExpandedDialog != null && mExpandedParams != null && mDisplaySize != null) {
             mExpandedParams.width = mDisplaySize.x;
             mExpandedParams.height = getExpandedHeight(mDisplaySize.y);
@@ -1883,6 +1907,10 @@
             } else {
                 mExpandedDialog.getWindow().setAttributes(mExpandedParams);
             }
+            if (DEBUG) {
+                Slog.d(TAG, "updateExpandedSize: height=" + mExpandedParams.height + " " + 
+                    (mExpandedVisible ? "VISIBLE":"INVISIBLE"));
+            }
         }
     }