Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
import org.mozilla.vrbrowser.crashreporting.CrashReporterService;
import org.mozilla.vrbrowser.crashreporting.GlobalExceptionHandler;
import org.mozilla.vrbrowser.geolocation.GeolocationWrapper;
import org.mozilla.vrbrowser.ui.widgets.prompts.AlertPromptWidget;
import org.mozilla.vrbrowser.ui.widgets.prompts.ConfirmPromptWidget;
import org.mozilla.vrbrowser.utils.DeviceType;
import org.mozilla.vrbrowser.input.MotionEventGenerator;
Expand Down Expand Up @@ -1273,9 +1272,12 @@ public void resetUIYaw() {

@Override
public void setCylinderDensity(final float aDensity) {
if (mWindows != null && aDensity == 0.0f && mWindows.getWindowsCount() > 1) {
return;
}
queueRunnable(() -> setCylinderDensityNative(aDensity));
if (mWindows != null) {
mWindows.updateCurvedMode();
mWindows.updateCurvedMode(false);
}
}

Expand Down
53 changes: 39 additions & 14 deletions app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/Windows.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ class WindowsState {
public static final int MAX_WINDOWS = 3;
private WindowWidget mFullscreenWindow;
private WindowPlacement mPrevWindowPlacement;
private boolean mCurvedMode = false;
private boolean mStoredCurvedMode = false;
private boolean mForcedCurvedMode = false;

public enum WindowPlacement{
FRONT(0),
Expand All @@ -93,6 +94,8 @@ public Windows(Context aContext) {
mRegularWindows = new ArrayList<>();
mPrivateWindows = new ArrayList<>();

mStoredCurvedMode = SettingsStore.getInstance(mContext).getCylinderDensity() > 0.0f;

restoreWindows();
}

Expand Down Expand Up @@ -200,7 +203,7 @@ public WindowWidget addWindow() {
updateMaxWindowScales();
mWidgetManager.addWidget(newWindow);
focusWindow(newWindow);
updateCurvedMode();
updateCurvedMode(true);
updateViews();
return newWindow;
}
Expand All @@ -217,7 +220,7 @@ private WindowWidget addWindow(@NonNull WindowState aState) {
newWindow.getPlacement().worldWidth = aState.worldWidth;
newWindow.setRestored(true);
placeWindow(newWindow, aState.placement);
updateCurvedMode();
updateCurvedMode(true);

mWidgetManager.addWidget(newWindow);
return newWindow;
Expand Down Expand Up @@ -362,7 +365,7 @@ public void enterPrivateMode() {
return;
}
mPrivateMode = true;
updateCurvedMode();
updateCurvedMode(true);
for (WindowWidget window: mRegularWindows) {
setWindowVisible(window, false);
}
Expand All @@ -388,7 +391,7 @@ public void exitPrivateMode() {
return;
}
mPrivateMode = false;
updateCurvedMode();
updateCurvedMode(true);
for (WindowWidget window: mRegularWindows) {
setWindowVisible(window, true);
}
Expand Down Expand Up @@ -510,7 +513,7 @@ private void removeWindow(@NonNull WindowWidget aWindow) {
aWindow.getSessionStack().removeContentListener(this);
aWindow.close();
updateMaxWindowScales();
updateCurvedMode();
updateCurvedMode(true);

if (mPrivateMode) {
TelemetryWrapper.openWindowsEvent(mPrivateWindows.size() + 1, mPrivateWindows.size(), true);
Expand All @@ -525,6 +528,10 @@ private void setWindowVisible(@NonNull WindowWidget aWindow, boolean aVisible) {
}

private void placeWindow(@NonNull WindowWidget aWindow, WindowPlacement aPosition) {
placeWindow(aWindow, aPosition, mStoredCurvedMode || mForcedCurvedMode);
}

private void placeWindow(@NonNull WindowWidget aWindow, WindowPlacement aPosition, boolean curvedMode) {
WidgetPlacement placement = aWindow.getPlacement();
aWindow.setWindowPlacement(aPosition);
switch (aPosition) {
Expand All @@ -546,7 +553,7 @@ private void placeWindow(@NonNull WindowWidget aWindow, WindowPlacement aPositio
placement.parentAnchorY = 0.0f;
placement.rotationAxisX = 0;
placement.rotationAxisZ = 0;
if (mCurvedMode) {
if (curvedMode) {
placement.rotationAxisY = 0;
placement.rotation = 0;
} else {
Expand All @@ -564,7 +571,7 @@ private void placeWindow(@NonNull WindowWidget aWindow, WindowPlacement aPositio
placement.parentAnchorY = 0.0f;
placement.rotationAxisX = 0;
placement.rotationAxisZ = 0;
if (mCurvedMode) {
if (curvedMode) {
placement.rotationAxisY = 0;
placement.rotation = 0;
} else {
Expand All @@ -578,19 +585,37 @@ private void placeWindow(@NonNull WindowWidget aWindow, WindowPlacement aPositio
}
}

public void updateCurvedMode() {
public void updateCurvedMode(boolean force) {
float density = SettingsStore.getInstance(mContext).getCylinderDensity();
boolean curved = getCurrentWindows().size() > 1 || density > 0;
if (curved != mCurvedMode) {
mCurvedMode = curved;
for (WindowWidget window: getCurrentWindows()) {
placeWindow(window, window.getWindowPlacement());
boolean storedCurvedMode = density > 0.0f;
boolean forcedCurvedMode = getCurrentWindows().size() > 1;

if (force) {
boolean curved = forcedCurvedMode || storedCurvedMode;

for (WindowWidget window : getCurrentWindows()) {
placeWindow(window, window.getWindowPlacement(), curved);
}
updateViews();
mWidgetManager.setCylinderDensity(curved ? SettingsStore.CYLINDER_DENSITY_ENABLED_DEFAULT : density);

} else if ((storedCurvedMode != mStoredCurvedMode) || (forcedCurvedMode != mForcedCurvedMode)) {
mStoredCurvedMode = storedCurvedMode;
mForcedCurvedMode = forcedCurvedMode;

boolean curved = mStoredCurvedMode || mForcedCurvedMode;
for (WindowWidget window : getCurrentWindows()) {
placeWindow(window, window.getWindowPlacement(), curved);
}
updateViews();
mWidgetManager.setCylinderDensity(curved ? SettingsStore.CYLINDER_DENSITY_ENABLED_DEFAULT : density);
}
}

public int getWindowsCount() {
return getCurrentWindows().size();
}

private void updateViews() {
WindowWidget frontWindow = getFrontWindow();
WindowWidget leftWindow = getLeftWindow();
Expand Down