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

Commit 564facfc authored by Chris Göllner's avatar Chris Göllner
Browse files

Fix system icons being truncated when increasing display/font size

The height of the system icons container is set to
"R.dimen.status_bar_system_icons_height". When increasing the display
or font size, the set height will be out of date.
The fix is to manually update it on config changes.

Fixes: 321845195
Test: PhoneStatusBarViewTest
Test: Manually
Flag: None
Change-Id: Iaf6925246a56689f03c927e814f0538d439f0076
parent 58fa714f
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)