summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Shamali P <shamalip@google.com> 2024-11-05 16:04:45 +0000
committer Shamali Patwa <shamalip@google.com> 2024-11-07 14:01:29 +0000
commit1c173e96be4d3a89f5356485d2039beade516063 (patch)
tree5ac6b1f9d55d2e466531d4b3f7235b3120aede9f
parent8694df5f5931da31271148ed9a42382ff3b5c57e (diff)
Define the list entry and view holder for the view all button
Child cl updates the adapter & picker to use this list entry type. Bug: 356127021 Flag: com.android.launcher3.enable_tiered_widgets_by_default_in_picker Test: Manual Change-Id: I69e82fb7df24270dac4cc0afd003e98247280552
-rw-r--r--res/drawable/ic_more_horiz_24.xml26
-rw-r--r--res/drawable/widgets_list_expand_button_background.xml25
-rw-r--r--res/layout/widgets_list_expand_button.xml33
-rw-r--r--res/values/attrs.xml2
-rw-r--r--res/values/colors.xml12
-rw-r--r--res/values/dimens.xml6
-rw-r--r--res/values/id.xml1
-rw-r--r--res/values/strings.xml6
-rw-r--r--res/values/styles.xml12
-rw-r--r--src/com/android/launcher3/widget/model/WidgetsListExpandActionEntry.java38
-rw-r--r--src/com/android/launcher3/widget/picker/WidgetsListExpandActionViewHolderBinder.java60
11 files changed, 221 insertions, 0 deletions
diff --git a/res/drawable/ic_more_horiz_24.xml b/res/drawable/ic_more_horiz_24.xml
new file mode 100644
index 0000000000..d46827cede
--- /dev/null
+++ b/res/drawable/ic_more_horiz_24.xml
@@ -0,0 +1,26 @@
+<!--
+ ~ Copyright (C) 2024 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:tint="#000000"
+ android:viewportHeight="24"
+ android:viewportWidth="24">
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M6,10c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2zM18,10c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2zM12,10c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2z" />
+</vector>
diff --git a/res/drawable/widgets_list_expand_button_background.xml b/res/drawable/widgets_list_expand_button_background.xml
new file mode 100644
index 0000000000..068b26db43
--- /dev/null
+++ b/res/drawable/widgets_list_expand_button_background.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+ ~ Copyright (C) 2024 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+<inset xmlns:android="http://schemas.android.com/apk/res/android">
+ <ripple android:color="?android:attr/colorControlHighlight">
+ <item>
+ <shape android:shape="rectangle">
+ <corners android:radius="50dp" />
+ <solid android:color="?attr/widgetPickerExpandButtonBackgroundColor" />
+ </shape>
+ </item>
+ </ripple>
+</inset> \ No newline at end of file
diff --git a/res/layout/widgets_list_expand_button.xml b/res/layout/widgets_list_expand_button.xml
new file mode 100644
index 0000000000..17c19ac677
--- /dev/null
+++ b/res/layout/widgets_list_expand_button.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+ ~ Copyright (C) 2024 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<Button xmlns:android="http://schemas.android.com/apk/res/android"
+ style="@style/Button.Rounded.Colored"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="@dimen/widgets_list_expand_button_top_margin"
+ android:background="@drawable/widgets_list_expand_button_background"
+ android:drawablePadding="@dimen/widgets_list_expand_button_drawable_padding"
+ android:drawableStart="@drawable/ic_more_horiz_24"
+ android:drawableTint="?attr/widgetPickerExpandButtonTextColor"
+ android:maxLines="1"
+ android:minHeight="48dp"
+ android:paddingEnd="@dimen/widgets_list_expand_button_end_padding"
+ android:paddingStart="@dimen/widgets_list_expand_button_start_padding"
+ android:paddingVertical="@dimen/widgets_list_expand_button_vertical_padding"
+ android:text="@string/widgets_list_expand_button_label"
+ android:contentDescription="@string/widgets_list_expand_button_content_description"
+ android:textColor="?attr/widgetPickerExpandButtonTextColor" /> \ No newline at end of file
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 4dddb9a506..8a805c3023 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -126,6 +126,8 @@
<attr name="widgetPickerCollapseHandleColor" format="color"/>
<attr name="widgetPickerAddButtonBackgroundColor" format="color"/>
<attr name="widgetPickerAddButtonTextColor" format="color"/>
+ <attr name="widgetPickerExpandButtonBackgroundColor" format="color"/>
+ <attr name="widgetPickerExpandButtonTextColor" format="color"/>
<attr name="widgetCellTitleColor" format="color" />
<attr name="widgetCellSubtitleColor" format="color" />
diff --git a/res/values/colors.xml b/res/values/colors.xml
index fa1626ea80..4549b869e4 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -117,6 +117,12 @@
<color name="widget_picker_collapse_handle_color_light">#C4C7C5</color>
<color name="widget_picker_add_button_background_color_light">#0B57D0</color>
<color name="widget_picker_add_button_text_color_light">#0B57D0</color>
+ <color name="widget_picker_expand_button_background_color_light">
+ @color/widget_picker_secondary_surface_color_light
+ </color>
+ <color name="widget_picker_expand_button_text_color_light">
+ @color/widget_picker_header_app_title_color_light
+ </color>
<color name="widget_cell_title_color_light">@color/system_on_surface_light</color>
<color name="widget_cell_subtitle_color_light">@color/system_on_surface_variant_light</color>
@@ -138,6 +144,12 @@
<color name="widget_picker_collapse_handle_color_dark">#444746</color>
<color name="widget_picker_add_button_background_color_dark">#062E6F</color>
<color name="widget_picker_add_button_text_color_dark">#FFFFFF</color>
+ <color name="widget_picker_expand_button_background_color_dark">
+ @color/widget_picker_secondary_surface_color_dark
+ </color>
+ <color name="widget_picker_expand_button_text_color_dark">
+ @color/widget_picker_header_app_title_color_dark
+ </color>
<color name="widget_cell_title_color_dark">@color/system_on_surface_dark</color>
<color name="widget_cell_subtitle_color_dark">@color/system_on_surface_variant_dark</color>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index d4773c3c9f..d1dde3fe4a 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -230,6 +230,12 @@
<dimen name="widget_list_top_bottom_corner_radius">28dp</dimen>
<dimen name="widget_list_content_corner_radius">4dp</dimen>
+ <!-- Button that expands the widget apps list in the widget picker. -->
+ <dimen name="widgets_list_expand_button_drawable_padding">8dp</dimen>
+ <dimen name="widgets_list_expand_button_start_padding">16dp</dimen>
+ <dimen name="widgets_list_expand_button_end_padding">24dp</dimen>
+ <dimen name="widgets_list_expand_button_vertical_padding">16dp</dimen>
+ <dimen name="widgets_list_expand_button_top_margin">14dp</dimen>
<dimen name="widget_list_header_view_vertical_padding">20dp</dimen>
<dimen name="widget_list_entry_spacing">2dp</dimen>
diff --git a/res/values/id.xml b/res/values/id.xml
index 28496b5a19..67692d8fee 100644
--- a/res/values/id.xml
+++ b/res/values/id.xml
@@ -19,6 +19,7 @@
<item type="id" name="view_type_widgets_space" />
<item type="id" name="view_type_widgets_list" />
<item type="id" name="view_type_widgets_header" />
+ <item type="id" name="view_type_widgets_list_expand" />
<!-- Accessibility actions -->
<item type="id" name="action_remove" />
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 746bd7eb74..f5af3393b2 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -157,6 +157,12 @@
<!-- Accessibility content description for the button that adds a widget to the home screen. The
placeholder text is the widget name. [CHAR_LIMIT=none] -->
<string name="widget_add_button_content_description">Add <xliff:g id="widget_name" example="Calendar month view">%1$s</xliff:g> widget</string>
+ <!-- Text on the button that enables users to expand the widgets list to see all widget apps besides the default ones displayed. [CHAR_LIMIT=15] -->
+ <string name="widgets_list_expand_button_label">Show all</string>
+ <!-- Accessibility content description for the button that enables users to expand the widgets list to see all widget apps besides the default ones displayed. [CHAR_LIMIT=none] -->
+ <string name="widgets_list_expand_button_content_description">Show all widgets</string>
+ <!-- Accessibility announcement to indicate to the users that widgets list is now expanded -->
+ <string name="widgets_list_expanded">Showing all widgets</string>
<!-- Text on an educational tip on widget informing users that they can change widget settings.
[CHAR_LIMIT=NONE] -->
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 728c523542..6d3579b1a9 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -275,6 +275,12 @@
@color/widget_picker_add_button_background_color_light</item>
<item name="widgetPickerAddButtonTextColor">
@color/widget_picker_add_button_text_color_light</item>
+ <item name="widgetPickerExpandButtonBackgroundColor">
+ @color/widget_picker_expand_button_background_color_light
+ </item>
+ <item name="widgetPickerExpandButtonTextColor">
+ @color/widget_picker_expand_button_text_color_light
+ </item>
<item name="widgetCellTitleColor">
@color/widget_cell_title_color_light</item>
<item name="widgetCellSubtitleColor">
@@ -316,6 +322,12 @@
@color/widget_picker_add_button_background_color_dark</item>
<item name="widgetPickerAddButtonTextColor">
@color/widget_picker_add_button_text_color_dark</item>
+ <item name="widgetPickerExpandButtonBackgroundColor">
+ @color/widget_picker_expand_button_background_color_dark
+ </item>
+ <item name="widgetPickerExpandButtonTextColor">
+ @color/widget_picker_expand_button_text_color_dark
+ </item>
<item name="widgetCellTitleColor">
@color/widget_cell_title_color_dark</item>
<item name="widgetCellSubtitleColor">
diff --git a/src/com/android/launcher3/widget/model/WidgetsListExpandActionEntry.java b/src/com/android/launcher3/widget/model/WidgetsListExpandActionEntry.java
new file mode 100644
index 0000000000..8c84030380
--- /dev/null
+++ b/src/com/android/launcher3/widget/model/WidgetsListExpandActionEntry.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.launcher3.widget.model;
+
+import android.os.Process;
+
+import com.android.launcher3.model.data.PackageItemInfo;
+
+import java.util.Collections;
+
+/**
+ * Binds the section to be displayed at the bottom of the widgets list that enables user to expand
+ * and view all the widget apps including non-default. Bound when
+ * {@link WidgetsListExpandActionEntry} exists in the list on adapter.
+ */
+public class WidgetsListExpandActionEntry extends WidgetsListBaseEntry {
+
+ public WidgetsListExpandActionEntry() {
+ super(/*pkgItem=*/ new PackageItemInfo(/* packageName= */ "", Process.myUserHandle()),
+ /*titleSectionName=*/ "",
+ /*items=*/ Collections.EMPTY_LIST);
+ mPkgItem.title = "";
+ }
+}
diff --git a/src/com/android/launcher3/widget/picker/WidgetsListExpandActionViewHolderBinder.java b/src/com/android/launcher3/widget/picker/WidgetsListExpandActionViewHolderBinder.java
new file mode 100644
index 0000000000..288c4567f1
--- /dev/null
+++ b/src/com/android/launcher3/widget/picker/WidgetsListExpandActionViewHolderBinder.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.launcher3.widget.picker;
+
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+
+import com.android.launcher3.R;
+import com.android.launcher3.recyclerview.ViewHolderBinder;
+import com.android.launcher3.widget.model.WidgetsListExpandActionEntry;
+
+import java.util.List;
+
+/**
+ * Creates and populates views for the {@link WidgetsListExpandActionEntry}.
+ */
+public class WidgetsListExpandActionViewHolderBinder implements
+ ViewHolderBinder<WidgetsListExpandActionEntry, RecyclerView.ViewHolder> {
+ @NonNull
+ View.OnClickListener mExpandListClickListener;
+ private final LayoutInflater mLayoutInflater;
+
+ public WidgetsListExpandActionViewHolderBinder(
+ @NonNull LayoutInflater layoutInflater,
+ @NonNull View.OnClickListener expandListClickListener) {
+ mLayoutInflater = layoutInflater;
+ mExpandListClickListener = expandListClickListener;
+ }
+
+ @Override
+ public RecyclerView.ViewHolder newViewHolder(ViewGroup parent) {
+ return new RecyclerView.ViewHolder(mLayoutInflater.inflate(
+ R.layout.widgets_list_expand_button, parent, false)) {
+ };
+ }
+
+ @Override
+ public void bindViewHolder(RecyclerView.ViewHolder viewHolder,
+ WidgetsListExpandActionEntry data, int position, List<Object> payloads) {
+ viewHolder.itemView.setOnClickListener(mExpandListClickListener);
+ }
+}