Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eec845be authored by Wenbo Jie's avatar Wenbo Jie
Browse files

[DocsUI M3] Add hover/ripple back to file list

Check the attached bug for demo.

Bug: 399217257
Test: m DocumentsUIGoogle && manual inspection
Flag: com.android.documentsui.flags.use_material3
Change-Id: Ie878e01642dab810b80eb320b12af0bfe3726a80
parent 725f07ab
Loading
Loading
Loading
Loading
+24 −0
Original line number Original line Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2025 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
  -->

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_enabled="false" android:color="@android:color/transparent" />
    <item android:state_selected="true" android:alpha="@dimen/ripple_overlay_alpha"
        android:color="?attr/colorOnPrimaryContainer" />
    <item android:alpha="@dimen/ripple_overlay_alpha"
        android:color="?attr/colorOnSurface" />
</selector>
+101 −54
Original line number Original line Diff line number Diff line
@@ -16,8 +16,16 @@


<!-- Use @color/list_item_selected_background_color instead of the "?attr/colorPrimaryContainer"
<!-- Use @color/list_item_selected_background_color instead of the "?attr/colorPrimaryContainer"
     because the variable is exposed in overlayable.xml. -->
     because the variable is exposed in overlayable.xml. -->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
    <!-- selected -->
    android:color="@color/list_item_ripple_color">

    <!-- The mask below only works for the ripple itself, doesn't work for other <item>s, we
         need to explicitly apply the drawable if the other items also need this mask. -->
    <item android:id="@android:id/mask" android:drawable="@drawable/list_item_mask"/>

    <item>
        <selector>
            <!-- Selected -->
            <item android:state_selected="true" android:state_drag_hovered="true">
            <item android:state_selected="true" android:state_drag_hovered="true">
                <layer-list>
                <layer-list>
                    <item>
                    <item>
@@ -27,7 +35,23 @@
                        </shape>
                        </shape>
                    </item>
                    </item>
                    <item>
                    <item>
                <shape android:tint="?attr/colorOnPrimary">
                        <shape android:tint="?attr/colorOnPrimaryContainer">
                            <corners android:radius="@dimen/list_item_height" />
                            <solid android:color="@color/overlay_hover_color_percentage" />
                        </shape>
                    </item>
                </layer-list>
            </item>
            <item android:state_selected="true" android:state_pressed="true">
                <layer-list>
                    <item>
                        <shape>
                            <corners android:radius="@dimen/list_item_height" />
                            <solid android:color="@color/list_item_selected_background_color" />
                        </shape>
                    </item>
                    <item>
                        <shape android:tint="?attr/colorOnPrimaryContainer">
                            <corners android:radius="@dimen/list_item_height" />
                            <corners android:radius="@dimen/list_item_height" />
                            <solid android:color="@color/overlay_hover_color_percentage" />
                            <solid android:color="@color/overlay_hover_color_percentage" />
                        </shape>
                        </shape>
@@ -57,11 +81,21 @@
                </layer-list>
                </layer-list>
            </item>
            </item>
            <item android:state_selected="true" android:state_hovered="true">
            <item android:state_selected="true" android:state_hovered="true">
                <layer-list>
                    <item>
                        <shape>
                        <shape>
                            <corners android:radius="@dimen/list_item_height" />
                            <corners android:radius="@dimen/list_item_height" />
                            <solid android:color="@color/list_item_selected_background_color" />
                            <solid android:color="@color/list_item_selected_background_color" />
                        </shape>
                        </shape>
                    </item>
                    </item>
                    <item>
                        <shape android:tint="?attr/colorOnPrimaryContainer">
                            <corners android:radius="@dimen/list_item_height" />
                            <solid android:color="@color/overlay_hover_color_percentage" />
                        </shape>
                    </item>
                </layer-list>
            </item>
            <item android:state_selected="true">
            <item android:state_selected="true">
                <shape>
                <shape>
                    <corners android:radius="@dimen/list_item_height" />
                    <corners android:radius="@dimen/list_item_height" />
@@ -69,13 +103,19 @@
                </shape>
                </shape>
            </item>
            </item>


    <!-- unselected -->
            <!-- Unselected -->
            <item android:state_drag_hovered="true">
            <item android:state_drag_hovered="true">
                <shape android:tint="?attr/colorOnSurface">
                <shape android:tint="?attr/colorOnSurface">
                    <corners android:radius="@dimen/list_item_height" />
                    <corners android:radius="@dimen/list_item_height" />
                    <solid android:color="@color/overlay_hover_color_percentage" />
                    <solid android:color="@color/overlay_hover_color_percentage" />
                </shape>
                </shape>
            </item>
            </item>
            <item android:state_pressed="true">
                <shape android:tint="?attr/colorOnSurface">
                    <corners android:radius="@dimen/list_item_height" />
                    <solid android:color="@color/overlay_hover_color_percentage" />
                </shape>
            </item>
            <item android:state_focused="true">
            <item android:state_focused="true">
                <shape>
                <shape>
                    <corners android:radius="@dimen/list_item_height" />
                    <corners android:radius="@dimen/list_item_height" />
@@ -85,9 +125,16 @@
                </shape>
                </shape>
            </item>
            </item>
            <item android:state_hovered="true">
            <item android:state_hovered="true">
        <color android:color="@android:color/transparent"/>
                <shape android:tint="?attr/colorOnSurface">
                    <corners android:radius="@dimen/list_item_height" />
                    <solid android:color="@color/overlay_hover_color_percentage" />
                </shape>
            </item>
            </item>

            <!-- Default: use the container background. -->
            <item>
            <item>
        <color android:color="?attr/colorSurfaceBright"/>
                <color android:color="@android:color/transparent"/>
            </item>
            </item>
        </selector>
        </selector>
    </item>
</ripple>
 No newline at end of file
+21 −0
Original line number Original line Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2025 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.
-->

<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <corners android:radius="@dimen/list_item_height" />
    <!-- The color here doesn't matter, it's just being used as a mask. -->
    <solid android:color="@android:color/white" />
</shape>
 No newline at end of file
+1 −0
Original line number Original line Diff line number Diff line
@@ -205,6 +205,7 @@
    <dimen name="cross_profile_button_message_margin_top">4dp</dimen>
    <dimen name="cross_profile_button_message_margin_top">4dp</dimen>


    <dimen name="focus_ring_width">3dp</dimen>
    <dimen name="focus_ring_width">3dp</dimen>
    <!-- 3dp focus ring width + 2dp gap between the ring and the content -->
    <dimen name="focus_ring_gap">5dp</dimen>
    <dimen name="focus_ring_gap">5dp</dimen>
    <dimen name="hover_overlay_alpha">0.08</dimen>
    <dimen name="hover_overlay_alpha">0.08</dimen>
    <dimen name="ripple_overlay_alpha">0.10</dimen>
    <dimen name="ripple_overlay_alpha">0.10</dimen>