Skip to content

[Implementation] Widget 1: Search + Duck.ai #6576

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: feature/ana/add_duck_ai_entry_points_to_widgets_plus_additional_widgets
Choose a base branch
from

Conversation

anikiki
Copy link
Contributor

@anikiki anikiki commented Aug 13, 2025

Task/Issue URL: https://app.asana.com/1/137249556945/project/276630244458377/task/1210378258410691?focus=true

Description

This PR updates the search widget to include Duck.ai functionality by:

  • Adding a new Duck.ai icon to the search widget
  • Replacing RelativeLayout with LinearLayout for better control of widget elements
  • Creating a SearchWidgetConfigurator to handle widget configuration based on feature availability
  • Adding a vertical separator between voice search and Duck.ai icons
  • Implementing a broadcast receiver to update widgets when Duck.ai becomes available
  • Increasing corner radius for the widget background for a more modern look
  • Updating the search icon to a 24dp version for better visual consistency
  • Adjusting padding and layout dimensions for improved appearance

Steps to test this PR

Widget UI Updates

  • Verify the Simple Search Widget Light and the Simple Search Widget Dark look as in Figma.
  • Verify the Simple Search Widget Light and the Simple Search Widget Dark behave as expected. See test cases in Asana.

UI changes

See Asana Task.


Copy link
Contributor Author

anikiki commented Aug 13, 2025

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@anikiki anikiki changed the title Added Duck.ai entry points to search widget and updated UI. No logic implemented yet. [Implementation] Widget 1: Search + Duck.ai Aug 13, 2025
@anikiki anikiki marked this pull request as ready for review August 15, 2025 11:12
TestCase(3, 465),
TestCase(4, 466),
TestCase(3, 466),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We changed some of the dimens, so I updated the test to match the current expected behavior.


val views = RemoteViews(context.packageName, layoutId)
views.setViewVisibility(R.id.searchInputBox, if (shouldShowHint) View.VISIBLE else View.INVISIBLE)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed all this as in the new requirements we don't hide the hint.

@@ -20,7 +20,7 @@
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:initialKeyguardLayout="@layout/search_widget_dark"
android:initialLayout="@layout/search_widget_dark"
android:minWidth="314dp"
android:minWidth="250dp"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New requirements.

@@ -20,7 +20,7 @@
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:initialKeyguardLayout="@layout/search_widget_light"
android:initialLayout="@layout/search_widget_light"
android:minWidth="314dp"
android:minWidth="250dp"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New requirements.

@@ -141,7 +141,7 @@
<dimen name="searchWidgetSearchBarSideMargin">16dp</dimen>
<dimen name="searchWidgetFavoriteItemContainerWidth">64dp</dimen>
<dimen name="searchWidgetFavoriteItemContainerHeight">78dp</dimen>
<dimen name="searchWidgetSearchBarHeight">46dp</dimen>
<dimen name="searchWidgetSearchBarHeight">48dp</dimen>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New requirements.

*
* @return Intent to open DuckChat.
*/
fun openDuckChatIntent(): Intent?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opened a proposal for the changes in this file.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements the first widget enhancement by integrating Duck.ai functionality into the search widget. The implementation replaces the RelativeLayout with LinearLayout for better control, adds Duck.ai and voice search icons with a separator, and includes dynamic configuration based on feature availability.

Key changes:

  • Widget layout restructure from RelativeLayout to LinearLayout with new Duck.ai icon and separator
  • SearchWidgetConfigurator class to handle dynamic widget configuration based on voice search and Duck.ai availability
  • Broadcast receiver system to update widgets when Duck.ai becomes available or settings change
  • Visual improvements including larger corner radius, updated icons, and better spacing

Reviewed Changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
app/src/main/res/layout/search_widget_*.xml Layout restructure from RelativeLayout to LinearLayout with new Duck.ai icon, separator, and updated styling
app/src/main/java/com/duckduckgo/widget/SearchWidgetConfigurator.kt New class handling dynamic widget configuration based on feature availability
duckchat/duckchat-api/src/main/java/com/duckduckgo/duckchat/api/DuckChat.kt Added createDuckChatIntent() method and moved isDuckChatUserEnabled() from internal interface
app/src/main/java/com/duckduckgo/widget/DuckAiSearchWidgetUpdaterReceiver.kt Broadcast receiver to update widgets when Duck.ai availability changes
duckchat/duckchat-impl/src/main/java/com/duckduckgo/duckchat/impl/repository/DuckChatFeatureRepository.kt Widget update broadcast on first Duck.ai usage

@anikiki anikiki force-pushed the feature/ana/add_duck_ai_entry_points_to_widgets_plus_additional_widgets branch from 4f9b5e7 to 6906ff5 Compare August 15, 2025 11:54
@anikiki anikiki force-pushed the feature/ana/implementation_widget_1_search_and_duck_ai branch from 40bb1d5 to 2c22a09 Compare August 15, 2025 11:54
Comment on lines +44 to +51
fun configureWidget(
context: Context,
remoteViews: RemoteViews,
appWidgetManager: AppWidgetManager,
appWidgetId: Int,
fromFavWidget: Boolean,
) {
appCoroutineScope.launch(dispatcherProvider.io()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ Would it be better to follow structured concurrency principles and mark this function suspend instead of launching? That way the caller gets to decide the scope and lifecycle.

Copy link
Contributor

@mikescamell mikescamell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! LGTM :shipit:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants