Dan Ballard pushed to branch firefox-android-115.2.1-13.5-1 at The Tor Project / Applications / firefox-android

Commits:

7 changed files:

Changes:

  • fenix/app/src/main/java/org/mozilla/fenix/settings/SettingsFragment.kt
    ... ... @@ -61,6 +61,7 @@ import org.mozilla.fenix.ext.showToolbar
    61 61
     import org.mozilla.fenix.nimbus.FxNimbus
    
    62 62
     import org.mozilla.fenix.perf.ProfilerViewModel
    
    63 63
     import org.mozilla.fenix.settings.account.AccountUiView
    
    64
    +import org.mozilla.fenix.tor.QuickStartPreference
    
    64 65
     import org.mozilla.fenix.tor.TorBridgeTransportConfig
    
    65 66
     import org.mozilla.fenix.tor.TorEvents
    
    66 67
     import org.mozilla.fenix.utils.Settings
    
    ... ... @@ -729,6 +730,14 @@ class SettingsFragment : PreferenceFragmentCompat() {
    729 730
                 }
    
    730 731
             }
    
    731 732
     
    
    733
    +        requirePreference<QuickStartPreference>(R.string.pref_key_quick_start).apply {
    
    734
    +            setOnPreferenceClickListener {
    
    735
    +                context.components.torController.quickstart = !context.components.torController.quickstart
    
    736
    +                updateSwitch()
    
    737
    +                true
    
    738
    +            }
    
    739
    +        }
    
    740
    +
    
    732 741
             requirePreference<Preference>(R.string.pref_key_use_new_bootstrap).apply {
    
    733 742
                 setOnPreferenceClickListener {
    
    734 743
                     val directions =
    

  • fenix/app/src/main/java/org/mozilla/fenix/tor/QuickStartPreference.kt
    1
    +package org.mozilla.fenix.tor
    
    2
    +
    
    3
    +import android.content.Context
    
    4
    +import android.util.AttributeSet
    
    5
    +import androidx.preference.PreferenceViewHolder
    
    6
    +import androidx.preference.SwitchPreference
    
    7
    +import com.google.android.material.switchmaterial.SwitchMaterial
    
    8
    +import org.mozilla.fenix.R
    
    9
    +import org.mozilla.fenix.ext.components
    
    10
    +
    
    11
    +class QuickStartPreference @JvmOverloads constructor(
    
    12
    +    context: Context,
    
    13
    +    attrs: AttributeSet? = null,
    
    14
    +) : SwitchPreference(context, attrs) {
    
    15
    +
    
    16
    +    private var switchView: SwitchMaterial? = null
    
    17
    +
    
    18
    +    init {
    
    19
    +        widgetLayoutResource = R.layout.preference_quick_start
    
    20
    +    }
    
    21
    +
    
    22
    +    override fun onBindViewHolder(holder: PreferenceViewHolder) {
    
    23
    +        super.onBindViewHolder(holder)
    
    24
    +        switchView = holder.findViewById(R.id.switch_widget) as SwitchMaterial
    
    25
    +
    
    26
    +        updateSwitch()
    
    27
    +    }
    
    28
    +
    
    29
    +    fun updateSwitch() {
    
    30
    +        switchView?.isChecked = context.components.torController.quickstart
    
    31
    +    }
    
    32
    +}

  • fenix/app/src/main/java/org/mozilla/fenix/tor/TorConnectionAssistFragment.kt
    ... ... @@ -27,6 +27,7 @@ import kotlinx.coroutines.launch
    27 27
     import mozilla.components.support.base.feature.UserInteractionHandler
    
    28 28
     import org.mozilla.fenix.R
    
    29 29
     import org.mozilla.fenix.databinding.FragmentTorConnectionAssistBinding
    
    30
    +import org.mozilla.fenix.ext.components
    
    30 31
     import org.mozilla.fenix.ext.hideToolbar
    
    31 32
     
    
    32 33
     class TorConnectionAssistFragment : Fragment(), UserInteractionHandler {
    
    ... ... @@ -74,11 +75,6 @@ class TorConnectionAssistFragment : Fragment(), UserInteractionHandler {
    74 75
                 }
    
    75 76
             }
    
    76 77
     
    
    77
    -        viewModel.quickstartToggle().observe(
    
    78
    -            viewLifecycleOwner,
    
    79
    -        ) {
    
    80
    -            binding.quickstartSwitch.isChecked = it == true
    
    81
    -        }
    
    82 78
         }
    
    83 79
     
    
    84 80
         override fun onDestroyView() {
    
    ... ... @@ -140,7 +136,7 @@ class TorConnectionAssistFragment : Fragment(), UserInteractionHandler {
    140 136
                     titleDescription.text = getString(screen.titleDescriptionTextStringResource)
    
    141 137
                 }
    
    142 138
                 quickstartSwitch.visibility = if (screen.quickstartSwitchVisible) View.VISIBLE else View.GONE
    
    143
    -            quickstartSwitch.isChecked = viewModel.quickstartToggle().value == true
    
    139
    +            quickstartSwitch.isChecked = requireContext().components.torController.quickstart
    
    144 140
                 quickstartSwitch.setOnCheckedChangeListener { _, isChecked ->
    
    145 141
                     viewModel.handleQuickstartChecked(isChecked)
    
    146 142
                 }
    

  • fenix/app/src/main/java/org/mozilla/fenix/tor/TorConnectionAssistViewModel.kt
    ... ... @@ -31,12 +31,6 @@ class TorConnectionAssistViewModel(
    31 31
             return _progress
    
    32 32
         }
    
    33 33
     
    
    34
    -    private val _quickStartToggle = MutableLiveData<Boolean>() // don't initialize with quickstart off the bat
    
    35
    -    fun quickstartToggle(): LiveData<Boolean?> {
    
    36
    -        _quickStartToggle.value = _torController.quickstart // quickstart isn't ready until torSettings is ready
    
    37
    -        return _quickStartToggle
    
    38
    -    }
    
    39
    -
    
    40 34
         init {
    
    41 35
             Log.d(TAG, "initiating TorConnectionAssistViewModel")
    
    42 36
             _torController.registerTorListener(this)
    
    ... ... @@ -55,7 +49,6 @@ class TorConnectionAssistViewModel(
    55 49
     
    
    56 50
         fun handleQuickstartChecked(checked: Boolean) {
    
    57 51
             _torController.quickstart = checked
    
    58
    -        _quickStartToggle.value = checked
    
    59 52
         }
    
    60 53
     
    
    61 54
         fun handleButton1Pressed(
    

  • fenix/app/src/main/res/layout/preference_quick_start.xml
    1
    +<?xml version="1.0" encoding="utf-8"?>
    
    2
    +<!-- This Source Code Form is subject to the terms of the Mozilla Public
    
    3
    +   - License, v. 2.0. If a copy of the MPL was not distributed with this
    
    4
    +   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
    
    5
    +
    
    6
    +<com.google.android.material.switchmaterial.SwitchMaterial xmlns:android="http://schemas.android.com/apk/res/android"
    
    7
    +    android:id="@+id/switch_widget"
    
    8
    +    android:layout_width="wrap_content"
    
    9
    +    android:layout_height="match_parent"
    
    10
    +    android:clickable="false"
    
    11
    +    android:focusable="false"
    
    12
    +    android:gravity="center_vertical"
    
    13
    +    android:orientation="vertical" />

  • fenix/app/src/main/res/values/preference_keys.xml
    ... ... @@ -16,6 +16,7 @@
    16 16
         <string name="pref_key_accessibility_font_scale" translatable="false">pref_key_accessibility_font_scale</string>
    
    17 17
         <string name="pref_key_privacy" translatable="false">pref_key_privacy</string>
    
    18 18
         <string name="pref_key_connection" translatable="false">pref_key_connection</string>
    
    19
    +    <string name="pref_key_quick_start" translatable="false">pref_key_quick_start</string>
    
    19 20
         <string name="pref_key_accessibility_force_enable_zoom" translatable="false">pref_key_accessibility_force_enable_zoom</string>
    
    20 21
         <string name="pref_key_advanced" translatable="false">pref_key_advanced</string>
    
    21 22
         <string name="pref_key_language" translatable="false">pref_key_language</string>
    

  • fenix/app/src/main/res/xml/preferences.xml
    ... ... @@ -170,6 +170,12 @@
    170 170
                 android:title="@string/preferences_tor_network_settings_bridge_config"
    
    171 171
                 android:summary="@string/preferences_tor_network_settings_bridge_config_description" />
    
    172 172
     
    
    173
    +        <org.mozilla.fenix.tor.QuickStartPreference
    
    174
    +            android:key="@string/pref_key_quick_start"
    
    175
    +            android:summary="@string/connection_assist_always_connect_automatically_toggle_description"
    
    176
    +            android:title="@string/tor_bootstrap_quick_start_label"
    
    177
    +            app:iconSpaceReserved="false" />
    
    178
    +
    
    173 179
             <Preference
    
    174 180
                 android:key="@string/pref_key_use_new_bootstrap"
    
    175 181
                 app:iconSpaceReserved="false"