Browse Source

For #8354 Fix opening custom tabs and links directly in private mode

master
mcarare 2 years ago
committed by Jeff Boek
parent
commit
9d755a877a
  1. 1
      app/src/main/java/org/mozilla/fenix/IntentReceiverActivity.kt
  2. 13
      app/src/main/java/org/mozilla/fenix/settings/PrivateBrowsingFragment.kt

1
app/src/main/java/org/mozilla/fenix/IntentReceiverActivity.kt

@ -39,6 +39,7 @@ class IntentReceiverActivity : Activity() {
val modeDependentProcessors = if (settings.openLinksInAPrivateTab) {
components.analytics.metrics.track(Event.OpenedLink(Event.OpenedLink.Mode.PRIVATE))
intent.putExtra(HomeActivity.PRIVATE_BROWSING_MODE, true)
listOf(
components.intentProcessors.privateCustomTabIntentProcessor,
components.intentProcessors.privateIntentProcessor

13
app/src/main/java/org/mozilla/fenix/settings/PrivateBrowsingFragment.kt

@ -7,11 +7,13 @@ package org.mozilla.fenix.settings
import android.os.Bundle
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import androidx.preference.SwitchPreference
import org.mozilla.fenix.R
import org.mozilla.fenix.components.PrivateShortcutCreateManager
import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.ext.getPreferenceKey
import org.mozilla.fenix.ext.metrics
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.ext.showToolbar
/**
@ -25,7 +27,10 @@ class PrivateBrowsingFragment : PreferenceFragmentCompat() {
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
setPreferencesFromResource(R.xml.private_browsing_preferences, rootKey)
updatePreferences()
}
private fun updatePreferences() {
findPreference<Preference>(getPreferenceKey(R.string.pref_key_add_private_browsing_shortcut))?.apply {
setOnPreferenceClickListener {
requireContext().metrics.track(Event.PrivateBrowsingCreateShortcut)
@ -33,5 +38,13 @@ class PrivateBrowsingFragment : PreferenceFragmentCompat() {
true
}
}
findPreference<SwitchPreference>(getPreferenceKey(R.string.pref_key_open_links_in_a_private_tab))?.apply {
setOnPreferenceClickListener {
isChecked = requireContext().settings().openLinksInAPrivateTab
onPreferenceChangeListener = SharedPreferenceUpdater()
true
}
}
}
}

Loading…
Cancel
Save