π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][cast] Return name and castDevice as record
Neeraj Guptabd225ced041a
diff --git a/mobile/lib/service_locator.dart b/mobile/lib/service_locator.dartindex eb79aab0fb..397703761e 100644--- a/mobile/lib/service_locator.dart+++ b/mobile/lib/service_locator.dart@@ -4,22 +4,6 @@ import "package:ente_cast_normal/ente_cast_normal.dart";import "package:ente_feature_flag/ente_feature_flag.dart";import "package:shared_preferences/shared_preferences.dart";-CastService? _castService;-CastService get castService {- _castService ??= CastServiceImpl();- return _castService!;-}--FlagService? _flagService;--FlagService get flagService {- _flagService ??= FlagService(- ServiceLocator.instance.prefs,- ServiceLocator.instance.enteDio,- );- return _flagService!;-}-class ServiceLocator {late final SharedPreferences prefs;late final Dio enteDio;@@ -34,3 +18,19 @@ class ServiceLocator {this.enteDio = enteDio;}}++FlagService? _flagService;++FlagService get flagService {+ _flagService ??= FlagService(+ ServiceLocator.instance.prefs,+ ServiceLocator.instance.enteDio,+ );+ return _flagService!;+}++CastService? _castService;+CastService get castService {+ _castService ??= CastServiceImpl();+ return _castService!;+}diff --git a/mobile/lib/ui/viewer/gallery/gallery_app_bar_widget.dart b/mobile/lib/ui/viewer/gallery/gallery_app_bar_widget.dartindex f433b336cb..a33fc9628b 100644--- a/mobile/lib/ui/viewer/gallery/gallery_app_bar_widget.dart+++ b/mobile/lib/ui/viewer/gallery/gallery_app_bar_widget.dart@@ -646,7 +646,7 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {}Widget castWidget(BuildContext context) {- return FutureBuilder<List<Object>>(+ return FutureBuilder<List<(String, Object)>>(future: castService.searchDevices(),builder: (context, snapshot) {if (snapshot.hasError) {@@ -666,7 +666,9 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {}return Column(- children: snapshot.data!.map((device) {+ children: snapshot.data!.map((result) {+ final device = result.$2;+ final name = result.$1;return GestureDetector(onTap: () async {try {@@ -675,7 +677,7 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {showGenericErrorDialog(context: context, error: e).ignore();}},- child: Text(device.toString()),+ child: Text(name),);}).toList(),);diff --git a/mobile/plugins/ente_cast/analysis_options.yaml b/mobile/plugins/ente_cast/analysis_options.yamlindex fac60e247c..f04c6cf0f3 100644--- a/mobile/plugins/ente_cast/analysis_options.yaml+++ b/mobile/plugins/ente_cast/analysis_options.yaml@@ -1 +1 @@-include: ../../analysis_options.yaml\ No newline at end of file+include: ../../analysis_options.yamldiff --git a/mobile/plugins/ente_cast/lib/src/service.dart b/mobile/plugins/ente_cast/lib/src/service.dartindex 74834f79d0..230269bb39 100644--- a/mobile/plugins/ente_cast/lib/src/service.dart+++ b/mobile/plugins/ente_cast/lib/src/service.dart@@ -2,6 +2,6 @@ import "package:flutter/widgets.dart";abstract class CastService {bool get isSupported;- Future<List<Object>> searchDevices();+ Future<List<(String, Object)>> searchDevices();Future<void> connectDevice(BuildContext context, Object device);}diff --git a/mobile/plugins/ente_cast/pubspec.yaml b/mobile/plugins/ente_cast/pubspec.yamlindex 8ed1e74121..967e147e91 100644--- a/mobile/plugins/ente_cast/pubspec.yaml+++ b/mobile/plugins/ente_cast/pubspec.yaml@@ -16,4 +16,4 @@ dependencies:dev_dependencies:flutter_lints:-flutter:\ No newline at end of file+flutter:diff --git a/mobile/plugins/ente_cast_none/analysis_options.yaml b/mobile/plugins/ente_cast_none/analysis_options.yamlindex fac60e247c..f04c6cf0f3 100644--- a/mobile/plugins/ente_cast_none/analysis_options.yaml+++ b/mobile/plugins/ente_cast_none/analysis_options.yaml@@ -1 +1 @@-include: ../../analysis_options.yaml\ No newline at end of file+include: ../../analysis_options.yamldiff --git a/mobile/plugins/ente_cast_none/lib/src/service.dart b/mobile/plugins/ente_cast_none/lib/src/service.dartindex 964f4e472a..166108c528 100644--- a/mobile/plugins/ente_cast_none/lib/src/service.dart+++ b/mobile/plugins/ente_cast_none/lib/src/service.dart@@ -8,10 +8,11 @@ class CastServiceImpl extends CastService {}@override- Future<List<Object>> searchDevices() {- throw UnimplementedError();- }+ bool get isSupported => false;@override- bool get isSupported => false;+ Future<List<(String, Object)>> searchDevices() {+ // TODO: implement searchDevices+ throw UnimplementedError();+ }}diff --git a/mobile/plugins/ente_cast_none/pubspec.yaml b/mobile/plugins/ente_cast_none/pubspec.yamlindex 0484f000f0..a4559fac53 100644--- a/mobile/plugins/ente_cast_none/pubspec.yaml+++ b/mobile/plugins/ente_cast_none/pubspec.yaml@@ -15,4 +15,4 @@ dependencies:dev_dependencies:flutter_lints:-flutter:\ No newline at end of file+flutter:diff --git a/mobile/plugins/ente_cast_normal/analysis_options.yaml b/mobile/plugins/ente_cast_normal/analysis_options.yamlindex fac60e247c..f04c6cf0f3 100644--- a/mobile/plugins/ente_cast_normal/analysis_options.yaml+++ b/mobile/plugins/ente_cast_normal/analysis_options.yaml@@ -1 +1 @@-include: ../../analysis_options.yaml\ No newline at end of file+include: ../../analysis_options.yamldiff --git a/mobile/plugins/ente_cast_normal/lib/src/service.dart b/mobile/plugins/ente_cast_normal/lib/src/service.dartindex 1664511b6c..eac98ae51b 100644--- a/mobile/plugins/ente_cast_normal/lib/src/service.dart+++ b/mobile/plugins/ente_cast_normal/lib/src/service.dart@@ -27,9 +27,10 @@ class CastServiceImpl extends CastService {}@override- Future<List<Object>> searchDevices() {- // TODO: implement searchDevices- throw UnimplementedError();+ Future<List<(String, Object)>> searchDevices() {+ return CastDiscoveryService().search().then((devices) {+ return devices.map((device) => (device.name, device)).toList();+ });}@overridediff --git a/mobile/plugins/ente_cast_normal/pubspec.yaml b/mobile/plugins/ente_cast_normal/pubspec.yamlindex 17d1721218..c97d70a84b 100644--- a/mobile/plugins/ente_cast_normal/pubspec.yaml+++ b/mobile/plugins/ente_cast_normal/pubspec.yaml@@ -19,4 +19,4 @@ dependencies:dev_dependencies:flutter_lints:-flutter:\ No newline at end of file+flutter: