[tor-commits] [Git][tpo/applications/fenix][tor-browser-82.0.0b4-10.0-1] 3 commits: fixup! Bug 40026: Integrate Security Level settings
Matthew Finkel
gitlab at torproject.org
Fri Oct 16 01:26:41 UTC 2020
Matthew Finkel pushed to branch tor-browser-82.0.0b4-10.0-1 at The Tor Project / Applications / fenix
Commits:
268e56f4 by Matthew Finkel at 2020-10-14T20:04:47+00:00
fixup! Bug 40026: Integrate Security Level settings
Bug 40053: Provide feedback in onboarding Security Level card
- - - - -
be57d067 by Matthew Finkel at 2020-10-14T20:04:51+00:00
fixup! Bug 40026: Integrate Security Level settings
Bug 40082: Use Security Level preference at startup
- - - - -
e8d4affa by Matthew Finkel at 2020-10-16T01:26:23+00:00
Merge branch 'bug_40053_00' into tor-browser-82.0.0b4-10.0-1
- - - - -
5 changed files:
- app/src/main/java/org/mozilla/fenix/components/Core.kt
- app/src/main/java/org/mozilla/fenix/home/sessioncontrol/viewholders/onboarding/TorOnboardingSecurityLevelViewHolder.kt
- app/src/main/java/org/mozilla/fenix/utils/Settings.kt
- app/src/main/res/layout/tor_onboarding_security_level.xml
- app/src/main/res/values/torbrowser_strings.xml
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
fontInflationEnabled = context.settings().shouldUseAutoSize,
suspendMediaWhenInactive = false,
forceUserScalableContent = context.settings().forceEnableZoom,
- loginAutofillEnabled = context.settings().shouldAutofillLogins
+ loginAutofillEnabled = context.settings().shouldAutofillLogins,
+ torSecurityLevel = context.settings().torSecurityLevel().intRepresentation
)
GeckoEngine(
=====================================
app/src/main/java/org/mozilla/fenix/home/sessioncontrol/viewholders/onboarding/TorOnboardingSecurityLevelViewHolder.kt
=====================================
@@ -69,9 +69,20 @@ class TorOnboardingSecurityLevelViewHolder(
safestSecurityLevel.onClickListener {
updateSecurityLevel(SecurityLevel.SAFEST)
}
+
+ updateSecurityLevel(securityLevel)
}
private fun updateSecurityLevel(newLevel: SecurityLevel) {
+ val resources = itemView.context.resources
+ val securityLevel = when (newLevel) {
+ SecurityLevel.STANDARD -> resources.getString(R.string.tor_security_level_standard_option)
+ SecurityLevel.SAFER -> resources.getString(R.string.tor_security_level_safer_option)
+ SecurityLevel.SAFEST -> resources.getString(R.string.tor_security_level_safest_option)
+ }
+ itemView.current_level.text = resources.getString(
+ R.string.tor_onboarding_chosen_security_level_label, securityLevel
+ )
itemView.context.components.let {
it.core.engine.settings.torSecurityLevel = newLevel.intRepresentation
}
=====================================
app/src/main/java/org/mozilla/fenix/utils/Settings.kt
=====================================
@@ -40,6 +40,7 @@ import org.mozilla.fenix.settings.deletebrowsingdata.DeleteBrowsingDataOnQuitTyp
import org.mozilla.fenix.settings.logins.SavedLoginsSortingStrategyMenu
import org.mozilla.fenix.settings.logins.SortingStrategy
import org.mozilla.fenix.settings.registerOnSharedPreferenceChangeListener
+import org.mozilla.fenix.tor.SecurityLevel
import java.security.InvalidParameterException
private const val AUTOPLAY_USER_SETTING = "AUTOPLAY_USER_SETTING"
@@ -176,6 +177,33 @@ class Settings(private val appContext: Context) : PreferencesHolder {
true
)
+ var standardSecurityLevel by booleanPreference(
+ appContext.getPreferenceKey(SecurityLevel.STANDARD.preferenceKey),
+ default = true
+ )
+
+ var saferSecurityLevel by booleanPreference(
+ appContext.getPreferenceKey(SecurityLevel.SAFER.preferenceKey),
+ default = false
+ )
+
+ var safestSecurityLevel by booleanPreference(
+ appContext.getPreferenceKey(SecurityLevel.SAFEST.preferenceKey),
+ default = false
+ )
+
+ // torSecurityLevel is defined as the first |true| preference,
+ // beginning at the safest level.
+ // If multiple preferences are true, then that is a bug and the
+ // highest |true| security level is chosen.
+ // Standard is the default level.
+ fun torSecurityLevel(): SecurityLevel = when {
+ safestSecurityLevel -> SecurityLevel.SAFEST
+ saferSecurityLevel -> SecurityLevel.SAFER
+ standardSecurityLevel -> SecurityLevel.STANDARD
+ else -> SecurityLevel.STANDARD
+ }
+
// If any of the prefs have been modified, quit displaying the fenix moved tip
fun shouldDisplayFenixMovingTip(): Boolean =
preferences.getBoolean(
=====================================
app/src/main/res/layout/tor_onboarding_security_level.xml
=====================================
@@ -32,9 +32,18 @@
android:textAppearance="@style/Body14TextStyle"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toBottomOf="@id/header_text"
+ app:layout_constraintTop_toBottomOf="@id/current_level"
tools:text="@string/tor_onboarding_security_level_description" />
+ <TextView
+ android:id="@+id/current_level"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="12dp"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@id/header_text"
+ tools:text="@string/tor_onboarding_chosen_security_level_label" />
<org.mozilla.fenix.onboarding.OnboardingRadioButton
android:id="@+id/security_level_standard_option"
=====================================
app/src/main/res/values/torbrowser_strings.xml
=====================================
@@ -20,6 +20,7 @@
<string name="tor_onboarding_security_level">Set your Security Level</string>
<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>
+ <string name="tor_onboarding_chosen_security_level_label">Current Security Level: %s</string>
<string name="tor_onboarding_security_settings_button">Open Security Settings</string>
<string name="tor_onboarding_donate_header">Donate and keep Tor safe</string>
<string name="tor_onboarding_donate_description">Tor is free to use because of donations from people like you.</string>
View it on GitLab: https://gitlab.torproject.org/tpo/applications/fenix/-/compare/15968de01cbf20ae735d5b65148ebc1eae590226...e8d4affafa17c9c0004eca757839c62c92484a4d
--
View it on GitLab: https://gitlab.torproject.org/tpo/applications/fenix/-/compare/15968de01cbf20ae735d5b65148ebc1eae590226...e8d4affafa17c9c0004eca757839c62c92484a4d
You're receiving this email because of your account on gitlab.torproject.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.torproject.org/pipermail/tor-commits/attachments/20201016/fcf430f6/attachment-0001.htm>
More information about the tor-commits
mailing list