Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Commit d2d289c

Browse files
authored
Fixes #2440 Fixes #2441 Hide selection context menu when back is pressed (#2671)
* Indentation fix * Hide selection context menus when back is pressed
1 parent f9bc1c2 commit d2d289c

2 files changed

Lines changed: 23 additions & 16 deletions

File tree

app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/KeyboardWidget.java

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -381,19 +381,19 @@ public void updateFocusedView(View aFocusedView) {
381381
}
382382

383383
public void dismiss() {
384-
exitVoiceInputMode();
385-
if (mFocusedView != null && mFocusedView != mAttachedWindow) {
386-
mFocusedView.clearFocus();
387-
}
388-
mWidgetPlacement.visible = false;
389-
mWidgetManager.updateWidget(this);
390-
391-
mWidgetManager.popBackHandler(mBackHandler);
392-
393-
mIsCapsLock = false;
394-
mIsLongPress = false;
395-
handleShift(false);
396-
hideOverlays();
384+
exitVoiceInputMode();
385+
if (mFocusedView != null && mFocusedView != mAttachedWindow) {
386+
mFocusedView.clearFocus();
387+
}
388+
mWidgetPlacement.visible = false;
389+
mWidgetManager.updateWidget(this);
390+
391+
mWidgetManager.popBackHandler(mBackHandler);
392+
393+
mIsCapsLock = false;
394+
mIsLongPress = false;
395+
handleShift(false);
396+
hideOverlays();
397397
}
398398

399399
public void proxifyLayerIfNeeded(ArrayList<WindowWidget> aWindows) {
@@ -1023,8 +1023,12 @@ public boolean dispatchKeyEvent(final KeyEvent event) {
10231023
final InputConnection connection = mInputConnection;
10241024
if (connection != null) {
10251025
if (isAttachToWindowWidget()) {
1026-
connection.sendKeyEvent(event);
1027-
hide(UIWidget.KEEP_WIDGET);
1026+
if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
1027+
return false;
1028+
} else {
1029+
connection.sendKeyEvent(event);
1030+
hide(UIWidget.KEEP_WIDGET);
1031+
}
10281032
return true;
10291033
}
10301034
// Android Components do not support InputConnection.sendKeyEvent()

app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/WindowWidget.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1806,10 +1806,13 @@ public void onAction(String action) {
18061806

18071807
@Override
18081808
public void onDismiss() {
1809-
hideContextMenus();
18101809
if (aSelection.isActionAvailable(GeckoSession.SelectionActionDelegate.ACTION_UNSELECT)) {
18111810
aSelection.execute(GeckoSession.SelectionActionDelegate.ACTION_UNSELECT);
1811+
} else {
1812+
aSelection.collapseToEnd();
18121813
}
1814+
1815+
aSelection.hide();
18131816
}
18141817
});
18151818
mSelectionMenu.show(KEEP_FOCUS);

0 commit comments

Comments
 (0)