Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2860ba1d authored by Steve McKay's avatar Steve McKay Committed by Android (Google) Code Review
Browse files

Merge "Show proper icons for SD and USB attached storage." into nyc-dev

parents 57af8a19 6695fdf0
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -14,8 +14,8 @@ Copyright (C) 2015 The Android Open Source Project
    limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="48dp"
        android:height="48dp"
        android:width="24dp"
        android:height="24dp"
        android:viewportWidth="24.0"
        android:viewportHeight="24.0">
    <path
+24 −0
Original line number Diff line number Diff line
<!--
Copyright (C) 2015 The Android Open Source Project

   Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

         http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="24dp"
        android:height="24dp"
        android:viewportWidth="24.0"
        android:viewportHeight="24.0">
    <path
        android:fillColor="#FF000000"
        android:pathData="M15 7v4h1v2h-3V5h2l-3,-4,-3 4h2v8H8v-2.07c.7,-.37 1.2,-1.08 1.2,-1.93 0,-1.21,-.99,-2.2,-2.2,-2.2,-1.21 0,-2.2.99,-2.2 2.2 0 .85.5 1.56 1.2 1.93V13c0 1.11.89 2 2 2h3v3.05c-.71.37,-1.2 1.1,-1.2 1.95 0 1.22.99 2.2 2.2 2.2 1.21 0 2.2,-.98 2.2,-2.2 0,-.85,-.49,-1.58,-1.2,-1.95V15h3c1.11 0 2,-.89 2,-2v-2h1V7h-4z"/>
</vector>
+42 −12
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.documentsui.model;

import static com.android.documentsui.Shared.DEBUG;
import static com.android.documentsui.Shared.compareToIgnoreCaseNullable;
import static com.android.documentsui.model.DocumentInfo.getCursorInt;
import static com.android.documentsui.model.DocumentInfo.getCursorLong;
@@ -31,6 +32,7 @@ import android.os.Parcelable;
import android.provider.DocumentsContract;
import android.provider.DocumentsContract.Root;
import android.text.TextUtils;
import android.util.Log;

import com.android.documentsui.IconUtils;
import com.android.documentsui.R;
@@ -47,6 +49,8 @@ import java.util.Objects;
 * Representation of a {@link Root}.
 */
public class RootInfo implements Durable, Parcelable, Comparable<RootInfo> {

    private static final String TAG = "RootInfo";
    private static final int VERSION_INIT = 1;
    private static final int VERSION_DROP_TYPE = 2;

@@ -59,6 +63,8 @@ public class RootInfo implements Durable, Parcelable, Comparable<RootInfo> {
            TYPE_DOWNLOADS,
            TYPE_LOCAL,
            TYPE_MTP,
            TYPE_SD,
            TYPE_USB,
            TYPE_OTHER
    })
    @Retention(RetentionPolicy.SOURCE)
@@ -70,7 +76,9 @@ public class RootInfo implements Durable, Parcelable, Comparable<RootInfo> {
    public static final int TYPE_DOWNLOADS = 5;
    public static final int TYPE_LOCAL = 6;
    public static final int TYPE_MTP = 7;
    public static final int TYPE_OTHER = 8;
    public static final int TYPE_SD = 8;
    public static final int TYPE_USB = 9;
    public static final int TYPE_OTHER = 10;

    public String authority;
    public String rootId;
@@ -185,33 +193,40 @@ public class RootInfo implements Durable, Parcelable, Comparable<RootInfo> {
    private void deriveFields() {
        derivedMimeTypes = (mimeTypes != null) ? mimeTypes.split("\n") : null;

        // TODO: remove these special case icons
        if (isHome()) {
            derivedIcon = R.drawable.ic_root_documents;
            derivedType = TYPE_LOCAL;
            derivedIcon = R.drawable.ic_root_documents;
        } else if (isMtp()) {
            derivedType = TYPE_MTP;
            derivedIcon = R.drawable.ic_usb_storage;
        } else if (isUsb()) {
            derivedType = TYPE_USB;
            derivedIcon = R.drawable.ic_usb_storage;
        } else if (isSd()) {
            derivedType = TYPE_SD;
            derivedIcon = R.drawable.ic_sd_storage;
        } else if (isExternalStorage()) {
            derivedIcon = R.drawable.ic_root_smartphone;
            derivedType = TYPE_LOCAL;
            // TODO: Apply SD card icon to SD devices.
            derivedIcon = R.drawable.ic_root_smartphone;
        } else if (isDownloads()) {
            derivedIcon = R.drawable.ic_root_download;
            derivedType = TYPE_DOWNLOADS;
            derivedIcon = R.drawable.ic_root_download;
        } else if (isImages()) {
            derivedIcon = R.drawable.ic_doc_image;
            derivedType = TYPE_IMAGES;
            derivedIcon = R.drawable.ic_doc_image;
        } else if (isVideos()) {
            derivedIcon = R.drawable.ic_doc_video;
            derivedType = TYPE_VIDEO;
            derivedIcon = R.drawable.ic_doc_video;
        } else if (isAudio()) {
            derivedIcon = R.drawable.ic_doc_audio;
            derivedType = TYPE_AUDIO;
            derivedIcon = R.drawable.ic_doc_audio;
        } else if (isRecents()) {
            derivedType = TYPE_RECENTS;
        } else if (isMtp()) {
            derivedType = TYPE_MTP;
        } else {
            derivedType = TYPE_OTHER;
        }

        if (DEBUG) Log.d(TAG, "Finished deriving fields: " + this);
    }

    public Uri getUri() {
@@ -291,6 +306,14 @@ public class RootInfo implements Durable, Parcelable, Comparable<RootInfo> {
        return (flags & Root.FLAG_EMPTY) != 0;
    }

    public boolean isSd() {
        return (flags & Root.FLAG_REMOVABLE_SD) != 0;
    }

    public boolean isUsb() {
        return (flags & Root.FLAG_REMOVABLE_USB) != 0;
    }

    public Drawable loadIcon(Context context) {
        if (derivedIcon != 0) {
            return context.getDrawable(derivedIcon);
@@ -358,7 +381,14 @@ public class RootInfo implements Durable, Parcelable, Comparable<RootInfo> {

    @Override
    public String toString() {
        return "Root{authority=" + authority + ", rootId=" + rootId + ", title=" + title + "}";
        return "Root{"
                + "authority=" + authority
                + ", rootId=" + rootId
                + ", title=" + title
                + ", isUsb=" + isUsb()
                + ", isSd=" + isSd()
                + ", isMtp=" + isMtp()
                + "}";
    }

    public String getDirectoryString() {