Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/keep model keys on release #146

Merged
merged 3 commits into from
Nov 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@ group 'de.minimalme.spotify_sdk'
version '1.0-SNAPSHOT'

buildscript {
ext.kotlin_version = '1.4.31'
ext.kotlin_version = '1.6.0'
repositories {
google()
jcenter()
mavenCentral()
maven { url "https://jitpack.io" }
}

dependencies {
classpath 'com.android.tools.build:gradle:4.0.1'
classpath 'com.android.tools.build:gradle:4.0.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

rootProject.allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven { url "https://jitpack.io" }
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class SpotifySdkPlugin : MethodCallHandler, FlutterPlugin, ActivityAware, Plugin
// method channel
private var methodChannel: MethodChannel? = null
private val channelName = "spotify_sdk"
private val loggingTag = "spotify_sdk"

// event channels
private var playerContextChannel : EventChannel? = null
Expand Down Expand Up @@ -236,12 +237,18 @@ class SpotifySdkPlugin : MethodCallHandler, FlutterPlugin, ActivityAware, Plugin
object : ConnectionListener {
override fun onConnected(spotifyAppRemoteValue: SpotifyAppRemote) {
spotifyAppRemote = spotifyAppRemoteValue

playerContextChannel?.setStreamHandler(PlayerContextChannel(spotifyAppRemote!!.playerApi))
Log.i(loggingTag, "Set stream handler for PlayerContextChannel")
playerStateChannel?.setStreamHandler(PlayerStateChannel(spotifyAppRemote!!.playerApi))
Log.i(loggingTag, "Set stream handler for PlayerStateChannel")
capabilitiesChannel?.setStreamHandler(CapabilitiesChannel(spotifyAppRemote!!.userApi))
Log.i(loggingTag, "Set stream handler for CapabilitiesChannel")
userStatusChannel?.setStreamHandler(UserStatusChannel(spotifyAppRemote!!.userApi))

Log.i(loggingTag, "Set stream handler for UserStatusChannel")
initiallyConnected = true

Log.i(loggingTag, "App Remote successfully connected")
// emit connection established event
connStatusEventChannel(ConnectionStatusChannel.ConnectionEvent(true, "Successfully connected to Spotify.", null, null))
// method success
Expand Down Expand Up @@ -297,7 +304,7 @@ class SpotifySdkPlugin : MethodCallHandler, FlutterPlugin, ActivityAware, Plugin
errorCode = errorConnection
}
}
Log.e("SPOTIFY_SDK", errorMessage)
Log.e(loggingTag, errorMessage)
// notify plugin
if (initiallyConnected) {
// emit connection error event
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
package de.minimalme.spotify_sdk.subscriptions

import android.util.Log
import com.google.gson.Gson
import com.google.gson.annotations.SerializedName
import io.flutter.plugin.common.EventChannel
import kotlinx.event.SetEvent

class ConnectionStatusChannel(private val connStatusStream: SetEvent<ConnectionEvent>) : EventChannel.StreamHandler {

data class ConnectionEvent(val connected: Boolean, val message: String, val errorCode: String?, val errorDetails: Any?)
data class ConnectionEvent(
@SerializedName("connected") val connected: Boolean,
@SerializedName("message" )val message: String,
@SerializedName("errorCode") val errorCode: String?,
@SerializedName("errorDetails") val errorDetails: Any?
)

override fun onListen(arguments: Any?, events: EventChannel.EventSink?) {
connStatusStream += { event ->
Expand Down
8 changes: 4 additions & 4 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
buildscript {
ext.kotlin_version = '1.4.31'
ext.kotlin_version = '1.6.0'
repositories {
google()
jcenter()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:7.0.2'
classpath 'com.android.tools.build:gradle:7.0.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}

Expand Down
8 changes: 8 additions & 0 deletions example/lib/logging/custom_log_filter.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import 'package:logger/logger.dart';

class CustomLogFilter extends LogFilter {
@override
bool shouldLog(LogEvent event) {
return true;
}
}
12 changes: 11 additions & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,17 @@ class Home extends StatefulWidget {
class _HomeState extends State<Home> {
bool _loading = false;
bool _connected = false;
final Logger _logger = Logger();
final Logger _logger = Logger(
//filter: CustomLogFilter(), // custom logfilter can be used to have logs in release mode
printer: PrettyPrinter(
methodCount: 2, // number of method calls to be displayed
errorMethodCount: 8, // number of method calls if stacktrace is provided
lineLength: 120, // width of the output
colors: true, // Colorful log messages
printEmojis: true, // Print an emoji for each log message
printTime: true,
),
);

CrossfadeState? crossfadeState;
late ImageUri? currentTrackImageUri;
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dependencies:
sdk: flutter
logger: ^1.1.0
flutter_dotenv: ^5.0.2
cupertino_icons: ^1.0.3
cupertino_icons: ^1.0.4

dev_dependencies:
flutter_test:
Expand Down
8 changes: 8 additions & 0 deletions lib/logging/custom_log_filter.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import 'package:logger/logger.dart';

class CustomLogFilter extends LogFilter {
@override
bool shouldLog(LogEvent event) {
return true;
}
}
10 changes: 4 additions & 6 deletions lib/models/album.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 4 additions & 6 deletions lib/models/artist.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions lib/models/capabilities.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 7 additions & 8 deletions lib/models/connection_status.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 5 additions & 6 deletions lib/models/crossfade_state.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions lib/models/image_uri.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 5 additions & 7 deletions lib/models/library_state.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 7 additions & 8 deletions lib/models/player_context.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 5 additions & 32 deletions lib/models/player_options.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 9 additions & 10 deletions lib/models/player_restrictions.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading