Commit 1596aa4
Enable Google Photos in the device media picker (#23102)
* feat(media): disambiguate in-grid device picker by media type
When the custom media grid's "Choose from device" action allows both
visual media and other files (the editor's add-file flow), tapping it
now shows a menu anchored to the action-bar item: "Photos and videos"
opens the visual picker (which the OS surfaces as the Android Photo
Picker on Android 13+), and "Other files" opens the document/audio
chooser. Flows with a single known type (featured image, site icon,
gravatar, editor photo/video) launch their picker directly, unchanged.
This preserves the custom grid's edit-before-upload capability while
enabling Google Photos browsing via the nested device picker.
- MediaPickerFragment: carry allowedTypes on OpenSystemPicker; add an
onSystemPickerTypeChosen passthrough.
- MediaPickerViewModel: pass allowedTypes through; re-run the picker
with a narrowed type set on menu selection; restrict the {AUDIO,
DOCUMENT} context to audio + document MIME types.
- MediaPickerActivity: show the disambiguation PopupMenu anchored to the
browse action item when the selection is ambiguous.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(media): show Google Photos albums in the system photo picker
For visual-media contexts, Android 13+ routes ACTION_GET_CONTENT to the
system Photo Picker, which filters album and cloud contents by an exact
match against EXTRA_MIME_TYPES. Passing our explicit list of accepted
subtypes (image/jpeg, image/heic, ...) made Google Photos albums and
"From this device" appear empty ("No photos yet"), because cloud items
may not report a subtype in that list.
Use a broad type (image/* and/or video/*) for the PHOTO, VIDEO, and
PHOTO_OR_VIDEO contexts so the picker shows all visual media, matching
how other apps behave. Audio and document flows use the document browser
and keep the explicit accepted-types list.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* chore(release-notes): note Google Photos browsing in the media picker
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(media): avoid double-tracking device-library open in disambiguation
Picking a category from the "Photos and videos" / "Other files"
disambiguation menu re-triggered the icon click, which fired the
MEDIA_PICKER_OPEN_DEVICE_LIBRARY event a second time (the first firing
happened when the menu was shown, before any picker opened). Split the
navigation out of clickIcon so the category re-trigger navigates without
tracking again.
Also tighten the {AUDIO, DOCUMENT} chooser branch to an exact set match
instead of a containsAll subset test, so only the disambiguation
"Other files" selection routes there.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* refactor(media): move picker-type disambiguation decision into the ViewModel
The Activity previously re-derived the visual-vs-other-files
classification to decide whether to show the disambiguation menu,
duplicating the allowedTypes taxonomy the ViewModel already owns. The
ViewModel now makes that decision and emits a dedicated
ShowSystemPickerTypeMenu action; the Activity just renders the menu.
This also corrects the "device library opened" analytics timing: the
ambiguous tap now shows the menu without tracking, and the open is
tracked when the user picks a category (the point at which a picker
actually opens), so dismissing the menu no longer counts as an open.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* test(media): cover picker-type disambiguation and open-tracking timing
Update the "all supported files" test to expect the new
ShowSystemPickerTypeMenu action, and add coverage for choosing a
category (photos/videos -> PHOTO_OR_VIDEO, other files -> MEDIA_FILE)
and for the device-library open being tracked on category choice rather
than when the disambiguation menu is shown.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* refactor(media): extract system picker type resolution into a collaborator
Move the allowedTypes -> (ChooserContext, MIME types) mapping and the
visual-vs-other-files ambiguity check out of MediaPickerViewModel into a
new SystemPickerResolver. This keeps the ViewModel under detekt's
LargeClass threshold (the disambiguation additions had pushed it over)
and makes the picker-type resolution independently testable.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(media): let "Other files" browse all accepted types, not just audio/docs
The disambiguation "Other files" option scoped the document browser to
audio and documents only, which regressed the pre-disambiguation file
picker: an image or video reachable only by browsing the filesystem
(e.g. a freshly downloaded image in Downloads that the Photo Picker
hasn't surfaced) could no longer be selected. Send the full accepted-
types set so ACTION_OPEN_DOCUMENT shows images, videos, audio, and
documents, matching trunk's file picker. Remove the now-unused
audio+documents-only resolver branch.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* style(media): use `is` for ShowSystemPickerTypeMenu when-branch
Match the surrounding branches (including the OpenCameraForPhotos object)
which use `is` for their type checks, for consistency.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* docs: Clarify EditorPhotoPicker no-op
* refactor(media): make the resolver the single source of visual MIME types
The broad image/* and video/* wildcards for the Photo Picker were decided
in WPMediaUtils.getMimeTypesForChooser, which overrode and discarded the
explicit subtype lists SystemPickerResolver had computed for the same
visual contexts. That left dead data in the resolver and duplicated the
ChooserContext -> MIME mapping across two files and two languages.
Move the wildcards into the resolver (the sole producer of
OpenSystemPicker) and drop the override so prepareChooserIntent uses the
resolved MIME types directly. Behavior is unchanged; add assertions
locking in image/* and image/*+video/* for the visual contexts.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(media): show Google Photos albums in the editor's device picker
The editor's "Browse" flow (EditorPhotoPicker -> WPMediaUtils.launchMediaLibrary
-> prepareMediaLibraryIntent) still passed our explicit accepted-subtype list as
EXTRA_MIME_TYPES, the same pattern that makes the Android 13+ system Photo Picker
show Google Photos albums as empty ("No photos yet"). This route bypasses
prepareChooserIntent, so the earlier broadening fix did not cover it.
Use broad image/* and video/* wildcards so the picker shows all album/cloud media,
matching the fix already applied to the media grid's system-picker route.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 7212d29 commit 1596aa4
9 files changed
Lines changed: 221 additions & 35 deletions
File tree
- WordPress/src
- main
- java/org/wordpress/android
- ui
- mediapicker
- posts/editor
- util
- res/values
- test/java/org/wordpress/android/ui/mediapicker
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
Lines changed: 28 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
10 | 12 | | |
11 | 13 | | |
12 | 14 | | |
| |||
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
| 33 | + | |
31 | 34 | | |
32 | 35 | | |
33 | 36 | | |
| |||
248 | 251 | | |
249 | 252 | | |
250 | 253 | | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
251 | 276 | | |
252 | 277 | | |
253 | 278 | | |
| |||
311 | 336 | | |
312 | 337 | | |
313 | 338 | | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
314 | 342 | | |
315 | 343 | | |
316 | 344 | | |
| |||
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
117 | 121 | | |
118 | 122 | | |
119 | 123 | | |
| |||
402 | 406 | | |
403 | 407 | | |
404 | 408 | | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
405 | 413 | | |
406 | 414 | | |
407 | 415 | | |
| |||
Lines changed: 30 additions & 30 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | 16 | | |
18 | 17 | | |
19 | 18 | | |
| |||
22 | 21 | | |
23 | 22 | | |
24 | 23 | | |
25 | | - | |
26 | 24 | | |
27 | 25 | | |
28 | 26 | | |
| 27 | + | |
29 | 28 | | |
30 | 29 | | |
31 | 30 | | |
| |||
78 | 77 | | |
79 | 78 | | |
80 | 79 | | |
81 | | - | |
| 80 | + | |
| 81 | + | |
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| |||
500 | 500 | | |
501 | 501 | | |
502 | 502 | | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
503 | 512 | | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
504 | 517 | | |
505 | 518 | | |
506 | 519 | | |
507 | 520 | | |
508 | 521 | | |
509 | 522 | | |
510 | 523 | | |
511 | | - | |
512 | | - | |
513 | 524 | | |
514 | 525 | | |
515 | 526 | | |
| |||
525 | 536 | | |
526 | 537 | | |
527 | 538 | | |
528 | | - | |
529 | | - | |
530 | | - | |
531 | | - | |
532 | | - | |
533 | | - | |
534 | | - | |
535 | | - | |
536 | | - | |
537 | | - | |
538 | | - | |
539 | | - | |
540 | | - | |
541 | | - | |
542 | | - | |
543 | | - | |
544 | | - | |
545 | | - | |
546 | | - | |
547 | | - | |
548 | | - | |
549 | | - | |
550 | | - | |
551 | | - | |
552 | | - | |
| 539 | + | |
| 540 | + | |
553 | 541 | | |
554 | 542 | | |
555 | 543 | | |
| |||
606 | 594 | | |
607 | 595 | | |
608 | 596 | | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
609 | 609 | | |
610 | 610 | | |
611 | 611 | | |
| |||
Lines changed: 71 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
291 | 291 | | |
292 | 292 | | |
293 | 293 | | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
294 | 298 | | |
295 | 299 | | |
296 | 300 | | |
| |||
Lines changed: 5 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
261 | 261 | | |
262 | 262 | | |
263 | 263 | | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
264 | 268 | | |
265 | | - | |
| 269 | + | |
266 | 270 | | |
267 | 271 | | |
268 | 272 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3296 | 3296 | | |
3297 | 3297 | | |
3298 | 3298 | | |
| 3299 | + | |
| 3300 | + | |
3299 | 3301 | | |
3300 | 3302 | | |
3301 | 3303 | | |
| |||
0 commit comments