1
0
Fork 0

For #2477 - Adds accessibility setting to force enable zoom

master
Jeff Boek 2019-10-18 16:08:06 -07:00 committed by Emily Kager
parent 47dfcc119e
commit d1643b785e
6 changed files with 40 additions and 0 deletions

View File

@ -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
}

View File

@ -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<SwitchPreference>(
getPreferenceKey(R.string.pref_key_accessibility_force_enable_zoom)
)
forceZoomPreference?.isVisible = FeatureFlags.forceZoomPreference
if (FeatureFlags.forceZoomPreference) {
forceZoomPreference?.setOnPreferenceChangeListener<Boolean> { 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<TextPercentageSeekBarPreference>(
getPreferenceKey(R.string.pref_key_accessibility_font_scale)
)

View File

@ -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 = ""

View File

@ -12,6 +12,7 @@
<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_language" translatable="false">pref_key_language</string>
<string name="pref_key_data_choices" translatable="false">pref_key_data_choices</string>
<string name="pref_key_privacy_link" translatable="false">pref_key_privacy_link</string>

View File

@ -24,4 +24,10 @@
<!--suppress CheckTagEmptyBody This is a default value for places where we don't want a string set-->
<string name="empty_string" translatable="false"></string>
<!-- Title for Accessibility Force Enable Zoom Preference -->
<string name="preference_accessibility_force_enable_zoom" translatable="false">Zoom on all websites</string>
<!-- Summary for Accessibility Force Enable Zoom Preference -->
<string name="preference_accessibility_force_enable_zoom_summary" translatable="false">Enable to allow pinch and zoom, even on websites that prevent this gesture.</string>
</resources>

View File

@ -24,4 +24,12 @@
app:min="0"
app:seekBarIncrement="1"
app:showSeekBarValue="true" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/pref_key_accessibility_force_enable_zoom"
android:summary="@string/preference_accessibility_force_enable_zoom_summary"
android:title="@string/preference_accessibility_force_enable_zoom"
app:isPreferenceVisible="false"
app:allowDividerAbove="true"
app:iconSpaceReserved="false" />
</PreferenceScreen>