Merge "Load Home directory by default."
This commit is contained in:
@@ -659,6 +659,16 @@ public final class DocumentsContract {
|
||||
.authority(authority).appendPath(PATH_ROOT).appendPath(rootId).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -137,11 +137,18 @@ public class FilesActivityUiTest extends InstrumentationTestCase {
|
||||
mBot.assertHasDocuments("file0.log", "file1.png", "file2.csv");
|
||||
}
|
||||
|
||||
public void testLoadsHomeByDefault() throws Exception {
|
||||
initTestFiles();
|
||||
|
||||
mDevice.waitForIdle();
|
||||
mBot.assertWindowTitle("Home");
|
||||
}
|
||||
|
||||
public void testRootClickSetsWindowTitle() throws Exception {
|
||||
initTestFiles();
|
||||
|
||||
mBot.openRoot("Home");
|
||||
mBot.assertWindowTitle("Home");
|
||||
mBot.openRoot("Downloads");
|
||||
mBot.assertWindowTitle("Downloads");
|
||||
}
|
||||
|
||||
public void testFilesList_LiveUpdate() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user