summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/src/com/android/systemui/communal/data/model/CommunalWidgetCategories.kt29
-rw-r--r--packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/CommunalEditModeViewModel.kt4
2 files changed, 22 insertions, 11 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/communal/data/model/CommunalWidgetCategories.kt b/packages/SystemUI/src/com/android/systemui/communal/data/model/CommunalWidgetCategories.kt
index 75f0badfc7cb..31ffbbd9f713 100644
--- a/packages/SystemUI/src/com/android/systemui/communal/data/model/CommunalWidgetCategories.kt
+++ b/packages/SystemUI/src/com/android/systemui/communal/data/model/CommunalWidgetCategories.kt
@@ -22,15 +22,24 @@ import android.appwidget.AppWidgetProviderInfo
* The widget categories to display on communal hub (where categories is a bitfield with values that
* match those in {@link AppWidgetProviderInfo}).
*/
-@JvmInline
-value class CommunalWidgetCategories(val categories: Int = defaultCategories) {
- fun contains(category: Int) = (categories and category) == category
+object CommunalWidgetCategories {
+ /**
+ * Categories that are allowed on communal hub.
+ * - Use "or" operator for including multiple categories.
+ */
+ val includedCategories: Int
+ get() {
+ return AppWidgetProviderInfo.WIDGET_CATEGORY_HOME_SCREEN or
+ AppWidgetProviderInfo.WIDGET_CATEGORY_KEYGUARD
+ }
- companion object {
- val defaultCategories: Int
- get() {
- return AppWidgetProviderInfo.WIDGET_CATEGORY_KEYGUARD or
- AppWidgetProviderInfo.WIDGET_CATEGORY_HOME_SCREEN
- }
- }
+ /**
+ * Categories to further filter included widgets by excluding certain opt-out categories.
+ * - WIDGET_CATEGORY_NOT_KEYGUARD: widgets opted out of displaying on keyguard like surfaces.
+ * - Use "and" operator for excluding multiple opt-out categories.
+ */
+ val excludedCategories: Int
+ get() {
+ return AppWidgetProviderInfo.WIDGET_CATEGORY_NOT_KEYGUARD.inv()
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/CommunalEditModeViewModel.kt b/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/CommunalEditModeViewModel.kt
index 52bf0004cbe4..8aba11190623 100644
--- a/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/CommunalEditModeViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/CommunalEditModeViewModel.kt
@@ -241,8 +241,9 @@ constructor(
)
putExtra(
AppWidgetManager.EXTRA_CATEGORY_FILTER,
- CommunalWidgetCategories.defaultCategories,
+ CommunalWidgetCategories.includedCategories,
)
+ putExtra(EXTRA_CATEGORY_EXCLUSION_FILTER, CommunalWidgetCategories.excludedCategories)
communalSettingsInteractor.workProfileUserDisallowedByDevicePolicy.value?.let {
putExtra(EXTRA_USER_ID_FILTER, arrayListOf(it.id))
@@ -281,6 +282,7 @@ constructor(
private const val EXTRA_DESIRED_WIDGET_WIDTH = "desired_widget_width"
private const val EXTRA_DESIRED_WIDGET_HEIGHT = "desired_widget_height"
+ private const val EXTRA_CATEGORY_EXCLUSION_FILTER = "category_exclusion_filter"
private const val EXTRA_PICKER_TITLE = "picker_title"
private const val EXTRA_PICKER_DESCRIPTION = "picker_description"
private const val EXTRA_UI_SURFACE_KEY = "ui_surface"