From 7fa1e4b642953d468c5f1c097cb5089f654cd24f Mon Sep 17 00:00:00 2001 From: Manuel Martin Date: Sat, 16 Nov 2019 00:35:32 +0100 Subject: [PATCH] Dismiss context menu when scrolling (#2271) --- .../vrbrowser/ui/callbacks/BookmarksCallback.java | 1 + .../vrbrowser/ui/callbacks/HistoryCallback.java | 1 + .../org/mozilla/vrbrowser/ui/views/BookmarksView.java | 1 + .../org/mozilla/vrbrowser/ui/views/HistoryView.java | 1 + .../org/mozilla/vrbrowser/ui/widgets/WindowWidget.java | 10 ++++++++++ 5 files changed, 14 insertions(+) diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/callbacks/BookmarksCallback.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/callbacks/BookmarksCallback.java index 9049e3318..0d23a7d06 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/callbacks/BookmarksCallback.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/callbacks/BookmarksCallback.java @@ -12,4 +12,5 @@ default void onSyncBookmarks(@NonNull View view) {} default void onFxALogin(@NonNull View view) {} default void onFxASynSettings(@NonNull View view) {} default void onShowContextMenu(@NonNull View view, Bookmark item, boolean isLastVisibleItem) {} + default void onHideContextMenu(@NonNull View view) {} } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/callbacks/HistoryCallback.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/callbacks/HistoryCallback.java index 60cc88652..5070d582a 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/callbacks/HistoryCallback.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/callbacks/HistoryCallback.java @@ -12,4 +12,5 @@ default void onSyncHistory(@NonNull View view) {} default void onFxALogin(@NonNull View view) {} default void onFxASynSettings(@NonNull View view) {} default void onShowContextMenu(@NonNull View view, @NonNull VisitInfo item, boolean isLastVisibleItem) {} + default void onHideContextMenu(@NonNull View view) {} } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/views/BookmarksView.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/views/BookmarksView.java index 06862f872..dcb02d9b0 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/views/BookmarksView.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/views/BookmarksView.java @@ -97,6 +97,7 @@ private void initialize(Context aContext) { v.requestFocusFromTouch(); return false; }); + mBinding.bookmarksList.setOnScrollChangeListener((v, scrollX, scrollY, oldScrollX, oldScrollY) -> mBookmarksViewListeners.forEach((listener) -> listener.onHideContextMenu(v))); mBinding.bookmarksList.setHasFixedSize(true); mBinding.bookmarksList.setItemViewCacheSize(20); mBinding.bookmarksList.setDrawingCacheEnabled(true); diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/views/HistoryView.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/views/HistoryView.java index ec3a38aef..503a11b72 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/views/HistoryView.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/views/HistoryView.java @@ -102,6 +102,7 @@ private void initialize(Context aContext) { v.requestFocusFromTouch(); return false; }); + mBinding.historyList.setOnScrollChangeListener((v, scrollX, scrollY, oldScrollX, oldScrollY) -> mHistoryViewListeners.forEach((listener) -> listener.onHideContextMenu(v))); mBinding.historyList.setHasFixedSize(true); mBinding.historyList.setItemViewCacheSize(20); mBinding.historyList.setDrawingCacheEnabled(true); 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 0a81be469..1ff4fd2f1 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 @@ -1390,6 +1390,11 @@ public void onShowContextMenu(@NonNull View view, @NotNull Bookmark item, boolea public void onFxASynSettings(@NonNull View view) { mWidgetManager.getTray().toggleSettingsDialog(SettingsWidget.SettingDialog.FXA); } + + @Override + public void onHideContextMenu(@NonNull View view) { + hideContextMenus(); + } }; private HistoryCallback mHistoryListener = new HistoryCallback() { @@ -1414,6 +1419,11 @@ public void onShowContextMenu(@NonNull View view, @NonNull VisitInfo item, boole public void onFxASynSettings(@NonNull View view) { mWidgetManager.getTray().toggleSettingsDialog(SettingsWidget.SettingDialog.FXA); } + + @Override + public void onHideContextMenu(@NonNull View view) { + hideContextMenus(); + } }; private void hideContextMenus() {