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

Commit

Permalink
Add hide_webxr_interstitial and hide_whats_new ADB commands. (#3243)
Browse files Browse the repository at this point in the history
  • Loading branch information
daoshengmu authored Apr 25, 2020
1 parent 17a313b commit d673d48
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
31 changes: 27 additions & 4 deletions app/src/common/shared/org/mozilla/vrbrowser/VRBrowserActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.function.Consumer;

import static org.mozilla.vrbrowser.ui.widgets.UIWidget.REMOVE_WIDGET;

public class VRBrowserActivity extends PlatformActivity implements WidgetManagerDelegate, ComponentCallbacks2, LifecycleOwner, ViewModelStoreOwner {

private BroadcastReceiver mCrashReceiver = new BroadcastReceiver() {
Expand Down Expand Up @@ -169,6 +171,7 @@ public void run() {
NavigationBarWidget mNavigationBar;
CrashDialogWidget mCrashDialog;
TrayWidget mTray;
WhatsNewWidget mWhatsNewWidget = null;
WebXRInterstitialWidget mWebXRInterstitial;
PermissionDelegate mPermissionDelegate;
LinkedList<UpdateListener> mWidgetUpdateListeners;
Expand All @@ -190,6 +193,7 @@ public void run() {
private Widget mActiveDialog;
private Set<String> mPoorPerformanceWhiteList;
private float mCurrentCylinderDensity = 0;
private boolean mHideWebXRIntersitial = false;

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

// Show the what's upp dialog if we haven't showed it yet and this is v6.
if (!SettingsStore.getInstance(this).isWhatsNewDisplayed()) {
final WhatsNewWidget whatsNew = new WhatsNewWidget(this);
whatsNew.setLoginOrigin(Accounts.LoginOrigin.NONE);
whatsNew.getPlacement().parentHandle = mWindows.getFocusedWindow().getHandle();
whatsNew.show(UIWidget.REQUEST_FOCUS);
mWhatsNewWidget = new WhatsNewWidget(this);
mWhatsNewWidget.setLoginOrigin(Accounts.LoginOrigin.NONE);
mWhatsNewWidget.getPlacement().parentHandle = mWindows.getFocusedWindow().getHandle();
mWhatsNewWidget.show(UIWidget.REQUEST_FOCUS);
}
}

Expand Down Expand Up @@ -616,6 +620,20 @@ void loadFromIntent(final Intent intent) {
uri = Uri.parse(SettingsStore.getInstance(this).getHomepage());
}
}

if (extras.containsKey("hide_webxr_interstitial")) {
mHideWebXRIntersitial = extras.getBoolean("hide_webxr_interstitial", false);
if (mHideWebXRIntersitial) {
setWebXRIntersitialState(WEBXR_INTERSTITIAL_HIDDEN);
}
}

if (extras.containsKey("hide_whats_new")) {
boolean hideWhatsNew = extras.getBoolean("hide_whats_new", false);
if (hideWhatsNew && mWhatsNewWidget != null) {
mWhatsNewWidget.hide(REMOVE_WIDGET);
}
}
}

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

@Override
public boolean isWebXRIntersitialHidden() {
return mHideWebXRIntersitial;
}

@Override
public void addConnectivityListener(Delegate aListener) {
if (!mConnectivityListeners.contains(aListener)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public void onEnterWebXR() {
showControllers();
// Add some delay to duplicated input detection conflicts with the EnterVR button.
postDelayed(() -> {
if (mWidgetManager != null) {
if (mWidgetManager != null && !mWidgetManager.isWebXRIntersitialHidden()) {
mWidgetManager.setWebXRIntersitialState(WidgetManagerDelegate.WEBXR_INTERSTITIAL_ALLOW_DISMISS);
}
}, 50);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ interface WebXRListener {
void addWebXRListener(WebXRListener aListener);
void removeWebXRListener(WebXRListener aListener);
void setWebXRIntersitialState(@WebXRInterstitialState int aState);
boolean isWebXRIntersitialHidden();
boolean isPermissionGranted(@NonNull String permission);
void requestPermission(String uri, @NonNull String permission, GeckoSession.PermissionDelegate.Callback aCallback);
boolean canOpenNewWindow();
Expand Down

0 comments on commit d673d48

Please sign in to comment.