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

Commit 855e2029 authored by Sherry Zhou's avatar Sherry Zhou Committed by Android (Google) Code Review
Browse files

Merge "Remove maxWidth constraints from WallpaperFocalAreaInteractor Instead,...

Merge "Remove maxWidth constraints from WallpaperFocalAreaInteractor Instead, we do it in ShapeRenderer" into main
parents df92d35d 07ec9119
Loading
Loading
Loading
Loading
+12 −6
Original line number Diff line number Diff line
@@ -96,7 +96,8 @@ class WallpaperFocalAreaInteractorTest : SysuiTestCase() {
            kosmos.wallpaperFocalAreaRepository.setNotificationDefaultTop(400F)
            kosmos.wallpaperFocalAreaRepository.setNotificationStackAbsoluteBottom(400F)

            assertThat(bounds).isEqualTo(RectF(250f, 700F, 750F, 1400F))
            assertThat(bounds?.top).isEqualTo(700F)
            assertThat(bounds?.bottom).isEqualTo(1400F)
        }

    @Test
@@ -116,7 +117,8 @@ class WallpaperFocalAreaInteractorTest : SysuiTestCase() {
            kosmos.wallpaperFocalAreaRepository.setNotificationDefaultTop(400F)
            kosmos.wallpaperFocalAreaRepository.setNotificationStackAbsoluteBottom(600F)

            assertThat(bounds).isEqualTo(RectF(250f, 800F, 750F, 1400F))
            assertThat(bounds?.top).isEqualTo(800F)
            assertThat(bounds?.bottom).isEqualTo(1400F)
        }

    @Test
@@ -136,7 +138,8 @@ class WallpaperFocalAreaInteractorTest : SysuiTestCase() {
            kosmos.wallpaperFocalAreaRepository.setNotificationDefaultTop(400F)
            kosmos.wallpaperFocalAreaRepository.setNotificationStackAbsoluteBottom(400F)

            assertThat(bounds).isEqualTo(RectF(600f, 600F, 1400F, 1100F))
            assertThat(bounds?.top).isEqualTo(600F)
            assertThat(bounds?.bottom).isEqualTo(1100F)
        }

    @Test
@@ -156,7 +159,8 @@ class WallpaperFocalAreaInteractorTest : SysuiTestCase() {
            kosmos.wallpaperFocalAreaRepository.setNotificationDefaultTop(400F)
            kosmos.wallpaperFocalAreaRepository.setNotificationStackAbsoluteBottom(600F)

            assertThat(bounds).isEqualTo(RectF(400f, 800F, 1200F, 1400F))
            assertThat(bounds?.top).isEqualTo(800F)
            assertThat(bounds?.bottom).isEqualTo(1400F)
        }

    @Test
@@ -176,7 +180,8 @@ class WallpaperFocalAreaInteractorTest : SysuiTestCase() {
            kosmos.wallpaperFocalAreaRepository.setNotificationDefaultTop(400F)
            kosmos.wallpaperFocalAreaRepository.setNotificationStackAbsoluteBottom(600F)

            assertThat(bounds).isEqualTo(RectF(400f, 800F, 1200F, 1400F))
            assertThat(bounds?.top).isEqualTo(800F)
            assertThat(bounds?.bottom).isEqualTo(1400F)
        }

    @Test
@@ -196,7 +201,8 @@ class WallpaperFocalAreaInteractorTest : SysuiTestCase() {
            kosmos.wallpaperFocalAreaRepository.setNotificationDefaultTop(200F)
            kosmos.wallpaperFocalAreaRepository.setNotificationStackAbsoluteBottom(200F)

            assertThat(bounds).isEqualTo(RectF(1000f, 600F, 2000F, 1400F))
            assertThat(bounds?.top).isEqualTo(600F)
            assertThat(bounds?.bottom).isEqualTo(1400F)
        }

    @Test
+4 −34
Original line number Diff line number Diff line
@@ -21,14 +21,12 @@ import android.content.res.Resources
import android.graphics.PointF
import android.graphics.RectF
import android.util.Log
import android.util.TypedValue
import com.android.app.animation.MathUtils
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.res.R
import com.android.systemui.shade.data.repository.ShadeRepository
import com.android.systemui.wallpapers.data.repository.WallpaperFocalAreaRepository
import javax.inject.Inject
import kotlin.math.min
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged
@@ -75,28 +73,11 @@ constructor(
                        screenBounds.centerY() + screenBounds.height() / 2F / wallpaperZoomedInScale,
                    )

                val focalAreaMaxWidthDp = getFocalAreaMaxWidthDp(context)
                val maxFocalAreaWidth =
                    TypedValue.applyDimension(
                        TypedValue.COMPLEX_UNIT_DIP,
                        focalAreaMaxWidthDp.toFloat(),
                        context.resources.displayMetrics,
                    )

                val (left, right) =
                // Tablet & unfold foldable landscape
                if (isShadeLayoutWide) {
                        Pair(
                            scaledBounds.centerX() - maxFocalAreaWidth / 2F,
                            scaledBounds.centerX() + maxFocalAreaWidth / 2F,
                        )
                    } else {
                        val focalAreaWidth = min(scaledBounds.width(), maxFocalAreaWidth)
                    Pair(
                            scaledBounds.centerX() - focalAreaWidth / 2F,
                            scaledBounds.centerX() + focalAreaWidth / 2F,
                        scaledBounds.centerX() - scaledBounds.width() / 2F,
                        scaledBounds.centerX() + scaledBounds.width() / 2F,
                    )
                    }
                val scaledBottomMargin =
                    (context.resources.displayMetrics.heightPixels - shortcutAbsoluteTop) /
                        wallpaperZoomedInScale
@@ -160,17 +141,6 @@ constructor(
            return if (scale == 0f) 1f else scale
        }

        // A max width for focal area shape effects bounds, to avoid it becoming too large,
        // especially in portrait mode
        const val FOCAL_AREA_MAX_WIDTH_DP_TABLET = 500
        const val FOCAL_AREA_MAX_WIDTH_DP_FOLDABLE = 400

        fun getFocalAreaMaxWidthDp(context: Context): Int {
            return if (context.resources.getBoolean(R.bool.center_align_focal_area_shape))
                FOCAL_AREA_MAX_WIDTH_DP_TABLET
            else FOCAL_AREA_MAX_WIDTH_DP_FOLDABLE
        }

        private val TAG = WallpaperFocalAreaInteractor::class.simpleName
    }
}