+ // Update the UI when the file name changes.
+ fileNameEditText.addTextChangedListener(object : TextWatcher {
+ override fun beforeTextChanged(charSequence: CharSequence?, p1: Int, p2: Int, p3: Int) {
+ // Do nothing.
+ }
+
+ override fun onTextChanged(charSequence: CharSequence?, p1: Int, p2: Int, p3: 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.isNotEmpty() && fileName.isNotEmpty() && !blobUrl && !dataUrlWarningTextView.isVisible
+ }
+ })
+