diff options
Diffstat (limited to 'toolkit/components/reader/AboutReader.jsm')
-rw-r--r-- | toolkit/components/reader/AboutReader.jsm | 89 |
1 files changed, 2 insertions, 87 deletions
diff --git a/toolkit/components/reader/AboutReader.jsm b/toolkit/components/reader/AboutReader.jsm index 9d9362a0c..3958af081 100644 --- a/toolkit/components/reader/AboutReader.jsm +++ b/toolkit/components/reader/AboutReader.jsm @@ -70,8 +70,6 @@ var AboutReader = function(win, articlePromise) { Services.obs.addObserver(this, "inner-window-destroyed", false); - doc.addEventListener("visibilitychange", this); - this._setupStyleDropdown(); this._setupButton("close-button", this._onReaderClose.bind(this), "aboutReader.toolbar.close"); @@ -238,14 +236,6 @@ AboutReader.prototype = { } break; - case "devicelight": - this._handleDeviceLight(aEvent.value); - break; - - case "visibilitychange": - this._handleVisibilityChange(); - break; - case "pagehide": // Close the Banners Font-dropdown, cleanup Android BackPressListener. this._closeDropdowns(); @@ -310,10 +300,6 @@ AboutReader.prototype = { const FONT_SIZE_MIN = 1; const FONT_SIZE_MAX = 9; - // Sample text shown in Android UI. - let sampleText = this._doc.querySelector(".font-size-sample"); - sampleText.textContent = gStrings.GetStringFromName("aboutReader.fontTypeSample"); - let currentSize = Services.prefs.getIntPref("reader.font_size"); currentSize = Math.max(FONT_SIZE_MIN, Math.min(FONT_SIZE_MAX, currentSize)); @@ -503,77 +489,8 @@ AboutReader.prototype = { }, true); }, - _handleDeviceLight(newLux) { - // Desired size of the this._luxValues array. - let luxValuesSize = 10; - // Add new lux value at the front of the array. - this._luxValues.unshift(newLux); - // Add new lux value to this._totalLux for averaging later. - this._totalLux += newLux; - - // Don't update when length of array is less than luxValuesSize except when it is 1. - if (this._luxValues.length < luxValuesSize) { - // Use the first lux value to set the color scheme until our array equals luxValuesSize. - if (this._luxValues.length == 1) { - this._updateColorScheme(newLux); - } - return; - } - // Holds the average of the lux values collected in this._luxValues. - let averageLuxValue = this._totalLux / luxValuesSize; - - this._updateColorScheme(averageLuxValue); - // Pop the oldest value off the array. - let oldLux = this._luxValues.pop(); - // Subtract oldLux since it has been discarded from the array. - this._totalLux -= oldLux; - }, - - _handleVisibilityChange() { - let colorScheme = Services.prefs.getCharPref("reader.color_scheme"); - if (colorScheme != "auto") { - return; - } - - // Turn off the ambient light sensor if the page is hidden - this._enableAmbientLighting(!this._doc.hidden); - }, - - // Setup or teardown the ambient light tracking system. - _enableAmbientLighting(enable) { - if (enable) { - this._win.addEventListener("devicelight", this); - this._luxValues = []; - this._totalLux = 0; - } else { - this._win.removeEventListener("devicelight", this); - delete this._luxValues; - delete this._totalLux; - } - }, - - _updateColorScheme(luxValue) { - // Upper bound value for "dark" color scheme beyond which it changes to "light". - let upperBoundDark = 50; - // Lower bound value for "light" color scheme beyond which it changes to "dark". - let lowerBoundLight = 10; - // Threshold for color scheme change. - let colorChangeThreshold = 20; - - // Ignore changes that are within a certain threshold of previous lux values. - if ((this._colorScheme === "dark" && luxValue < upperBoundDark) || - (this._colorScheme === "light" && luxValue > lowerBoundLight)) - return; - - if (luxValue < colorChangeThreshold) - this._setColorScheme("dark"); - else - this._setColorScheme("light"); - }, - _setColorScheme(newColorScheme) { - // "auto" is not a real color scheme - if (this._colorScheme === newColorScheme || newColorScheme === "auto") + if (this._colorScheme === newColorScheme) return; let bodyClasses = this._doc.body.classList; @@ -585,10 +502,8 @@ AboutReader.prototype = { bodyClasses.add(this._colorScheme); }, - // Pref values include "dark", "light", and "auto", which automatically switches - // between light and dark color schemes based on the ambient light level. + // Pref values include "dark", "light", and "sepia". _setColorSchemePref(colorSchemePref) { - this._enableAmbientLighting(colorSchemePref === "auto"); this._setColorScheme(colorSchemePref); AsyncPrefs.set("reader.color_scheme", colorSchemePref); |