[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [Git][tpo/applications/fenix][tor-browser-82.0.0b4-10.0-1] 3 commits: fixup! Bug 40026: Integrate Security Level settings



Title: GitLab

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

Commits:

5 changed files:

Changes:

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

  • app/src/main/java/org/mozilla/fenix/home/sessioncontrol/viewholders/onboarding/TorOnboardingSecurityLevelViewHolder.kt
    ... ... @@ -69,9 +69,20 @@ class TorOnboardingSecurityLevelViewHolder(
    69 69
             safestSecurityLevel.onClickListener {
    
    70 70
                 updateSecurityLevel(SecurityLevel.SAFEST)
    
    71 71
             }
    
    72
    +
    
    73
    +        updateSecurityLevel(securityLevel)
    
    72 74
         }
    
    73 75
     
    
    74 76
         private fun updateSecurityLevel(newLevel: SecurityLevel) {
    
    77
    +        val resources = itemView.context.resources
    
    78
    +        val securityLevel = when (newLevel) {
    
    79
    +            SecurityLevel.STANDARD -> resources.getString(R.string.tor_security_level_standard_option)
    
    80
    +            SecurityLevel.SAFER -> resources.getString(R.string.tor_security_level_safer_option)
    
    81
    +            SecurityLevel.SAFEST -> resources.getString(R.string.tor_security_level_safest_option)
    
    82
    +        }
    
    83
    +        itemView.current_level.text = resources.getString(
    
    84
    +            R.string.tor_onboarding_chosen_security_level_label, securityLevel
    
    85
    +        )
    
    75 86
             itemView.context.components.let {
    
    76 87
                 it.core.engine.settings.torSecurityLevel = newLevel.intRepresentation
    
    77 88
             }
    

  • app/src/main/java/org/mozilla/fenix/utils/Settings.kt
    ... ... @@ -40,6 +40,7 @@ import org.mozilla.fenix.settings.deletebrowsingdata.DeleteBrowsingDataOnQuitTyp
    40 40
     import org.mozilla.fenix.settings.logins.SavedLoginsSortingStrategyMenu
    
    41 41
     import org.mozilla.fenix.settings.logins.SortingStrategy
    
    42 42
     import org.mozilla.fenix.settings.registerOnSharedPreferenceChangeListener
    
    43
    +import org.mozilla.fenix.tor.SecurityLevel
    
    43 44
     import java.security.InvalidParameterException
    
    44 45
     
    
    45 46
     private const val AUTOPLAY_USER_SETTING = "AUTOPLAY_USER_SETTING"
    
    ... ... @@ -176,6 +177,33 @@ class Settings(private val appContext: Context) : PreferencesHolder {
    176 177
             true
    
    177 178
         )
    
    178 179
     
    
    180
    +    var standardSecurityLevel by booleanPreference(
    
    181
    +        appContext.getPreferenceKey(SecurityLevel.STANDARD.preferenceKey),
    
    182
    +        default = true
    
    183
    +    )
    
    184
    +
    
    185
    +    var saferSecurityLevel by booleanPreference(
    
    186
    +        appContext.getPreferenceKey(SecurityLevel.SAFER.preferenceKey),
    
    187
    +        default = false
    
    188
    +    )
    
    189
    +
    
    190
    +    var safestSecurityLevel by booleanPreference(
    
    191
    +        appContext.getPreferenceKey(SecurityLevel.SAFEST.preferenceKey),
    
    192
    +        default = false
    
    193
    +    )
    
    194
    +
    
    195
    +    // torSecurityLevel is defined as the first |true| preference,
    
    196
    +    // beginning at the safest level.
    
    197
    +    // If multiple preferences are true, then that is a bug and the
    
    198
    +    // highest |true| security level is chosen.
    
    199
    +    // Standard is the default level.
    
    200
    +    fun torSecurityLevel(): SecurityLevel = when {
    
    201
    +        safestSecurityLevel -> SecurityLevel.SAFEST
    
    202
    +        saferSecurityLevel -> SecurityLevel.SAFER
    
    203
    +        standardSecurityLevel -> SecurityLevel.STANDARD
    
    204
    +        else -> SecurityLevel.STANDARD
    
    205
    +    }
    
    206
    +
    
    179 207
         // If any of the prefs have been modified, quit displaying the fenix moved tip
    
    180 208
         fun shouldDisplayFenixMovingTip(): Boolean =
    
    181 209
             preferences.getBoolean(
    

  • app/src/main/res/layout/tor_onboarding_security_level.xml
    ... ... @@ -32,9 +32,18 @@
    32 32
             android:textAppearance="@style/Body14TextStyle"
    
    33 33
             app:layout_constraintEnd_toEndOf="parent"
    
    34 34
             app:layout_constraintStart_toStartOf="parent"
    
    35
    -        app:layout_constraintTop_toBottomOf="@id/header_text"
    
    35
    +        app:layout_constraintTop_toBottomOf="@id/current_level"
    
    36 36
             tools:text="@string/tor_onboarding_security_level_description" />
    
    37 37
     
    
    38
    +    <TextView
    
    39
    +        android:id="@+id/current_level"
    
    40
    +        android:layout_width="match_parent"
    
    41
    +        android:layout_height="wrap_content"
    
    42
    +        android:layout_marginTop="12dp"
    
    43
    +        app:layout_constraintEnd_toEndOf="parent"
    
    44
    +        app:layout_constraintStart_toStartOf="parent"
    
    45
    +        app:layout_constraintTop_toBottomOf="@id/header_text"
    
    46
    +        tools:text="@string/tor_onboarding_chosen_security_level_label" />
    
    38 47
     
    
    39 48
         <org.mozilla.fenix.onboarding.OnboardingRadioButton
    
    40 49
             android:id="@+id/security_level_standard_option"
    

  • app/src/main/res/values/torbrowser_strings.xml
    ... ... @@ -20,6 +20,7 @@
    20 20
     
    
    21 21
         <string name="tor_onboarding_security_level">Set your Security Level</string>
    
    22 22
         <string name="tor_onboarding_security_level_description">Disable certain web features that can be used to attack you, and harm your security, anonymity, and privacy.</string>
    
    23
    +    <string name="tor_onboarding_chosen_security_level_label">Current Security Level: %s</string>
    
    23 24
         <string name="tor_onboarding_security_settings_button">Open Security Settings</string>
    
    24 25
         <string name="tor_onboarding_donate_header">Donate and keep Tor safe</string>
    
    25 26
         <string name="tor_onboarding_donate_description">Tor is free to use because of donations from people like you.</string>
    

  • _______________________________________________
    tor-commits mailing list
    tor-commits@xxxxxxxxxxxxxxxxxxxx
    https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits