60 Commits

Author SHA1 Message Date
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
Steve McKay
dbec47a494 Add support for single-select mode.
This is required for some of the intent invoked modes when the
"ALLOW_MULTI_SELECT" extra is not present.

Bug: 23155138
Change-Id: Ib92512c7f1c8e906ecca98d69ff727fc865fd53e
2015-08-14 14:32:49 -07:00
Steve McKay
5353a1eb7d Start selection mode with single mouse click...
Double clicking an item opens it.
BandSelectManager tells MultiSelectManager where its selection begins
    so Shift+Click behavior can be complimentary.
BandSelectManager more actively manages selection...so it doesn't
    clear existing selection on mouse down.

Change-Id: Ibe65e793e84463d333a19f363dfb0d42c37480e3
2015-07-31 11:38:44 -07:00
Steve McKay
5542d91998 Add a TestSuite for running unittests.
Change-Id: If9777dd23d3a4cb2969e2709f98806417e412c5d
2015-07-29 14:34:57 -07:00
Steve McKay
e63dce7fbd Add SHIFT+Click selection support.
Bug: 22799741
Change-Id: Ia1221675db8c2813667bfde561c23304e4d0b31f
2015-07-29 12:07:14 -07:00
Steve McKay
b04b1648c5 Clear selection when empty space is tapped.
Change-Id: I37f3ce8ec8d6b4c69a990ad129ff37229a8d2ac2
2015-07-27 11:25:25 -07:00
Steve McKay
3b409d01b9 Push equals impl into SparseBooleanArray.
Also, implement hashcode, because it is naughty to not.

Change-Id: I2042dac6840cf07027871783a7b6763578fa805d
2015-07-22 11:53:14 -07:00
Steve McKay
4b3a13c1d0 Update DirectoryFragment to use RecyclerView.
Add MultiSelectMaanger class to manager selection on a RecyclerView instance.
There are several outstanding issues that still need to be addressed
surrounding Grid mode as the GridLayout manager doesn't support
automatic column count calculation.
Also, we're missing the puddle effect on touch...
And probably other stuff. But it all *mostly* works.
Oh, also. Footers are currently commented out.
Add traditional unit tests for MultiSelectManager.

BUG: 22225617
Change-Id: I3cd26a10683f42053556d463a5d2f0d2a0bbde84
2015-07-21 17:30:32 -07:00
Ben Kwa
cf1e2f03df resolved conflicts for merge of 3aff4fc6 to master
Change-Id: Id816d859f929de3bd0328ef3a67e2bef9fadf28b
2015-06-10 18:22:10 -07:00
Ben Kwa
77797400ec Enable apps to exclude their own roots from the DocumentsUI roots list.
- Add DocumentsContract.EXTRA_EXCLUDE_SELF (boolean extra)
- Add code to DocumentsActivity to cache the providers of the calling
  app if EXTRA_EXCLUDE_SELF is set on incoming Intents.
- Add code to RootsCache to exclude roots from the calling app.
- Add code to allow only system apps to use EXTRA_PACKAGE_NAME.

Change-Id: Ia7cc2a1a297676c7b26f6e583042a4607d8c9a4e
2015-06-10 11:24:55 -07:00
Ben Kwa
0b4a3c47c6 Add a move feature to DocumentsUI.
Add a menu item (protected behind a system property) for moving files.
Add an extra to the copy intent for transfer mode (copy/move).
Add code to CopyService to delete files after copy when in move mode.
Add tests.

BUG=20559838

Change-Id: I983f57a528327d1e7a12982b599094aad2c856ed
2015-05-15 07:48:28 -07:00
Ben Kwa
c7a01cfe15 Cherry pick beefed-up error handling in the CopyService from master. DO NOT MERGE
Send copy errors to the destination provider.
Big overhaul of tests to make them simpler.
Test that errors during copying are detected and partial copies are
cleaned up.
Test that copying empty directories works properly.

Change-Id: I3fe0e73bdc92c2b6f522857ca5631f6d03d5a666
(cherry picked from commit dae8c378d6c680ae9efa8e1202d9bc92fb0dfb11)
2015-05-04 20:28:44 +00:00
Ben Kwa
dae8c378d6 Beef up error handling in the CopyService.
Send copy errors to the destination provider.
Big overhaul of tests to make them simpler.
Test that errors during copying are detected and partial copies are
cleaned up.
Test that copying empty directories works properly.

Change-Id: I3fe0e73bdc92c2b6f522857ca5631f6d03d5a666
2015-05-04 10:26:50 -07:00