From 56cf73a0f4704c2d1665ed0287fecea3cd871a51 Mon Sep 17 00:00:00 2001 From: Adrian Roos Date: Mon, 18 Jul 2016 14:23:32 -0700 Subject: [PATCH] Direct Reply: Allow closing IME separately from DirectReply mode If the IME is showing, the first BACK now closes just the IME instead of also closing the Direct Reply mode. Subsequent back closes the notification panel as usual. Change-Id: Ic4b5a4d6b528a211c2fa0c8b5ceb0f7017c09400 Fixes: 29996385 --- .../statusbar/phone/StatusBarWindowView.java | 11 ++++++---- .../statusbar/policy/RemoteInputView.java | 20 ++++++++++++------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java index 7b22b882abab6..47ea59e62da79 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java @@ -190,6 +190,12 @@ public class StatusBarWindowView extends FrameLayout { @Override public boolean dispatchKeyEvent(KeyEvent event) { + if (mService.interceptMediaKey(event)) { + return true; + } + if (super.dispatchKeyEvent(event)) { + return true; + } boolean down = event.getAction() == KeyEvent.ACTION_DOWN; switch (event.getKeyCode()) { case KeyEvent.KEYCODE_BACK: @@ -214,10 +220,7 @@ public class StatusBarWindowView extends FrameLayout { } break; } - if (mService.interceptMediaKey(event)) { - return true; - } - return super.dispatchKeyEvent(event); + return false; } @Override diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java index 38dbaee576eac..29577ef13874d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java @@ -366,7 +366,6 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene * @return true if a matching action was found, false otherwise */ public boolean updatePendingIntentFromActions(Notification.Action[] actions) { - boolean found = false; if (mPendingIntent == null || actions == null) { return false; } @@ -473,14 +472,21 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene } @Override - public boolean onKeyPreIme(int keyCode, KeyEvent event) { - if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) { - defocusIfNeeded(true /* animate */); - final InputMethodManager imm = InputMethodManager.getInstance(); - imm.hideSoftInputFromWindow(getWindowToken(), 0); + public boolean onKeyDown(int keyCode, KeyEvent event) { + if (keyCode == KeyEvent.KEYCODE_BACK) { + // Eat the DOWN event here to prevent any default behavior. return true; } - return super.onKeyPreIme(keyCode, event); + return super.onKeyDown(keyCode, event); + } + + @Override + public boolean onKeyUp(int keyCode, KeyEvent event) { + if (keyCode == KeyEvent.KEYCODE_BACK) { + defocusIfNeeded(true /* animate */); + return true; + } + return super.onKeyUp(keyCode, event); } @Override