From 050c5005154dadc70afaa5e3cee1fea3bc4606a6 Mon Sep 17 00:00:00 2001 From: Manuel Martin Date: Mon, 25 Nov 2019 16:25:59 +0100 Subject: [PATCH] Revert explicit and use LoadRequest event to close library panels --- .../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 | 28 +++++++++++-------- 5 files changed, 17 insertions(+), 17 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 17fbc5e8e..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 @@ -13,5 +13,4 @@ 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 badf60e38..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 @@ -13,5 +13,4 @@ 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 f27834623..fc3b18d28 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 @@ -156,8 +156,6 @@ 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 0f28e4971..c7421cb18 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 @@ -159,8 +159,6 @@ 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 2b5cbc50b..ebd0b0a6b 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 @@ -27,6 +27,7 @@ import androidx.annotation.UiThread; import org.jetbrains.annotations.NotNull; +import org.mozilla.geckoview.AllowOrDeny; import org.mozilla.geckoview.GeckoResult; import org.mozilla.geckoview.GeckoSession; import org.mozilla.geckoview.PanZoomController; @@ -67,7 +68,6 @@ import java.util.GregorianCalendar; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.Executor; -import java.util.function.Consumer; import mozilla.components.concept.storage.PageObservation; import mozilla.components.concept.storage.PageVisit; @@ -1424,11 +1424,6 @@ public void onHideContextMenu(@NonNull View view) { hideContextMenus(); } - @Override - public void onItemClicked(@NonNull View view, Bookmark item) { - hideBookmarks(); - } - @Override public void onFxALogin(@NonNull View view) { hideBookmarks(); @@ -1463,11 +1458,6 @@ public void onHideContextMenu(@NonNull View view) { hideContextMenus(); } - @Override - public void onItemClicked(@NonNull View view, VisitInfo item) { - hideHistory(); - } - @Override public void onFxALogin(@NonNull View view) { hideHistory(); @@ -1583,6 +1573,22 @@ public void captureImage() { mSession.captureBitmap(); } + // GeckoSession.NavigationDelegate + + @Nullable + @Override + public GeckoResult onLoadRequest(@NonNull GeckoSession geckoSession, @NonNull LoadRequest loadRequest) { + if (isHistoryVisible()) { + hideHistory(); + } + + if (isBookmarksVisible()) { + hideBookmarks(); + } + + return GeckoResult.ALLOW; + } + @Override public void onLocationChange(@NonNull GeckoSession session, @Nullable String url) { updateTitleBarUrl(url);