Skip to content

armgit / ente

Public Imported from GitHub
0

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

fix(mobile): add panorama detection

Prateek Sunald8f275a38810
diff --git a/mobile/lib/ui/viewer/file/file_bottom_bar.dart b/mobile/lib/ui/viewer/file/file_bottom_bar.dart
index 37ebc248e2..e3d2eda7a7 100644
--- a/mobile/lib/ui/viewer/file/file_bottom_bar.dart
+++ b/mobile/lib/ui/viewer/file/file_bottom_bar.dart
@@ -15,6 +15,7 @@ import 'package:photos/ui/collections/collection_action_sheet.dart';
import "package:photos/ui/viewer/file/panorama_viewer_screen.dart";
import 'package:photos/utils/delete_file_util.dart';
import "package:photos/utils/file_util.dart";
+import "package:photos/utils/panorama_util.dart";
import 'package:photos/utils/share_util.dart';
class FileBottomBar extends StatefulWidget {
@@ -41,6 +42,25 @@ class FileBottomBar extends StatefulWidget {
class FileBottomBarState extends State<FileBottomBar> {
final GlobalKey shareButtonKey = GlobalKey();
+ bool isPanorama = false;
+
+ Future<void> _checkPanoroma() async {
+ if (widget.file.fileType != FileType.image) {
+ return;
+ }
+
+ final file = await getFile(widget.file);
+ if (file == null) {
+ return;
+ }
+
+ final result = await checkIfPanorama(file);
+
+ if (mounted && isPanorama == !result) {
+ isPanorama = result;
+ setState(() {});
+ }
+ }
@override
Widget build(BuildContext context) {
@@ -129,23 +149,25 @@ class FileBottomBarState extends State<FileBottomBar> {
);
}
- children.add(
- Tooltip(
- message: S.of(context).panorama,
- child: Padding(
- padding: const EdgeInsets.only(top: 12, bottom: 12),
- child: IconButton(
- icon: const Icon(
- Icons.threesixty,
- color: Colors.white,
+ if (isPanorama) {
+ children.add(
+ Tooltip(
+ message: S.of(context).panorama,
+ child: Padding(
+ padding: const EdgeInsets.only(top: 12, bottom: 12),
+ child: IconButton(
+ icon: const Icon(
+ Icons.threesixty,
+ color: Colors.white,
+ ),
+ onPressed: () async {
+ await openPanoramaViewerPage(widget.file);
+ },
),
- onPressed: () async {
- await openPanoramaViewerPage(widget.file);
- },
),
),
- ),
- );
+ );
+ }
children.add(
Tooltip(
message: S.of(context).share,
diff --git a/mobile/lib/utils/panorama_util.dart b/mobile/lib/utils/panorama_util.dart
new file mode 100644
index 0000000000..ef68b7e7ac
--- /dev/null
+++ b/mobile/lib/utils/panorama_util.dart
@@ -0,0 +1,19 @@
+import "dart:io";
+
+import "package:photos/utils/exif_util.dart";
+import "package:xmp/xmp.dart";
+
+Future<bool> checkIfPanorama(File file) async {
+ try {
+ final result = XMP.extract(file.readAsBytesSync());
+
+ if (result["Rdf Projectiontype"] == "cylindrical") {
+ return true;
+ }
+ } catch (_) {}
+
+ final result = await readExifAsync(file);
+
+ final element = result["EXIF CustomRendered"];
+ return (element?.printable == "6");
+}
diff --git a/mobile/pubspec.lock b/mobile/pubspec.lock
index 9780891185..2794bd4cb4 100644
--- a/mobile/pubspec.lock
+++ b/mobile/pubspec.lock
@@ -791,10 +791,10 @@ packages:
dependency: "direct dev"
description:
name: flutter_lints
- sha256: a25a15ebbdfc33ab1cd26c63a6ee519df92338a9c10f122adda92938253bef04
+ sha256: "9e8c3858111da373efc5aa341de011d9bd23e2c5c5e0c62bccf32438e192d7b1"
url: "https://pub.dev"
source: hosted
- version: "2.0.3"
+ version: "3.0.2"
flutter_local_notifications:
dependency: "direct main"
description:
@@ -1328,10 +1328,10 @@ packages:
dependency: transitive
description:
name: lints
- sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452"
+ sha256: cbf8d4b858bb0134ef3ef87841abdf8d63bfc255c266b7bf6b39daa1085c4290
url: "https://pub.dev"
source: hosted
- version: "2.1.1"
+ version: "3.0.0"
lists:
dependency: transitive
description:
@@ -2548,6 +2548,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.1.1"
+ utility:
+ dependency: transitive
+ description:
+ name: utility
+ sha256: "200d264c3804e87da7ea36aa81bd73fb845d2cb7b2e820f3f357a0a2bd4e37f5"
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.0.3"
uuid:
dependency: "direct main"
description:
@@ -2798,6 +2806,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.1.1"
+ xmp:
+ dependency: "direct main"
+ description:
+ name: xmp
+ sha256: "317a023e882101713cd12a25aa9f2e2f2ed61146f2a79e20ed0dd31787b9b895"
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.0.3"
yaml:
dependency: transitive
description:
diff --git a/mobile/pubspec.yaml b/mobile/pubspec.yaml
index fddd00d442..10fa325357 100644
--- a/mobile/pubspec.yaml
+++ b/mobile/pubspec.yaml
@@ -181,6 +181,7 @@ dependencies:
wechat_assets_picker: ^8.6.3
widgets_to_image: ^0.0.2
xml: ^6.3.0
+ xmp: ^1.0.3
dependency_overrides:
# Remove this after removing dependency from flutter_sodium.
@@ -199,7 +200,7 @@ flutter_intl:
dev_dependencies:
build_runner: ^2.4.7
- flutter_lints: ^2.0.1
+ flutter_lints: ^3.0.1
flutter_test:
sdk: flutter
freezed: ^2.5.2