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

Commit 3ae1d386 authored by Julian Mancini's avatar Julian Mancini
Browse files

Add time to the 'last modified' string

I added a small helper method that combines two different DateFormat
subclasses in order to format both the date and the time based on user
locale.

Bug: 63633834
Test: In place
Change-Id: I03f1f7fb48eb1ac905fe227ba092f3a2ac1600d6
parent b417953d
Loading
Loading
Loading
Loading
+15 −2
Original line number Diff line number Diff line
@@ -26,6 +26,8 @@ import com.android.documentsui.base.DocumentInfo;
import com.android.documentsui.base.Lookup;
import com.android.documentsui.inspector.InspectorController.DetailsDisplay;

import java.util.Locale;

/**
 * Displays the basic details about a file.
 */
@@ -58,8 +60,7 @@ public class DetailsView extends TableView implements DetailsDisplay {
        }

        if (info.lastModified > 0) {
            put(R.string.sort_dimension_date,
                    DateFormat.getDateFormat(getContext()).format(info.lastModified));
            put(R.string.sort_dimension_date, formatDate(info.lastModified));
        }

        if (info.summary != null) {
@@ -71,4 +72,16 @@ public class DetailsView extends TableView implements DetailsDisplay {
    public void setChildrenCount(int count) {
        put(R.string.directory_items, String.valueOf(count));
    }

    /**
     * This small helper method combines two different DateFormat subclasses in order to format
     * both the date and the time based on user locale.
     * @param date Unix timestamp
     * @return formatted String of date
     */
    private static String formatDate(long date) {
        String format = DateFormat.getBestDateTimePattern(Locale.getDefault(),
                "MMM dd, yyyy, hh:mm");
        return DateFormat.format(format, date).toString();
    }
}
 No newline at end of file