Commit b834de1f authored by Michael Thiessen's avatar Michael Thiessen Committed by Commit Bot

VR: More VR java code cleanup.

Cleans up our method ordering, public statics first, package/private
below, followed by non-statics and fixes visibility on a bunch of
functions.

Also cleans up a bunch of functions for testing that really just
wanted access to VrShellImpl.

Change-Id: Ieb731d82f5633c8ec69d7b427c696b891b46cab2
Reviewed-on: https://chromium-review.googlesource.com/1136856Reviewed-by: default avatarTibor Goldschwendt <tiborg@chromium.org>
Commit-Queue: Michael Thiessen <mthiesse@chromium.org>
Cr-Commit-Position: refs/heads/master@{#575327}
parent 20d78afb
...@@ -124,4 +124,13 @@ public class VrIntentUtils { ...@@ -124,4 +124,13 @@ public class VrIntentUtils {
intent.removeCategory(DAYDREAM_CATEGORY); intent.removeCategory(DAYDREAM_CATEGORY);
assert !isVrIntent(intent); assert !isVrIntent(intent);
} }
/**
* Adds the necessary VR flags to an intent.
* @param intent The intent to add VR flags to.
* @return the intent with VR flags set.
*/
public static Intent setupVrIntent(Intent intent) {
return VrShellDelegate.getVrClassesWrapper().setupVrIntent(intent);
}
} }
...@@ -64,6 +64,7 @@ import org.chromium.ui.base.PermissionCallback; ...@@ -64,6 +64,7 @@ import org.chromium.ui.base.PermissionCallback;
import org.chromium.ui.base.WindowAndroid; import org.chromium.ui.base.WindowAndroid;
import org.chromium.ui.display.DisplayAndroid; import org.chromium.ui.display.DisplayAndroid;
import org.chromium.ui.display.VirtualDisplayAndroid; import org.chromium.ui.display.VirtualDisplayAndroid;
import org.chromium.ui.widget.UiWidgetFactory;
/** /**
* This view extends from GvrLayout which wraps a GLSurfaceView that renders VR shell. * This view extends from GvrLayout which wraps a GLSurfaceView that renders VR shell.
...@@ -104,6 +105,7 @@ public class VrShellImpl ...@@ -104,6 +105,7 @@ public class VrShellImpl
private boolean mReprojectedRendering; private boolean mReprojectedRendering;
private TabRedirectHandler mNonVrTabRedirectHandler; private TabRedirectHandler mNonVrTabRedirectHandler;
private UiWidgetFactory mNonVrUiWidgetFactory;
private TabModelSelector mTabModelSelector; private TabModelSelector mTabModelSelector;
private float mLastContentWidth; private float mLastContentWidth;
...@@ -162,6 +164,12 @@ public class VrShellImpl ...@@ -162,6 +164,12 @@ public class VrShellImpl
mActivity.getFindToolbarManager().hideToolbar(); mActivity.getFindToolbarManager().hideToolbar();
} }
if (ChromeFeatureList.isEnabled(ChromeFeatureList.VR_BROWSING_NATIVE_ANDROID_UI)) {
mNonVrUiWidgetFactory = UiWidgetFactory.getInstance();
UiWidgetFactory.setInstance(
new VrUiWidgetFactory(this, mActivity.getModalDialogManager()));
}
// This overrides the default intent created by GVR to return to Chrome when the DON flow // This overrides the default intent created by GVR to return to Chrome when the DON flow
// is triggered by resuming the GvrLayout, which is the usual way Daydream apps enter VR. // is triggered by resuming the GvrLayout, which is the usual way Daydream apps enter VR.
// See VrShellDelegate#getEnterVrPendingIntent for why we need to do this. // See VrShellDelegate#getEnterVrPendingIntent for why we need to do this.
...@@ -774,6 +782,8 @@ public class VrShellImpl ...@@ -774,6 +782,8 @@ public class VrShellImpl
mActivity.getToolbarManager().setProgressBarEnabled(true); mActivity.getToolbarManager().setProgressBarEnabled(true);
} }
if (mNonVrUiWidgetFactory != null) UiWidgetFactory.setInstance(mNonVrUiWidgetFactory);
FrameLayout decor = (FrameLayout) mActivity.getWindow().getDecorView(); FrameLayout decor = (FrameLayout) mActivity.getWindow().getDecorView();
decor.removeView(mUiView); decor.removeView(mUiView);
super.shutdown(); super.shutdown();
......
...@@ -41,11 +41,11 @@ public class TestVrShellDelegate extends VrShellDelegate { ...@@ -41,11 +41,11 @@ public class TestVrShellDelegate extends VrShellDelegate {
} }
public static boolean isDisplayingUrlForTesting() { public static boolean isDisplayingUrlForTesting() {
return VrShellDelegate.isDisplayingUrl(); return TestVrShellDelegate.getInstance().getVrShell().isDisplayingUrlForTesting();
} }
public static VrShell getVrShellForTesting() { public static VrShell getVrShellForTesting() {
return VrShellDelegate.getVrShell(); return TestVrShellDelegate.getInstance().getVrShell();
} }
@Override @Override
...@@ -85,25 +85,21 @@ public class TestVrShellDelegate extends VrShellDelegate { ...@@ -85,25 +85,21 @@ public class TestVrShellDelegate extends VrShellDelegate {
return super.isShowingDoff(); return super.isShowingDoff();
} }
@Override
public void acceptDoffPromptForTesting() { public void acceptDoffPromptForTesting() {
super.acceptDoffPromptForTesting(); getVrShell().acceptDoffPromptForTesting();
} }
@Override
public void performControllerActionForTesting( public void performControllerActionForTesting(
int elementName, int actionType, PointF position) { int elementName, int actionType, PointF position) {
super.performControllerActionForTesting(elementName, actionType, position); getVrShell().performControllerActionForTesting(elementName, actionType, position);
} }
@Override
public void setUiExpectingActivityForTesting(int quiescenceTimeoutMs, Runnable resultCallback) { public void setUiExpectingActivityForTesting(int quiescenceTimeoutMs, Runnable resultCallback) {
super.setUiExpectingActivityForTesting(quiescenceTimeoutMs, resultCallback); getVrShell().setUiExpectingActivityForTesting(quiescenceTimeoutMs, resultCallback);
} }
@Override
public int getLastUiActivityResultForTesting() { public int getLastUiActivityResultForTesting() {
return super.getLastUiActivityResultForTesting(); return getVrShell().getLastUiActivityResultForTesting();
} }
@Override @Override
......
...@@ -221,7 +221,7 @@ public class TransitionUtils { ...@@ -221,7 +221,7 @@ public class TransitionUtils {
new Intent(ContextUtils.getApplicationContext(), VrMainActivity.class); new Intent(ContextUtils.getApplicationContext(), VrMainActivity.class);
intent.setData(Uri.parse(url)); intent.setData(Uri.parse(url));
intent.addCategory(VrIntentUtils.DAYDREAM_CATEGORY); intent.addCategory(VrIntentUtils.DAYDREAM_CATEGORY);
VrShellDelegate.getVrClassesWrapper().setupVrIntent(intent); VrIntentUtils.setupVrIntent(intent);
if (autopresent) { if (autopresent) {
// Daydream removes this category for deep-linked URLs for legacy reasons. // Daydream removes this category for deep-linked URLs for legacy reasons.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment