Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 43d00a8b authored by Prince Donkor's avatar Prince Donkor Committed by Android (Google) Code Review
Browse files

Merge "Centering widgets in portrait mode" into main

parents 5d802314 fb11a8d9
Loading
Loading
Loading
Loading
+20 −20
Original line number Diff line number Diff line
@@ -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,7 +1286,8 @@ fun DisabledWidgetPlaceholder(
        modifier =
            modifier
                .background(
                    MaterialTheme.colorScheme.surfaceVariant,
                    color = MaterialTheme.colorScheme.surfaceVariant,
                    shape =
                        RoundedCornerShape(dimensionResource(system_app_widget_background_radius))
                )
                .clickable(
@@ -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() {
            val result =
                if (config.orientation == Configuration.ORIENTATION_LANDSCAPE) {
                return 114.adjustedDp
                    114.dp
                } else {
                    val windowMetrics =
                        WindowMetricsCalculator.getOrCreate().computeCurrentWindowMetrics(context)
                val screenHeight = with(density) { windowMetrics.bounds.height().adjustedDp }

                return (screenHeight - CardHeightFull) / 2
                    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