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

Commit 41001681 authored by Milton Wu's avatar Milton Wu Committed by Android (Google) Code Review
Browse files

Merge changes from topic "cutoutProvider" into tm-qpr-dev

* changes:
  Re-land ScreenDecorations Cutout Provider
  Move color and display info into DecorProvider
parents fcad8a9b 6e4eccab
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -131,7 +131,11 @@
    <!-- For StatusIconContainer to tag its icon views -->
    <item type="id" name="status_bar_view_state_tag" />

    <!-- Default display cutout on the physical top of screen -->
    <item type="id" name="display_cutout" />
    <item type="id" name="display_cutout_left" />
    <item type="id" name="display_cutout_right" />
    <item type="id" name="display_cutout_bottom" />

    <item type="id" name="row_tag_for_content_view" />

+32 −21
Original line number Diff line number Diff line
@@ -47,7 +47,8 @@ import com.android.systemui.animation.Interpolators
open class DisplayCutoutBaseView : View, RegionInterceptableView {

    private var shouldDrawCutout: Boolean = DisplayCutout.getFillBuiltInDisplayCutout(
            context.resources, context.display?.uniqueId)
        context.resources, context.display?.uniqueId
    )
    private var displayUniqueId: String? = null
    private var displayMode: Display.Mode? = null
    protected val location = IntArray(2)
@@ -74,8 +75,8 @@ open class DisplayCutoutBaseView : View, RegionInterceptableView {

    constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)

    constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int)
            : super(context, attrs, defStyleAttr)
    constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) :
        super(context, attrs, defStyleAttr)

    override fun onAttachedToWindow() {
        super.onAttachedToWindow()
@@ -85,7 +86,7 @@ open class DisplayCutoutBaseView : View, RegionInterceptableView {
        onUpdate()
    }

    fun onDisplayChanged(displayId: Int) {
    fun onDisplayChanged(newDisplayUniqueId: String?) {
        val oldMode: Display.Mode? = displayMode
        val display: Display? = context.display
        displayMode = display?.mode
@@ -93,7 +94,8 @@ open class DisplayCutoutBaseView : View, RegionInterceptableView {
        if (displayUniqueId != display?.uniqueId) {
            displayUniqueId = display?.uniqueId
            shouldDrawCutout = DisplayCutout.getFillBuiltInDisplayCutout(
                    context.resources, displayUniqueId)
                context.resources, displayUniqueId
            )
        }

        // Skip if display mode or cutout hasn't changed.
@@ -101,7 +103,7 @@ open class DisplayCutoutBaseView : View, RegionInterceptableView {
                display?.cutout == displayInfo.displayCutout) {
            return
        }
        if (displayId == display?.displayId) {
        if (newDisplayUniqueId == display?.uniqueId) {
            updateCutout()
            updateProtectionBoundingPath()
            onUpdate()
@@ -147,8 +149,9 @@ open class DisplayCutoutBaseView : View, RegionInterceptableView {
        cutoutBounds.translate(-location[0], -location[1])

        // Intersect with window's frame
        cutoutBounds.op(rootView.left, rootView.top, rootView.right, rootView.bottom,
                Region.Op.INTERSECT)
        cutoutBounds.op(
            rootView.left, rootView.top, rootView.right, rootView.bottom, Region.Op.INTERSECT
        )
        return cutoutBounds
    }

@@ -171,9 +174,12 @@ open class DisplayCutoutBaseView : View, RegionInterceptableView {

    protected open fun drawCutoutProtection(canvas: Canvas) {
        if (cameraProtectionProgress > HIDDEN_CAMERA_PROTECTION_SCALE &&
                !protectionRect.isEmpty) {
            canvas.scale(cameraProtectionProgress, cameraProtectionProgress,
                    protectionRect.centerX(), protectionRect.centerY())
            !protectionRect.isEmpty
        ) {
            canvas.scale(
                cameraProtectionProgress, cameraProtectionProgress, protectionRect.centerX(),
                protectionRect.centerY()
            )
            canvas.drawPath(protectionPath, paint)
        }
    }
@@ -205,14 +211,17 @@ open class DisplayCutoutBaseView : View, RegionInterceptableView {
            requestLayout()
        }
        cameraProtectionAnimator?.cancel()
        cameraProtectionAnimator = ValueAnimator.ofFloat(cameraProtectionProgress,
                if (showProtection) 1.0f else HIDDEN_CAMERA_PROTECTION_SCALE).setDuration(750)
        cameraProtectionAnimator = ValueAnimator.ofFloat(
            cameraProtectionProgress,
            if (showProtection) 1.0f else HIDDEN_CAMERA_PROTECTION_SCALE
        ).setDuration(750)
        cameraProtectionAnimator?.interpolator = Interpolators.DECELERATE_QUINT
        cameraProtectionAnimator?.addUpdateListener(ValueAnimator.AnimatorUpdateListener {
            animation: ValueAnimator ->
        cameraProtectionAnimator?.addUpdateListener(
            ValueAnimator.AnimatorUpdateListener { animation: ValueAnimator ->
                cameraProtectionProgress = animation.animatedValue as Float
                invalidate()
        })
            }
        )
        cameraProtectionAnimator?.addListener(object : AnimatorListenerAdapter() {
            override fun onAnimationEnd(animation: Animator) {
                cameraProtectionAnimator = null
@@ -245,8 +254,10 @@ open class DisplayCutoutBaseView : View, RegionInterceptableView {
        // Apply rotation.
        val lw: Int = displayInfo.logicalWidth
        val lh: Int = displayInfo.logicalHeight
        val flipped = (displayInfo.rotation == Surface.ROTATION_90 ||
                displayInfo.rotation == Surface.ROTATION_270)
        val flipped = (
            displayInfo.rotation == Surface.ROTATION_90 ||
                displayInfo.rotation == Surface.ROTATION_270
            )
        val dw = if (flipped) lh else lw
        val dh = if (flipped) lw else lh
        transformPhysicalToLogicalCoordinates(displayInfo.rotation, dw, dh, m)
+92 −172

File changed.

Preview size limit exceeded, changes collapsed.

+60 −0

File added.

Preview size limit exceeded, changes collapsed.

+65 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading