Re: [android-developers] Using ACTION_OPEN_DOCUMENT for editing files

2014-01-30 Thread Dave Smith
Thanks for the thoughts, Jeff.

I understand your reasoning, so perhaps the best course of action is to 
modify the example documentation.  The "Edit a document" section of the SAF 
Guide 
(https://developer.android.com/guide/topics/providers/document-provider.html#edit)
 
states that to "edit a text document in place", the correct choice is 
ACTION_OPEN_DOCUMENT.  Based on what you are saying, since 
ACTION_CREATE_DOCUMENT allows you to pick an existing file, that is the 
better choice for "in place editing".

The guide should probably either be changed to reflect 
ACTION_CREATE_DOCUMENT for editing, or to indicate that using 
ACTION_OPEN_DOCUMENT should include a branch check on FLAG_SUPPORTS_WRITE 
to determine if the edit can happen in place, or if ACTION_CREATE_DOCUMENT 
will need to be used anyway to create a new file for the edit changes.

Thanks again,
Dave Smith
@devunwired

>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [android-developers] Using ACTION_OPEN_DOCUMENT for editing files

2014-01-30 Thread Jeff Sharkey
Yep, you're right that checking FLAG_SUPPORTS_WRITE is the best way to
check if a write is allowed.

If you're really looking to focus on writing data, then
ACTION_CREATE_DOCUMENT might be a better fit, since it also lets the user
select an existing file, and it filters to only allow selection of
documents that have FLAG_SUPPORTS_WRITE set.

I'm thinking that allowing an app to request filtering of read-only
documents during a OPEN_DOCUMENT request would lead to user confusion
because of the inconsistency between apps.  (For example, a user would
still expect to open a read-only document for viewing purposes.)  If a user
then tried saving changes to a read-only document, it makes sense for the
app to use CREATE_DOCUMENT to ask them to save the modifications somewhere
else.

Hope this helps.  :)

j


On Wed, Jan 1, 2014 at 9:05 PM, Dave Smith  wrote:

> As far as I can tell from the documentation and testing with the new
> Storage Access Framework and Intent.ACTION_OPEN_DOCUMENT, there doesn't
> seem to be a way (via an extra or otherwise) to pass with the Intent
> request to open a document to only return documents from providers that
> support writing (i.e. have FLAG_SUPPORTS_WRITE set).  Instead, we are
> forced to check a document selection made by the user (via a metadata
> query) to determine if the document supports write before we attempt to
> open an OutputStream or ParcelFileDescriptor in "w" mode.  Is this correct,
> or have I overlooked something?
>
> This seems to be a large missing piece in the new Storage Access Framework
> when attempting to allow a user to open an existing document to be edited
> as it forces the user to make a selection first, then have us check if they
> can write, throw and error if they cannot, and force them to pick again.
>  Furthermore, we cannot say that it is uncommon for documents providers not
> to support writing, because even the system media documents provider (i.e.
> the source for images/videos) does not support write and will throw and
> IllegalArgumentException ("Media is read-only") when one attempts to write
> to one of its files (as an image editing app, the most common example used
> in the docs, would attempt to do).  Is there a proper method with the new
> SAF of limiting selections to writable providers only?
>
> Feedback appreciated for anything I may have missed here.  As it stands,
> suggesting that developers use ACTION_OPEN_DOCUMENT for in-place editing
> doesn't seem like a viable approach.
>
> Dave Smith
> @devuwired
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Android Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to android-developers+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
Jeff Sharkey
jshar...@android.com

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[android-developers] Using ACTION_OPEN_DOCUMENT for editing files

2014-01-01 Thread Dave Smith
As far as I can tell from the documentation and testing with the new 
Storage Access Framework and Intent.ACTION_OPEN_DOCUMENT, there doesn't 
seem to be a way (via an extra or otherwise) to pass with the Intent 
request to open a document to only return documents from providers that 
support writing (i.e. have FLAG_SUPPORTS_WRITE set).  Instead, we are 
forced to check a document selection made by the user (via a metadata 
query) to determine if the document supports write before we attempt to 
open an OutputStream or ParcelFileDescriptor in "w" mode.  Is this correct, 
or have I overlooked something?

This seems to be a large missing piece in the new Storage Access Framework 
when attempting to allow a user to open an existing document to be edited 
as it forces the user to make a selection first, then have us check if they 
can write, throw and error if they cannot, and force them to pick again. 
 Furthermore, we cannot say that it is uncommon for documents providers not 
to support writing, because even the system media documents provider (i.e. 
the source for images/videos) does not support write and will throw and 
IllegalArgumentException ("Media is read-only") when one attempts to write 
to one of its files (as an image editing app, the most common example used 
in the docs, would attempt to do).  Is there a proper method with the new 
SAF of limiting selections to writable providers only?

Feedback appreciated for anything I may have missed here.  As it stands, 
suggesting that developers use ACTION_OPEN_DOCUMENT for in-place editing 
doesn't seem like a viable approach.

Dave Smith
@devuwired

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.