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

Commit 8453b968 authored by Aga Wronska's avatar Aga Wronska
Browse files

Add config flag to hide home directory ("Documents") from the roots list.

Make home root hidden by default.

Change-Id: Ia9f97f3cad7ab102d65e01d6e0dd9bc39ab72f21
Fixed: 27683725
parent 68e52fe6
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -21,4 +21,8 @@
    <!-- Intentionally unset. Vendors should set this in an overlay. -->
    <string name="trusted_quick_viewer_package" translatable="false"></string>
    <bool name="list_divider_inset_left">true</bool>
    <!-- Indicates if the home directory should be hidden in the roots list, that is presented
         in the drawer/left side panel ) -->
    <bool name="home_root_hidden">true</bool>

</resources>
+11 −1
Original line number Diff line number Diff line
@@ -317,7 +317,10 @@ public class RootsFragment extends Fragment {

            for (final RootInfo root : roots) {
                final RootItem item = new RootItem(root);
                if (root.isLibrary()) {

                if (root.isHome() && isHomeRootHidden(context)) {
                    continue;
                } else if (root.isLibrary()) {
                    if (DEBUG) Log.d(TAG, "Adding " + root + " as library.");
                    libraries.add(item);
                } else {
@@ -367,6 +370,13 @@ public class RootsFragment extends Fragment {
            }
        }

        /*
         * Indicates if the home directory should be hidden in the roots list.
         */
        private boolean isHomeRootHidden(Context context) {
            return context.getResources().getBoolean(R.bool.home_root_hidden);
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            final Item item = getItem(position);
+9 −4
Original line number Diff line number Diff line
@@ -58,18 +58,23 @@ public class FilesActivityUiTest extends ActivityTest<FilesActivity> {
    public void testRootsListed() throws Exception {
        initTestFiles();

        bots.roots.openRoot(ROOT_0_ID);

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

        // Separate logic for "Documents" root, which presence depends on the config setting
        boolean homeRootHidden = context.getResources().getBoolean(R.bool.home_root_hidden);
        if (homeRootHidden) {
            bots.roots.assertRootsAbsent("Documents");
        } else {
            bots.roots.assertRootsPresent("Documents");
        }
    }

    public void testFilesListed() throws Exception {
+13 −1
Original line number Diff line number Diff line
@@ -69,7 +69,7 @@ public class RootsListBot extends BaseBot {
        mDevice.waitForIdle();
    }

    public void assertHasRoots(String... labels) throws UiObjectNotFoundException {
    public void assertRootsPresent(String... labels) throws UiObjectNotFoundException {
        List<String> missing = new ArrayList<>();
        for (String label : labels) {
            if (!findRoot(label).exists()) {
@@ -82,6 +82,18 @@ public class RootsListBot extends BaseBot {
        }
    }

    public void assertRootsAbsent(String... labels) throws UiObjectNotFoundException {
        List<String> unexpected = new ArrayList<>();
        for (String label : labels) {
            if (findRoot(label).exists()) {
                unexpected.add(label);
            }
        }
        if (!unexpected.isEmpty()) {
            Assert.fail("Unexpected roots " + unexpected);
        }
    }

    public void assertHasFocus() {
        assertHasFocus(ROOTS_LIST_ID);
    }