Skip to content

Commit

Permalink
fix: replace connectivity_plus with internet_connection_checker
Browse files Browse the repository at this point in the history
  • Loading branch information
KRTirtho committed Aug 26, 2023
1 parent 5378571 commit f23e871
Show file tree
Hide file tree
Showing 16 changed files with 112 additions and 57 deletions.
6 changes: 3 additions & 3 deletions CONTRIBUTION.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion aur-struct/.SRCINFO
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion aur-struct/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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=()
Expand Down
2 changes: 2 additions & 0 deletions lib/collections/spotube_icons.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
4 changes: 3 additions & 1 deletion lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
4 changes: 2 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';
Expand Down Expand Up @@ -105,7 +105,7 @@ Future<void> main(List<String> rawArgs) async {
await QueryClient.initialize(
cachePrefix: "oss.krtirtho.spotube",
cacheDir: hiveCacheDir,
connectivity: FlQueryConnectivityPlusAdapter(),
connectivity: FlQueryInternetConnectionCheckerAdapter(),
);
Hive.registerAdapter(MatchedTrackAdapter());
Hive.registerAdapter(SkipSegmentAdapter());
Expand Down
51 changes: 51 additions & 0 deletions lib/pages/root/root_app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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 {
Expand All @@ -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(() {
Expand Down
12 changes: 12 additions & 0 deletions lib/services/connectivity_adapter.dart
Original file line number Diff line number Diff line change
@@ -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<bool> get isConnected => InternetConnectionChecker().hasConnection;

@override
Stream<bool> get onConnectivityChanged => InternetConnectionChecker()
.onStatusChange
.map((status) => status == InternetConnectionStatus.connected);
}
1 change: 0 additions & 1 deletion linux/packaging/deb/make_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ dependencies:
- libsecret-1-0
- libnotify-bin
- libjsoncpp25
- network-manager

essential: false
icon: assets/spotube-logo.png
Expand Down
1 change: 0 additions & 1 deletion linux/packaging/rpm/make_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ requires:
- jsoncpp
- libsecret
- libnotify
- NetworkManager

display_name: Spotube

Expand Down
2 changes: 0 additions & 2 deletions macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"))
Expand Down
40 changes: 8 additions & 32 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
37 changes: 29 additions & 8 deletions untranslated_messages.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
3 changes: 0 additions & 3 deletions windows/flutter/generated_plugin_registrant.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "generated_plugin_registrant.h"

#include <catcher/catcher_plugin.h>
#include <connectivity_plus/connectivity_plus_windows_plugin.h>
#include <flutter_secure_storage_windows/flutter_secure_storage_windows_plugin.h>
#include <local_notifier/local_notifier_plugin.h>
#include <media_kit_libs_windows_audio/media_kit_libs_windows_audio_plugin_c_api.h>
Expand All @@ -22,8 +21,6 @@
void RegisterPlugins(flutter::PluginRegistry* registry) {
CatcherPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("CatcherPlugin"));
ConnectivityPlusWindowsPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("ConnectivityPlusWindowsPlugin"));
FlutterSecureStorageWindowsPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FlutterSecureStorageWindowsPlugin"));
LocalNotifierPluginRegisterWithRegistrar(
Expand Down
1 change: 0 additions & 1 deletion windows/flutter/generated_plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

list(APPEND FLUTTER_PLUGIN_LIST
catcher
connectivity_plus
flutter_secure_storage_windows
local_notifier
media_kit_libs_windows_audio
Expand Down

0 comments on commit f23e871

Please sign in to comment.