Loading res/layout/item_root.xml +1 −1 Original line number Diff line number Diff line Loading @@ -43,7 +43,7 @@ <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingStart="16dp" android:paddingStart="7dp" android:paddingTop="8dp" android:paddingBottom="8dp" android:orientation="vertical" Loading res/layout/item_root_spacer.xml +1 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingStart="@dimen/root_spacer_padding" android:paddingTop="12dp" android:paddingBottom="12dp"> Loading res/values/dimens.xml +1 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ <dimen name="icon_size">40dp</dimen> <dimen name="root_icon_size">24dp</dimen> <dimen name="root_icon_margin">0dp</dimen> <dimen name="root_spacer_padding">0dp</dimen> <dimen name="check_icon_size">30dp</dimen> <dimen name="list_item_thumbnail_size">40dp</dimen> <dimen name="grid_item_icon_size">30dp</dimen> Loading src/com/android/documentsui/base/RootInfo.java +24 −10 Original line number Diff line number Diff line Loading @@ -23,7 +23,7 @@ import static com.android.documentsui.base.SharedMinimal.VERBOSE; import static com.android.documentsui.base.Shared.compareToIgnoreCaseNullable; import androidx.annotation.IntDef; import androidx.annotation.Nullable; import android.content.Context; import android.database.Cursor; import android.graphics.drawable.Drawable; Loading @@ -35,13 +35,11 @@ import android.provider.DocumentsContract.Root; import android.text.TextUtils; import android.util.Log; import com.android.documentsui.DocumentsAccess; import com.android.documentsui.IconUtils; import com.android.documentsui.R; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; Loading @@ -59,10 +57,10 @@ public class RootInfo implements Durable, Parcelable, Comparable<RootInfo> { // The values of these constants determine the sort order of various roots in the RootsFragment. @IntDef(flag = false, value = { TYPE_RECENTS, TYPE_IMAGES, TYPE_VIDEO, TYPE_AUDIO, TYPE_RECENTS, TYPE_DOWNLOADS, TYPE_LOCAL, TYPE_MTP, Loading @@ -72,10 +70,10 @@ public class RootInfo implements Durable, Parcelable, Comparable<RootInfo> { }) @Retention(RetentionPolicy.SOURCE) public @interface RootType {} public static final int TYPE_IMAGES = 1; public static final int TYPE_VIDEO = 2; public static final int TYPE_AUDIO = 3; public static final int TYPE_RECENTS = 4; public static final int TYPE_RECENTS = 1; public static final int TYPE_IMAGES = 2; public static final int TYPE_VIDEO = 3; public static final int TYPE_AUDIO = 4; public static final int TYPE_DOWNLOADS = 5; public static final int TYPE_LOCAL = 6; public static final int TYPE_MTP = 7; Loading Loading @@ -200,7 +198,7 @@ public class RootInfo implements Durable, Parcelable, Comparable<RootInfo> { private void deriveFields() { derivedMimeTypes = (mimeTypes != null) ? mimeTypes.split("\n") : null; if (isHome()) { if (isExternalStorageHome()) { derivedType = TYPE_LOCAL; derivedIcon = R.drawable.ic_root_documents; } else if (isMtp()) { Loading Loading @@ -244,7 +242,10 @@ public class RootInfo implements Durable, Parcelable, Comparable<RootInfo> { return authority == null && rootId == null; } public boolean isHome() { /* * Return true, if the root is from ExternalStorage and the id is home. Otherwise, return false. */ public boolean isExternalStorageHome() { // Note that "home" is the expected root id for the auto-created // user home directory on external storage. The "home" value should // match ExternalStorageProvider.ROOT_ID_HOME. Loading Loading @@ -278,6 +279,9 @@ public class RootInfo implements Durable, Parcelable, Comparable<RootInfo> { return Providers.AUTHORITY_MTP.equals(authority); } /* * Return true, if the derivedType of this root is library type. Otherwise, return false. */ public boolean isLibrary() { return derivedType == TYPE_IMAGES || derivedType == TYPE_VIDEO Loading @@ -285,6 +289,16 @@ public class RootInfo implements Durable, Parcelable, Comparable<RootInfo> { || derivedType == TYPE_RECENTS; } /* * Return true, if the derivedType of this root is storage type. Otherwise, return false. */ public boolean isStorage() { return derivedType == TYPE_LOCAL || derivedType == TYPE_MTP || derivedType == TYPE_USB || derivedType == TYPE_SD; } public boolean hasSettings() { return (flags & Root.FLAG_HAS_SETTINGS) != 0; } Loading src/com/android/documentsui/sidebar/RootsAdapter.java +10 −5 Original line number Diff line number Diff line Loading @@ -34,6 +34,9 @@ import java.util.Map; * {@link Item}s and provides sub-views to {@link android.widget.ListView}. */ class RootsAdapter extends ArrayAdapter<Item> { private static final int TYPE_ROOT = 0; private static final int TYPE_APP = 1; private static final int TYPE_SPACER = 2; private static final Map<String, Long> sIdMap = new HashMap<>(); // the next available id to associate with a new string id private static long sNextAvailableId; Loading Loading @@ -95,21 +98,23 @@ class RootsAdapter extends ArrayAdapter<Item> { @Override public boolean isEnabled(int position) { return getItemViewType(position) != 1; return getItemViewType(position) != TYPE_SPACER; } @Override public int getItemViewType(int position) { final Item item = getItem(position); if (item instanceof RootItem || item instanceof AppItem) { return 0; if (item instanceof RootItem) { return TYPE_ROOT; } else if (item instanceof AppItem) { return TYPE_APP; } else { return 1; return TYPE_SPACER; } } @Override public int getViewTypeCount() { return 2; return 3; } } Loading
res/layout/item_root.xml +1 −1 Original line number Diff line number Diff line Loading @@ -43,7 +43,7 @@ <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingStart="16dp" android:paddingStart="7dp" android:paddingTop="8dp" android:paddingBottom="8dp" android:orientation="vertical" Loading
res/layout/item_root_spacer.xml +1 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingStart="@dimen/root_spacer_padding" android:paddingTop="12dp" android:paddingBottom="12dp"> Loading
res/values/dimens.xml +1 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ <dimen name="icon_size">40dp</dimen> <dimen name="root_icon_size">24dp</dimen> <dimen name="root_icon_margin">0dp</dimen> <dimen name="root_spacer_padding">0dp</dimen> <dimen name="check_icon_size">30dp</dimen> <dimen name="list_item_thumbnail_size">40dp</dimen> <dimen name="grid_item_icon_size">30dp</dimen> Loading
src/com/android/documentsui/base/RootInfo.java +24 −10 Original line number Diff line number Diff line Loading @@ -23,7 +23,7 @@ import static com.android.documentsui.base.SharedMinimal.VERBOSE; import static com.android.documentsui.base.Shared.compareToIgnoreCaseNullable; import androidx.annotation.IntDef; import androidx.annotation.Nullable; import android.content.Context; import android.database.Cursor; import android.graphics.drawable.Drawable; Loading @@ -35,13 +35,11 @@ import android.provider.DocumentsContract.Root; import android.text.TextUtils; import android.util.Log; import com.android.documentsui.DocumentsAccess; import com.android.documentsui.IconUtils; import com.android.documentsui.R; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; Loading @@ -59,10 +57,10 @@ public class RootInfo implements Durable, Parcelable, Comparable<RootInfo> { // The values of these constants determine the sort order of various roots in the RootsFragment. @IntDef(flag = false, value = { TYPE_RECENTS, TYPE_IMAGES, TYPE_VIDEO, TYPE_AUDIO, TYPE_RECENTS, TYPE_DOWNLOADS, TYPE_LOCAL, TYPE_MTP, Loading @@ -72,10 +70,10 @@ public class RootInfo implements Durable, Parcelable, Comparable<RootInfo> { }) @Retention(RetentionPolicy.SOURCE) public @interface RootType {} public static final int TYPE_IMAGES = 1; public static final int TYPE_VIDEO = 2; public static final int TYPE_AUDIO = 3; public static final int TYPE_RECENTS = 4; public static final int TYPE_RECENTS = 1; public static final int TYPE_IMAGES = 2; public static final int TYPE_VIDEO = 3; public static final int TYPE_AUDIO = 4; public static final int TYPE_DOWNLOADS = 5; public static final int TYPE_LOCAL = 6; public static final int TYPE_MTP = 7; Loading Loading @@ -200,7 +198,7 @@ public class RootInfo implements Durable, Parcelable, Comparable<RootInfo> { private void deriveFields() { derivedMimeTypes = (mimeTypes != null) ? mimeTypes.split("\n") : null; if (isHome()) { if (isExternalStorageHome()) { derivedType = TYPE_LOCAL; derivedIcon = R.drawable.ic_root_documents; } else if (isMtp()) { Loading Loading @@ -244,7 +242,10 @@ public class RootInfo implements Durable, Parcelable, Comparable<RootInfo> { return authority == null && rootId == null; } public boolean isHome() { /* * Return true, if the root is from ExternalStorage and the id is home. Otherwise, return false. */ public boolean isExternalStorageHome() { // Note that "home" is the expected root id for the auto-created // user home directory on external storage. The "home" value should // match ExternalStorageProvider.ROOT_ID_HOME. Loading Loading @@ -278,6 +279,9 @@ public class RootInfo implements Durable, Parcelable, Comparable<RootInfo> { return Providers.AUTHORITY_MTP.equals(authority); } /* * Return true, if the derivedType of this root is library type. Otherwise, return false. */ public boolean isLibrary() { return derivedType == TYPE_IMAGES || derivedType == TYPE_VIDEO Loading @@ -285,6 +289,16 @@ public class RootInfo implements Durable, Parcelable, Comparable<RootInfo> { || derivedType == TYPE_RECENTS; } /* * Return true, if the derivedType of this root is storage type. Otherwise, return false. */ public boolean isStorage() { return derivedType == TYPE_LOCAL || derivedType == TYPE_MTP || derivedType == TYPE_USB || derivedType == TYPE_SD; } public boolean hasSettings() { return (flags & Root.FLAG_HAS_SETTINGS) != 0; } Loading
src/com/android/documentsui/sidebar/RootsAdapter.java +10 −5 Original line number Diff line number Diff line Loading @@ -34,6 +34,9 @@ import java.util.Map; * {@link Item}s and provides sub-views to {@link android.widget.ListView}. */ class RootsAdapter extends ArrayAdapter<Item> { private static final int TYPE_ROOT = 0; private static final int TYPE_APP = 1; private static final int TYPE_SPACER = 2; private static final Map<String, Long> sIdMap = new HashMap<>(); // the next available id to associate with a new string id private static long sNextAvailableId; Loading Loading @@ -95,21 +98,23 @@ class RootsAdapter extends ArrayAdapter<Item> { @Override public boolean isEnabled(int position) { return getItemViewType(position) != 1; return getItemViewType(position) != TYPE_SPACER; } @Override public int getItemViewType(int position) { final Item item = getItem(position); if (item instanceof RootItem || item instanceof AppItem) { return 0; if (item instanceof RootItem) { return TYPE_ROOT; } else if (item instanceof AppItem) { return TYPE_APP; } else { return 1; return TYPE_SPACER; } } @Override public int getViewTypeCount() { return 2; return 3; } }