From e599ddbd61fcb513c118633d2ecd4235cf2cf1e6 Mon Sep 17 00:00:00 2001 From: Wenbo Jie Date: Mon, 3 Mar 2025 01:21:43 +0000 Subject: [DocsUI M3] Fix the 3-section layout on compact screen * Update table header height as per spec. * Show table header section for medium/compact screen size with Name column only. * Add divider in compact screen size for header and breadcrumb, make it as 3-section layout, similar to other screen size layouts. * Adjust the bottom section layout in compact screen to prevent breadcrumb section from being shadowed by the saver footer in file saver mode. Check the attached bug for demo. Bug: 399225360 Test: m DocumentsUIGoogle && manual inspection Flag: com.android.documentsui.flags.use_material3 Change-Id: I251da779013964b93835f7820dcf0b4d025cab0a --- .../layout-w900dp/column_headers.xml | 192 ++++++++++----------- .../layout-w900dp/shared_cell_content.xml | 40 ----- .../layout/column_headers.xml | 39 ++++- .../layout/directory_app_bar.xml | 23 ++- .../layout/drawer_layout.xml | 37 ++-- .../layout/shared_cell_content.xml | 40 +++++ .../values-w600dp/dimens.xml | 5 + .../values-w900dp/dimens.xml | 5 + .../values/dimens.xml | 13 +- .../android/documentsui/HorizontalBreadcrumb.java | 11 +- .../android/documentsui/NavigationViewManager.java | 24 ++- .../documentsui/dirlist/DirectoryFragment.java | 7 + .../documentsui/sorting/TableHeaderController.java | 25 ++- 13 files changed, 278 insertions(+), 183 deletions(-) delete mode 100644 res/flag(com.android.documentsui.flags.use_material3)/layout-w900dp/shared_cell_content.xml create mode 100644 res/flag(com.android.documentsui.flags.use_material3)/layout/shared_cell_content.xml diff --git a/res/flag(com.android.documentsui.flags.use_material3)/layout-w900dp/column_headers.xml b/res/flag(com.android.documentsui.flags.use_material3)/layout-w900dp/column_headers.xml index c692b4124..dcd3283b4 100644 --- a/res/flag(com.android.documentsui.flags.use_material3)/layout-w900dp/column_headers.xml +++ b/res/flag(com.android.documentsui.flags.use_material3)/layout-w900dp/column_headers.xml @@ -27,111 +27,103 @@ android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="@dimen/doc_header_height" - android:paddingHorizontal="@dimen/list_container_padding" + android:baselineAligned="false" + android:gravity="center_vertical" + android:paddingStart="@dimen/table_header_padding_start" + android:paddingEnd="@dimen/table_header_padding_end" android:visibility="gone"> - + + + + - - - - - + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + android:layout_weight="0.2" + android:clickable="true" + android:focusable="false" + android:gravity="center_vertical" + android:orientation="horizontal" + android:animateLayoutChanges="true"> + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/res/flag(com.android.documentsui.flags.use_material3)/layout-w900dp/shared_cell_content.xml b/res/flag(com.android.documentsui.flags.use_material3)/layout-w900dp/shared_cell_content.xml deleted file mode 100644 index f269afdbe..000000000 --- a/res/flag(com.android.documentsui.flags.use_material3)/layout-w900dp/shared_cell_content.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/res/flag(com.android.documentsui.flags.use_material3)/layout/column_headers.xml b/res/flag(com.android.documentsui.flags.use_material3)/layout/column_headers.xml index fde349b88..18a8dc8f7 100644 --- a/res/flag(com.android.documentsui.flags.use_material3)/layout/column_headers.xml +++ b/res/flag(com.android.documentsui.flags.use_material3)/layout/column_headers.xml @@ -15,6 +15,39 @@ limitations under the License. --> - - + + + + + + + + + + + \ No newline at end of file diff --git a/res/flag(com.android.documentsui.flags.use_material3)/layout/directory_app_bar.xml b/res/flag(com.android.documentsui.flags.use_material3)/layout/directory_app_bar.xml index 54a6a7cb2..94e4b953d 100644 --- a/res/flag(com.android.documentsui.flags.use_material3)/layout/directory_app_bar.xml +++ b/res/flag(com.android.documentsui.flags.use_material3)/layout/directory_app_bar.xml @@ -23,29 +23,40 @@ android:layout_height="wrap_content" android:touchscreenBlocksFocus="false"> + + app:layout_scrollFlags="noScroll"> - + android:layout_height="wrap_content" + android:orientation="vertical" + android:background="?attr/colorSurfaceBright"> - + + - + - + android:orientation="vertical" + android:layout_gravity="bottom"> - + + + + + + + diff --git a/res/flag(com.android.documentsui.flags.use_material3)/layout/shared_cell_content.xml b/res/flag(com.android.documentsui.flags.use_material3)/layout/shared_cell_content.xml new file mode 100644 index 000000000..f269afdbe --- /dev/null +++ b/res/flag(com.android.documentsui.flags.use_material3)/layout/shared_cell_content.xml @@ -0,0 +1,40 @@ + + + + + + + + \ No newline at end of file diff --git a/res/flag(com.android.documentsui.flags.use_material3)/values-w600dp/dimens.xml b/res/flag(com.android.documentsui.flags.use_material3)/values-w600dp/dimens.xml index 4707991f6..880d6c0b0 100644 --- a/res/flag(com.android.documentsui.flags.use_material3)/values-w600dp/dimens.xml +++ b/res/flag(com.android.documentsui.flags.use_material3)/values-w600dp/dimens.xml @@ -26,5 +26,10 @@ @dimen/main_container_padding_start @dimen/space_extra_small_6 + + + 28dp + + 20dp diff --git a/res/flag(com.android.documentsui.flags.use_material3)/values-w900dp/dimens.xml b/res/flag(com.android.documentsui.flags.use_material3)/values-w900dp/dimens.xml index d37f3af68..24ff2b17b 100644 --- a/res/flag(com.android.documentsui.flags.use_material3)/values-w900dp/dimens.xml +++ b/res/flag(com.android.documentsui.flags.use_material3)/values-w900dp/dimens.xml @@ -36,4 +36,9 @@ @dimen/space_small_3 @dimen/space_small_1 + + + 32dp + + 12dp 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 65740f15c..6735c715b 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 @@ -14,7 +14,7 @@ limitations under the License. --> - + 2dp @@ -23,10 +23,6 @@ 0dp 20dp @dimen/space_extra_small_4 - - 48dp 40dp 48dp 24dp @@ -90,6 +86,11 @@ 24dp 2dp + + 24dp + + 16dp + 28dp 12dp @@ -115,7 +116,7 @@ 8dp 32dp - 60dp + 48dp 12dp 54dp diff --git a/src/com/android/documentsui/HorizontalBreadcrumb.java b/src/com/android/documentsui/HorizontalBreadcrumb.java index 94f0e13f9..cb25479b3 100644 --- a/src/com/android/documentsui/HorizontalBreadcrumb.java +++ b/src/com/android/documentsui/HorizontalBreadcrumb.java @@ -25,6 +25,7 @@ import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; +import androidx.annotation.Nullable; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -45,6 +46,9 @@ public final class HorizontalBreadcrumb extends RecyclerView implements Breadcru private LinearLayoutManager mLayoutManager; private BreadcrumbAdapter mAdapter; private IntConsumer mClickListener; + // Represents the top divider (border) of the breadcrumb on the compact size screen. + // It will be null on other screen sizes, or when the use_material3 flag is OFF. + private @Nullable View mTopDividerView; public HorizontalBreadcrumb(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); @@ -61,12 +65,14 @@ public final class HorizontalBreadcrumb extends RecyclerView implements Breadcru @Override public void setup(Environment env, com.android.documentsui.base.State state, - IntConsumer listener) { + IntConsumer listener, + @Nullable View topDivider) { mClickListener = listener; mLayoutManager = new HorizontalBreadcrumbLinearLayoutManager( getContext(), LinearLayoutManager.HORIZONTAL, false); mAdapter = new BreadcrumbAdapter(state, env, this::onKey); + mTopDividerView = topDivider; // Since we are using GestureDetector to detect click events, a11y services don't know which // views are clickable because we aren't using View.OnClickListener. Thus, we need to use a // custom accessibility delegate to route click events correctly. @@ -109,6 +115,9 @@ public final class HorizontalBreadcrumb extends RecyclerView implements Breadcru setVisibility(GONE); setAdapter(null); } + if (mTopDividerView != null) { + mTopDividerView.setVisibility(visibility ? VISIBLE : GONE); + } mAdapter.updateLastItemSize(); } diff --git a/src/com/android/documentsui/NavigationViewManager.java b/src/com/android/documentsui/NavigationViewManager.java index 86b5e517f..12afbd69b 100644 --- a/src/com/android/documentsui/NavigationViewManager.java +++ b/src/com/android/documentsui/NavigationViewManager.java @@ -27,10 +27,10 @@ import android.graphics.drawable.Drawable; import android.util.Log; import android.view.MenuItem; import android.view.View; +import android.view.ViewGroup; import android.view.ViewOutlineProvider; import android.view.Window; import android.view.WindowManager; -import android.widget.FrameLayout; import androidx.annotation.ColorRes; import androidx.annotation.Nullable; @@ -144,7 +144,13 @@ public class NavigationViewManager extends SelectionTracker.SelectionObserver