diff --git a/mobile/android/base/GeckoPreferences.java b/mobile/android/base/GeckoPreferences.java index 4bc028bf36e9..4a1b53192ea1 100644 --- a/mobile/android/base/GeckoPreferences.java +++ b/mobile/android/base/GeckoPreferences.java @@ -38,6 +38,7 @@ package org.mozilla.gecko; +import java.lang.CharSequence; import java.util.ArrayList; import android.os.Build; @@ -131,8 +132,12 @@ public class GeckoPreferences public boolean onPreferenceChange(Preference preference, Object newValue) { String prefName = preference.getKey(); setPreference(prefName, newValue); - if (preference instanceof ListPreference) - ((ListPreference)preference).setSummary((String)newValue); + if (preference instanceof ListPreference) { + // We need to find the entry for the new value + int newIndex = ((ListPreference)preference).findIndexOfValue((String) newValue); + CharSequence newEntry = ((ListPreference)preference).getEntries()[newIndex]; + ((ListPreference)preference).setSummary(newEntry); + } if (preference instanceof LinkPreference) finish(); return true; @@ -177,6 +182,9 @@ public class GeckoPreferences GeckoAppShell.getMainHandler().post(new Runnable() { public void run() { ((ListPreference)pref).setValue(value); + // Set the summary string to the current entry + CharSequence selectedEntry = ((ListPreference)pref).getEntry(); + ((ListPreference)pref).setSummary(selectedEntry); } }); } diff --git a/mobile/android/base/Makefile.in b/mobile/android/base/Makefile.in index 9dc61fa09b27..ef07c937be68 100644 --- a/mobile/android/base/Makefile.in +++ b/mobile/android/base/Makefile.in @@ -206,6 +206,7 @@ RES_LAYOUT_V11 = \ RES_VALUES = \ res/values/defaults.xml \ + res/values/arrays.xml \ res/values/colors.xml \ res/values/styles.xml \ res/values/themes.xml \ @@ -453,6 +454,7 @@ $(RES_VALUES): \ $(srcdir)/resources/values/colors.xml \ $(srcdir)/resources/values/styles.xml \ $(srcdir)/resources/values/themes.xml \ + $(srcdir)/resources/values/arrays.xml \ $(topsrcdir)/$(MOZ_BRANDING_DIRECTORY)/res/values/defaults.xml $(NSINSTALL) -D res/values $(NSINSTALL) $^ res/values diff --git a/mobile/android/base/locales/en-US/android_strings.dtd b/mobile/android/base/locales/en-US/android_strings.dtd index d0917a683c20..8176e2317488 100644 --- a/mobile/android/base/locales/en-US/android_strings.dtd +++ b/mobile/android/base/locales/en-US/android_strings.dtd @@ -62,6 +62,10 @@ + + + + diff --git a/mobile/android/base/resources/values/arrays.xml b/mobile/android/base/resources/values/arrays.xml new file mode 100644 index 000000000000..302bdf8f269a --- /dev/null +++ b/mobile/android/base/resources/values/arrays.xml @@ -0,0 +1,14 @@ + + + + + @string/pref_enable_flash_yes + @string/pref_enable_flash_tap_to_play + @string/pref_enable_flash_no + + + 1 + 2 + 0 + + diff --git a/mobile/android/base/resources/xml/preferences.xml b/mobile/android/base/resources/xml/preferences.xml index c7644b6ba12a..e999a55380a6 100644 --- a/mobile/android/base/resources/xml/preferences.xml +++ b/mobile/android/base/resources/xml/preferences.xml @@ -19,6 +19,12 @@ android:title="@string/pref_char_encoding" android:persistent="false" /> + + diff --git a/mobile/android/base/strings.xml.in b/mobile/android/base/strings.xml.in index b7907193dc75..c3cf03cc0e93 100644 --- a/mobile/android/base/strings.xml.in +++ b/mobile/android/base/strings.xml.in @@ -68,6 +68,10 @@ &pref_clear_history_confirm; &pref_clear_private_data; &pref_clear_private_data_confirm; + &pref_enable_flash; + &pref_enable_flash_yes; + &pref_enable_flash_tap_to_play; + &pref_enable_flash_no; &reload; &forward; diff --git a/mobile/android/chrome/content/browser.js b/mobile/android/chrome/content/browser.js index 2884e3502268..b9282f43fb13 100644 --- a/mobile/android/chrome/content/browser.js +++ b/mobile/android/chrome/content/browser.js @@ -435,6 +435,16 @@ var BrowserApp = { name: prefName }; + // The plugin pref is actually two separate prefs, so + // we need to handle it differently + if (prefName == "plugin.enable") { + // Use a string type for java's ListPreference + pref.type = "string"; + pref.value = PluginHelper.getPluginPreference(); + prefs.push(pref); + continue; + } + try { switch (Services.prefs.getPrefType(prefName)) { case Ci.nsIPrefBranch.PREF_BOOL: @@ -490,6 +500,13 @@ var BrowserApp = { setPreferences: function setPreferences(aPref) { let json = JSON.parse(aPref); + // The plugin pref is actually two separate prefs, so + // we need to handle it differently + if (json.name == "plugin.enable") { + PluginHelper.setPluginPreference(json.value); + return; + } + // when sending to java, we normalized special preferences that use // integers and strings to represent booleans. here, we convert them back // to their actual types so we can store them. @@ -2926,6 +2943,32 @@ var PluginHelper = { } }, + getPluginPreference: function getPluginPreference() { + let pluginDisable = Services.prefs.getBoolPref("plugin.disable"); + if (pluginDisable) + return "0"; + + let clickToPlay = Services.prefs.getBoolPref("plugins.click_to_play"); + return clickToPlay ? "2" : "1"; + }, + + setPluginPreference: function setPluginPreference(aValue) { + switch (aValue) { + case "0": // Enable Plugins = No + Services.prefs.setBoolPref("plugin.disable", true); + Services.prefs.clearUserPref("plugins.click_to_play"); + break; + case "1": // Enable Plugins = Yes + Services.prefs.clearUserPref("plugin.disable"); + Services.prefs.setBoolPref("plugins.click_to_play", false); + break; + case "2": // Enable Plugins = Tap to Play (default) + Services.prefs.clearUserPref("plugin.disable"); + Services.prefs.clearUserPref("plugins.click_to_play"); + break; + } + }, + // Mostly copied from /browser/base/content/browser.js addPluginClickCallback: function (plugin, callbackName /*callbackArgs...*/) { // XXX just doing (callback)(arg) was giving a same-origin error. bug?