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

Commit b0c0ea9b authored by Hawkwood Glazier's avatar Hawkwood Glazier Committed by Android (Google) Code Review
Browse files

Merge changes from topic "gsf_axis_tags" into main

* changes:
  Log Clock Visibility & Alpha changes in logbuffers
  Centralize GSF Axis Tags
parents 585b77ac b9f2a77b
Loading
Loading
Loading
Loading
+16 −9
Original line number Diff line number Diff line
package com.android.systemui.animation

private const val TAG_WGHT = "wght"
private const val TAG_WDTH = "wdth"
private const val TAG_OPSZ = "opsz"
private const val TAG_ROND = "ROND"
object GSFAxes {
    const val WEIGHT = "wght"
    const val WIDTH = "wdth"
    const val SLANT = "slnt"
    const val ROUND = "ROND"
    const val OPTICAL_SIZE = "opsz"
}

class FontVariationUtils {
    private var mWeight = -1
@@ -21,7 +24,7 @@ class FontVariationUtils {
        weight: Int = -1,
        width: Int = -1,
        opticalSize: Int = -1,
        roundness: Int = -1
        roundness: Int = -1,
    ): String {
        isUpdated = false
        if (weight >= 0 && mWeight != weight) {
@@ -43,16 +46,20 @@ class FontVariationUtils {
        }
        var resultString = ""
        if (mWeight >= 0) {
            resultString += "'$TAG_WGHT' $mWeight"
            resultString += "'${GSFAxes.WEIGHT}' $mWeight"
        }
        if (mWidth >= 0) {
            resultString += (if (resultString.isBlank()) "" else ", ") + "'$TAG_WDTH' $mWidth"
            resultString +=
                (if (resultString.isBlank()) "" else ", ") + "'${GSFAxes.WIDTH}' $mWidth"
        }
        if (mOpticalSize >= 0) {
            resultString += (if (resultString.isBlank()) "" else ", ") + "'$TAG_OPSZ' $mOpticalSize"
            resultString +=
                (if (resultString.isBlank()) "" else ", ") +
                    "'${GSFAxes.OPTICAL_SIZE}' $mOpticalSize"
        }
        if (mRoundness >= 0) {
            resultString += (if (resultString.isBlank()) "" else ", ") + "'$TAG_ROND' $mRoundness"
            resultString +=
                (if (resultString.isBlank()) "" else ", ") + "'${GSFAxes.ROUND}' $mRoundness"
        }
        return if (isUpdated) resultString else ""
    }
+9 −8
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ import android.content.Context
import android.content.res.Resources
import android.graphics.Typeface
import android.view.LayoutInflater
import com.android.systemui.animation.GSFAxes
import com.android.systemui.customization.R
import com.android.systemui.log.core.MessageBuffer
import com.android.systemui.plugins.clocks.ClockController
@@ -107,18 +108,18 @@ class DefaultClockProvider(
        // TODO(b/364681643): Variations for retargetted DIGITAL_CLOCK_FLEX
        val LEGACY_FLEX_LS_VARIATION =
            listOf(
                ClockFontAxisSetting("wght", 600f),
                ClockFontAxisSetting("wdth", 100f),
                ClockFontAxisSetting("ROND", 100f),
                ClockFontAxisSetting("slnt", 0f),
                ClockFontAxisSetting(GSFAxes.WEIGHT, 600f),
                ClockFontAxisSetting(GSFAxes.WIDTH, 100f),
                ClockFontAxisSetting(GSFAxes.ROUND, 100f),
                ClockFontAxisSetting(GSFAxes.SLANT, 0f),
            )

        val LEGACY_FLEX_AOD_VARIATION =
            listOf(
                ClockFontAxisSetting("wght", 74f),
                ClockFontAxisSetting("wdth", 43f),
                ClockFontAxisSetting("ROND", 100f),
                ClockFontAxisSetting("slnt", 0f),
                ClockFontAxisSetting(GSFAxes.WEIGHT, 74f),
                ClockFontAxisSetting(GSFAxes.WIDTH, 43f),
                ClockFontAxisSetting(GSFAxes.ROUND, 100f),
                ClockFontAxisSetting(GSFAxes.SLANT, 0f),
            )

        val FLEX_TYPEFACE by lazy {
+5 −4
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.systemui.shared.clocks

import com.android.systemui.animation.GSFAxes
import com.android.systemui.customization.R
import com.android.systemui.plugins.clocks.AlarmData
import com.android.systemui.plugins.clocks.AxisType
@@ -122,7 +123,7 @@ class FlexClockController(private val clockCtx: ClockContext) : ClockController
        val FONT_AXES =
            listOf(
                ClockFontAxis(
                    key = "wght",
                    key = GSFAxes.WEIGHT,
                    type = AxisType.Float,
                    minValue = 25f,
                    currentValue = 400f,
@@ -131,7 +132,7 @@ class FlexClockController(private val clockCtx: ClockContext) : ClockController
                    description = "Glyph Weight",
                ),
                ClockFontAxis(
                    key = "wdth",
                    key = GSFAxes.WIDTH,
                    type = AxisType.Float,
                    minValue = 25f,
                    currentValue = 100f,
@@ -140,7 +141,7 @@ class FlexClockController(private val clockCtx: ClockContext) : ClockController
                    description = "Glyph Width",
                ),
                ClockFontAxis(
                    key = "ROND",
                    key = GSFAxes.ROUND,
                    type = AxisType.Boolean,
                    minValue = 0f,
                    currentValue = 0f,
@@ -149,7 +150,7 @@ class FlexClockController(private val clockCtx: ClockContext) : ClockController
                    description = "Glyph Roundness",
                ),
                ClockFontAxis(
                    key = "slnt",
                    key = GSFAxes.SLANT,
                    type = AxisType.Boolean,
                    minValue = 0f,
                    currentValue = 0f,
+2 −1
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.view.Gravity
import android.view.View
import android.view.ViewGroup.LayoutParams.MATCH_PARENT
import android.widget.FrameLayout
import com.android.systemui.animation.GSFAxes
import com.android.systemui.customization.R
import com.android.systemui.plugins.clocks.AlarmData
import com.android.systemui.plugins.clocks.ClockAnimations
@@ -130,7 +131,7 @@ class FlexClockFaceController(clockCtx: ClockContext, private val isLargeClock:
            if (!isLargeClock) {
                axes =
                    axes.map { axis ->
                        if (axis.key == "wdth" && axis.value > SMALL_CLOCK_MAX_WDTH) {
                        if (axis.key == GSFAxes.WIDTH && axis.value > SMALL_CLOCK_MAX_WDTH) {
                            axis.copy(value = SMALL_CLOCK_MAX_WDTH)
                        } else {
                            axis
+38 −2
Original line number Diff line number Diff line
@@ -139,13 +139,49 @@ class FlexClockView(clockCtx: ClockContext) : FrameLayout(clockCtx.context) {
        digitalClockTextViewMap.forEach { (_, textView) -> textView.refreshText() }
    }

    override fun setVisibility(visibility: Int) {
        if (visibility != this.visibility) {
            logger.d({ "setVisibility(${str1 ?: int1})" }) {
                int1 = visibility
                str1 =
                    when (visibility) {
                        VISIBLE -> "VISIBLE"
                        INVISIBLE -> "INVISIBLE"
                        GONE -> "GONE"
                        else -> null
                    }
            }
        }

        super.setVisibility(visibility)
    }

    private var loggedAlpha = 1000f

    override fun setAlpha(alpha: Float) {
        val delta = if (alpha <= 0f || alpha >= 1f) 0.001f else 0.5f
        if (abs(loggedAlpha - alpha) >= delta) {
            loggedAlpha = alpha
            logger.d({ "setAlpha($double1)" }) { double1 = alpha.toDouble() }
        }
        super.setAlpha(alpha)
    }

    private val isDrawn: Boolean
        get() = (mPrivateFlags and 0x20 /* PFLAG_DRAWN */) > 0

    override fun invalidate() {
        if (isDrawn && visibility == VISIBLE) {
            logger.d("invalidate()")
        }

        super.invalidate()
    }

    override fun requestLayout() {
        if (!isLayoutRequested()) {
            logger.d("requestLayout()")
        }
        super.requestLayout()
    }

Loading