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

Commit ac0280f3 authored by Raj Yengisetty's avatar Raj Yengisetty
Browse files

CMFileManager: Include sort by type

Change-Id: I44730f6493ee79bbcff49045568d14192544839b
parent 010d820a
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -23,6 +23,8 @@
        <item>@string/sort_by_date_desc</item>
        <item>@string/sort_by_size_asc</item>
        <item>@string/sort_by_size_desc</item>
        <item>@string/sort_by_type_asc</item>
        <item>@string/sort_by_type_desc</item>
    </string-array>

    <!-- The strings of the menu for navigation layout mode enumeration -->
+4 −0
Original line number Diff line number Diff line
@@ -184,6 +184,10 @@
    <string name="sort_by_size_asc">By size \u25B2</string>
    <!-- Navigation View - Sort - Sort by size (descending) -->
    <string name="sort_by_size_desc">By size \u25BC</string>
    <!-- Navigation View - Sort - Sort by type (ascending) -->
    <string name="sort_by_type_asc">By type \u25B2</string>
    <!-- Navigation View - Sort - Sort by type (descending) -->
    <string name="sort_by_type_desc">By type \u25BC</string>

    <!-- Navigation View - Layout - Icons -->
    <string name="layout_icons">Icons</string>
+9 −1
Original line number Diff line number Diff line
@@ -44,7 +44,15 @@ public enum NavigationSortMode implements ObjectIdentifier {
    /**
     * That mode sorts objects by size (descending).
     */
    SIZE_DESC(5);
    SIZE_DESC(5),
    /**
     * That mode sorts objects by type (ascending).
     */
    TYPE_ASC(6),
    /**
     * That mode sorts objects by type (descending).
     */
    TYPE_DESC(7);

    private int mId;

+11 −0
Original line number Diff line number Diff line
@@ -785,6 +785,17 @@ public final class FileHelper {
            return Long.compare(fso1.getSize(), fso2.getSize()) * -1;
        }

        //Type (ascending)
        if (mode.getId() == NavigationSortMode.TYPE_ASC.getId()) {
            // Shouldn't need context here, mimetypes should be loaded
            return MimeTypeHelper.compareFSO(null, fso1, fso2);
        }
        //Type (descending)
        if (mode.getId() == NavigationSortMode.TYPE_DESC.getId()) {
            // Shouldn't need context here, mimetypes should be loaded
            return MimeTypeHelper.compareFSO(null, fso1, fso2) * -1;
        }

        //Comparison between files directly
        return fso1.compareTo(fso2);
    }
+16 −0
Original line number Diff line number Diff line
@@ -336,6 +336,22 @@ public final class MimeTypeHelper {
        return getMimeTypeFromExtension(fso);
    }

    /**
     * Method that compares {@link FileSystemObject} by MimeTypeCategory
     *
     * @param context The current context
     * @param fso1 File system object 1
     * @param fso2 File system object 2
     * @return int Either -1, 0, 1 based on if fso1 appears before or after fso2
     */
    public static final int compareFSO(Context context, FileSystemObject fso1,
            FileSystemObject fso2) {
        MimeTypeCategory mtc1 = getCategory(context, fso1);
        MimeTypeCategory mtc2 = getCategory(context, fso2);

        return mtc1.compareTo(mtc2);
    }

    /**
     * Method that returns the mime/type description of the {@link FileSystemObject}.
     *