Skip to content

Commit 73b9c29

Browse files
committed
Notification panel on tablet does not handle back and home key events.
1. Notification panel on tablet does not handle back and home key events and as a result the notification panel stays open. Hence, after opening the notifications panel, pressing the back key on a keyboard will move back in the app instead closing the panel. Same happens for the home key. The expected behavior is if the panel is open the back button will dismiss it and the key should be consumed by the panel. The home key should hide the panel and the key should not be consumed by the panel so the system can do the right thing. bug:6902903 Change-Id: I06e8ceea1f51b998e6703d70dcb3a24128d5a581
1 parent a39fdd1 commit 73b9c29

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

packages/SystemUI/src/com/android/systemui/statusbar/tablet/NotificationPanel.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import android.util.AttributeSet;
2626
import android.util.Slog;
2727
import android.view.Gravity;
28+
import android.view.KeyEvent;
2829
import android.view.LayoutInflater;
2930
import android.view.MotionEvent;
3031
import android.view.View;
@@ -34,7 +35,6 @@
3435
import android.view.animation.DecelerateInterpolator;
3536
import android.view.animation.Interpolator;
3637
import android.widget.RelativeLayout;
37-
import android.widget.ScrollView;
3838

3939
import com.android.systemui.ExpandHelper;
4040
import com.android.systemui.R;
@@ -197,6 +197,27 @@ public boolean dispatchHoverEvent(MotionEvent event) {
197197
return true;
198198
}
199199

200+
@Override
201+
public boolean dispatchKeyEvent(KeyEvent event) {
202+
final int keyCode = event.getKeyCode();
203+
switch (keyCode) {
204+
// We exclusively handle the back key by hiding this panel.
205+
case KeyEvent.KEYCODE_BACK: {
206+
if (event.getAction() == KeyEvent.ACTION_UP) {
207+
mBar.animateCollapse();
208+
}
209+
return true;
210+
}
211+
// We react to the home key but let the system handle it.
212+
case KeyEvent.KEYCODE_HOME: {
213+
if (event.getAction() == KeyEvent.ACTION_UP) {
214+
mBar.animateCollapse();
215+
}
216+
} break;
217+
}
218+
return super.dispatchKeyEvent(event);
219+
}
220+
200221
/*
201222
@Override
202223
protected void onLayout(boolean changed, int l, int t, int r, int b) {

0 commit comments

Comments
 (0)