Loading src/com/android/documentsui/inspector/MediaView.java +22 −1 Original line number Diff line number Diff line Loading @@ -133,8 +133,29 @@ public class MediaView extends TableView implements MediaDisplay { } if (tags.containsKey(ExifInterface.TAG_SHUTTER_SPEED_VALUE)) { String shutterSpeed = String.valueOf(tags.get(ExifInterface.TAG_SHUTTER_SPEED_VALUE)); String shutterSpeed = String.valueOf( formatShutterSpeed(tags.getDouble(ExifInterface.TAG_SHUTTER_SPEED_VALUE))); table.put(R.string.metadata_shutter_speed, shutterSpeed); } } /** * * @param speed a value n, where shutter speed equals 1/(2^n) * @return a String containing either a fraction that displays 1 over a positive integer, or a * double rounded to one decimal, depending on if 1/(2^n) is less than or greater than 1, * respectively. */ private static String formatShutterSpeed(double speed) { if (speed <= 0) { double shutterSpeed = Math.pow(2, -1 * speed); String formattedSpeed = String.valueOf(Math.round(shutterSpeed * 10.0) / 10.0); return formattedSpeed; } else { int approximateSpeedDenom = (int) Math.pow(2, speed) + 1; String formattedSpeed = "1/" + String.valueOf(approximateSpeedDenom); return formattedSpeed; } } } tests/unit/com/android/documentsui/inspector/MediaViewTest.java +1 −0 Original line number Diff line number Diff line Loading @@ -58,6 +58,7 @@ public class MediaViewTest { mTable.assertHasRow(R.string.metadata_altitude, "1244.0"); mTable.assertHasRow(R.string.metadata_make, "Google"); mTable.assertHasRow(R.string.metadata_model, "Pixel"); mTable.assertHasRow(R.string.metadata_shutter_speed, "1/100"); } /** Loading tests/unit/com/android/documentsui/inspector/TestMetadata.java +1 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ final class TestMetadata { exif.putDouble(ExifInterface.TAG_GPS_ALTITUDE, 1244); exif.putString(ExifInterface.TAG_MAKE, "Google"); exif.putString(ExifInterface.TAG_MODEL, "Pixel"); exif.putDouble(ExifInterface.TAG_SHUTTER_SPEED_VALUE, 6.643); container.putBundle(DocumentsContract.METADATA_EXIF, exif); } } Loading
src/com/android/documentsui/inspector/MediaView.java +22 −1 Original line number Diff line number Diff line Loading @@ -133,8 +133,29 @@ public class MediaView extends TableView implements MediaDisplay { } if (tags.containsKey(ExifInterface.TAG_SHUTTER_SPEED_VALUE)) { String shutterSpeed = String.valueOf(tags.get(ExifInterface.TAG_SHUTTER_SPEED_VALUE)); String shutterSpeed = String.valueOf( formatShutterSpeed(tags.getDouble(ExifInterface.TAG_SHUTTER_SPEED_VALUE))); table.put(R.string.metadata_shutter_speed, shutterSpeed); } } /** * * @param speed a value n, where shutter speed equals 1/(2^n) * @return a String containing either a fraction that displays 1 over a positive integer, or a * double rounded to one decimal, depending on if 1/(2^n) is less than or greater than 1, * respectively. */ private static String formatShutterSpeed(double speed) { if (speed <= 0) { double shutterSpeed = Math.pow(2, -1 * speed); String formattedSpeed = String.valueOf(Math.round(shutterSpeed * 10.0) / 10.0); return formattedSpeed; } else { int approximateSpeedDenom = (int) Math.pow(2, speed) + 1; String formattedSpeed = "1/" + String.valueOf(approximateSpeedDenom); return formattedSpeed; } } }
tests/unit/com/android/documentsui/inspector/MediaViewTest.java +1 −0 Original line number Diff line number Diff line Loading @@ -58,6 +58,7 @@ public class MediaViewTest { mTable.assertHasRow(R.string.metadata_altitude, "1244.0"); mTable.assertHasRow(R.string.metadata_make, "Google"); mTable.assertHasRow(R.string.metadata_model, "Pixel"); mTable.assertHasRow(R.string.metadata_shutter_speed, "1/100"); } /** Loading
tests/unit/com/android/documentsui/inspector/TestMetadata.java +1 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ final class TestMetadata { exif.putDouble(ExifInterface.TAG_GPS_ALTITUDE, 1244); exif.putString(ExifInterface.TAG_MAKE, "Google"); exif.putString(ExifInterface.TAG_MODEL, "Pixel"); exif.putDouble(ExifInterface.TAG_SHUTTER_SPEED_VALUE, 6.643); container.putBundle(DocumentsContract.METADATA_EXIF, exif); } }