195 Commits

Author SHA1 Message Date
Jeff Sharkey
f56ae2b903 am 118cb035: Merge "Filter roots based on incoming request." into klp-dev
* commit '118cb0353f6dabce1a1d6b550f7fc9eb78c7de87':
  Filter roots based on incoming request.
2013-09-02 20:55:12 -07:00
Jeff Sharkey
92c7406b85 am 7c925042: Merge "New recents behavior to match spec." into klp-dev
* commit '7c925042061bf4b80cf80a7e6d94995c62eca7e1':
  New recents behavior to match spec.
2013-09-02 20:51:44 -07:00
Jeff Sharkey
32bfd2a398 am c22acf6f: Merge "Instance state, fix sharing, Durable objects." into klp-dev
* commit 'c22acf6f1fc001ad0f1c23c5261f371d63e4106e':
  Instance state, fix sharing, Durable objects.
2013-09-02 20:51:40 -07:00
Jeff Sharkey
e1dfca2989 am db06adec: Merge "Use Cursors directly when binding documents." into klp-dev
* commit 'db06adec0d25f57d0fff8788b0081f92f6e5383c':
  Use Cursors directly when binding documents.
2013-09-02 20:51:37 -07:00
Jeff Sharkey
118cb0353f Merge "Filter roots based on incoming request." into klp-dev 2013-09-03 03:50:56 +00:00
Jeff Sharkey
7c92504206 Merge "New recents behavior to match spec." into klp-dev 2013-09-03 03:50:27 +00:00
Jeff Sharkey
c22acf6f1f Merge "Instance state, fix sharing, Durable objects." into klp-dev 2013-09-03 03:50:10 +00:00
Jeff Sharkey
db06adec0d Merge "Use Cursors directly when binding documents." into klp-dev 2013-09-03 03:50:00 +00:00
Jeff Sharkey
348ad6866b Filter roots based on incoming request.
When incoming request is for local-only content, or for ACTION_CREATE,
only include roots advertise those features.

Filters roots based on the allowed MIME types and the supported types
advertised by each root.  This supports displaying Images and Audio
roots only when requesting those content types.  Applies the same
filter when deciding which roots to query for recents.

Fixes advanced filtering instead of limiting to just devices. Update
sorting so that Recent always appears first. Add testing support for
LOCAL_ONLY.

Bug: 10597317, 10526535
Change-Id: Ic5ccf475c4fe93fd52b29388d369d7f6915c0c42
2013-09-02 17:43:14 -07:00
Jeff Sharkey
8c58b79243 am cd6d7dee: Merge "Refactoring of DocumentsContract." into klp-dev
* commit 'cd6d7deec8742e257a670db8e027f628afdf337e':
  Refactoring of DocumentsContract.
2013-09-02 17:09:15 -07:00
Jeff Sharkey
cd6d7deec8 Merge "Refactoring of DocumentsContract." into klp-dev 2013-09-03 00:07:17 +00:00
Jeff Sharkey
251097b378 New recents behavior to match spec.
Updated behavior queries each documents root for recently modified
documents.  It uses a new variant of DirectoryLoader which limits the
maximum number of parallel queries to relieve memory pressure.  When
first started, it waits up to 500ms for everyone to finish, then
publishes whatever results are ready, and then refreshes results as
each straggler finishes.

New RootCursorWrapper that always blends in authority and rootId
columns, which are used for binding root details from blended cursors.

Bug: 10593596, 10329994
Change-Id: Icc0d4a2f1b6166edc72f78a4c88f444eeba6f2f0
2013-09-02 15:33:57 -07:00
Jeff Sharkey
b51331116e Instance state, fix sharing, Durable objects.
Remember instance state across configuration changes, and enable
rotation.  This remembers current modes and in-progress traversals.

Always finish action modes after launching an action.  Fix sharing
by always putting Uris in extras, and always wrap in a chooser.  Find
common MIME types when sharing multiple documents.  Fix downloads
launching by following directory MIME type change.

Introduce "Durable" which is like Parcelable, but can be used for
both byte[] storage and Parcel transport.  Make both DocumentInfo
and DocumentStack durable.

Disable recents until new behavior is implemented.

Bug: 10460236, 10446265, 10533674, 10456344, 10456702
Change-Id: I4eaf2b0b4cde611c69a1e7b5f1586f6b02019b27
2013-09-01 18:59:38 -07:00
Jeff Sharkey
5dfb345df7 Use Cursors directly when binding documents.
Instead of creating a DocumentInfo for every list item, bind the
adapter against Cursor directly.

Create new SortingCursorWrapper which performs sorting at query time
and keeps a O(1) mapping from sorted to unsorted positions in the
underlying Cursor.

Suppress extra loader passes that had been kicked off.  Use unstable
provider when querying to guard against broken providers.

Bug: 10567506, 10510851
Change-Id: I535814da6b17c38de04a1175e0afcc78c6b966ce
2013-08-31 21:33:56 -07:00
Jeff Sharkey
ae9b51bfa3 Refactoring of DocumentsContract.
Combines related columns and constants onto the same class so they
are easier to discover.  Move back to surfacing roots with columns
so they are consistent with documents.

Advanced roots are represented with a flag instead of distinct
types.  Flags to indicate supporting of well-known media types,
instead of arbitrary an MIME filter.  Reintroduce well-formed rootId
to support recents.

Always use the expanded version of "documents" in constants, methods,
and argument names.

Refactor DocumentProvider method names to clearly distinguish if
a single item or multiple could be returned, and of which type.  Add
documentation to clearly define which methods have already been
overridden.

Bug: 10567506, 10567557
Change-Id: I981f26ab82f2b520a19aa1ce66f659de50d7fac0
2013-08-31 16:58:28 -07:00
Jeff Sharkey
6607275b3a am 9fd81a90: Merge "Stronger DocumentsProvider contract." into klp-dev
* commit '9fd81a9008d5c8dd33272b6a451d89fa2fa1841e':
  Stronger DocumentsProvider contract.
2013-08-28 21:32:08 -07:00
Jeff Sharkey
9fd81a9008 Merge "Stronger DocumentsProvider contract." into klp-dev 2013-08-29 04:27:02 +00:00
Jeff Sharkey
aeb16e2435 Stronger DocumentsProvider contract.
Using a contract class requires that a provider implement it exactly
with little help. This change introduces a DocumentsProvider abstract
class that provides a client-side implementation of the contract that
greatly reduces developer burden, and improves correctness.

This also moves to first-class DocumentRoot objects, and moves calls
with complex side effects to be ContentProvider.call() invocations,
offering more granular permission control over Uri operations that
shouldn't be available through Uri grants.

This new design also relaxes the requirement that root information be
burned into every Uri.  Migrate ExternalDocumentsProvider and
DocumentsUI to adopt new API.

Bug: 10497206
Change-Id: I6f2b3f519bfd62a9d693223ea5628a971ce2e743
2013-08-28 20:49:42 -07:00
Baligh Uddin
62ee6fab65 Import translations. DO NOT MERGE
Change-Id: Ic6b1048f4afaa520fea602ec4367de5e192186bd
Auto-generated-cl: translation import
2013-08-28 18:05:47 -07:00
Jeff Sharkey
d0fcacd949 am 98d62123: Merge "Add CancellationSignal support to file operations." into klp-dev
* commit '98d6212327d1c483894b642d5e24c3aac9fca9cf':
  Add CancellationSignal support to file operations.
2013-08-26 15:02:53 -07:00
Baligh Uddin
a943688bb0 Import translations. DO NOT MERGE
Change-Id: I7be513f3d5decec282200b01900ce480fcf291cf
Auto-generated-cl: translation import
2013-08-26 09:42:10 -07:00
Jeff Sharkey
98d6212327 Merge "Add CancellationSignal support to file operations." into klp-dev 2013-08-23 23:17:47 +00:00
Jeff Sharkey
bd3b902567 Add CancellationSignal support to file operations.
Since ContentProvider file operations can end up doing substantial
network I/O before returning the file, allow clients to cancel their
file requests with CancellationSignal.

Ideally this would only be needed for openFile(), but ContentResolver
heavily relies on openAssetFile() and openTypedAssetFile() for common
cases.

Also improve documentation to mention reliable ParcelFileDescriptors
and encourage developers to move away from "rw" combination modes,
since they restrict provider flexibility.  Mention more about places
where pipes or socket pairs could be returned.

Improve DocumentsContract documentation.

Bug: 10329944
Change-Id: I49b2825ea433eb051624c4da3b77612fe3ffc99c
2013-08-23 11:27:25 -07:00
Baligh Uddin
20e4beea1c Import translations. DO NOT MERGE
Change-Id: Ibbd7d5bc59126933bbcf0370cbdcd590f89d0ad7
Auto-generated-cl: translation import
2013-08-23 10:08:48 -07:00
Jeff Sharkey
b448660a22 Request more documents when EXTRA_HAS_MORE.
Implement EXTRA_HAS_MORE and EXTRA_REQUEST_MORE contract with
document providers.  Providers can include EXTRA_HAS_MORE when
additional data is available with additional cost, such as a network
request.

Listen to content changes based on returned cursor instead of
original Uri.  Include a test backend to exercise.  UX still under
development.

Bug: 10350207
Change-Id: Iaa8954df55a1a1c0aa96eb8a4fd288e12c2fbb01
2013-08-18 22:32:02 -07:00
Jeff Sharkey
4eb407a832 Management actions, invalidate caches.
In manage mode, touching launches a VIEW intent for the file.  Also
adds actions for sharing and deleting.

Move roots and thumbnail caches into Application object, and flush
cache when thumbnail size changes.  Listen for package changes and
broadcasts that should invalidate our roots cache.

Pick default grid/list mode based on provider hint.

Bug: 10329983, 10330210, 10378834, 10330069
Change-Id: I75afb1c58ab71bb9d55852b1059da7257a376248
2013-08-18 21:14:02 -07:00
Jeff Sharkey
9d0843df7e Resized thumbnails; async; extend MatrixCursor.
When requesting thumbnails, check if their dimensions are larger
than requested, and downscale to avoid memory pressure.  Load them
async and with LruCache.

Extend MatrixCursor so that RowBuilder can offer() columns without
requiring they know the projection map.  This makes it easier to
respond to query() calls, where the remote side controls the
projection map.  Use it to handle custom projections in external
storage backend.

Update date/time formatting to match spec.

Bug: 10333418, 10331689
Change-Id: I7e947a8e8068af8a39b55e6766b3241de4f3fc16
2013-08-17 19:05:07 -07:00
Jeff Sharkey
a5599ef636 Documents management mode; API adjustment.
Create documents manage mode to support Downloads and transient
storage devices.  Locks user into requested backend root, and forces
file sizes on and sorting by last modified.

Separate API constants for Documents versus Roots, and give concrete
MIME types for roots.

Treat null sizes as unknown.  Documents are always enabled in list
so that divider is drawn.  Mark external storage file as writable.

Bug: 10329983, 10332993, 10332952
Change-Id: I05f4fdf5b04041a38e1ba7fb30202a3b0c615bf6
2013-08-15 16:25:30 -07:00
Jeff Sharkey
54ca29a5b9 DocumentsUI handles GET_CONTENT; hinting, errors.
Document browser now takes over all GET_CONTENT requests that request
openable Uris. It shows both storage backends and includes other apps
that respond to GET_CONTENT. Only grants transient read permissions.

Better guarding against throwing storage backends. Send sort order
and local-only hinting to backends.

Require that OPEN/CREATE_DOC users include openable category.

Bug: 10330112, 10329976, 10340741, 10331689, 10329971
Change-Id: Ieb8768a6d71201816046f4a4c48832061a313c28
2013-08-15 14:14:48 -07:00
Jeff Sharkey
255b4a6fdb Always include a default DocumentStack.
Change-Id: Idbde1d832ac95c4b3c8bd5cd82b0fa695e0bcb6d
2013-08-08 17:57:16 -07:00
Jeff Sharkey
0c2d31bfa1 Better handling of broken storage providers.
Begin throwing FNFE when storage provider doesn't know about document
or when it's having trouble.  Treat all provider errors as FNFE and
avoid crashing our UI.

Change-Id: I946f1ae4125791999464dc4ce494853d5d1c0629
2013-08-07 18:36:41 -07:00
Jeff Sharkey
9fb567b591 Settings, replace files, sorting by size, tweaks.
Add settings to show file sizes and advanced storage devices, both
disabled by default. Add sorting by size when enabled in settings.

Always show all documents, but only allow selection when they match
MIME filter. When creating, select entire filename on focus. When
creating, treat selected documents as replacement targets using that
exact Uri unless display name is changed.

Show available bytes for device roots. Show empty text label in
empty directories. Split grid backend and details into two separate
lines. Fix path label ordering when rendering recent directories.

Change-Id: I44c62e8adb8ca7d4355510a13d1ba975196a2d29
2013-08-07 16:29:51 -07:00
Jeff Sharkey
b156f4bf8c Recents in create, uniform item layouts.
Show recent directories in a separate fragment, and save as serialized
versions of new DirectoryStack. Cleaner behavior around recents and
search, instead of treating them as pseudo-Documents.

More uniform item layouts between list and grid, including both date
and size information, and originating storage root in recents. Avoid
clashing directory loaders by assigning unique numbers. Promote
list/grid switching up into activity.

Change-Id: I9a93460b896067ca036d7e772eeabde31face2e1
2013-08-06 18:16:21 -07:00
Jeff Sharkey
66516697a2 Storage roots in fragment, sectioned.
Move storage roots into a fragment, since it's not a drawer on
tablets.  Cluster and sort roots when displaying.  SectionedListAdapter
to make clustered roots easier to manage.  Add docs for root types.

Move roots cache into separate class to make it easier to share.

Change-Id: Ia0b92eade059e816324641f600c08026c0e268c9
2013-08-06 11:38:46 -07:00
Jeff Sharkey
ef7184a1aa More recents work; filtering and sorting.
Update DirectoryFragment to render List<Document>, making it more
general purpose.  Feed it documents either from a backend Cursor or
after resolving fields from a recents Cursor.  Start in recents when
no persisted stack available.  Synthesize a root for recents.

Local directory filtering and sorting using predicates and
comparators, all performed on background thread.  Introduce
UriDerivativeLoader which handles ContentObserver updates while
producing a derivative work of a Cursor.

Split data model classes into separate files.

Change-Id: Idb88b4ee22c58c8e508328e678877f7e4c978533
2013-08-05 20:14:12 -07:00
Jeff Sharkey
dc2963aeca Track and persist directory stacks; recents work.
Move to manual tracking of directory navigation stack so we have Uri
data to persist, instead of opaque fragment backstack.  Remember
directory stacks across launches on a per-app basis.

Start recording recently opened and created files.  Uniform Uri
parameter extraction utility methods in contract.

Change-Id: I79ed30ee10272bf7c53d339e797639c993f649bb
2013-08-02 17:39:38 -07:00
Jeff Sharkey
92d7e697a8 Reference docs by ROOT_ID and DOC_ID; recents.
The same document may be present with different sematics under
multiple storage roots, so always reference using both ROOT_ID and
DOC_ID.  This enables backends to revoke permissions for an entire
root, such as when an account is removed.

Start building provider to remember recently accessed documents.

Change-Id: I75befa2e61393dec12fcc7fd27f631fcddae46fa
2013-08-02 11:05:11 -07:00
Jeff Sharkey
7e258b31e7 XML metadata for storage backend; custom icons.
Introduce XML metadata for storage backends, used to indicate if
custom roots should be queried, and provide any custom MIME type
icons inside that backend.

Parse metadata and resolve custom icons in UI.

Change-Id: Iec026c0b10845edff7a345d9389691ddf2c87a0e
2013-08-01 11:34:56 -07:00
Jeff Sharkey
bc2971d249 Sliding drawer for roots, move sorting, search.
Move backend root exploration into sliding drawer, and adjust action
bar when moving between modes.  Moves sorting into action bar spinner
instead of separate dialog.  Also add initial search support.

Change-Id: I70189911ba56ae6bd93d5c503a8600acd6d6c0c5
2013-07-31 21:03:09 -07:00
Jeff Sharkey
20d96d8aff Define storage roots, external GUIDs, creation.
Allow storage backends to publish multiple roots into the UI, which
are defined by a directory GUID, type, and label details.  Update
external provider to surface a primary external storage root, and
switch to burning file path into the returned GUIDs so they remain
durable.

Added insert, update, and delete support to external provider. Adds
file extensions to display names when needed to match MIME type.

Add flags for searching and deletion, and extras for Cursor
pagination. Add directory creation dialog to UI. Opening a document
always gives write access.

Change-Id: I9bea1aa0dcde909a5ab86aefeece7451ab920cf1
2013-07-30 22:55:23 -07:00
Jeff Sharkey
e6ddb9222d Disable documents test UI.
Change-Id: Iae8ef3e751a53a3f7df0a7c5bc666ec75e91d9e9
2013-07-16 13:01:57 -07:00
Jeff Sharkey
1482789374 Support sorting in storage UI.
Extract mode information into DisplayState which is now consistent
across directory traversal.  Use grid mode by default when working
with images.  Dialog to switch sort order.

Add testing UI to exercise until we have real clients.

Change-Id: Ic423584d4559732fb3d2aea9e0406b57d43f6e6d
2013-07-01 20:28:20 -07:00
Jeff Sharkey
be8b12e687 Support multi-select in storage UI.
When caller has specified that multiple documents are okay, enable
multi-select action mode.  Currently only allows document selection,
not directories.  Returns multiple documents through ClipData.

Fix bug where GridView was stuck with 2 columns on tablets.

Change-Id: Id49b29a86330639b56fa116d37e7f0d874980c5b
2013-07-01 17:00:14 -07:00
Jeff Sharkey
54e55b740f Iterate on storage UI.
Support both grid and list view of documents.  Show breadcrumb
navigation trail in action bar.  Start supporting file and directory
creation.

Change-Id: I93a973da7b0d4387a57fe719e7bb20944adb0290
2013-07-01 15:31:44 -07:00
Jeff Sharkey
9e0036ed7d External storage provider, document picker UI.
Continuing to flesh out storage backends by adding an external
storage document backend.  Still rough, but it can traverse files
and directories.

Early pass at OPEN/CREATE_DOC picker UI, which offers to traverse
any known storage backends.  Supports opening subdirectories and
returning a picked file.

Change-Id: Idc3554036b3816a93d9b465ee8a620746859d2ae
2013-05-01 17:44:42 -07:00