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

Commit 1219c416 authored by Julia Reynolds's avatar Julia Reynolds
Browse files

Propagate font weight adjustments

Test: manual - enable "Bold Text" and view notification bundle headers; verify new config is making it to the composable with logging
Bug: 425501135
Flag: EXEMPT BUG_FIX
Change-Id: Ie1689f27ea0f0cc1967098b96c5d1f3a308ca868
parent 047c1899
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ import android.content.Context
import android.content.pm.ActivityInfo
import android.content.res.Configuration
import android.graphics.Rect
import android.graphics.fonts.FontStyle.FONT_WEIGHT_MIN
import android.os.LocaleList
import android.view.View.LAYOUT_DIRECTION_RTL
import com.android.systemui.statusbar.data.repository.StatusBarConfigurationController
@@ -43,6 +44,7 @@ constructor(@Assisted private val context: Context) :
    private var localeList: LocaleList? = null
    private var layoutDirection: Int
    private var orientation = Configuration.ORIENTATION_UNDEFINED
    private var fontWeightAdjustment: Int = FONT_WEIGHT_MIN

    init {
        val currentConfig = context.resources.configuration
@@ -56,6 +58,7 @@ constructor(@Assisted private val context: Context) :
        uiMode = currentConfig.uiMode and Configuration.UI_MODE_NIGHT_MASK
        localeList = currentConfig.locales
        layoutDirection = currentConfig.layoutDirection
        fontWeightAdjustment = currentConfig.fontWeightAdjustment
    }

    override fun notifyThemeChanged() {
@@ -79,13 +82,16 @@ constructor(@Assisted private val context: Context) :
        val fontScale = newConfig.fontScale
        val density = newConfig.densityDpi
        val uiMode = newConfig.uiMode and Configuration.UI_MODE_NIGHT_MASK
        val fontWeightAdjustment = newConfig.fontWeightAdjustment
        val uiModeChanged = uiMode != this.uiMode
        if (density != this.density || fontScale != this.fontScale || inCarMode && uiModeChanged) {
        if (density != this.density || fontScale != this.fontScale || inCarMode && uiModeChanged
            || fontWeightAdjustment != this.fontWeightAdjustment) {
            listeners.filterForEach({ this.listeners.contains(it) }) {
                it.onDensityOrFontScaleChanged()
            }
            this.density = density
            this.fontScale = fontScale
            this.fontWeightAdjustment = fontWeightAdjustment
        }

        val smallestScreenWidth = newConfig.smallestScreenWidthDp