Fix panel handles on large screens.

Bug: 7171620
Change-Id: If8445210fe654aa0b8ba508f4e6f93ad6d4fca14
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 9c978d5..c9ec481 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
@@ -21,19 +21,28 @@
 import android.graphics.Canvas;
 import android.graphics.drawable.Drawable;
 import android.util.AttributeSet;
+import android.view.View;
+
 import com.android.systemui.R;
 
 public class NotificationPanelView extends PanelView {
 
     Drawable mHandleBar;
     float mHandleBarHeight;
+    View mHandleView;
 
     public NotificationPanelView(Context context, AttributeSet attrs) {
         super(context, attrs);
+    }
 
-        Resources resources = context.getResources();
+    @Override
+    protected void onFinishInflate() {
+        super.onFinishInflate();
+
+        Resources resources = getContext().getResources();
         mHandleBar = resources.getDrawable(R.drawable.status_bar_close);
         mHandleBarHeight = resources.getDimension(R.dimen.close_handle_height);
+        mHandleView = findViewById(R.id.handle);
     }
 
     @Override
@@ -44,19 +53,24 @@
         super.fling(vel, always);
     }
 
+    // We draw the handle ourselves so that it's always glued to the bottom of the window.
     @Override
     protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
         super.onLayout(changed, left, top, right, bottom);
         if (changed) {
-            mHandleBar.setBounds(0, 0, getWidth(), (int) mHandleBarHeight);
+            final int pl = getPaddingLeft();
+            final int pr = getPaddingRight();
+            mHandleBar.setBounds(pl, 0, getWidth() - pr, (int) mHandleBarHeight);
         }
     }
 
     @Override
     public void draw(Canvas canvas) {
         super.draw(canvas);
-        canvas.translate(0, getHeight() - mHandleBarHeight);
+        final int off = (int) (getHeight() - mHandleBarHeight - getPaddingBottom());
+        canvas.translate(0, off);
+        mHandleBar.setState(mHandleView.getDrawableState());
         mHandleBar.draw(canvas);
-        canvas.translate(0, -getHeight() + mHandleBarHeight);
+        canvas.translate(0, -off);
     }
 }