From cdc26951ff271d951a34d2cccbc0b7bda352606f Mon Sep 17 00:00:00 2001 From: Willie Koomson Date: Thu, 8 Feb 2024 19:16:07 +0000 Subject: [PATCH] Add tap-to-add button to widget picker This change introduces an "Add" button that appears when a widget preview is clicked in the widget picker. This button disappears when the preview is clicked again, or another preview is clicked. When the button is pressed, it adds that widget to the picker. The add button is available in the app-specific widget sheet as well. Bug: 323886237 Test: Manual Flag: ACONFIG com.android.launcher3.enable_widget_tap_to_add DEVELOPMENT Change-Id: I86a8a4c22119960c54a885fd2efeb91916b4f9a0 --- aconfig/launcher.aconfig | 7 ++ res/drawable/ic_plus.xml | 24 +++++ .../widget_cell_add_button_background.xml | 28 ++++++ res/layout/widget_cell_content.xml | 98 ++++++++++++------- res/values-night-v31/colors.xml | 4 + res/values-v31/colors.xml | 4 + res/values/attrs.xml | 2 + res/values/colors.xml | 4 + res/values/dimens.xml | 4 + res/values/strings.xml | 12 +++ res/values/styles.xml | 8 ++ .../launcher3/logging/StatsLogManager.java | 3 + .../launcher3/widget/BaseWidgetSheet.java | 47 ++++++++- .../android/launcher3/widget/WidgetCell.java | 87 +++++++++++++++- .../launcher3/widget/GeneratedPreviewTest.kt | 10 +- .../WidgetsListTableViewHolderBinderTest.java | 4 +- 16 files changed, 303 insertions(+), 43 deletions(-) create mode 100644 res/drawable/ic_plus.xml create mode 100644 res/drawable/widget_cell_add_button_background.xml diff --git a/aconfig/launcher.aconfig b/aconfig/launcher.aconfig index 4de1c960de..a724602e7b 100644 --- a/aconfig/launcher.aconfig +++ b/aconfig/launcher.aconfig @@ -215,3 +215,10 @@ flag { description: "Enables the Home gesture animation" bug: "308801666" } + +flag { + name: "enable_widget_tap_to_add" + namespace: "launcher" + description: "Enables an add button in the widget picker" + bug: "323886237" +} diff --git a/res/drawable/ic_plus.xml b/res/drawable/ic_plus.xml new file mode 100644 index 0000000000..3ab926aade --- /dev/null +++ b/res/drawable/ic_plus.xml @@ -0,0 +1,24 @@ + + + + + diff --git a/res/drawable/widget_cell_add_button_background.xml b/res/drawable/widget_cell_add_button_background.xml new file mode 100644 index 0000000000..860d1cdd02 --- /dev/null +++ b/res/drawable/widget_cell_add_button_background.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/res/layout/widget_cell_content.xml b/res/layout/widget_cell_content.xml index 0c606f6f8f..106c5b7d56 100644 --- a/res/layout/widget_cell_content.xml +++ b/res/layout/widget_cell_content.xml @@ -45,40 +45,70 @@ android:layout_margin="@dimen/profile_badge_margin"/> - - - - - + android:layout_height="wrap_content"> + + + - + + - \ No newline at end of file + + + +