From cb99bc8226cd74f53cb15b23770b63e96f5173ad Mon Sep 17 00:00:00 2001 From: Tobias Busch Date: Mon, 15 Feb 2021 09:58:10 +0100 Subject: [PATCH] Feature/update packages (#74) * Update Libraries and move to android embedded v2 * update packages * Update spotify_sdk.yml * Update spotify_sdk.yml * downgrade pedantic * update sdk version * Update spotify_sdk.yml * remove flutter upper bound * move some files to seperate folders * remove unneccessary changes * Update spotify_sdk.yml * downgrade packages * Update spotify_sdk.yml * donwgrade cupertino icons * revert changes from flutter beta * fix dartformat * readd automatically added changes * Update spotify_sdk.yml * Update spotify_sdk.yml * Update README.md * Update README.md * Update README.md --- .github/workflows/spotify_sdk.yml | 16 ++---- README.md | 4 +- .../android/app/src/main/AndroidManifest.xml | 18 ++++--- .../spotify_sdk_example/MainActivity.kt | 9 +--- .../app/src/main/res/values/styles.xml | 4 ++ example/android/build.gradle | 2 +- .../gradle/wrapper/gradle-wrapper.properties | 4 +- example/ios/Flutter/Debug.xcconfig | 1 + example/ios/Flutter/Release.xcconfig | 2 +- example/lib/main.dart | 24 ++++----- example/lib/widgets/sized_icon_button.dart | 2 +- example/pubspec.yaml | 9 ++-- lib/enums/image_dimension_enum.dart | 17 ++++++ lib/enums/repeat_mode_enum.dart | 11 ++++ lib/extensions/image_dimension_extension.dart | 16 ++++++ lib/spotify_sdk.dart | 53 +++---------------- lib/spotify_sdk_web.dart | 8 ++- pubspec.yaml | 12 ++--- 18 files changed, 106 insertions(+), 106 deletions(-) create mode 100644 lib/enums/image_dimension_enum.dart create mode 100644 lib/enums/repeat_mode_enum.dart create mode 100644 lib/extensions/image_dimension_extension.dart diff --git a/.github/workflows/spotify_sdk.yml b/.github/workflows/spotify_sdk.yml index bcf2f25a..c61c201b 100644 --- a/.github/workflows/spotify_sdk.yml +++ b/.github/workflows/spotify_sdk.yml @@ -1,5 +1,5 @@ name: spotify_sdk -on: [push, pull_request] +on: pull_request jobs: build: @@ -13,15 +13,5 @@ jobs: run: flutter format --set-exit-if-changed lib test example - name: Analyze run: flutter analyze lib test example - - name: Run tests - run: flutter test --no-pub --coverage --test-randomize-ordering-seed random - - name: Check Code Coverage - uses: ChicagoFlutter/lcov-cop@v1.0.0 - with: - min_coverage: 3 - path: coverage/lcov.info - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v1 - with: - token: ${{ secrets.CODECOV_TOKEN }} - - run: flutter pub publish --dry-run + - name: Publish dry run + run: flutter pub publish --dry-run diff --git a/README.md b/README.md index 807b36ec..fb7c6975 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # spotify_sdk -[![pub package](https://img.shields.io/badge/pub-1.0.0-orange)](https://pub.dev/packages/spotify_sdk) -[![Dry Run](https://github.com/brim-borium/spotify_sdk/workflows/Dry%20Run/badge.svg?branch=master)](https://github.com/brim-borium/spotify_sdk/actions?query=workflow%3A%22Dry+Run%22) +[![pub package](https://img.shields.io/badge/pub-1.0.1-orange)](https://pub.dev/packages/spotify_sdk) +[![build](https://github.com/brim-borium/spotify_sdk/workflows/spotify_sdk/badge.svg?branch=master)](https://github.com/brim-borium/spotify_sdk/actions?query=workflow%3Aspotify_sdk) [![licence](https://img.shields.io/badge/licence-MIT-blue.svg)](https://github.com/IamTobi/spotify_sdk/blob/master/LICENSE) ## Description diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml index ff2970bd..f60518f1 100644 --- a/example/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -6,9 +6,11 @@ additional functionality it is fine to subclass or reimplement FlutterApplication and put your custom class here. --> + - + android:name="io.flutter.embedding.android.SplashScreenDrawable" + android:resource="@drawable/launch_background" /> + + + diff --git a/example/android/app/src/main/kotlin/de/minimalme/spotify_sdk_example/MainActivity.kt b/example/android/app/src/main/kotlin/de/minimalme/spotify_sdk_example/MainActivity.kt index 1c2959d9..21cb09be 100644 --- a/example/android/app/src/main/kotlin/de/minimalme/spotify_sdk_example/MainActivity.kt +++ b/example/android/app/src/main/kotlin/de/minimalme/spotify_sdk_example/MainActivity.kt @@ -1,12 +1,7 @@ package de.minimalme.spotify_sdk_example -import android.os.Bundle -import io.flutter.app.FlutterActivity -import io.flutter.plugins.GeneratedPluginRegistrant +import io.flutter.embedding.android.FlutterActivity; class MainActivity: FlutterActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - GeneratedPluginRegistrant.registerWith(this) - } + } diff --git a/example/android/app/src/main/res/values/styles.xml b/example/android/app/src/main/res/values/styles.xml index 00fa4417..6db44969 100644 --- a/example/android/app/src/main/res/values/styles.xml +++ b/example/android/app/src/main/res/values/styles.xml @@ -5,4 +5,8 @@ Flutter draws its first frame --> @drawable/launch_background + + diff --git a/example/android/build.gradle b/example/android/build.gradle index dc5cdbc9..c505a863 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -6,7 +6,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:4.0.1' + classpath 'com.android.tools.build:gradle:4.1.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties index 55dde6dd..6946aab9 100644 --- a/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/example/android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Wed Jul 08 17:57:20 CEST 2020 +#Sun Nov 01 19:28:37 CET 2020 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip diff --git a/example/ios/Flutter/Debug.xcconfig b/example/ios/Flutter/Debug.xcconfig index e8efba11..b2f5fae9 100644 --- a/example/ios/Flutter/Debug.xcconfig +++ b/example/ios/Flutter/Debug.xcconfig @@ -1,2 +1,3 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "Generated.xcconfig" diff --git a/example/ios/Flutter/Release.xcconfig b/example/ios/Flutter/Release.xcconfig index 399e9340..c4855bfe 100644 --- a/example/ios/Flutter/Release.xcconfig +++ b/example/ios/Flutter/Release.xcconfig @@ -1,2 +1,2 @@ -#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "Generated.xcconfig" diff --git a/example/lib/main.dart b/example/lib/main.dart index ecc78422..45fb4fe0 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -15,7 +15,7 @@ import 'package:spotify_sdk/spotify_sdk.dart'; import 'widgets/sized_icon_button.dart'; Future main() async { - await DotEnv().load('.env'); + await load(fileName: '.env'); runApp(Home()); } @@ -49,7 +49,7 @@ class _HomeState extends State { title: const Text('SpotifySdk Example'), actions: [ _connected - ? FlatButton( + ? TextButton( child: const Text('Disconnect'), onPressed: disconnect) : Container() ], @@ -70,11 +70,11 @@ class _HomeState extends State { Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - FlatButton( + TextButton( child: const Icon(Icons.settings_remote), onPressed: connectToSpotifyRemote, ), - FlatButton( + TextButton( child: const Text('get auth token '), onPressed: getAuthenticationToken, ), @@ -145,12 +145,12 @@ class _HomeState extends State { ), ], ), - FlatButton( + TextButton( child: const Icon(Icons.favorite), onPressed: addToLibrary), Row( children: [ - FlatButton(child: const Text('seek to'), onPressed: seekTo), - FlatButton( + TextButton(child: const Text('seek to'), onPressed: seekTo), + TextButton( child: const Text('seek to relative'), onPressed: seekToRelative), ], @@ -162,7 +162,7 @@ class _HomeState extends State { fontSize: 16, ), ), - FlatButton( + TextButton( child: const Text('getCrossfadeState'), onPressed: getCrossfadeState), // ignore: prefer_single_quotes @@ -356,8 +356,8 @@ class _HomeState extends State { _loading = true; }); var result = await SpotifySdk.connectToSpotifyRemote( - clientId: DotEnv().env['CLIENT_ID'].toString(), - redirectUrl: DotEnv().env['REDIRECT_URL'].toString()); + clientId: env['CLIENT_ID'].toString(), + redirectUrl: env['REDIRECT_URL'].toString()); setStatus(result ? 'connect to spotify successful' : 'connect to spotify failed'); @@ -380,8 +380,8 @@ class _HomeState extends State { Future getAuthenticationToken() async { try { var authenticationToken = await SpotifySdk.getAuthenticationToken( - clientId: DotEnv().env['CLIENT_ID'].toString(), - redirectUrl: DotEnv().env['REDIRECT_URL'].toString(), + clientId: env['CLIENT_ID'].toString(), + redirectUrl: env['REDIRECT_URL'].toString(), scope: 'app-remote-control, ' 'user-modify-playback-state, ' 'playlist-read-private, ' diff --git a/example/lib/widgets/sized_icon_button.dart b/example/lib/widgets/sized_icon_button.dart index 5f16b821..954ed26c 100644 --- a/example/lib/widgets/sized_icon_button.dart +++ b/example/lib/widgets/sized_icon_button.dart @@ -29,7 +29,7 @@ class SizedIconButton extends StatelessWidget { Widget build(BuildContext context) { return SizedBox( width: width, - child: FlatButton( + child: TextButton( child: Icon(icon), onPressed: onPressed, ), diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 14bbe45f..ba447efd 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -8,17 +8,14 @@ environment: dependencies: flutter: sdk: flutter - logger: ^0.9.1 - flutter_dotenv: ^2.1.0 - - # The following adds the Cupertino Icons font to your application. - # Use with the CupertinoIcons class for iOS style icons. + logger: ^0.9.3 + flutter_dotenv: ^3.1.0 cupertino_icons: ^1.0.0 dev_dependencies: flutter_test: sdk: flutter - pedantic: ^1.9.0 + pedantic: ^1.9.2 spotify_sdk: path: ../ diff --git a/lib/enums/image_dimension_enum.dart b/lib/enums/image_dimension_enum.dart new file mode 100644 index 00000000..1e410540 --- /dev/null +++ b/lib/enums/image_dimension_enum.dart @@ -0,0 +1,17 @@ +/// Holds the values from the spotify api for supported Image dimensions +enum ImageDimension { + /// large image + large, + + ///medium image + medium, + + /// small image + small, + + ///xsmall image + xSmall, + + /// thumbnail image + thumbnail +} diff --git a/lib/enums/repeat_mode_enum.dart b/lib/enums/repeat_mode_enum.dart new file mode 100644 index 00000000..94cd0437 --- /dev/null +++ b/lib/enums/repeat_mode_enum.dart @@ -0,0 +1,11 @@ +/// Holds the values from the spotify api for RepeatModes +enum RepeatMode { + /// repeat is off + off, + + /// repeats the current track + track, + + /// repeats the current context + context, +} diff --git a/lib/extensions/image_dimension_extension.dart b/lib/extensions/image_dimension_extension.dart new file mode 100644 index 00000000..522b1a4c --- /dev/null +++ b/lib/extensions/image_dimension_extension.dart @@ -0,0 +1,16 @@ +import 'package:spotify_sdk/enums/image_dimension_enum.dart'; + +///Extension for formatting the ImageDimension enum to value +extension ImageDimensionExtension on ImageDimension { + ///maps the value to the specified enum + static const values = { + ImageDimension.large: 720, + ImageDimension.medium: 480, + ImageDimension.small: 360, + ImageDimension.xSmall: 240, + ImageDimension.thumbnail: 144, + }; + + /// returns the value + int get value => values[this]; +} diff --git a/lib/spotify_sdk.dart b/lib/spotify_sdk.dart index 815734d7..3b2682d8 100644 --- a/lib/spotify_sdk.dart +++ b/lib/spotify_sdk.dart @@ -6,6 +6,8 @@ import 'package:flutter/services.dart'; import 'package:flutter/widgets.dart'; import 'package:logger/logger.dart'; +import 'enums/image_dimension_enum.dart'; +import 'enums/repeat_mode_enum.dart'; import 'models/capabilities.dart'; import 'models/connection_status.dart'; import 'models/crossfade_state.dart'; @@ -16,6 +18,10 @@ import 'models/player_state.dart'; import 'models/user_status.dart'; import 'platform_channels.dart'; +export 'package:spotify_sdk/enums/image_dimension_enum.dart'; +export 'package:spotify_sdk/enums/repeat_mode_enum.dart'; +export 'package:spotify_sdk/extensions/image_dimension_extension.dart'; + /// /// [SpotifySdk] holds the functionality to connect via spotify remote or /// get an authToken to control the spotify playback and use the functionality @@ -494,7 +500,7 @@ class SpotifySdk { try { return _channel.invokeMethod(MethodNames.getImage, { ParamNames.imageUri: imageUri.raw, - ParamNames.imageDimension: dimension.value + ParamNames.imageDimension: dimension }); } on Exception catch (e) { _logException(MethodNames.getImage, e); @@ -547,48 +553,3 @@ class SpotifySdk { } } } - -/// Holds the values from the spotify api for supported Image dimensions -enum ImageDimension { - /// large image - large, - - ///medium image - medium, - - /// small image - small, - - ///xsmall image - xSmall, - - /// thumbnail image - thumbnail -} - -/// Extension for formatting the ImageDimension enum to value -extension ImageDimensionExtension on ImageDimension { - ///maps the value to the specified enum - static const values = { - ImageDimension.large: 720, - ImageDimension.medium: 480, - ImageDimension.small: 360, - ImageDimension.xSmall: 240, - ImageDimension.thumbnail: 144, - }; - - /// returns the value - int get value => values[this]; -} - -/// Holds the values from the spotify api for RepeatModes -enum RepeatMode { - /// repeat is off - off, - - /// repeats the current track - track, - - /// repeats the current context - context, -} diff --git a/lib/spotify_sdk_web.dart b/lib/spotify_sdk_web.dart index 2476e5eb..34216a02 100644 --- a/lib/spotify_sdk_web.dart +++ b/lib/spotify_sdk_web.dart @@ -9,15 +9,16 @@ import 'dart:html'; import 'dart:js'; import 'dart:math' as math; +import 'package:crypto/crypto.dart'; import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_web_plugins/flutter_web_plugins.dart'; import 'package:js/js.dart'; import 'package:js/js_util.dart'; -import 'package:crypto/crypto.dart'; import 'package:synchronized/synchronized.dart' as synchronized; +import 'enums/repeat_mode_enum.dart'; import 'models/album.dart'; import 'models/artist.dart'; import 'models/connection_status.dart'; @@ -28,7 +29,10 @@ import 'models/player_restrictions.dart'; import 'models/player_state.dart'; import 'models/track.dart'; import 'platform_channels.dart'; -import 'spotify_sdk.dart'; + +export 'package:spotify_sdk/enums/image_dimension_enum.dart'; +export 'package:spotify_sdk/enums/repeat_mode_enum.dart'; +export 'package:spotify_sdk/extensions/image_dimension_extension.dart'; /// /// [SpotifySdkPlugin] is the web implementation of the Spotify SDK plugin. diff --git a/pubspec.yaml b/pubspec.yaml index 705271cd..50525e68 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,12 +1,12 @@ name: spotify_sdk description: A flutter plugin that let's you communicate with the spotify sdk and auth lib -version: 1.0.0 +version: 1.0.1 homepage: https://github.com/brim-borium/spotify_sdk issue_tracker: https://github.com/brim-borium/spotify_sdk/issues environment: sdk: ">=2.7.0 <3.0.0" - flutter: ">=1.12.0 <2.0.0" + flutter: ">=1.12.0" dependencies: flutter: @@ -15,7 +15,7 @@ dependencies: sdk: flutter logger: ^0.9.4 dio: ^3.0.10 - json_annotation: ^3.1.0 + json_annotation: ^3.1.1 js: ^0.6.2 crypto: ^2.1.5 synchronized: ^2.2.0+2 @@ -23,9 +23,9 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - build_runner: ^1.10.0 - json_serializable: ^3.4.0 - pedantic: ^1.9.0 + build_runner: ^1.10.12 + json_serializable: ^3.5.1 + pedantic: ^1.9.2 # For information on the generic Dart part of this file, see the