Loading res/values/strings.xml +3 −0 Original line number Original line Diff line number Diff line Loading @@ -413,6 +413,9 @@ <string name="metadata_aperture">Aperture</string> <string name="metadata_aperture">Aperture</string> <!--The value of a photos shutter speed. Note that this is probably camera EXIF data.--> <!--The value of a photos shutter speed. Note that this is probably camera EXIF data.--> <string name="metadata_shutter_speed">Shutter speed</string> <string name="metadata_shutter_speed">Shutter speed</string> <!--When a photo was taken. Note that this is probably camera EXIF data.--> <string name="metadata_date_time">Taken on</string> <!--String label for developer/debug file details, specifying a file's uri/content address. --> <!--String label for developer/debug file details, specifying a file's uri/content address. --> <string name="debug_content_uri">Uri</string> <string name="debug_content_uri">Uri</string> Loading src/com/android/documentsui/inspector/DateUtils.java 0 → 100644 +36 −0 Original line number Original line Diff line number Diff line /* * Copyright (C) 2017 The Android Open Source 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. */ package com.android.documentsui.inspector; import android.text.format.DateFormat; import java.util.Locale; /** * Helper methods for dealing with dates. */ final class DateUtils { /** * 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 */ static String formatDate(long date) { String format = DateFormat.getBestDateTimePattern(Locale.getDefault(), "MMM dd, yyyy, hh:mm"); return DateFormat.format(format, date).toString(); } } src/com/android/documentsui/inspector/DetailsView.java +1 −16 Original line number Original line Diff line number Diff line Loading @@ -16,7 +16,6 @@ package com.android.documentsui.inspector; package com.android.documentsui.inspector; import android.content.Context; import android.content.Context; import android.text.format.DateFormat; import android.text.format.Formatter; import android.text.format.Formatter; import android.util.AttributeSet; import android.util.AttributeSet; Loading @@ -26,8 +25,6 @@ import com.android.documentsui.base.DocumentInfo; import com.android.documentsui.base.Lookup; import com.android.documentsui.base.Lookup; import com.android.documentsui.inspector.InspectorController.DetailsDisplay; import com.android.documentsui.inspector.InspectorController.DetailsDisplay; import java.util.Locale; /** /** * Displays the basic details about a file. * Displays the basic details about a file. */ */ Loading Loading @@ -60,7 +57,7 @@ public class DetailsView extends TableView implements DetailsDisplay { } } if (info.lastModified > 0) { if (info.lastModified > 0) { put(R.string.sort_dimension_date, formatDate(info.lastModified)); put(R.string.sort_dimension_date, DateUtils.formatDate(info.lastModified)); } } if (info.summary != null) { if (info.summary != null) { Loading @@ -72,16 +69,4 @@ public class DetailsView extends TableView implements DetailsDisplay { public void setChildrenCount(int count) { public void setChildrenCount(int count) { put(R.string.directory_items, String.valueOf(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 src/com/android/documentsui/inspector/InspectorController.java +5 −0 Original line number Original line Diff line number Diff line Loading @@ -223,6 +223,11 @@ public final class InspectorController { + String.valueOf(height)); + String.valueOf(height)); } } if (bundle.containsKey(ExifInterface.TAG_DATETIME)) { long date = bundle.getLong(ExifInterface.TAG_DATETIME); mMetadata.put(R.string.metadata_date_time, DateUtils.formatDate(date)); } if (bundle.containsKey(ExifInterface.TAG_GPS_LATITUDE) if (bundle.containsKey(ExifInterface.TAG_GPS_LATITUDE) && bundle.containsKey(ExifInterface.TAG_GPS_LONGITUDE) ) { && bundle.containsKey(ExifInterface.TAG_GPS_LONGITUDE) ) { double latitude = bundle.getDouble(ExifInterface.TAG_GPS_LATITUDE); double latitude = bundle.getDouble(ExifInterface.TAG_GPS_LATITUDE); Loading tests/unit/com/android/documentsui/inspector/InspectorControllerTest.java +2 −0 Original line number Original line Diff line number Diff line Loading @@ -291,6 +291,7 @@ public class InspectorControllerTest { Map<Integer, String> expected = new HashMap<>(); Map<Integer, String> expected = new HashMap<>(); expected.put(R.string.metadata_dimensions, "3840 x 2160"); expected.put(R.string.metadata_dimensions, "3840 x 2160"); expected.put(R.string.metadata_date_time, DateUtils.formatDate(1000000L)); expected.put(R.string.metadata_location, "37.7749, -122.4194"); expected.put(R.string.metadata_location, "37.7749, -122.4194"); expected.put(R.string.metadata_altitude, "1244.0"); expected.put(R.string.metadata_altitude, "1244.0"); expected.put(R.string.metadata_make, "Google"); expected.put(R.string.metadata_make, "Google"); Loading Loading @@ -320,6 +321,7 @@ public class InspectorControllerTest { Bundle data = new Bundle(); Bundle data = new Bundle(); data.putInt(ExifInterface.TAG_IMAGE_WIDTH, 3840); data.putInt(ExifInterface.TAG_IMAGE_WIDTH, 3840); data.putInt(ExifInterface.TAG_IMAGE_LENGTH, 2160); data.putInt(ExifInterface.TAG_IMAGE_LENGTH, 2160); data.putLong(ExifInterface.TAG_DATETIME, 1000000L); data.putDouble(ExifInterface.TAG_GPS_LATITUDE, 37.7749); data.putDouble(ExifInterface.TAG_GPS_LATITUDE, 37.7749); data.putDouble(ExifInterface.TAG_GPS_LONGITUDE, -122.4194); data.putDouble(ExifInterface.TAG_GPS_LONGITUDE, -122.4194); data.putDouble(ExifInterface.TAG_GPS_ALTITUDE, 1244); data.putDouble(ExifInterface.TAG_GPS_ALTITUDE, 1244); Loading Loading
res/values/strings.xml +3 −0 Original line number Original line Diff line number Diff line Loading @@ -413,6 +413,9 @@ <string name="metadata_aperture">Aperture</string> <string name="metadata_aperture">Aperture</string> <!--The value of a photos shutter speed. Note that this is probably camera EXIF data.--> <!--The value of a photos shutter speed. Note that this is probably camera EXIF data.--> <string name="metadata_shutter_speed">Shutter speed</string> <string name="metadata_shutter_speed">Shutter speed</string> <!--When a photo was taken. Note that this is probably camera EXIF data.--> <string name="metadata_date_time">Taken on</string> <!--String label for developer/debug file details, specifying a file's uri/content address. --> <!--String label for developer/debug file details, specifying a file's uri/content address. --> <string name="debug_content_uri">Uri</string> <string name="debug_content_uri">Uri</string> Loading
src/com/android/documentsui/inspector/DateUtils.java 0 → 100644 +36 −0 Original line number Original line Diff line number Diff line /* * Copyright (C) 2017 The Android Open Source 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. */ package com.android.documentsui.inspector; import android.text.format.DateFormat; import java.util.Locale; /** * Helper methods for dealing with dates. */ final class DateUtils { /** * 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 */ static String formatDate(long date) { String format = DateFormat.getBestDateTimePattern(Locale.getDefault(), "MMM dd, yyyy, hh:mm"); return DateFormat.format(format, date).toString(); } }
src/com/android/documentsui/inspector/DetailsView.java +1 −16 Original line number Original line Diff line number Diff line Loading @@ -16,7 +16,6 @@ package com.android.documentsui.inspector; package com.android.documentsui.inspector; import android.content.Context; import android.content.Context; import android.text.format.DateFormat; import android.text.format.Formatter; import android.text.format.Formatter; import android.util.AttributeSet; import android.util.AttributeSet; Loading @@ -26,8 +25,6 @@ import com.android.documentsui.base.DocumentInfo; import com.android.documentsui.base.Lookup; import com.android.documentsui.base.Lookup; import com.android.documentsui.inspector.InspectorController.DetailsDisplay; import com.android.documentsui.inspector.InspectorController.DetailsDisplay; import java.util.Locale; /** /** * Displays the basic details about a file. * Displays the basic details about a file. */ */ Loading Loading @@ -60,7 +57,7 @@ public class DetailsView extends TableView implements DetailsDisplay { } } if (info.lastModified > 0) { if (info.lastModified > 0) { put(R.string.sort_dimension_date, formatDate(info.lastModified)); put(R.string.sort_dimension_date, DateUtils.formatDate(info.lastModified)); } } if (info.summary != null) { if (info.summary != null) { Loading @@ -72,16 +69,4 @@ public class DetailsView extends TableView implements DetailsDisplay { public void setChildrenCount(int count) { public void setChildrenCount(int count) { put(R.string.directory_items, String.valueOf(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
src/com/android/documentsui/inspector/InspectorController.java +5 −0 Original line number Original line Diff line number Diff line Loading @@ -223,6 +223,11 @@ public final class InspectorController { + String.valueOf(height)); + String.valueOf(height)); } } if (bundle.containsKey(ExifInterface.TAG_DATETIME)) { long date = bundle.getLong(ExifInterface.TAG_DATETIME); mMetadata.put(R.string.metadata_date_time, DateUtils.formatDate(date)); } if (bundle.containsKey(ExifInterface.TAG_GPS_LATITUDE) if (bundle.containsKey(ExifInterface.TAG_GPS_LATITUDE) && bundle.containsKey(ExifInterface.TAG_GPS_LONGITUDE) ) { && bundle.containsKey(ExifInterface.TAG_GPS_LONGITUDE) ) { double latitude = bundle.getDouble(ExifInterface.TAG_GPS_LATITUDE); double latitude = bundle.getDouble(ExifInterface.TAG_GPS_LATITUDE); Loading
tests/unit/com/android/documentsui/inspector/InspectorControllerTest.java +2 −0 Original line number Original line Diff line number Diff line Loading @@ -291,6 +291,7 @@ public class InspectorControllerTest { Map<Integer, String> expected = new HashMap<>(); Map<Integer, String> expected = new HashMap<>(); expected.put(R.string.metadata_dimensions, "3840 x 2160"); expected.put(R.string.metadata_dimensions, "3840 x 2160"); expected.put(R.string.metadata_date_time, DateUtils.formatDate(1000000L)); expected.put(R.string.metadata_location, "37.7749, -122.4194"); expected.put(R.string.metadata_location, "37.7749, -122.4194"); expected.put(R.string.metadata_altitude, "1244.0"); expected.put(R.string.metadata_altitude, "1244.0"); expected.put(R.string.metadata_make, "Google"); expected.put(R.string.metadata_make, "Google"); Loading Loading @@ -320,6 +321,7 @@ public class InspectorControllerTest { Bundle data = new Bundle(); Bundle data = new Bundle(); data.putInt(ExifInterface.TAG_IMAGE_WIDTH, 3840); data.putInt(ExifInterface.TAG_IMAGE_WIDTH, 3840); data.putInt(ExifInterface.TAG_IMAGE_LENGTH, 2160); data.putInt(ExifInterface.TAG_IMAGE_LENGTH, 2160); data.putLong(ExifInterface.TAG_DATETIME, 1000000L); data.putDouble(ExifInterface.TAG_GPS_LATITUDE, 37.7749); data.putDouble(ExifInterface.TAG_GPS_LATITUDE, 37.7749); data.putDouble(ExifInterface.TAG_GPS_LONGITUDE, -122.4194); data.putDouble(ExifInterface.TAG_GPS_LONGITUDE, -122.4194); data.putDouble(ExifInterface.TAG_GPS_ALTITUDE, 1244); data.putDouble(ExifInterface.TAG_GPS_ALTITUDE, 1244); Loading