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

Commit acd29b5c authored by Steve McKay's avatar Steve McKay Committed by Android (Google) Code Review
Browse files

Merge "Add "Home" directory support."

parents 7f35036c c6a4cd8c
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24dp"
    android:height="24dp"
    android:viewportWidth="24"
    android:viewportHeight="24">

    <path
        android:fillColor="#000000"
        android:pathData="M20 6h-8l-2-2H4c-1.1 0-1.99 .9 -1.99 2L2 18c0 1.1 .9 2 2 2h16c1.1 0 2-.9
2-2V8c0-1.1-.9-2-2-2zm-5 3c1.1 0 2 .9 2 2s-.9 2-2 2-2-.9-2-2 .9-2 2-2zm4
8h-8v-1c0-1.33 2.67-2 4-2s4 .67 4 2v1z" />
    <path
        android:pathData="M0 0h24v24H0z" />
</vector>
+1 −1
Original line number Diff line number Diff line
@@ -297,7 +297,7 @@ public class RootsFragment extends Fragment {

            for (final RootInfo root : roots) {
                final RootItem item = new RootItem(root);
                if (root.isLibrary()) {
                if (root.isLibrary() || root.isHome()) {
                    libraries.add(item);
                } else {
                    others.add(item);
+13 −3
Original line number Diff line number Diff line
@@ -52,7 +52,7 @@ public class RootInfo implements Durable, Parcelable {
    public static final int TYPE_DOWNLOADS = 5;
    public static final int TYPE_LOCAL = 6;
    public static final int TYPE_MTP = 7;
    public static final int TYPE_CLOUD = 8;
    public static final int TYPE_OTHER = 8;

    public String authority;
    public String rootId;
@@ -168,7 +168,10 @@ public class RootInfo implements Durable, Parcelable {
        derivedMimeTypes = (mimeTypes != null) ? mimeTypes.split("\n") : null;

        // TODO: remove these special case icons
        if (isExternalStorage()) {
        if (isHome()) {
            derivedIcon = R.drawable.ic_root_home;
            derivedType = TYPE_LOCAL;
        } else if (isExternalStorage()) {
            derivedIcon = R.drawable.ic_root_sdcard;
            derivedType = TYPE_LOCAL;
        } else if (isDownloads()) {
@@ -188,7 +191,7 @@ public class RootInfo implements Durable, Parcelable {
        } else if (isMtp()) {
            derivedType = TYPE_MTP;
        } else {
            derivedType = TYPE_CLOUD;
            derivedType = TYPE_OTHER;
        }
    }

@@ -196,6 +199,13 @@ public class RootInfo implements Durable, Parcelable {
        return authority == null && rootId == null;
    }

    public boolean isHome() {
        // Note that "home" is the expected root id for the auto-created
        // user home directory on external storage. The "home" value should
        // match ExternalStorageProvider.ROOT_ID_HOME.
        return isExternalStorage() && "home".equals(rootId);
    }

    public boolean isExternalStorage() {
        return "com.android.externalstorage.documents".equals(authority);
    }
+8 −0
Original line number Diff line number Diff line
@@ -125,6 +125,7 @@ public class FilesActivityUiTest extends InstrumentationTestCase {
                "Videos",
                "Audio",
                "Downloads",
                "Home",
                ROOT_0_ID,
                ROOT_1_ID);
    }
@@ -136,6 +137,13 @@ public class FilesActivityUiTest extends InstrumentationTestCase {
        mBot.assertHasDocuments("file0.log", "file1.png", "file2.csv");
    }

    public void testRootClickSetsWindowTitle() throws Exception {
        initTestFiles();

        mBot.openRoot("Home");
        mBot.assertWindowTitle("Home");
    }

    public void testFilesList_LiveUpdate() throws Exception {
        initTestFiles();

+16 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.documentsui;

import static junit.framework.Assert.assertEquals;

import android.support.test.uiautomator.By;
import android.support.test.uiautomator.BySelector;
import android.support.test.uiautomator.UiDevice;
@@ -80,6 +82,20 @@ class UiBot {
        mDevice.waitForIdle();
    }

    void assertWindowTitle(String expected) {
        // Turns out the title field on a window does not have
        // an id associated with it at runtime (which confuses the hell out of me)
        // In code we address this via "android.R.id.title".
        UiObject2 o = find(By.text(expected));
        // It's a bit of a conceit that we then *assert* that the title
        // is the value that we used to identify the UiObject2.
        // If the preceeding lookup fails, this'll choke with an NPE.
        // But given the issue described in the comment above, we're
        // going to do it anyway. Because we shouldn't be looking up
        // the uiobject by it's expected content :|
        assertEquals(expected, o.getText());
    }

    void assertHasRoots(String... labels) throws UiObjectNotFoundException {
        List<String> missing = new ArrayList<>();
        for (String label : labels) {
Loading