diff --git a/CONTRIBUTION.md b/CONTRIBUTION.md index b9a57b2f4..11206e6d9 100644 --- a/CONTRIBUTION.md +++ b/CONTRIBUTION.md @@ -123,16 +123,16 @@ Do the following: - Install Development dependencies in linux - Debian (>=12/Bookworm)/Ubuntu ```bash - $ apt-get install mpv libmpv-dev libappindicator3-1 gir1.2-appindicator3-0.1 libappindicator3-dev libsecret-1-0 libjsoncpp25 libsecret-1-dev libjsoncpp-dev libnotify-bin libnotify-dev network-manager + $ apt-get install mpv libmpv-dev libappindicator3-1 gir1.2-appindicator3-0.1 libappindicator3-dev libsecret-1-0 libjsoncpp25 libsecret-1-dev libjsoncpp-dev libnotify-bin libnotify-dev ``` - Use `libjsoncpp1` instead of `libjsoncpp25` (for Ubuntu < 22.04) - Arch/Manjaro ```bash - yay -S mpv libappindicator-gtk3 libsecret jsoncpp libnotify networkmanager + yay -S mpv libappindicator-gtk3 libsecret jsoncpp libnotify ``` - Fedora ```bash - dnf install mpv mpv-devel libappindicator-gtk3 libappindicator-gtk3-devel libsecret libsecret-devel jsoncpp jsoncpp-devel libnotify libnotify-devel NetworkManager + dnf install mpv mpv-devel libappindicator-gtk3 libappindicator-gtk3-devel libsecret libsecret-devel jsoncpp jsoncpp-devel libnotify libnotify-devel ``` - Clone the Repo - Create a `.env` in root of the project following the `.env.example` template diff --git a/aur-struct/.SRCINFO b/aur-struct/.SRCINFO index 13c823820..4f50a9510 100644 --- a/aur-struct/.SRCINFO +++ b/aur-struct/.SRCINFO @@ -10,7 +10,6 @@ pkgbase = spotube-bin depends = libsecret depends = jsoncpp depends = libnotify - depends = networkmanager source = https://github.com/KRTirtho/spotube/releases/download/v2.3.0/Spotube-linux-x86_64.tar.xz md5sums = 8cd6a7385c5c75d203dccd762f1d63ec diff --git a/aur-struct/PKGBUILD b/aur-struct/PKGBUILD index 9d2e093f5..313cd3081 100644 --- a/aur-struct/PKGBUILD +++ b/aur-struct/PKGBUILD @@ -8,7 +8,7 @@ arch=(x86_64) url="https://github.com/KRTirtho/spotube/" license=('BSD-4-Clause') groups=() -depends=('mpv' 'libappindicator-gtk3' 'libsecret' 'jsoncpp' 'libnotify' 'networkmanager') +depends=('mpv' 'libappindicator-gtk3' 'libsecret' 'jsoncpp' 'libnotify') makedepends=() checkdepends=() optdepends=() diff --git a/lib/collections/spotube_icons.dart b/lib/collections/spotube_icons.dart index 754c5f7ec..a0fd39229 100644 --- a/lib/collections/spotube_icons.dart +++ b/lib/collections/spotube_icons.dart @@ -91,4 +91,6 @@ abstract class SpotubeIcons { static const clipboard = FeatherIcons.clipboard; static const api = FeatherIcons.database; static const skip = FeatherIcons.fastForward; + static const noWifi = FeatherIcons.wifiOff; + static const wifi = FeatherIcons.wifi; } diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index d1d723bd1..a99757da7 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -256,5 +256,7 @@ "encryption_failed_warning": "Spotube uses encryption to securely store your data. But failed to do so. So it'll fallback to insecure storage\nIf you're using linux, please make sure you've any secret-service (gnome-keyring, kde-wallet, keepassxc etc) installed", "querying_info": "Querying info...", "piped_api_down": "Piped API is down", - "piped_down_error_instructions": "The Piped instance {pipedInstance} is currently down\n\nEither change the instance or change the 'API type' to official YouTube API\n\nMake sure to restart the app after change" + "piped_down_error_instructions": "The Piped instance {pipedInstance} is currently down\n\nEither change the instance or change the 'API type' to official YouTube API\n\nMake sure to restart the app after change", + "you_are_offline": "You are currently offline", + "connection_restored": "Your internet connection was restored" } \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index 1c4b93650..a7f37bad9 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -4,7 +4,6 @@ import 'package:args/args.dart'; import 'package:catcher/catcher.dart'; import 'package:device_preview/device_preview.dart'; import 'package:fl_query/fl_query.dart'; -import 'package:fl_query_connectivity_plus_adapter/fl_query_connectivity_plus_adapter.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -27,6 +26,7 @@ import 'package:spotube/models/skip_segment.dart'; import 'package:spotube/provider/palette_provider.dart'; import 'package:spotube/provider/user_preferences_provider.dart'; import 'package:spotube/services/audio_player/audio_player.dart'; +import 'package:spotube/services/connectivity_adapter.dart'; import 'package:spotube/themes/theme.dart'; import 'package:spotube/utils/persisted_state_notifier.dart'; import 'package:system_theme/system_theme.dart'; @@ -105,7 +105,7 @@ Future main(List rawArgs) async { await QueryClient.initialize( cachePrefix: "oss.krtirtho.spotube", cacheDir: hiveCacheDir, - connectivity: FlQueryConnectivityPlusAdapter(), + connectivity: FlQueryInternetConnectionCheckerAdapter(), ); Hive.registerAdapter(MatchedTrackAdapter()); Hive.registerAdapter(SkipSegmentAdapter()); diff --git a/lib/pages/root/root_app.dart b/lib/pages/root/root_app.dart index e144e3c61..9f3435397 100644 --- a/lib/pages/root/root_app.dart +++ b/lib/pages/root/root_app.dart @@ -5,11 +5,14 @@ import 'package:flutter/services.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:go_router/go_router.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:internet_connection_checker/internet_connection_checker.dart'; import 'package:shared_preferences/shared_preferences.dart'; +import 'package:spotube/collections/spotube_icons.dart'; import 'package:spotube/components/shared/dialogs/replace_downloaded_dialog.dart'; import 'package:spotube/components/root/bottom_player.dart'; import 'package:spotube/components/root/sidebar.dart'; import 'package:spotube/components/root/spotube_navigation_bar.dart'; +import 'package:spotube/extensions/context.dart'; import 'package:spotube/hooks/use_update_checker.dart'; import 'package:spotube/provider/download_manager_provider.dart'; import 'package:spotube/utils/persisted_state_notifier.dart'; @@ -34,6 +37,8 @@ class RootApp extends HookConsumerWidget { final isMounted = useIsMounted(); final showingDialogCompleter = useRef(Completer()..complete()); final downloader = ref.watch(downloadManagerProvider); + final scaffoldMessenger = ScaffoldMessenger.of(context); + final theme = Theme.of(context); useEffect(() { WidgetsBinding.instance.addPostFrameCallback((_) async { @@ -44,6 +49,52 @@ class RootApp extends HookConsumerWidget { await PersistedStateNotifier.showNoEncryptionDialog(context); } }); + + final subscription = + InternetConnectionChecker().onStatusChange.listen((status) { + switch (status) { + case InternetConnectionStatus.connected: + scaffoldMessenger.showSnackBar( + SnackBar( + content: Row( + children: [ + Icon( + SpotubeIcons.wifi, + color: theme.colorScheme.onPrimary, + ), + const SizedBox(width: 10), + Text(context.l10n.connection_restored), + ], + ), + backgroundColor: theme.colorScheme.primary, + showCloseIcon: true, + width: 350, + ), + ); + case InternetConnectionStatus.disconnected: + scaffoldMessenger.showSnackBar( + SnackBar( + content: Row( + children: [ + Icon( + SpotubeIcons.noWifi, + color: theme.colorScheme.onError, + ), + const SizedBox(width: 10), + Text(context.l10n.you_are_offline), + ], + ), + backgroundColor: theme.colorScheme.error, + showCloseIcon: true, + width: 300, + ), + ); + } + }); + + return () { + subscription.cancel(); + }; }, []); useEffect(() { diff --git a/lib/services/connectivity_adapter.dart b/lib/services/connectivity_adapter.dart new file mode 100644 index 000000000..6a3a46ee7 --- /dev/null +++ b/lib/services/connectivity_adapter.dart @@ -0,0 +1,12 @@ +import 'package:fl_query/fl_query.dart'; +import 'package:internet_connection_checker/internet_connection_checker.dart'; + +class FlQueryInternetConnectionCheckerAdapter extends ConnectivityAdapter { + @override + Future get isConnected => InternetConnectionChecker().hasConnection; + + @override + Stream get onConnectivityChanged => InternetConnectionChecker() + .onStatusChange + .map((status) => status == InternetConnectionStatus.connected); +} diff --git a/linux/packaging/deb/make_config.yaml b/linux/packaging/deb/make_config.yaml index b8c9ec048..c120ce45c 100644 --- a/linux/packaging/deb/make_config.yaml +++ b/linux/packaging/deb/make_config.yaml @@ -16,7 +16,6 @@ dependencies: - libsecret-1-0 - libnotify-bin - libjsoncpp25 - - network-manager essential: false icon: assets/spotube-logo.png diff --git a/linux/packaging/rpm/make_config.yaml b/linux/packaging/rpm/make_config.yaml index 0379ee9a7..55e772cef 100644 --- a/linux/packaging/rpm/make_config.yaml +++ b/linux/packaging/rpm/make_config.yaml @@ -12,7 +12,6 @@ requires: - jsoncpp - libsecret - libnotify - - NetworkManager display_name: Spotube diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index 80a2d2edd..3f63519c1 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -8,7 +8,6 @@ import Foundation import audio_service import audio_session import catcher -import connectivity_plus import device_info_plus import flutter_secure_storage_macos import local_notifier @@ -28,7 +27,6 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { AudioServicePlugin.register(with: registry.registrar(forPlugin: "AudioServicePlugin")) AudioSessionPlugin.register(with: registry.registrar(forPlugin: "AudioSessionPlugin")) CatcherPlugin.register(with: registry.registrar(forPlugin: "CatcherPlugin")) - ConnectivityPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlugin")) DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin")) FlutterSecureStoragePlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStoragePlugin")) LocalNotifierPlugin.register(with: registry.registrar(forPlugin: "LocalNotifierPlugin")) diff --git a/pubspec.lock b/pubspec.lock index 0e2986161..2dbe8cb01 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -330,22 +330,6 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.0" - connectivity_plus: - dependency: transitive - description: - name: connectivity_plus - sha256: "8599ae9edca5ff96163fca3e36f8e481ea917d1e71cdad912c084b5579913f34" - url: "https://pub.dev" - source: hosted - version: "4.0.1" - connectivity_plus_platform_interface: - dependency: transitive - description: - name: connectivity_plus_platform_interface - sha256: cf1d1c28f4416f8c654d7dc3cd638ec586076255d407cef3ddbdaf178272a71a - url: "https://pub.dev" - source: hosted - version: "1.2.4" convert: dependency: transitive description: @@ -538,14 +522,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.0-alpha.3" - fl_query_connectivity_plus_adapter: - dependency: "direct main" - description: - name: fl_query_connectivity_plus_adapter - sha256: a0e69615e25f6dfe74d1e5a0909aeeb865e93c65dd4e0b236f0846f9e54f758b - url: "https://pub.dev" - source: hosted - version: "0.1.0-alpha.2" fl_query_hooks: dependency: "direct main" description: @@ -966,6 +942,14 @@ packages: description: flutter source: sdk version: "0.0.0" + internet_connection_checker: + dependency: "direct main" + description: + name: internet_connection_checker + sha256: "1c683e63e89c9ac66a40748b1b20889fd9804980da732bf2b58d6d5456c8e876" + url: "https://pub.dev" + source: hosted + version: "1.0.0+1" intl: dependency: "direct main" description: @@ -1174,14 +1158,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" oauth2: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 928363427..377c4149f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -36,7 +36,6 @@ dependencies: file_picker: ^5.2.2 fl_query: ^1.0.0-alpha.3 fl_query_hooks: ^1.0.0-alpha.3 - fl_query_connectivity_plus_adapter: ^0.1.0-alpha.2 fluentui_system_icons: ^1.1.189 flutter: sdk: flutter @@ -63,6 +62,7 @@ dependencies: hooks_riverpod: ^2.1.1 html: ^0.15.1 http: ^1.1.0 + internet_connection_checker: ^1.0.0+1 intl: ^0.18.0 introduction_screen: ^3.0.2 json_annotation: ^4.8.1 diff --git a/untranslated_messages.json b/untranslated_messages.json index 0647a58ba..71307e9a2 100644 --- a/untranslated_messages.json +++ b/untranslated_messages.json @@ -1,42 +1,63 @@ { "bn": [ "piped_api_down", - "piped_down_error_instructions" + "piped_down_error_instructions", + "you_are_offline", + "connection_restored" ], "ca": [ "querying_info", "piped_api_down", - "piped_down_error_instructions" + "piped_down_error_instructions", + "you_are_offline", + "connection_restored" ], "de": [ "piped_api_down", - "piped_down_error_instructions" + "piped_down_error_instructions", + "you_are_offline", + "connection_restored" ], "es": [ "piped_api_down", - "piped_down_error_instructions" + "piped_down_error_instructions", + "you_are_offline", + "connection_restored" ], "fr": [ "piped_api_down", - "piped_down_error_instructions" + "piped_down_error_instructions", + "you_are_offline", + "connection_restored" ], "hi": [ "piped_api_down", - "piped_down_error_instructions" + "piped_down_error_instructions", + "you_are_offline", + "connection_restored" ], "ja": [ "piped_api_down", - "piped_down_error_instructions" + "piped_down_error_instructions", + "you_are_offline", + "connection_restored" + ], + + "pl": [ + "you_are_offline", + "connection_restored" ], "zh": [ "piped_api_down", - "piped_down_error_instructions" + "piped_down_error_instructions", + "you_are_offline", + "connection_restored" ] } diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index b377c3c93..b8983c9c7 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -7,7 +7,6 @@ #include "generated_plugin_registrant.h" #include -#include #include #include #include @@ -22,8 +21,6 @@ void RegisterPlugins(flutter::PluginRegistry* registry) { CatcherPluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("CatcherPlugin")); - ConnectivityPlusWindowsPluginRegisterWithRegistrar( - registry->GetRegistrarForPlugin("ConnectivityPlusWindowsPlugin")); FlutterSecureStorageWindowsPluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("FlutterSecureStorageWindowsPlugin")); LocalNotifierPluginRegisterWithRegistrar( diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index ca8c97c92..e066d2236 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -4,7 +4,6 @@ list(APPEND FLUTTER_PLUGIN_LIST catcher - connectivity_plus flutter_secure_storage_windows local_notifier media_kit_libs_windows_audio