For #14923 - Removes auto size preference toggle

pull/216/head
ekager 4 years ago
parent db2cee4a12
commit 881e3d6ccd

@ -85,7 +85,7 @@ class SettingsBasicsTest {
verifyThemes()
}.goBack {
}.openAccessibilitySubMenu {
verifyAutomaticFontSizingMenuItems()
verifyMenuItems()
}.goBack {
// drill down to submenu
}
@ -181,7 +181,7 @@ class SettingsBasicsTest {
}
@Test
fun changeAccessibiltySettings() {
fun changeAccessibilitySettings() {
// Goes through the settings and changes the default text on a webpage, then verifies if the text has changed.
val fenixApp = activityIntentTestRule.activity.applicationContext as FenixApplication
val webpage = getLoremIpsumAsset(mockWebServer).url
@ -193,8 +193,7 @@ class SettingsBasicsTest {
}.openThreeDotMenu {
}.openSettings {
}.openAccessibilitySubMenu {
clickFontSizingSwitch()
verifyNewMenuItems()
verifyMenuItems()
changeTextSizeSlider(textSizePercentage)
verifyTextSizePercentage(textSizePercentage)
}.goBack {
@ -202,14 +201,6 @@ class SettingsBasicsTest {
}.openNavigationToolbar {
}.enterURLAndEnterToBrowser(webpage) {
checkTextSizeOnWebsite(textSizePercentage, fenixApp.components)
}.openTabDrawer {
}.openNewTab {
}.dismiss {
}.openThreeDotMenu {
}.openSettings {
}.openAccessibilitySubMenu {
clickFontSizingSwitch()
verifyNewMenuItemsAreGone()
}
}

@ -21,7 +21,6 @@ import android.widget.TextView
import androidx.test.espresso.UiController
import androidx.test.espresso.ViewAction
import androidx.test.espresso.ViewAssertion
import androidx.test.espresso.assertion.ViewAssertions.doesNotExist
import org.hamcrest.CoreMatchers.allOf
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.espresso.matcher.ViewMatchers.withId
@ -49,13 +48,7 @@ class SettingsSubMenuAccessibilityRobot {
const val TEXT_SIZE = 16f
}
fun verifyAutomaticFontSizingMenuItems() = assertAutomaticFontSizingMenuItems()
fun clickFontSizingSwitch() = toggleFontSizingSwitch()
fun verifyNewMenuItems() = assertNewMenuItems()
fun verifyNewMenuItemsAreGone() = assertNewMenuItemsAreGone()
fun verifyMenuItems() = assertMenuItems()
fun changeTextSizeSlider(seekBarPercentage: Int) = adjustTextSizeSlider(seekBarPercentage)
@ -76,22 +69,7 @@ class SettingsSubMenuAccessibilityRobot {
val device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
private fun assertAutomaticFontSizingMenuItems() {
onView(withText("Automatic font sizing"))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
val strFont = "Font size will match your Android settings. Disable to manage font size here."
onView(withText(strFont))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
}
private fun toggleFontSizingSwitch() {
// Toggle font size to off
onView(withText("Automatic font sizing"))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
.perform(click())
}
private fun assertNewMenuItems() {
private fun assertMenuItems() {
assertFontSize()
assertSliderBar()
}
@ -125,22 +103,6 @@ private fun assertTextSizePercentage(textSize: Int) {
.check(textSizePercentageEquals(textSize))
}
private fun assertNewMenuItemsAreGone() {
onView(withText("Font Size")).check(doesNotExist())
val strFont = "Make text on websites larger or smaller"
onView(withText(strFont))
.check(doesNotExist())
onView(withId(org.mozilla.fenix.R.id.sampleText))
.check(doesNotExist())
onView(withId(org.mozilla.fenix.R.id.seekbar_value))
.check(doesNotExist())
onView(withId(org.mozilla.fenix.R.id.seekbar))
.check(doesNotExist())
}
private fun goBackButton() =
onView(allOf(withContentDescription("Navigate up")))

@ -47,7 +47,7 @@ object GeckoProvider {
.build()
val settings = context.components.settings
if (!settings.shouldUseAutoSize) {
if (!settings.shouldUseAutoSize()) {
runtimeSettings.automaticFontSizeAdjustment = false
val fontSize = settings.fontSizeFactor
runtimeSettings.fontSizeFactor = fontSize

@ -47,7 +47,7 @@ object GeckoProvider {
.build()
val settings = context.components.settings
if (!settings.shouldUseAutoSize) {
if (!settings.shouldUseAutoSize()) {
runtimeSettings.automaticFontSizeAdjustment = false
val fontSize = settings.fontSizeFactor
runtimeSettings.fontSizeFactor = fontSize

@ -57,7 +57,7 @@ object GeckoProvider {
.build()
val settings = context.components.settings
if (!settings.shouldUseAutoSize) {
if (!settings.shouldUseAutoSize()) {
runtimeSettings.automaticFontSizeAdjustment = false
val fontSize = settings.fontSizeFactor
runtimeSettings.fontSizeFactor = fontSize

@ -95,8 +95,8 @@ class Core(
trackingProtectionPolicy = trackingProtectionPolicyFactory.createTrackingProtectionPolicy(),
historyTrackingDelegate = HistoryDelegate(lazyHistoryStorage),
preferredColorScheme = getPreferredColorScheme(),
automaticFontSizeAdjustment = context.settings().shouldUseAutoSize,
fontInflationEnabled = context.settings().shouldUseAutoSize,
automaticFontSizeAdjustment = context.settings().shouldUseAutoSize(),
fontInflationEnabled = context.settings().shouldUseAutoSize(),
suspendMediaWhenInactive = false,
forceUserScalableContent = context.settings().forceEnableZoom,
loginAutofillEnabled = context.settings().shouldAutofillLogins

@ -47,33 +47,16 @@ class AccessibilityFragment : PreferenceFragmentCompat() {
// Value is mapped from 0->30 in steps of 1 so let's convert to float in range 0.5->2.0
val newTextScale = ((newTextSize * STEP_SIZE) + MIN_SCALE_VALUE).toFloat() / PERCENT_TO_DECIMAL
// Save new text scale value. We assume auto sizing is off if this change listener was called.
settings.fontSizeFactor = newTextScale
components.core.engine.settings.fontSizeFactor = newTextScale
// Reload the current session to reflect the new text scale
components.useCases.sessionUseCases.reload()
true
}
textSizePreference.isVisible = !requireContext().settings().shouldUseAutoSize
val useAutoSizePreference =
requirePreference<SwitchPreference>(R.string.pref_key_accessibility_auto_size)
useAutoSizePreference.setOnPreferenceChangeListener<Boolean> { preference, useAutoSize ->
val settings = preference.context.settings()
val components = preference.context.components
// Save the new setting value
settings.shouldUseAutoSize = useAutoSize
// If scale is 100%, use the automatic font size adjustment
val useAutoSize = newTextScale == 1F
components.core.engine.settings.automaticFontSizeAdjustment = useAutoSize
components.core.engine.settings.fontInflationEnabled = useAutoSize
// If using manual sizing, update the engine settings with the local saved setting
// If using manual sizing, update the engine settings with the new scale
if (!useAutoSize) {
components.core.engine.settings.fontSizeFactor = settings.fontSizeFactor
settings.fontSizeFactor = newTextScale
components.core.engine.settings.fontSizeFactor = newTextScale
}
// Show the manual sizing controls if automatic sizing is turned off.
textSizePreference.isVisible = !useAutoSize
// Reload the current session to reflect the new text scale
components.useCases.sessionUseCases.reload()

@ -311,16 +311,13 @@ class Settings(private val appContext: Context) : PreferencesHolder {
val shouldShowSecurityPinWarning: Boolean
get() = loginsSecureWarningCount.underMaxCount()
fun shouldUseAutoSize() = fontSizeFactor == 1F
var shouldUseLightTheme by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_light_theme),
default = false
)
var shouldUseAutoSize by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_accessibility_auto_size),
default = true
)
var fontSizeFactor by floatPreference(
appContext.getPreferenceKey(R.string.pref_key_accessibility_font_scale),
default = 1f

@ -11,7 +11,6 @@
<string name="pref_key_site_permissions" translatable="false">pref_key_site_permissions</string>
<string name="pref_key_add_private_browsing_shortcut" translatable="false">pref_key_add_private_browsing_shortcut</string>
<string name="pref_key_accessibility" translatable="false">pref_key_accessibility</string>
<string name="pref_key_accessibility_auto_size" translatable="false">pref_key_accessibility_auto_size</string>
<string name="pref_key_accessibility_font_scale" translatable="false">pref_key_accessibility_font_scale</string>
<string name="pref_key_accessibility_force_enable_zoom" translatable="false">pref_key_accessibility_force_enable_zoom</string>
<string name="pref_key_advanced" translatable="false">pref_key_advanced</string>

@ -4,11 +4,6 @@
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<SwitchPreference
android:defaultValue="true"
android:key="@string/pref_key_accessibility_auto_size"
android:summary="@string/preference_accessibility_auto_size_summary"
android:title="@string/preference_accessibility_auto_size_2" />
<!-- Custom Preference that scales from 50-200% by steps of 5 represented by 0-30 in steps of 1-->
<org.mozilla.fenix.settings.TextPercentageSeekBarPreference
android:defaultValue="10"
@ -19,7 +14,6 @@
android:title="@string/preference_accessibility_font_size_title"
app:adjustable="true"
app:iconSpaceReserved="false"
app:isPreferenceVisible="false"
app:min="0"
app:seekBarIncrement="1"
app:showSeekBarValue="true" />

@ -43,9 +43,6 @@ class ExtensionsTest {
every {
fragment.getString(R.string.pref_key_accessibility_force_enable_zoom)
} returns "pref_key_accessibility_force_enable_zoom"
every {
fragment.getString(R.string.pref_key_accessibility_auto_size)
} returns "pref_key_accessibility_auto_size"
}
@Test
@ -78,11 +75,6 @@ class ExtensionsTest {
every {
fragment.findPreference<SwitchPreference>("pref_key_accessibility_auto_size")
} returns switchPreference
assertEquals(
switchPreference,
fragment.requirePreference<SwitchPreference>(R.string.pref_key_accessibility_auto_size)
)
}
@Test

@ -245,19 +245,6 @@ class SettingsTest {
assertEquals(settings.getTabTimeout(), Settings.ONE_MONTH_MS)
}
@Test
fun shouldUseAutoSize() {
// When just created
// Then
assertTrue(settings.shouldUseAutoSize)
// When
settings.shouldUseAutoSize = false
// Then
assertFalse(settings.shouldUseAutoSize)
}
@Test
fun shouldAutofill() {
// When just created

Loading…
Cancel
Save