summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Wenbo Jie <wenbojie@google.com> 2025-03-18 04:49:50 +0000
committer Wenbo Jie <wenbojie@google.com> 2025-03-18 23:45:11 +0000
commit5a17064b06105fd077943c89ba3ff87e772a56c6 (patch)
tree18aeffbdac03830ab57be7019c03741bc4b040be
parent98129c980bbd136e8971e268609023e10ac88b2f (diff)
[DocsUI M3] Restyle breadcrumb
Check the attached bug for the demo. Bug: 377770982 Test: m DocumentsUIGoogle && manual inspection Flag: com.android.documentsui.flags.use_material3 Change-Id: I62f3b2e84d92730beee5f7d12bc14e00a2daef94
-rw-r--r--res/flag(com.android.documentsui.flags.use_material3)/color/breadcrumb_item_ripple_color.xml20
-rw-r--r--res/flag(com.android.documentsui.flags.use_material3)/color/horizontal_breadcrumb_color.xml6
-rw-r--r--res/flag(com.android.documentsui.flags.use_material3)/drawable/breadcrumb_item_background.xml40
-rw-r--r--res/flag(com.android.documentsui.flags.use_material3)/drawable/breadcrumb_item_mask.xml21
-rw-r--r--res/flag(com.android.documentsui.flags.use_material3)/drawable/ic_breadcrumb_arrow.xml14
-rw-r--r--res/flag(com.android.documentsui.flags.use_material3)/layout/navigation_breadcrumb_item.xml31
-rw-r--r--res/flag(com.android.documentsui.flags.use_material3)/values/colors.xml1
-rw-r--r--res/flag(com.android.documentsui.flags.use_material3)/values/dimens.xml4
-rw-r--r--res/flag(com.android.documentsui.flags.use_material3)/values/styles_text.xml3
-rw-r--r--src/com/android/documentsui/HorizontalBreadcrumb.java7
10 files changed, 99 insertions, 48 deletions
diff --git a/res/flag(com.android.documentsui.flags.use_material3)/color/breadcrumb_item_ripple_color.xml b/res/flag(com.android.documentsui.flags.use_material3)/color/breadcrumb_item_ripple_color.xml
new file mode 100644
index 000000000..1ca24551e
--- /dev/null
+++ b/res/flag(com.android.documentsui.flags.use_material3)/color/breadcrumb_item_ripple_color.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright 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
+
+ https://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:alpha="@dimen/ripple_overlay_alpha" android:color="?attr/colorOnSurfaceVariant"/>
+</selector> \ No newline at end of file
diff --git a/res/flag(com.android.documentsui.flags.use_material3)/color/horizontal_breadcrumb_color.xml b/res/flag(com.android.documentsui.flags.use_material3)/color/horizontal_breadcrumb_color.xml
index ab511326d..f615b257c 100644
--- a/res/flag(com.android.documentsui.flags.use_material3)/color/horizontal_breadcrumb_color.xml
+++ b/res/flag(com.android.documentsui.flags.use_material3)/color/horizontal_breadcrumb_color.xml
@@ -15,7 +15,7 @@
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:state_enabled="true"
- android:color="?android:colorAccent" />
- <item android:color="?android:attr/colorControlNormal" />
+ <item android:state_enabled="false"
+ android:color="?attr/colorOnSurface" />
+ <item android:color="?attr/colorOnSurfaceVariant" />
</selector>
diff --git a/res/flag(com.android.documentsui.flags.use_material3)/drawable/breadcrumb_item_background.xml b/res/flag(com.android.documentsui.flags.use_material3)/drawable/breadcrumb_item_background.xml
index 8e6282199..3ca0191cd 100644
--- a/res/flag(com.android.documentsui.flags.use_material3)/drawable/breadcrumb_item_background.xml
+++ b/res/flag(com.android.documentsui.flags.use_material3)/drawable/breadcrumb_item_background.xml
@@ -17,25 +17,37 @@
<ripple
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
- android:color="?attr/colorControlHighlight">
+ android:color="@color/breadcrumb_item_ripple_color">
<item
android:id="@android:id/mask"
- android:drawable="@android:color/white"/>
+ android:drawable="@drawable/breadcrumb_item_mask"/>
<item>
<selector>
- <item
- app:state_highlighted="true"
- android:drawable="@color/item_breadcrumb_background_hovered"/>
- <item
- app:state_highlighted="false"
- android:drawable="@android:color/transparent">
- <corners
- android:topLeftRadius="2dp"
- android:topRightRadius="2dp"
- android:bottomLeftRadius="2dp"
- android:bottomRightRadius="2dp"
- />
+ <item android:state_pressed="true">
+ <shape android:tint="?attr/colorOnSurfaceVariant">
+ <corners android:radius="@dimen/breadcrumb_item_height" />
+ <solid android:color="@color/overlay_hover_color_percentage" />
+ </shape>
+ </item>
+ <item android:state_focused="true">
+ <shape>
+ <corners android:radius="@dimen/breadcrumb_item_height" />
+ <stroke
+ android:width="@dimen/focus_ring_width"
+ android:color="?attr/colorSecondary" />
+ </shape>
+ </item>
+ <item android:state_hovered="true">
+ <shape android:tint="?attr/colorOnSurfaceVariant">
+ <corners android:radius="@dimen/breadcrumb_item_height" />
+ <solid android:color="@color/overlay_hover_color_percentage" />
+ </shape>
+ </item>
+
+ <!-- Default: use the container background. -->
+ <item>
+ <color android:color="@android:color/transparent"/>
</item>
</selector>
</item>
diff --git a/res/flag(com.android.documentsui.flags.use_material3)/drawable/breadcrumb_item_mask.xml b/res/flag(com.android.documentsui.flags.use_material3)/drawable/breadcrumb_item_mask.xml
new file mode 100644
index 000000000..c64be0765
--- /dev/null
+++ b/res/flag(com.android.documentsui.flags.use_material3)/drawable/breadcrumb_item_mask.xml
@@ -0,0 +1,21 @@
+<?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/breadcrumb_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
diff --git a/res/flag(com.android.documentsui.flags.use_material3)/drawable/ic_breadcrumb_arrow.xml b/res/flag(com.android.documentsui.flags.use_material3)/drawable/ic_breadcrumb_arrow.xml
index 5305b4ae3..8a4aea8ac 100644
--- a/res/flag(com.android.documentsui.flags.use_material3)/drawable/ic_breadcrumb_arrow.xml
+++ b/res/flag(com.android.documentsui.flags.use_material3)/drawable/ic_breadcrumb_arrow.xml
@@ -15,12 +15,12 @@
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="24dp"
- android:height="24dp"
- android:autoMirrored="true"
- android:viewportWidth="24"
- android:viewportHeight="24">
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="960"
+ android:viewportHeight="960"
+ android:autoMirrored="true">
<path
- android:fillColor="?android:attr/colorControlNormal"
- android:pathData="M10,6L8.59,7.41 13.17,12l-4.58,4.59L10,18l6,-6 -6,-6z"/>
+ android:fillColor="?attr/colorSecondary"
+ android:pathData="M504,480L320,296L376,240L616,480L376,720L320,664L504,480Z"/>
</vector>
diff --git a/res/flag(com.android.documentsui.flags.use_material3)/layout/navigation_breadcrumb_item.xml b/res/flag(com.android.documentsui.flags.use_material3)/layout/navigation_breadcrumb_item.xml
index 672343795..ba99ac35d 100644
--- a/res/flag(com.android.documentsui.flags.use_material3)/layout/navigation_breadcrumb_item.xml
+++ b/res/flag(com.android.documentsui.flags.use_material3)/layout/navigation_breadcrumb_item.xml
@@ -15,29 +15,20 @@
limitations under the License.
-->
-
-<!--
- CoordinatorLayout is necessary for various components (e.g. Snackbars, and
- floating action buttons) to operate correctly.
--->
-<!--
- focusableInTouchMode is set in order to force key events to go to the activity's global key
- callback, which is necessary for proper event routing. See BaseActivity.onKeyDown.
--->
-
<LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:minHeight="48dp"
- android:focusable="true"
- android:gravity="center_vertical"
- android:orientation="horizontal">
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:minHeight="@dimen/breadcrumb_height"
+ android:gravity="center_vertical"
+ android:orientation="horizontal">
<TextView
android:id="@+id/breadcrumb_text"
android:layout_width="wrap_content"
- android:layout_height="match_parent"
+ android:layout_height="@dimen/breadcrumb_item_height"
+ android:focusable="true"
+ android:clickable="true"
android:maxWidth="275dp"
android:gravity="center_vertical"
android:maxLines="1"
@@ -47,8 +38,8 @@
<ImageView
android:id="@+id/breadcrumb_arrow"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
+ android:layout_width="@dimen/breadcrumb_item_arrow_size"
+ android:layout_height="@dimen/breadcrumb_item_arrow_size"
android:src="@drawable/ic_breadcrumb_arrow"/>
</LinearLayout> \ No newline at end of file
diff --git a/res/flag(com.android.documentsui.flags.use_material3)/values/colors.xml b/res/flag(com.android.documentsui.flags.use_material3)/values/colors.xml
index 84a8f720a..fe98c92b5 100644
--- a/res/flag(com.android.documentsui.flags.use_material3)/values/colors.xml
+++ b/res/flag(com.android.documentsui.flags.use_material3)/values/colors.xml
@@ -29,6 +29,7 @@
<!-- TODO(b/379776735): remove this after use_material3 flag is launched. -->
<color name="chip_background_disable_color">#fff1f3f4</color>
<color name="menu_search_background">@android:color/transparent</color>
+ <!-- TODO(b/379776735): remove this after use_material3 flag is launched. -->
<color name="item_breadcrumb_background_hovered">#1affffff</color>
<!-- All the colors used inside the drag drop badge don't support Material color attributes
diff --git a/res/flag(com.android.documentsui.flags.use_material3)/values/dimens.xml b/res/flag(com.android.documentsui.flags.use_material3)/values/dimens.xml
index 16f75313c..8c1fb7440 100644
--- a/res/flag(com.android.documentsui.flags.use_material3)/values/dimens.xml
+++ b/res/flag(com.android.documentsui.flags.use_material3)/values/dimens.xml
@@ -66,7 +66,9 @@
<dimen name="breadcrumb_item_padding_horizontal">12dp</dimen>
<dimen name="breadcrumb_item_padding_vertical">6dp</dimen>
<dimen name="breadcrumb_item_arrow_padding">@dimen/space_extra_small_2</dimen>
- <dimen name="breadcrumb_item_height">36dp</dimen>
+ <dimen name="breadcrumb_item_height">32dp</dimen>
+ <dimen name="breadcrumb_height">48dp</dimen>
+ <dimen name="breadcrumb_item_arrow_size">16dp</dimen>
<dimen name="dir_elevation">8dp</dimen>
<dimen name="drag_shadow_size">120dp</dimen>
<dimen name="grid_item_width">150dp</dimen>
diff --git a/res/flag(com.android.documentsui.flags.use_material3)/values/styles_text.xml b/res/flag(com.android.documentsui.flags.use_material3)/values/styles_text.xml
index 37dd8a135..2f400ea24 100644
--- a/res/flag(com.android.documentsui.flags.use_material3)/values/styles_text.xml
+++ b/res/flag(com.android.documentsui.flags.use_material3)/values/styles_text.xml
@@ -96,9 +96,8 @@
<item name="fontFamily">@string/config_fontFamilyMedium</item>
</style>
- <style name="BreadcrumbText" parent="@style/TextAppearance.Widget.AppCompat.Toolbar.Subtitle">
+ <style name="BreadcrumbText" parent="@style/TextAppearance.Material3.TitleSmall">
<item name="android:textColor">@color/horizontal_breadcrumb_color</item>
- <item name="android:textSize">14sp</item>
<item name="fontFamily">@string/config_fontFamilyMedium</item>
</style>
diff --git a/src/com/android/documentsui/HorizontalBreadcrumb.java b/src/com/android/documentsui/HorizontalBreadcrumb.java
index f47f464c0..9d2fc723e 100644
--- a/src/com/android/documentsui/HorizontalBreadcrumb.java
+++ b/src/com/android/documentsui/HorizontalBreadcrumb.java
@@ -192,7 +192,12 @@ public final class HorizontalBreadcrumb extends RecyclerView implements Breadcru
holder.mTitle.setText(
isFirst ? mEnv.getCurrentRoot().title : mState.stack.get(position).displayName);
- holder.mTitle.setEnabled(isLast);
+ if (isUseMaterial3FlagEnabled()) {
+ // The last path part in the breadcrumb is not clickable.
+ holder.mTitle.setEnabled(!isLast);
+ } else {
+ holder.mTitle.setEnabled(isLast);
+ }
if (isUseMaterial3FlagEnabled()) {
final int paddingHorizontal =
(int)