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

Commit 29ac230c authored by Fabian Kozynski's avatar Fabian Kozynski
Browse files

Don't limit carrier text when using large screen

When using the large screen header that fits in one line, we don't need
to limit the length of the carrier text (and it looks bad if we do).

Test: manual
Test: atest QSCarrierTest
Fixes: 245747995

Change-Id: Iec2e30f6fd5aa5e4e5e7a9d22c31f52a183f9f00
parent fd6c3092
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -35,4 +35,6 @@
    <!-- Percentage of displacement for items in QQS to guarantee matching with bottom of clock at
         fade_out_complete_frame -->
    <dimen name="percent_displacement_at_fade_out" format="float">0.1066</dimen>

    <integer name="qs_carrier_max_em">7</integer>
</resources>
 No newline at end of file
+19 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.systemui.qs.carrier;
import android.annotation.StyleRes;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Configuration;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
@@ -33,6 +34,7 @@ import com.android.settingslib.Utils;
import com.android.settingslib.graph.SignalDrawable;
import com.android.systemui.FontSizeUtils;
import com.android.systemui.R;
import com.android.systemui.util.LargeScreenUtils;

import java.util.Objects;

@@ -72,6 +74,7 @@ public class QSCarrier extends LinearLayout {
        mMobileSignal = findViewById(R.id.mobile_signal);
        mCarrierText = findViewById(R.id.qs_carrier_text);
        mSpacer = findViewById(R.id.spacer);
        updateResources();
    }

    /**
@@ -142,4 +145,20 @@ public class QSCarrier extends LinearLayout {
    public void updateTextAppearance(@StyleRes int resId) {
        FontSizeUtils.updateFontSizeFromStyle(mCarrierText, resId);
    }

    @Override
    protected void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        updateResources();
    }

    private void updateResources() {
        boolean useLargeScreenHeader =
                LargeScreenUtils.shouldUseLargeScreenShadeHeader(getResources());
        mCarrierText.setMaxEms(
                useLargeScreenHeader
                        ? Integer.MAX_VALUE
                        : getResources().getInteger(R.integer.qs_carrier_max_em)
        );
    }
}
+28 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import androidx.test.filters.SmallTest;

@@ -48,6 +49,7 @@ public class QSCarrierTest extends SysuiTestCase {
    public void setUp() throws Exception {
        mTestableLooper = TestableLooper.get(this);
        LayoutInflater inflater = LayoutInflater.from(mContext);
        mContext.ensureTestableResources();
        mTestableLooper.runWithLooper(() ->
                mQSCarrier = (QSCarrier) inflater.inflate(R.layout.qs_carrier, null));

@@ -119,4 +121,30 @@ public class QSCarrierTest extends SysuiTestCase {
        mQSCarrier.updateState(c, true);
        assertEquals(View.GONE, mQSCarrier.getRSSIView().getVisibility());
    }

    @Test
    public void testCarrierNameMaxWidth_smallScreen_fromResource() {
        int maxEms = 10;
        mContext.getOrCreateTestableResources().addOverride(R.integer.qs_carrier_max_em, maxEms);
        mContext.getOrCreateTestableResources()
                .addOverride(R.bool.config_use_large_screen_shade_header, false);
        TextView carrierText = mQSCarrier.requireViewById(R.id.qs_carrier_text);

        mQSCarrier.onConfigurationChanged(mContext.getResources().getConfiguration());

        assertEquals(maxEms, carrierText.getMaxEms());
    }

    @Test
    public void testCarrierNameMaxWidth_largeScreen_maxInt() {
        int maxEms = 10;
        mContext.getOrCreateTestableResources().addOverride(R.integer.qs_carrier_max_em, maxEms);
        mContext.getOrCreateTestableResources()
                .addOverride(R.bool.config_use_large_screen_shade_header, true);
        TextView carrierText = mQSCarrier.requireViewById(R.id.qs_carrier_text);

        mQSCarrier.onConfigurationChanged(mContext.getResources().getConfiguration());

        assertEquals(Integer.MAX_VALUE, carrierText.getMaxEms());
    }
}