1
0
Fork 0

For issue #7620: Add support for external download managers

master
Arturo Mejia 2020-08-07 01:03:07 -04:00
parent d796dac145
commit c52e4fd9f5
6 changed files with 25 additions and 1 deletions

View File

@ -48,4 +48,9 @@ object FeatureFlags {
* Enables wait til first contentful paint
*/
val waitUntilPaintToDraw = Config.channel.isNightlyOrDebug
/**
* Enables downloads with external download managers.
*/
val externalDownloadManager = Config.channel.isNightlyOrDebug
}

View File

@ -21,6 +21,7 @@ import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import androidx.lifecycle.lifecycleScope
import androidx.navigation.fragment.findNavController
import androidx.preference.PreferenceManager
import com.google.android.material.snackbar.Snackbar
import kotlinx.android.synthetic.main.fragment_browser.*
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.downloads.DownloadService
import org.mozilla.fenix.downloads.DynamicDownloadDialog
import org.mozilla.fenix.ext.getPreferenceKey
import org.mozilla.fenix.ext.accessibilityManager
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.enterToImmersiveMode
@ -346,6 +348,11 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Session
view = view
)
val shouldForwardToThirdParties =
PreferenceManager.getDefaultSharedPreferences(context).getBoolean(
context.getPreferenceKey(R.string.pref_key_external_download_manager), false
)
val downloadFeature = DownloadsFeature(
context.applicationContext,
store = store,
@ -357,6 +364,7 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Session
store,
DownloadService::class
),
shouldForwardToThirdParties = { shouldForwardToThirdParties },
promptsStyling = DownloadsFeature.PromptsStyling(
gravity = Gravity.BOTTOM,
shouldWidthMatchParent = true,

View File

@ -29,6 +29,7 @@ import mozilla.components.support.ktx.android.content.hasCamera
import org.mozilla.fenix.BrowserDirection
import org.mozilla.fenix.Config
import org.mozilla.fenix.HomeActivity
import org.mozilla.fenix.FeatureFlags
import org.mozilla.fenix.R
import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.ext.application
@ -301,7 +302,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
private fun setupPreferences() {
val leakKey = getPreferenceKey(R.string.pref_key_leakcanary)
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 preferenceRemoteDebugging = findPreference<Preference>(debuggingKey)
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 ->
preference.context.settings().preferences.edit()
.putBoolean(preference.key, newValue).apply()

View File

@ -149,6 +149,7 @@
<!-- 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_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>
<!-- Quick Action Sheet -->

View File

@ -296,6 +296,8 @@
<string name="preferences_account_settings">Account settings</string>
<!-- Preference for open links in third party apps -->
<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 -->
<string name="preferences_addons">Add-ons</string>

View File

@ -132,6 +132,12 @@
android:key="@string/pref_key_open_links_in_external_app"
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
android:defaultValue="true"
android:icon="@drawable/ic_info"