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

Added global autoplay support #1312

Merged
merged 1 commit into from
Jun 11, 2019
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 @@ -967,6 +967,24 @@ public void setRemoteDebugging(final boolean enabled) {
}
}

public void setAutoplayEnabled(final boolean enabled) {
if (mRuntime != null) {
mRuntime.getSettings().setAutoplayDefault(enabled ?
GeckoRuntimeSettings.AUTOPLAY_DEFAULT_ALLOWED :
GeckoRuntimeSettings.AUTOPLAY_DEFAULT_BLOCKED);
}
}

public boolean getAutoplayEnabled() {
if (mRuntime != null) {
return mRuntime.getSettings().getAutoplayDefault() == GeckoRuntimeSettings.AUTOPLAY_DEFAULT_ALLOWED ?
true :
false;
}

return false;
}

// NavigationDelegate

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public boolean isChecked() {

public void setChecked(boolean value) {
mSwitch.setChecked(value);
updateSwitchText();
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class PrivacyOptionsView extends SettingsView {
private AudioEngine mAudio;
private UIButton mBackButton;
private SwitchSetting mTrackingSetting;
private SwitchSetting mAutoplaySetting;
private ButtonSetting mResetButton;
private ArrayList<Pair<ButtonSetting, String>> mPermissionButtons;
private int mAlertDialogHandle;
Expand Down Expand Up @@ -73,6 +74,12 @@ private void initialize(Context aContext) {
SessionStore.get().setTrackingProtection(enabled);
});

mAutoplaySetting = findViewById(R.id.autoplaySwitch);
mAutoplaySetting.setChecked(SessionStore.get().getAutoplayEnabled());
mAutoplaySetting.setOnCheckedChangeListener((compoundButton, enabled, apply) -> {
SessionStore.get().setAutoplayEnabled(enabled);
});

TextView permissionsTitleText = findViewById(R.id.permissionsTitle);
permissionsTitleText.setText(getContext().getString(R.string.security_options_permissions_title, getContext().getString(R.string.app_name)));

Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/layout/options_privacy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@
android:layout_height="wrap_content"
app:description="@string/security_options_tracking_protection" />

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

<TextView
android:id="@+id/permissionsTitle"
style="@style/settingsDescription"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/non_L10n.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<string name="settings_key_console_logs" translatable="false">settings_console_logs</string>
<string name="settings_key_environment_override" translatable="false">settings_environment_override</string>
<string name="settings_key_multiprocess" translatable="false">settings_environment_multiprocess</string>
<string name="settings_key_servo">settings_environment_servo</string>
<string name="settings_key_servo" translatable="false">settings_environment_servo</string>
<string name="settings_key_tracking_protection" translatable="false">settings_tracking_protection</string>
<string name="settings_key_user_agent_version" translatable="false">settings_user_agent_version</string>
<string name="settings_key_input_mode" translatable="false">settings_touch_mode</string>
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,10 @@
and is used to enable or disable tracking protection. -->
<string name="security_options_tracking_protection">Tracking Protection</string>

<!-- This string labels an On/Off switch in the Privacy and Security settings dialog
and is used to enable or disable media autoplay. -->
<string name="security_options_autoplay">Autoplay Media</string>

<!-- This string is a label above the group of buttons that indicates that the buttons below
relate to Android system permissions granted to the app.
'%1$s' will be replaced at runtime with the app's name. -->
Expand Down