summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Darrell Shi <darrellshi@google.com> 2023-11-17 15:25:55 +0800
committer Darrell Shi <darrellshi@google.com> 2023-11-17 15:25:55 +0800
commit16d5fce56dc902f596c4413614339db774e0521d (patch)
tree4d5fcd34a27126796ff994ac1ee7df8c0fa11699
parent630a48f90a1159b3befb9721b830b84510ba33bd (diff)
Clean up widget wrapper
Bug: 306471933 Test: NA Flag: NA Change-Id: I78481006f01b7e4a96794bc6f97fb0810f914a77
-rw-r--r--packages/SystemUI/res/values/ids.xml1
-rw-r--r--packages/SystemUI/src/com/android/systemui/communal/ui/adapter/CommunalWidgetViewAdapter.kt80
-rw-r--r--packages/SystemUI/src/com/android/systemui/communal/ui/view/CommunalWidgetWrapper.kt31
3 files changed, 0 insertions, 112 deletions
diff --git a/packages/SystemUI/res/values/ids.xml b/packages/SystemUI/res/values/ids.xml
index 74d435d18823..1838795a57d6 100644
--- a/packages/SystemUI/res/values/ids.xml
+++ b/packages/SystemUI/res/values/ids.xml
@@ -230,7 +230,6 @@
<!-- Communal mode -->
<item type="id" name="communal_hub" />
- <item type="id" name="communal_widget_wrapper" />
<!-- Values assigned to the views in Biometrics Prompt -->
<item type="id" name="pin_pad"/>
diff --git a/packages/SystemUI/src/com/android/systemui/communal/ui/adapter/CommunalWidgetViewAdapter.kt b/packages/SystemUI/src/com/android/systemui/communal/ui/adapter/CommunalWidgetViewAdapter.kt
deleted file mode 100644
index 0daf7b5610e8..000000000000
--- a/packages/SystemUI/src/com/android/systemui/communal/ui/adapter/CommunalWidgetViewAdapter.kt
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2023 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.systemui.communal.ui.adapter
-
-import android.appwidget.AppWidgetHost
-import android.appwidget.AppWidgetManager
-import android.content.Context
-import android.util.SizeF
-import com.android.systemui.communal.shared.model.CommunalAppWidgetInfo
-import com.android.systemui.communal.ui.view.CommunalWidgetWrapper
-import com.android.systemui.dagger.qualifiers.Application
-import com.android.systemui.log.LogBuffer
-import com.android.systemui.log.core.Logger
-import com.android.systemui.log.dagger.CommunalLog
-import javax.inject.Inject
-import kotlinx.coroutines.flow.Flow
-import kotlinx.coroutines.flow.map
-
-/** Transforms a [CommunalAppWidgetInfo] to a view that renders the widget. */
-class CommunalWidgetViewAdapter
-@Inject
-constructor(
- @Application private val context: Context,
- private val appWidgetManager: AppWidgetManager,
- private val appWidgetHost: AppWidgetHost,
- @CommunalLog logBuffer: LogBuffer,
-) {
- companion object {
- private const val TAG = "CommunalWidgetViewAdapter"
- }
-
- private val logger = Logger(logBuffer, TAG)
-
- fun adapt(providerInfoFlow: Flow<CommunalAppWidgetInfo?>): Flow<CommunalWidgetWrapper?> =
- providerInfoFlow.map {
- if (it == null) {
- return@map null
- }
-
- val appWidgetId = it.appWidgetId
- val providerInfo = it.providerInfo
-
- if (appWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId, providerInfo.provider)) {
- logger.d("Success binding app widget id: $appWidgetId")
- return@map CommunalWidgetWrapper(context).apply {
- addView(
- appWidgetHost.createView(context, appWidgetId, providerInfo).apply {
- // Set the widget to minimum width and height
- updateAppWidgetSize(
- appWidgetManager.getAppWidgetOptions(appWidgetId),
- listOf(
- SizeF(
- providerInfo.minResizeWidth.toFloat(),
- providerInfo.minResizeHeight.toFloat()
- )
- )
- )
- }
- )
- }
- } else {
- logger.w("Failed binding app widget id")
- return@map null
- }
- }
-}
diff --git a/packages/SystemUI/src/com/android/systemui/communal/ui/view/CommunalWidgetWrapper.kt b/packages/SystemUI/src/com/android/systemui/communal/ui/view/CommunalWidgetWrapper.kt
deleted file mode 100644
index 039078eb1f21..000000000000
--- a/packages/SystemUI/src/com/android/systemui/communal/ui/view/CommunalWidgetWrapper.kt
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2023 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.systemui.communal.ui.view
-
-import android.content.Context
-import android.util.AttributeSet
-import android.widget.LinearLayout
-import com.android.systemui.res.R
-
-/** Wraps around a widget rendered in communal mode. */
-class CommunalWidgetWrapper(context: Context, attrs: AttributeSet? = null) :
- LinearLayout(context, attrs) {
- init {
- id = R.id.communal_widget_wrapper
- }
-}