Merge "Add config flag to hide home directory ("Documents") from the roots list. Make home root hidden by default." into nyc-dev

This commit is contained in:
Aga Wronska
2016-03-18 00:54:15 +00:00
committed by Android (Google) Code Review
4 changed files with 37 additions and 6 deletions

View File

@@ -21,4 +21,8 @@
<!-- Intentionally unset. Vendors should set this in an overlay. -->
<string name="trusted_quick_viewer_package" translatable="false"></string>
<bool name="list_divider_inset_left">true</bool>
<!-- Indicates if the home directory should be hidden in the roots list, that is presented
in the drawer/left side panel ) -->
<bool name="home_root_hidden">true</bool>
</resources>

View File

@@ -317,7 +317,10 @@ public class RootsFragment extends Fragment {
for (final RootInfo root : roots) {
final RootItem item = new RootItem(root);
if (root.isLibrary()) {
if (root.isHome() && isHomeRootHidden(context)) {
continue;
} else if (root.isLibrary()) {
if (DEBUG) Log.d(TAG, "Adding " + root + " as library.");
libraries.add(item);
} else {
@@ -367,6 +370,13 @@ public class RootsFragment extends Fragment {
}
}
/*
* Indicates if the home directory should be hidden in the roots list.
*/
private boolean isHomeRootHidden(Context context) {
return context.getResources().getBoolean(R.bool.home_root_hidden);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
final Item item = getItem(position);

View File

@@ -58,18 +58,23 @@ public class FilesActivityUiTest extends ActivityTest<FilesActivity> {
public void testRootsListed() throws Exception {
initTestFiles();
bots.roots.openRoot(ROOT_0_ID);
// Should also have Drive, but that requires pre-configuration of devices
// We omit for now.
bots.roots.assertHasRoots(
bots.roots.assertRootsPresent(
"Images",
"Videos",
"Audio",
"Downloads",
"Documents",
ROOT_0_ID,
ROOT_1_ID);
// Separate logic for "Documents" root, which presence depends on the config setting
boolean homeRootHidden = context.getResources().getBoolean(R.bool.home_root_hidden);
if (homeRootHidden) {
bots.roots.assertRootsAbsent("Documents");
} else {
bots.roots.assertRootsPresent("Documents");
}
}
public void testFilesListed() throws Exception {

View File

@@ -69,7 +69,7 @@ public class RootsListBot extends BaseBot {
mDevice.waitForIdle();
}
public void assertHasRoots(String... labels) throws UiObjectNotFoundException {
public void assertRootsPresent(String... labels) throws UiObjectNotFoundException {
List<String> missing = new ArrayList<>();
for (String label : labels) {
if (!findRoot(label).exists()) {
@@ -82,6 +82,18 @@ public class RootsListBot extends BaseBot {
}
}
public void assertRootsAbsent(String... labels) throws UiObjectNotFoundException {
List<String> unexpected = new ArrayList<>();
for (String label : labels) {
if (findRoot(label).exists()) {
unexpected.add(label);
}
}
if (!unexpected.isEmpty()) {
Assert.fail("Unexpected roots " + unexpected);
}
}
public void assertHasFocus() {
assertHasFocus(ROOTS_LIST_ID);
}