1616import android .util .Log ;
1717import android .util .Pair ;
1818import android .view .LayoutInflater ;
19+ import android .view .MotionEvent ;
1920import android .view .View ;
2021import android .webkit .URLUtil ;
2122import android .widget .EditText ;
@@ -115,7 +116,7 @@ public interface NavigationListener {
115116 private Executor mUIThreadExecutor ;
116117 private ArrayList <NavigationListener > mNavigationListeners ;
117118 private TrackingProtectionStore mTrackingDelegate ;
118- private boolean mIsWindowAttached ;
119+ private WidgetPlacement mBeforeFullscreenPlacement ;
119120
120121 public NavigationBarWidget (Context aContext ) {
121122 super (aContext );
@@ -141,8 +142,6 @@ private void initialize(@NonNull Context aContext) {
141142
142143 updateUI ();
143144
144- mIsWindowAttached = false ;
145-
146145 mAppContext = aContext .getApplicationContext ();
147146
148147 mUIThreadExecutor = ((VRBrowserApplication )aContext .getApplicationContext ()).getExecutors ().mainThread ();
@@ -304,6 +303,8 @@ private void updateUI() {
304303 boolean wasVisible = mProjectionMenu .isVisible ();
305304 closeFloatingMenus ();
306305
306+ mProjectionMenu .mWidgetPlacement .cylinder = SettingsStore .getInstance (getContext ()).isCurvedModeEnabled ();
307+
307308 if (!wasVisible ) {
308309 mProjectionMenu .show (REQUEST_FOCUS );
309310 }
@@ -321,6 +322,8 @@ private void updateUI() {
321322 boolean wasVisible = mBrightnessWidget .isVisible ();
322323 closeFloatingMenus ();
323324
325+ mBrightnessWidget .mWidgetPlacement .cylinder = SettingsStore .getInstance (getContext ()).isCurvedModeEnabled ();
326+
324327 if (!wasVisible ) {
325328 float anchor = 0.5f + (float )mBinding .navigationBarFullscreen .brightnessButton .getMeasuredWidth () / (float )NavigationBarWidget .this .getMeasuredWidth ();
326329 mBrightnessWidget .getPlacement ().parentAnchorX = anchor ;
@@ -383,6 +386,12 @@ private void updateUI() {
383386 if (mAttachedWindow != null ) {
384387 mBinding .navigationBarNavigation .urlBar .attachToWindow (mAttachedWindow );
385388 }
389+
390+ setOnTouchListener ((v , event ) -> {
391+ closeFloatingMenus ();
392+ v .performClick ();
393+ return true ;
394+ });
386395 }
387396
388397 TrackingProtectionStore .TrackingProtectionListener mTrackingListener = new TrackingProtectionStore .TrackingProtectionListener () {
@@ -501,8 +510,6 @@ public void detachFromWindow() {
501510 mViewModel .getIsPopUpBlocked ().removeObserver (mIsPopUpBlockedListener );
502511 mViewModel = null ;
503512 }
504-
505- mIsWindowAttached = false ;
506513 }
507514
508515 @ Override
@@ -530,14 +537,14 @@ public void attachToWindow(@NonNull WindowWidget aWindow) {
530537
531538 mAttachedWindow .addWindowListener (this );
532539
540+ mBeforeFullscreenPlacement = mWidgetPlacement ;
541+
533542 clearFocus ();
534543
535544 if (getSession () != null ) {
536545 setUpSession (getSession ());
537546 }
538547 handleWindowResize ();
539-
540- mIsWindowAttached = true ;
541548 }
542549
543550 private Session getSession () {
@@ -572,6 +579,10 @@ public void onFullScreen(@NonNull WindowWidget aWindow, boolean aFullScreen) {
572579 if (aFullScreen ) {
573580 enterFullScreenMode ();
574581
582+ mBeforeFullscreenPlacement = mWidgetPlacement .clone ();
583+ mWidgetPlacement .cylinder = SettingsStore .getInstance (getContext ()).isCurvedModeEnabled ();
584+ updateWidget ();
585+
575586 if (mAttachedWindow .isResizing ()) {
576587 exitResizeMode (ResizeAction .KEEP_SIZE );
577588 }
@@ -587,6 +598,9 @@ public void onFullScreen(@NonNull WindowWidget aWindow, boolean aFullScreen) {
587598 }
588599 }
589600 } else {
601+ mWidgetPlacement = mBeforeFullscreenPlacement ;
602+ updateWidget ();
603+
590604 if (mViewModel .getIsInVRVideo ().getValue ().get ()) {
591605 exitVRVideo ();
592606 }
0 commit comments