From 212d63ec3921b88a7eaa63ec80e4c63bcc3d2ad9 Mon Sep 17 00:00:00 2001 From: Jeff Boek Date: Fri, 18 Oct 2019 16:08:06 -0700 Subject: [PATCH] [fenix] For https://github.com/mozilla-mobile/fenix/issues/2477 - Adds accessibility setting to force enable zoom --- .../java/org/mozilla/fenix/FeatureFlags.kt | 2 ++ .../fenix/settings/AccessibilityFragment.kt | 18 ++++++++++++++++++ .../java/org/mozilla/fenix/utils/Settings.kt | 5 +++++ app/src/main/res/values/preference_keys.xml | 1 + app/src/main/res/values/static_strings.xml | 6 ++++++ .../main/res/xml/accessibility_preferences.xml | 8 ++++++++ 6 files changed, 40 insertions(+) diff --git a/app/src/main/java/org/mozilla/fenix/FeatureFlags.kt b/app/src/main/java/org/mozilla/fenix/FeatureFlags.kt index f0c80a32cf..c53ee89a21 100644 --- a/app/src/main/java/org/mozilla/fenix/FeatureFlags.kt +++ b/app/src/main/java/org/mozilla/fenix/FeatureFlags.kt @@ -54,4 +54,6 @@ object FeatureFlags { * Allows Progressive Web Apps to be installed to the device home screen. */ val progressiveWebApps = nightly or debug + + val forceZoomPreference = nightly or debug } diff --git a/app/src/main/java/org/mozilla/fenix/settings/AccessibilityFragment.kt b/app/src/main/java/org/mozilla/fenix/settings/AccessibilityFragment.kt index a77630af32..dca6b3ed98 100644 --- a/app/src/main/java/org/mozilla/fenix/settings/AccessibilityFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/settings/AccessibilityFragment.kt @@ -8,6 +8,7 @@ import android.os.Bundle import androidx.appcompat.app.AppCompatActivity import androidx.preference.PreferenceFragmentCompat import androidx.preference.SwitchPreference +import org.mozilla.fenix.FeatureFlags import org.mozilla.fenix.R import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.getPreferenceKey @@ -25,6 +26,23 @@ class AccessibilityFragment : PreferenceFragmentCompat() { (activity as AppCompatActivity).title = getString(R.string.preferences_accessibility) (activity as AppCompatActivity).supportActionBar?.show() + val forceZoomPreference = findPreference( + getPreferenceKey(R.string.pref_key_accessibility_force_enable_zoom) + ) + forceZoomPreference?.isVisible = FeatureFlags.forceZoomPreference + + if (FeatureFlags.forceZoomPreference) { + forceZoomPreference?.setOnPreferenceChangeListener { preference, shouldForce -> + val settings = preference.context.settings() + val components = preference.context.components + + settings.forceEnableZoom = shouldForce + components.core.engine.settings.forceUserScalableContent = shouldForce + + true + } + } + val textSizePreference = findPreference( getPreferenceKey(R.string.pref_key_accessibility_font_scale) ) diff --git a/app/src/main/java/org/mozilla/fenix/utils/Settings.kt b/app/src/main/java/org/mozilla/fenix/utils/Settings.kt index 50b5515b8b..254691817b 100644 --- a/app/src/main/java/org/mozilla/fenix/utils/Settings.kt +++ b/app/src/main/java/org/mozilla/fenix/utils/Settings.kt @@ -77,6 +77,11 @@ class Settings private constructor( override val preferences: SharedPreferences = appContext.getSharedPreferences(FENIX_PREFERENCES, MODE_PRIVATE) + var forceEnableZoom by booleanPreference( + appContext.getPreferenceKey(R.string.pref_key_accessibility_force_enable_zoom), + default = false + ) + var adjustCampaignId by stringPreference( appContext.getPreferenceKey(R.string.pref_key_adjust_campaign), default = "" diff --git a/app/src/main/res/values/preference_keys.xml b/app/src/main/res/values/preference_keys.xml index 19e2d959da..58dcc8adce 100644 --- a/app/src/main/res/values/preference_keys.xml +++ b/app/src/main/res/values/preference_keys.xml @@ -12,6 +12,7 @@ pref_key_accessibility pref_key_accessibility_auto_size pref_key_accessibility_font_scale + pref_key_accessibility_force_enable_zoom pref_key_language pref_key_data_choices pref_key_privacy_link diff --git a/app/src/main/res/values/static_strings.xml b/app/src/main/res/values/static_strings.xml index c94b703e86..2ac1cc510a 100644 --- a/app/src/main/res/values/static_strings.xml +++ b/app/src/main/res/values/static_strings.xml @@ -24,4 +24,10 @@ + + + + Zoom on all websites + + Enable to allow pinch and zoom, even on websites that prevent this gesture. diff --git a/app/src/main/res/xml/accessibility_preferences.xml b/app/src/main/res/xml/accessibility_preferences.xml index 8ed45e20bd..e8405e986b 100644 --- a/app/src/main/res/xml/accessibility_preferences.xml +++ b/app/src/main/res/xml/accessibility_preferences.xml @@ -24,4 +24,12 @@ app:min="0" app:seekBarIncrement="1" app:showSeekBarValue="true" /> +