Commit 35c1f766 authored by MozLando's avatar MozLando
Browse files

Merge #4689 #4692 #4694

4689: feature-contextmenu: Do not show download confirmation dialog for "save image". r=csadilek a=pocmo

Fixing Fenix issue: https://github.com/mozilla-mobile/fenix/issues/952





4692: Import strings from android-l10n. r=pocmo a=mozilla-l10n-automation-bot

n/t

4694:  Docs update (20191009-121304) [ci skip] r=pocmo a=MickeyMoz
Co-authored-by: default avatarSebastian Kaspari <s.kaspari@gmail.com>
Co-authored-by: default avatarMozilla L10n Automation Bot <release+l10n-automation-bot@mozilla.com>
Co-authored-by: default avatarMickeyMoz <sebastian@mozilla.com>
......@@ -167,6 +167,15 @@
<!-- The document title and heading of an error page. -->
<string name="mozac_browser_errorpages_file_not_found_title">Không tìm thấy tệp</string>
<!-- The document title and heading of an error page. -->
<string name="mozac_browser_errorpages_file_access_denied_title">Truy cập tập tin bị từ chối</string>
<!-- The document title and heading of an error page. -->
<string name="mozac_browser_errorpages_proxy_connection_refused_title">Máy chủ proxy từ chối kết nối</string>
<!-- The document title and heading of an error page. -->
<string name="mozac_browser_errorpages_unknown_proxy_host_title">Không tìm thấy máy chủ proxy</string>
<!-- The document title and heading of an error page. -->
<string name="mozac_browser_errorpages_safe_phishing_uri_title">Vấn đề trang web lừa đảo</string>
<!-- The %1$s will be replaced by the malicious website URL-->
......
......@@ -26,5 +26,6 @@ data class DownloadState(
val userAgent: String? = null,
val destinationDirectory: String = Environment.DIRECTORY_DOWNLOADS,
val referrerUrl: String? = null,
val skipConfirmation: Boolean = false,
val id: String = UUID.randomUUID().toString()
)
......@@ -151,7 +151,7 @@ data class ContextMenuCandidate(
action = { tab, hitResult ->
contextMenuUseCases.injectDownload(
tab.id,
DownloadState(hitResult.src)
DownloadState(hitResult.src, skipConfirmation = true)
)
}
)
......
......@@ -19,7 +19,7 @@
<!-- Text for confirmation "snackbar" shown after opening a link in a new private tab. -->
<string name="mozac_feature_contextmenu_snackbar_new_private_tab_opened">Ny privat fane opna</string>
<!-- Text for confirmation "snackbar" shown after copying a link or image URL to the clipboard. -->
<string name="mozac_feature_contextmenu_snackbar_text_copied">Tekst kopiert til utklippstavla</string>
<string name="mozac_feature_contextmenu_snackbar_link_copied">Lenke kopiert til utklippstavla</string>
<!-- Action shown in a "snacbkar" after opening a new/private tab. Clicking this action will switch to the newly opened tab. -->
<string name="mozac_feature_contextmenu_snackbar_action_switch">Byt</string>
</resources>
......@@ -382,6 +382,8 @@ class ContextMenuCandidateTest {
assertEquals(
"https://www.mozilla.org/media/img/logos/firefox/logo-quantum.9c5e96634f92.png",
store.state.tabs.first().content.download!!.url)
assertTrue(
store.state.tabs.first().content.download!!.skipConfirmation)
}
@Test
......
......@@ -107,7 +107,7 @@ class DownloadsFeature(
*/
private fun processDownload(tab: SessionState, download: DownloadState): Boolean {
return if (applicationContext.isPermissionGranted(downloadManager.permissions.asIterable())) {
if (fragmentManager != null) {
if (fragmentManager != null && !download.skipConfirmation) {
showDialog(tab, download)
false
} else {
......
......@@ -152,6 +152,43 @@ class DownloadsFeatureTest {
verify(downloadManager).download(eq(download), anyString())
}
@Test
fun `Adding a Download with skipConfirmation flag will start download immediately`() {
val fragmentManager: FragmentManager = mockFragmentManager()
grantPermissions()
val downloadManager: DownloadManager = mock()
doReturn(
arrayOf(INTERNET, WRITE_EXTERNAL_STORAGE)
).`when`(downloadManager).permissions
val feature = DownloadsFeature(
testContext,
store,
useCases = mock(),
fragmentManager = fragmentManager,
downloadManager = downloadManager
)
feature.start()
verify(fragmentManager, never()).beginTransaction()
val download = DownloadState(
url = "https://www.mozilla.org",
skipConfirmation = true
)
store.dispatch(ContentAction.UpdateDownloadAction("test-tab", download))
.joinBlocking()
testDispatcher.advanceUntilIdle()
verify(fragmentManager, never()).beginTransaction()
verify(downloadManager).download(eq(download), anyString())
}
@Test
fun `When starting the feature will reattach to already existing dialog`() {
grantPermissions()
......
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment