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

Fixed environment fade when clicking on Privacy and Bug Report settings #650

Merged
merged 1 commit into from
Oct 22, 2018
Merged
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 @@ -14,12 +14,13 @@
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CompoundButton;
import android.widget.ImageButton;
import android.widget.Switch;
import android.widget.TextView;

import org.mozilla.geckoview.GeckoSession;
import org.mozilla.vrbrowser.*;
import org.mozilla.vrbrowser.BuildConfig;
import org.mozilla.vrbrowser.R;
import org.mozilla.vrbrowser.audio.AudioEngine;
import org.mozilla.vrbrowser.browser.SessionStore;
import org.mozilla.vrbrowser.browser.SettingsStore;
Expand Down Expand Up @@ -83,60 +84,48 @@ private void initialize(Context aContext) {

ImageButton cancelButton = findViewById(R.id.settingsCancelButton);

cancelButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (mAudio != null) {
mAudio.playSound(AudioEngine.Sound.CLICK);
}

onDismiss();
cancelButton.setOnClickListener(v -> {
if (mAudio != null) {
mAudio.playSound(AudioEngine.Sound.CLICK);
}

onDismiss();
});

SettingsButton privacyButton = findViewById(R.id.privacyButton);
privacyButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
if (mAudio != null) {
mAudio.playSound(AudioEngine.Sound.CLICK);
}

onSettingsPrivacyClick();
privacyButton.setOnClickListener(view -> {
if (mAudio != null) {
mAudio.playSound(AudioEngine.Sound.CLICK);
}

onSettingsPrivacyClick();
});

final TextView crashReportingSwitchText = findViewById(R.id.crash_reporting_switch_text);
Switch crashReportingSwitch = findViewById(R.id.crash_reporting_switch);
crashReportingSwitch.setChecked(SettingsStore.getInstance(getContext()).isCrashReportingEnabled());
crashReportingSwitchText.setText(crashReportingSwitch.isChecked() ? getContext().getString(R.string.on) : getContext().getString(R.string.off));
crashReportingSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if (mAudio != null) {
mAudio.playSound(AudioEngine.Sound.CLICK);
}

crashReportingSwitchText.setText(b ? getContext().getString(R.string.on) : getContext().getString(R.string.off));
onSettingsCrashReportingChange(b);
crashReportingSwitch.setOnCheckedChangeListener((compoundButton, b) -> {
if (mAudio != null) {
mAudio.playSound(AudioEngine.Sound.CLICK);
}

crashReportingSwitchText.setText(b ? getContext().getString(R.string.on) : getContext().getString(R.string.off));
onSettingsCrashReportingChange(b);
});
crashReportingSwitch.setSoundEffectsEnabled(false);

final TextView crashTelemetrySwitchText = findViewById(R.id.telemetry_switch_text);
Switch telemetrySwitch = findViewById(R.id.telemetry_switch);
telemetrySwitch.setChecked(SettingsStore.getInstance(getContext()).isTelemetryEnabled());
crashTelemetrySwitchText.setText(telemetrySwitch.isChecked() ? getContext().getString(R.string.on) : getContext().getString(R.string.off));
telemetrySwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if (mAudio != null) {
mAudio.playSound(AudioEngine.Sound.CLICK);
}

crashTelemetrySwitchText.setText(b ? getContext().getString(R.string.on) : getContext().getString(R.string.off));
onSettingsTelemetryChange(b);
telemetrySwitch.setOnCheckedChangeListener((compoundButton, b) -> {
if (mAudio != null) {
mAudio.playSound(AudioEngine.Sound.CLICK);
}

crashTelemetrySwitchText.setText(b ? getContext().getString(R.string.on) : getContext().getString(R.string.off));
onSettingsTelemetryChange(b);
});
telemetrySwitch.setSoundEffectsEnabled(false);

Expand All @@ -154,38 +143,29 @@ public void onCheckedChanged(CompoundButton compoundButton, boolean b) {

ViewGroup versionLayout = findViewById(R.id.versionLayout);
final GestureDetector gd = new GestureDetector(getContext(), new VersionGestureListener());
versionLayout.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
if (gd.onTouchEvent(motionEvent)) {
return true;
}
return view.onTouchEvent(motionEvent);
versionLayout.setOnTouchListener((view, motionEvent) -> {
if (gd.onTouchEvent(motionEvent)) {
return true;
}
return view.onTouchEvent(motionEvent);
});

SettingsButton reportButton = findViewById(R.id.reportButton);
reportButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
if (mAudio != null) {
mAudio.playSound(AudioEngine.Sound.CLICK);
}

onSettingsReportClick();
reportButton.setOnClickListener(view -> {
if (mAudio != null) {
mAudio.playSound(AudioEngine.Sound.CLICK);
}

onSettingsReportClick();
});

SettingsButton developerOptionsButton = findViewById(R.id.developerOptionsButton);
developerOptionsButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
if (mAudio != null) {
mAudio.playSound(AudioEngine.Sound.CLICK);
}

onDeveloperOptionsClick();
developerOptionsButton.setOnClickListener(view -> {
if (mAudio != null) {
mAudio.playSound(AudioEngine.Sound.CLICK);
}

onDeveloperOptionsClick();
});

mAudio = AudioEngine.fromContext(aContext);
Expand Down Expand Up @@ -230,6 +210,7 @@ private void onSettingsPrivacyClick() {
SessionStore.get().loadUri(getContext().getString(R.string.private_policy_url));

hide();
mWidgetManager.fadeInWorld();
}

private void onSettingsReportClick() {
Expand Down Expand Up @@ -260,6 +241,7 @@ private void onSettingsReportClick() {
SessionStore.get().loadUri(getContext().getString(R.string.private_report_url, url));

hide();
mWidgetManager.fadeInWorld();
}

private void onDeveloperOptionsClick() {
Expand Down Expand Up @@ -310,12 +292,7 @@ private void showDeveloperOptionsDialog() {
if (widget == null) {
widget = createChild(DeveloperOptionsWidget.class, false);
mDeveloperOptionsDialogHandle = widget.getHandle();
widget.setDelegate(new Delegate() {
@Override
public void onDismiss() {
onDeveloperOptionsDialogDismissed();
}
});
widget.setDelegate(() -> onDeveloperOptionsDialogDismissed());
}

widget.show();
Expand Down