Loading go/src/com/android/launcher3/model/WidgetsModel.java +4 −3 Original line number Diff line number Diff line Loading @@ -79,12 +79,13 @@ public class WidgetsModel { } public WidgetItem getWidgetProviderInfoByProviderName( ComponentName providerName) { ComponentName providerName, UserHandle user) { return null; } /** Returns {@link PackageItemInfo} of a pending widget. */ public static PackageItemInfo newPendingItemInfo(ComponentName provider) { return new PackageItemInfo(provider.getPackageName()); public static PackageItemInfo newPendingItemInfo( Context context, ComponentName provider, UserHandle userHandle) { return new PackageItemInfo(provider.getPackageName(), userHandle); } } No newline at end of file res/values/attrs.xml +14 −0 Original line number Diff line number Diff line Loading @@ -260,4 +260,18 @@ <declare-styleable name="WidgetsListRowHeader"> <attr name="appIconSize" format="dimension" /> </declare-styleable> <declare-styleable name="WidgetSections"> <!-- Component name of an app widget provider. --> <attr name="provider" format="string" /> <!-- If true, keep the app widget under its app listing in addition to the widget category in the widget picker. Defaults to false if not specified. --> <attr name="alsoKeepInApp" format="boolean" /> <!-- The category of an app widget provider. Defaults to -1 if not specified. --> <attr name="category" format="integer" /> <!-- The title name of a widget category. --> <attr name="sectionTitle" format="reference" /> <!-- The icon drawable of a widget category. --> <attr name="sectionDrawable" format="reference" /> </declare-styleable> </resources> res/xml/widget_sections.xml 0 → 100644 +25 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2021 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. --> <widget-sections xmlns:launcher="http://schemas.android.com/apk/res-auto"> <section launcher:category="0" launcher:sectionDrawable="@drawable/ic_conversations_widget_category" launcher:sectionTitle="@string/widget_category_conversations"> <widget launcher:provider="com.android.systemui/.people.widget.PeopleSpaceWidgetProvider" /> </section> </widget-sections> No newline at end of file src/com/android/launcher3/graphics/LauncherPreviewRenderer.java +1 −1 Original line number Diff line number Diff line Loading @@ -352,7 +352,7 @@ public class LauncherPreviewRenderer extends ContextWrapper private void inflateAndAddWidgets(LauncherAppWidgetInfo info, WidgetsModel widgetsModel) { WidgetItem widgetItem = widgetsModel.getWidgetProviderInfoByProviderName( info.providerName); info.providerName, info.user); if (widgetItem == null) { return; } Loading src/com/android/launcher3/icons/IconCache.java +9 −4 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.launcher3.icons; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import static com.android.launcher3.util.Executors.MODEL_EXECUTOR; import static com.android.launcher3.widget.WidgetSections.NO_CATEGORY; import static java.util.stream.Collectors.groupingBy; Loading Loading @@ -46,7 +47,6 @@ import androidx.annotation.NonNull; import com.android.launcher3.InvariantDeviceProfile; import com.android.launcher3.LauncherFiles; import com.android.launcher3.R; import com.android.launcher3.Utilities; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.icons.ComponentWithLabel.ComponentCachingLogic; Loading @@ -63,6 +63,8 @@ import com.android.launcher3.shortcuts.ShortcutKey; import com.android.launcher3.util.InstantAppResolver; import com.android.launcher3.util.PackageUserKey; import com.android.launcher3.util.Preconditions; import com.android.launcher3.widget.WidgetSections; import com.android.launcher3.widget.WidgetSections.WidgetSection; import java.util.Collections; import java.util.List; Loading Loading @@ -275,7 +277,8 @@ public class IconCache extends BaseIconCache { getTitleAndIcon(appInfo, false); return appInfo.bitmap; } else { PackageItemInfo pkgInfo = new PackageItemInfo(shortcutInfo.getPackage()); PackageItemInfo pkgInfo = new PackageItemInfo(shortcutInfo.getPackage(), shortcutInfo.getUserHandle()); getTitleAndIconForApp(pkgInfo, false); return pkgInfo.bitmap; } Loading Loading @@ -409,8 +412,10 @@ public class IconCache extends BaseIconCache { CacheEntry entry = getEntryForPackageLocked( infoInOut.packageName, infoInOut.user, useLowResIcon); applyCacheEntry(entry, infoInOut); if (infoInOut.category == PackageItemInfo.CONVERSATIONS) { infoInOut.title = mContext.getString(R.string.widget_category_conversations); if (infoInOut.widgetCategory != NO_CATEGORY) { WidgetSection widgetSection = WidgetSections.getWidgetSections(mContext) .get(infoInOut.widgetCategory); infoInOut.title = mContext.getString(widgetSection.mSectionTitle); infoInOut.contentDescription = mPackageManager.getUserBadgedLabel( infoInOut.title, infoInOut.user); } Loading Loading
go/src/com/android/launcher3/model/WidgetsModel.java +4 −3 Original line number Diff line number Diff line Loading @@ -79,12 +79,13 @@ public class WidgetsModel { } public WidgetItem getWidgetProviderInfoByProviderName( ComponentName providerName) { ComponentName providerName, UserHandle user) { return null; } /** Returns {@link PackageItemInfo} of a pending widget. */ public static PackageItemInfo newPendingItemInfo(ComponentName provider) { return new PackageItemInfo(provider.getPackageName()); public static PackageItemInfo newPendingItemInfo( Context context, ComponentName provider, UserHandle userHandle) { return new PackageItemInfo(provider.getPackageName(), userHandle); } } No newline at end of file
res/values/attrs.xml +14 −0 Original line number Diff line number Diff line Loading @@ -260,4 +260,18 @@ <declare-styleable name="WidgetsListRowHeader"> <attr name="appIconSize" format="dimension" /> </declare-styleable> <declare-styleable name="WidgetSections"> <!-- Component name of an app widget provider. --> <attr name="provider" format="string" /> <!-- If true, keep the app widget under its app listing in addition to the widget category in the widget picker. Defaults to false if not specified. --> <attr name="alsoKeepInApp" format="boolean" /> <!-- The category of an app widget provider. Defaults to -1 if not specified. --> <attr name="category" format="integer" /> <!-- The title name of a widget category. --> <attr name="sectionTitle" format="reference" /> <!-- The icon drawable of a widget category. --> <attr name="sectionDrawable" format="reference" /> </declare-styleable> </resources>
res/xml/widget_sections.xml 0 → 100644 +25 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2021 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. --> <widget-sections xmlns:launcher="http://schemas.android.com/apk/res-auto"> <section launcher:category="0" launcher:sectionDrawable="@drawable/ic_conversations_widget_category" launcher:sectionTitle="@string/widget_category_conversations"> <widget launcher:provider="com.android.systemui/.people.widget.PeopleSpaceWidgetProvider" /> </section> </widget-sections> No newline at end of file
src/com/android/launcher3/graphics/LauncherPreviewRenderer.java +1 −1 Original line number Diff line number Diff line Loading @@ -352,7 +352,7 @@ public class LauncherPreviewRenderer extends ContextWrapper private void inflateAndAddWidgets(LauncherAppWidgetInfo info, WidgetsModel widgetsModel) { WidgetItem widgetItem = widgetsModel.getWidgetProviderInfoByProviderName( info.providerName); info.providerName, info.user); if (widgetItem == null) { return; } Loading
src/com/android/launcher3/icons/IconCache.java +9 −4 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.launcher3.icons; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import static com.android.launcher3.util.Executors.MODEL_EXECUTOR; import static com.android.launcher3.widget.WidgetSections.NO_CATEGORY; import static java.util.stream.Collectors.groupingBy; Loading Loading @@ -46,7 +47,6 @@ import androidx.annotation.NonNull; import com.android.launcher3.InvariantDeviceProfile; import com.android.launcher3.LauncherFiles; import com.android.launcher3.R; import com.android.launcher3.Utilities; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.icons.ComponentWithLabel.ComponentCachingLogic; Loading @@ -63,6 +63,8 @@ import com.android.launcher3.shortcuts.ShortcutKey; import com.android.launcher3.util.InstantAppResolver; import com.android.launcher3.util.PackageUserKey; import com.android.launcher3.util.Preconditions; import com.android.launcher3.widget.WidgetSections; import com.android.launcher3.widget.WidgetSections.WidgetSection; import java.util.Collections; import java.util.List; Loading Loading @@ -275,7 +277,8 @@ public class IconCache extends BaseIconCache { getTitleAndIcon(appInfo, false); return appInfo.bitmap; } else { PackageItemInfo pkgInfo = new PackageItemInfo(shortcutInfo.getPackage()); PackageItemInfo pkgInfo = new PackageItemInfo(shortcutInfo.getPackage(), shortcutInfo.getUserHandle()); getTitleAndIconForApp(pkgInfo, false); return pkgInfo.bitmap; } Loading Loading @@ -409,8 +412,10 @@ public class IconCache extends BaseIconCache { CacheEntry entry = getEntryForPackageLocked( infoInOut.packageName, infoInOut.user, useLowResIcon); applyCacheEntry(entry, infoInOut); if (infoInOut.category == PackageItemInfo.CONVERSATIONS) { infoInOut.title = mContext.getString(R.string.widget_category_conversations); if (infoInOut.widgetCategory != NO_CATEGORY) { WidgetSection widgetSection = WidgetSections.getWidgetSections(mContext) .get(infoInOut.widgetCategory); infoInOut.title = mContext.getString(widgetSection.mSectionTitle); infoInOut.contentDescription = mPackageManager.getUserBadgedLabel( infoInOut.title, infoInOut.user); } Loading