- // Get the URL size on the IO thread.
- withContext(Dispatchers.IO) {
- // Get the URL size.
- urlSize = GetUrlSizeHelper.getUrl(requireContext(), URL(urlToSave), userAgentString, cookiesEnabled)
- }
+ // Enable the save button if the edit texts are populated and this isn't a blob URL.
+ saveButton.isEnabled = urlToSave.isNotBlank() && fileName.isNotBlank() && !blobUrl
+
+ // Determine if this is a data URL.
+ val dataUrl = urlToSave.startsWith("data:")
+
+ // Only process the URL if it is not a data URL.
+ if (!dataUrl) {
+ CoroutineScope(Dispatchers.Main).launch {
+ // Create a URL size string.
+ var fileNameAndSize: Pair<String, String>
+
+ // Get the URL size on the IO thread.
+ withContext(Dispatchers.IO) {
+ // Get the updated file name and size.
+ fileNameAndSize = UrlHelper.getNameAndSize(requireContext(), urlToSave, userAgentString, cookiesEnabled)
+
+ // Save the updated file name.
+ fileNameString = fileNameAndSize.first
+ }