From 31551ac1dc487adaf3015124c38804bc886ce69e Mon Sep 17 00:00:00 2001 From: Kingkor Roy Tirtho Date: Sat, 21 May 2022 17:15:46 +0600 Subject: [PATCH] application adpted to Flutter 3.0 Got ready for F-Droid release --- bin/create-secrets.dart | 150 +++++++++++++++++- lib/components/Home/Sidebar.dart | 2 +- lib/components/Library/UserArtists.dart | 2 +- lib/components/Player/Player.dart | 2 +- lib/components/Player/PlayerView.dart | 2 +- lib/components/Shared/RecordHotKeyDialog.dart | 6 +- lib/helpers/search-youtube.dart | 2 +- lib/hooks/useIsCurrentRoute.dart | 2 +- lib/hooks/usePaletteColor.dart | 2 +- pubspec.lock | 96 +++++------ 10 files changed, 205 insertions(+), 61 deletions(-) diff --git a/bin/create-secrets.dart b/bin/create-secrets.dart index feb0d7fe..e59c5668 100644 --- a/bin/create-secrets.dart +++ b/bin/create-secrets.dart @@ -3,6 +3,139 @@ import 'dart:io'; import 'package:path/path.dart' as path; +// blob metadata for de-stringifying +const randHash = [ + 49, + 111, + 98, + 72, + 78, + 122, + 98, + 48, + 112, + 73, + 81, + 50, + 112, + 89, + 90, + 50, + 116, + 83, + 84, + 110, + 99, + 105, + 76, + 67, + 74, + 67, + 89, + 121, + 48, + 119, + 77, + 106, + 69, + 50, + 86, + 69, + 53, + 107, + 77, + 69, + 86, + 71, + 101, + 68, + 66, + 113, + 78, + 110, + 66, + 119 +]; +const sugarCarbonator = [ + 81, + 119, + 79, + 71, + 85, + 53, + 78, + 50, + 69, + 52, + 90, + 68, + 107, + 120, + 77, + 87, + 89, + 52, + 89, + 84, + 73 +]; +const randomSalt = [ + 70, + 117, + 67, + 75, + 117, + 116, + 72, + 101, + 105, + 102, + 65, + 110, + 68, + 87, + 72, + 97, + 84, + 85, + 82, + 100, + 79, + 73, + 110, + 103, + 83, + 117, + 75, + 115 +]; +const algorithmicSugar = [ + 70, + 117, + 67, + 75, + 117, + 116, + 72, + 101, + 105, + 102, + 65, + 78, + 100, + 102, + 68, + 114, + 79, + 105, + 100, + 115, + 85, + 99, + 107, + 83 +]; + void main(List args) async { List val; List val2; @@ -10,7 +143,7 @@ void main(List args) async { final cwd = Directory.current.path; final binSafe = cwd.endsWith("/bin") ? ".." : ""; if (args.isEmpty) { - throw ArgumentError("Expected 1-2 arguments but passed none"); + throw ArgumentError("Expected 1-3 arguments but passed none"); } if (args.contains("--local")) { final secretFilePath = path.join(cwd, binSafe, "secrets.json"); @@ -19,11 +152,22 @@ void main(List args) async { final data = jsonDecode(await file.readAsString()); val = List.castFrom(data["LYRICS_SECRET"]); val2 = List.castFrom(data["SPOTIFY_SECRET"]); + } else if (args.contains("--fdroid")) { + final decodedLyricSecret = utf8.decode(base64Decode( + args[1].replaceAll( + String.fromCharCodes(randomSalt), String.fromCharCodes(randHash)), + )); + final decodedSpotifySecret = utf8.decode(base64Decode( + args.last.replaceAll(String.fromCharCodes(algorithmicSugar), + String.fromCharCodes(sugarCarbonator)), + )); + val = List.castFrom(jsonDecode(decodedLyricSecret)); + val2 = List.castFrom(jsonDecode(decodedSpotifySecret)); } else { final decodedLyricSecret = utf8.decode(base64Decode(args.first)); - final decodedSpotifySecrete = utf8.decode(base64Decode(args.last)); + final decodedSpotifySecret = utf8.decode(base64Decode(args.last)); val = List.castFrom(jsonDecode(decodedLyricSecret)); - val2 = List.castFrom(jsonDecode(decodedSpotifySecrete)); + val2 = List.castFrom(jsonDecode(decodedSpotifySecret)); } await File(path.join(cwd, binSafe, "lib/models/generated_secrets.dart")) diff --git a/lib/components/Home/Sidebar.dart b/lib/components/Home/Sidebar.dart index ffd5219e..ae67b877 100644 --- a/lib/components/Home/Sidebar.dart +++ b/lib/components/Home/Sidebar.dart @@ -81,7 +81,7 @@ class Sidebar extends HookConsumerWidget { trailing: FutureBuilder( future: spotify.me.get(), builder: (context, snapshot) { - var avatarImg = imageToUrlString(snapshot.data?.images, + final avatarImg = imageToUrlString(snapshot.data?.images, index: (snapshot.data?.images?.length ?? 1) - 1); return extended.value ? Padding( diff --git a/lib/components/Library/UserArtists.dart b/lib/components/Library/UserArtists.dart index 46524930..f7eabc1f 100644 --- a/lib/components/Library/UserArtists.dart +++ b/lib/components/Library/UserArtists.dart @@ -21,7 +21,7 @@ class _UserArtistsState extends ConsumerState { @override void initState() { super.initState(); - WidgetsBinding.instance?.addPostFrameCallback((timestamp) { + WidgetsBinding.instance.addPostFrameCallback((timestamp) { _pagingController.addPageRequestListener((pageKey) async { try { SpotifyApi spotifyApi = ref.read(spotifyProvider); diff --git a/lib/components/Player/Player.dart b/lib/components/Player/Player.dart index bd8d101f..0d7b9cdf 100644 --- a/lib/components/Player/Player.dart +++ b/lib/components/Player/Player.dart @@ -92,7 +92,7 @@ class Player extends HookConsumerWidget { // I can't believe useEffect doesn't run Post Frame aka // after rendering/painting the UI // `My disappointment is immeasurable and my day is ruined` XD - WidgetsBinding.instance?.addPostFrameCallback((time) { + WidgetsBinding.instance.addPostFrameCallback((time) { // clearing the overlay-entry as passing the already available // entry will result in splashing while resizing the window if (breakpoint.isLessThanOrEqualTo(Breakpoints.md) && diff --git a/lib/components/Player/PlayerView.dart b/lib/components/Player/PlayerView.dart index eb66945b..8216af3e 100644 --- a/lib/components/Player/PlayerView.dart +++ b/lib/components/Player/PlayerView.dart @@ -29,7 +29,7 @@ class PlayerView extends HookConsumerWidget { useEffect(() { if (breakpoint.isMoreThan(Breakpoints.md)) { - WidgetsBinding.instance?.addPostFrameCallback((_) { + WidgetsBinding.instance.addPostFrameCallback((_) { GoRouter.of(context).pop(); }); } diff --git a/lib/components/Shared/RecordHotKeyDialog.dart b/lib/components/Shared/RecordHotKeyDialog.dart index 4114f3c6..ff8a6885 100644 --- a/lib/components/Shared/RecordHotKeyDialog.dart +++ b/lib/components/Shared/RecordHotKeyDialog.dart @@ -13,7 +13,7 @@ class RecordHotKeyDialog extends HookWidget { @override Widget build(BuildContext context) { - var _hotKey = useState(HotKey(null)); + final _hotKey = useState(null); return AlertDialog( content: SingleChildScrollView( child: ListBody( @@ -72,10 +72,10 @@ class RecordHotKeyDialog extends HookWidget { ), TextButton( child: const Text('OK'), - onPressed: !_hotKey.value.isSetted + onPressed: _hotKey.value == null ? null : () { - onHotKeyRecorded(_hotKey.value); + onHotKeyRecorded(_hotKey.value!); GoRouter.of(context).pop(); }, ), diff --git a/lib/helpers/search-youtube.dart b/lib/helpers/search-youtube.dart index afba453c..5d449144 100644 --- a/lib/helpers/search-youtube.dart +++ b/lib/helpers/search-youtube.dart @@ -30,7 +30,7 @@ Future toSpotubeTrack( .replaceAll("\$FEATURED_ARTISTS", featuredArtists); logger.v("[Youtube Search Term] $queryString"); - SearchList videos = await youtube.search.getVideos(queryString); + VideoSearchList videos = await youtube.search.search(queryString); List ratedRankedVideos = videos .map((video) { diff --git a/lib/hooks/useIsCurrentRoute.dart b/lib/hooks/useIsCurrentRoute.dart index eeb1ff77..96c55a05 100644 --- a/lib/hooks/useIsCurrentRoute.dart +++ b/lib/hooks/useIsCurrentRoute.dart @@ -6,7 +6,7 @@ bool? useIsCurrentRoute([String matcher = "/"]) { final isCurrentRoute = useState(null); final context = useContext(); useEffect(() { - WidgetsBinding.instance?.addPostFrameCallback((timer) { + WidgetsBinding.instance.addPostFrameCallback((timer) { final isCurrent = GoRouter.of(context).location == matcher; if (isCurrent != isCurrentRoute.value) { isCurrentRoute.value = isCurrent; diff --git a/lib/hooks/usePaletteColor.dart b/lib/hooks/usePaletteColor.dart index b6cebd5a..5d665b33 100644 --- a/lib/hooks/usePaletteColor.dart +++ b/lib/hooks/usePaletteColor.dart @@ -9,7 +9,7 @@ PaletteColor usePaletteColor(BuildContext context, String imageUrl) { final mounted = useIsMounted(); useEffect(() { - WidgetsBinding.instance?.addPostFrameCallback((timeStamp) async { + WidgetsBinding.instance.addPostFrameCallback((timeStamp) async { final palette = await PaletteGenerator.fromImageProvider( CachedNetworkImageProvider( imageUrl, diff --git a/pubspec.lock b/pubspec.lock index 861c95c4..1125967c 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -14,14 +14,14 @@ packages: name: archive url: "https://pub.dartlang.org" source: hosted - version: "3.2.1" + version: "3.3.0" args: dependency: transitive description: name: args url: "https://pub.dartlang.org" source: hosted - version: "2.3.0" + version: "2.3.1" async: dependency: transitive description: @@ -105,7 +105,7 @@ packages: name: cached_network_image url: "https://pub.dartlang.org" source: hosted - version: "3.2.0" + version: "3.2.1" cached_network_image_platform_interface: dependency: transitive description: @@ -154,7 +154,7 @@ packages: name: crypto url: "https://pub.dartlang.org" source: hosted - version: "3.0.1" + version: "3.0.2" csslib: dependency: transitive description: @@ -189,7 +189,7 @@ packages: name: ffi url: "https://pub.dartlang.org" source: hosted - version: "1.1.2" + version: "1.2.1" file: dependency: transitive description: @@ -208,7 +208,7 @@ packages: name: flutter_blurhash url: "https://pub.dartlang.org" source: hosted - version: "0.6.4" + version: "0.7.0" flutter_cache_manager: dependency: transitive description: @@ -222,7 +222,7 @@ packages: name: flutter_hooks url: "https://pub.dartlang.org" source: hosted - version: "0.18.2+1" + version: "0.18.4" flutter_launcher_icons: dependency: "direct dev" description: @@ -243,7 +243,7 @@ packages: name: flutter_riverpod url: "https://pub.dartlang.org" source: hosted - version: "1.0.3" + version: "1.0.4" flutter_test: dependency: "direct dev" description: flutter @@ -267,21 +267,21 @@ packages: name: go_router url: "https://pub.dartlang.org" source: hosted - version: "3.0.4" + version: "3.1.0" hooks_riverpod: dependency: "direct main" description: name: hooks_riverpod url: "https://pub.dartlang.org" source: hosted - version: "1.0.3" + version: "1.0.4" hotkey_manager: dependency: "direct main" description: name: hotkey_manager url: "https://pub.dartlang.org" source: hosted - version: "0.1.6" + version: "0.1.7" html: dependency: "direct main" description: @@ -302,7 +302,7 @@ packages: name: http_parser url: "https://pub.dartlang.org" source: hosted - version: "4.0.0" + version: "4.0.1" image: dependency: transitive description: @@ -330,14 +330,14 @@ packages: name: json_annotation url: "https://pub.dartlang.org" source: hosted - version: "4.4.0" + version: "4.5.0" just_audio: dependency: "direct main" description: name: just_audio url: "https://pub.dartlang.org" source: hosted - version: "0.9.20" + version: "0.9.21" just_audio_background: dependency: "direct main" description: @@ -400,7 +400,7 @@ packages: name: marquee url: "https://pub.dartlang.org" source: hosted - version: "2.2.1" + version: "2.2.2" matcher: dependency: transitive description: @@ -442,7 +442,7 @@ packages: name: octo_image url: "https://pub.dartlang.org" source: hosted - version: "1.0.1" + version: "1.0.2" package_config: dependency: transitive description: @@ -512,49 +512,49 @@ packages: name: path_provider url: "https://pub.dartlang.org" source: hosted - version: "2.0.9" + version: "2.0.10" path_provider_android: dependency: transitive description: name: path_provider_android url: "https://pub.dartlang.org" source: hosted - version: "2.0.11" + version: "2.0.14" path_provider_ios: dependency: transitive description: name: path_provider_ios url: "https://pub.dartlang.org" source: hosted - version: "2.0.7" + version: "2.0.9" path_provider_linux: dependency: transitive description: name: path_provider_linux url: "https://pub.dartlang.org" source: hosted - version: "2.1.5" + version: "2.1.6" path_provider_macos: dependency: transitive description: name: path_provider_macos url: "https://pub.dartlang.org" source: hosted - version: "2.0.5" + version: "2.0.6" path_provider_platform_interface: dependency: transitive description: name: path_provider_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.0.3" + version: "2.0.4" path_provider_windows: dependency: transitive description: name: path_provider_windows url: "https://pub.dartlang.org" source: hosted - version: "2.0.5" + version: "2.0.6" pedantic: dependency: transitive description: @@ -582,7 +582,7 @@ packages: name: permission_handler_apple url: "https://pub.dartlang.org" source: hosted - version: "9.0.3" + version: "9.0.4" permission_handler_platform_interface: dependency: transitive description: @@ -603,7 +603,7 @@ packages: name: petitparser url: "https://pub.dartlang.org" source: hosted - version: "4.4.0" + version: "5.0.0" platform: dependency: transitive description: @@ -652,35 +652,35 @@ packages: name: shared_preferences url: "https://pub.dartlang.org" source: hosted - version: "2.0.13" + version: "2.0.15" shared_preferences_android: dependency: transitive description: name: shared_preferences_android url: "https://pub.dartlang.org" source: hosted - version: "2.0.11" + version: "2.0.12" shared_preferences_ios: dependency: transitive description: name: shared_preferences_ios url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.1.1" shared_preferences_linux: dependency: transitive description: name: shared_preferences_linux url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.1.1" shared_preferences_macos: dependency: transitive description: name: shared_preferences_macos url: "https://pub.dartlang.org" source: hosted - version: "2.0.3" + version: "2.0.4" shared_preferences_platform_interface: dependency: transitive description: @@ -694,14 +694,14 @@ packages: name: shared_preferences_web url: "https://pub.dartlang.org" source: hosted - version: "2.0.3" + version: "2.0.4" shared_preferences_windows: dependency: transitive description: name: shared_preferences_windows url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.1.1" sky_engine: dependency: transitive description: flutter @@ -713,7 +713,7 @@ packages: name: sliver_tools url: "https://pub.dartlang.org" source: hosted - version: "0.2.5" + version: "0.2.6" source_span: dependency: transitive description: @@ -736,14 +736,14 @@ packages: name: sqflite url: "https://pub.dartlang.org" source: hosted - version: "2.0.2" + version: "2.0.2+1" sqflite_common: dependency: transitive description: name: sqflite_common url: "https://pub.dartlang.org" source: hosted - version: "2.2.0" + version: "2.2.1+1" stack_trace: dependency: transitive description: @@ -778,7 +778,7 @@ packages: name: synchronized url: "https://pub.dartlang.org" source: hosted - version: "3.0.0" + version: "3.0.0+2" term_glyph: dependency: transitive description: @@ -799,42 +799,42 @@ packages: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.3.1" url_launcher: dependency: "direct main" description: name: url_launcher url: "https://pub.dartlang.org" source: hosted - version: "6.0.20" + version: "6.1.2" url_launcher_android: dependency: transitive description: name: url_launcher_android url: "https://pub.dartlang.org" source: hosted - version: "6.0.15" + version: "6.0.17" url_launcher_ios: dependency: transitive description: name: url_launcher_ios url: "https://pub.dartlang.org" source: hosted - version: "6.0.15" + version: "6.0.17" url_launcher_linux: dependency: transitive description: name: url_launcher_linux url: "https://pub.dartlang.org" source: hosted - version: "3.0.0" + version: "3.0.1" url_launcher_macos: dependency: transitive description: name: url_launcher_macos url: "https://pub.dartlang.org" source: hosted - version: "3.0.0" + version: "3.0.1" url_launcher_platform_interface: dependency: transitive description: @@ -848,14 +848,14 @@ packages: name: url_launcher_web url: "https://pub.dartlang.org" source: hosted - version: "2.0.8" + version: "2.0.11" url_launcher_windows: dependency: transitive description: name: url_launcher_windows url: "https://pub.dartlang.org" source: hosted - version: "3.0.0" + version: "3.0.1" uuid: dependency: transitive description: @@ -890,21 +890,21 @@ packages: name: xml url: "https://pub.dartlang.org" source: hosted - version: "5.3.1" + version: "5.4.1" yaml: dependency: transitive description: name: yaml url: "https://pub.dartlang.org" source: hosted - version: "3.1.0" + version: "3.1.1" youtube_explode_dart: dependency: "direct main" description: name: youtube_explode_dart url: "https://pub.dartlang.org" source: hosted - version: "1.10.9+1" + version: "1.11.0" sdks: dart: ">=2.17.0 <3.0.0" - flutter: ">=2.10.0" + flutter: ">=3.0.0"