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

Commit 049b22db authored by Tony Huang's avatar Tony Huang
Browse files

Change default root when open document tree

Make action OPEN_DOCUMENT_TREE default root from recent to
spcific root(Downloads) because user cannot pick recent as a
target for OPEN_DOCUMENT_TREE. This root should also hide in
drawer.

Fix: 123328677
Test: atest DocumentUITests
Test: atest DocumentsTest
Test: manual
Change-Id: I3c82fab252b1d6c2b8dbedc802042baaf5208845
parent 6b91e762
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -182,11 +182,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_GET_CONTENT:
            case ACTION_OPEN:
            case ACTION_OPEN_TREE:
                loadRecent();
                break;
            default:
+6 −0
Original line number Diff line number Diff line
@@ -89,6 +89,12 @@ public interface ProvidersAccess {
                continue;
            }

            if (state.action == State.ACTION_OPEN_TREE && root.isRecents()) {
                if (VERBOSE) Log.v(
                        tag, "Excluding recent root because: ACTION_OPEN_TREE.");
                continue;
            }

            if (!state.showAdvanced && root.isAdvanced()) {
                if (VERBOSE) Log.v(tag, "Excluding root because: unwanted advanced device.");
                continue;
+17 −10
Original line number Diff line number Diff line
@@ -180,20 +180,13 @@ public class ActionHandlerTest {
    }

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

    @Test
    public void testInitLocation_DefaultsToDownloads_ActionCreate() throws Exception {
        mEnv.state.action = State.ACTION_CREATE;
        mActivity.resources.bools.put(R.bool.show_documents_root, false);

        mActivity.refreshCurrentRootAndDirectory.assertNotCalled();

        mHandler.initLocation(mActivity.getIntent());

        assertRootPicked(TestProvidersAccess.DOWNLOADS.getUri());
        testInitLocationDefaultToDownloadsOnAction(State.ACTION_CREATE);
    }

    @Test
@@ -509,6 +502,20 @@ public class ActionHandlerTest {
        mActivity.refreshCurrentRootAndDirectory.assertCalled();
    }

    private void testInitLocationDefaultToDownloadsOnAction(@ActionType int action)
            throws Exception {
        mEnv.state.action = action;
        mActivity.resources.bools.put(R.bool.show_documents_root, false);
        mActivity.resources.strings.put(R.string.default_root_uri,
                TestProvidersAccess.DOWNLOADS.getUri().toString());

        mActivity.refreshCurrentRootAndDirectory.assertNotCalled();

        mHandler.initLocation(mActivity.getIntent());

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

    private void assertRootPicked(Uri expectedUri) throws Exception {
        mEnv.beforeAsserts();