Closed Bug 2074254 Opened 2 months ago Closed 1 month ago

Add 3 new widgets for Firefox on Android

Categories

(Firefox for Android :: Search, task)

All
Android
task

Tracking

()

RESOLVED FIXED
160 Branch
Tracking Status
firefox160 --- fixed
firefox161 --- verified

People

(Reporter: Gela, Assigned: Gela)

References

(Blocks 1 open bug)

Details

(Whiteboard: [fxdroid][android-activation-trust])

Attachments

(1 file, 5 external files, 5 obsolete files)

1.29 MB, image/jpeg
Details

Move everything that is not specific to the widget's five layouts into a base
class in org.mozilla.fenix.widget: the pending intents, the app icon, the width
buckets and the hint text. SearchWidgetProvider keeps only the layout it picks
for a width and how it binds that layout, and stays in org.mozilla.gecko.search
because its name is part of the widget's identity on the launcher.

This is behaviour-neutral. The pending intents now travel together in a
SearchWidgetIntents holder rather than as three parameters, and the size and
layout helpers move off the companion object onto the instance, so the tests
call them on an instance.

Firefox is about to ship more than one search widget, and every caller that
refreshes the widget has to reach all of them: a new default search engine, a
new app icon or a voice search toggle changes how each one draws.

Replace SearchWidgetProvider.updateAllWidgets with a SearchWidgets registry
that holds every provider and broadcasts an update to each. The list holds the
one provider that exists today; each new widget appends itself.

This also fixes the installed flag, which onDisabled cleared whenever any one
provider lost its last instance. It now asks the registry whether the user
still has a search widget anywhere on the launcher.

A full-width search bar for the launcher: the Firefox icon, a search hint, and
a private browsing and a voice search button at the end. Unlike the original
widget it keeps one layout at every width and only swaps the hint, so it does
not need a layout per size.

BaseSearchBarWidgetProvider carries what the bar widgets share, since two more
follow: the single layout, the hint, and a set of action buttons that the
widget hides when the action behind one is unavailable. The private tab intent
goes through NewTabShortcutIntentProcessor, the path the launcher's "New
private tab" shortcut already takes.

The same full-width bar, with a row of round shortcut buttons at the end:
Google Lens, private browsing and voice search. Lens joins the set of actions
a bar widget can carry; the widget hides each button whose action is
unavailable, so a device without speech recognition or a user whose default
engine is not Google sees a shorter row rather than a dead button.

A narrow bar for users who cannot spare a full row: the Firefox icon and the
hint sit together in a pill, with the shortcut buttons beside it. The pill
leaves far less room for text than a full-width bar, so this widget keeps the
short hint at every width rather than growing to "Search the web".

Attachment #9646526 - Attachment description: WIP: Bug 2074254 - Extract BaseSearchWidgetProvider from the search widget. → WIP: Bug 2074254 - Part 1: Extract BaseSearchWidgetProvider from the search widget.
Attachment #9646527 - Attachment description: WIP: Bug 2074254 - Track and refresh the search widgets through a registry. → WIP: Bug 2074254 - Part 2: Track and refresh the search widgets through a registry.
Attachment #9646528 - Attachment description: WIP: Bug 2074254 - Add the "Search bar" widget. → WIP: Bug 2074254 - Part 3: Add the "Search bar" widget
Attachment #9646529 - Attachment description: WIP: Bug 2074254 - Add the "Search bar with shortcuts" widget. → WIP: Bug 2074254 - Part 4: Add the "Search bar with shortcuts" widget.
Attachment #9646531 - Attachment description: WIP: Bug 2074254 - Add the "Compact search bar" widget. → WIP: Bug 2074254 - Part 5: Add the "Compact search bar" widget.
Attachment #9646531 - Attachment description: WIP: Bug 2074254 - Part 5: Add the "Compact search bar" widget. → WIP: Bug 2074254 - Part 5: Add the "Compact search bar" widget
Attachment #9646526 - Attachment description: WIP: Bug 2074254 - Part 1: Extract BaseSearchWidgetProvider from the search widget. → WIP: Bug 2074254 - Part 1: Create BaseSearchWidgetProvider from the search widget
Attachment #9646527 - Attachment description: WIP: Bug 2074254 - Part 2: Track and refresh the search widgets through a registry. → WIP: Bug 2074254 - Part 2: Replace `updateAllWidgets` with a `SearchWidgets` to keep widgets up to date
Attachment #9646526 - Attachment description: WIP: Bug 2074254 - Part 1: Create BaseSearchWidgetProvider from the search widget → WIP: Bug 2074254 - Part 1: Create BaseSearchWidgetProvider
Attachment #9646526 - Attachment description: WIP: Bug 2074254 - Part 1: Create BaseSearchWidgetProvider → Bug 2074254 - Part 1: Create BaseSearchWidgetProvider
Attachment #9646527 - Attachment description: WIP: Bug 2074254 - Part 2: Replace `updateAllWidgets` with a `SearchWidgets` to keep widgets up to date → Bug 2074254 - Part 2: Replace `updateAllWidgets` with a `SearchWidgets` to keep widgets up to date
Attachment #9646528 - Attachment description: WIP: Bug 2074254 - Part 3: Add the "Search bar" widget → Bug 2074254 - Part 3: Add the "Search bar" widget
Attachment #9646529 - Attachment description: WIP: Bug 2074254 - Part 4: Add the "Search bar with shortcuts" widget. → Bug 2074254 - Part 4: Add the "Search bar with shortcuts" widget.
Attachment #9646531 - Attachment description: WIP: Bug 2074254 - Part 5: Add the "Compact search bar" widget → Bug 2074254 - Part 5: Add the "Compact search bar" widget
Attachment #9646526 - Attachment description: Bug 2074254 - Part 1: Create BaseSearchWidgetProvider → WIP: Bug 2074254 - Part 1: Create BaseSearchWidgetProvider
Attachment #9646527 - Attachment description: Bug 2074254 - Part 2: Replace `updateAllWidgets` with a `SearchWidgets` to keep widgets up to date → WIP: Bug 2074254 - Part 2: Replace `updateAllWidgets` with a `SearchWidgets` to keep widgets up to date
Attachment #9646528 - Attachment description: Bug 2074254 - Part 3: Add the "Search bar" widget → WIP: Bug 2074254 - Part 3: Add the "Search bar" widget
Attachment #9646529 - Attachment description: Bug 2074254 - Part 4: Add the "Search bar with shortcuts" widget. → WIP: Bug 2074254 - Part 4: Add the "Search bar with shortcuts" widget.
Attachment #9646531 - Attachment description: Bug 2074254 - Part 5: Add the "Compact search bar" widget → WIP: Bug 2074254 - Part 5: Add the "Compact search bar" widget

No behavior change. The Glance search bar widgets added in the next patch
reuse these intents.

Generated previews need Android 15. The system rate limits publishing, so it
runs once per app version, after visual completeness.

Android 14 and earlier cannot show generated previews, so they use these static
images, with night variants for the dark theme.

Attachment #9655475 - Attachment description: WIP: Bug 2074254 - Use Glance to add search widgets [prototype] → WIP: Bug 2074254 - Add three Glance search bar widgets
Attachment #9656338 - Attachment description: WIP: Bug 2074254 - Move the search widget intent building into SearchWidgetIntents. → WIP: Bug 2074254 - Part 1: Move the search widget intent building into SearchWidgetIntents
Attachment #9655475 - Attachment description: WIP: Bug 2074254 - Add three Glance search bar widgets → WIP: Bug 2074254 - Part 2: Add three Glance search bar widgets
Attachment #9656339 - Attachment description: WIP: Bug 2074254 - Publish generated widget picker previews for the search bar widgets. → WIP: Bug 2074254 - Part 3: Publish generated widget picker previews for the search bar widgets.
Attachment #9656340 - Attachment description: WIP: Bug 2074254 - Add widget picker preview images for the search bar widgets. → WIP: Bug 2074254 - Part 4: Add widget picker preview images for the search bar widgets
Attachment #9656338 - Attachment description: WIP: Bug 2074254 - Part 1: Move the search widget intent building into SearchWidgetIntents → Bug 2074254 - Part 1: Move the search widget intent building into SearchWidgetIntents
Attachment #9656339 - Attachment description: WIP: Bug 2074254 - Part 3: Publish generated widget picker previews for the search bar widgets. → Bug 2074254 - Part 3: Publish generated widget picker previews for the search bar widgets.
Attachment #9655475 - Attachment description: WIP: Bug 2074254 - Part 2: Add three Glance search bar widgets → Bug 2074254 - Part 2: Add three Glance search bar widgets
Attachment #9656340 - Attachment description: WIP: Bug 2074254 - Part 4: Add widget picker preview images for the search bar widgets → Bug 2074254 - Part 4: Add widget picker preview images for the search bar widgets
Blocks: 2079955
Attachment #9646531 - Attachment is obsolete: true
Attachment #9646526 - Attachment is obsolete: true
Attachment #9646527 - Attachment is obsolete: true
Attachment #9646528 - Attachment is obsolete: true
Attachment #9646529 - Attachment is obsolete: true
Pushed by gmalekpour@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/a76c38b7c7e0 https://hg.mozilla.org/integration/autoland/rev/de8182bd0d58 Part 1: Move the search widget intent building into SearchWidgetIntents r=android-reviewers,cbect https://github.com/mozilla-firefox/firefox/commit/d8ab8d0cbd86 https://hg.mozilla.org/integration/autoland/rev/8ec4a3a0a93a Part 2: Add three Glance search bar widgets r=android-reviewers,android-l10n-reviewers,parker,petru https://github.com/mozilla-firefox/firefox/commit/fd94bedf6a54 https://hg.mozilla.org/integration/autoland/rev/2a6fd98e692d Part 3: Publish generated widget picker previews for the search bar widgets. r=android-reviewers,petru https://github.com/mozilla-firefox/firefox/commit/fe3236168f11 https://hg.mozilla.org/integration/autoland/rev/695187d29a0e Part 4: Add widget picker preview images for the search bar widgets r=android-reviewers,petru https://github.com/mozilla-firefox/firefox/commit/3d5c71b38c01 https://hg.mozilla.org/integration/autoland/rev/3d73a47c3243 Part 5: stop deriving the state from callbacks and instead compute it from the system each time r=android-reviewers,petru
Flags: qe-verify+
Attached image widgets.jpg —

Verified as implemented on the Firefox for Android Nightly 160.0a1 and 161.0a1 that there are 3 extra widgets. These can be added on the device's home screen and are functioning as expected.
Tested with a Pixel 6 (Android 17), Samsung Galaxy Tab S9 Ultra (Android 16), Xiaomi Mi8 Lite (Android 10), and a Samsung Galaxy S24 (Android 16).

Flags: qe-verify+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: