From d2d289ce116c22ea8afb29178f5325b4ff86e79e Mon Sep 17 00:00:00 2001 From: Manuel Martin Date: Wed, 5 Feb 2020 01:46:32 +0100 Subject: [PATCH] Fixes #2440 Fixes #2441 Hide selection context menu when back is pressed (#2671) * Indentation fix * Hide selection context menus when back is pressed --- .../vrbrowser/ui/widgets/KeyboardWidget.java | 34 +++++++++++-------- .../vrbrowser/ui/widgets/WindowWidget.java | 5 ++- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/KeyboardWidget.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/KeyboardWidget.java index f5913559e..cd154e10a 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/KeyboardWidget.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/KeyboardWidget.java @@ -381,19 +381,19 @@ public void updateFocusedView(View aFocusedView) { } public void dismiss() { - exitVoiceInputMode(); - if (mFocusedView != null && mFocusedView != mAttachedWindow) { - mFocusedView.clearFocus(); - } - mWidgetPlacement.visible = false; - mWidgetManager.updateWidget(this); - - mWidgetManager.popBackHandler(mBackHandler); - - mIsCapsLock = false; - mIsLongPress = false; - handleShift(false); - hideOverlays(); + exitVoiceInputMode(); + if (mFocusedView != null && mFocusedView != mAttachedWindow) { + mFocusedView.clearFocus(); + } + mWidgetPlacement.visible = false; + mWidgetManager.updateWidget(this); + + mWidgetManager.popBackHandler(mBackHandler); + + mIsCapsLock = false; + mIsLongPress = false; + handleShift(false); + hideOverlays(); } public void proxifyLayerIfNeeded(ArrayList aWindows) { @@ -1023,8 +1023,12 @@ public boolean dispatchKeyEvent(final KeyEvent event) { final InputConnection connection = mInputConnection; if (connection != null) { if (isAttachToWindowWidget()) { - connection.sendKeyEvent(event); - hide(UIWidget.KEEP_WIDGET); + if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { + return false; + } else { + connection.sendKeyEvent(event); + hide(UIWidget.KEEP_WIDGET); + } return true; } // Android Components do not support InputConnection.sendKeyEvent() diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/WindowWidget.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/WindowWidget.java index 2b8d6c19f..6f904a08f 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/WindowWidget.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/WindowWidget.java @@ -1806,10 +1806,13 @@ public void onAction(String action) { @Override public void onDismiss() { - hideContextMenus(); if (aSelection.isActionAvailable(GeckoSession.SelectionActionDelegate.ACTION_UNSELECT)) { aSelection.execute(GeckoSession.SelectionActionDelegate.ACTION_UNSELECT); + } else { + aSelection.collapseToEnd(); } + + aSelection.hide(); } }); mSelectionMenu.show(KEEP_FOCUS);