diff --git a/app/src/common/shared/org/mozilla/vrbrowser/browser/SettingsStore.java b/app/src/common/shared/org/mozilla/vrbrowser/browser/SettingsStore.java index d923a828a..014a42327 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/browser/SettingsStore.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/browser/SettingsStore.java @@ -73,8 +73,8 @@ SettingsStore getInstance(final @NonNull Context aContext) { public final static boolean AUTOPLAY_ENABLED = false; // Enable telemetry by default (opt-out). - private final static boolean enableCrashReportingByDefault = false; - private final static boolean enableTelemetryByDefault = true; + public final static boolean CRASH_REPORTING_DEFAULT = false; + public final static boolean TELEMETRY_DEFAULT = true; private int mCachedScrollDirection = -1; @@ -84,7 +84,7 @@ public SettingsStore(Context aContext) { } public boolean isCrashReportingEnabled() { - return mPrefs.getBoolean(mContext.getString(R.string.settings_key_crash), enableCrashReportingByDefault); + return mPrefs.getBoolean(mContext.getString(R.string.settings_key_crash), CRASH_REPORTING_DEFAULT); } public void setCrashReportingEnabled(boolean isEnabled) { @@ -98,7 +98,7 @@ public boolean isTelemetryEnabled() { final StrictMode.ThreadPolicy threadPolicy = StrictMode.allowThreadDiskReads(); try { return mPrefs.getBoolean( - mContext.getString(R.string.settings_key_telemetry), enableTelemetryByDefault); + mContext.getString(R.string.settings_key_telemetry), TELEMETRY_DEFAULT); } finally { StrictMode.setThreadPolicy(threadPolicy); } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/DeveloperOptionsView.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/DeveloperOptionsView.java index 8fc615234..8b13d58fa 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/DeveloperOptionsView.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/DeveloperOptionsView.java @@ -152,7 +152,9 @@ private void setPerformance(boolean value, boolean doApply) { mBinding.performanceMonitorSwitch.setValue(value, false); mBinding.performanceMonitorSwitch.setOnCheckedChangeListener(mPerformanceListener); - SettingsStore.getInstance(getContext()).setPerformanceMonitorEnabled(value); + if (doApply) { + SettingsStore.getInstance(getContext()).setPerformanceMonitorEnabled(value); + } } private void setServo(boolean value, boolean doApply) { diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/PrivacyOptionsView.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/PrivacyOptionsView.java index d0c7a532b..9498b71b2 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/PrivacyOptionsView.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/PrivacyOptionsView.java @@ -62,22 +62,6 @@ private void initialize(Context aContext) { exitWholeSettings(); }); - mBinding.drmContentPlaybackSwitch.setChecked(SettingsStore.getInstance(getContext()).isDrmContentPlaybackEnabled()); - mBinding.drmContentPlaybackSwitch.setOnCheckedChangeListener((compoundButton, enabled, apply) -> { - SettingsStore.getInstance(getContext()).setDrmContentPlaybackEnabled(enabled); - // TODO Enable/Disable DRM content playback - }); - mBinding.drmContentPlaybackSwitch.setLinkClickListener((widget, url) -> { - SessionStore.get().getActiveStore().loadUri(url); - exitWholeSettings(); - }); - - mBinding.trackingProtectionSwitch.setChecked(SettingsStore.getInstance(getContext()).isTrackingProtectionEnabled()); - mBinding.trackingProtectionSwitch.setOnCheckedChangeListener((compoundButton, enabled, apply) -> { - SettingsStore.getInstance(getContext()).setTrackingProtectionEnabled(enabled); - SessionStore.get().setTrackingProtection(enabled); - }); - TextView permissionsTitleText = findViewById(R.id.permissionsTitle); permissionsTitleText.setText(getContext().getString(R.string.security_options_permissions_title, getContext().getString(R.string.app_name))); @@ -97,22 +81,27 @@ private void initialize(Context aContext) { togglePermission(button.first, button.second)); } - mBinding.notificationsPermissionSwitch.setChecked(SettingsStore.getInstance(getContext()).isNotificationsEnabled()); - mBinding.notificationsPermissionSwitch.setOnCheckedChangeListener((compoundButton, enabled, apply) -> { - SettingsStore.getInstance(getContext()).setNotificationsEnabled(enabled); + mBinding.drmContentPlaybackSwitch.setOnCheckedChangeListener(mDrmContentListener); + mBinding.drmContentPlaybackSwitch.setLinkClickListener((widget, url) -> { + SessionStore.get().getActiveStore().loadUri(url); + exitWholeSettings(); }); + setDrmContent(SettingsStore.getInstance(getContext()).isDrmContentPlaybackEnabled(), false); - mBinding.speechDataSwitch.setChecked(SettingsStore.getInstance(getContext()).isSpeechDataCollectionEnabled()); - mBinding.speechDataSwitch.setOnCheckedChangeListener((compoundButton, enabled, apply) -> - SettingsStore.getInstance(getContext()).setSpeechDataCollectionEnabled(enabled)); + mBinding.trackingProtectionSwitch.setOnCheckedChangeListener(mTrackingProtectionListener); + setTrackingProtection(SettingsStore.getInstance(getContext()).isTrackingProtectionEnabled(), false); - mBinding.telemetryDataSwitch.setChecked(SettingsStore.getInstance(getContext()).isTelemetryEnabled()); - mBinding.telemetryDataSwitch.setOnCheckedChangeListener((compoundButton, enabled, apply) -> - SettingsStore.getInstance(getContext()).setTelemetryEnabled(enabled)); + mBinding.notificationsPermissionSwitch.setOnCheckedChangeListener(mNotificationsListener); + setNotifications(SettingsStore.getInstance(getContext()).isNotificationsEnabled(), false); - mBinding.crashReportsDataSwitch.setChecked(SettingsStore.getInstance(getContext()).isCrashReportingEnabled()); - mBinding.crashReportsDataSwitch.setOnCheckedChangeListener((compoundButton, enabled, apply) -> - SettingsStore.getInstance(getContext()).setCrashReportingEnabled(enabled)); + mBinding.speechDataSwitch.setOnCheckedChangeListener(mSpeechDataListener); + setSpeechData(SettingsStore.getInstance(getContext()).isSpeechDataCollectionEnabled(), false); + + mBinding.telemetryDataSwitch.setOnCheckedChangeListener(mTelemetryListener); + setTelemetry(SettingsStore.getInstance(getContext()).isTelemetryEnabled(), false); + + mBinding.crashReportsDataSwitch.setOnCheckedChangeListener(mCrashReportsListener); + setCrashReports(SettingsStore.getInstance(getContext()).isCrashReportingEnabled(), false); } private void togglePermission(SwitchSetting aButton, String aPermission) { @@ -134,9 +123,115 @@ public void reject() { } } + private SwitchSetting.OnCheckedChangeListener mDrmContentListener = (compoundButton, value, doApply) -> { + setDrmContent(value, doApply); + }; + + private SwitchSetting.OnCheckedChangeListener mTrackingProtectionListener = (compoundButton, value, doApply) -> { + setTrackingProtection(value, doApply); + }; + + private SwitchSetting.OnCheckedChangeListener mNotificationsListener = (compoundButton, value, doApply) -> { + setNotifications(value, doApply); + }; + + private SwitchSetting.OnCheckedChangeListener mSpeechDataListener = (compoundButton, value, doApply) -> { + setSpeechData(value, doApply); + }; + + private SwitchSetting.OnCheckedChangeListener mTelemetryListener = (compoundButton, value, doApply) -> { + setTelemetry(value, doApply); + }; + + private SwitchSetting.OnCheckedChangeListener mCrashReportsListener = (compoundButton, value, doApply) -> { + setCrashReports(value, doApply); + }; + private void resetOptions() { + if (mBinding.drmContentPlaybackSwitch.isChecked() != SettingsStore.DRM_PLAYBACK_DEFAULT) { + setDrmContent(SettingsStore.DRM_PLAYBACK_DEFAULT, true); + } + if (mBinding.trackingProtectionSwitch.isChecked() != SettingsStore.TRACKING_DEFAULT) { - mBinding.trackingProtectionSwitch.setChecked(SettingsStore.TRACKING_DEFAULT); + setTrackingProtection(SettingsStore.TRACKING_DEFAULT, true); + } + + if (mBinding.notificationsPermissionSwitch.isChecked() != SettingsStore.NOTIFICATIONS_DEFAULT) { + setNotifications(SettingsStore.NOTIFICATIONS_DEFAULT, true); + } + + if (mBinding.speechDataSwitch.isChecked() != SettingsStore.SPEECH_DATA_COLLECTION_DEFAULT) { + setSpeechData(SettingsStore.SPEECH_DATA_COLLECTION_DEFAULT, true); + } + + if (mBinding.telemetryDataSwitch.isChecked() != SettingsStore.TELEMETRY_DEFAULT) { + setTelemetry(SettingsStore.TELEMETRY_DEFAULT, true); + } + + if (mBinding.crashReportsDataSwitch.isChecked() != SettingsStore.CRASH_REPORTING_DEFAULT) { + setCrashReports(SettingsStore.CRASH_REPORTING_DEFAULT, true); + } + } + + private void setDrmContent(boolean value, boolean doApply) { + mBinding.drmContentPlaybackSwitch.setOnCheckedChangeListener(null); + mBinding.drmContentPlaybackSwitch.setValue(value, false); + mBinding.drmContentPlaybackSwitch.setOnCheckedChangeListener(mDrmContentListener); + + if (doApply) { + SettingsStore.getInstance(getContext()).setDrmContentPlaybackEnabled(value); + // TODO Enable/Disable DRM content playback + } + } + + private void setTrackingProtection(boolean value, boolean doApply) { + mBinding.trackingProtectionSwitch.setOnCheckedChangeListener(null); + mBinding.trackingProtectionSwitch.setValue(value, false); + mBinding.trackingProtectionSwitch.setOnCheckedChangeListener(mTrackingProtectionListener); + + if (doApply) { + SettingsStore.getInstance(getContext()).setTrackingProtectionEnabled(value); + SessionStore.get().setTrackingProtection(value); + } + } + + private void setNotifications(boolean value, boolean doApply) { + mBinding.notificationsPermissionSwitch.setOnCheckedChangeListener(null); + mBinding.notificationsPermissionSwitch.setValue(value, false); + mBinding.notificationsPermissionSwitch.setOnCheckedChangeListener(mNotificationsListener); + + if (doApply) { + SettingsStore.getInstance(getContext()).setNotificationsEnabled(value); + } + } + + private void setSpeechData(boolean value, boolean doApply) { + mBinding.speechDataSwitch.setOnCheckedChangeListener(null); + mBinding.speechDataSwitch.setValue(value, false); + mBinding.speechDataSwitch.setOnCheckedChangeListener(mSpeechDataListener); + + if (doApply) { + SettingsStore.getInstance(getContext()).setSpeechDataCollectionEnabled(value); + } + } + + private void setTelemetry(boolean value, boolean doApply) { + mBinding.telemetryDataSwitch.setOnCheckedChangeListener(null); + mBinding.telemetryDataSwitch.setValue(value, false); + mBinding.telemetryDataSwitch.setOnCheckedChangeListener(mTelemetryListener); + + if (doApply) { + SettingsStore.getInstance(getContext()).setTelemetryEnabled(value); + } + } + + private void setCrashReports(boolean value, boolean doApply) { + mBinding.crashReportsDataSwitch.setOnCheckedChangeListener(null); + mBinding.crashReportsDataSwitch.setValue(value, false); + mBinding.crashReportsDataSwitch.setOnCheckedChangeListener(mCrashReportsListener); + + if (doApply) { + SettingsStore.getInstance(getContext()).setCrashReportingEnabled(value); } } diff --git a/app/src/main/res/layout/options_environment.xml b/app/src/main/res/layout/options_environment.xml index 6a970b1a5..b8f5a9ce4 100644 --- a/app/src/main/res/layout/options_environment.xml +++ b/app/src/main/res/layout/options_environment.xml @@ -29,7 +29,7 @@ android:layout_marginTop="10dp" android:layout_marginBottom="10dp" android:paddingEnd="30dp" - app:layout_constraintBottom_toTopOf="@id/footer_layout" + app:layout_constraintBottom_toTopOf="@id/envOverrideSwitch" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/header_layout"> @@ -48,21 +48,22 @@ app:values="@array/developer_options_environments_values" app:images="@array/developer_options_environments_images"/> - - - + + diff --git a/app/src/main/res/layout/options_language_content.xml b/app/src/main/res/layout/options_language_content.xml index 641cce36f..ec43a887f 100644 --- a/app/src/main/res/layout/options_language_content.xml +++ b/app/src/main/res/layout/options_language_content.xml @@ -57,9 +57,6 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:contentDescription="@string/app_name" - android:fadingEdge="vertical" - android:fadingEdgeLength="60dp" - android:requiresFadingEdge="vertical" app:layoutManager="org.mozilla.vrbrowser.ui.adapters.LanguagesAdapter$CustLinearLayoutManager" /> @@ -86,9 +83,6 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:contentDescription="@string/app_name" - android:fadingEdge="vertical" - android:fadingEdgeLength="60dp" - android:requiresFadingEdge="vertical" app:layoutManager="org.mozilla.vrbrowser.ui.adapters.LanguagesAdapter$CustLinearLayoutManager" /> diff --git a/app/src/main/res/layout/options_privacy.xml b/app/src/main/res/layout/options_privacy.xml index 2949fb7a8..65acea895 100644 --- a/app/src/main/res/layout/options_privacy.xml +++ b/app/src/main/res/layout/options_privacy.xml @@ -153,7 +153,7 @@ android:id="@+id/footer_layout" android:layout_width="match_parent" android:layout_height="60dp" - app:description="@string/display_options_reset" + app:description="@string/privacy_options_reset" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" /> diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 567600f54..abba99d94 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -177,6 +177,9 @@ @drawable/scrollbar_thumb true true + vertical + 60dp + vertical