Skip to content

Commit 195b6e1

Browse files
dsandlerAndroid (Google) Code Review
authored andcommitted
Merge "Fix panel handles on large screens." into jb-mr1-dev
2 parents 13701b5 + 13522a2 commit 195b6e1

File tree

7 files changed

+74
-31
lines changed

7 files changed

+74
-31
lines changed

packages/SystemUI/res/layout/quick_settings.xml

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,27 +24,21 @@
2424
<!-- TODO: Put into ScrollView -->
2525
<ScrollView
2626
android:layout_width="match_parent"
27-
android:layout_height="wrap_content">
28-
<com.android.systemui.statusbar.phone.QuickSettingsContainerView
29-
android:id="@+id/quick_settings_container"
30-
android:layout_width="match_parent"
31-
android:layout_height="wrap_content"
32-
android:animateLayoutChanges="true"
33-
android:columnCount="@integer/quick_settings_num_columns"
34-
/>
35-
</ScrollView>
36-
<LinearLayout android:id="@+id/handle"
37-
android:layout_width="match_parent"
38-
android:layout_height="@dimen/close_handle_height"
39-
android:layout_gravity="bottom"
40-
android:orientation="vertical"
27+
android:layout_height="wrap_content"
28+
android:layout_marginBottom="@dimen/close_handle_underlap"
4129
>
42-
<ImageView
30+
<com.android.systemui.statusbar.phone.QuickSettingsContainerView
31+
android:id="@+id/quick_settings_container"
4332
android:layout_width="match_parent"
44-
android:layout_height="@dimen/close_handle_height"
45-
android:layout_gravity="bottom"
46-
android:scaleType="fitXY"
47-
android:src="@drawable/status_bar_close"
33+
android:layout_height="wrap_content"
34+
android:animateLayoutChanges="true"
35+
android:columnCount="@integer/quick_settings_num_columns"
4836
/>
49-
</LinearLayout>
37+
</ScrollView>
38+
39+
<View
40+
android:id="@+id/handle"
41+
android:layout_width="match_parent"
42+
android:layout_height="@dimen/close_handle_height"
43+
/>
5044
</com.android.systemui.statusbar.phone.SettingsPanelView >

packages/SystemUI/res/layout/status_bar_expanded.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,9 @@
7676
</ScrollView>
7777
</LinearLayout>
7878

79-
<View android:id="@+id/handle"
79+
<View
80+
android:id="@+id/handle"
8081
android:layout_width="match_parent"
8182
android:layout_height="@dimen/close_handle_height"
82-
android:layout_gravity="bottom"
8383
/>
84-
8584
</com.android.systemui.statusbar.phone.NotificationPanelView><!-- end of sliding panel -->

packages/SystemUI/res/values/dimens.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,10 @@
146146
<dimen name="navbar_search_panel_height">230dip</dimen>
147147

148148
<!-- Height of the draggable handle at the bottom of the phone notification panel -->
149-
<dimen name="close_handle_height">32dp</dimen>
149+
<dimen name="close_handle_height">36dp</dimen>
150150

151-
<!-- Amount of close_handle that will not overlap the notification list -->
152-
<dimen name="close_handle_underlap">18dp</dimen>
151+
<!-- Amount of close_handle that will NOT overlap the notification list -->
152+
<dimen name="close_handle_underlap">32dp</dimen>
153153

154154
<!-- Height of the notification panel header bar -->
155155
<dimen name="notification_panel_header_height">48dp</dimen>

packages/SystemUI/src/com/android/systemui/statusbar/phone/CloseDragHandle.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ public CloseDragHandle(Context context, AttributeSet attrs) {
3636
*/
3737
@Override
3838
public boolean onTouchEvent(MotionEvent event) {
39-
if (event.getAction() != MotionEvent.ACTION_DOWN) {
39+
if (event.getAction() == MotionEvent.ACTION_DOWN) {
40+
setPressed(true);
41+
} else {
4042
mService.interceptTouchEvent(event);
4143
}
4244
return true;

packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,28 @@
2121
import android.graphics.Canvas;
2222
import android.graphics.drawable.Drawable;
2323
import android.util.AttributeSet;
24+
import android.view.View;
25+
2426
import com.android.systemui.R;
2527

2628
public class NotificationPanelView extends PanelView {
2729

2830
Drawable mHandleBar;
2931
float mHandleBarHeight;
32+
View mHandleView;
3033

3134
public NotificationPanelView(Context context, AttributeSet attrs) {
3235
super(context, attrs);
36+
}
37+
38+
@Override
39+
protected void onFinishInflate() {
40+
super.onFinishInflate();
3341

34-
Resources resources = context.getResources();
42+
Resources resources = getContext().getResources();
3543
mHandleBar = resources.getDrawable(R.drawable.status_bar_close);
3644
mHandleBarHeight = resources.getDimension(R.dimen.close_handle_height);
45+
mHandleView = findViewById(R.id.handle);
3746
}
3847

3948
@Override
@@ -44,19 +53,24 @@ public void fling(float vel, boolean always) {
4453
super.fling(vel, always);
4554
}
4655

56+
// We draw the handle ourselves so that it's always glued to the bottom of the window.
4757
@Override
4858
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
4959
super.onLayout(changed, left, top, right, bottom);
5060
if (changed) {
51-
mHandleBar.setBounds(0, 0, getWidth(), (int) mHandleBarHeight);
61+
final int pl = getPaddingLeft();
62+
final int pr = getPaddingRight();
63+
mHandleBar.setBounds(pl, 0, getWidth() - pr, (int) mHandleBarHeight);
5264
}
5365
}
5466

5567
@Override
5668
public void draw(Canvas canvas) {
5769
super.draw(canvas);
58-
canvas.translate(0, getHeight() - mHandleBarHeight);
70+
final int off = (int) (getHeight() - mHandleBarHeight - getPaddingBottom());
71+
canvas.translate(0, off);
72+
mHandleBar.setState(mHandleView.getDrawableState());
5973
mHandleBar.draw(canvas);
60-
canvas.translate(0, -getHeight() + mHandleBarHeight);
74+
canvas.translate(0, -off);
6175
}
6276
}

packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ public boolean onTouch(View v, MotionEvent event) {
220220
switch (event.getAction()) {
221221
case MotionEvent.ACTION_DOWN:
222222
mTracking = true;
223+
mHandleView.setPressed(true);
223224
mInitialTouchY = y;
224225
mVelocityTracker = VelocityTracker.obtain();
225226
trackMovement(event);
@@ -239,6 +240,7 @@ public boolean onTouch(View v, MotionEvent event) {
239240
case MotionEvent.ACTION_CANCEL:
240241
mFinalTouchY = y;
241242
mTracking = false;
243+
mHandleView.setPressed(false);
242244
mBar.onTrackingStopped(PanelView.this);
243245
trackMovement(event);
244246
mVelocityTracker.computeCurrentVelocity(1000);

packages/SystemUI/src/com/android/systemui/statusbar/phone/SettingsPanelView.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import android.content.Context;
2121
import android.content.Intent;
2222
import android.content.res.Resources;
23+
import android.graphics.Canvas;
24+
import android.graphics.drawable.Drawable;
2325
import android.util.AttributeSet;
2426
import android.view.LayoutInflater;
2527
import 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

Comments
 (0)