Skip to content

Commit c4f2a56

Browse files
committed
Back button dismisses notifications again.
Bug: 6441337 Change-Id: Iabc97cd2a3f66ee2af5406807b3023908965b8c8
1 parent 5380cdc commit c4f2a56

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
@@ -148,7 +148,7 @@ public class PhoneStatusBar extends BaseStatusBar {
148148

149149
IWindowManager mWindowManager;
150150

151-
View mStatusBarWindow;
151+
StatusBarWindowView mStatusBarWindow;
152152
PhoneStatusBarView mStatusBarView;
153153

154154
int mPixelFormat;
@@ -283,11 +283,12 @@ protected PhoneStatusBarView makeStatusBarView() {
283283

284284
mIconSize = res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_icon_size);
285285

286-
mStatusBarWindow = View.inflate(context,
286+
mStatusBarWindow = (StatusBarWindowView) View.inflate(context,
287287
R.layout.super_status_bar, null);
288288
if (DEBUG) {
289289
mStatusBarWindow.setBackgroundColor(0x6000FF80);
290290
}
291+
mStatusBarWindow.mService = this;
291292
mStatusBarWindow.setOnTouchListener(new View.OnTouchListener() {
292293
@Override
293294
public boolean onTouch(View v, MotionEvent event) {
@@ -1134,10 +1135,13 @@ private void makeExpandedVisible() {
11341135
// Expand the window to encompass the full screen in anticipation of the drag.
11351136
// This is only possible to do atomically because the status bar is at the top of the screen!
11361137
WindowManager.LayoutParams lp = (WindowManager.LayoutParams) mStatusBarWindow.getLayoutParams();
1138+
lp.flags &= (~WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
11371139
lp.height = ViewGroup.LayoutParams.MATCH_PARENT;
11381140
final WindowManager wm = WindowManagerImpl.getDefault();
11391141
wm.updateViewLayout(mStatusBarWindow, lp);
11401142

1143+
mStatusBarWindow.requestFocus(View.FOCUS_FORWARD);
1144+
11411145
visibilityChanged(true);
11421146
}
11431147

@@ -1224,6 +1228,7 @@ void performCollapse() {
12241228
// Shrink the window to the size of the status bar only
12251229
WindowManager.LayoutParams lp = (WindowManager.LayoutParams) mStatusBarWindow.getLayoutParams();
12261230
lp.height = getStatusBarHeight();
1231+
lp.flags |= (WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
12271232
final WindowManager wm = WindowManagerImpl.getDefault();
12281233
wm.updateViewLayout(mStatusBarWindow, lp);
12291234

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)