Skip to content

Commit

Permalink
Feature/update packages (#74)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
brim-borium authored Feb 15, 2021
1 parent b91e8a9 commit cb99bc8
Show file tree
Hide file tree
Showing 18 changed files with 106 additions and 106 deletions.
16 changes: 3 additions & 13 deletions .github/workflows/spotify_sdk.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: spotify_sdk
on: [push, pull_request]
on: pull_request

jobs:
build:
Expand All @@ -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/[email protected]
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
18 changes: 11 additions & 7 deletions example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,27 @@
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<application
android:name="io.flutter.app.FlutterApplication"
android:label="spotify_sdk_example"
android:icon="@mipmap/ic_launcher">
<meta-data
android:name="flutterEmbedding"
android:value="2" />
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- This keeps the window background of the activity showing
until Flutter renders its first frame. It can be removed if
there is no splash screen (such as the default splash screen
defined in @style/LaunchTheme). -->
<meta-data
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
android:value="true" />
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background" />

<!-- Theme to apply as soon as Flutter begins rendering frames -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
}

}
4 changes: 4 additions & 0 deletions example/android/app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@
Flutter draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
</style>

<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
<item name="android:windowBackground">@drawable/launch_background</item>
</style>
</resources>
2 changes: 1 addition & 1 deletion example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
Expand Down
4 changes: 2 additions & 2 deletions example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions example/ios/Flutter/Debug.xcconfig
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 1 addition & 1 deletion example/ios/Flutter/Release.xcconfig
Original file line number Diff line number Diff line change
@@ -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"
24 changes: 12 additions & 12 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import 'package:spotify_sdk/spotify_sdk.dart';
import 'widgets/sized_icon_button.dart';

Future<void> main() async {
await DotEnv().load('.env');
await load(fileName: '.env');
runApp(Home());
}

Expand Down Expand Up @@ -49,7 +49,7 @@ class _HomeState extends State<Home> {
title: const Text('SpotifySdk Example'),
actions: [
_connected
? FlatButton(
? TextButton(
child: const Text('Disconnect'), onPressed: disconnect)
: Container()
],
Expand All @@ -70,11 +70,11 @@ class _HomeState extends State<Home> {
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
FlatButton(
TextButton(
child: const Icon(Icons.settings_remote),
onPressed: connectToSpotifyRemote,
),
FlatButton(
TextButton(
child: const Text('get auth token '),
onPressed: getAuthenticationToken,
),
Expand Down Expand Up @@ -145,12 +145,12 @@ class _HomeState extends State<Home> {
),
],
),
FlatButton(
TextButton(
child: const Icon(Icons.favorite), onPressed: addToLibrary),
Row(
children: <Widget>[
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),
],
Expand All @@ -162,7 +162,7 @@ class _HomeState extends State<Home> {
fontSize: 16,
),
),
FlatButton(
TextButton(
child: const Text('getCrossfadeState'),
onPressed: getCrossfadeState),
// ignore: prefer_single_quotes
Expand Down Expand Up @@ -356,8 +356,8 @@ class _HomeState extends State<Home> {
_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');
Expand All @@ -380,8 +380,8 @@ class _HomeState extends State<Home> {
Future<String> 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, '
Expand Down
2 changes: 1 addition & 1 deletion example/lib/widgets/sized_icon_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
Expand Down
9 changes: 3 additions & 6 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: ../

Expand Down
17 changes: 17 additions & 0 deletions lib/enums/image_dimension_enum.dart
Original file line number Diff line number Diff line change
@@ -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
}
11 changes: 11 additions & 0 deletions lib/enums/repeat_mode_enum.dart
Original file line number Diff line number Diff line change
@@ -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,
}
16 changes: 16 additions & 0 deletions lib/extensions/image_dimension_extension.dart
Original file line number Diff line number Diff line change
@@ -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];
}
53 changes: 7 additions & 46 deletions lib/spotify_sdk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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,
}
8 changes: 6 additions & 2 deletions lib/spotify_sdk_web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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.
Expand Down
Loading

0 comments on commit cb99bc8

Please sign in to comment.