Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Fix shutter speed display on Android to show human-readable format

copilot-swe-agent[bot]fc77f183c851
diff --git a/mobile/apps/photos/lib/ui/viewer/file/file_details_widget.dart b/mobile/apps/photos/lib/ui/viewer/file/file_details_widget.dart
index d858f047fd..285d239bc4 100644
--- a/mobile/apps/photos/lib/ui/viewer/file/file_details_widget.dart
+++ b/mobile/apps/photos/lib/ui/viewer/file/file_details_widget.dart
@@ -410,12 +410,53 @@ class _FileDetailsWidgetState extends State<FileDetailsWidget> {
}
if (exif["EXIF ExposureTime"] != null) {
- _exifData["exposureTime"] = exif["EXIF ExposureTime"].toString();
+ _exifData["exposureTime"] =
+ _formatExposureTime(exif["EXIF ExposureTime"]!);
}
if (exif["EXIF ISOSpeedRatings"] != null) {
_exifData['ISO'] = exif["EXIF ISOSpeedRatings"].toString();
}
}
+
+ /// Formats exposure time from EXIF data into a human-readable string.
+ ///
+ /// For shutter speeds >= 1 second, displays as decimal with 's' suffix (e.g., "1.3s")
+ /// For shutter speeds < 1 second, displays as a fraction (e.g., "1/100")
+ String _formatExposureTime(IfdTag exposureTimeTag) {
+ final values = exposureTimeTag.values.toList();
+ if (values.isEmpty) {
+ return exposureTimeTag.toString();
+ }
+
+ final value = values[0];
+ if (value is! Ratio) {
+ return exposureTimeTag.toString();
+ }
+
+ final numerator = value.numerator;
+ final denominator = value.denominator;
+
+ if (denominator == 0) {
+ return exposureTimeTag.toString();
+ }
+
+ final double seconds = numerator / denominator;
+
+ if (seconds >= 1) {
+ // For exposures >= 1 second, show as decimal seconds
+ if (seconds == seconds.roundToDouble()) {
+ return "${seconds.toInt()}s";
+ }
+ return "${seconds.toStringAsFixed(1)}s";
+ } else if (numerator == 1) {
+ // If the fraction already has numerator 1, use it directly (e.g., 1/100)
+ return "$numerator/$denominator";
+ } else {
+ // For other fractions, calculate and display as 1/x
+ final reciprocal = (1 / seconds).round();
+ return "1/$reciprocal";
+ }
+ }
}
class FileDetailsDivider extends StatelessWidget {