16
16
import android .util .Log ;
17
17
import android .util .Pair ;
18
18
import android .view .LayoutInflater ;
19
+ import android .view .MotionEvent ;
19
20
import android .view .View ;
20
21
import android .webkit .URLUtil ;
21
22
import android .widget .EditText ;
@@ -115,7 +116,7 @@ public interface NavigationListener {
115
116
private Executor mUIThreadExecutor ;
116
117
private ArrayList <NavigationListener > mNavigationListeners ;
117
118
private TrackingProtectionStore mTrackingDelegate ;
118
- private boolean mIsWindowAttached ;
119
+ private WidgetPlacement mBeforeFullscreenPlacement ;
119
120
120
121
public NavigationBarWidget (Context aContext ) {
121
122
super (aContext );
@@ -141,8 +142,6 @@ private void initialize(@NonNull Context aContext) {
141
142
142
143
updateUI ();
143
144
144
- mIsWindowAttached = false ;
145
-
146
145
mAppContext = aContext .getApplicationContext ();
147
146
148
147
mUIThreadExecutor = ((VRBrowserApplication )aContext .getApplicationContext ()).getExecutors ().mainThread ();
@@ -304,6 +303,8 @@ private void updateUI() {
304
303
boolean wasVisible = mProjectionMenu .isVisible ();
305
304
closeFloatingMenus ();
306
305
306
+ mProjectionMenu .mWidgetPlacement .cylinder = SettingsStore .getInstance (getContext ()).isCurvedModeEnabled ();
307
+
307
308
if (!wasVisible ) {
308
309
mProjectionMenu .show (REQUEST_FOCUS );
309
310
}
@@ -321,6 +322,8 @@ private void updateUI() {
321
322
boolean wasVisible = mBrightnessWidget .isVisible ();
322
323
closeFloatingMenus ();
323
324
325
+ mBrightnessWidget .mWidgetPlacement .cylinder = SettingsStore .getInstance (getContext ()).isCurvedModeEnabled ();
326
+
324
327
if (!wasVisible ) {
325
328
float anchor = 0.5f + (float )mBinding .navigationBarFullscreen .brightnessButton .getMeasuredWidth () / (float )NavigationBarWidget .this .getMeasuredWidth ();
326
329
mBrightnessWidget .getPlacement ().parentAnchorX = anchor ;
@@ -383,6 +386,12 @@ private void updateUI() {
383
386
if (mAttachedWindow != null ) {
384
387
mBinding .navigationBarNavigation .urlBar .attachToWindow (mAttachedWindow );
385
388
}
389
+
390
+ setOnTouchListener ((v , event ) -> {
391
+ closeFloatingMenus ();
392
+ v .performClick ();
393
+ return true ;
394
+ });
386
395
}
387
396
388
397
TrackingProtectionStore .TrackingProtectionListener mTrackingListener = new TrackingProtectionStore .TrackingProtectionListener () {
@@ -501,8 +510,6 @@ public void detachFromWindow() {
501
510
mViewModel .getIsPopUpBlocked ().removeObserver (mIsPopUpBlockedListener );
502
511
mViewModel = null ;
503
512
}
504
-
505
- mIsWindowAttached = false ;
506
513
}
507
514
508
515
@ Override
@@ -530,14 +537,14 @@ public void attachToWindow(@NonNull WindowWidget aWindow) {
530
537
531
538
mAttachedWindow .addWindowListener (this );
532
539
540
+ mBeforeFullscreenPlacement = mWidgetPlacement ;
541
+
533
542
clearFocus ();
534
543
535
544
if (getSession () != null ) {
536
545
setUpSession (getSession ());
537
546
}
538
547
handleWindowResize ();
539
-
540
- mIsWindowAttached = true ;
541
548
}
542
549
543
550
private Session getSession () {
@@ -572,6 +579,10 @@ public void onFullScreen(@NonNull WindowWidget aWindow, boolean aFullScreen) {
572
579
if (aFullScreen ) {
573
580
enterFullScreenMode ();
574
581
582
+ mBeforeFullscreenPlacement = mWidgetPlacement .clone ();
583
+ mWidgetPlacement .cylinder = SettingsStore .getInstance (getContext ()).isCurvedModeEnabled ();
584
+ updateWidget ();
585
+
575
586
if (mAttachedWindow .isResizing ()) {
576
587
exitResizeMode (ResizeAction .KEEP_SIZE );
577
588
}
@@ -587,6 +598,9 @@ public void onFullScreen(@NonNull WindowWidget aWindow, boolean aFullScreen) {
587
598
}
588
599
}
589
600
} else {
601
+ mWidgetPlacement = mBeforeFullscreenPlacement ;
602
+ updateWidget ();
603
+
590
604
if (mViewModel .getIsInVRVideo ().getValue ().get ()) {
591
605
exitVRVideo ();
592
606
}
0 commit comments