172 Commits

Author SHA1 Message Date
Steve McKay
14e827a958 CopyService generalization.
Make the service operation agnostic, so we can also move delete operations to it.
In a followup change we'll see about adding support for multiple concurrent
    operations. We'll need to evaluate how to do this in IntentService (which
    serializes requests....a major limitation).

Change-Id: I03eca9c1ecaba519af42d88edffeb0dce78bd1da
2016-01-07 16:29:36 -08:00
Tomasz Mikolajewski
4b6ac4a359 Merge "Revert "Revert "Remove the flag and make openTypedDocument throw FileNotFoundException.""" 2016-01-07 07:19:56 +00:00
Tomasz Mikolajewski
75395651c2 Revert "Revert "Remove the flag and make openTypedDocument throw FileNotFoundException.""
This reverts commit 2b931719783cda11c3bbac9928c603d0a0a06d43.

Change-Id: Ic61b874012daeada02b73643f5c58f9ec840b3e5
2016-01-07 07:19:22 +00:00
Tomasz Mikolajewski
97dd67cc34 Merge "Revert "Remove the flag and make openTypedDocument throw FileNotFoundException."" 2016-01-07 04:47:42 +00:00
Tomasz Mikolajewski
2b93171978 Revert "Remove the flag and make openTypedDocument throw FileNotFoundException."
This reverts commit 95149ab6a5442a05f05f448854b6ab386c87f717.

Change-Id: I218aa8059ef674400dac8531a86cd326748c26d5
2016-01-07 04:47:03 +00:00
Tomasz Mikolajewski
5a22e1a19d Merge "Remove the flag and make openTypedDocument throw FileNotFoundException." 2016-01-07 03:52:01 +00:00
Tomasz Mikolajewski
95149ab6a5 Remove the flag and make openTypedDocument throw FileNotFoundException.
To be compatible with ContentProvider, DocumentsProvider should not
require checking for a flag before calling openTypedAssetFile.

This CL removes the flag, and makes the default implementation throw
FileNotFoundException instead.

Bug: 26222645
Change-Id: I3492f05804e39583ebb8584109c7017b3082846e
2016-01-07 03:49:14 +00:00
Steve McKay
44408260ba Don't proxy calls to DocumentsAdapter in MultiSelManager.
We were bouncing calls out to the adapter pulled from RecyclerView,
but the adapter is easy to write a test double for and
we can readily inject the adapter when needed at runtime.

Eliminates unnecessary indirection.
Also, protect against failure when documents can't be loaded for delete.

Change-Id: Ief6585bf2e3e4fd407d801d485a9d7cd888b8500
2016-01-05 15:50:35 -08:00
Steve McKay
955e46d004 Fix event relay to correctly dispatch events.
This fixes:
- UI to show selection which was broken in ag/838866
- Delete undo, which throws IOB exception
  when undoing a a full delete of all entries.

Change-Id: Idbb43510974e130d283313602a71ac15ad10aadf
2016-01-05 14:13:57 -08:00
Steve McKay
ef16f5f411 Move Adapters to their own classes.
Move section break support into a separate wrapper class.
Fix issue where intermediate directory updates were briefly showing hidden files.
Add a rudimentary test for ModelBackedDocumentsAdapter.

Bug: 26293561, 26383237, 26293561, 26309025
Change-Id: I1fa489b110754d8801091b2009caebe9d2278701
2016-01-05 10:50:52 -08:00
Ben Kwa
af55a15196 Merge "Implement bucketed sorting in DocumentsUI." 2015-12-18 23:06:13 +00:00
Ben Kwa
c72a2cb899 Implement bucketed sorting in DocumentsUI.
Change the sort code in the Model to bucket items into two separate
categories (folders and documents) and then sort the two buckets
separately.

Add code to the adapter to insert a visual break in the UI, between
folders and documents.

Change-Id: I759fedcef829aba9ad61554326489a9e62641cc7
2015-12-18 15:04:26 -08:00
Tomasz Mikolajewski
c7ec678d7c Cleanup StubProvider a little.
Change-Id: I1d9f1c978850f466ff204bff97a152ba7919a096
2015-12-18 11:29:48 +09:00
Tomasz Mikolajewski
f65fdebddb Add tests for copying virtual typed files.
Bug: 26147488
Change-Id: I44cfae518f4b6dfceed5b9f50b132e2acf161b3f
2015-12-17 17:02:42 +09:00
Tomasz Mikolajewski
cca31ebb0e Add support to virtual and typed files in StubProvider.
Bug: 26147488
Change-Id: I40a75547ff16bb7d45f36843c29692268b4291b6
2015-12-17 15:06:29 +09:00
Ben Kwa
fcb54d8be7 Wrap up the stable ID refactor.
- Rationalize band selection: make it internally a range selection
  operation, that translates positions to IDs only when updating the
  Selection.
- Clean up TODOs and comments.
- Fix selection adjustment when things are removed from the view.

Change-Id: If917eb9dd18e755c5a0ce83c84409902c4ef3d2e
2015-12-16 14:04:24 -08:00
Ben Kwa
862b9641e3 Re-enable sorting in the DirectoryFragment.
- Move sorting from the back-end (using SortingCursorWrapper) to the the
  front-end (in DocumentsAdapter).  This makes it such that re-sorting
  the directory contents doesn't necessitate a reload.
- Update DirectoryLoaders to just return unsorted results, and rely on
  the UI to sort them.
- Remove the (now-unused) SortingCursorWrapper.
- Update Model tests to test sorting.

BUG=26024369

Change-Id: I871cc0e496267d381ae546e0309125d04649415a
2015-12-16 13:54:01 -08:00
Ben Kwa
db65cd5e48 Fix file deletion after the move to Model IDs.
- Add methods to the DocumentsAdatper to hide and unhide files.  This
  removes that burden from the Model.

- Remove clunky markForDeletion/finalizeDeletion and all related code
  from the Model.  Replace with a straight-up delete method.

- Modify deletion code in the DirectoryFragment.  Deletion now looks
  like:
  - user presses delete
  - DocumentsAdapter hides the deleted files
  - If the user presses cancel, the DocumentsAdapter unhides the files.
  - If the user doesn't cancel, Model.delete is called to delete the
    files.

- Fix deletion-related Model tests.

BUG=26024369

Change-Id: I02e2131c1aff1ebcd0bdb93d374675fd157d7f51
2015-12-14 11:47:27 -08:00
Ben Kwa
743c7c2f0f Transition selection to use Model IDs.
This CL transitions the MultiSelectManager to (mostly) use Model IDs.

- Add the ability to retrieve all model IDs for the current directory,
  from the model.

- Add a map in the DocumentsAdapter that maps from adapter position to
  model ID.

- Make the adapter listen for model updates, and update its internal map
  of positions to model IDs appropriately.

- Use the aforementioned map when binding ViewHolders.

- Get unit tests to compile; get as many tests passing as possible at
  this point.  Tests related to deleting things won't work right now.

Still to do:

- Add code to the adapter to sort and group items.  After this is done,
  SortingCursorWrapper will no longer be needed.

- Add code to the adapter to deal with item addition/removal.  After
  this is done, the pending-deletion code in the model can be removed.

- Rationalize position-based vs model-based selection.  Some code in the
  MSM (in particular, code dealing with range selection) is still
  position-based.  It's becoming clear that it doesn't make sense for
  range selection to be ID-based, since "range" is a concept that only
  makes sense in the context of items that are positioned in the UI.
  Will need to iterate more on the position-based code to make sure it
  makes sense.

BUG=26024369

Change-Id: I767cde2d888c101aaf83b59155b14634a236164b
2015-12-14 11:47:27 -08:00
Ben Kwa
003a999db6 Switch DirectoryFragment code to use model IDs.
A Model ID is a unique, stable identifier referring to a document.
The basic idea is to move away from doing everything using adapter
positions, and instead use model IDs.

This is the first in a line of CLs toward that goal.  It does the
following:

- Introduce the concept of a Model ID, which is unique for each
  document.
- Add a method to retrieve items from the Model using ID rather than
  adapter position.
- Transition code in the DirectoryFragment to talk to the Model using
  Model IDs rather than positions.
- Break the Model class out into a separate file of its own.

BUG=26024369

Change-Id: Ia5171f089d6b8a83855423ec05cf14dbfc7b6ba8
2015-12-14 11:47:27 -08:00
Steve McKay
b67bfbf975 Load Home directory by default.
Don't update toolbar before first root load.
This was causing Recents > Home flicker due
to Recents being the default root returned from getCurrentRoot.
Revert change causing regression in selection highlight.

Bug: 26093756
Change-Id: I2c555aa38d68e9bf7962b1407f9fc75c800216a6
2015-12-14 18:17:16 +00:00
Steve McKay
27fd7c6727 Followup changes to ag/810782.
Note, one of the requested changes already happened.

Change-Id: I253cbc2b3b7f2091ca80f43c90e951263fc50ad2
2015-12-04 12:13:25 -08:00
Steve McKay
dbdaa49be4 Add DownloadsActivity functional test.
Bug: 25809806
Change-Id: I43ceaf3a99715a57e3d349bee60f2edf7f6666bd
2015-12-02 14:11:47 -08:00
Steve McKay
d3afdeebeb Don't copy a directory into itself...doesn't go well.
Minimally deform CopyService such that we can listen
    to the completion of operations in the test.
Add test coverage.
Add equals and hashcode to DocumentInfo...so we can compare
    the heck out of 'em. + a test.
WIP: Expose (@hide style) DocumentsProvider.isChildDocument via
    DocumentsContract. Use that to check for recusive copies.

Bug: 25794511

Change-Id: I05bb329eb10b43540c6806d634e5b96a753e8178
2015-12-01 14:16:38 -08:00
Steve McKay
c6a4cd8c0f Add "Home" directory support.
Update FilesActivityUiTests to verify Home is present
    and that clicking a root sets the title accordingly.
Guard addition of WRITABLE flag with a volume test.

Bug: 25147243
Change-Id: Ic20372737cae08a82af0aade0c0dbbd8c22d5f34
2015-11-19 15:56:05 -08:00
Steve McKay
c89cc4419e Merge "Add test size annotations to docsui tests." 2015-11-16 19:47:53 +00:00
Steve McKay
53c774b572 Add test size annotations to docsui tests.
Required by APCT.

Bug: 25152838
Change-Id: I18629036a7b290719d8faf326117e25b52f0ae07
2015-11-12 14:09:29 +09:00
Steve McKay
57a93babd7 Handle shift+arrow correctly in single select mode.
Bug: 25603626
Change-Id: I2f71152b303ac218ecec59e8200acf8a716ea0ee
2015-11-11 16:48:26 +09:00
Steve McKay
f862155e34 Move DirectoryFragment and family to dirlist pkg.
Stuff was getting out of control in the main package.

Change-Id: Ia06ba96f5bbe13388d51e6ad52a9dac76af97cc0
2015-11-04 15:04:57 -08:00
Steve McKay
0c3c695469 Use StubProvider for functional tests.
Add a "UiBot" class for driving the UI from tests.
Add a "DocumentsProviderHelper" class for convenient test doc setup.
Update FilesActivityUiTest to use "TargetContext" which is
    necessary in order to perform ContentProvider
    operations.
Fix a bug where CopyTest relied on implicit order of roots.
Don't include guava in tests...since it breaks functional tests (incompatible class def).
Add test coverage for:
- basic roots list.
- basic files list.
- Live updates to files list.
- basic delete operations.

Bug: 24988170
Change-Id: I2ec01a5e1a474314cb33efb6e92df0f61dfcc1da
NOTE: This is currently broken at the point I try to init files in the stub roots.
2015-11-03 13:18:00 -08:00
Steve McKay
bbbb644a2e Delete TestDocumentsProvider.
We can use StubProvider.

Change-Id: I8a38acd86e2ce57ff50f05710cb7f7f4c1fec63d
2015-10-26 16:09:06 -07:00
Steve McKay
01792570ba Add functional tests for FilesActivity.
Adds a bare bones test provider with dummy data.
This is basically just the bones of a test at this point.
Has just one simple test...switch list/grid modes.
Will add more tests (like manipulating the dummy data) in future CLs.

Bug: 24988170
Change-Id: Icc25718a416bc804874835c74a6d7862a52c9861
2015-10-26 12:10:40 -07:00
Steve McKay
edd0575b46 Don't try to delete files twice.
Also, apply delete in reverse order to placate RecyclerView.
TODO: Refactor this whole stack...needs some love.

Bug: 25091323, 24749296
Change-Id: I84e21c16423048bd50cd988eb1e2a36dc62b9d16
2015-10-22 09:44:48 -07:00
Steve McKay
669ebe7f63 Decouple gesture detection.
DirectoryFragment now uses an independent gesture detector.
Move early event-handling logic out of listener into the handler class.

Change-Id: Ie8a01b1507c8a8aa74355ead38feb7b802029540
2015-10-19 21:59:56 +00:00
Ben Kwa
8250db41cb Add shift-selection to DocumentsUI.
- Move the key listener from BaseActivity into DirectoryFragment, where it
belongs.
- Add code to detect the shift key during keyboard navigation, and
extend the selection in that case.

BUG=20859059

Change-Id: Ia7d3c7d4343f0185873deeaf1a35028a716b6e19
2015-10-16 15:41:59 -07:00
Steve McKay
8359eaafa2 Merge "Provide previous stack when opening new window." 2015-10-01 17:48:41 +00:00
Ben Kwa
272c02041c Consolidate unit tests.
- Move all unit tests to be run under the android framework.
- Add a unit test for ag/776629
- Make DirectoryFragment.Model tests properly simulate finalization conditions.

Change-Id: Ie33d097154d464149fd8c0c24bf66ada677db4ad
2015-09-30 15:12:52 -07:00
Steve McKay
323ee3ec09 Provide previous stack when opening new window.
EXTRA_STACK support was already in place (from CopyService).
Add "isRootUri" to DocumentsContract.

Bug: 24410611
Change-Id: Ia380030216323d1272ef247280582e4b55b83c42
2015-09-29 16:59:11 -07:00
Steve McKay
7a3b88cf56 Move State to a separate file.
Update remaining local DEBUG definitions to use Shared.DEBUG.

Change-Id: I3ed4d4b184836da161adff14bd3d9ca01b435847
2015-09-23 17:22:28 -07:00
Ben Kwa
91caed80b1 Restore more missing DirectoryFragment functionality.
- Add a material-style horizontal progress bar to DocumentsUI.  This
  replaces the old loading footer.
- Restore the view-switching code that displayed a dedicated "empty"
  view when displaying an empty directory.
- Fix tests.

Change-Id: Ifecb867f6edecbdeb37b8607d87d9797879a589d
2015-09-22 13:24:51 -07:00
Ben Kwa
5e65d1a991 Merge "Clean up unit tests." 2015-09-12 00:19:44 +00:00
Ben Kwa
ce9a87928b Clean up unit tests.
- Rework unit tests to eliminate some null checks from production code.
- Fix some flakiness in the tests resulting from a coupling between
  DirectoryFragment.Model and the application View.

Change-Id: I6b23774a5b4897f33d8641e677bda9e66d86cb96
2015-09-11 15:15:45 -07:00
Steve McKay
b99837361c Merge "Don't start band select on empty grid." 2015-09-09 19:12:20 +00:00
Steve McKay
c3ef0d6410 Don't start band select on empty grid.
Masks an issue in band controller resulting in index out of bounds exceptions.
Eliminate the need to cast helper when constructing BandController.
Improve naming of Band related classes for clarity of purpose.
Normalize some "helper" class method names.
Rename BandSelectModelTest to match existing convention for tests on inner classes.

Bug: 23905473
Change-Id: Iaf7604fb729cf563a04dc92d78b24e2fe4812abe
2015-09-09 12:11:11 -07:00
Ben Kwa
18fce3cd3c Add unit tests for DirectoryFragment.Model.
Refactor DirectoryFragment.Model to be a static class.
Introduce some unit tests.

BUG=23754695

Change-Id: Iaa064292ab26b23ac7247e49c05ba91033d84a18
2015-09-08 09:58:35 -07:00
Steve McKay
635b094997 Fix erroneous band selection start.
Fix band selection to not start when crossing off of a grid item into empty space.
This CL also introduces a MotionEvent wrapper class, since MotionEvent
can't be used in tests.
Note that this CL works around several issues with b/23793622.

Bug: 23727363
Change-Id: I010a82db3363d99f2d804db2653a3a25d8cac940
2015-09-04 12:03:37 -07:00
Kyle Horimoto
2c80257e14 Integrate band selection into the files app.
This consists of:
1) Moving both BandSelect* classes into MultiSelectManager as nested
classes. This removes extra layers of indirection and makes code easier
to comprehend.
2) Fixing an issue where band selection could start within an item
instead of only within margins between items.
3) Adding "provisional selection" support to the Selection class. This
gives band select the ability to select some items "temporarily" such
that when the band select no longer covers those items, they are
deselected.
4) Adding glue code between the classes.

Bug: 23081429, 23083146, 20669231

Change-Id: I0dc57e2c0d2ccedb3e1218f0e496de637be227a2
2015-08-27 14:43:30 -07:00
Kyle Horimoto
164752df2a Merge "BandSelectMatrix: Create matrix tracking location of RecycleView items and band selection." 2015-08-20 21:39:12 +00:00
Kyle Horimoto
8f0c98b646 BandSelectMatrix: Create matrix tracking location of RecycleView items and band selection.
Change-Id: Ia5d1011427ba1321571d999bc2425e1443e71ca6
2015-08-20 14:37:10 -07:00
Steve McKay
58efce36cd Use type inference where possible.
Normalize use of Annotations like VisibleForTesting, Nullable and so on.
Also, fix a small issue where we were not doubling the marging on cells when calculating columns for grid view.

Change-Id: Ia02f683c2682fa8d0963d13f253a359911d27965
2015-08-20 13:10:07 -07:00