For issue #7620: Add support for external download managers
parent
d796dac145
commit
c52e4fd9f5
|
@ -48,4 +48,9 @@ object FeatureFlags {
|
||||||
* Enables wait til first contentful paint
|
* Enables wait til first contentful paint
|
||||||
*/
|
*/
|
||||||
val waitUntilPaintToDraw = Config.channel.isNightlyOrDebug
|
val waitUntilPaintToDraw = Config.channel.isNightlyOrDebug
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables downloads with external download managers.
|
||||||
|
*/
|
||||||
|
val externalDownloadManager = Config.channel.isNightlyOrDebug
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.navigation.fragment.findNavController
|
import androidx.navigation.fragment.findNavController
|
||||||
|
import androidx.preference.PreferenceManager
|
||||||
import com.google.android.material.snackbar.Snackbar
|
import com.google.android.material.snackbar.Snackbar
|
||||||
import kotlinx.android.synthetic.main.fragment_browser.*
|
import kotlinx.android.synthetic.main.fragment_browser.*
|
||||||
import kotlinx.android.synthetic.main.fragment_browser.view.*
|
import kotlinx.android.synthetic.main.fragment_browser.view.*
|
||||||
|
@ -96,6 +97,7 @@ import org.mozilla.fenix.components.toolbar.ToolbarIntegration
|
||||||
import org.mozilla.fenix.components.toolbar.ToolbarPosition
|
import org.mozilla.fenix.components.toolbar.ToolbarPosition
|
||||||
import org.mozilla.fenix.downloads.DownloadService
|
import org.mozilla.fenix.downloads.DownloadService
|
||||||
import org.mozilla.fenix.downloads.DynamicDownloadDialog
|
import org.mozilla.fenix.downloads.DynamicDownloadDialog
|
||||||
|
import org.mozilla.fenix.ext.getPreferenceKey
|
||||||
import org.mozilla.fenix.ext.accessibilityManager
|
import org.mozilla.fenix.ext.accessibilityManager
|
||||||
import org.mozilla.fenix.ext.components
|
import org.mozilla.fenix.ext.components
|
||||||
import org.mozilla.fenix.ext.enterToImmersiveMode
|
import org.mozilla.fenix.ext.enterToImmersiveMode
|
||||||
|
@ -346,6 +348,11 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Session
|
||||||
view = view
|
view = view
|
||||||
)
|
)
|
||||||
|
|
||||||
|
val shouldForwardToThirdParties =
|
||||||
|
PreferenceManager.getDefaultSharedPreferences(context).getBoolean(
|
||||||
|
context.getPreferenceKey(R.string.pref_key_external_download_manager), false
|
||||||
|
)
|
||||||
|
|
||||||
val downloadFeature = DownloadsFeature(
|
val downloadFeature = DownloadsFeature(
|
||||||
context.applicationContext,
|
context.applicationContext,
|
||||||
store = store,
|
store = store,
|
||||||
|
@ -357,6 +364,7 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Session
|
||||||
store,
|
store,
|
||||||
DownloadService::class
|
DownloadService::class
|
||||||
),
|
),
|
||||||
|
shouldForwardToThirdParties = { shouldForwardToThirdParties },
|
||||||
promptsStyling = DownloadsFeature.PromptsStyling(
|
promptsStyling = DownloadsFeature.PromptsStyling(
|
||||||
gravity = Gravity.BOTTOM,
|
gravity = Gravity.BOTTOM,
|
||||||
shouldWidthMatchParent = true,
|
shouldWidthMatchParent = true,
|
||||||
|
|
|
@ -29,6 +29,7 @@ import mozilla.components.support.ktx.android.content.hasCamera
|
||||||
import org.mozilla.fenix.BrowserDirection
|
import org.mozilla.fenix.BrowserDirection
|
||||||
import org.mozilla.fenix.Config
|
import org.mozilla.fenix.Config
|
||||||
import org.mozilla.fenix.HomeActivity
|
import org.mozilla.fenix.HomeActivity
|
||||||
|
import org.mozilla.fenix.FeatureFlags
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
import org.mozilla.fenix.components.metrics.Event
|
import org.mozilla.fenix.components.metrics.Event
|
||||||
import org.mozilla.fenix.ext.application
|
import org.mozilla.fenix.ext.application
|
||||||
|
@ -301,7 +302,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
||||||
private fun setupPreferences() {
|
private fun setupPreferences() {
|
||||||
val leakKey = getPreferenceKey(R.string.pref_key_leakcanary)
|
val leakKey = getPreferenceKey(R.string.pref_key_leakcanary)
|
||||||
val debuggingKey = getPreferenceKey(R.string.pref_key_remote_debugging)
|
val debuggingKey = getPreferenceKey(R.string.pref_key_remote_debugging)
|
||||||
|
val preferenceExternalDownloadManager = requirePreference<Preference>(R.string.pref_key_make_default_browser)
|
||||||
val preferenceLeakCanary = findPreference<Preference>(leakKey)
|
val preferenceLeakCanary = findPreference<Preference>(leakKey)
|
||||||
val preferenceRemoteDebugging = findPreference<Preference>(debuggingKey)
|
val preferenceRemoteDebugging = findPreference<Preference>(debuggingKey)
|
||||||
val preferenceMakeDefaultBrowser = requirePreference<Preference>(R.string.pref_key_make_default_browser)
|
val preferenceMakeDefaultBrowser = requirePreference<Preference>(R.string.pref_key_make_default_browser)
|
||||||
|
@ -314,6 +315,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
preferenceExternalDownloadManager.isVisible = FeatureFlags.externalDownloadManager
|
||||||
preferenceRemoteDebugging?.setOnPreferenceChangeListener<Boolean> { preference, newValue ->
|
preferenceRemoteDebugging?.setOnPreferenceChangeListener<Boolean> { preference, newValue ->
|
||||||
preference.context.settings().preferences.edit()
|
preference.context.settings().preferences.edit()
|
||||||
.putBoolean(preference.key, newValue).apply()
|
.putBoolean(preference.key, newValue).apply()
|
||||||
|
|
|
@ -149,6 +149,7 @@
|
||||||
<!-- Privacy Settings -->
|
<!-- Privacy Settings -->
|
||||||
<string name="pref_key_open_links_in_a_private_tab" translatable="false">pref_key_open_links_in_a_private_tab</string>
|
<string name="pref_key_open_links_in_a_private_tab" translatable="false">pref_key_open_links_in_a_private_tab</string>
|
||||||
<string name="pref_key_open_links_in_external_app" translatable="false">pref_key_open_links_in_external_app</string>
|
<string name="pref_key_open_links_in_external_app" translatable="false">pref_key_open_links_in_external_app</string>
|
||||||
|
<string name="pref_key_external_download_manager" translatable="false">pref_key_external_download_manager</string>
|
||||||
<string name="pref_key_allow_screenshots_in_private_mode" translatable="false">pref_key_allow_screenshots_in_private_mode</string>
|
<string name="pref_key_allow_screenshots_in_private_mode" translatable="false">pref_key_allow_screenshots_in_private_mode</string>
|
||||||
|
|
||||||
<!-- Quick Action Sheet -->
|
<!-- Quick Action Sheet -->
|
||||||
|
|
|
@ -296,6 +296,8 @@
|
||||||
<string name="preferences_account_settings">Account settings</string>
|
<string name="preferences_account_settings">Account settings</string>
|
||||||
<!-- Preference for open links in third party apps -->
|
<!-- Preference for open links in third party apps -->
|
||||||
<string name="preferences_open_links_in_apps">Open links in apps</string>
|
<string name="preferences_open_links_in_apps">Open links in apps</string>
|
||||||
|
<!-- Preference for open download with an external download manager app -->
|
||||||
|
<string name="preferences_external_download_manager">External download manager</string>
|
||||||
<!-- Preference for add_ons -->
|
<!-- Preference for add_ons -->
|
||||||
<string name="preferences_addons">Add-ons</string>
|
<string name="preferences_addons">Add-ons</string>
|
||||||
|
|
||||||
|
|
|
@ -132,6 +132,12 @@
|
||||||
android:key="@string/pref_key_open_links_in_external_app"
|
android:key="@string/pref_key_open_links_in_external_app"
|
||||||
android:title="@string/preferences_open_links_in_apps" />
|
android:title="@string/preferences_open_links_in_apps" />
|
||||||
|
|
||||||
|
<androidx.preference.SwitchPreference
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:icon="@drawable/ic_download"
|
||||||
|
android:key="@string/pref_key_external_download_manager"
|
||||||
|
android:title="@string/preferences_external_download_manager" />
|
||||||
|
|
||||||
<androidx.preference.SwitchPreference
|
<androidx.preference.SwitchPreference
|
||||||
android:defaultValue="true"
|
android:defaultValue="true"
|
||||||
android:icon="@drawable/ic_info"
|
android:icon="@drawable/ic_info"
|
||||||
|
|
Loading…
Reference in New Issue