Skip to content

Commit

Permalink
[Dialog] Fix crashes when colorControlHighlight is a CSL
Browse files Browse the repository at this point in the history
We set ?attr/colorControlHighlight as scroll indicators' background attribute. However, on older platforms this will crash the app due to Android expects a drawable or a plain color for the background attribute.

Changes the view to TextView so it will be rendered as MaterialTextView, which supports app:backgroundTint with CSLs. Also changes the base background color to #1F000000 and the tint color to ?attr/colorForeground, which are aligned with what framework's alert dialog implementation is doing.

Resolves #2455

PiperOrigin-RevId: 423917985
  • Loading branch information
drchen authored and dsn5ft committed Jan 25, 2022
1 parent 9a5ec35 commit 1c5c054
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
-->
<androidx.appcompat.widget.AlertDialogLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/parentPanel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand All @@ -30,12 +31,14 @@
android:layout_height="wrap_content"
android:minHeight="48dp">

<View android:id="@+id/scrollIndicatorUp"
<ImageView android:id="@+id/scrollIndicatorUp"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_gravity="top"
android:background="?attr/colorControlHighlight"
android:visibility="gone"/>
android:background="#1f000000"
android:visibility="gone"
android:contentDescription="@null"
app:backgroundTint="?android:attr/colorForeground"/>

<androidx.core.widget.NestedScrollView
android:id="@+id/scrollView"
Expand Down Expand Up @@ -70,12 +73,14 @@
</LinearLayout>
</androidx.core.widget.NestedScrollView>

<View android:id="@+id/scrollIndicatorDown"
<ImageView android:id="@+id/scrollIndicatorDown"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_gravity="bottom"
android:background="?attr/colorControlHighlight"
android:visibility="gone"/>
android:background="#1f000000"
android:visibility="gone"
android:contentDescription="@null"
app:backgroundTint="?android:attr/colorForeground"/>

</FrameLayout>

Expand Down

0 comments on commit 1c5c054

Please sign in to comment.