[DocsUI M3] Add bottom Select and Cancel buttons to file pickers
The GET_CONTENT and OPEN_DOCUMENT pickers allow the users to pick
files, rather than folders. Previously if the user wanted to pick
the file or files they had enabled selection on, there would be a
SELECT button in the top right hand corner (in the toolbar).
We want to update this design to instead have two buttons:
Cancel and Select, in the bottom right hand corner. This is similar
to the design of the CREATE and OPEN_TREE/PICK_COPY_DESTINATION pickers.
These pickers use an additional SaveFragment/PickDirectoryFragment on
top of the PickActivity to add these buttons. We can't re-use these
fragments as their logic is quite different. The SaveFragment is
creating the picked file and the PickDirectoryFragment is picking a
folder.
Create PickFilesFragment that adds a Cancel and Select button.
The Select button is only enabled when there are files that are
selected. When the user clicks Select, those files are passed to the
PickActivity (via onDocumentPicked()/onDocumentsPicked()) just like
they were in the previous SELECT button.
PickFilesFragment can track selection through a SelectionObserver which
will notify the fragment of selection changes. We do need to be careful
here as to add a SelectionObserver we need to call
DocsSelectionHelper.addObserver(). Unfortunately the DocsSelectionHelper
gets initialised after the PickFilesFragment. Add a ResetObsever to the
DocsSelectionHelper that the PickFilesFragment can use to be notified
when the DocsSelectionHelper has been initialised (reset).
Do not show the previous SELECT button when the flag is off.
See bug for demo.
Bug: 409931248
Test: atest PickActivityTest
Test: atest ActionHandlerTest
Flag: com.android.documentsui.flags.use_material3
Change-Id: I085e527d6da0391d85f373df8bbd64140bf247a6
11 files changed