Loading packages/SystemUI/src/com/android/systemui/ScreenDecorHwcLayer.kt +6 −1 Original line number Diff line number Diff line Loading @@ -369,10 +369,15 @@ class ScreenDecorHwcLayer(context: Context, displayDecorationSupport: DisplayDec * Update the rounded corner size. */ fun updateRoundedCornerSize(top: Int, bottom: Int) { if (roundedCornerTopSize == top && roundedCornerBottomSize == bottom) { return } roundedCornerTopSize = top roundedCornerBottomSize = bottom updateRoundedCornerDrawableBounds() invalidate() // Use requestLayout() to trigger transparent region recalculated requestLayout() } private fun updateRoundedCornerDrawableBounds() { Loading packages/SystemUI/src/com/android/systemui/ScreenDecorations.java +9 −0 Original line number Diff line number Diff line Loading @@ -1045,13 +1045,22 @@ public class ScreenDecorations extends CoreStartable implements Tunable , Dumpab mExecutor.execute(() -> { if (mOverlays == null) return; if (SIZE.equals(key)) { boolean hasReloadRoundedCornerRes = false; if (newValue != null) { try { mRoundedCornerResDelegate.updateTuningSizeFactor( Integer.parseInt(newValue)); hasReloadRoundedCornerRes = true; } catch (Exception e) { } } // When onTuningChanged() is not called through updateRoundedCornerRadii(), // we need to reload rounded corner res to prevent incorrect dimen if (!hasReloadRoundedCornerRes) { mRoundedCornerResDelegate.reloadAll(mDisplayUniqueId); } updateRoundedCornerSize( mRoundedCornerResDelegate.getTopRoundedSize(), mRoundedCornerResDelegate.getBottomRoundedSize()); Loading packages/SystemUI/src/com/android/systemui/decor/RoundedCornerResDelegate.kt +9 −36 Original line number Diff line number Diff line Loading @@ -56,17 +56,17 @@ class RoundedCornerResDelegate( private set init { reloadDrawables() reloadRes() reloadMeasures() } fun reloadAll(newDisplayUniqueId: String?) { displayUniqueId = newDisplayUniqueId reloadDrawables() reloadRes() reloadMeasures() } private fun reloadDrawables() { private fun reloadRes() { val configIdx = DisplayUtils.getDisplayUniqueIdConfigIndex(res, displayUniqueId) isMultipleRadius = getIsMultipleRadius(configIdx) Loading @@ -85,34 +85,6 @@ class RoundedCornerResDelegate( arrayResId = R.array.config_roundedCornerBottomDrawableArray, backupDrawableId = R.drawable.rounded_corner_bottom ) ?: roundedDrawable // If config_roundedCornerMultipleRadius set as true, ScreenDecorations respect the // (width, height) size of drawable/rounded.xml instead of rounded_corner_radius if (isMultipleRadius) { roundedSize = Size( roundedDrawable?.intrinsicWidth ?: 0, roundedDrawable?.intrinsicHeight ?: 0) topRoundedDrawable?.let { topRoundedSize = Size(it.intrinsicWidth, it.intrinsicHeight) } bottomRoundedDrawable?.let { bottomRoundedSize = Size(it.intrinsicWidth, it.intrinsicHeight) } } else { val defaultRadius = RoundedCorners.getRoundedCornerRadius(res, displayUniqueId) val topRadius = RoundedCorners.getRoundedCornerTopRadius(res, displayUniqueId) val bottomRadius = RoundedCorners.getRoundedCornerBottomRadius(res, displayUniqueId) roundedSize = Size(defaultRadius, defaultRadius) topRoundedSize = Size(topRadius, topRadius) bottomRoundedSize = Size(bottomRadius, bottomRadius) } if (topRoundedSize.width == 0) { topRoundedSize = roundedSize } if (bottomRoundedSize.width == 0) { bottomRoundedSize = roundedSize } } private fun reloadMeasures(roundedSizeFactor: Int? = null) { Loading @@ -137,17 +109,18 @@ class RoundedCornerResDelegate( bottomRoundedSize = Size(bottomRadius, bottomRadius) } roundedSizeFactor ?.let { val length: Int = (it * density).toInt() roundedSize = Size(length, length) } if (topRoundedSize.width == 0) { topRoundedSize = roundedSize } if (bottomRoundedSize.width == 0) { bottomRoundedSize = roundedSize } if (roundedSizeFactor != null && roundedSizeFactor > 0) { val length: Int = (roundedSizeFactor * density).toInt() topRoundedSize = Size(length, length) bottomRoundedSize = Size(length, length) } } fun updateTuningSizeFactor(factor: Int) { Loading packages/SystemUI/tests/src/com/android/systemui/decor/RoundedCornerResDelegateTest.kt +1 −1 Original line number Diff line number Diff line Loading @@ -75,7 +75,7 @@ class RoundedCornerResDelegateTest : SysuiTestCase() { fun testUpdateTuningSizeFactor() { mContext.orCreateTestableResources.addOverrides( mockTypeArray = mockTypedArray, radiusTop = 0, radiusTop = 2, radiusBottom = 0, multipleRadius = false) Loading Loading
packages/SystemUI/src/com/android/systemui/ScreenDecorHwcLayer.kt +6 −1 Original line number Diff line number Diff line Loading @@ -369,10 +369,15 @@ class ScreenDecorHwcLayer(context: Context, displayDecorationSupport: DisplayDec * Update the rounded corner size. */ fun updateRoundedCornerSize(top: Int, bottom: Int) { if (roundedCornerTopSize == top && roundedCornerBottomSize == bottom) { return } roundedCornerTopSize = top roundedCornerBottomSize = bottom updateRoundedCornerDrawableBounds() invalidate() // Use requestLayout() to trigger transparent region recalculated requestLayout() } private fun updateRoundedCornerDrawableBounds() { Loading
packages/SystemUI/src/com/android/systemui/ScreenDecorations.java +9 −0 Original line number Diff line number Diff line Loading @@ -1045,13 +1045,22 @@ public class ScreenDecorations extends CoreStartable implements Tunable , Dumpab mExecutor.execute(() -> { if (mOverlays == null) return; if (SIZE.equals(key)) { boolean hasReloadRoundedCornerRes = false; if (newValue != null) { try { mRoundedCornerResDelegate.updateTuningSizeFactor( Integer.parseInt(newValue)); hasReloadRoundedCornerRes = true; } catch (Exception e) { } } // When onTuningChanged() is not called through updateRoundedCornerRadii(), // we need to reload rounded corner res to prevent incorrect dimen if (!hasReloadRoundedCornerRes) { mRoundedCornerResDelegate.reloadAll(mDisplayUniqueId); } updateRoundedCornerSize( mRoundedCornerResDelegate.getTopRoundedSize(), mRoundedCornerResDelegate.getBottomRoundedSize()); Loading
packages/SystemUI/src/com/android/systemui/decor/RoundedCornerResDelegate.kt +9 −36 Original line number Diff line number Diff line Loading @@ -56,17 +56,17 @@ class RoundedCornerResDelegate( private set init { reloadDrawables() reloadRes() reloadMeasures() } fun reloadAll(newDisplayUniqueId: String?) { displayUniqueId = newDisplayUniqueId reloadDrawables() reloadRes() reloadMeasures() } private fun reloadDrawables() { private fun reloadRes() { val configIdx = DisplayUtils.getDisplayUniqueIdConfigIndex(res, displayUniqueId) isMultipleRadius = getIsMultipleRadius(configIdx) Loading @@ -85,34 +85,6 @@ class RoundedCornerResDelegate( arrayResId = R.array.config_roundedCornerBottomDrawableArray, backupDrawableId = R.drawable.rounded_corner_bottom ) ?: roundedDrawable // If config_roundedCornerMultipleRadius set as true, ScreenDecorations respect the // (width, height) size of drawable/rounded.xml instead of rounded_corner_radius if (isMultipleRadius) { roundedSize = Size( roundedDrawable?.intrinsicWidth ?: 0, roundedDrawable?.intrinsicHeight ?: 0) topRoundedDrawable?.let { topRoundedSize = Size(it.intrinsicWidth, it.intrinsicHeight) } bottomRoundedDrawable?.let { bottomRoundedSize = Size(it.intrinsicWidth, it.intrinsicHeight) } } else { val defaultRadius = RoundedCorners.getRoundedCornerRadius(res, displayUniqueId) val topRadius = RoundedCorners.getRoundedCornerTopRadius(res, displayUniqueId) val bottomRadius = RoundedCorners.getRoundedCornerBottomRadius(res, displayUniqueId) roundedSize = Size(defaultRadius, defaultRadius) topRoundedSize = Size(topRadius, topRadius) bottomRoundedSize = Size(bottomRadius, bottomRadius) } if (topRoundedSize.width == 0) { topRoundedSize = roundedSize } if (bottomRoundedSize.width == 0) { bottomRoundedSize = roundedSize } } private fun reloadMeasures(roundedSizeFactor: Int? = null) { Loading @@ -137,17 +109,18 @@ class RoundedCornerResDelegate( bottomRoundedSize = Size(bottomRadius, bottomRadius) } roundedSizeFactor ?.let { val length: Int = (it * density).toInt() roundedSize = Size(length, length) } if (topRoundedSize.width == 0) { topRoundedSize = roundedSize } if (bottomRoundedSize.width == 0) { bottomRoundedSize = roundedSize } if (roundedSizeFactor != null && roundedSizeFactor > 0) { val length: Int = (roundedSizeFactor * density).toInt() topRoundedSize = Size(length, length) bottomRoundedSize = Size(length, length) } } fun updateTuningSizeFactor(factor: Int) { Loading
packages/SystemUI/tests/src/com/android/systemui/decor/RoundedCornerResDelegateTest.kt +1 −1 Original line number Diff line number Diff line Loading @@ -75,7 +75,7 @@ class RoundedCornerResDelegateTest : SysuiTestCase() { fun testUpdateTuningSizeFactor() { mContext.orCreateTestableResources.addOverrides( mockTypeArray = mockTypedArray, radiusTop = 0, radiusTop = 2, radiusBottom = 0, multipleRadius = false) Loading