summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlamefire <alex@grundis.de>2014-09-17 02:40:04 +0200
committerArne Coucheron <arco68@gmail.com>2017-12-16 06:51:42 +0100
commit4f26a40d60f036f0d10cb07e0c229dc6e8177204 (patch)
tree2b91d0a140dfaa3788d65038ce8a57c0ee37ad5a
parent269085e79c88ad7cb868a8eae8f74089645dd7d7 (diff)
downloadandroid_packages_apps_Gallery2-4f26a40d60f036f0d10cb07e0c229dc6e8177204.tar.gz
android_packages_apps_Gallery2-4f26a40d60f036f0d10cb07e0c229dc6e8177204.tar.bz2
android_packages_apps_Gallery2-4f26a40d60f036f0d10cb07e0c229dc6e8177204.zip
Gallery2: Add record time to details view
Change-Id: Idef3a68699fc25898f9408b64afc6a7c6b45a86e
-rw-r--r--gallerycommon/src/com/android/gallery3d/exif/ExifInterface.java18
-rw-r--r--gallerycommon/src/com/android/gallery3d/exif/ExifTag.java10
-rw-r--r--res/values/cm_strings.xml20
-rw-r--r--src/com/android/gallery3d/data/MediaDetails.java29
-rw-r--r--src/com/android/gallery3d/ui/DetailsHelper.java2
-rw-r--r--src/com/android/gallery3d/ui/DialogDetailsView.java16
6 files changed, 67 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 c30a97143..186cb81cf 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.
*/
@@ -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)));
}
}
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..707b1dc36 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,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),
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.