Matthew Finkel pushed to branch tor-browser-82.0.0b4-10.0-1 at The Tor Project / Applications / fenix

Commits:

7 changed files:

Changes:

  • app/src/main/java/org/mozilla/fenix/components/Core.kt
    ... ... @@ -93,7 +93,8 @@ class Core(private val context: Context, private val crashReporter: CrashReporti
    93 93
                 suspendMediaWhenInactive = false,
    
    94 94
                 forceUserScalableContent = context.settings().forceEnableZoom,
    
    95 95
                 loginAutofillEnabled = context.settings().shouldAutofillLogins,
    
    96
    -            torSecurityLevel = context.settings().torSecurityLevel().intRepresentation
    
    96
    +            torSecurityLevel = context.settings().torSecurityLevel().intRepresentation,
    
    97
    +            spoofEnglish = context.settings().spoofEnglish
    
    97 98
             )
    
    98 99
     
    
    99 100
             GeckoEngine(
    

  • app/src/main/java/org/mozilla/fenix/settings/advanced/DefaultLocaleSettingsController.kt
    ... ... @@ -7,6 +7,7 @@ package org.mozilla.fenix.settings.advanced
    7 7
     import android.app.Activity
    
    8 8
     import android.content.Context
    
    9 9
     import mozilla.components.support.locale.LocaleManager
    
    10
    +import org.mozilla.fenix.ext.components
    
    10 11
     import java.util.Locale
    
    11 12
     
    
    12 13
     interface LocaleSettingsController {
    
    ... ... @@ -55,5 +56,9 @@ class DefaultLocaleSettingsController(
    55 56
             config.setLocale(locale)
    
    56 57
             config.setLayoutDirection(locale)
    
    57 58
             resources.updateConfiguration(config, resources.displayMetrics)
    
    59
    +        // A slightly hacky way of triggering a `runtime.settings.locales` update,
    
    60
    +        // so that the locales are updated in GeckoView.
    
    61
    +        val spoofEnglish = context.components.core.engine.settings.spoofEnglish
    
    62
    +        context.components.core.engine.settings.spoofEnglish = spoofEnglish
    
    58 63
         }
    
    59 64
     }

  • app/src/main/java/org/mozilla/fenix/settings/advanced/LocaleSettingsFragment.kt
    ... ... @@ -20,6 +20,8 @@ import mozilla.components.support.ktx.android.view.hideKeyboard
    20 20
     import mozilla.components.support.locale.LocaleManager
    
    21 21
     import org.mozilla.fenix.R
    
    22 22
     import org.mozilla.fenix.components.StoreProvider
    
    23
    +import org.mozilla.fenix.ext.requireComponents
    
    24
    +import org.mozilla.fenix.ext.settings
    
    23 25
     import org.mozilla.fenix.ext.showToolbar
    
    24 26
     
    
    25 27
     class LocaleSettingsFragment : Fragment() {
    
    ... ... @@ -38,7 +40,9 @@ class LocaleSettingsFragment : Fragment() {
    38 40
             container: ViewGroup?,
    
    39 41
             savedInstanceState: Bundle?
    
    40 42
         ): View? {
    
    41
    -        val view = inflater.inflate(R.layout.fragment_locale_settings, container, false)
    
    43
    +        val view = inflater.inflate(R.layout.fragment_locale_settings, container, false).also {
    
    44
    +            bindEnableSwitch(it)
    
    45
    +        }
    
    42 46
     
    
    43 47
             store = getStore()
    
    44 48
             interactor = LocaleSettingsInteractor(
    
    ... ... @@ -51,6 +55,16 @@ class LocaleSettingsFragment : Fragment() {
    51 55
             return view
    
    52 56
         }
    
    53 57
     
    
    58
    +    @SuppressWarnings("LongMethod")
    
    59
    +    private fun bindEnableSwitch(view: View) {
    
    60
    +        val switch = view.enable_switch
    
    61
    +        switch.isChecked = requireComponents.core.engine.settings.spoofEnglish
    
    62
    +        switch.setOnCheckedChangeListener { _, isChecked ->
    
    63
    +            context?.settings()?.spoofEnglish = isChecked
    
    64
    +            requireComponents.core.engine.settings.spoofEnglish = isChecked
    
    65
    +        }
    
    66
    +    }
    
    67
    +
    
    54 68
         override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
    
    55 69
             inflater.inflate(R.menu.languages_list, menu)
    
    56 70
             val searchItem = menu.findItem(R.id.search)
    

  • app/src/main/java/org/mozilla/fenix/utils/Settings.kt
    ... ... @@ -204,6 +204,11 @@ class Settings(private val appContext: Context) : PreferencesHolder {
    204 204
             else -> SecurityLevel.STANDARD
    
    205 205
         }
    
    206 206
     
    
    207
    +    var spoofEnglish by booleanPreference(
    
    208
    +        appContext.getPreferenceKey(R.string.pref_key_spoof_english),
    
    209
    +        default = false
    
    210
    +    )
    
    211
    +
    
    207 212
         // If any of the prefs have been modified, quit displaying the fenix moved tip
    
    208 213
         fun shouldDisplayFenixMovingTip(): Boolean =
    
    209 214
             preferences.getBoolean(
    

  • app/src/main/res/layout/fragment_locale_settings.xml
    ... ... @@ -7,13 +7,30 @@
    7 7
         android:layout_width="match_parent"
    
    8 8
         android:layout_height="match_parent">
    
    9 9
     
    
    10
    +    <com.google.android.material.switchmaterial.SwitchMaterial
    
    11
    +        android:id="@+id/enable_switch"
    
    12
    +        android:layout_width="match_parent"
    
    13
    +        android:layout_height="wrap_content"
    
    14
    +        android:layout_gravity="center_vertical|end"
    
    15
    +        android:background="?android:attr/selectableItemBackground"
    
    16
    +        android:checked="true"
    
    17
    +        android:clickable="true"
    
    18
    +        android:focusable="true"
    
    19
    +        android:layout_marginStart="54dp"
    
    20
    +        android:padding="16dp"
    
    21
    +        android:text="@string/tor_spoof_english"
    
    22
    +        android:textColor="?primaryText"
    
    23
    +        android:textSize="16sp"
    
    24
    +        app:layout_constraintEnd_toEndOf="parent"
    
    25
    +        app:layout_constraintStart_toStartOf="parent"
    
    26
    +        app:layout_constraintTop_toTopOf="parent"  />
    
    10 27
         <FrameLayout
    
    11 28
             android:id="@+id/locale_container"
    
    12 29
             android:layout_width="match_parent"
    
    13
    -        android:layout_height="match_parent"
    
    30
    +        android:layout_height="0dp"
    
    14 31
             app:layout_constraintBottom_toBottomOf="parent"
    
    15 32
             app:layout_constraintEnd_toEndOf="parent"
    
    16 33
             app:layout_constraintStart_toStartOf="parent"
    
    17
    -        app:layout_constraintTop_toTopOf="parent" />
    
    34
    +        app:layout_constraintTop_toBottomOf="@id/enable_switch" />
    
    18 35
     
    
    19
    -</androidx.constraintlayout.widget.ConstraintLayout>
    \ No newline at end of file
    36
    +</androidx.constraintlayout.widget.ConstraintLayout>

  • app/src/main/res/values/preference_keys.xml
    ... ... @@ -253,4 +253,6 @@
    253 253
         <string name="pref_key_tor_network_settings_tor_ready">pref_key_tor_network_settings_tor_ready</string>
    
    254 254
         <string name="pref_key_tor_network_settings_state">pref_key_tor_network_settings_state</string>
    
    255 255
         <string name="pref_key_tor_network_settings_bridges_enabled">pref_key_tor_network_settings_bridges_enabled</string>
    
    256
    +
    
    257
    +    <string name="pref_key_spoof_english" translatable="false">pref_key_spoof_english</string>
    
    256 258
     </resources>

  • app/src/main/res/values/torbrowser_strings.xml
    ... ... @@ -70,4 +70,6 @@
    70 70
         <string name="tor_security_level_safest_option">Safest</string>
    
    71 71
         <string name="tor_security_level_safest_description">Only allow website features required for static sites and basic services. These changes affect images, media, and scripts.</string>
    
    72 72
     
    
    73
    +    <!-- Spoof locale to English -->
    
    74
    +    <string name="tor_spoof_english">Request English versions of web pages for enhanced privacy</string>
    
    73 75
     </resources>