diff options
author | Flamefire <alex@grundis.de> | 2014-09-17 02:40:04 +0200 |
---|---|---|
committer | LuK1337 <priv.luk@gmail.com> | 2019-10-21 21:40:56 +0200 |
commit | 884d8500eb5ce5fcd3a219b5a684c77d0f173667 (patch) | |
tree | 37cc4909d4315120b4930204e850b32fc5290f23 | |
parent | 2ad4dea6c3101b6bf33c43bae2a169a21fbb3bc0 (diff) | |
download | android_packages_apps_Gallery2-884d8500eb5ce5fcd3a219b5a684c77d0f173667.tar.gz android_packages_apps_Gallery2-884d8500eb5ce5fcd3a219b5a684c77d0f173667.tar.bz2 android_packages_apps_Gallery2-884d8500eb5ce5fcd3a219b5a684c77d0f173667.zip |
Gallery2: Add record time to details view
Change-Id: Idef3a68699fc25898f9408b64afc6a7c6b45a86e
-rw-r--r-- | gallerycommon/src/com/android/gallery3d/exif/ExifInterface.java | 18 | ||||
-rw-r--r-- | gallerycommon/src/com/android/gallery3d/exif/ExifTag.java | 9 | ||||
-rw-r--r-- | res/values/cm_strings.xml | 20 | ||||
-rw-r--r-- | src/com/android/gallery3d/data/MediaDetails.java | 31 | ||||
-rw-r--r-- | src/com/android/gallery3d/ui/DetailsHelper.java | 2 | ||||
-rw-r--r-- | src/com/android/gallery3d/ui/DialogDetailsView.java | 16 |
6 files changed, 68 insertions, 28 deletions
diff --git a/gallerycommon/src/com/android/gallery3d/exif/ExifInterface.java b/gallerycommon/src/com/android/gallery3d/exif/ExifInterface.java index 87db689e8..21422095e 100644 --- a/gallerycommon/src/com/android/gallery3d/exif/ExifInterface.java +++ b/gallerycommon/src/com/android/gallery3d/exif/ExifInterface.java @@ -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; } diff --git a/gallerycommon/src/com/android/gallery3d/exif/ExifTag.java b/gallerycommon/src/com/android/gallery3d/exif/ExifTag.java index 664fcb019..c257bcd7e 100644 --- a/gallerycommon/src/com/android/gallery3d/exif/ExifTag.java +++ b/gallerycommon/src/com/android/gallery3d/exif/ExifTag.java @@ -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. */ @@ -536,9 +533,9 @@ 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))); } } diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml new file mode 100644 index 000000000..d6da3b19d --- /dev/null +++ b/res/values/cm_strings.xml @@ -0,0 +1,20 @@ +<?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 diff --git a/src/com/android/gallery3d/data/MediaDetails.java b/src/com/android/gallery3d/data/MediaDetails.java index 2a501c7c5..49d78a336 100644 --- a/src/com/android/gallery3d/data/MediaDetails.java +++ b/src/com/android/gallery3d/data/MediaDetails.java @@ -17,15 +17,11 @@ package com.android.gallery3d.data; import org.codeaurora.gallery.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,14 @@ 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), diff --git a/src/com/android/gallery3d/ui/DetailsHelper.java b/src/com/android/gallery3d/ui/DetailsHelper.java index 860ace774..167615be8 100644 --- a/src/com/android/gallery3d/ui/DetailsHelper.java +++ b/src/com/android/gallery3d/ui/DetailsHelper.java @@ -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; } diff --git a/src/com/android/gallery3d/ui/DialogDetailsView.java b/src/com/android/gallery3d/ui/DialogDetailsView.java index efe575445..5b3a016de 100644 --- a/src/com/android/gallery3d/ui/DialogDetailsView.java +++ b/src/com/android/gallery3d/ui/DialogDetailsView.java @@ -36,14 +36,18 @@ import org.codeaurora.gallery.R; import com.android.gallery3d.app.AbstractGalleryActivity; import com.android.gallery3d.common.Utils; import com.android.gallery3d.data.MediaDetails; +import com.android.gallery3d.exif.ExifInterface; import com.android.gallery3d.ui.DetailsAddressResolver.AddressResolvingListener; import com.android.gallery3d.ui.DetailsHelper.CloseListener; import com.android.gallery3d.ui.DetailsHelper.DetailsSource; import com.android.gallery3d.ui.DetailsHelper.DetailsViewContainer; import com.android.gallery3d.ui.DetailsHelper.ResolutionResolvingListener; +import java.text.DateFormat; import java.text.DecimalFormat; +import java.text.ParseException; import java.util.ArrayList; +import java.util.Date; import java.util.Locale; import java.util.Map.Entry; @@ -154,6 +158,15 @@ public class DialogDetailsView implements DetailsViewContainer { setDetails(context, details); } + private String exifDateToFormatedDate(String exifDt) { + try { + Date date = ExifInterface.DATETIME_FORMAT.parse(exifDt); + return DateFormat.getDateTimeInstance().format(date); + } catch (ParseException e) { + return exifDt; + } + } + private void setDetails(Context context, MediaDetails details) { boolean resolutionIsValid = true; String path = null; @@ -244,6 +257,9 @@ public class DialogDetailsView implements DetailsViewContainer { case MediaDetails.INDEX_ORIENTATION: value = toLocalInteger(detail.getValue()); break; + case MediaDetails.INDEX_DATETIME_ORIGINAL: + value = exifDateToFormatedDate(detail.getValue().toString()); + break; default: { Object valueObj = detail.getValue(); // This shouldn't happen, log its key to help us diagnose the problem. |