diff options
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. |