π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mobile][photos] Correct cropped panorama initial longitude
Rahul Agarwal934ea7ec352d
diff --git a/mobile/apps/photos/lib/ui/viewer/file/panorama_view_data.dart b/mobile/apps/photos/lib/ui/viewer/file/panorama_view_data.dartindex 6e77b79d33..af1b92f0a5 100644--- a/mobile/apps/photos/lib/ui/viewer/file/panorama_view_data.dart+++ b/mobile/apps/photos/lib/ui/viewer/file/panorama_view_data.dart@@ -25,15 +25,16 @@ class PanoramaViewData {////// The panorama widget maps the cropped area to its absolute position on the/// full equirectangular canvas, and its longitude 0 faces the horizontal- /// edge (u = 0) of that canvas. Partial panoramas (e.g. Pixel sweep+ /// center (u = 0.5) of that canvas. Partial panoramas (e.g. Pixel sweep/// panoramas) keep the compass heading of the shot, so their cropped area/// can sit anywhere on the canvas; without this correction the initial view/// often faces an empty part of the sphere.double get initialLongitude {final double uCenter =(croppedArea.left + croppedArea.width / 2) / fullWidth;- double longitude = (1 - uCenter) * 360;+ double longitude = (uCenter - 0.5) * 360;if (longitude > 180) longitude -= 360;+ if (longitude < -180) longitude += 360;return longitude;}diff --git a/mobile/apps/photos/test/ui/viewer/file/panorama_view_data_test.dart b/mobile/apps/photos/test/ui/viewer/file/panorama_view_data_test.dartindex 57443ce42a..8ef3855684 100644--- a/mobile/apps/photos/test/ui/viewer/file/panorama_view_data_test.dart+++ b/mobile/apps/photos/test/ui/viewer/file/panorama_view_data_test.dart@@ -32,12 +32,12 @@ void main() {croppedArea: Rect.fromLTWH(6183, 1040, 2520, 1664),);// Crop center sits at u = (6183 + 1260) / 8762 = 0.8495 of the full- // canvas; the widget's longitude 0 faces u = 0 and longitude L faces- // u = 1 - L / 360, hence L = (1 - 0.8495) * 360.- expect(data.initialLongitude, closeTo(54.19, 0.01));+ // canvas; the widget's longitude 0 faces u = 0.5 and longitude L faces+ // u = 0.5 + L / 360, hence L = (0.8495 - 0.5) * 360.+ expect(data.initialLongitude, closeTo(125.81, 0.01));// Matches the recorded compass heading of the sample within rounding:// GPano:InitialViewHeadingDegrees = 305 = 0.8495 * 360.- final uCenter = 1 - data.initialLongitude / 360;+ final uCenter = 0.5 + data.initialLongitude / 360;expect(uCenter * 360, closeTo(305.8, 0.1));});@@ -47,8 +47,8 @@ void main() {fullHeight: 500,croppedArea: Rect.fromLTWH(100, 100, 200, 300),);- // uCenter = 0.2 -> raw longitude 288 -> normalized -72.- expect(data.initialLongitude, closeTo(-72, 0.001));+ // uCenter = 0.2 -> longitude (0.2 - 0.5) * 360 = -108.+ expect(data.initialLongitude, closeTo(-108, 0.001));});test("derives full height and top for Samsung-style metadata", () {diff --git a/mobile/apps/photos/test/ui/viewer/file/panorama_viewer_screen_test.dart b/mobile/apps/photos/test/ui/viewer/file/panorama_viewer_screen_test.dartindex 54e2d82874..3ca10ff479 100644--- a/mobile/apps/photos/test/ui/viewer/file/panorama_viewer_screen_test.dart+++ b/mobile/apps/photos/test/ui/viewer/file/panorama_viewer_screen_test.dart@@ -145,8 +145,9 @@ void main() {expect(pano.croppedFullWidth, 8762);expect(pano.croppedFullHeight, 4381);// The initial view must face the cropped area (compass heading 305.8- // degrees maps to longitude 54.19), not the canvas edge.- expect(pano.longitude, closeTo(54.19, 0.01));+ // degrees maps to longitude 125.81 because the panorama widget's+ // longitude 0 faces the horizontal center), not the empty canvas area.+ expect(pano.longitude, closeTo(125.81, 0.01));// Let the auto-hide timer fire and dispose the screen.await tester.pump(const Duration(seconds: 6));