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

Commit

Permalink
Fix curved mode reset not working (#1478)
Browse files Browse the repository at this point in the history
  • Loading branch information
keianhzo authored and MortimerGoro committed Jul 31, 2019
1 parent 8e847aa commit 34c619f
Showing 1 changed file with 18 additions and 7 deletions.
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

0 comments on commit 34c619f

Please sign in to comment.