Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix curved mode reset not working #1478

Merged
merged 1 commit into from
Jul 31, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import android.graphics.Point;
import android.view.View;

import org.mozilla.vrbrowser.BuildConfig;
import org.mozilla.vrbrowser.R;
import org.mozilla.vrbrowser.audio.AudioEngine;
import org.mozilla.vrbrowser.browser.SessionStore;
Expand Down Expand Up @@ -57,12 +56,8 @@ private void initialize(Context aContext) {
});

mCurvedDisplaySwitch = findViewById(R.id.curved_display_switch);
mCurvedDisplaySwitch.setChecked(SettingsStore.getInstance(getContext()).getCylinderDensity() > 0.0f);
mCurvedDisplaySwitch.setOnCheckedChangeListener((compoundButton, enabled, apply) -> {
float density = enabled ? SettingsStore.CYLINDER_DENSITY_ENABLED_DEFAULT : 0.0f;
SettingsStore.getInstance(getContext()).setCylinderDensity(density);
mWidgetManager.setCylinderDensity(density);
});
mCurvedDisplaySwitch.setOnCheckedChangeListener(mCurvedDisplayListener);
setCurvedDisplay(SettingsStore.getInstance(getContext()).getCylinderDensity() > 0.0f, false);

int uaMode = SettingsStore.getInstance(getContext()).getUaMode();
mUaModeRadio = findViewById(R.id.ua_radio);
Expand Down Expand Up @@ -265,6 +260,9 @@ public boolean isEditing() {
}
};

private SwitchSetting.OnCheckedChangeListener mCurvedDisplayListener = (compoundButton, enabled, apply) ->
setCurvedDisplay(enabled, true);

private OnClickListener mResetListener = (view) -> {
boolean restart = false;

Expand Down Expand Up @@ -302,11 +300,24 @@ public boolean isEditing() {

setHomepage(mDefaultHomepageUrl);
setAutoplay(SettingsStore.AUTOPLAY_ENABLED, true);
setCurvedDisplay(false, true);

if (restart)
showRestartDialog();
};

private void setCurvedDisplay(boolean value, boolean doApply) {
mCurvedDisplaySwitch.setOnCheckedChangeListener(null);
mCurvedDisplaySwitch.setValue(value, false);
mCurvedDisplaySwitch.setOnCheckedChangeListener(mCurvedDisplayListener);

if (doApply) {
float density = value ? SettingsStore.CYLINDER_DENSITY_ENABLED_DEFAULT : 0.0f;
SettingsStore.getInstance(getContext()).setCylinderDensity(density);
mWidgetManager.setCylinderDensity(density);
}
}

private void setAutoplay(boolean value, boolean doApply) {
mAutoplaySetting.setOnCheckedChangeListener(null);
mAutoplaySetting.setValue(value, false);
Expand Down