Loading packages/SystemUI/res/values/integers.xml +2 −0 Original line number Diff line number Diff line Loading @@ -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 packages/SystemUI/src/com/android/systemui/qs/carrier/QSCarrier.java +19 −0 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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(); } /** Loading Loading @@ -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) ); } } packages/SystemUI/tests/src/com/android/systemui/qs/carrier/QSCarrierTest.java +28 −0 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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)); Loading Loading @@ -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()); } } Loading
packages/SystemUI/res/values/integers.xml +2 −0 Original line number Diff line number Diff line Loading @@ -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
packages/SystemUI/src/com/android/systemui/qs/carrier/QSCarrier.java +19 −0 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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(); } /** Loading Loading @@ -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) ); } }
packages/SystemUI/tests/src/com/android/systemui/qs/carrier/QSCarrierTest.java +28 −0 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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)); Loading Loading @@ -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()); } }