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

Commit 462569ac authored by Ivan Chiang's avatar Ivan Chiang
Browse files

Set the default root to ExternalStroage root in tree mode

Change-Id: I79f2a80acf71612181100a395e729b90980ed81b
Fix: 141600571
Test: atest DocumentsUIGoogleTests:ActionHandlerTest
parent 30414eba
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -565,6 +565,11 @@ public abstract class AbstractActionHandler<T extends FragmentActivity & CommonA
        }
    }

    protected final void loadDeviceRoot() {
        mActivity.onRootPicked(
                mProviders.getRootOneshot(Providers.AUTHORITY_STORAGE, Providers.ROOT_ID_DEVICE));
    }

    protected final void loadHomeDir() {
        loadRoot(Shared.getDefaultRootUri(mActivity));
    }
+3 −1
Original line number Diff line number Diff line
@@ -225,9 +225,11 @@ class ActionHandler<T extends FragmentActivity & Addons> extends AbstractActionH
    private void loadDefaultLocation() {
        switch (mState.action) {
            case ACTION_CREATE:
            case ACTION_OPEN_TREE:
                loadHomeDir();
                break;
            case ACTION_OPEN_TREE:
                loadDeviceRoot();
                break;
            case ACTION_GET_CONTENT:
            case ACTION_OPEN:
                loadRecent();
+11 −7
Original line number Diff line number Diff line
@@ -55,7 +55,6 @@ public class TestProvidersAccess implements ProvidersAccess {
        DOWNLOADS.derivedType = RootInfo.TYPE_DOWNLOADS;
        DOWNLOADS.flags = Root.FLAG_LOCAL_ONLY
                | Root.FLAG_SUPPORTS_CREATE
                | Root.FLAG_SUPPORTS_IS_CHILD
                | Root.FLAG_SUPPORTS_RECENTS;

        HOME = new RootInfo();
@@ -80,12 +79,14 @@ public class TestProvidersAccess implements ProvidersAccess {
        PICKLES.rootId = "pickles";
        PICKLES.title = "Pickles";

        RECENTS = new RootInfo() {{
        RECENTS = new RootInfo() {
            {
                // Special root for recents
                derivedType = RootInfo.TYPE_RECENTS;
            flags = Root.FLAG_LOCAL_ONLY | Root.FLAG_SUPPORTS_IS_CHILD;
                flags = Root.FLAG_LOCAL_ONLY;
                availableBytes = -1;
        }};
            }
        };
        RECENTS.title = "Recents";

        INSPECTOR = new RootInfo();
@@ -118,6 +119,8 @@ public class TestProvidersAccess implements ProvidersAccess {
        EXTERNALSTORAGE.rootId = Providers.ROOT_ID_DEVICE;
        EXTERNALSTORAGE.title = "Device";
        EXTERNALSTORAGE.derivedType = RootInfo.TYPE_LOCAL;
        EXTERNALSTORAGE.flags = Root.FLAG_LOCAL_ONLY
                | Root.FLAG_SUPPORTS_IS_CHILD;
    }

    public final Map<String, Collection<RootInfo>> roots = new HashMap<>();
@@ -128,6 +131,7 @@ public class TestProvidersAccess implements ProvidersAccess {
        add(HOME);
        add(HAMMY);
        add(PICKLES);
        add(EXTERNALSTORAGE);
    }

    private void add(RootInfo root) {
+8 −4
Original line number Diff line number Diff line
@@ -218,13 +218,17 @@ public class ActionHandlerTest {
    }

    @Test
    public void testInitLocation_DefaultToDownloads_ActionOpenTree() throws Exception {
        testInitLocationDefaultToDownloadsOnAction(State.ACTION_OPEN_TREE);
    public void testInitLocation_DefaultsToDownloads_ActionCreate() throws Exception {
        testInitLocationDefaultToDownloadsOnAction(State.ACTION_CREATE);
    }

    @Test
    public void testInitLocation_DefaultsToDownloads_ActionCreate() throws Exception {
        testInitLocationDefaultToDownloadsOnAction(State.ACTION_CREATE);
    public void testInitLocation_DefaultToDeviceRoot_ActionOpenTree() throws Exception {
        mEnv.state.action = State.ACTION_OPEN_TREE;

        mHandler.initLocation(mActivity.getIntent());

        assertRootPicked(TestProvidersAccess.EXTERNALSTORAGE.getUri());
    }

    @Test