From 1c07abd57742ea85a09546959d8f24e0c94c7f70 Mon Sep 17 00:00:00 2001 From: Bo Majewski Date: Fri, 28 Feb 2025 05:05:53 +0000 Subject: [DocsUI, Search]: Use class name in logging. To make more obvious which version of the loader is calling based method, we change BaseFileLoader to this::class.simpleName. Bug: 381326491 Test: m DocumentsUIGoogle Flag: com.android.documentsui.flags.use_search_v2_read_only Change-Id: Ib8cb36bfe095a6407b649d743a0a5588561cb788 --- src/com/android/documentsui/loaders/BaseFileLoader.kt | 12 ++++++------ src/com/android/documentsui/loaders/FolderLoader.kt | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) 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) -- cgit v1.2.3-59-g8ed1b From 47cd74f7fd16a5d857b0e5e6a8c51abf90280078 Mon Sep 17 00:00:00 2001 From: Wenbo Jie Date: Mon, 17 Mar 2025 04:33:31 +0000 Subject: [DocsUI M3] Use dynamic color for Mime type icons Since dynamic color in RRO Mime type icons is not supported currently, as a workaround, we define a map in our app code to achieve this custom color mapping for certain Mime type icons. Check the attached bug for the before/after comparison. Bug: 380746671 Test: m DocumentsUIGoogle && manual inspection Flag: com.android.documentsui.flags.use_material3 Change-Id: Ibdfa3cc25763b6910be8cee158cc4ec912581683 --- src/com/android/documentsui/IconUtils.java | 49 +++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) 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 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) { -- cgit v1.2.3-59-g8ed1b From 5a17064b06105fd077943c89ba3ff87e772a56c6 Mon Sep 17 00:00:00 2001 From: Wenbo Jie Date: Tue, 18 Mar 2025 04:49:50 +0000 Subject: [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 --- .../color/breadcrumb_item_ripple_color.xml | 20 +++++++++++ .../color/horizontal_breadcrumb_color.xml | 6 ++-- .../drawable/breadcrumb_item_background.xml | 40 ++++++++++++++-------- .../drawable/breadcrumb_item_mask.xml | 21 ++++++++++++ .../drawable/ic_breadcrumb_arrow.xml | 14 ++++---- .../layout/navigation_breadcrumb_item.xml | 31 ++++++----------- .../values/colors.xml | 1 + .../values/dimens.xml | 4 ++- .../values/styles_text.xml | 3 +- .../android/documentsui/HorizontalBreadcrumb.java | 7 +++- 10 files changed, 99 insertions(+), 48 deletions(-) create mode 100644 res/flag(com.android.documentsui.flags.use_material3)/color/breadcrumb_item_ripple_color.xml create mode 100644 res/flag(com.android.documentsui.flags.use_material3)/drawable/breadcrumb_item_mask.xml 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 @@ + + + + + + \ 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 @@ --> - - + + 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 @@ + android:color="@color/breadcrumb_item_ripple_color"> + android:drawable="@drawable/breadcrumb_item_mask"/> - - - + + + + + + + + + + + + + + + + + + + + + + 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 @@ + + + + + + + + \ 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 @@ --> + android:width="24dp" + android:height="24dp" + android:viewportWidth="960" + android:viewportHeight="960" + android:autoMirrored="true"> + android:fillColor="?attr/colorSecondary" + android:pathData="M504,480L320,296L376,240L616,480L376,720L320,664L504,480Z"/> 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. --> - - - - + 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"> \ 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 @@ #fff1f3f4 @android:color/transparent + #1affffff