From 5597ea0747feb6f11d4e0b81fc0280f931558caf Mon Sep 17 00:00:00 2001 From: Manuel Martin Date: Fri, 22 Nov 2019 18:44:36 +0100 Subject: [PATCH] Dismiss library panels explicitly (#2353) --- .../ui/callbacks/BookmarksCallback.java | 1 + .../ui/callbacks/HistoryCallback.java | 1 + .../vrbrowser/ui/views/BookmarksView.java | 2 ++ .../vrbrowser/ui/views/HistoryView.java | 2 ++ .../vrbrowser/ui/widgets/WindowWidget.java | 18 ++++++++++-------- 5 files changed, 16 insertions(+), 8 deletions(-) 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 0d23a7d06..17fbc5e8e 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 @@ -13,4 +13,5 @@ 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) {} + default void onItemClicked(@NonNull View view, Bookmark item) {} } 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 5070d582a..badf60e38 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 @@ -13,4 +13,5 @@ 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) {} + default void onItemClicked(@NonNull View view, VisitInfo item) {} } 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 dcb02d9b0..7f9241325 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 @@ -155,6 +155,8 @@ public void onClick(@NonNull View view, @NonNull Bookmark item) { Session session = SessionStore.get().getActiveSession(); session.loadUri(item.getUrl()); + + mBookmarksViewListeners.forEach((listener) -> listener.onItemClicked(view, item)); } @Override 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 e96d694ea..4f644d2b7 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 @@ -158,6 +158,8 @@ public void onClick(View view, VisitInfo item) { Session session = SessionStore.get().getActiveSession(); session.loadUri(item.getUrl()); + + mHistoryViewListeners.forEach((listener) -> listener.onItemClicked(view, item)); } @Override 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 f4a736824..5e782e54f 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 @@ -1420,6 +1420,11 @@ public void onFxASynSettings(@NonNull View view) { public void onHideContextMenu(@NonNull View view) { hideContextMenus(); } + + @Override + public void onItemClicked(@NonNull View view, Bookmark item) { + hideBookmarks(); + } }; private HistoryCallback mHistoryListener = new HistoryCallback() { @@ -1449,6 +1454,11 @@ public void onFxASynSettings(@NonNull View view) { public void onHideContextMenu(@NonNull View view) { hideContextMenus(); } + + @Override + public void onItemClicked(@NonNull View view, VisitInfo item) { + hideHistory(); + } }; private void hideContextMenus() { @@ -1546,14 +1556,6 @@ public void onVideoAvailabilityChanged(boolean aVideosAvailable) { @Override public void onPageStart(@NonNull GeckoSession geckoSession, @NonNull String s) { mCaptureOnPageStop = true; - - if (isHistoryVisible()) { - hideHistory(); - } - - if (isBookmarksVisible()) { - hideBookmarks(); - } } @Override