diff options
3 files changed, 39 insertions, 9 deletions
diff --git a/core/java/android/provider/DocumentsContract.java b/core/java/android/provider/DocumentsContract.java index 77a44859ee5a..084ff7728ca4 100644 --- a/core/java/android/provider/DocumentsContract.java +++ b/core/java/android/provider/DocumentsContract.java @@ -660,6 +660,16 @@ public final class DocumentsContract { } /** + * Builds URI for user home directory on external (local) storage. + * {@hide} + */ + public static Uri buildHomeUri() { + // TODO: Avoid this type of interpackage copying. Added here to avoid + // direct coupling, but not ideal. + return DocumentsContract.buildRootUri("com.android.externalstorage.documents", "home"); + } + + /** * Build URI representing the recently modified documents of a specific root * in a document provider. When queried, a provider will return zero or more * rows with columns defined by {@link Document}. diff --git a/packages/DocumentsUI/src/com/android/documentsui/FilesActivity.java b/packages/DocumentsUI/src/com/android/documentsui/FilesActivity.java index bf44013c59a9..0b6a09f43bfc 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/FilesActivity.java +++ b/packages/DocumentsUI/src/com/android/documentsui/FilesActivity.java @@ -101,21 +101,24 @@ public class FilesActivity extends BaseActivity { // from EXTRA_STACK intent extra. In this case, we'll skip other means of // loading or restoring the stack. if (!mState.stack.isEmpty()) { + if (DEBUG) Log.d(TAG, "Launching with non-empty stack."); // When restoring from a stack, if a URI is present, it should only ever // be a launch URI. Launch URIs support sensible activity management, but - // don't specify an real content target. - if (uri != null) { - checkState(LauncherActivity.isLaunchUri(uri)); - } + // don't specify a real content target. + checkState(uri == null || LauncherActivity.isLaunchUri(uri)); onCurrentDirectoryChanged(ANIM_NONE); } else if (DocumentsContract.isRootUri(this, uri)) { + if (DEBUG) Log.d(TAG, "Launching with root URI."); // If we've got a specific root to display, restore that root using a dedicated // authority. That way a misbehaving provider won't result in an ANR. new RestoreRootTask(uri).executeOnExecutor( ProviderExecutor.forAuthority(uri.getAuthority())); } else { - // Finally, we try to restore a stack from recents. - new RestoreStackTask().execute(); + if (DEBUG) Log.d(TAG, "Launching into Home directory."); + // If all else fails, try to load "Home" directory. + uri = DocumentsContract.buildHomeUri(); + new RestoreRootTask(uri).executeOnExecutor( + ProviderExecutor.forAuthority(uri.getAuthority())); } // TODO: Ensure we're handling CopyService errors correctly across all activities. @@ -159,7 +162,17 @@ public class FilesActivity extends BaseActivity { @Override protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); - updateActionBar(); + // This check avoids a flicker from "Recents" to "Home". + // Only update action bar at this point if there is an active + // serach. Why? Because this avoid an early (undesired) load of + // the recents root...which is the default root in other activities. + // In Files app "Home" is the default, but it is loaded async. + // updateActionBar will be called once Home root is loaded. + // Except while searching we need this call to ensure the + // search bits get layed out correctly. + if (mSearchManager.isSearching()) { + updateActionBar(); + } } @Override diff --git a/packages/DocumentsUI/tests/src/com/android/documentsui/FilesActivityUiTest.java b/packages/DocumentsUI/tests/src/com/android/documentsui/FilesActivityUiTest.java index 71d8b34f6773..f0dbfe97f00c 100644 --- a/packages/DocumentsUI/tests/src/com/android/documentsui/FilesActivityUiTest.java +++ b/packages/DocumentsUI/tests/src/com/android/documentsui/FilesActivityUiTest.java @@ -137,13 +137,20 @@ public class FilesActivityUiTest extends InstrumentationTestCase { mBot.assertHasDocuments("file0.log", "file1.png", "file2.csv"); } - public void testRootClickSetsWindowTitle() throws Exception { + public void testLoadsHomeByDefault() throws Exception { initTestFiles(); - mBot.openRoot("Home"); + mDevice.waitForIdle(); mBot.assertWindowTitle("Home"); } + public void testRootClickSetsWindowTitle() throws Exception { + initTestFiles(); + + mBot.openRoot("Downloads"); + mBot.assertWindowTitle("Downloads"); + } + public void testFilesList_LiveUpdate() throws Exception { initTestFiles(); |