summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Android Build Coastguard Worker <android-build-coastguard-worker@google.com> 2025-03-19 16:43:22 -0700
committer Android Build Coastguard Worker <android-build-coastguard-worker@google.com> 2025-03-19 16:43:22 -0700
commit6f688e13e1397a56bdd3eeaaaf04d30414ae795b (patch)
treea678af14f7145c90ac6b3477030831be17c05a9f
parent678049b831ed7ccc0d70c3d9051ddd45b12f9ff4 (diff)
parentbe161fd3c293aaac948629c8660331a83ed5f89c (diff)
Snap for 13241370 from be161fd3c293aaac948629c8660331a83ed5f89c to 25Q2-release
Change-Id: Ia5daa6a897279d3c1d13117738622e964d4dfbce
-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
-rw-r--r--src/com/android/documentsui/IconUtils.java49
-rw-r--r--src/com/android/documentsui/loaders/BaseFileLoader.kt12
-rw-r--r--src/com/android/documentsui/loaders/FolderLoader.kt2
13 files changed, 154 insertions, 56 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)
diff --git a/src/com/android/documentsui/IconUtils.java b/src/com/android/documentsui/IconUtils.java
index ece38bb64..477209150 100644
--- a/src/com/android/documentsui/IconUtils.java
+++ b/src/com/android/documentsui/IconUtils.java
@@ -16,19 +16,56 @@
package com.android.documentsui;
+import static com.android.documentsui.util.FlagUtils.isUseMaterial3FlagEnabled;
+
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.pm.ProviderInfo;
+import android.content.res.Resources;
import android.graphics.Outline;
import android.graphics.drawable.Drawable;
+import android.graphics.drawable.Icon;
import android.util.TypedValue;
import android.view.View;
import android.view.ViewOutlineProvider;
import android.widget.ImageView;
import com.android.documentsui.base.UserId;
+import com.android.documentsui.util.ColorUtils;
+
+import java.util.HashMap;
+import java.util.Map;
public class IconUtils {
+ // key: drawable resource id, value: color attribute id
+ private static final Map<Integer, Integer> sCustomIconColorMap = new HashMap<>();
+
+ static {
+ if (isUseMaterial3FlagEnabled()) {
+ // Use Resources.getSystem().getIdentifier() here instead of R.drawable.ic_doc_folder
+ // because com.android.internal.R is not public.
+ sCustomIconColorMap.put(
+ Resources.getSystem().getIdentifier("ic_doc_folder", "drawable", "android"),
+ com.google.android.material.R.attr.colorPrimaryFixedDim);
+ sCustomIconColorMap.put(
+ Resources.getSystem().getIdentifier("ic_doc_generic", "drawable", "android"),
+ com.google.android.material.R.attr.colorOutline);
+ sCustomIconColorMap.put(
+ Resources.getSystem()
+ .getIdentifier("ic_doc_certificate", "drawable", "android"),
+ com.google.android.material.R.attr.colorOutline);
+ sCustomIconColorMap.put(
+ Resources.getSystem().getIdentifier("ic_doc_codes", "drawable", "android"),
+ com.google.android.material.R.attr.colorOutline);
+ sCustomIconColorMap.put(
+ Resources.getSystem().getIdentifier("ic_doc_contact", "drawable", "android"),
+ com.google.android.material.R.attr.colorOutline);
+ sCustomIconColorMap.put(
+ Resources.getSystem().getIdentifier("ic_doc_font", "drawable", "android"),
+ com.google.android.material.R.attr.colorOutline);
+ }
+ }
+
public static Drawable loadPackageIcon(Context context, UserId userId, String authority,
int icon, boolean maybeShowBadge) {
if (icon != 0) {
@@ -65,7 +102,17 @@ public class IconUtils {
*/
public static Drawable loadMimeIcon(Context context, String mimeType) {
if (mimeType == null) return null;
- return context.getContentResolver().getTypeInfo(mimeType).getIcon().loadDrawable(context);
+ Icon icon = context.getContentResolver().getTypeInfo(mimeType).getIcon();
+ Drawable drawable = icon.loadDrawable(context);
+ // TODO(b/400263417): Remove this once RRO mime icons support dynamic colors.
+ if (isUseMaterial3FlagEnabled()
+ && drawable != null
+ && sCustomIconColorMap.containsKey(icon.getResId())) {
+ drawable.setTint(
+ ColorUtils.resolveMaterialColorAttribute(
+ context, sCustomIconColorMap.get(icon.getResId())));
+ }
+ return drawable;
}
public static Drawable applyTintColor(Context context, int drawableId, int tintColorId) {
diff --git a/src/com/android/documentsui/loaders/BaseFileLoader.kt b/src/com/android/documentsui/loaders/BaseFileLoader.kt
index dd76217ac..fcb1d4cb0 100644
--- a/src/com/android/documentsui/loaders/BaseFileLoader.kt
+++ b/src/com/android/documentsui/loaders/BaseFileLoader.kt
@@ -77,7 +77,7 @@ abstract class BaseFileLoader(
private var mResult: DirectoryResult? = null
override fun cancelLoadInBackground() {
- Log.d(TAG, "BasedFileLoader.cancelLoadInBackground")
+ Log.d(TAG, "${this::class.simpleName}.cancelLoadInBackground")
super.cancelLoadInBackground()
synchronized(this) {
@@ -86,7 +86,7 @@ abstract class BaseFileLoader(
}
override fun deliverResult(result: DirectoryResult?) {
- Log.d(TAG, "BasedFileLoader.deliverResult")
+ Log.d(TAG, "${this::class.simpleName}.deliverResult")
if (isReset) {
closeResult(result)
return
@@ -104,7 +104,7 @@ abstract class BaseFileLoader(
}
override fun onStartLoading() {
- Log.d(TAG, "BasedFileLoader.onStartLoading")
+ Log.d(TAG, "${this::class.simpleName}.onStartLoading")
val isCursorStale: Boolean = checkIfCursorStale(mResult)
if (mResult != null && !isCursorStale) {
deliverResult(mResult)
@@ -115,17 +115,17 @@ abstract class BaseFileLoader(
}
override fun onStopLoading() {
- Log.d(TAG, "BasedFileLoader.onStopLoading")
+ Log.d(TAG, "${this::class.simpleName}.onStopLoading")
cancelLoad()
}
override fun onCanceled(result: DirectoryResult?) {
- Log.d(TAG, "BasedFileLoader.onCanceled")
+ Log.d(TAG, "${this::class.simpleName}.onCanceled")
closeResult(result)
}
override fun onReset() {
- Log.d(TAG, "BasedFileLoader.onReset")
+ Log.d(TAG, "${this::class.simpleName}.onReset")
super.onReset()
// Ensure the loader is stopped
diff --git a/src/com/android/documentsui/loaders/FolderLoader.kt b/src/com/android/documentsui/loaders/FolderLoader.kt
index a166ca752..40c15dfe1 100644
--- a/src/com/android/documentsui/loaders/FolderLoader.kt
+++ b/src/com/android/documentsui/loaders/FolderLoader.kt
@@ -60,7 +60,7 @@ class FolderLoader(
mListedDir.authority,
mListedDir.documentId
)
- var cursor =
+ val cursor =
queryLocation(mRoot.rootId, folderChildrenUri, mOptions.otherQueryArgs, ALL_RESULTS)
?: emptyCursor()
cursor.registerContentObserver(mObserver)