2020import android .content .Context ;
2121import android .content .Intent ;
2222import android .content .res .Resources ;
23+ import android .graphics .Canvas ;
24+ import android .graphics .drawable .Drawable ;
2325import android .util .AttributeSet ;
2426import android .view .LayoutInflater ;
2527import android .view .View ;
@@ -37,6 +39,10 @@ public class SettingsPanelView extends PanelView {
3739 private QuickSettings mQS ;
3840 private QuickSettingsContainerView mQSContainer ;
3941
42+ Drawable mHandleBar ;
43+ float mHandleBarHeight ;
44+ View mHandleView ;
45+
4046 public SettingsPanelView (Context context , AttributeSet attrs ) {
4147 super (context , attrs );
4248 }
@@ -47,6 +53,11 @@ protected void onFinishInflate() {
4753
4854 mQSContainer = (QuickSettingsContainerView ) findViewById (R .id .quick_settings_container );
4955 mQS = new QuickSettings (getContext (), mQSContainer );
56+
57+ Resources resources = getContext ().getResources ();
58+ mHandleBar = resources .getDrawable (R .drawable .status_bar_close );
59+ mHandleBarHeight = resources .getDimension (R .dimen .close_handle_height );
60+ mHandleView = findViewById (R .id .handle );
5061 }
5162
5263 @ Override
@@ -95,4 +106,25 @@ public void setService(PhoneStatusBar phoneStatusBar) {
95106 mQS .setService (phoneStatusBar );
96107 }
97108 }
109+
110+ // We draw the handle ourselves so that it's always glued to the bottom of the window.
111+ @ Override
112+ protected void onLayout (boolean changed , int left , int top , int right , int bottom ) {
113+ super .onLayout (changed , left , top , right , bottom );
114+ if (changed ) {
115+ final int pl = getPaddingLeft ();
116+ final int pr = getPaddingRight ();
117+ mHandleBar .setBounds (pl , 0 , getWidth () - pr , (int ) mHandleBarHeight );
118+ }
119+ }
120+
121+ @ Override
122+ public void draw (Canvas canvas ) {
123+ super .draw (canvas );
124+ final int off = (int ) (getHeight () - mHandleBarHeight - getPaddingBottom ());
125+ canvas .translate (0 , off );
126+ mHandleBar .setState (mHandleView .getDrawableState ());
127+ mHandleBar .draw (canvas );
128+ canvas .translate (0 , -off );
129+ }
98130}
0 commit comments