+ // Update the UI when the file name changes.
+ fileNameEditText.addTextChangedListener(object : TextWatcher {
+ override fun beforeTextChanged(charSequence: CharSequence?, start: Int, count: Int, after: Int) {
+ // Do nothing.
+ }
+
+ override fun onTextChanged(charSequence: CharSequence?, start: Int, before: Int, count: Int) {
+ // Do nothing.
+ }
+
+ override fun afterTextChanged(editable: Editable?) {
+ // Get the contents of the edit texts.
+ val urlToSave = urlEditText.text.toString()
+ val fileName = fileNameEditText.text.toString()
+
+ // Determine if this is a blob URL.
+ val blobUrl = urlToSave.startsWith("blob:")
+
+ // Enable the save button if the edit texts are populated and this isn't a blob URL (or a data URL using Android's download manager).
+ saveButton.isEnabled = urlToSave.isNotBlank() && fileName.isNotBlank() && !blobUrl && !dataUrlWarningTextView.isVisible
+ }
+ })
+