Commit 67b34b8f authored by MozLando's avatar MozLando
Browse files

Merge #4762 #4769



4762: For #4761 - Adds setting to control `forceUserScalableEnabled` r=csadilek a=boek



4769: For #2923: Don't crash if Intl.RelativeTimeFormat not supported r=Amejia481 a=csadilek

`Intl.RelativeTimeFormat` is in Nightly and Beta, but not yet on Release (until Monday). Not a problem as Fenix is on Beta (and R-B on Nightly) anyway, but good to catch errors anyway. This would also help if an article specified an invalid lang for instance.
Co-authored-by: default avatarJeff Boek <jeff@jeffboek.com>
Co-authored-by: default avatarChristian Sadilek <christian.sadilek@gmail.com>
...@@ -333,6 +333,10 @@ class GeckoEngine( ...@@ -333,6 +333,10 @@ class GeckoEngine(
runtime.settings.fontSizeFactor = it runtime.settings.fontSizeFactor = it
} }
} }
override var forceUserScalableContent: Boolean
get() = runtime.settings.forceUserScalableEnabled
set(value) { runtime.settings.forceUserScalableEnabled = value }
}.apply { }.apply {
defaultSettings?.let { defaultSettings?.let {
this.javascriptEnabled = it.javascriptEnabled this.javascriptEnabled = it.javascriptEnabled
...@@ -349,6 +353,7 @@ class GeckoEngine( ...@@ -349,6 +353,7 @@ class GeckoEngine(
this.suspendMediaWhenInactive = it.suspendMediaWhenInactive this.suspendMediaWhenInactive = it.suspendMediaWhenInactive
this.fontInflationEnabled = it.fontInflationEnabled this.fontInflationEnabled = it.fontInflationEnabled
this.fontSizeFactor = it.fontSizeFactor this.fontSizeFactor = it.fontSizeFactor
this.forceUserScalableContent = it.forceUserScalableContent
} }
} }
} }
......
...@@ -88,6 +88,7 @@ class GeckoEngineTest { ...@@ -88,6 +88,7 @@ class GeckoEngineTest {
whenever(runtimeSettings.automaticFontSizeAdjustment).thenReturn(true) whenever(runtimeSettings.automaticFontSizeAdjustment).thenReturn(true)
whenever(runtimeSettings.fontInflationEnabled).thenReturn(true) whenever(runtimeSettings.fontInflationEnabled).thenReturn(true)
whenever(runtimeSettings.fontSizeFactor).thenReturn(1.0F) whenever(runtimeSettings.fontSizeFactor).thenReturn(1.0F)
whenever(runtimeSettings.forceUserScalableEnabled).thenReturn(false)
whenever(runtimeSettings.contentBlocking).thenReturn(contentBlockingSettings) whenever(runtimeSettings.contentBlocking).thenReturn(contentBlockingSettings)
whenever(runtimeSettings.preferredColorScheme).thenReturn(GeckoRuntimeSettings.COLOR_SCHEME_SYSTEM) whenever(runtimeSettings.preferredColorScheme).thenReturn(GeckoRuntimeSettings.COLOR_SCHEME_SYSTEM)
whenever(runtimeSettings.autoplayDefault).thenReturn(GeckoRuntimeSettings.AUTOPLAY_DEFAULT_ALLOWED) whenever(runtimeSettings.autoplayDefault).thenReturn(GeckoRuntimeSettings.AUTOPLAY_DEFAULT_ALLOWED)
...@@ -118,6 +119,10 @@ class GeckoEngineTest { ...@@ -118,6 +119,10 @@ class GeckoEngineTest {
engine.settings.fontSizeFactor = 2.0F engine.settings.fontSizeFactor = 2.0F
verify(runtimeSettings).fontSizeFactor = 2.0F verify(runtimeSettings).fontSizeFactor = 2.0F
assertFalse(engine.settings.forceUserScalableContent)
engine.settings.forceUserScalableContent = true
verify(runtimeSettings).forceUserScalableEnabled = true
assertFalse(engine.settings.remoteDebuggingEnabled) assertFalse(engine.settings.remoteDebuggingEnabled)
engine.settings.remoteDebuggingEnabled = true engine.settings.remoteDebuggingEnabled = true
verify(runtimeSettings).remoteDebuggingEnabled = true verify(runtimeSettings).remoteDebuggingEnabled = true
...@@ -328,7 +333,8 @@ class GeckoEngineTest { ...@@ -328,7 +333,8 @@ class GeckoEngineTest {
userAgentString = "test-ua", userAgentString = "test-ua",
preferredColorScheme = PreferredColorScheme.Light, preferredColorScheme = PreferredColorScheme.Light,
allowAutoplayMedia = false, allowAutoplayMedia = false,
suspendMediaWhenInactive = true suspendMediaWhenInactive = true,
forceUserScalableContent = false
), runtime) ), runtime)
verify(runtimeSettings).javaScriptEnabled = false verify(runtimeSettings).javaScriptEnabled = false
...@@ -338,6 +344,7 @@ class GeckoEngineTest { ...@@ -338,6 +344,7 @@ class GeckoEngineTest {
verify(runtimeSettings).fontSizeFactor = 2.0F verify(runtimeSettings).fontSizeFactor = 2.0F
verify(runtimeSettings).remoteDebuggingEnabled = true verify(runtimeSettings).remoteDebuggingEnabled = true
verify(runtimeSettings).autoplayDefault = GeckoRuntimeSettings.AUTOPLAY_DEFAULT_BLOCKED verify(runtimeSettings).autoplayDefault = GeckoRuntimeSettings.AUTOPLAY_DEFAULT_BLOCKED
verify(runtimeSettings).forceUserScalableEnabled = false
val trackingStrictCategories = TrackingProtectionPolicy.strict().trackingCategories.sumBy { it.id } val trackingStrictCategories = TrackingProtectionPolicy.strict().trackingCategories.sumBy { it.id }
val artificialCategory = val artificialCategory =
......
...@@ -169,6 +169,11 @@ abstract class Settings { ...@@ -169,6 +169,11 @@ abstract class Settings {
* Setting to control the font size factor. All font sizes will be multiplied by this factor. * Setting to control the font size factor. All font sizes will be multiplied by this factor.
*/ */
open var fontSizeFactor: Float? by UnsupportedSetting() open var fontSizeFactor: Float? by UnsupportedSetting()
/**
* Setting to force the ability to scale the content
*/
open var forceUserScalableContent: Boolean by UnsupportedSetting()
} }
/** /**
...@@ -202,7 +207,8 @@ data class DefaultSettings( ...@@ -202,7 +207,8 @@ data class DefaultSettings(
override var allowAutoplayMedia: Boolean = true, override var allowAutoplayMedia: Boolean = true,
override var suspendMediaWhenInactive: Boolean = false, override var suspendMediaWhenInactive: Boolean = false,
override var fontInflationEnabled: Boolean? = null, override var fontInflationEnabled: Boolean? = null,
override var fontSizeFactor: Float? = null override var fontSizeFactor: Float? = null,
override var forceUserScalableContent: Boolean = false
) : Settings() ) : Settings()
class UnsupportedSetting<T> { class UnsupportedSetting<T> {
......
...@@ -78,7 +78,9 @@ class SettingsTest { ...@@ -78,7 +78,9 @@ class SettingsTest {
{ settings.fontInflationEnabled }, { settings.fontInflationEnabled },
{ settings.fontInflationEnabled = false }, { settings.fontInflationEnabled = false },
{ settings.fontSizeFactor }, { settings.fontSizeFactor },
{ settings.fontSizeFactor = 1.0F } { settings.fontSizeFactor = 1.0F },
{ settings.forceUserScalableContent },
{ settings.forceUserScalableContent = true }
) )
} }
...@@ -118,6 +120,7 @@ class SettingsTest { ...@@ -118,6 +120,7 @@ class SettingsTest {
assertFalse(settings.suspendMediaWhenInactive) assertFalse(settings.suspendMediaWhenInactive)
assertNull(settings.fontInflationEnabled) assertNull(settings.fontInflationEnabled)
assertNull(settings.fontSizeFactor) assertNull(settings.fontSizeFactor)
assertFalse(settings.forceUserScalableContent)
val interceptor: RequestInterceptor = mock() val interceptor: RequestInterceptor = mock()
val historyTrackingDelegate: HistoryTrackingDelegate = mock() val historyTrackingDelegate: HistoryTrackingDelegate = mock()
...@@ -150,7 +153,8 @@ class SettingsTest { ...@@ -150,7 +153,8 @@ class SettingsTest {
allowAutoplayMedia = false, allowAutoplayMedia = false,
suspendMediaWhenInactive = true, suspendMediaWhenInactive = true,
fontInflationEnabled = false, fontInflationEnabled = false,
fontSizeFactor = 2.0F) fontSizeFactor = 2.0F,
forceUserScalableContent = true)
assertFalse(defaultSettings.domStorageEnabled) assertFalse(defaultSettings.domStorageEnabled)
assertFalse(defaultSettings.javascriptEnabled) assertFalse(defaultSettings.javascriptEnabled)
...@@ -180,5 +184,6 @@ class SettingsTest { ...@@ -180,5 +184,6 @@ class SettingsTest {
assertTrue(defaultSettings.suspendMediaWhenInactive) assertTrue(defaultSettings.suspendMediaWhenInactive)
assertFalse(defaultSettings.fontInflationEnabled!!) assertFalse(defaultSettings.fontInflationEnabled!!)
assertEquals(2.0F, defaultSettings.fontSizeFactor) assertEquals(2.0F, defaultSettings.fontSizeFactor)
assertTrue(defaultSettings.forceUserScalableContent)
} }
} }
\ No newline at end of file
...@@ -194,17 +194,21 @@ class ReaderView { ...@@ -194,17 +194,21 @@ class ReaderView {
// Construct a localized and "humanized" reading time in minutes. // Construct a localized and "humanized" reading time in minutes.
// If we have both a fast and slow reading time we'll show both e.g. // If we have both a fast and slow reading time we'll show both e.g.
// "2 - 4 minutes", otherwise we'll just show "4 minutes". // "2 - 4 minutes", otherwise we'll just show "4 minutes".
var parts = new Intl.RelativeTimeFormat(lang).formatToParts(readingTimeMinsSlow, 'minute'); try {
var parts = new Intl.RelativeTimeFormat(lang).formatToParts(readingTimeMinsSlow, 'minute');
if (parts.length == 3) { if (parts.length == 3) {
// No need to use part[0] which represents the literal "in". // No need to use part[0] which represents the literal "in".
var readingTime = parts[1].value; // reading time in minutes var readingTime = parts[1].value; // reading time in minutes
var minutesLiteral = parts[2].value; // localized singular or plural literal of 'minute' var minutesLiteral = parts[2].value; // localized singular or plural literal of 'minute'
var readingTimeString = `${readingTime} ${minutesLiteral}`; var readingTimeString = `${readingTime} ${minutesLiteral}`;
if (readingTimeMinsSlow != readingTimeMinsFast) { if (readingTimeMinsSlow != readingTimeMinsFast) {
readingTimeString = `${readingTimeMinsFast} - ${readingTimeString}`; readingTimeString = `${readingTimeMinsFast} - ${readingTimeString}`;
}
return readingTimeString;
} }
return readingTimeString; }
catch(error) {
console.error(`Failed to format reading time: ${error}`);
} }
return ""; return "";
......
...@@ -15,6 +15,12 @@ permalink: /changelog/ ...@@ -15,6 +15,12 @@ permalink: /changelog/
* **browser-menu** * **browser-menu**
* Adds the ability to create a BrowserMenuCategory, a menu item that defines a category for other menu items * Adds the ability to create a BrowserMenuCategory, a menu item that defines a category for other menu items
* **concept-engine**
* Adds the setting `forceUserScalableContent`.
* **engine-gecko-nightly**
* Implements the setting `forceUserScalableContent`.
# 17.0.0 # 17.0.0
* [Commits](https://github.com/mozilla-mobile/android-components/compare/v16.0.0...v17.0.0) * [Commits](https://github.com/mozilla-mobile/android-components/compare/v16.0.0...v17.0.0)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment