Skip to content

Commit e825b3e

Browse files
dsandlerAndroid (Google) Code Review
authored andcommitted
Merge "Back button dismisses notifications again." into jb-dev
2 parents 0008f73 + c4f2a56 commit e825b3e

File tree

5 files changed

+61
-6
lines changed

5 files changed

+61
-6
lines changed

packages/SystemUI/res/layout-sw600dp/super_status_bar.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@
1818
-->
1919

2020
<!-- This is the combined status bar / notification panel window. -->
21-
<FrameLayout
21+
<com.android.systemui.statusbar.phone.StatusBarWindowView
2222
xmlns:android="http://schemas.android.com/apk/res/android"
2323
xmlns:systemui="http://schemas.android.com/apk/res/com.android.systemui"
24+
android:focusable="true"
25+
android:descendantFocusability="afterDescendants"
2426
android:fitsSystemWindows="true"
2527
>
2628

@@ -35,4 +37,4 @@
3537
android:layout_height="@*android:dimen/status_bar_height"
3638
/>
3739

38-
</FrameLayout>
40+
</com.android.systemui.statusbar.phone.StatusBarWindowView>

packages/SystemUI/res/layout/super_status_bar.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
-->
1919

2020
<!-- This is the combined status bar / notification panel window. -->
21-
<FrameLayout
21+
<com.android.systemui.statusbar.phone.StatusBarWindowView
2222
xmlns:android="http://schemas.android.com/apk/res/android"
2323
xmlns:systemui="http://schemas.android.com/apk/res/com.android.systemui"
2424
android:focusable="true"
@@ -36,4 +36,4 @@
3636
android:layout_height="@*android:dimen/status_bar_height"
3737
/>
3838

39-
</FrameLayout>
39+
</com.android.systemui.statusbar.phone.StatusBarWindowView>

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public class PhoneStatusBar extends BaseStatusBar {
147147

148148
IWindowManager mWindowManager;
149149

150-
View mStatusBarWindow;
150+
StatusBarWindowView mStatusBarWindow;
151151
PhoneStatusBarView mStatusBarView;
152152

153153
int mPixelFormat;
@@ -280,11 +280,12 @@ protected PhoneStatusBarView makeStatusBarView() {
280280

281281
mIconSize = res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_icon_size);
282282

283-
mStatusBarWindow = View.inflate(context,
283+
mStatusBarWindow = (StatusBarWindowView) View.inflate(context,
284284
R.layout.super_status_bar, null);
285285
if (DEBUG) {
286286
mStatusBarWindow.setBackgroundColor(0x6000FF80);
287287
}
288+
mStatusBarWindow.mService = this;
288289
mStatusBarWindow.setOnTouchListener(new View.OnTouchListener() {
289290
@Override
290291
public boolean onTouch(View v, MotionEvent event) {
@@ -1141,10 +1142,13 @@ private void makeExpandedVisible() {
11411142
// Expand the window to encompass the full screen in anticipation of the drag.
11421143
// This is only possible to do atomically because the status bar is at the top of the screen!
11431144
WindowManager.LayoutParams lp = (WindowManager.LayoutParams) mStatusBarWindow.getLayoutParams();
1145+
lp.flags &= (~WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
11441146
lp.height = ViewGroup.LayoutParams.MATCH_PARENT;
11451147
final WindowManager wm = WindowManagerImpl.getDefault();
11461148
wm.updateViewLayout(mStatusBarWindow, lp);
11471149

1150+
mStatusBarWindow.requestFocus(View.FOCUS_FORWARD);
1151+
11481152
visibilityChanged(true);
11491153
}
11501154

@@ -1231,6 +1235,7 @@ void performCollapse() {
12311235
// Shrink the window to the size of the status bar only
12321236
WindowManager.LayoutParams lp = (WindowManager.LayoutParams) mStatusBarWindow.getLayoutParams();
12331237
lp.height = getStatusBarHeight();
1238+
lp.flags |= (WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
12341239
final WindowManager wm = WindowManagerImpl.getDefault();
12351240
wm.updateViewLayout(mStatusBarWindow, lp);
12361241

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import android.graphics.Rect;
2323
import android.os.SystemClock;
2424
import android.util.AttributeSet;
25+
import android.view.KeyEvent;
2526
import android.view.MotionEvent;
2627
import android.view.View;
2728
import android.view.ViewGroup;
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright (C) 2012 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.android.systemui.statusbar.phone;
18+
19+
import android.content.Context;
20+
import android.util.AttributeSet;
21+
import android.view.KeyEvent;
22+
import android.widget.FrameLayout;
23+
import android.widget.TextSwitcher;
24+
25+
26+
public class StatusBarWindowView extends FrameLayout
27+
{
28+
PhoneStatusBar mService;
29+
30+
public StatusBarWindowView(Context context, AttributeSet attrs) {
31+
super(context, attrs);
32+
}
33+
34+
@Override
35+
public boolean dispatchKeyEvent(KeyEvent event) {
36+
boolean down = event.getAction() == KeyEvent.ACTION_DOWN;
37+
switch (event.getKeyCode()) {
38+
case KeyEvent.KEYCODE_BACK:
39+
if (!down) {
40+
mService.animateCollapse();
41+
}
42+
return true;
43+
}
44+
return super.dispatchKeyEvent(event);
45+
}
46+
}
47+

0 commit comments

Comments
 (0)