Loading app/src/main/java/org/mozilla/fenix/components/Core.kt +2 −1 Original line number Original line Diff line number Diff line Loading @@ -93,7 +93,8 @@ class Core(private val context: Context, private val crashReporter: CrashReporti suspendMediaWhenInactive = false, suspendMediaWhenInactive = false, forceUserScalableContent = context.settings().forceEnableZoom, forceUserScalableContent = context.settings().forceEnableZoom, loginAutofillEnabled = context.settings().shouldAutofillLogins, loginAutofillEnabled = context.settings().shouldAutofillLogins, torSecurityLevel = context.settings().torSecurityLevel().intRepresentation torSecurityLevel = context.settings().torSecurityLevel().intRepresentation, spoofEnglish = context.settings().spoofEnglish ) ) GeckoEngine( GeckoEngine( Loading app/src/main/java/org/mozilla/fenix/settings/advanced/DefaultLocaleSettingsController.kt +5 −0 Original line number Original line Diff line number Diff line Loading @@ -7,6 +7,7 @@ package org.mozilla.fenix.settings.advanced import android.app.Activity import android.app.Activity import android.content.Context import android.content.Context import mozilla.components.support.locale.LocaleManager import mozilla.components.support.locale.LocaleManager import org.mozilla.fenix.ext.components import java.util.Locale import java.util.Locale interface LocaleSettingsController { interface LocaleSettingsController { Loading Loading @@ -55,5 +56,9 @@ class DefaultLocaleSettingsController( config.setLocale(locale) config.setLocale(locale) config.setLayoutDirection(locale) config.setLayoutDirection(locale) resources.updateConfiguration(config, resources.displayMetrics) resources.updateConfiguration(config, resources.displayMetrics) // A slightly hacky way of triggering a `runtime.settings.locales` update, // so that the locales are updated in GeckoView. val spoofEnglish = context.components.core.engine.settings.spoofEnglish context.components.core.engine.settings.spoofEnglish = spoofEnglish } } } } app/src/main/java/org/mozilla/fenix/settings/advanced/LocaleSettingsFragment.kt +15 −1 Original line number Original line Diff line number Diff line Loading @@ -20,6 +20,8 @@ import mozilla.components.support.ktx.android.view.hideKeyboard import mozilla.components.support.locale.LocaleManager import mozilla.components.support.locale.LocaleManager import org.mozilla.fenix.R import org.mozilla.fenix.R import org.mozilla.fenix.components.StoreProvider import org.mozilla.fenix.components.StoreProvider import org.mozilla.fenix.ext.requireComponents import org.mozilla.fenix.ext.settings import org.mozilla.fenix.ext.showToolbar import org.mozilla.fenix.ext.showToolbar class LocaleSettingsFragment : Fragment() { class LocaleSettingsFragment : Fragment() { Loading @@ -38,7 +40,9 @@ class LocaleSettingsFragment : Fragment() { container: ViewGroup?, container: ViewGroup?, savedInstanceState: Bundle? savedInstanceState: Bundle? ): View? { ): View? { val view = inflater.inflate(R.layout.fragment_locale_settings, container, false) val view = inflater.inflate(R.layout.fragment_locale_settings, container, false).also { bindEnableSwitch(it) } store = getStore() store = getStore() interactor = LocaleSettingsInteractor( interactor = LocaleSettingsInteractor( Loading @@ -51,6 +55,16 @@ class LocaleSettingsFragment : Fragment() { return view return view } } @SuppressWarnings("LongMethod") private fun bindEnableSwitch(view: View) { val switch = view.enable_switch switch.isChecked = requireComponents.core.engine.settings.spoofEnglish switch.setOnCheckedChangeListener { _, isChecked -> context?.settings()?.spoofEnglish = isChecked requireComponents.core.engine.settings.spoofEnglish = isChecked } } override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { inflater.inflate(R.menu.languages_list, menu) inflater.inflate(R.menu.languages_list, menu) val searchItem = menu.findItem(R.id.search) val searchItem = menu.findItem(R.id.search) Loading app/src/main/java/org/mozilla/fenix/utils/Settings.kt +5 −0 Original line number Original line Diff line number Diff line Loading @@ -204,6 +204,11 @@ class Settings(private val appContext: Context) : PreferencesHolder { else -> SecurityLevel.STANDARD else -> SecurityLevel.STANDARD } } var spoofEnglish by booleanPreference( appContext.getPreferenceKey(R.string.pref_key_spoof_english), default = false ) // If any of the prefs have been modified, quit displaying the fenix moved tip // If any of the prefs have been modified, quit displaying the fenix moved tip fun shouldDisplayFenixMovingTip(): Boolean = fun shouldDisplayFenixMovingTip(): Boolean = preferences.getBoolean( preferences.getBoolean( Loading app/src/main/res/layout/fragment_locale_settings.xml +20 −3 Original line number Original line Diff line number Diff line Loading @@ -7,13 +7,30 @@ android:layout_width="match_parent" android:layout_width="match_parent" android:layout_height="match_parent"> android:layout_height="match_parent"> <com.google.android.material.switchmaterial.SwitchMaterial android:id="@+id/enable_switch" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center_vertical|end" android:background="?android:attr/selectableItemBackground" android:checked="true" android:clickable="true" android:focusable="true" android:layout_marginStart="54dp" android:padding="16dp" android:text="@string/tor_spoof_english" android:textColor="?primaryText" android:textSize="16sp" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> <FrameLayout <FrameLayout android:id="@+id/locale_container" android:id="@+id/locale_container" android:layout_width="match_parent" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_height="0dp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toBottomOf="@id/enable_switch" /> </androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout> Loading
app/src/main/java/org/mozilla/fenix/components/Core.kt +2 −1 Original line number Original line Diff line number Diff line Loading @@ -93,7 +93,8 @@ class Core(private val context: Context, private val crashReporter: CrashReporti suspendMediaWhenInactive = false, suspendMediaWhenInactive = false, forceUserScalableContent = context.settings().forceEnableZoom, forceUserScalableContent = context.settings().forceEnableZoom, loginAutofillEnabled = context.settings().shouldAutofillLogins, loginAutofillEnabled = context.settings().shouldAutofillLogins, torSecurityLevel = context.settings().torSecurityLevel().intRepresentation torSecurityLevel = context.settings().torSecurityLevel().intRepresentation, spoofEnglish = context.settings().spoofEnglish ) ) GeckoEngine( GeckoEngine( Loading
app/src/main/java/org/mozilla/fenix/settings/advanced/DefaultLocaleSettingsController.kt +5 −0 Original line number Original line Diff line number Diff line Loading @@ -7,6 +7,7 @@ package org.mozilla.fenix.settings.advanced import android.app.Activity import android.app.Activity import android.content.Context import android.content.Context import mozilla.components.support.locale.LocaleManager import mozilla.components.support.locale.LocaleManager import org.mozilla.fenix.ext.components import java.util.Locale import java.util.Locale interface LocaleSettingsController { interface LocaleSettingsController { Loading Loading @@ -55,5 +56,9 @@ class DefaultLocaleSettingsController( config.setLocale(locale) config.setLocale(locale) config.setLayoutDirection(locale) config.setLayoutDirection(locale) resources.updateConfiguration(config, resources.displayMetrics) resources.updateConfiguration(config, resources.displayMetrics) // A slightly hacky way of triggering a `runtime.settings.locales` update, // so that the locales are updated in GeckoView. val spoofEnglish = context.components.core.engine.settings.spoofEnglish context.components.core.engine.settings.spoofEnglish = spoofEnglish } } } }
app/src/main/java/org/mozilla/fenix/settings/advanced/LocaleSettingsFragment.kt +15 −1 Original line number Original line Diff line number Diff line Loading @@ -20,6 +20,8 @@ import mozilla.components.support.ktx.android.view.hideKeyboard import mozilla.components.support.locale.LocaleManager import mozilla.components.support.locale.LocaleManager import org.mozilla.fenix.R import org.mozilla.fenix.R import org.mozilla.fenix.components.StoreProvider import org.mozilla.fenix.components.StoreProvider import org.mozilla.fenix.ext.requireComponents import org.mozilla.fenix.ext.settings import org.mozilla.fenix.ext.showToolbar import org.mozilla.fenix.ext.showToolbar class LocaleSettingsFragment : Fragment() { class LocaleSettingsFragment : Fragment() { Loading @@ -38,7 +40,9 @@ class LocaleSettingsFragment : Fragment() { container: ViewGroup?, container: ViewGroup?, savedInstanceState: Bundle? savedInstanceState: Bundle? ): View? { ): View? { val view = inflater.inflate(R.layout.fragment_locale_settings, container, false) val view = inflater.inflate(R.layout.fragment_locale_settings, container, false).also { bindEnableSwitch(it) } store = getStore() store = getStore() interactor = LocaleSettingsInteractor( interactor = LocaleSettingsInteractor( Loading @@ -51,6 +55,16 @@ class LocaleSettingsFragment : Fragment() { return view return view } } @SuppressWarnings("LongMethod") private fun bindEnableSwitch(view: View) { val switch = view.enable_switch switch.isChecked = requireComponents.core.engine.settings.spoofEnglish switch.setOnCheckedChangeListener { _, isChecked -> context?.settings()?.spoofEnglish = isChecked requireComponents.core.engine.settings.spoofEnglish = isChecked } } override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { inflater.inflate(R.menu.languages_list, menu) inflater.inflate(R.menu.languages_list, menu) val searchItem = menu.findItem(R.id.search) val searchItem = menu.findItem(R.id.search) Loading
app/src/main/java/org/mozilla/fenix/utils/Settings.kt +5 −0 Original line number Original line Diff line number Diff line Loading @@ -204,6 +204,11 @@ class Settings(private val appContext: Context) : PreferencesHolder { else -> SecurityLevel.STANDARD else -> SecurityLevel.STANDARD } } var spoofEnglish by booleanPreference( appContext.getPreferenceKey(R.string.pref_key_spoof_english), default = false ) // If any of the prefs have been modified, quit displaying the fenix moved tip // If any of the prefs have been modified, quit displaying the fenix moved tip fun shouldDisplayFenixMovingTip(): Boolean = fun shouldDisplayFenixMovingTip(): Boolean = preferences.getBoolean( preferences.getBoolean( Loading
app/src/main/res/layout/fragment_locale_settings.xml +20 −3 Original line number Original line Diff line number Diff line Loading @@ -7,13 +7,30 @@ android:layout_width="match_parent" android:layout_width="match_parent" android:layout_height="match_parent"> android:layout_height="match_parent"> <com.google.android.material.switchmaterial.SwitchMaterial android:id="@+id/enable_switch" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center_vertical|end" android:background="?android:attr/selectableItemBackground" android:checked="true" android:clickable="true" android:focusable="true" android:layout_marginStart="54dp" android:padding="16dp" android:text="@string/tor_spoof_english" android:textColor="?primaryText" android:textSize="16sp" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> <FrameLayout <FrameLayout android:id="@+id/locale_container" android:id="@+id/locale_container" android:layout_width="match_parent" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_height="0dp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toBottomOf="@id/enable_switch" /> </androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>