parent
5cc1ea951c
commit
bcf80d0e0b
|
@ -271,7 +271,14 @@ abstract class BaseBrowserFragment : Fragment(), BackHandler, SessionManager.Obs
|
||||||
context = context,
|
context = context,
|
||||||
didFail = downloadJobStatus == AbstractFetchDownloadService.DownloadJobStatus.FAILED,
|
didFail = downloadJobStatus == AbstractFetchDownloadService.DownloadJobStatus.FAILED,
|
||||||
download = download,
|
download = download,
|
||||||
tryAgain = downloadFeature::tryAgain
|
tryAgain = downloadFeature::tryAgain,
|
||||||
|
onCannotOpenFile = {
|
||||||
|
FenixSnackbar.make(view, Snackbar.LENGTH_SHORT)
|
||||||
|
.setText(context.getString(R.string.mozac_feature_downloads_could_not_open_file))
|
||||||
|
.setAnchorView(browserToolbarView.view)
|
||||||
|
.show()
|
||||||
|
}
|
||||||
|
|
||||||
)
|
)
|
||||||
dialog.show()
|
dialog.show()
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,8 @@ class DownloadNotificationBottomSheetDialog(
|
||||||
context: Context,
|
context: Context,
|
||||||
private val download: DownloadState,
|
private val download: DownloadState,
|
||||||
private val didFail: Boolean,
|
private val didFail: Boolean,
|
||||||
private val tryAgain: (Long) -> Unit
|
private val tryAgain: (Long) -> Unit,
|
||||||
|
private val onCannotOpenFile: () -> Unit
|
||||||
// We must pass in the BottomSheetDialog theme for the transparent window background to apply properly
|
// We must pass in the BottomSheetDialog theme for the transparent window background to apply properly
|
||||||
) : BottomSheetDialog(context, R.style.Theme_MaterialComponents_BottomSheetDialog) {
|
) : BottomSheetDialog(context, R.style.Theme_MaterialComponents_BottomSheetDialog) {
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
@ -64,11 +65,16 @@ class DownloadNotificationBottomSheetDialog(
|
||||||
mozilla.components.feature.downloads.R.string.mozac_feature_downloads_button_open
|
mozilla.components.feature.downloads.R.string.mozac_feature_downloads_button_open
|
||||||
)
|
)
|
||||||
setOnClickListener {
|
setOnClickListener {
|
||||||
AbstractFetchDownloadService.openFile(
|
val fileWasOpened = AbstractFetchDownloadService.openFile(
|
||||||
context = context,
|
context = context,
|
||||||
contentType = download.contentType,
|
contentType = download.contentType,
|
||||||
filePath = download.filePath
|
filePath = download.filePath
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (!fileWasOpened) {
|
||||||
|
onCannotOpenFile()
|
||||||
|
}
|
||||||
|
|
||||||
context.metrics.track(Event.InAppNotificationDownloadOpen)
|
context.metrics.track(Event.InAppNotificationDownloadOpen)
|
||||||
dismiss()
|
dismiss()
|
||||||
}
|
}
|
||||||
|
@ -83,7 +89,6 @@ class DownloadNotificationBottomSheetDialog(
|
||||||
|
|
||||||
setOnShowListener {
|
setOnShowListener {
|
||||||
window?.apply {
|
window?.apply {
|
||||||
// setBackgroundDrawableResource(android.R.color.transparent)
|
|
||||||
setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
|
setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
|
||||||
setLayout(
|
setLayout(
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||||
|
|
Loading…
Reference in New Issue