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

Commit

Permalink
Fixes #2660 Set the correct fullscreen controls and menus curved state (
Browse files Browse the repository at this point in the history
#3305)

* Fix navigation bar and menus curved mode

* Close brightness/projection menus when clicked in the widget
  • Loading branch information
keianhzo authored May 1, 2020
1 parent 444367e commit 78da896
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.mozilla.vrbrowser.R;
import org.mozilla.geckoview.MediaElement;
import org.mozilla.vrbrowser.browser.Media;
import org.mozilla.vrbrowser.browser.SettingsStore;
import org.mozilla.vrbrowser.ui.views.MediaSeekBar;
import org.mozilla.vrbrowser.ui.views.UIButton;
import org.mozilla.vrbrowser.ui.views.VolumeControl;
Expand Down Expand Up @@ -123,6 +124,7 @@ private void initialize(Context aContext) {
placement.parentAnchorX = 0.65f;
placement.parentAnchorY = 0.4f;
placement.cylinderMapRadius = 0.0f;
placement.cylinder = SettingsStore.getInstance(getContext()).isCurvedModeEnabled();
if (mWidgetManager.getCylinderDensity() > 0) {
placement.rotationAxisY = 1.0f;
placement.rotation = (float) Math.toRadians(-7);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import android.util.Log;
import android.util.Pair;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.webkit.URLUtil;
import android.widget.EditText;
Expand Down Expand Up @@ -115,7 +116,7 @@ public interface NavigationListener {
private Executor mUIThreadExecutor;
private ArrayList<NavigationListener> mNavigationListeners;
private TrackingProtectionStore mTrackingDelegate;
private boolean mIsWindowAttached;
private WidgetPlacement mBeforeFullscreenPlacement;

public NavigationBarWidget(Context aContext) {
super(aContext);
Expand All @@ -141,8 +142,6 @@ private void initialize(@NonNull Context aContext) {

updateUI();

mIsWindowAttached = false;

mAppContext = aContext.getApplicationContext();

mUIThreadExecutor = ((VRBrowserApplication)aContext.getApplicationContext()).getExecutors().mainThread();
Expand Down Expand Up @@ -304,6 +303,8 @@ private void updateUI() {
boolean wasVisible = mProjectionMenu.isVisible();
closeFloatingMenus();

mProjectionMenu.mWidgetPlacement.cylinder = SettingsStore.getInstance(getContext()).isCurvedModeEnabled();

if (!wasVisible) {
mProjectionMenu.show(REQUEST_FOCUS);
}
Expand All @@ -321,6 +322,8 @@ private void updateUI() {
boolean wasVisible = mBrightnessWidget.isVisible();
closeFloatingMenus();

mBrightnessWidget.mWidgetPlacement.cylinder = SettingsStore.getInstance(getContext()).isCurvedModeEnabled();

if (!wasVisible) {
float anchor = 0.5f + (float)mBinding.navigationBarFullscreen.brightnessButton.getMeasuredWidth() / (float)NavigationBarWidget.this.getMeasuredWidth();
mBrightnessWidget.getPlacement().parentAnchorX = anchor;
Expand Down Expand Up @@ -383,6 +386,12 @@ private void updateUI() {
if (mAttachedWindow != null) {
mBinding.navigationBarNavigation.urlBar.attachToWindow(mAttachedWindow);
}

setOnTouchListener((v, event) -> {
closeFloatingMenus();
v.performClick();
return true;
});
}

TrackingProtectionStore.TrackingProtectionListener mTrackingListener = new TrackingProtectionStore.TrackingProtectionListener() {
Expand Down Expand Up @@ -501,8 +510,6 @@ public void detachFromWindow() {
mViewModel.getIsPopUpBlocked().removeObserver(mIsPopUpBlockedListener);
mViewModel = null;
}

mIsWindowAttached = false;
}

@Override
Expand Down Expand Up @@ -530,14 +537,14 @@ public void attachToWindow(@NonNull WindowWidget aWindow) {

mAttachedWindow.addWindowListener(this);

mBeforeFullscreenPlacement = mWidgetPlacement;

clearFocus();

if (getSession() != null) {
setUpSession(getSession());
}
handleWindowResize();

mIsWindowAttached = true;
}

private Session getSession() {
Expand Down Expand Up @@ -572,6 +579,10 @@ public void onFullScreen(@NonNull WindowWidget aWindow, boolean aFullScreen) {
if (aFullScreen) {
enterFullScreenMode();

mBeforeFullscreenPlacement = mWidgetPlacement.clone();
mWidgetPlacement.cylinder = SettingsStore.getInstance(getContext()).isCurvedModeEnabled();
updateWidget();

if (mAttachedWindow.isResizing()) {
exitResizeMode(ResizeAction.KEEP_SIZE);
}
Expand All @@ -587,6 +598,9 @@ public void onFullScreen(@NonNull WindowWidget aWindow, boolean aFullScreen) {
}
}
} else {
mWidgetPlacement = mBeforeFullscreenPlacement;
updateWidget();

if (mViewModel.getIsInVRVideo().getValue().get()) {
exitVRVideo();
}
Expand Down

0 comments on commit 78da896

Please sign in to comment.