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

Commit 5431327

Browse files
keianhzobluemarvin
authored andcommitted
Added global autoplay support (#1231) (#1312)
1 parent 15cf22a commit 5431327

File tree

6 files changed

+37
-1
lines changed

6 files changed

+37
-1
lines changed

app/src/common/shared/org/mozilla/vrbrowser/browser/SessionStore.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -967,6 +967,24 @@ public void setRemoteDebugging(final boolean enabled) {
967967
}
968968
}
969969

970+
public void setAutoplayEnabled(final boolean enabled) {
971+
if (mRuntime != null) {
972+
mRuntime.getSettings().setAutoplayDefault(enabled ?
973+
GeckoRuntimeSettings.AUTOPLAY_DEFAULT_ALLOWED :
974+
GeckoRuntimeSettings.AUTOPLAY_DEFAULT_BLOCKED);
975+
}
976+
}
977+
978+
public boolean getAutoplayEnabled() {
979+
if (mRuntime != null) {
980+
return mRuntime.getSettings().getAutoplayDefault() == GeckoRuntimeSettings.AUTOPLAY_DEFAULT_ALLOWED ?
981+
true :
982+
false;
983+
}
984+
985+
return false;
986+
}
987+
970988
// NavigationDelegate
971989

972990
@Override

app/src/common/shared/org/mozilla/vrbrowser/ui/views/settings/SwitchSetting.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ public boolean isChecked() {
9494

9595
public void setChecked(boolean value) {
9696
mSwitch.setChecked(value);
97+
updateSwitchText();
9798
}
9899

99100

app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/PrivacyOptionsView.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class PrivacyOptionsView extends SettingsView {
2727
private AudioEngine mAudio;
2828
private UIButton mBackButton;
2929
private SwitchSetting mTrackingSetting;
30+
private SwitchSetting mAutoplaySetting;
3031
private ButtonSetting mResetButton;
3132
private ArrayList<Pair<ButtonSetting, String>> mPermissionButtons;
3233
private int mAlertDialogHandle;
@@ -73,6 +74,12 @@ private void initialize(Context aContext) {
7374
SessionStore.get().setTrackingProtection(enabled);
7475
});
7576

77+
mAutoplaySetting = findViewById(R.id.autoplaySwitch);
78+
mAutoplaySetting.setChecked(SessionStore.get().getAutoplayEnabled());
79+
mAutoplaySetting.setOnCheckedChangeListener((compoundButton, enabled, apply) -> {
80+
SessionStore.get().setAutoplayEnabled(enabled);
81+
});
82+
7683
TextView permissionsTitleText = findViewById(R.id.permissionsTitle);
7784
permissionsTitleText.setText(getContext().getString(R.string.security_options_permissions_title, getContext().getString(R.string.app_name)));
7885

app/src/main/res/layout/options_privacy.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@
5858
android:layout_height="wrap_content"
5959
app:description="@string/security_options_tracking_protection" />
6060

61+
<org.mozilla.vrbrowser.ui.views.settings.SwitchSetting
62+
android:id="@+id/autoplaySwitch"
63+
android:layout_width="match_parent"
64+
android:layout_height="wrap_content"
65+
app:description="@string/security_options_autoplay" />
66+
6167
<TextView
6268
android:id="@+id/permissionsTitle"
6369
style="@style/settingsDescription"

app/src/main/res/values/non_L10n.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<string name="settings_key_console_logs" translatable="false">settings_console_logs</string>
1212
<string name="settings_key_environment_override" translatable="false">settings_environment_override</string>
1313
<string name="settings_key_multiprocess" translatable="false">settings_environment_multiprocess</string>
14-
<string name="settings_key_servo">settings_environment_servo</string>
14+
<string name="settings_key_servo" translatable="false">settings_environment_servo</string>
1515
<string name="settings_key_tracking_protection" translatable="false">settings_tracking_protection</string>
1616
<string name="settings_key_user_agent_version" translatable="false">settings_user_agent_version</string>
1717
<string name="settings_key_input_mode" translatable="false">settings_touch_mode</string>

app/src/main/res/values/strings.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,10 @@
377377
and is used to enable or disable tracking protection. -->
378378
<string name="security_options_tracking_protection">Tracking Protection</string>
379379

380+
<!-- This string labels an On/Off switch in the Privacy and Security settings dialog
381+
and is used to enable or disable media autoplay. -->
382+
<string name="security_options_autoplay">Autoplay Media</string>
383+
380384
<!-- This string is a label above the group of buttons that indicates that the buttons below
381385
relate to Android system permissions granted to the app.
382386
'%1$s' will be replaced at runtime with the app's name. -->

0 commit comments

Comments
 (0)