Loading src/com/android/documentsui/BaseActivity.java +2 −1 Original line number Original line Diff line number Diff line Loading @@ -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. Loading src/com/android/documentsui/NavigationViewManager.java +5 −2 Original line number Original line Diff line number Diff line Loading @@ -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); Loading Loading @@ -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()); Loading tests/common/com/android/documentsui/bots/UiBot.java +9 −0 Original line number Original line Diff line number Diff line Loading @@ -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; Loading Loading @@ -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. */ */ Loading tests/functional/com/android/documentsui/FilesActivityUiTest.java +5 −28 Original line number Original line Diff line number Diff line Loading @@ -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; Loading Loading @@ -86,10 +85,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"); } } } } Loading Loading @@ -131,29 +133,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 { Loading Loading @@ -264,8 +243,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); Loading Loading
src/com/android/documentsui/BaseActivity.java +2 −1 Original line number Original line Diff line number Diff line Loading @@ -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. Loading
src/com/android/documentsui/NavigationViewManager.java +5 −2 Original line number Original line Diff line number Diff line Loading @@ -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); Loading Loading @@ -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()); Loading
tests/common/com/android/documentsui/bots/UiBot.java +9 −0 Original line number Original line Diff line number Diff line Loading @@ -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; Loading Loading @@ -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. */ */ Loading
tests/functional/com/android/documentsui/FilesActivityUiTest.java +5 −28 Original line number Original line Diff line number Diff line Loading @@ -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; Loading Loading @@ -86,10 +85,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"); } } } } Loading Loading @@ -131,29 +133,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 { Loading Loading @@ -264,8 +243,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); Loading