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

Commit 06af41d4 authored by Shan Huang's avatar Shan Huang Committed by Automerger Merge Worker
Browse files

Merge "Show wired ripple from the correct charger location for different...

Merge "Show wired ripple from the correct charger location for different orientations." into sc-dev am: f7066203

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14097782

Change-Id: Ieeeb942ecd4ca62a4673bcb6bb387193b7837a11
parents 0cfccb97 f7066203
Loading
Loading
Loading
Loading
+20 −2
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import com.android.systemui.statusbar.commandline.Command
import com.android.systemui.statusbar.commandline.CommandRegistry
import com.android.systemui.statusbar.policy.BatteryController
import com.android.systemui.statusbar.policy.ConfigurationController
import com.android.systemui.util.leak.RotationUtils
import java.io.PrintWriter
import javax.inject.Inject

@@ -122,13 +123,30 @@ class WiredChargingRippleController @Inject constructor(
    }

    private fun layoutRipple() {
        // TODO(shanh): Set origin base on phone orientation.
        val displayMetrics = DisplayMetrics()
        context.display.getRealMetrics(displayMetrics)
        val width = displayMetrics.widthPixels
        val height = displayMetrics.heightPixels
        rippleView.origin = PointF(width / 2f, height.toFloat())
        rippleView.radius = Integer.max(width, height).toFloat()

        // Always show the ripple from the charging cable location.
        // Currently assuming the charging cable is at the bottom of the screen.
        // TODO(shanh): Pull charging port location into configurations.
        rippleView.origin = when (RotationUtils.getRotation(context)) {
            RotationUtils.ROTATION_LANDSCAPE -> {
                PointF(width.toFloat(), height / 2f)
            }
            RotationUtils.ROTATION_UPSIDE_DOWN -> {
                PointF(width / 2f, 0f)
            }
            RotationUtils.ROTATION_SEASCAPE -> {
                PointF(0f, height / 2f)
            }
            else -> {
                // ROTATION_NONE
                PointF(width / 2f, height.toFloat())
            }
        }
    }

    private fun updateRippleColor() {