From 35367389f0ca8b349c27b6094750c6ce4534aaa1 Mon Sep 17 00:00:00 2001 From: Krille Date: Sun, 8 Oct 2023 19:38:57 +0200 Subject: [PATCH] fix: Remove uncompatible dependencies connectivity_plus and wakelock --- lib/pages/chat/recording_dialog.dart | 6 +-- lib/pages/dialer/dialer.dart | 6 +-- lib/utils/voip_plugin.dart | 20 -------- macos/Flutter/GeneratedPluginRegistrant.swift | 4 -- pubspec.lock | 50 +------------------ pubspec.yaml | 3 +- .../flutter/generated_plugin_registrant.cc | 3 -- windows/flutter/generated_plugins.cmake | 1 - 8 files changed, 8 insertions(+), 85 deletions(-) diff --git a/lib/pages/chat/recording_dialog.dart b/lib/pages/chat/recording_dialog.dart index 317ab7919..86d6cbb61 100644 --- a/lib/pages/chat/recording_dialog.dart +++ b/lib/pages/chat/recording_dialog.dart @@ -6,7 +6,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:path_provider/path_provider.dart'; import 'package:record/record.dart'; -import 'package:wakelock/wakelock.dart'; +import 'package:wakelock_plus/wakelock_plus.dart'; import 'package:fluffychat/config/app_config.dart'; import 'package:fluffychat/utils/platform_infos.dart'; @@ -45,7 +45,7 @@ class RecordingDialogState extends State { setState(() => error = true); return; } - await Wakelock.enable(); + await WakelockPlus.enable(); await _audioRecorder.start( path: _recordedPath, bitRate: bitRate, @@ -77,7 +77,7 @@ class RecordingDialogState extends State { @override void dispose() { - Wakelock.disable(); + WakelockPlus.disable(); _recorderSubscription?.cancel(); _audioRecorder.stop(); super.dispose(); diff --git a/lib/pages/dialer/dialer.dart b/lib/pages/dialer/dialer.dart index a78628077..1af65ce9d 100644 --- a/lib/pages/dialer/dialer.dart +++ b/lib/pages/dialer/dialer.dart @@ -28,7 +28,7 @@ import 'package:flutter_webrtc/flutter_webrtc.dart'; import 'package:just_audio/just_audio.dart'; import 'package:matrix/matrix.dart'; import 'package:vibration/vibration.dart'; -import 'package:wakelock/wakelock.dart'; +import 'package:wakelock_plus/wakelock_plus.dart'; import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart'; import 'package:fluffychat/utils/platform_infos.dart'; @@ -223,7 +223,7 @@ class MyCallingPage extends State { if (call.type == CallType.kVideo) { try { // Enable wakelock (keep screen on) - unawaited(Wakelock.enable()); + unawaited(WakelockPlus.enable()); } catch (_) {} } } @@ -235,7 +235,7 @@ class MyCallingPage extends State { ); if (call.type == CallType.kVideo) { try { - unawaited(Wakelock.disable()); + unawaited(WakelockPlus.disable()); } catch (_) {} } } diff --git a/lib/utils/voip_plugin.dart b/lib/utils/voip_plugin.dart index 393c1dde5..3cc9d5161 100644 --- a/lib/utils/voip_plugin.dart +++ b/lib/utils/voip_plugin.dart @@ -3,7 +3,6 @@ import 'dart:core'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; -import 'package:connectivity_plus/connectivity_plus.dart'; import 'package:flutter_foreground_task/flutter_foreground_task.dart'; import 'package:flutter_webrtc/flutter_webrtc.dart' as webrtc_impl; import 'package:matrix/matrix.dart'; @@ -22,14 +21,6 @@ class VoipPlugin with WidgetsBindingObserver implements WebRTCDelegate { Client get client => matrix.client; VoipPlugin(this.matrix) { voip = VoIP(client, this); - Connectivity() - .onConnectivityChanged - .listen(_handleNetworkChanged) - .onError((e) => _currentConnectivity = ConnectivityResult.none); - Connectivity() - .checkConnectivity() - .then((result) => _currentConnectivity = result) - .catchError((e) => _currentConnectivity = ConnectivityResult.none); if (!kIsWeb) { final wb = WidgetsBinding.instance; wb.addObserver(this); @@ -39,20 +30,9 @@ class VoipPlugin with WidgetsBindingObserver implements WebRTCDelegate { bool background = false; bool speakerOn = false; late VoIP voip; - ConnectivityResult? _currentConnectivity; OverlayEntry? overlayEntry; BuildContext get context => matrix.context; - void _handleNetworkChanged(ConnectivityResult result) async { - /// Got a new connectivity status! - if (_currentConnectivity != result) { - voip.calls.forEach((_, sess) { - sess.restartIce(); - }); - } - _currentConnectivity = result; - } - @override void didChangeAppLifecycleState(AppLifecycleState? state) { Logs().v('AppLifecycleState = $state'); diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index f6375bfec..e47880af4 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -6,7 +6,6 @@ import FlutterMacOS import Foundation import audio_session -import connectivity_plus import desktop_drop import desktop_lifecycle import device_info_plus @@ -31,13 +30,11 @@ import shared_preferences_foundation import sqflite import url_launcher_macos import video_compress -import wakelock_macos import wakelock_plus import window_to_front func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { AudioSessionPlugin.register(with: registry.registrar(forPlugin: "AudioSessionPlugin")) - ConnectivityPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlugin")) DesktopDropPlugin.register(with: registry.registrar(forPlugin: "DesktopDropPlugin")) DesktopLifecyclePlugin.register(with: registry.registrar(forPlugin: "DesktopLifecyclePlugin")) DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin")) @@ -62,7 +59,6 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin")) UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) VideoCompressPlugin.register(with: registry.registrar(forPlugin: "VideoCompressPlugin")) - WakelockMacosPlugin.register(with: registry.registrar(forPlugin: "WakelockMacosPlugin")) WakelockPlusMacosPlugin.register(with: registry.registrar(forPlugin: "WakelockPlusMacosPlugin")) WindowToFrontPlugin.register(with: registry.registrar(forPlugin: "WindowToFrontPlugin")) } diff --git a/pubspec.lock b/pubspec.lock index 72d1c6ce5..7155d6332 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -177,22 +177,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.17.2" - connectivity_plus: - dependency: "direct main" - description: - name: connectivity_plus - sha256: "77a180d6938f78ca7d2382d2240eb626c0f6a735d0bfdce227d8ffb80f95c48b" - url: "https://pub.dev" - source: hosted - version: "4.0.2" - connectivity_plus_platform_interface: - dependency: transitive - description: - name: connectivity_plus_platform_interface - sha256: cf1d1c28f4416f8c654d7dc3cd638ec586076255d407cef3ddbdaf178272a71a - url: "https://pub.dev" - source: hosted - version: "1.2.4" console: dependency: transitive description: @@ -1189,14 +1173,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.0" - nm: - dependency: transitive - description: - name: nm - sha256: "2c9aae4127bdc8993206464fcc063611e0e36e72018696cd9631023a31b24254" - url: "https://pub.dev" - source: hosted - version: "0.5.0" olm: dependency: transitive description: @@ -2058,22 +2034,6 @@ packages: url: "https://pub.dev" source: hosted version: "11.7.1" - wakelock: - dependency: "direct main" - description: - name: wakelock - sha256: "769ecf42eb2d07128407b50cb93d7c10bd2ee48f0276ef0119db1d25cc2f87db" - url: "https://pub.dev" - source: hosted - version: "0.6.2" - wakelock_macos: - dependency: transitive - description: - name: wakelock_macos - sha256: "047c6be2f88cb6b76d02553bca5a3a3b95323b15d30867eca53a19a0a319d4cd" - url: "https://pub.dev" - source: hosted - version: "0.4.0" wakelock_platform_interface: dependency: transitive description: @@ -2083,7 +2043,7 @@ packages: source: hosted version: "0.3.0" wakelock_plus: - dependency: transitive + dependency: "direct main" description: name: wakelock_plus sha256: aac3f3258f01781ec9212df94eecef1eb9ba9350e106728def405baa096ba413 @@ -2098,14 +2058,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.1.0" - wakelock_web: - dependency: transitive - description: - name: wakelock_web - sha256: "1b256b811ee3f0834888efddfe03da8d18d0819317f20f6193e2922b41a501b5" - url: "https://pub.dev" - source: hosted - version: "0.4.0" wakelock_windows: dependency: "direct overridden" description: diff --git a/pubspec.yaml b/pubspec.yaml index 75ca45643..4d09d34b1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,7 +16,6 @@ dependencies: callkeep: ^0.3.2 chewie: ^1.3.6 collection: ^1.16.0 - connectivity_plus: ^4.0.1 cupertino_icons: any desktop_drop: ^0.4.0 desktop_lifecycle: ^0.1.0 @@ -88,7 +87,7 @@ dependencies: vibration: ^1.7.4-nullsafety.0 video_compress: ^3.1.1 video_player: ^2.2.18 - wakelock: ^0.6.2 + wakelock_plus: ^1.1.1 webrtc_interface: ^1.0.13 dev_dependencies: diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index 9a0f2d89a..c56ef092b 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -6,7 +6,6 @@ #include "generated_plugin_registrant.h" -#include #include #include #include @@ -22,8 +21,6 @@ #include void RegisterPlugins(flutter::PluginRegistry* registry) { - ConnectivityPlusWindowsPluginRegisterWithRegistrar( - registry->GetRegistrarForPlugin("ConnectivityPlusWindowsPlugin")); DesktopDropPluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("DesktopDropPlugin")); DesktopLifecyclePluginRegisterWithRegistrar( diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index 2d6a562c7..27cc5bc0d 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -3,7 +3,6 @@ # list(APPEND FLUTTER_PLUGIN_LIST - connectivity_plus desktop_drop desktop_lifecycle dynamic_color