diff options
| author | 2023-07-12 16:58:26 +0100 | |
|---|---|---|
| committer | 2023-07-19 13:35:20 +0100 | |
| commit | 328168993c5d6f4412e448d4c6a4b504fd2a01fa (patch) | |
| tree | f5140a9b3f9f2790b131aa802b492a004da8372c | |
| parent | 1672c54654c6475d9a04f120479a3f372b386b01 (diff) | |
Add onRtlPropertiesChanged if layoutDirection changes during
resolveLayoutDirection
ImageView passes layout direction to the drawable in two cases:
1) when the new one is set
2) in onRtlPropertiesChanged.
The problem with `onRtlPropertiesChanged` is that in some cases it might
not be called (ex. when the view is detached from window). Therefore the
view would get an updated state with `resolveLayoutDirection` that doesn't
invoke `onRtlPropertiesChanged` though.
Test: manual on phone: enable for RTL in Developer settings -> open QS
Fixes: 286508181
Change-Id: Id2b62f905197b1abc7130b259a5ebcfc3ff2a2d0
| -rw-r--r-- | packages/SystemUI/res/layout/qs_tile_side_icon.xml | 3 | ||||
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/qs/tileimpl/ChevronImageView.kt | 33 |
2 files changed, 34 insertions, 2 deletions
diff --git a/packages/SystemUI/res/layout/qs_tile_side_icon.xml b/packages/SystemUI/res/layout/qs_tile_side_icon.xml index f1b7259f4c1d..fbcead1cbb8b 100644 --- a/packages/SystemUI/res/layout/qs_tile_side_icon.xml +++ b/packages/SystemUI/res/layout/qs_tile_side_icon.xml @@ -30,12 +30,11 @@ android:visibility="gone" /> - <ImageView + <com.android.systemui.qs.tileimpl.ChevronImageView android:id="@+id/chevron" android:layout_width="@dimen/qs_icon_size" android:layout_height="@dimen/qs_icon_size" android:src="@*android:drawable/ic_chevron_end" - android:autoMirrored="true" android:visibility="gone" android:importantForAccessibility="no" /> diff --git a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/ChevronImageView.kt b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/ChevronImageView.kt new file mode 100644 index 000000000000..8fd1d6f9496b --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/ChevronImageView.kt @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2023 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.qs.tileimpl + +import android.content.Context +import android.util.AttributeSet +import android.widget.ImageView + +class ChevronImageView(context: Context, attrs: AttributeSet?) : ImageView(context, attrs) { + + override fun resolveLayoutDirection(): Boolean { + val previousLayoutDirection = layoutDirection + return super.resolveLayoutDirection().also { resolved -> + if (resolved && layoutDirection != previousLayoutDirection) { + onRtlPropertiesChanged(layoutDirection) + } + } + } +} |