Bug 1854385 - When accessing files from downloads that cannot be opened, a snack bar with an error message should appear.

fenix/120.0
iorgamgabriel 8 months ago committed by mergify[bot]
parent d85d8cc474
commit 5f336076d9

@ -16,6 +16,7 @@ import android.view.ViewGroup
import androidx.annotation.VisibleForTesting
import androidx.core.view.MenuProvider
import androidx.lifecycle.Lifecycle
import com.google.android.material.snackbar.Snackbar
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.MainScope
@ -28,8 +29,10 @@ import mozilla.components.support.base.feature.UserInteractionHandler
import org.mozilla.fenix.HomeActivity
import org.mozilla.fenix.R
import org.mozilla.fenix.browser.browsingmode.BrowsingMode
import org.mozilla.fenix.components.FenixSnackbar
import org.mozilla.fenix.components.StoreProvider
import org.mozilla.fenix.databinding.FragmentDownloadsBinding
import org.mozilla.fenix.downloads.DynamicDownloadDialog
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.filterNotExistsOnDisk
import org.mozilla.fenix.ext.getRootView
@ -216,17 +219,33 @@ class DownloadFragment : LibraryPageFragment<DownloadItem>(), UserInteractionHan
} else {
0L
}
AbstractFetchDownloadService.openFile(
val downloadState = DownloadState(
id = item.id,
url = item.url,
fileName = item.fileName,
contentType = item.contentType,
status = item.status,
contentLength = contentLength,
)
val canOpenFile = AbstractFetchDownloadService.openFile(
applicationContext = it.applicationContext,
download = DownloadState(
id = item.id,
url = item.url,
fileName = item.fileName,
contentType = item.contentType,
status = item.status,
contentLength = contentLength,
),
download = downloadState,
)
if (!canOpenFile) {
FenixSnackbar.make(
view = binding.root,
duration = Snackbar.LENGTH_SHORT,
isDisplayedWithBrowserToolbar = true,
).setText(
DynamicDownloadDialog.getCannotOpenFileErrorMessage(
it,
downloadState,
),
)
.show()
}
}
}

Loading…
Cancel
Save