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 @@ -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;

Expand All @@ -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) {
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)));

Expand All @@ -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) {
Expand All @@ -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);
}
}

Expand Down
19 changes: 10 additions & 9 deletions app/src/main/res/layout/options_environment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand All @@ -48,21 +48,22 @@
app:values="@array/developer_options_environments_values"
app:images="@array/developer_options_environments_images"/>


<org.mozilla.vrbrowser.ui.views.settings.SwitchSetting
android:id="@+id/envOverrideSwitch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:description="@string/developer_options_env_override" />

</LinearLayout>
</ScrollView>

<org.mozilla.vrbrowser.ui.views.settings.SwitchSetting
android:id="@+id/envOverrideSwitch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/scrollbar"
app:layout_constraintBottom_toTopOf="@id/footer_layout"
app:description="@string/developer_options_env_override" />

<org.mozilla.vrbrowser.ui.widgets.settings.SettingsFooter
android:id="@+id/footer_layout"
android:layout_width="match_parent"
android:layout_height="60dp"
app:description="@string/display_options_reset"
app:description="@string/environment_options_reset"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
Expand Down
6 changes: 0 additions & 6 deletions app/src/main/res/layout/options_language_content.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
</LinearLayout>

Expand All @@ -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" />
</LinearLayout>
</LinearLayout>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/options_privacy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@
<item name="android:scrollbarThumbVertical">@drawable/scrollbar_thumb</item>
<item name="android:fastScrollEnabled">true</item>
<item name="android:fastScrollAlwaysVisible">true</item>
<item name="android:fadingEdge">vertical</item>
<item name="android:fadingEdgeLength">60dp</item>
<item name="android:requiresFadingEdge">vertical</item>
</style>

<style name="settingsEdit">
Expand Down