PDFs and some certain file formats don't open, even when I do have the apps installed to open them
Also: why am I not able to just download the attachment and then use it?
One could change the suffix of the file to hide what file it actually is. So you need to download it first to change the suffix and then use it as intended.
Or in my case the app I want to use the attachment with does not register the file type.
I'd like to be able to download my private keys and import into the Termius mobile app to manage remote servers. When attempting to download the attachments, Bitwarden gives me an error message saying: Your device cannot open this type of file.
@kspearrin Would it be possible to remove this restriction?
Similarly to what @bassarf said, some users also use custom file extensions. My private keys in Putty format end in .ppk and my private keys in OpenSSH format use .pk. A lot of times it's simply developer preference.
Our code for creating an intent to open files is here:
https://github.com/bitwarden/mobile/blob/ced9d33d2eccaf968e83528b6af577bf82361154/src/Android/Services/DeviceActionService.cs#L164-L198
I am not sure why, but this code can return no intent/activities if it can't understand how to open the file. Not sure what other alternative there is?
I'm not an Android Developer, so I personally don't know. In my case I prefer to download the file, not open the file. Similar to issue #192 which seems to have been closed.
Edit: I've made a Feature Request on the Bitwarden Community Forums. If anyone else is interested be sure to show your support there.
https://community.bitwarden.com/t/download-attachments-as-an-alternative-to-open-with/8226
@kspearrin To save files, you need to use ACTION_CREATE_DOCUMENT.
I use this functionality in my own app to export a database. Here's a simplified example:
```kotlin
class SampleActivity : Activity() {
val EXPORT_REQUEST_CODE = 1;
fun export() {
val intent = Intent(Intent.ACTION_CREATE_DOCUMENT)
intent.type = "application/octet-stream"
startActivityForResult(intent, EXPORT_REQUEST_CODE)
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
if (requestCode == EXPORT_REQUEST_CODE && resultCode == RESULT_OK) {
val exportFd = it.contentResolver.openFileDescriptor(uri, "w") ?: throw Exception("Could not open file")
val exportStream = FileOutputStream(exportFd.fileDescriptor)
val fileStream = FileInputStream(<path to file to save>)
exportStream.channel.truncate(0)
val buffer = ByteArray(1024)
do {
val length = fileStream.read(buffer)
if (length > 0) {
exportStream.write(buffer, 0, length)
} else {
break
}
} while (true)
exportStream.close()
fileStream.close()
}
}
}
I've been working on this issue and I'm curious what everyone's thoughts are regarding expected behavior. Do we:
1 - Try to open the attachment like we do now, but fall back to the option to save if that fails
2 - Always open images (based on file extension) and prompt to save everything else
3 - Always prompt to save
4 - Provide options for both actions up front
5 - Something else I haven't thought of
Option 4 seems like the best choice but has the potential to become a thing once UX changes are involved. My first thought was to add long-press support on the "open" button to prompt for saving, but discoverability of that capability can be an issue for less experienced Android users.
Thoughts?
Another option would be to always save the file, but display a notification when this process is complete. Tapping the notification would open the file. This is the UI pattern used when downloading a file using a web browser.
Option 4, in my opinion. I think adding a second icon for saving the file is best.
Users can then easily choose to open the attachment or download and save the attachment.
I think the current icon makes more sense for saving, and then an alternative icon for opening the file.
If I would implement it, I think I would choose the behavior to be:
Tapping the file name would open it. And a download icon for downloading it.
I agree with @DougParker1992 that the current icon looks like a download icon
Other than that, I would rate the alternatives in the following order:
But that's just me. I don't use it to store pictures which I just want to open.
For me this feature makes more sense for storing sensitive stuff like 2FA backup keys or something else. Maybe some key files you need to log in or open something. Maybe your private pgp key. And maybe you want to "disguise" it as Picture. Or it's an encrypted file which you have to do some stuff with after downloading. Or I want to send the file to someone after downloading.
It would be interesting to know how the majority uses the attachments.
Anyhow.... I think opening it first is like an autocorrect fail. It's annoying when software think it's smart when it's wrong. Then it's better to don't be smart.
I personally would be satisfied if there is just one straight forward way to download the attachments.
Thank you for working on it, and thank to for asking for feedback.
Thanks everyone for the feedback. I've implemented something that I think covers the bases without introducing any technical debt on our side.
After clicking the download icon:
The end result is we can save everything + optionally open when available.
Edit: Removed gigantic screenshots
looks very good. Thank you.
This looks like an elegant solution to me. :)
Thank you very much.
Most helpful comment
Thanks everyone for the feedback. I've implemented something that I think covers the bases without introducing any technical debt on our side.
After clicking the download icon:
The end result is we can save everything + optionally open when available.
Edit: Removed gigantic screenshots