Loading packages/SystemUI/res/values/dimens.xml +5 −0 Original line number Diff line number Diff line Loading @@ -1569,4 +1569,9 @@ <dimen name="dream_overlay_status_bar_ambient_text_shadow_dx">0.5dp</dimen> <dimen name="dream_overlay_status_bar_ambient_text_shadow_dy">0.5dp</dimen> <dimen name="dream_overlay_status_bar_ambient_text_shadow_radius">2dp</dimen> <!-- Default device corner radius, used for assist UI --> <dimen name="config_rounded_mask_size">0px</dimen> <dimen name="config_rounded_mask_size_top">0px</dimen> <dimen name="config_rounded_mask_size_bottom">0px</dimen> </resources> packages/SystemUI/src/com/android/systemui/assist/ui/DisplayUtils.java +9 −22 Original line number Diff line number Diff line Loading @@ -21,6 +21,8 @@ import android.util.DisplayMetrics; import android.view.Display; import android.view.Surface; import com.android.systemui.R; /** * Utility class for determining screen and corner dimensions. */ Loading Loading @@ -82,17 +84,13 @@ public class DisplayUtils { * where the curve ends), in pixels. */ public static int getCornerRadiusBottom(Context context) { int radius = 0; int resourceId = context.getResources().getIdentifier("config_rounded_mask_size_bottom", "dimen", "com.android.systemui"); if (resourceId > 0) { radius = context.getResources().getDimensionPixelSize(resourceId); } int radius = context.getResources().getDimensionPixelSize( R.dimen.config_rounded_mask_size_bottom); if (radius == 0) { radius = getCornerRadiusDefault(context); } return radius; } Loading @@ -101,28 +99,17 @@ public class DisplayUtils { * the curve ends), in pixels. */ public static int getCornerRadiusTop(Context context) { int radius = 0; int resourceId = context.getResources().getIdentifier("config_rounded_mask_size_top", "dimen", "com.android.systemui"); if (resourceId > 0) { radius = context.getResources().getDimensionPixelSize(resourceId); } int radius = context.getResources().getDimensionPixelSize( R.dimen.config_rounded_mask_size_top); if (radius == 0) { radius = getCornerRadiusDefault(context); } return radius; } private static int getCornerRadiusDefault(Context context) { int radius = 0; int resourceId = context.getResources().getIdentifier("config_rounded_mask_size", "dimen", "com.android.systemui"); if (resourceId > 0) { radius = context.getResources().getDimensionPixelSize(resourceId); } return radius; return context.getResources().getDimensionPixelSize(R.dimen.config_rounded_mask_size); } } packages/SystemUI/tests/src/com/android/systemui/assist/ui/DisplayUtilsTest.java 0 → 100644 +78 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui.assist.ui; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.when; import android.content.Context; import android.content.res.Resources; import android.testing.AndroidTestingRunner; import androidx.test.filters.SmallTest; import com.android.systemui.R; import com.android.systemui.SysuiTestCase; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; @SmallTest @RunWith(AndroidTestingRunner.class) public class DisplayUtilsTest extends SysuiTestCase { @Mock Resources mResources; @Mock Context mMockContext; @Before public void setup() { MockitoAnnotations.initMocks(this); } @Test public void testGetCornerRadii_noOverlay() { assertEquals(0, DisplayUtils.getCornerRadiusBottom(mContext)); assertEquals(0, DisplayUtils.getCornerRadiusTop(mContext)); } @Test public void testGetCornerRadii_onlyDefaultOverridden() { when(mResources.getDimensionPixelSize(R.dimen.config_rounded_mask_size)).thenReturn(100); when(mMockContext.getResources()).thenReturn(mResources); assertEquals(100, DisplayUtils.getCornerRadiusBottom(mMockContext)); assertEquals(100, DisplayUtils.getCornerRadiusTop(mMockContext)); } @Test public void testGetCornerRadii_allOverridden() { when(mResources.getDimensionPixelSize(R.dimen.config_rounded_mask_size)).thenReturn(100); when(mResources.getDimensionPixelSize(R.dimen.config_rounded_mask_size_top)).thenReturn( 150); when(mResources.getDimensionPixelSize(R.dimen.config_rounded_mask_size_bottom)).thenReturn( 200); when(mMockContext.getResources()).thenReturn(mResources); assertEquals(200, DisplayUtils.getCornerRadiusBottom(mMockContext)); assertEquals(150, DisplayUtils.getCornerRadiusTop(mMockContext)); } } Loading
packages/SystemUI/res/values/dimens.xml +5 −0 Original line number Diff line number Diff line Loading @@ -1569,4 +1569,9 @@ <dimen name="dream_overlay_status_bar_ambient_text_shadow_dx">0.5dp</dimen> <dimen name="dream_overlay_status_bar_ambient_text_shadow_dy">0.5dp</dimen> <dimen name="dream_overlay_status_bar_ambient_text_shadow_radius">2dp</dimen> <!-- Default device corner radius, used for assist UI --> <dimen name="config_rounded_mask_size">0px</dimen> <dimen name="config_rounded_mask_size_top">0px</dimen> <dimen name="config_rounded_mask_size_bottom">0px</dimen> </resources>
packages/SystemUI/src/com/android/systemui/assist/ui/DisplayUtils.java +9 −22 Original line number Diff line number Diff line Loading @@ -21,6 +21,8 @@ import android.util.DisplayMetrics; import android.view.Display; import android.view.Surface; import com.android.systemui.R; /** * Utility class for determining screen and corner dimensions. */ Loading Loading @@ -82,17 +84,13 @@ public class DisplayUtils { * where the curve ends), in pixels. */ public static int getCornerRadiusBottom(Context context) { int radius = 0; int resourceId = context.getResources().getIdentifier("config_rounded_mask_size_bottom", "dimen", "com.android.systemui"); if (resourceId > 0) { radius = context.getResources().getDimensionPixelSize(resourceId); } int radius = context.getResources().getDimensionPixelSize( R.dimen.config_rounded_mask_size_bottom); if (radius == 0) { radius = getCornerRadiusDefault(context); } return radius; } Loading @@ -101,28 +99,17 @@ public class DisplayUtils { * the curve ends), in pixels. */ public static int getCornerRadiusTop(Context context) { int radius = 0; int resourceId = context.getResources().getIdentifier("config_rounded_mask_size_top", "dimen", "com.android.systemui"); if (resourceId > 0) { radius = context.getResources().getDimensionPixelSize(resourceId); } int radius = context.getResources().getDimensionPixelSize( R.dimen.config_rounded_mask_size_top); if (radius == 0) { radius = getCornerRadiusDefault(context); } return radius; } private static int getCornerRadiusDefault(Context context) { int radius = 0; int resourceId = context.getResources().getIdentifier("config_rounded_mask_size", "dimen", "com.android.systemui"); if (resourceId > 0) { radius = context.getResources().getDimensionPixelSize(resourceId); } return radius; return context.getResources().getDimensionPixelSize(R.dimen.config_rounded_mask_size); } }
packages/SystemUI/tests/src/com/android/systemui/assist/ui/DisplayUtilsTest.java 0 → 100644 +78 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui.assist.ui; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.when; import android.content.Context; import android.content.res.Resources; import android.testing.AndroidTestingRunner; import androidx.test.filters.SmallTest; import com.android.systemui.R; import com.android.systemui.SysuiTestCase; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; @SmallTest @RunWith(AndroidTestingRunner.class) public class DisplayUtilsTest extends SysuiTestCase { @Mock Resources mResources; @Mock Context mMockContext; @Before public void setup() { MockitoAnnotations.initMocks(this); } @Test public void testGetCornerRadii_noOverlay() { assertEquals(0, DisplayUtils.getCornerRadiusBottom(mContext)); assertEquals(0, DisplayUtils.getCornerRadiusTop(mContext)); } @Test public void testGetCornerRadii_onlyDefaultOverridden() { when(mResources.getDimensionPixelSize(R.dimen.config_rounded_mask_size)).thenReturn(100); when(mMockContext.getResources()).thenReturn(mResources); assertEquals(100, DisplayUtils.getCornerRadiusBottom(mMockContext)); assertEquals(100, DisplayUtils.getCornerRadiusTop(mMockContext)); } @Test public void testGetCornerRadii_allOverridden() { when(mResources.getDimensionPixelSize(R.dimen.config_rounded_mask_size)).thenReturn(100); when(mResources.getDimensionPixelSize(R.dimen.config_rounded_mask_size_top)).thenReturn( 150); when(mResources.getDimensionPixelSize(R.dimen.config_rounded_mask_size_bottom)).thenReturn( 200); when(mMockContext.getResources()).thenReturn(mResources); assertEquals(200, DisplayUtils.getCornerRadiusBottom(mMockContext)); assertEquals(150, DisplayUtils.getCornerRadiusTop(mMockContext)); } }