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

Commit d673d48

Browse files
authored
Add hide_webxr_interstitial and hide_whats_new ADB commands. (#3243)
1 parent 17a313b commit d673d48

3 files changed

Lines changed: 29 additions & 5 deletions

File tree

app/src/common/shared/org/mozilla/vrbrowser/VRBrowserActivity.java

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@
9797
import java.util.concurrent.CopyOnWriteArrayList;
9898
import java.util.function.Consumer;
9999

100+
import static org.mozilla.vrbrowser.ui.widgets.UIWidget.REMOVE_WIDGET;
101+
100102
public class VRBrowserActivity extends PlatformActivity implements WidgetManagerDelegate, ComponentCallbacks2, LifecycleOwner, ViewModelStoreOwner {
101103

102104
private BroadcastReceiver mCrashReceiver = new BroadcastReceiver() {
@@ -169,6 +171,7 @@ public void run() {
169171
NavigationBarWidget mNavigationBar;
170172
CrashDialogWidget mCrashDialog;
171173
TrayWidget mTray;
174+
WhatsNewWidget mWhatsNewWidget = null;
172175
WebXRInterstitialWidget mWebXRInterstitial;
173176
PermissionDelegate mPermissionDelegate;
174177
LinkedList<UpdateListener> mWidgetUpdateListeners;
@@ -190,6 +193,7 @@ public void run() {
190193
private Widget mActiveDialog;
191194
private Set<String> mPoorPerformanceWhiteList;
192195
private float mCurrentCylinderDensity = 0;
196+
private boolean mHideWebXRIntersitial = false;
193197

194198
private boolean callOnAudioManager(Consumer<AudioManager> fn) {
195199
if (mAudioManager == null) {
@@ -383,10 +387,10 @@ public void onWindowVideoAvailabilityChanged(@NonNull WindowWidget aWindow) {
383387

384388
// Show the what's upp dialog if we haven't showed it yet and this is v6.
385389
if (!SettingsStore.getInstance(this).isWhatsNewDisplayed()) {
386-
final WhatsNewWidget whatsNew = new WhatsNewWidget(this);
387-
whatsNew.setLoginOrigin(Accounts.LoginOrigin.NONE);
388-
whatsNew.getPlacement().parentHandle = mWindows.getFocusedWindow().getHandle();
389-
whatsNew.show(UIWidget.REQUEST_FOCUS);
390+
mWhatsNewWidget = new WhatsNewWidget(this);
391+
mWhatsNewWidget.setLoginOrigin(Accounts.LoginOrigin.NONE);
392+
mWhatsNewWidget.getPlacement().parentHandle = mWindows.getFocusedWindow().getHandle();
393+
mWhatsNewWidget.show(UIWidget.REQUEST_FOCUS);
390394
}
391395
}
392396

@@ -616,6 +620,20 @@ void loadFromIntent(final Intent intent) {
616620
uri = Uri.parse(SettingsStore.getInstance(this).getHomepage());
617621
}
618622
}
623+
624+
if (extras.containsKey("hide_webxr_interstitial")) {
625+
mHideWebXRIntersitial = extras.getBoolean("hide_webxr_interstitial", false);
626+
if (mHideWebXRIntersitial) {
627+
setWebXRIntersitialState(WEBXR_INTERSTITIAL_HIDDEN);
628+
}
629+
}
630+
631+
if (extras.containsKey("hide_whats_new")) {
632+
boolean hideWhatsNew = extras.getBoolean("hide_whats_new", false);
633+
if (hideWhatsNew && mWhatsNewWidget != null) {
634+
mWhatsNewWidget.hide(REMOVE_WIDGET);
635+
}
636+
}
619637
}
620638

621639
// If there is a URI we open it
@@ -1457,6 +1475,11 @@ public void setWebXRIntersitialState(@WebXRInterstitialState int aState) {
14571475
queueRunnable(() -> setWebXRIntersitialStateNative(aState));
14581476
}
14591477

1478+
@Override
1479+
public boolean isWebXRIntersitialHidden() {
1480+
return mHideWebXRIntersitial;
1481+
}
1482+
14601483
@Override
14611484
public void addConnectivityListener(Delegate aListener) {
14621485
if (!mConnectivityListeners.contains(aListener)) {

app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/WebXRInterstitialWidget.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public void onEnterWebXR() {
133133
showControllers();
134134
// Add some delay to duplicated input detection conflicts with the EnterVR button.
135135
postDelayed(() -> {
136-
if (mWidgetManager != null) {
136+
if (mWidgetManager != null && !mWidgetManager.isWebXRIntersitialHidden()) {
137137
mWidgetManager.setWebXRIntersitialState(WidgetManagerDelegate.WEBXR_INTERSTITIAL_ALLOW_DISMISS);
138138
}
139139
}, 50);

app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/WidgetManagerDelegate.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ interface WebXRListener {
9191
void addWebXRListener(WebXRListener aListener);
9292
void removeWebXRListener(WebXRListener aListener);
9393
void setWebXRIntersitialState(@WebXRInterstitialState int aState);
94+
boolean isWebXRIntersitialHidden();
9495
boolean isPermissionGranted(@NonNull String permission);
9596
void requestPermission(String uri, @NonNull String permission, GeckoSession.PermissionDelegate.Callback aCallback);
9697
boolean canOpenNewWindow();

0 commit comments

Comments
 (0)