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

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
keianhzo committed Nov 15, 2018
1 parent 41548af commit 0e110cf
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 115 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import org.mozilla.vrbrowser.ui.widgets.NavigationBarWidget;
import org.mozilla.vrbrowser.ui.widgets.RootWidget;
import org.mozilla.vrbrowser.ui.widgets.TopBarWidget;
import org.mozilla.vrbrowser.ui.widgets.TrayListener;
import org.mozilla.vrbrowser.ui.widgets.TrayWidget;
import org.mozilla.vrbrowser.ui.widgets.VideoProjectionMenuWidget;
import org.mozilla.vrbrowser.ui.widgets.Widget;
Expand Down Expand Up @@ -218,15 +219,13 @@ protected void initializeWorld() {
// Create Tray
mTray = new TrayWidget(this);


// Bookmarks panel
mBookmarksWidget = new BookmarksWidget(this);
mBookmarksWidget.setBrowserWidget(mBrowserWidget);

// Add widget listeners
mTray.addListener(mBookmarksWidget);
mTray.addListeners(new TrayListener[]{mBookmarksWidget, mNavigationBar});
mBookmarksWidget.addListeners(new BookmarkListener[]{mBrowserWidget, mNavigationBar, mTray});
mNavigationBar.addListener(mBookmarksWidget);

addWidgets(Arrays.asList(mRootWidget, mBrowserWidget, mNavigationBar, mKeyboard, mTray, mBookmarksWidget));
}
Expand Down Expand Up @@ -285,7 +284,6 @@ protected void onDestroy() {
// Remove all widget listeners
mTray.removeAllListeners();
mBookmarksWidget.removeAllListeners();
mNavigationBar.removeAllListeners();

SessionStore.get().unregisterListeners();
super.onDestroy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public class NavigationURLBar extends FrameLayout {
private NavigationUrlBinding mBinding;
private BookmarkViewModel mBookmarkModel;
private AudioEngine mAudio;
private boolean mUpdateBar;

private Unit domainAutocompleteFilter(String text, InlineAutocompleteEditText view) {
if (view != null) {
Expand Down Expand Up @@ -162,6 +163,7 @@ private void initialize(Context aContext) {
mBookmarkButton.setSoundEffectsEnabled(false);

setURL("");
mUpdateBar = true;

// Prevent the URL TextEdit to get focus when user touches something outside of it
setFocusable(true);
Expand All @@ -172,6 +174,11 @@ public void setDelegate(NavigationURLBarDelegate delegate) {
mDelegate = delegate;
}

public void setUpdate(boolean update) {
mUpdateBar = update;
syncViews();
}

private final NavigationBarCallback mNavigationBarCallback = new NavigationBarCallback() {
@Override
public void onBookmarkClick(Bookmark bookmark) {
Expand Down Expand Up @@ -199,6 +206,10 @@ public void setHint(@StringRes int aHint) {
}

public void setURL(String aURL) {
if (!mUpdateBar) {
return;
}

// Setup model view for this URL
if (mBookmarkModel != null) {
mBookmarkModel.getObservableBookmark().removeObserver(mBookmarkObserver);
Expand Down Expand Up @@ -308,7 +319,7 @@ public void showVoiceSearch(boolean enabled) {
}

private void syncViews() {
boolean showContainer = mIsInsecure || mIsLoading;
boolean showContainer = (mIsInsecure || mIsLoading) && mUpdateBar;
int leftPadding = mDefaultURLLeftPadding;
if (showContainer) {
mURLLeftContainer.setVisibility(View.VISIBLE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
import android.util.AttributeSet;
import android.view.LayoutInflater;

import org.mozilla.geckoview.AllowOrDeny;
import org.mozilla.geckoview.GeckoResult;
import org.mozilla.geckoview.GeckoSession;
import org.mozilla.geckoview.WebRequestError;
import org.mozilla.vrbrowser.R;
import org.mozilla.vrbrowser.audio.AudioEngine;
import org.mozilla.vrbrowser.browser.SessionStore;
Expand All @@ -27,6 +31,8 @@
import java.util.Arrays;
import java.util.List;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.databinding.DataBindingUtil;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.Observer;
Expand All @@ -35,7 +41,7 @@


public class BookmarksWidget extends UIWidget implements Application.ActivityLifecycleCallbacks,
WidgetManagerDelegate.UpdateListener, TrayListener, NavigationBarListener {
WidgetManagerDelegate.UpdateListener, TrayListener, GeckoSession.NavigationDelegate {

private BookmarksBinding mBinding;
private BookmarkAdapter mBookmarkAdapter;
Expand Down Expand Up @@ -66,6 +72,7 @@ private void initialize(Context aContext) {

((Application)getApplicationContext()).registerActivityLifecycleCallbacks(this);
mWidgetManager.addUpdateListener(this);
SessionStore.get().addNavigationListener(this);

LayoutInflater inflater = LayoutInflater.from(aContext);

Expand All @@ -79,10 +86,6 @@ private void initialize(Context aContext) {
subscribeUi(mBookmarkListModel.getBookmarks());
}

public void addListener(BookmarkListener aListener) {
mBookmarkListeners.add(aListener);
}

public void addListeners(BookmarkListener... listeners) {
mBookmarkListeners.addAll(Arrays.asList(listeners));
}
Expand All @@ -92,21 +95,18 @@ public void removeAllListeners() {
}

private void notifyBookmarksShow() {
mBookmarkListeners.forEach(bookmarkListener -> {
bookmarkListener.onBookmarksShow();
});
mBookmarkListeners.forEach(bookmarkListener -> bookmarkListener.onBookmarksShow());
}

private void notifyBookmarksHide() {
mBookmarkListeners.forEach(bookmarkListener -> {
bookmarkListener.onBookmarksHide();
});
mBookmarkListeners.forEach(bookmarkListener -> bookmarkListener.onBookmarksHide());
}

@Override
public void releaseWidget() {
((Application)getApplicationContext()).unregisterActivityLifecycleCallbacks(this);
mWidgetManager.removeUpdateListener(this);
SessionStore.get().removeNavigationListener(this);

super.releaseWidget();
}
Expand All @@ -125,9 +125,8 @@ public void onClick(Bookmark bookmark) {
mAudio.playSound(AudioEngine.Sound.CLICK);
}

SessionStore.get().loadUri(bookmark.getUrl());
notifyBookmarksShow();
hide();
SessionStore.get().loadUri(bookmark.getUrl());
}

@Override
Expand Down Expand Up @@ -261,31 +260,41 @@ public void onBookmarksClicked() {
toggle();
}

// NavigationDelegate

@Override
public void onHelpClicked() {
if (mWidgetPlacement.visible) {
hide();
}
public void onLocationChange(GeckoSession session, String url) {

}

@Override
public void onSettingsClicked() {
public void onCanGoBack(GeckoSession session, boolean canGoBack) {

}

@Override
public void onPrivateBrowsingClicked() {
public void onCanGoForward(GeckoSession session, boolean canGoForward) {

}

@Nullable
@Override
public GeckoResult<AllowOrDeny> onLoadRequest(@NonNull GeckoSession session, @NonNull LoadRequest request) {
if (mWidgetPlacement.visible) {
hide();
}

return GeckoResult.ALLOW;
}

// NavigationBarListener
@Nullable
@Override
public GeckoResult<GeckoSession> onNewSession(@NonNull GeckoSession session, @NonNull String uri) {
return null;
}

@Override
public void onNavigationStarted() {
if (mWidgetPlacement.visible) {
hide();
}
public GeckoResult<String> onLoadError(GeckoSession session, String uri, WebRequestError error) {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,17 @@
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.Surface;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import android.widget.FrameLayout;
import android.widget.LinearLayout;

import org.mozilla.geckoview.AllowOrDeny;
import org.mozilla.geckoview.GeckoDisplay;
import org.mozilla.geckoview.GeckoResult;
import org.mozilla.geckoview.GeckoSession;
import org.mozilla.geckoview.GeckoSessionSettings;
import org.mozilla.vrbrowser.*;
import org.mozilla.vrbrowser.R;
import org.mozilla.vrbrowser.browser.SessionStore;
import org.mozilla.vrbrowser.browser.SettingsStore;
import org.mozilla.vrbrowser.model.Bookmark;
import org.mozilla.vrbrowser.ui.prompts.ChoicePromptWidget;


Expand Down

This file was deleted.

Loading

0 comments on commit 0e110cf

Please sign in to comment.