Loading packages/DocumentsUI/src/com/android/documentsui/RootsFragment.java +10 −19 Original line number Diff line number Diff line Loading @@ -287,33 +287,24 @@ public class RootsFragment extends Fragment { super(context, 0); final List<RootItem> libraries = new ArrayList<>(); final List<RootItem> clouds = new ArrayList<>(); final List<RootItem> locals = new ArrayList<>(); for (RootInfo root : roots) { RootItem item = new RootItem(root); switch (root.derivedType) { case RootInfo.TYPE_LOCAL: locals.add(item); break; case RootInfo.TYPE_CLOUD: clouds.add(item); break; default: final List<RootItem> others = new ArrayList<>(); for (final RootInfo root : roots) { final RootItem item = new RootItem(root); if (root.isLibrary()) { libraries.add(item); break; } else { others.add(item); } } final RootComparator comp = new RootComparator(); Collections.sort(libraries, comp); Collections.sort(locals, comp); Collections.sort(clouds, comp); Collections.sort(others, comp); addAll(libraries); add(new SpacerItem()); addAll(locals); addAll(clouds); addAll(others); if (includeApps != null) { final PackageManager pm = context.getPackageManager(); Loading packages/DocumentsUI/src/com/android/documentsui/model/RootInfo.java +13 −1 Original line number Diff line number Diff line Loading @@ -51,7 +51,8 @@ public class RootInfo implements Durable, Parcelable { public static final int TYPE_RECENTS = 4; public static final int TYPE_DOWNLOADS = 5; public static final int TYPE_LOCAL = 6; public static final int TYPE_CLOUD = 7; public static final int TYPE_MTP = 7; public static final int TYPE_CLOUD = 8; public String authority; public String rootId; Loading Loading @@ -184,6 +185,8 @@ public class RootInfo implements Durable, Parcelable { derivedType = TYPE_AUDIO; } else if (isRecents()) { derivedType = TYPE_RECENTS; } else if (isMtp()) { derivedType = TYPE_MTP; } else { derivedType = TYPE_CLOUD; } Loading Loading @@ -216,6 +219,15 @@ public class RootInfo implements Durable, Parcelable { && "audio_root".equals(rootId); } public boolean isMtp() { return "com.android.mtp.documents".equals(authority); } public boolean isLibrary() { return derivedType == TYPE_IMAGES || derivedType == TYPE_VIDEO || derivedType == TYPE_AUDIO || derivedType == TYPE_RECENTS || derivedType == TYPE_DOWNLOADS; } @Override public String toString() { return "Root{authority=" + authority + ", rootId=" + rootId + ", title=" + title + "}"; Loading Loading
packages/DocumentsUI/src/com/android/documentsui/RootsFragment.java +10 −19 Original line number Diff line number Diff line Loading @@ -287,33 +287,24 @@ public class RootsFragment extends Fragment { super(context, 0); final List<RootItem> libraries = new ArrayList<>(); final List<RootItem> clouds = new ArrayList<>(); final List<RootItem> locals = new ArrayList<>(); for (RootInfo root : roots) { RootItem item = new RootItem(root); switch (root.derivedType) { case RootInfo.TYPE_LOCAL: locals.add(item); break; case RootInfo.TYPE_CLOUD: clouds.add(item); break; default: final List<RootItem> others = new ArrayList<>(); for (final RootInfo root : roots) { final RootItem item = new RootItem(root); if (root.isLibrary()) { libraries.add(item); break; } else { others.add(item); } } final RootComparator comp = new RootComparator(); Collections.sort(libraries, comp); Collections.sort(locals, comp); Collections.sort(clouds, comp); Collections.sort(others, comp); addAll(libraries); add(new SpacerItem()); addAll(locals); addAll(clouds); addAll(others); if (includeApps != null) { final PackageManager pm = context.getPackageManager(); Loading
packages/DocumentsUI/src/com/android/documentsui/model/RootInfo.java +13 −1 Original line number Diff line number Diff line Loading @@ -51,7 +51,8 @@ public class RootInfo implements Durable, Parcelable { public static final int TYPE_RECENTS = 4; public static final int TYPE_DOWNLOADS = 5; public static final int TYPE_LOCAL = 6; public static final int TYPE_CLOUD = 7; public static final int TYPE_MTP = 7; public static final int TYPE_CLOUD = 8; public String authority; public String rootId; Loading Loading @@ -184,6 +185,8 @@ public class RootInfo implements Durable, Parcelable { derivedType = TYPE_AUDIO; } else if (isRecents()) { derivedType = TYPE_RECENTS; } else if (isMtp()) { derivedType = TYPE_MTP; } else { derivedType = TYPE_CLOUD; } Loading Loading @@ -216,6 +219,15 @@ public class RootInfo implements Durable, Parcelable { && "audio_root".equals(rootId); } public boolean isMtp() { return "com.android.mtp.documents".equals(authority); } public boolean isLibrary() { return derivedType == TYPE_IMAGES || derivedType == TYPE_VIDEO || derivedType == TYPE_AUDIO || derivedType == TYPE_RECENTS || derivedType == TYPE_DOWNLOADS; } @Override public String toString() { return "Root{authority=" + authority + ", rootId=" + rootId + ", title=" + title + "}"; Loading