Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use storage access framework to write files #2844

Closed
cketti opened this issue Oct 17, 2017 · 6 comments
Closed

Use storage access framework to write files #2844

cketti opened this issue Oct 17, 2017 · 6 comments
Labels
type: enhancement New features or improvements to existing features.

Comments

@cketti
Copy link
Member

cketti commented Oct 17, 2017

Using the storage access framework we will be able to support all kinds of removable storage supported by Android (e.g. secondary external storage like an SD card). Additionally users can save files to supported cloud storage providers without us having to add special support for them ourselves.
This will also allow us to drop the permission to write to external storage (once we drop support for moving the message database to external storage).

Requesting access to a directory and persistable permissions aren't that well supported. But I don't mind getting rid of the default path to save attachments to and prompt the user every time.

@cketti cketti added the type: enhancement New features or improvements to existing features. label Oct 17, 2017
@Trogel
Copy link
Contributor

Trogel commented Oct 21, 2017

So, is your idea basically to do an ACTION_CREATE_DOCUMENT whenever an attachment (or something else?) shall be written?

@cketti
Copy link
Member Author

cketti commented Oct 22, 2017

Yes. However, that's only available on API 19+. So there needs to be some fallback code for older versions. Preferably, we'd display a UI to select a folder and filename similar to what the system UI looks like on newer Android versions.

@Trogel
Copy link
Contributor

Trogel commented Oct 22, 2017

That sounds reasonable. May I give it a try?

@cketti
Copy link
Member Author

cketti commented Oct 22, 2017

I'd wait until we switch to using AppCompat for Material Design. Otherwise half of the fallback UI might have to be rewritten.
But you could start with the ACTION_CREATE_DOCUMENT part and keep the current behavior for old Android versions.

@thunderbird thunderbird deleted a comment from maidik Dec 15, 2017
fat-tire added a commit to fat-tire/k-9 that referenced this issue Feb 1, 2018
The approach was to make it so that any K9Activity can easily request
whatever permission in the future.

The Contacts permission is now requested in two locations:

1.  When a list of Messages is displayed
2.  When a new message is first started to be composed.

The permission request is displayed ONCE per onCreate(). Any more than this
and it got really annoying.  A typical user who reads or writes emails
WILL see the request, trust me.  Once they see the message 2x, they
also have the option to block the requests from appearing.

If they DECLINE the request (or decline + DENY any further attempts),
the app should continues to work, albeit without incorporating contact data
(thumbnails, autocomplete, etc.). Contacts may still be added to the
Contacts app, as this uses an Intent and does not require any permission.

Once the Read Contacts permission is enabled, the app immediately begins
to use it.

To add other permissions in the future (such as External Storage access),
the request can be made in a similar way and the permission request result
handled appropriately by just adding it to K9Activity (or overriding in
a particular Activity).

I did *not* implement this for external storage access, as 1. there is a PR
waiting (thunderbird#3118) and 2. I think that using the Storage Access Framework
is a much better way to approach that as suggested in Issue thunderbird#2844.

I noticed there are 3 additional custom permissions in the manifest having
to do with other apps controlling K9, but I don't think they're required by
k9 itself.  If so, they can be requested from any K9Activity.
@fat-tire
Copy link

fat-tire commented Feb 2, 2018

I think you'd probably want to use Intent.ACTION_OPEN_DOCUMENT_TREE, supported starting in Lollipop, to select the target directory, yeah?

fat-tire added a commit to fat-tire/k-9 that referenced this issue Feb 9, 2018
The approach was to make it so that any K9Activity can easily request
whatever permission in the future.

The Contacts permission is now requested in two locations:

1.  When a list of Messages is displayed
2.  When a new message is first started to be composed.

The permission request is displayed ONCE per onCreate(). Any more than this
and it got really annoying.  A typical user who reads or writes emails
WILL see the request, trust me.  Once they see the message 2x, they
also have the option to block the requests from appearing.

If they DECLINE the request (or decline + DENY any further attempts),
the app should continues to work, albeit without incorporating contact data
(thumbnails, autocomplete, etc.). Contacts may still be added to the
Contacts app, as this uses an Intent and does not require any permission.

Once the Read Contacts permission is enabled, the app immediately begins
to use it.

To add other permissions in the future (such as External Storage access),
the request can be made in a similar way and the permission request result
handled appropriately by just adding it to K9Activity (or overriding in
a particular Activity).

I did *not* implement this for external storage access, as 1. there is a PR
waiting (thunderbird#3118) and 2. I think that using the Storage Access Framework
is a much better way to approach that as suggested in Issue thunderbird#2844.

I noticed there are 3 additional custom permissions in the manifest having
to do with other apps controlling K9, but I don't think they're required by
k9 itself.  If so, they can be requested from any K9Activity.
fat-tire added a commit to fat-tire/k-9 that referenced this issue Feb 10, 2018
The approach was to make it so that any K9Activity can easily request
whatever permission in the future.

The Contacts permission is now requested in two locations:

1.  When a list of Messages is displayed
2.  When a new message is first started to be composed.

The permission request is displayed ONCE per onCreate(). Any more than this
and it got really annoying.  A typical user who reads or writes emails
WILL see the request, trust me.  Once they see the message 2x, they
also have the option to block the requests from appearing.

If they DECLINE the request (or decline + DENY any further attempts),
the app should continues to work, albeit without incorporating contact data
(thumbnails, autocomplete, etc.). Contacts may still be added to the
Contacts app, as this uses an Intent and does not require any permission.

Once the Read Contacts permission is enabled, the app immediately begins
to use it.

To add other permissions in the future (such as External Storage access),
the request can be made in a similar way and the permission request result
handled appropriately by just adding it to K9Activity (or overriding in
a particular Activity).

I did *not* implement this for external storage access, as 1. there is a PR
waiting (thunderbird#3118) and 2. I think that using the Storage Access Framework
is a much better way to approach that as suggested in Issue thunderbird#2844.

I noticed there are 3 additional custom permissions in the manifest having
to do with other apps controlling K9, but I don't think they're required by
k9 itself.  If so, they can be requested from any K9Activity.
fat-tire added a commit to fat-tire/k-9 that referenced this issue Feb 10, 2018
The approach was to make it so that any K9Activity can easily request
whatever permission in the future.

The Contacts permission is now requested in two locations:

1.  When a list of Messages is displayed
2.  When a new message is first started to be composed.

The permission request is displayed ONCE per onCreate(). Any more than this
and it got really annoying.  A typical user who reads or writes emails
WILL see the request, trust me.  Once they see the message 2x, they
also have the option to block the requests from appearing.

If they DECLINE the request (or decline + DENY any further attempts),
the app should continues to work, albeit without incorporating contact data
(thumbnails, autocomplete, etc.). Contacts may still be added to the
Contacts app, as this uses an Intent and does not require any permission.

Once the Read Contacts permission is enabled, the app immediately begins
to use it.

To add other permissions in the future (such as External Storage access),
the request can be made in a similar way and the permission request result
handled appropriately by just adding it to K9Activity (or overriding in
a particular Activity).

I did *not* implement this for external storage access, as 1. there is a PR
waiting (thunderbird#3118) and 2. I think that using the Storage Access Framework
is a much better way to approach that as suggested in Issue thunderbird#2844.

I noticed there are 3 additional custom permissions in the manifest having
to do with other apps controlling K9, but I don't think they're required by
k9 itself.  If so, they can be requested from any K9Activity.
@pellajl

This comment has been minimized.

GoneUp added a commit to GoneUp/k-9 that referenced this issue Oct 10, 2018
- Legacy save on old devices
- SAF single file save on 4.4 or on long press
- SAF tree save on >5.0
Matches beahviour in thunderbird#2844 better
GoneUp added a commit to GoneUp/k-9 that referenced this issue Nov 28, 2018
- Legacy save on old devices
- SAF single file save on 4.4 or on long press
- SAF tree save on >5.0
Matches beahviour in thunderbird#2844 better
@cketti cketti closed this as completed Dec 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement New features or improvements to existing features.
Projects
None yet
Development

No branches or pull requests

4 participants