summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Luciano Pacheco <lucmult@google.com> 2024-12-05 14:49:34 +1100
committer Luciano Pacheco <lucmult@google.com> 2024-12-13 08:24:16 +1100
commitdb8b95325052b2f6c64f295d807c5965b4ec928d (patch)
treede280c99c70fe3a7b46103559043647d81410dce
parent9ffb04ab54ae461738597e3e2af42864a0fd6ef3 (diff)
DocsUI M3: Move parts of the app bar around
This CL mostly just move things around, follow up restyles them. Move the buttons/menu-items: sub_menu_grid and sub_menu_list from the sub_menu to options_menu_search. Update logic handling their visibility to account for this move. Move the breadcrumb to the bottom without re-styling it yet, so its appearance isn't ideal yet. Update the Snackbars to be anchored on coordinator_layout instead of container_save because it snackbar messages were pushing the breadcrumb up when displaying the message. Test: Manual build, deploy apk and start it on DUT with flag off Flag: com.android.documentsui.flags.use_material3 Bug: 377771946 Change-Id: Ie27cf066a65a7a89931c1f16c537dcedd0008f22
-rw-r--r--res/flag(com.android.documentsui.flags.use_material3)/layout/directory_header.xml31
-rw-r--r--res/flag(com.android.documentsui.flags.use_material3)/layout/drawer_layout.xml7
-rw-r--r--res/flag(com.android.documentsui.flags.use_material3)/layout/fixed_layout.xml5
-rw-r--r--res/flag(com.android.documentsui.flags.use_material3)/menu/activity.xml10
-rw-r--r--res/flag(com.android.documentsui.flags.use_material3)/menu/sub_menu.xml31
-rw-r--r--src/com/android/documentsui/BaseActivity.java28
-rw-r--r--src/com/android/documentsui/MenuManager.java15
-rw-r--r--src/com/android/documentsui/ui/Snackbars.java7
8 files changed, 65 insertions, 69 deletions
diff --git a/res/flag(com.android.documentsui.flags.use_material3)/layout/directory_header.xml b/res/flag(com.android.documentsui.flags.use_material3)/layout/directory_header.xml
index 8d8bd7f8a..2c8728de4 100644
--- a/res/flag(com.android.documentsui.flags.use_material3)/layout/directory_header.xml
+++ b/res/flag(com.android.documentsui.flags.use_material3)/layout/directory_header.xml
@@ -20,10 +20,6 @@
android:layout_height="wrap_content"
android:orientation="vertical">
- <com.android.documentsui.HorizontalBreadcrumb
- android:id="@+id/horizontal_breadcrumb"
- android:layout_width="match_parent"
- android:layout_height="wrap_content" />
<!-- used for search chip. -->
<include layout="@layout/search_chip_row"/>
@@ -62,33 +58,6 @@
<!-- used for apps row. -->
<include layout="@layout/apps_row"/>
- <LinearLayout
- android:id="@+id/header_container"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginStart="@dimen/root_info_header_horizontal_padding"
- android:layout_marginEnd="@dimen/root_info_header_horizontal_padding"
- android:minHeight="@dimen/root_info_header_height"
- android:accessibilityHeading="true">
-
- <TextView
- android:id="@+id/header_title"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:textAppearance="@style/SectionHeader"
- android:maxLines="1"
- android:ellipsize="end"
- android:gravity="start|center_vertical"/>
-
- <androidx.appcompat.widget.ActionMenuView
- android:id="@+id/sub_menu"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="end|center_vertical"/>
-
- </LinearLayout>
-
<!-- column headers are empty on small screens, in portrait or in grid mode. -->
<include layout="@layout/column_headers"/>
diff --git a/res/flag(com.android.documentsui.flags.use_material3)/layout/drawer_layout.xml b/res/flag(com.android.documentsui.flags.use_material3)/layout/drawer_layout.xml
index 58ef57f58..2f52fd9e7 100644
--- a/res/flag(com.android.documentsui.flags.use_material3)/layout/drawer_layout.xml
+++ b/res/flag(com.android.documentsui.flags.use_material3)/layout/drawer_layout.xml
@@ -60,6 +60,13 @@
android:layout_height="match_parent"/>
</FrameLayout>
+ <com.android.documentsui.HorizontalBreadcrumb
+ android:id="@+id/horizontal_breadcrumb"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="bottom"
+ />
+
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/container_save"
android:layout_width="match_parent"
diff --git a/res/flag(com.android.documentsui.flags.use_material3)/layout/fixed_layout.xml b/res/flag(com.android.documentsui.flags.use_material3)/layout/fixed_layout.xml
index 682edcb7d..28fa67009 100644
--- a/res/flag(com.android.documentsui.flags.use_material3)/layout/fixed_layout.xml
+++ b/res/flag(com.android.documentsui.flags.use_material3)/layout/fixed_layout.xml
@@ -99,6 +99,11 @@
</FrameLayout>
+ <com.android.documentsui.HorizontalBreadcrumb
+ android:id="@+id/horizontal_breadcrumb"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
+
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/container_save"
android:layout_width="match_parent"
diff --git a/res/flag(com.android.documentsui.flags.use_material3)/menu/activity.xml b/res/flag(com.android.documentsui.flags.use_material3)/menu/activity.xml
index 98b12efe3..16b0f82af 100644
--- a/res/flag(com.android.documentsui.flags.use_material3)/menu/activity.xml
+++ b/res/flag(com.android.documentsui.flags.use_material3)/menu/activity.xml
@@ -33,6 +33,16 @@
android:visible="false"
app:showAsAction="always|collapseActionView"
app:actionViewClass="androidx.appcompat.widget.SearchView"/>
+ <item
+ android:id="@+id/sub_menu_grid"
+ android:title="@string/menu_grid"
+ android:icon="@drawable/ic_menu_view_grid"
+ app:showAsAction="always" />
+ <item
+ android:id="@+id/sub_menu_list"
+ android:title="@string/menu_list"
+ android:icon="@drawable/ic_menu_view_list"
+ app:showAsAction="always" />
<!-- This group is being hidden when searching is in full bar mode-->
<group android:id="@+id/group_hide_when_searching">
<item
diff --git a/res/flag(com.android.documentsui.flags.use_material3)/menu/sub_menu.xml b/res/flag(com.android.documentsui.flags.use_material3)/menu/sub_menu.xml
deleted file mode 100644
index 80d6d2cda..000000000
--- a/res/flag(com.android.documentsui.flags.use_material3)/menu/sub_menu.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2024 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.
--->
-
-<menu
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto">
-
- <item
- android:id="@+id/sub_menu_grid"
- android:title="@string/menu_grid"
- android:icon="@drawable/ic_menu_view_grid"
- app:showAsAction="always"/>
- <item
- android:id="@+id/sub_menu_list"
- android:title="@string/menu_list"
- android:icon="@drawable/ic_menu_view_list"
- app:showAsAction="always"/>
-</menu> \ No newline at end of file
diff --git a/src/com/android/documentsui/BaseActivity.java b/src/com/android/documentsui/BaseActivity.java
index b3439d585..fe81fbf16 100644
--- a/src/com/android/documentsui/BaseActivity.java
+++ b/src/com/android/documentsui/BaseActivity.java
@@ -440,9 +440,10 @@ public abstract class BaseActivity
boolean showSearchBar = getResources().getBoolean(R.bool.show_search_bar);
mSearchManager.install(menu, fullBarSearch, showSearchBar);
+ // Remove the subMenu when material3 is launched b/379776735.
final ActionMenuView subMenuView = findViewById(R.id.sub_menu);
// If size is 0, it means the menu has not inflated and it should only do once.
- if (subMenuView.getMenu().size() == 0) {
+ if (subMenuView != null && subMenuView.getMenu().size() == 0) {
subMenuView.setOnMenuItemClickListener(this::onOptionsItemSelected);
getMenuInflater().inflate(R.menu.sub_menu, subMenuView.getMenu());
}
@@ -455,8 +456,14 @@ public abstract class BaseActivity
public boolean onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu);
mSearchManager.showMenu(mState.stack);
- final ActionMenuView subMenuView = findViewById(R.id.sub_menu);
- mInjector.menuManager.updateSubMenu(subMenuView.getMenu());
+ // Remove the subMenu when material3 is launched b/379776735.
+ if (useMaterial3()) {
+ mInjector.menuManager.updateSubMenu(null);
+ } else {
+ final ActionMenuView subMenuView = findViewById(R.id.sub_menu);
+ mInjector.menuManager.updateSubMenu(subMenuView.getMenu());
+ }
+
return true;
}
@@ -759,8 +766,13 @@ public abstract class BaseActivity
LocalPreferences.setViewMode(this, getCurrentRoot(), mode);
mState.derivedMode = mode;
- final ActionMenuView subMenuView = findViewById(R.id.sub_menu);
- mInjector.menuManager.updateSubMenu(subMenuView.getMenu());
+ // Remove the subMenu when material3 is launched b/379776735.
+ if (useMaterial3()) {
+ mInjector.menuManager.updateSubMenu(null);
+ } else {
+ final ActionMenuView subMenuView = findViewById(R.id.sub_menu);
+ mInjector.menuManager.updateSubMenu(subMenuView.getMenu());
+ }
DirectoryFragment dir = getDirectoryFragment();
if (dir != null) {
@@ -793,6 +805,7 @@ public abstract class BaseActivity
* @param shouldHideHeader whether to hide header container or not
*/
public void updateHeader(boolean shouldHideHeader) {
+ // Remove headContainer when material3 is launched. b/379776735.
View headerContainer = findViewById(R.id.header_container);
if (headerContainer == null) {
updateHeaderTitle();
@@ -840,8 +853,11 @@ public abstract class BaseActivity
break;
}
+ // Remove the headerTitle when material3 is launched b/379776735.
TextView headerTitle = findViewById(R.id.header_title);
- headerTitle.setText(result);
+ if (headerTitle != null) {
+ headerTitle.setText(result);
+ }
}
private String getHeaderRecentTitle() {
diff --git a/src/com/android/documentsui/MenuManager.java b/src/com/android/documentsui/MenuManager.java
index f46ffe482..78339862b 100644
--- a/src/com/android/documentsui/MenuManager.java
+++ b/src/com/android/documentsui/MenuManager.java
@@ -16,6 +16,8 @@
package com.android.documentsui;
+import static com.android.documentsui.flags.Flags.useMaterial3;
+
import android.view.KeyboardShortcutGroup;
import android.view.Menu;
import android.view.MenuInflater;
@@ -98,12 +100,25 @@ public abstract class MenuManager {
updateLauncher(mOptionMenu.findItem(R.id.option_menu_launcher));
updateShowHiddenFiles(mOptionMenu.findItem(R.id.option_menu_show_hidden_files));
+ if (useMaterial3()) {
+ updateModePicker(mOptionMenu.findItem(R.id.sub_menu_grid),
+ mOptionMenu.findItem(R.id.sub_menu_list));
+ }
+
Menus.disableHiddenItems(mOptionMenu);
mSearchManager.updateMenu();
}
public void updateSubMenu(Menu menu) {
+ // Remove the subMenu when material3 is launched b/379776735.
+ if (useMaterial3()) {
+ menu = mOptionMenu;
+ if (menu == null) {
+ return;
+ }
+ }
updateModePicker(menu.findItem(R.id.sub_menu_grid), menu.findItem(R.id.sub_menu_list));
+
}
public void updateModel(Model model) {}
diff --git a/src/com/android/documentsui/ui/Snackbars.java b/src/com/android/documentsui/ui/Snackbars.java
index b45c247b5..c6eaf4661 100644
--- a/src/com/android/documentsui/ui/Snackbars.java
+++ b/src/com/android/documentsui/ui/Snackbars.java
@@ -16,6 +16,8 @@
package com.android.documentsui.ui;
+import static com.android.documentsui.flags.Flags.useMaterial3;
+
import android.app.Activity;
import android.view.Gravity;
import android.view.View;
@@ -110,7 +112,10 @@ public final class Snackbars {
public static final Snackbar makeSnackbar(
Activity activity, CharSequence message, int duration) {
- final View view = activity.findViewById(R.id.container_save);
+ final View view = activity.findViewById(useMaterial3()
+ ? R.id.coordinator_layout
+ : R.id.container_save
+ );
return Snackbar.make(view, message, duration);
}
}