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

Commit 96901d38 authored by Flamefire's avatar Flamefire Committed by Gerrit Code Review
Browse files

Add record time to details view

PS2: Move strings
PS3: Move DateTime format to public in ExifInterface
PS4: Actually use that DateTime format

Change-Id: If30e19d0b79039357f393752544c655e073a46d2
parent 3a82b6a4
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
@@ -318,6 +318,13 @@ public class ExifInterface {
    public static final int TAG_INTEROPERABILITY_INDEX =
        defineTag(IfdId.TYPE_IFD_INTEROPERABILITY, (short) 1);

    private static final String GPS_DATE_FORMAT_STR = "yyyy:MM:dd";
    private static final String DATETIME_FORMAT_STR = "yyyy:MM:dd kk:mm:ss";
    public static final DateFormat DATETIME_FORMAT = new SimpleDateFormat(DATETIME_FORMAT_STR);
    private final DateFormat mGPSDateStampFormat = new SimpleDateFormat(GPS_DATE_FORMAT_STR);
    private final Calendar mGPSTimeStampCalendar = Calendar
            .getInstance(TimeZone.getTimeZone("UTC"));

    /**
     * Tags that contain offset markers. These are included in the banned
     * defines.
@@ -1944,13 +1951,6 @@ public class ExifInterface {
        return latLon;
    }

    private static final String GPS_DATE_FORMAT_STR = "yyyy:MM:dd";
    private static final String DATETIME_FORMAT_STR = "yyyy:MM:dd kk:mm:ss";
    private final DateFormat mDateTimeStampFormat = new SimpleDateFormat(DATETIME_FORMAT_STR);
    private final DateFormat mGPSDateStampFormat = new SimpleDateFormat(GPS_DATE_FORMAT_STR);
    private final Calendar mGPSTimeStampCalendar = Calendar
            .getInstance(TimeZone.getTimeZone("UTC"));

    /**
     * Creates, formats, and sets the DateTimeStamp tag for one of:
     * {@link #TAG_DATE_TIME}, {@link #TAG_DATE_TIME_DIGITIZED},
@@ -1964,8 +1964,8 @@ public class ExifInterface {
    public boolean addDateTimeStampTag(int tagId, long timestamp, TimeZone timezone) {
        if (tagId == TAG_DATE_TIME || tagId == TAG_DATE_TIME_DIGITIZED
                || tagId == TAG_DATE_TIME_ORIGINAL) {
            mDateTimeStampFormat.setTimeZone(timezone);
            ExifTag t = buildTag(tagId, mDateTimeStampFormat.format(timestamp));
            DATETIME_FORMAT.setTimeZone(timezone);
            ExifTag t = buildTag(tagId, DATETIME_FORMAT.format(timestamp));
            if (t == null) {
                return false;
            }
+4 −6
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.gallery3d.exif;

import java.nio.charset.Charset;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;

@@ -102,8 +101,6 @@ public class ExifTag {
    // Value offset in exif header.
    private int mOffset;

    private static final SimpleDateFormat TIME_FORMAT = new SimpleDateFormat("yyyy:MM:dd kk:mm:ss");

    /**
     * Returns true if the given IFD is a valid IFD.
     */
@@ -537,9 +534,10 @@ public class ExifTag {
     * @return true on success
     */
    public boolean setTimeValue(long time) {
        // synchronized on TIME_FORMAT as SimpleDateFormat is not thread safe
        synchronized (TIME_FORMAT) {
            return setValue(TIME_FORMAT.format(new Date(time)));
        // synchronized on DATETIME_FORMAT as SimpleDateFormat is not thread
        // safe
        synchronized (ExifInterface.DATETIME_FORMAT) {
            return setValue(ExifInterface.DATETIME_FORMAT.format(new Date(time)));
        }
    }

+20 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
     Copyright (C) 2012-2014 The CyanogenMod 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.
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
    <!-- Text indicating the time a media item was recorded in details window [CHAR LIMIT=14] -->
    <string name="record_time">Record time</string>
</resources>
 No newline at end of file
+16 −13
Original line number Diff line number Diff line
@@ -17,15 +17,11 @@
package com.android.gallery3d.data;

import com.android.gallery3d.R;
import com.android.gallery3d.common.Utils;
import com.android.gallery3d.exif.ExifInterface;
import com.android.gallery3d.exif.ExifTag;
import com.android.gallery3d.exif.Rational;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
@@ -50,15 +46,16 @@ public class MediaDetails implements Iterable<Entry<Integer, Object>> {
    public static final int INDEX_SIZE = 10;

    // for EXIF
    public static final int INDEX_MAKE = 100;
    public static final int INDEX_MODEL = 101;
    public static final int INDEX_FLASH = 102;
    public static final int INDEX_FOCAL_LENGTH = 103;
    public static final int INDEX_WHITE_BALANCE = 104;
    public static final int INDEX_APERTURE = 105;
    public static final int INDEX_SHUTTER_SPEED = 106;
    public static final int INDEX_EXPOSURE_TIME = 107;
    public static final int INDEX_ISO = 108;
    public static final int INDEX_DATETIME_ORIGINAL = 100;
    public static final int INDEX_MAKE = 101;
    public static final int INDEX_MODEL = 102;
    public static final int INDEX_FLASH = 103;
    public static final int INDEX_FOCAL_LENGTH = 104;
    public static final int INDEX_WHITE_BALANCE = 105;
    public static final int INDEX_APERTURE = 106;
    public static final int INDEX_SHUTTER_SPEED = 107;
    public static final int INDEX_EXPOSURE_TIME = 108;
    public static final int INDEX_ISO = 109;

    // Put this last because it may be long.
    public static final int INDEX_PATH = 200;
@@ -148,6 +145,12 @@ public class MediaDetails implements Iterable<Entry<Integer, Object>> {
                MediaDetails.INDEX_WIDTH);
        setExifData(details, exif.getTag(ExifInterface.TAG_IMAGE_LENGTH),
                MediaDetails.INDEX_HEIGHT);
        ExifTag recordTag = exif.getTag(ExifInterface.TAG_DATE_TIME_ORIGINAL);
        if (recordTag == null)
            recordTag = exif.getTag(ExifInterface.TAG_DATE_TIME_DIGITIZED);
        if (recordTag == null)
            recordTag = exif.getTag(ExifInterface.TAG_DATE_TIME);
        setExifData(details, recordTag, MediaDetails.INDEX_DATETIME_ORIGINAL);
        setExifData(details, exif.getTag(ExifInterface.TAG_MAKE),
                MediaDetails.INDEX_MAKE);
        setExifData(details, exif.getTag(ExifInterface.TAG_MODEL),
+2 −0
Original line number Diff line number Diff line
@@ -139,6 +139,8 @@ public class DetailsHelper {
                return context.getString(R.string.exposure_time);
            case MediaDetails.INDEX_ISO:
                return context.getString(R.string.iso);
            case MediaDetails.INDEX_DATETIME_ORIGINAL:
                return context.getString(R.string.record_time);
            default:
                return "Unknown key" + key;
        }
Loading