summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Prince Donkor <princedonkor@google.com> 2024-08-19 13:56:27 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2024-08-19 13:56:27 +0000
commit43d00a8bdf43d9ee67768624ac37771bae05e6d9 (patch)
treead92a8932d8246327faea34a470c70b18627372d
parent5d80231405a7839b60be5aa85b0c316c73eccc8a (diff)
parentfb11a8d98ed839a62c6b887357336f7bafe2a6cf (diff)
Merge "Centering widgets in portrait mode" into main
-rw-r--r--packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalHub.kt40
1 files changed, 20 insertions, 20 deletions
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalHub.kt b/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalHub.kt
index 7472d818d71a..91a88bc7aa97 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalHub.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalHub.kt
@@ -170,7 +170,6 @@ import com.android.systemui.communal.ui.viewmodel.BaseCommunalViewModel
import com.android.systemui.communal.ui.viewmodel.CommunalEditModeViewModel
import com.android.systemui.communal.ui.viewmodel.CommunalViewModel
import com.android.systemui.communal.util.DensityUtils.Companion.adjustedDp
-import com.android.systemui.communal.util.DensityUtils.Companion.scalingAdjustment
import com.android.systemui.communal.widgets.SmartspaceAppWidgetHostView
import com.android.systemui.communal.widgets.WidgetConfigurator
import com.android.systemui.res.R
@@ -478,8 +477,7 @@ fun CommunalHub(
}
val hubDimensions: Dimensions
- @Composable
- get() = Dimensions(LocalContext.current, LocalConfiguration.current, LocalDensity.current)
+ @Composable get() = Dimensions(LocalContext.current, LocalConfiguration.current)
@Composable
private fun DisclaimerBottomSheetContent(onButtonClicked: () -> Unit) {
@@ -1288,8 +1286,9 @@ fun DisabledWidgetPlaceholder(
modifier =
modifier
.background(
- MaterialTheme.colorScheme.surfaceVariant,
- RoundedCornerShape(dimensionResource(system_app_widget_background_radius))
+ color = MaterialTheme.colorScheme.surfaceVariant,
+ shape =
+ RoundedCornerShape(dimensionResource(system_app_widget_background_radius))
)
.clickable(
enabled = !viewModel.isEditMode,
@@ -1325,10 +1324,8 @@ fun PendingWidgetPlaceholder(
Column(
modifier =
modifier.background(
- MaterialTheme.colorScheme.surfaceVariant,
- RoundedCornerShape(
- dimensionResource(system_app_widget_background_radius) * scalingAdjustment
- )
+ color = MaterialTheme.colorScheme.surfaceVariant,
+ shape = RoundedCornerShape(dimensionResource(system_app_widget_background_radius))
),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally,
@@ -1514,21 +1511,24 @@ data class ContentPaddingInPx(val start: Float, val top: Float) {
fun toOffset(): Offset = Offset(start, top)
}
-class Dimensions(val context: Context, val config: Configuration, val density: Density) {
+class Dimensions(val context: Context, val config: Configuration) {
val GridTopSpacing: Dp
get() {
- if (config.orientation == Configuration.ORIENTATION_LANDSCAPE) {
- return 114.adjustedDp
- } else {
- val windowMetrics =
- WindowMetricsCalculator.getOrCreate().computeCurrentWindowMetrics(context)
- val screenHeight = with(density) { windowMetrics.bounds.height().adjustedDp }
-
- return (screenHeight - CardHeightFull) / 2
- }
+ val result =
+ if (config.orientation == Configuration.ORIENTATION_LANDSCAPE) {
+ 114.dp
+ } else {
+ val windowMetrics =
+ WindowMetricsCalculator.getOrCreate().computeCurrentWindowMetrics(context)
+ val density = context.resources.displayMetrics.density
+ val screenHeight = (windowMetrics.bounds.height() / density).dp
+ ((screenHeight - CardHeightFull) / 2)
+ }
+ return result
}
- val GridHeight = CardHeightFull + GridTopSpacing
+ val GridHeight: Dp
+ get() = CardHeightFull + GridTopSpacing
companion object {
val CardHeightFull