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

Fixes #834 #835 Bookmarks resize issues #888

Merged
merged 1 commit into from
Dec 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 25 additions & 31 deletions app/src/common/shared/org/mozilla/vrbrowser/VRBrowserActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@
import org.mozilla.vrbrowser.telemetry.TelemetryWrapper;
import org.mozilla.vrbrowser.ui.OffscreenDisplay;
import org.mozilla.vrbrowser.ui.widgets.BookmarkListener;
import org.mozilla.vrbrowser.ui.widgets.BookmarksWidget;
import org.mozilla.vrbrowser.ui.widgets.BrowserWidget;
import org.mozilla.vrbrowser.ui.views.BookmarksView;
import org.mozilla.vrbrowser.ui.widgets.KeyboardWidget;
import org.mozilla.vrbrowser.ui.widgets.NavigationBarWidget;
import org.mozilla.vrbrowser.ui.widgets.RootWidget;
Expand All @@ -59,11 +58,11 @@
import org.mozilla.vrbrowser.ui.widgets.Widget;
import org.mozilla.vrbrowser.ui.widgets.WidgetManagerDelegate;
import org.mozilla.vrbrowser.ui.widgets.WidgetPlacement;
import org.mozilla.vrbrowser.ui.widgets.WindowWidget;
import org.mozilla.vrbrowser.ui.widgets.dialogs.CrashDialogWidget;

import java.io.IOException;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
Expand Down Expand Up @@ -113,14 +112,14 @@ public void run() {
SwipeRunnable mLastRunnable;
Handler mHandler = new Handler();
Runnable mAudioUpdateRunnable;
BrowserWidget mBrowserWidget;
WindowWidget mWindowWidget;
RootWidget mRootWidget;
KeyboardWidget mKeyboard;
NavigationBarWidget mNavigationBar;
CrashDialogWidget mCrashDialog;
TopBarWidget mTopBar;
TrayWidget mTray;
BookmarksWidget mBookmarksWidget;
BookmarksView mBookmarksView;
PermissionDelegate mPermissionDelegate;
LinkedList<UpdateListener> mWidgetUpdateListeners;
LinkedList<PermissionListener> mPermissionListeners;
Expand All @@ -132,7 +131,6 @@ public void run() {
private LinkedList<Pair<Object, Float>> mBrightnessQueue;
private Pair<Object, Float> mCurrentBrightness;
private SearchEngineWrapper mSearchEngineWrapper;
private ArrayList<Widget> mResizableWidgets;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand Down Expand Up @@ -164,8 +162,6 @@ protected void onCreate(Bundle savedInstanceState) {
mBrightnessQueue = new LinkedList<>();
mCurrentBrightness = Pair.create(null, 1.0f);

mResizableWidgets = new ArrayList<>();

mWidgets = new HashMap<>();
mWidgetContainer = new FrameLayout(this);
mWidgetContainer.getViewTreeObserver().addOnGlobalFocusChangeListener((oldFocus, newFocus) -> {
Expand Down Expand Up @@ -199,30 +195,30 @@ protected void onCreate(Bundle savedInstanceState) {
}

protected void initializeWorld() {
// Bookmarks panel
mBookmarksView = new BookmarksView(this);

// Create browser widget
if (SessionStore.get().getCurrentSession() == null) {
int id = SessionStore.get().createSession();
SessionStore.get().setCurrentSession(id);
}
int currentSession = SessionStore.get().getCurrentSessionId();
mBrowserWidget = new BrowserWidget(this, currentSession);
mPermissionDelegate.setParentWidgetHandle(mBrowserWidget.getHandle());

// Bookmarks panel
mBookmarksWidget = new BookmarksWidget(this);
mWindowWidget = new WindowWidget(this, currentSession);
mWindowWidget.setBookmarksView(mBookmarksView);
mPermissionDelegate.setParentWidgetHandle(mWindowWidget.getHandle());

// Create Browser navigation widget
mNavigationBar = new NavigationBarWidget(this);
mNavigationBar.setBrowserWidget(mBrowserWidget);
mNavigationBar.setBookmarksWidget(mBookmarksWidget);
mNavigationBar.setBrowserWidget(mWindowWidget);

// Create keyboard widget
mKeyboard = new KeyboardWidget(this);
mKeyboard.setBrowserWidget(mBrowserWidget);
mKeyboard.setBrowserWidget(mWindowWidget);

// Create the top bar
mTopBar = new TopBarWidget(this);
mTopBar.setBrowserWidget(mBrowserWidget);
mTopBar.setBrowserWidget(mWindowWidget);

// Empty widget just for handling focus on empty space
mRootWidget = new RootWidget(this);
Expand All @@ -236,12 +232,10 @@ protected void initializeWorld() {
mTray = new TrayWidget(this);

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

mResizableWidgets.addAll(Arrays.asList(mBrowserWidget, mBookmarksWidget));
mTray.addListeners(new TrayListener[]{mWindowWidget, mNavigationBar});
mBookmarksView.addListeners(new BookmarkListener[]{mWindowWidget, mNavigationBar, mTray});

addWidgets(Arrays.asList(mRootWidget, mBrowserWidget, mNavigationBar, mKeyboard, mTray, mBookmarksWidget));
addWidgets(Arrays.asList(mRootWidget, mWindowWidget, mNavigationBar, mKeyboard, mTray));
}

@Override
Expand Down Expand Up @@ -297,7 +291,7 @@ protected void onDestroy() {

// Remove all widget listeners
mTray.removeAllListeners();
mBookmarksWidget.removeAllListeners();
mBookmarksView.removeAllListeners();

SessionStore.get().unregisterListeners();
super.onDestroy();
Expand Down Expand Up @@ -501,8 +495,8 @@ void handleMotionEvent(final int aHandle, final int aDevice, final boolean aPres
Widget widget = mWidgets.get(aHandle);
if (widget == null) {
MotionEventGenerator.dispatch(mRootWidget, aDevice, aPressed, aX, aY);
} else if (widget == mBrowserWidget && mBrowserWidget.getBorderWidth() > 0) {
final int border = mBrowserWidget.getBorderWidth();
} else if (widget == mWindowWidget && mWindowWidget.getBorderWidth() > 0) {
final int border = mWindowWidget.getBorderWidth();
MotionEventGenerator.dispatch(widget, aDevice, aPressed, aX - border, aY - border);
} else {
MotionEventGenerator.dispatch(widget, aDevice, aPressed, aX, aY);
Expand Down Expand Up @@ -575,7 +569,7 @@ void handleAudioPose(float qx, float qy, float qz, float qw, float px, float py,
@SuppressWarnings("unused")
void handleResize(final int aHandle, final float aWorldWidth, final float aWorldHeight) {
runOnUiThread(() -> {
mResizableWidgets.forEach(widget -> widget.handleResizeEvent(aWorldWidth, aWorldHeight));
mWindowWidget.handleResizeEvent(aWorldWidth, aWorldHeight);
});
}

Expand All @@ -590,9 +584,9 @@ class PauseCompositorRunnable implements Runnable {
@Override
public void run() {
synchronized (VRBrowserActivity.this) {
if (mBrowserWidget != null) {
if (mWindowWidget != null) {
Log.d(LOGTAG, "About to pause Compositor");
mBrowserWidget.pauseCompositor();
mWindowWidget.pauseCompositor();
Log.d(LOGTAG, "Compositor Paused");
}
done = true;
Expand Down Expand Up @@ -633,8 +627,8 @@ void resumeGeckoViewCompositor() {
TelemetryWrapper.uploadImmersiveToHistogram();
Handler handler = new Handler(Looper.getMainLooper());
handler.postDelayed(() -> {
if (mBrowserWidget != null) {
mBrowserWidget.resumeCompositor();
if (mWindowWidget != null) {
mWindowWidget.resumeCompositor();
Log.d(LOGTAG, "Compositor Resumed");
}
}, 20);
Expand Down Expand Up @@ -921,7 +915,7 @@ public void setControllersVisible(final boolean aVisible) {

@Override
public void setWindowSize(float targetWidth, float targetHeight) {
mBrowserWidget.resizeByMultiplier(targetWidth / targetHeight, 1.0f);
mWindowWidget.resizeByMultiplier(targetWidth / targetHeight, 1.0f);
}

@Override
Expand Down
Loading