Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 438368bb authored by Cassy Chun-Crogan's avatar Cassy Chun-Crogan
Browse files

[DocsUI M3] Remove search bar

Remove the search bar (searchbar_title) which only appeared
in Recents so that the backup search icon (option_menu_search) shows
instead.

Bug: 409934594
Test: (with flag on and off) atest FilesActivityUiTest
Flag: com.android.documentsui.flags.use_material3
Change-Id: Ibc01d85a8223fad6af12761bdc0c817ff29c3009
parent f0d52d9e
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -508,7 +508,8 @@ public abstract class BaseActivity
        getMenuInflater().inflate(getRes(R.menu.activity), menu);
        getMenuInflater().inflate(getRes(R.menu.activity), menu);
        mNavigator.update();
        mNavigator.update();
        boolean fullBarSearch = getResources().getBoolean(R.bool.full_bar_search_view);
        boolean fullBarSearch = getResources().getBoolean(R.bool.full_bar_search_view);
        boolean showSearchBar = getResources().getBoolean(R.bool.show_search_bar);
        boolean showSearchBar = isUseMaterial3FlagEnabled() ? false : getResources().getBoolean(
                R.bool.show_search_bar);
        mSearchManager.install(menu, fullBarSearch, showSearchBar);
        mSearchManager.install(menu, fullBarSearch, showSearchBar);


        // Remove the subMenu when material3 is launched b/379776735.
        // Remove the subMenu when material3 is launched b/379776735.
+5 −2
Original line number Original line Diff line number Diff line
@@ -178,7 +178,8 @@ public class NavigationViewManager extends SelectionTracker.SelectionObserver<St
        mCollapsingBarLayout = activity.findViewById(getRes(R.id.collapsing_toolbar));
        mCollapsingBarLayout = activity.findViewById(getRes(R.id.collapsing_toolbar));
        mDefaultActionBarBackground = mToolbar.getBackground();
        mDefaultActionBarBackground = mToolbar.getBackground();
        mDefaultOutlineProvider = mToolbar.getOutlineProvider();
        mDefaultOutlineProvider = mToolbar.getOutlineProvider();
        mShowSearchBar = activity.getResources().getBoolean(R.bool.show_search_bar);
        mShowSearchBar = isUseMaterial3FlagEnabled() ? false : activity.getResources().getBoolean(
                R.bool.show_search_bar);


        final int[] styledAttrs = {android.R.attr.statusBarColor};
        final int[] styledAttrs = {android.R.attr.statusBarColor};
        TypedArray a = mActivity.obtainStyledAttributes(styledAttrs);
        TypedArray a = mActivity.obtainStyledAttributes(styledAttrs);
@@ -408,7 +409,9 @@ public class NavigationViewManager extends SelectionTracker.SelectionObserver<St
            mToolbar.invalidateMenu();
            mToolbar.invalidateMenu();
            boolean fullBarSearch =
            boolean fullBarSearch =
                    mActivity.getResources().getBoolean(R.bool.full_bar_search_view);
                    mActivity.getResources().getBoolean(R.bool.full_bar_search_view);
            boolean showSearchBar = mActivity.getResources().getBoolean(R.bool.show_search_bar);
            boolean showSearchBar =
                    isUseMaterial3FlagEnabled() ? false : mActivity.getResources().getBoolean(
                            R.bool.show_search_bar);
            mInjector.searchManager.install(mToolbar.getMenu(), fullBarSearch, showSearchBar);
            mInjector.searchManager.install(mToolbar.getMenu(), fullBarSearch, showSearchBar);
            if (isVisualSignalsFlagEnabled()) {
            if (isVisualSignalsFlagEnabled()) {
                mInjector.menuManager.instantiateJobProgress(mToolbar.getMenu());
                mInjector.menuManager.instantiateJobProgress(mToolbar.getMenu());
+9 −0
Original line number Original line Diff line number Diff line
@@ -23,6 +23,7 @@ import static androidx.test.espresso.matcher.ViewMatchers.hasFocus;
import static androidx.test.espresso.matcher.ViewMatchers.isAssignableFrom;
import static androidx.test.espresso.matcher.ViewMatchers.isAssignableFrom;
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.withClassName;
import static androidx.test.espresso.matcher.ViewMatchers.withClassName;
import static androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static androidx.test.espresso.matcher.ViewMatchers.withText;
import static androidx.test.espresso.matcher.ViewMatchers.withText;


@@ -124,6 +125,14 @@ public class UiBot extends Bots.BaseBot {
        onView(withId(R.id.searchbar_title)).check(matches(isDisplayed()));
        onView(withId(R.id.searchbar_title)).check(matches(isDisplayed()));
    }
    }


    /**
     * Checks that the search bar is not visible.
     */
    public void assertSearchBarGone() {
        onView(withId(R.id.searchbar_title)).check(
                matches(withEffectiveVisibility(ViewMatchers.Visibility.GONE)));
    }

    /**
    /**
     * Checks that the UI chip that toggles location search menu is visible.
     * Checks that the UI chip that toggles location search menu is visible.
     */
     */
+5 −28
Original line number Original line Diff line number Diff line
@@ -28,8 +28,7 @@ import static com.android.documentsui.base.Providers.AUTHORITY_STORAGE;
import static com.android.documentsui.base.Providers.ROOT_ID_DEVICE;
import static com.android.documentsui.base.Providers.ROOT_ID_DEVICE;
import static com.android.documentsui.flags.Flags.FLAG_USE_MATERIAL3;
import static com.android.documentsui.flags.Flags.FLAG_USE_MATERIAL3;
import static com.android.documentsui.flags.Flags.FLAG_USE_SEARCH_V2_READ_ONLY;
import static com.android.documentsui.flags.Flags.FLAG_USE_SEARCH_V2_READ_ONLY;

import static com.android.documentsui.util.FlagUtils.isUseMaterial3FlagEnabled;
import static com.google.common.truth.TruthJUnit.assume;


import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;
import static junit.framework.Assert.assertTrue;
@@ -84,10 +83,13 @@ public class FilesActivityUiTest extends ActivityTestJunit4<FilesActivity> {
        bots.roots.openRoot("Recent");
        bots.roots.openRoot("Recent");


        boolean showSearchBar =
        boolean showSearchBar =
                context.getResources().getBoolean(R.bool.show_search_bar);
                isUseMaterial3FlagEnabled() ? false : context.getResources().getBoolean(
                        R.bool.show_search_bar);
        if (showSearchBar) {
        if (showSearchBar) {
            bots.main.assertSearchBarShow();
            bots.main.assertSearchBarShow();
        } else {
        } else {
            bots.main.assertSearchBarGone();
            bots.search.assertIconVisible(true);
            bots.main.assertWindowTitle("Recent");
            bots.main.assertWindowTitle("Recent");
        }
        }
    }
    }
@@ -129,29 +131,6 @@ public class FilesActivityUiTest extends ActivityTestJunit4<FilesActivity> {
        assertFalse(bots.directory.hasDocuments(fileName));
        assertFalse(bots.directory.hasDocuments(fileName));
    }
    }


    @Test
    @RequiresFlagsEnabled(FLAG_USE_MATERIAL3)
    public void testRecentsSelectionClearsSearchBar() throws Exception {
        assume().that(context.getResources().getBoolean(R.bool.show_search_bar)).isTrue();

        DocumentsProviderHelper storageDocsHelper = setupStorageAuthorityDocsHelper();
        RootInfo primaryRoot = storageDocsHelper.getRoot(ROOT_ID_DEVICE);
        DocumentInfo info = storageDocsHelper.findFile(primaryRoot.documentId, "Download");

        // Open up Recents and create a file that should appear.
        bots.roots.openRoot("Recent");
        final String fileName = "Recent.txt";
        storageDocsHelper.createDocument(info.documentId, "text/plain", fileName);

        try {
            bots.directory.waitForDocument(fileName);
            bots.directory.selectDocument(fileName, 1);
            bots.directory.selectDocument(fileName);
        } finally {
            cleanupFile(fileName, primaryRoot.title);
        }
    }

    @Test
    @Test
    @RequiresFlagsDisabled(FLAG_USE_MATERIAL3)
    @RequiresFlagsDisabled(FLAG_USE_MATERIAL3)
    public void testRootClick_SetsWindowTitle() throws Exception {
    public void testRootClick_SetsWindowTitle() throws Exception {
@@ -262,8 +241,6 @@ public class FilesActivityUiTest extends ActivityTestJunit4<FilesActivity> {
    @Test
    @Test
    @RequiresFlagsEnabled(FLAG_USE_MATERIAL3)
    @RequiresFlagsEnabled(FLAG_USE_MATERIAL3)
    public void testClearSelectionInRecentsResetsActions() throws Exception {
    public void testClearSelectionInRecentsResetsActions() throws Exception {
        assume().that(context.getResources().getBoolean(R.bool.show_search_bar)).isTrue();

        // Ensure Downloads exists and get the location of the main root (e.g. "Pixel Tablet").
        // Ensure Downloads exists and get the location of the main root (e.g. "Pixel Tablet").
        DocumentsProviderHelper storageDocsHelper = setupStorageAuthorityDocsHelper();
        DocumentsProviderHelper storageDocsHelper = setupStorageAuthorityDocsHelper();
        RootInfo primaryRoot = storageDocsHelper.getRoot(ROOT_ID_DEVICE);
        RootInfo primaryRoot = storageDocsHelper.getRoot(ROOT_ID_DEVICE);