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

Commit cfd779f

Browse files
MortimerGorokeianhzo
authored andcommitted
Hide context menus when window activation state changes (#1906)
1 parent b8e71a8 commit cfd779f

1 file changed

Lines changed: 15 additions & 12 deletions

File tree

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

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -570,14 +570,21 @@ public void setActiveWindow(boolean active) {
570570
updateTitleBar();
571571
}
572572

573-
if (mContextMenu != null) {
574-
mContextMenu.hide(REMOVE_WIDGET);
575-
}
573+
hideContextMenus();
576574

577575
TelemetryWrapper.activePlacementEvent(mWindowPlacement.getValue(), mActive);
578576
updateBorder();
579577
}
580578

579+
private void hideContextMenus() {
580+
if (mContextMenu != null && mContextMenu.isVisible()) {
581+
mContextMenu.hide(REMOVE_WIDGET);
582+
}
583+
if (mLibraryItemContextMenu != null && mLibraryItemContextMenu.isVisible()) {
584+
mLibraryItemContextMenu.hide(REMOVE_WIDGET);
585+
}
586+
}
587+
581588
private void updateTitleBar() {
582589
if (isBookmarksVisible()) {
583590
updateTitleBarUrl(getResources().getString(R.string.url_bookmarks_title));
@@ -1200,9 +1207,7 @@ private int getWindowWidth(float aWorldWidth) {
12001207
private void showLibraryItemContextMenu(@NotNull View view, LibraryItemContextMenu.LibraryContextMenuItem item, boolean isLastVisibleItem) {
12011208
view.requestFocusFromTouch();
12021209

1203-
if (mLibraryItemContextMenu != null) {
1204-
mLibraryItemContextMenu.hide(REMOVE_WIDGET);
1205-
}
1210+
hideContextMenus();
12061211

12071212
float ratio = WidgetPlacement.viewToWidgetRatio(getContext(), WindowWidget.this);
12081213

@@ -1233,19 +1238,19 @@ private void showLibraryItemContextMenu(@NotNull View view, LibraryItemContextMe
12331238
@Override
12341239
public void onOpenInNewWindowClick(LibraryItemContextMenu.LibraryContextMenuItem item) {
12351240
mWidgetManager.openNewWindow(item.getUrl());
1236-
mLibraryItemContextMenu.hide(REMOVE_WIDGET);
1241+
hideContextMenus();
12371242
}
12381243

12391244
@Override
12401245
public void onAddToBookmarks(LibraryItemContextMenu.LibraryContextMenuItem item) {
12411246
SessionStore.get().getBookmarkStore().addBookmark(item.getUrl(), item.getTitle());
1242-
mLibraryItemContextMenu.hide(REMOVE_WIDGET);
1247+
hideContextMenus();
12431248
}
12441249

12451250
@Override
12461251
public void onRemoveFromBookmarks(LibraryItemContextMenu.LibraryContextMenuItem item) {
12471252
SessionStore.get().getBookmarkStore().deleteBookmarkByURL(item.getUrl());
1248-
mLibraryItemContextMenu.hide(REMOVE_WIDGET);
1253+
hideContextMenus();
12491254
}
12501255
}));
12511256
mLibraryItemContextMenu.show(REQUEST_FOCUS);
@@ -1425,9 +1430,7 @@ public void dismiss() {
14251430
public void onContextMenu(GeckoSession session, int screenX, int screenY, ContextElement element) {
14261431
TelemetryWrapper.longPressContextMenuEvent();
14271432

1428-
if (mContextMenu != null) {
1429-
mContextMenu.hide(REMOVE_WIDGET);
1430-
}
1433+
hideContextMenus();
14311434

14321435
mContextMenu = new ContextMenuWidget(getContext());
14331436
mContextMenu.mWidgetPlacement.parentHandle = getHandle();

0 commit comments

Comments
 (0)