summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Josh <jmokut@google.com> 2024-05-15 18:14:44 +0000
committer Josh <jmokut@google.com> 2024-05-16 14:10:00 +0000
commitabf49c1290d2fe151c23a42af30d86f15a40977c (patch)
tree7ea2dc937005c41f76dff39f0f40b91aadbccac7
parentd95cbf18743e9757bace716d6be9f4fdbc2bae59 (diff)
Fixed clipping of qs focus state
Ripple drawable uses some custom draw logic that clips its layers should they attempt to draw outside of its bound. So I've moved focus layer of qs tile background to overlay - now focus state will be rendered as an overlay of the view, avoiding any issues with clipping. Test: Manual test - go/sysui-pkt-manual-testing Fixes: 340897219 Flag: ACONFIG com.android.systemui.qs_tile_focus_state TRUNKFOOD Change-Id: I287cec0ebec97c2494b14ce6c6fde20baf57dd92
-rw-r--r--packages/SystemUI/res/drawable/qs_tile_background_flagged.xml30
-rw-r--r--packages/SystemUI/res/drawable/qs_tile_focused_background.xml18
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt17
3 files changed, 31 insertions, 34 deletions
diff --git a/packages/SystemUI/res/drawable/qs_tile_background_flagged.xml b/packages/SystemUI/res/drawable/qs_tile_background_flagged.xml
index a30a12221105..c32acf2fdea2 100644
--- a/packages/SystemUI/res/drawable/qs_tile_background_flagged.xml
+++ b/packages/SystemUI/res/drawable/qs_tile_background_flagged.xml
@@ -15,16 +15,10 @@
-->
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/qs_tile_ripple_color">
- <!-- We don't really use the ripple effect here, but changing it to LayerDrawable causes
- performance regression, see: b/339412453.
- Since this ripple has just one layer inside, we can try to remove that extra "background"
- layer. However this should only be done when the flag
- com.android.systemui.qs_tile_focus_state has completed all its stages and this drawable
- fully replaces the previous one to ensure consistency with code sections searching for
- specific ids in drawable hierarchy
- -->
<item
- android:id="@id/background">
+ android:id="@android:id/mask"
+ android:drawable="@drawable/qs_tile_background_shape" />
+ <item android:id="@id/background">
<layer-list>
<item
android:id="@+id/qs_tile_background_base"
@@ -32,22 +26,8 @@
<item android:id="@+id/qs_tile_background_overlay">
<selector>
<item
- android:state_hovered="true"
- android:drawable="@drawable/qs_tile_background_shape" />
- </selector>
- </item>
- <!-- In the layer below we have negative insets because we need the focus outline
- to draw outside the bounds, around the main background. We use 5dp because
- the outline stroke is 3dp and the required padding is 2dp.-->
- <item
- android:top="-5dp"
- android:right="-5dp"
- android:left="-5dp"
- android:bottom="-5dp">
- <selector>
- <item
- android:state_focused="true"
- android:drawable="@drawable/qs_tile_focused_background"/>
+ android:drawable="@drawable/qs_tile_background_shape"
+ android:state_hovered="true" />
</selector>
</item>
</layer-list>
diff --git a/packages/SystemUI/res/drawable/qs_tile_focused_background.xml b/packages/SystemUI/res/drawable/qs_tile_focused_background.xml
index fd456df2c9d8..33f0d02efb2a 100644
--- a/packages/SystemUI/res/drawable/qs_tile_focused_background.xml
+++ b/packages/SystemUI/res/drawable/qs_tile_focused_background.xml
@@ -13,10 +13,14 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
-<shape
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
- android:shape="rectangle">
- <corners android:radius="30dp"/>
- <stroke android:width="3dp" android:color="?androidprv:attr/materialColorSecondaryFixed"/>
-</shape> \ No newline at end of file
+
+<inset xmlns:android="http://schemas.android.com/apk/res/android"
+ android:inset="-5dp">
+ <shape xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
+ android:shape="rectangle">
+ <corners android:radius="30dp" />
+ <stroke
+ android:width="3dp"
+ android:color="?androidprv:attr/materialColorSecondaryFixed" />
+ </shape>
+</inset> \ No newline at end of file
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt
index 4fd0df4d3f8f..c6dfdd5c137b 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt
@@ -148,7 +148,8 @@ open class QSTileViewImpl @JvmOverloads constructor(
*/
protected var showRippleEffect = true
- private lateinit var qsTileBackground: LayerDrawable
+ private lateinit var qsTileBackground: RippleDrawable
+ private lateinit var qsTileFocusBackground: Drawable
private lateinit var backgroundDrawable: LayerDrawable
private lateinit var backgroundBaseDrawable: Drawable
private lateinit var backgroundOverlayDrawable: Drawable
@@ -313,10 +314,11 @@ open class QSTileViewImpl @JvmOverloads constructor(
private fun createTileBackground(): Drawable {
qsTileBackground = if (Flags.qsTileFocusState()) {
- mContext.getDrawable(R.drawable.qs_tile_background_flagged) as LayerDrawable
+ mContext.getDrawable(R.drawable.qs_tile_background_flagged) as RippleDrawable
} else {
mContext.getDrawable(R.drawable.qs_tile_background) as RippleDrawable
}
+ qsTileFocusBackground = mContext.getDrawable(R.drawable.qs_tile_focused_background)!!
backgroundDrawable =
qsTileBackground.findDrawableByLayerId(R.id.background) as LayerDrawable
backgroundBaseDrawable =
@@ -332,6 +334,17 @@ open class QSTileViewImpl @JvmOverloads constructor(
updateHeight()
}
+ override fun onFocusChanged(gainFocus: Boolean, direction: Int, previouslyFocusedRect: Rect?) {
+ super.onFocusChanged(gainFocus, direction, previouslyFocusedRect)
+ if (Flags.qsTileFocusState()) {
+ if (gainFocus) {
+ qsTileFocusBackground.setBounds(0, 0, width, height)
+ overlay.add(qsTileFocusBackground)
+ } else {
+ overlay.clear()
+ }
+ }
+ }
private fun updateHeight() {
// TODO(b/332900989): Find a more robust way of resetting the tile if not reset by the
// launch animation.