98 Commits

Author SHA1 Message Date
Aga Wronska
0950df196f Add tests for rename documents feature
- Add helper class for the Ui tests. It creates basic test environment.
      It is intermediate layer between UiBot/DocumentsProviderHelper and UiTest classes.
    - Refactor SearchView tests
    - Add renaming support in the test DocumentsProvider
    - Add renaming tests

Bug=26799799

Change-Id: I2849913a1addabff0087bb06b80f36de7cb144f3
2016-02-01 10:36:02 -08:00
Tomasz Mikolajewski
748ea8cc78 Show a warning notification and a dialog in case of conversion when copying.
Change-Id: I451b0944069deb5f0b49b54c514e7761be449e3d
2016-01-28 13:12:55 +09:00
Tomasz Mikolajewski
b8436af1b8 Wire multi-parents support for moving to DocumentsUI.
Bug: 26481380

Change-Id: Ief7db8f8abeca94e47832995fd0e2a6f31bfbc93
2016-01-27 10:40:04 +09:00
Steve McKay
2ed9f813b0 Enabled content validation in file ops tests.
Authority isn't set by default. Wrapped in RootCursorWrapper.

Bug: 26687509
Change-Id: Ie99dbd799914f03bf7beac540b64df67c1e637a6
2016-01-25 19:01:38 -08:00
Steve McKay
d0086a4960 Fix broken SearchViewUiTest.
Change-Id: I0df509ff6307f9aeb32d9fbfaaf68de59507e3f7
2016-01-22 16:23:32 -08:00
Aga Wronska
31f97bc4ee Merge "Add support for renaming documents" 2016-01-22 23:26:35 +00:00
Aga Wronska
3b327ef9f9 Add support for renaming documents
- Add rename dialog
- Add rename menu option
- Enable rename menu option only when renaming supported
- Rename files and directories
- Present error message if renaming fails

Bug: 20493815
Change-Id: Ic7386d14e3876655fb19245b9a90b4c67a4febb4
2016-01-22 13:36:40 -08:00
Tomasz Mikolajewski
87156dc8ae Do not allow to move virtual files using conversion.
Change-Id: Ia792bc766272645f7bf8a2683c22895b03df3a1f
2016-01-22 13:50:13 +09:00
Ben Kwa
29852339f1 Merge "Fix band selection problems." 2016-01-22 02:09:07 +00:00
Ben Kwa
22f479dad3 Fix band selection problems.
- Remove whitespace from the GridModel, which isn't set up to deal with
  it.

- Use absolute column bounds whenever translating the band rectangle
  into column indices.  This necessitates additional binary searching,
  but is necessary when columns aren't fully populated, which happens
  with the new grid layout.

BUG=26512327

Change-Id: I5016d5de8f00c366f575f0722739007ac1612923
2016-01-21 18:08:00 -08:00
Steve McKay
17fefe5b1a Merge "Move delete support into FileOperationService." 2016-01-21 21:38:41 +00:00
Ben Kwa
760199ea72 Merge "Rework selection handling for items in the DirectoryFragment." 2016-01-21 21:28:46 +00:00
Ben Kwa
0436a75721 Rework selection handling for items in the DirectoryFragment.
- Remove the gesture detector from the MultiSelectManager, and
  consolidate gesture detection and event dispatch logic in
  DirectoryFragment.GestureListener.

- Route single-tap events through the DocumentHolder, so that it can
  apply view-specific logic, like making a tap on the item's icon
  select rather than activate.

- Consolidate event handling logic in the ItemEventListener.

- Add new unit tests for DocumentHandler.

BUG=24326546

Change-Id: Id15cdd11b13e4c063c1baff95aa8ee09c190d6c3
2016-01-21 12:18:01 -08:00
Steve McKay
3564543e1e Move delete support into FileOperationService.
Refactor Jobs to work with files from multiple providers.
Don't shut down threadpool until service#onDestroy is called.

Bug: 26696797, 26462789, 26567205, 25162803, 26714663
Change-Id: Id43e8e3dc2294cd07dcd6a3477b19efb298c260f
2016-01-21 12:16:04 -08:00
Steve McKay
cdcf99bc08 Merge "Support for concurrent file operations." 2016-01-20 20:05:02 +00:00
Steve McKay
ecbf3c504c Support for concurrent file operations.
Swith to using a regular service.
Perform file ops on thread pool.
Separate Job tests from service test.
Check in service test that wake lock is released and service shut down.
Increase copy buffer size to 32k (suggested by mtomasz).
Rework Copy testing to use an out-of-process provider (which has caused a content validation problem).
Move copy testing logic into base test and share it with Move testing.

Change-Id: I2f97d6c9f23c205b0f39ca6ba93bec119d63c80b
2016-01-20 11:45:47 -08:00
Aga Wronska
f6a31d319f Refactor SearchManager:
- Move SearchManager out of BaseActivity.
- Refactor usage of onCurrentDirectoryChanged(int anim).
- Cancel search when directory changes.
- Enable testing for cancelling search when directory changes.
- Avoid recreating action bar when only the content of the directory is
  changed.

BUG=26495573

Change-Id: I1400090fcb529ad3905018d1640fdb7416542989
2016-01-19 13:29:09 -08:00
Aga Wronska
619f3be0fa Add Search View UI tests
Change-Id: I67726e7764ec147c5987cbf737f763c3146f5766
2016-01-15 09:49:36 -08:00
Ben Kwa
d20d01061c Merge "Increase the stability of sorting in the Model." 2016-01-09 01:05:06 +00:00
Ben Kwa
e2564f9f19 Increase the stability of sorting in the Model.
This is necessary to prevent UI thrash (items continually shuffling
around) when the underlying Provider doesn't return its contents in a
stable order from one load event to another (DownloadStorageProvider is
an example).

BUG=26417297

Change-Id: Ie99e56b610f5d01d5318be07c0379b506c828735
2016-01-08 16:59:20 -08:00
Ben Kwa
433df5c865 Merge "Fix home key behaviour when there are no subdirs in cwd." 2016-01-08 20:58:24 +00:00
Ben Kwa
2ad8214916 Merge "Fix shift-selection." 2016-01-08 20:57:40 +00:00
Ben Kwa
2613802d4b Fix shift-selection.
The shift-selection code was failing to correctly anchor the selection
prior to shifting focus.  This meant that the first shift-navigation
event (i.e. starting from non-selection mode) would not select the right
set of stuff.

BUG=26459949

Change-Id: I62ed959fb549198c503cfd2131d2499f9a61f7e5
2016-01-08 12:56:10 -08:00
Ben Kwa
f5ce1035d4 Fix home key behaviour when there are no subdirs in cwd.
The divider is extraneous when a directory contains only subdirs, or
only files.  The "only dirs" case works (the divider is omitted) but in
the case where a directory contains only files, a divider gets inserted
at position 0, which messes up navigation.  This change adds code to
avoid adding a divider when a directory contains only files.

BUG=26406821

Change-Id: I7333911baf94e34bf428a3dd18b55694a73e3a62
2016-01-08 11:36:55 -08:00
Daichi Hirono
3360de1ea8 Merge "Fix document stack." 2016-01-08 05:34:59 +00:00
Daichi Hirono
7f34b20a70 Fix document stack.
We need to add document to stack by using 'push' method instead of 'add'
method.

BUG=26437613

Change-Id: I3e4ac6b0d03cacbe2d6cdd93443ce1c96c8c47d9
2016-01-08 14:33:11 +09:00
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