summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Evan Laird <evanlaird@google.com> 2023-06-07 12:33:37 -0400
committer Evan Laird <evanlaird@google.com> 2023-06-07 12:46:35 -0400
commiteba0b0f0dfd77caa7bcda7dd2994e972418d4ab9 (patch)
tree1969e81ce2a5f847fae41b249daba8f5716e0552
parent76a732f8e527554cdf7f36bb6eec71c5c6213556 (diff)
[Decor] Split RoundedCornerResDelegate into impl and interface
In order to support a new debug corner res delegate, we should split out the RoundedCornerResDelegate into an interface + implementation. This will allow us to create a DebugCornerDelegate that can be reused by the RoundedCornerDecorProvider without needing to duplicate that class definition. Test: RoundedCornerDecorProviderFactoryTest Test: RoundedCornerResDelegateTest Test: adb shell setprop debug.screenshot_rounded_corners 1 && restart-sysui Bug: 285941724 Change-Id: I68fbe1a7d0662781b611c84ae81dd526381aad22
-rw-r--r--packages/SystemUI/src/com/android/systemui/ScreenDecorations.java8
-rw-r--r--packages/SystemUI/src/com/android/systemui/decor/RoundedCornerResDelegate.kt41
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/decor/RoundedCornerDecorProviderFactoryTest.kt2
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/decor/RoundedCornerResDelegateTest.kt12
4 files changed, 39 insertions, 24 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java b/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java
index 29f7a5e42778..892b9dc7f08e 100644
--- a/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java
+++ b/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java
@@ -78,7 +78,7 @@ import com.android.systemui.decor.FaceScanningProviderFactory;
import com.android.systemui.decor.OverlayWindow;
import com.android.systemui.decor.PrivacyDotDecorProviderFactory;
import com.android.systemui.decor.RoundedCornerDecorProviderFactory;
-import com.android.systemui.decor.RoundedCornerResDelegate;
+import com.android.systemui.decor.RoundedCornerResDelegateImpl;
import com.android.systemui.log.ScreenDecorationsLogger;
import com.android.systemui.qs.SettingObserver;
import com.android.systemui.settings.DisplayTracker;
@@ -142,7 +142,7 @@ public class ScreenDecorations implements CoreStartable, Dumpable {
public final int mFaceScanningViewId;
@VisibleForTesting
- protected RoundedCornerResDelegate mRoundedCornerResDelegate;
+ protected RoundedCornerResDelegateImpl mRoundedCornerResDelegate;
@VisibleForTesting
protected DecorProviderFactory mRoundedCornerFactory;
private CutoutDecorProviderFactory mCutoutFactory;
@@ -429,8 +429,8 @@ public class ScreenDecorations implements CoreStartable, Dumpable {
mDisplayMode = mDisplayInfo.getMode();
mDisplayUniqueId = mDisplayInfo.uniqueId;
mDisplayCutout = mDisplayInfo.displayCutout;
- mRoundedCornerResDelegate = new RoundedCornerResDelegate(mContext.getResources(),
- mDisplayUniqueId);
+ mRoundedCornerResDelegate =
+ new RoundedCornerResDelegateImpl(mContext.getResources(), mDisplayUniqueId);
mRoundedCornerResDelegate.setPhysicalPixelDisplaySizeRatio(
getPhysicalPixelDisplaySizeRatio());
mRoundedCornerFactory = new RoundedCornerDecorProviderFactory(mRoundedCornerResDelegate);
diff --git a/packages/SystemUI/src/com/android/systemui/decor/RoundedCornerResDelegate.kt b/packages/SystemUI/src/com/android/systemui/decor/RoundedCornerResDelegate.kt
index 5f5ca54bd01f..c64766a3eb3c 100644
--- a/packages/SystemUI/src/com/android/systemui/decor/RoundedCornerResDelegate.kt
+++ b/packages/SystemUI/src/com/android/systemui/decor/RoundedCornerResDelegate.kt
@@ -27,35 +27,50 @@ import com.android.systemui.Dumpable
import com.android.systemui.R
import java.io.PrintWriter
-class RoundedCornerResDelegate(
+interface RoundedCornerResDelegate {
+ val hasTop: Boolean
+ val topRoundedDrawable: Drawable?
+ val topRoundedSize: Size
+
+ val hasBottom: Boolean
+ val bottomRoundedDrawable: Drawable?
+ val bottomRoundedSize: Size
+
+ var physicalPixelDisplaySizeRatio: Float
+
+ fun updateDisplayUniqueId(newDisplayUniqueId: String?, newReloadToken: Int?)
+}
+
+/**
+ * Delegate for the device-default rounded corners. These will always be loaded from the config
+ * values `R.array.config_roundedCornerTopDrawableArray` and `R.drawable.rounded_corner_top`
+ */
+class RoundedCornerResDelegateImpl(
private val res: Resources,
private var displayUniqueId: String?
-) : Dumpable {
-
- private val density: Float
- get() = res.displayMetrics.density
+) : RoundedCornerResDelegate, Dumpable {
private var reloadToken: Int = 0
- var hasTop: Boolean = false
+ override var hasTop: Boolean = false
private set
- var hasBottom: Boolean = false
+ override var hasBottom: Boolean = false
private set
- var topRoundedDrawable: Drawable? = null
+ override var topRoundedDrawable: Drawable? = null
private set
- var bottomRoundedDrawable: Drawable? = null
+ override var bottomRoundedDrawable: Drawable? = null
private set
- var topRoundedSize = Size(0, 0)
+ override var topRoundedSize = Size(0, 0)
private set
- var bottomRoundedSize = Size(0, 0)
+ override var bottomRoundedSize = Size(0, 0)
private set
- var physicalPixelDisplaySizeRatio: Float = 1f
+ override var physicalPixelDisplaySizeRatio: Float = 1f
set(value) {
if (field == value) {
return
@@ -69,7 +84,7 @@ class RoundedCornerResDelegate(
reloadMeasures()
}
- fun updateDisplayUniqueId(newDisplayUniqueId: String?, newReloadToken: Int?) {
+ override fun updateDisplayUniqueId(newDisplayUniqueId: String?, newReloadToken: Int?) {
if (displayUniqueId != newDisplayUniqueId) {
displayUniqueId = newDisplayUniqueId
newReloadToken ?.let { reloadToken = it }
diff --git a/packages/SystemUI/tests/src/com/android/systemui/decor/RoundedCornerDecorProviderFactoryTest.kt b/packages/SystemUI/tests/src/com/android/systemui/decor/RoundedCornerDecorProviderFactoryTest.kt
index fcc358982e6c..8f0b19307000 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/decor/RoundedCornerDecorProviderFactoryTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/decor/RoundedCornerDecorProviderFactoryTest.kt
@@ -39,7 +39,7 @@ class RoundedCornerDecorProviderFactoryTest : SysuiTestCase() {
@Before
fun setUp() {
- roundedCornerResDelegate = spy(RoundedCornerResDelegate(mContext.resources, null))
+ roundedCornerResDelegate = spy(RoundedCornerResDelegateImpl(mContext.resources, null))
}
@Test
diff --git a/packages/SystemUI/tests/src/com/android/systemui/decor/RoundedCornerResDelegateTest.kt b/packages/SystemUI/tests/src/com/android/systemui/decor/RoundedCornerResDelegateTest.kt
index 3912bc0e354e..4feba7bfd359 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/decor/RoundedCornerResDelegateTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/decor/RoundedCornerResDelegateTest.kt
@@ -48,7 +48,7 @@ class RoundedCornerResDelegateTest : SysuiTestCase() {
@Test
fun testTopAndBottomRoundedCornerExist() {
setupResources(radius = 5)
- roundedCornerResDelegate = RoundedCornerResDelegate(mContext.resources, null)
+ roundedCornerResDelegate = RoundedCornerResDelegateImpl(mContext.resources, null)
assertEquals(true, roundedCornerResDelegate.hasTop)
assertEquals(true, roundedCornerResDelegate.hasBottom)
}
@@ -56,7 +56,7 @@ class RoundedCornerResDelegateTest : SysuiTestCase() {
@Test
fun testTopRoundedCornerExist() {
setupResources(radiusTop = 10)
- roundedCornerResDelegate = RoundedCornerResDelegate(mContext.resources, null)
+ roundedCornerResDelegate = RoundedCornerResDelegateImpl(mContext.resources, null)
assertEquals(true, roundedCornerResDelegate.hasTop)
assertEquals(false, roundedCornerResDelegate.hasBottom)
}
@@ -64,7 +64,7 @@ class RoundedCornerResDelegateTest : SysuiTestCase() {
@Test
fun testBottomRoundedCornerExist() {
setupResources(radiusBottom = 15)
- roundedCornerResDelegate = RoundedCornerResDelegate(mContext.resources, null)
+ roundedCornerResDelegate = RoundedCornerResDelegateImpl(mContext.resources, null)
assertEquals(false, roundedCornerResDelegate.hasTop)
assertEquals(true, roundedCornerResDelegate.hasBottom)
}
@@ -75,7 +75,7 @@ class RoundedCornerResDelegateTest : SysuiTestCase() {
roundedTopDrawable = getTestsDrawable(R.drawable.rounded3px),
roundedBottomDrawable = getTestsDrawable(R.drawable.rounded4px))
- roundedCornerResDelegate = RoundedCornerResDelegate(mContext.resources, null)
+ roundedCornerResDelegate = RoundedCornerResDelegateImpl(mContext.resources, null)
assertEquals(Size(3, 3), roundedCornerResDelegate.topRoundedSize)
assertEquals(Size(4, 4), roundedCornerResDelegate.bottomRoundedSize)
@@ -96,7 +96,7 @@ class RoundedCornerResDelegateTest : SysuiTestCase() {
roundedTopDrawable = getTestsDrawable(R.drawable.rounded3px),
roundedBottomDrawable = getTestsDrawable(R.drawable.rounded4px))
- roundedCornerResDelegate = RoundedCornerResDelegate(mContext.resources, null)
+ roundedCornerResDelegate = RoundedCornerResDelegateImpl(mContext.resources, null)
assertEquals(Size(3, 3), roundedCornerResDelegate.topRoundedSize)
assertEquals(Size(4, 4), roundedCornerResDelegate.bottomRoundedSize)
@@ -114,7 +114,7 @@ class RoundedCornerResDelegateTest : SysuiTestCase() {
roundedTopDrawable = getTestsDrawable(R.drawable.rounded4px),
roundedBottomDrawable = getTestsDrawable(R.drawable.rounded4px))
- roundedCornerResDelegate = RoundedCornerResDelegate(mContext.resources, null)
+ roundedCornerResDelegate = RoundedCornerResDelegateImpl(mContext.resources, null)
assertEquals(Size(4, 4), roundedCornerResDelegate.topRoundedSize)
assertEquals(Size(4, 4), roundedCornerResDelegate.bottomRoundedSize)