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

Commit bb3cd8d5 authored by Nigel Tao's avatar Nigel Tao Committed by Android (Google) Code Review
Browse files

Merge "DocsUI M3: add show_media_roots config" into main

parents abb27a5c f2109100
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@
  int feature_notification_channel;
  int full_bar_search_view;
  int is_launcher_enabled;
  int show_media_roots;
  int show_search_bar;
  int show_apps_row;
}
+3 −0
Original line number Diff line number Diff line
@@ -26,6 +26,9 @@
         layouts we reduce this to an input-box adjacent to menu actions. -->
    <bool name="full_bar_search_view">true</bool>

    <!-- Indicates if showing Audio / Downloads / Images / Video roots -->
    <bool name="show_media_roots">true</bool>

    <!-- Indicates if showing as search bar design -->
    <bool name="show_search_bar">false</bool>

+7 −6
Original line number Diff line number Diff line
@@ -39,9 +39,9 @@
            <!-- END THEME / STYLE -->

            <!-- START COLOR -->
            <item type="color" name="primary"/>
            <item type="color" name="list_item_selected_background_color"/>
            <item type="color" name="color_surface_header"/>
            <item type="color" name="list_item_selected_background_color"/>
            <item type="color" name="primary"/>
            <!-- END COLOR -->

            <!-- START DIMEN -->
@@ -50,22 +50,23 @@
            <!-- END DIMEN -->

            <!-- START DRAWABLE -->
            <item type="drawable" name="ic_advanced_shortcut"/>
            <item type="drawable" name="ic_eject"/>
            <item type="drawable" name="ic_root_download"/>
            <item type="drawable" name="ic_sd_storage"/>
            <item type="drawable" name="ic_root_smartphone"/>
            <item type="drawable" name="ic_sd_storage"/>
            <item type="drawable" name="root_list_selector"/>
            <item type="drawable" name="ic_advanced_shortcut"/>
            <!-- END DRAWABLE -->

            <!-- START BOOLEAN CONFIG -->
            <item type="bool" name="config_button_all_caps"/>
            <item type="bool" name="config_default_show_device_root"/>
            <item type="bool" name="force_material3"/>
            <item type="bool" name="handle_view_downloads_intent"/>
            <item type="bool" name="is_launcher_enabled"/>
            <item type="bool" name="show_search_bar"/>
            <item type="bool" name="show_apps_row"/>
            <item type="bool" name="force_material3"/>
            <item type="bool" name="show_media_roots"/>
            <item type="bool" name="show_search_bar"/>
            <!-- END BOOLEAN CONFIG -->

            <!-- START STRING CONFIG -->
+4 −4
Original line number Diff line number Diff line
@@ -476,18 +476,18 @@ public class RootsFragment extends Fragment {
        final RootItemListBuilder storageProvidersBuilder = new RootItemListBuilder(selectedUser,
                userIds);
        final List<RootItem> otherProviders = new ArrayList<>();
        final boolean hideMediaRoots = isUseMaterial3FlagEnabled()
                && !getResources().getBoolean(R.bool.show_media_roots);

        for (final RootInfo root : roots) {
            final RootItem item;

            if (root.isExternalStorageHome()) {
                continue;
            } else if (isUseMaterial3FlagEnabled()
                    && context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_PC)
                // No-op.
            } else if (hideMediaRoots
                    && (root.isImages() || root.isVideos()
                    || root.isDocuments()
                    || root.isAudio())) {
                // Hide Images/Videos/Documents/Audio roots on desktop.
                Log.d(TAG, "Hiding " + root);
            } else if (root.isLibrary() || root.isDownloads()) {
                item =
+3 −33
Original line number Diff line number Diff line
@@ -18,11 +18,6 @@ package com.android.documentsui;

import static com.android.documentsui.StubProvider.ROOT_0_ID;
import static com.android.documentsui.StubProvider.ROOT_1_ID;
import static com.android.documentsui.flags.Flags.FLAG_USE_MATERIAL3;

import android.content.pm.PackageManager;
import android.platform.test.annotations.RequiresFlagsDisabled;
import android.platform.test.annotations.RequiresFlagsEnabled;

import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.LargeTest;
@@ -68,43 +63,18 @@ public class FilesActivityDefaultsUiTest extends ActivityTestJunit4<FilesActivit

    @Test
    @HugeLongTest
    @RequiresFlagsDisabled(FLAG_USE_MATERIAL3)
    public void testDefaultRoots_useMaterial3FlagDisabled() throws Exception {
    public void testDefaultRoots() throws Exception {
        device.waitForIdle();

        // Should also have Drive, but that requires pre-configuration of devices
        // We omit for now.
        bots.roots.assertRootsPresent(
                "Images",
                "Videos",
                "Audio",
                "Downloads",
                ROOT_0_ID,
                ROOT_1_ID);
    }

    @Test
    @HugeLongTest
    @RequiresFlagsEnabled(FLAG_USE_MATERIAL3)
    public void testDefaultRoots_useMaterial3FlagEnabled() throws Exception {
        device.waitForIdle();

        String[] expectedRoots;
        if (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_PC)) {
            expectedRoots = new String[]{"Downloads",
                    ROOT_0_ID,
                    ROOT_1_ID};
        } else {
            expectedRoots = new String[]{
                    "Images",
                    "Videos",
                    "Audio",
                    "Downloads",
                    ROOT_0_ID,
                    ROOT_1_ID};
        if (context.getResources().getBoolean(R.bool.show_media_roots)) {
            bots.roots.assertRootsPresent("Audio", "Images");
        }
        // Should also have Drive, but that requires pre-configuration of devices
        // We omit for now.
        bots.roots.assertRootsPresent(expectedRoots);
    }
}