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

Commit 236b59d0 authored by Chris Göllner's avatar Chris Göllner Committed by Android (Google) Code Review
Browse files

Merge "Fix system icons being truncated when increasing display/font size" into main

parents bc9139ce 564facfc
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -239,10 +239,22 @@ public class PhoneStatusBarView extends FrameLayout {
        ViewGroup.LayoutParams layoutParams = getLayoutParams();
        mStatusBarHeight = SystemBarUtils.getStatusBarHeight(mContext);
        layoutParams.height = mStatusBarHeight - waterfallTopInset;
        updateSystemIconsContainerHeight();
        updatePaddings();
        setLayoutParams(layoutParams);
    }

    private void updateSystemIconsContainerHeight() {
        View systemIconsContainer = findViewById(R.id.system_icons);
        ViewGroup.LayoutParams layoutParams = systemIconsContainer.getLayoutParams();
        int newSystemIconsHeight =
                getResources().getDimensionPixelSize(R.dimen.status_bar_system_icons_height);
        if (layoutParams.height != newSystemIconsHeight) {
            layoutParams.height = newSystemIconsHeight;
            systemIconsContainer.setLayoutParams(layoutParams);
        }
    }

    private void updatePaddings() {
        int statusBarPaddingStart = getResources().getDimensionPixelSize(
                R.dimen.status_bar_padding_start);
+20 −3
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.view.LayoutInflater
import android.view.MotionEvent
import android.view.PrivacyIndicatorBounds
import android.view.RoundedCorners
import android.view.View
import android.view.WindowInsets
import android.widget.FrameLayout
import androidx.test.filters.SmallTest
@@ -50,6 +51,8 @@ import org.mockito.Mockito.verify
class PhoneStatusBarViewTest : SysuiTestCase() {

    private lateinit var view: PhoneStatusBarView
    private val systemIconsContainer: View
        get() = view.requireViewById(R.id.system_icons)

    private val contentInsetsProvider = mock<StatusBarContentInsetsProvider>()
    private val windowController = mock<StatusBarWindowController>()
@@ -62,6 +65,7 @@ class PhoneStatusBarViewTest : SysuiTestCase() {
        )
        mDependency.injectTestDependency(DarkIconDispatcher::class.java, mock<DarkIconDispatcher>())
        mDependency.injectTestDependency(StatusBarWindowController::class.java, windowController)
        context.ensureTestableResources()
        view = spy(createStatusBarView())
        whenever(view.rootWindowInsets).thenReturn(emptyWindowInsets())
        whenever(contentInsetsProvider.getStatusBarContentInsetsForCurrentRotation())
@@ -272,6 +276,19 @@ class PhoneStatusBarViewTest : SysuiTestCase() {
        assertThat(view.paddingBottom).isEqualTo(0)
    }

    @Test
    fun onConfigurationChanged_systemIconsHeightChanged_containerHeightIsUpdated() {
        val newHeight = 123456
        context.orCreateTestableResources.addOverride(
            R.dimen.status_bar_system_icons_height,
            newHeight
        )

        view.onConfigurationChanged(Configuration())

        assertThat(systemIconsContainer.layoutParams.height).isEqualTo(newHeight)
    }

    @Test
    fun onApplyWindowInsets_updatesLeftTopRightPaddingsBasedOnInsets() {
        val insets = Insets.of(/* left = */ 90, /* top = */ 10, /* right = */ 45, /* bottom = */ 50)