Skip to content

Commit 77c0c89

Browse files
author
Adam Ratzman
committed
fix top level method not showing up on android
1 parent 6444873 commit 77c0c89

File tree

9 files changed

+110
-110
lines changed

9 files changed

+110
-110
lines changed

build.gradle.kts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ buildscript {
3131
}
3232

3333
group = "com.adamratzman"
34-
version = "3.2.03"
34+
version = "3.2.04"
3535

3636
/*java {
3737
withSourcesJar()
@@ -52,15 +52,14 @@ android {
5252
setTargetCompatibility(JavaVersion.VERSION_1_8)
5353
}
5454
packagingOptions {
55-
exclude("META-INF/*.kotlin_module")
55+
// exclude("META-INF/*.kotlin_module")
5656
exclude("META-INF/*.md")
5757
}
5858
defaultConfig {
59-
minSdkVersion(15)
59+
minSdkVersion(20)
6060
targetSdkVersion(30)
6161
versionCode = 1
6262
versionName = "1.0"
63-
multiDexEnabled = true
6463
testInstrumentationRunner = "android.support.test.runner.AndroidJUnitRunner"
6564
}
6665
buildTypes {
@@ -272,7 +271,11 @@ publishing {
272271
}
273272

274273
signing {
275-
sign(publishing.publications)
274+
if (project.hasProperty("signing.keyId")
275+
&& project.hasProperty("signing.password")
276+
&& project.hasProperty("signing.secretKeyRingFile")) {
277+
sign(publishing.publications)
278+
}
276279
}
277280

278281
tasks {

settings.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ pluginManagement {
2929

3030
enableFeaturePreview("GRADLE_METADATA")
3131

32-
rootProject.name = "com.adamratzman.spotify-web-api-kotlin"
32+
rootProject.name = "spotify-web-api-kotlin"
3333

src/androidMain/kotlin/com/adamratzman/spotify/Pkce.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
/* Spotify Web API, Kotlin Wrapper; MIT License, 2017-2020; Original author: Adam Ratzman */
12
package com.adamratzman.spotify
23

34
import android.os.Build.VERSION
45
import android.os.Build.VERSION_CODES
6+
import android.util.Base64
57
import java.security.MessageDigest
6-
import android.util.Base64;
78

89
actual fun getSpotifyPkceCodeChallenge(codeVerifier: String): String {
910
val sha256 = MessageDigest.getInstance("SHA-256").digest(codeVerifier.toByteArray())

src/androidTest/kotlin/com/adamratzman/spotify/CommonImpl.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import android.os.Build.VERSION
55
import java.lang.reflect.Field
66
import java.lang.reflect.Modifier
77

8-
98
fun setFinalStatic(field: Field, newValue: Any?) {
109
field.isAccessible = true
1110
val modifiersField = Field::class.java.getDeclaredField("modifiers")

src/commonMain/kotlin/com.adamratzman.spotify/Builder.kt

Lines changed: 81 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ import kotlinx.serialization.json.Json
3131
* @param state This provides protection against attacks such as cross-site request forgery.
3232
*/
3333
fun getSpotifyAuthorizationUrl(
34-
vararg scopes: SpotifyScope,
35-
clientId: String,
36-
redirectUri: String,
37-
isImplicitGrantFlow: Boolean = false,
38-
shouldShowDialog: Boolean = false,
39-
state: String? = null
34+
vararg scopes: SpotifyScope,
35+
clientId: String,
36+
redirectUri: String,
37+
isImplicitGrantFlow: Boolean = false,
38+
shouldShowDialog: Boolean = false,
39+
state: String? = null
4040
): String {
4141
return SpotifyApi.getAuthUrlFull(
4242
*scopes,
@@ -60,11 +60,11 @@ fun getSpotifyAuthorizationUrl(
6060
* Then, base64url encode the hash that you generated.
6161
*/
6262
fun getPkceAuthorizationUrl(
63-
vararg scopes: SpotifyScope,
64-
clientId: String,
65-
redirectUri: String,
66-
codeChallenge: String,
67-
state: String? = null
63+
vararg scopes: SpotifyScope,
64+
clientId: String,
65+
redirectUri: String,
66+
codeChallenge: String,
67+
state: String? = null
6868
): String {
6969
return SpotifyApi.getPkceAuthUrlFull(
7070
*scopes,
@@ -224,10 +224,10 @@ fun spotifyAppApi(block: SpotifyAppApiBuilder.() -> Unit) = SpotifyAppApiBuilder
224224
* @return Configurable [SpotifyClientApiBuilder] that, when built, creates a new [SpotifyClientApi]
225225
*/
226226
fun spotifyClientApi(
227-
clientId: String,
228-
clientSecret: String,
229-
redirectUri: String,
230-
block: SpotifyClientApiBuilder.() -> Unit
227+
clientId: String,
228+
clientSecret: String,
229+
redirectUri: String,
230+
block: SpotifyClientApiBuilder.() -> Unit
231231
) = SpotifyClientApiBuilder().apply(block).apply {
232232
credentials {
233233
this.clientId = clientId
@@ -248,10 +248,10 @@ fun spotifyClientApi(
248248
* @return Configurable [SpotifyClientApiBuilder] that, when built, creates a new [SpotifyClientApi]
249249
*/
250250
fun spotifyClientApi(
251-
clientId: String?,
252-
clientSecret: String?,
253-
redirectUri: String?,
254-
apiToken: Token
251+
clientId: String?,
252+
clientSecret: String?,
253+
redirectUri: String?,
254+
apiToken: Token
255255
) = SpotifyClientApiBuilder().apply {
256256
credentials {
257257
this.clientId = clientId
@@ -276,10 +276,10 @@ fun spotifyClientApi(
276276
* @return Configurable [SpotifyClientApiBuilder] that, when built, creates a new [SpotifyClientApi]
277277
*/
278278
fun spotifyClientApi(
279-
clientId: String?,
280-
clientSecret: String?,
281-
redirectUri: String?,
282-
authCode: String
279+
clientId: String?,
280+
clientSecret: String?,
281+
redirectUri: String?,
282+
authCode: String
283283
) = SpotifyClientApiBuilder().apply {
284284
credentials {
285285
this.clientId = clientId
@@ -292,7 +292,6 @@ fun spotifyClientApi(
292292
}
293293
}
294294

295-
296295
/**
297296
* Instantiate a new [SpotifyClientApiBuilder] using a Spotify [clientId], [clientSecret], and [redirectUri],
298297
* with an existing [SpotifyUserAuthorization] and with the ability to configure the api settings by providing a
@@ -310,12 +309,12 @@ fun spotifyClientApi(
310309
* @return Configurable [SpotifyClientApiBuilder] that, when built, creates a new [SpotifyClientApi]
311310
*/
312311
fun spotifyClientApi(
313-
clientId: String,
314-
clientSecret: String,
315-
redirectUri: String,
316-
authorization: SpotifyUserAuthorization,
317-
options: SpotifyApiOptions? = null,
318-
block: SpotifyClientApiBuilder.() -> Unit = {}
312+
clientId: String,
313+
clientSecret: String,
314+
redirectUri: String,
315+
authorization: SpotifyUserAuthorization,
316+
options: SpotifyApiOptions? = null,
317+
block: SpotifyClientApiBuilder.() -> Unit = {}
319318
) = SpotifyClientApiBuilder().apply(block).apply {
320319
credentials {
321320
this.clientId = clientId
@@ -338,7 +337,6 @@ fun spotifyClientApi(
338337
*/
339338
fun spotifyClientApi(block: SpotifyClientApiBuilder.() -> Unit) = SpotifyClientApiBuilder().apply(block)
340339

341-
342340
// PKCE Client Api Builders
343341
/*
344342
____________________________
@@ -365,10 +363,10 @@ fun spotifyClientApi(block: SpotifyClientApiBuilder.() -> Unit) = SpotifyClientA
365363
* @return Configurable [SpotifyClientApiBuilder] that, when built, creates a new [SpotifyClientApi]
366364
*/
367365
fun spotifyClientPkceApi(
368-
clientId: String?,
369-
redirectUri: String?,
370-
authCode: String,
371-
codeVerifier: String
366+
clientId: String?,
367+
redirectUri: String?,
368+
authCode: String,
369+
codeVerifier: String
372370
) = SpotifyClientApiBuilder().apply {
373371
credentials {
374372
this.clientId = clientId
@@ -395,11 +393,11 @@ fun spotifyClientPkceApi(
395393
* @return Configurable [SpotifyClientApiBuilder] that, when built, creates a new [SpotifyClientApi]
396394
*/
397395
fun spotifyClientPkceApi(
398-
clientId: String?,
399-
redirectUri: String?,
400-
authCode: String,
401-
codeVerifier: String,
402-
block: SpotifyClientApiBuilder.() -> Unit = {}
396+
clientId: String?,
397+
redirectUri: String?,
398+
authCode: String,
399+
codeVerifier: String,
400+
block: SpotifyClientApiBuilder.() -> Unit = {}
403401
) = SpotifyClientApiBuilder().apply {
404402
credentials {
405403
this.clientId = clientId
@@ -412,15 +410,13 @@ fun spotifyClientPkceApi(
412410
}
413411
}.apply(block)
414412

415-
416-
417413
/**
418414
* Spotify API builder
419415
*/
420416
class SpotifyApiBuilder(
421-
private var clientId: String?,
422-
private var clientSecret: String?,
423-
private var redirectUri: String?
417+
private var clientId: String?,
418+
private var clientSecret: String?,
419+
private var redirectUri: String?
424420
) {
425421
/**
426422
* Allows you to authenticate a [SpotifyClientApi] with an authorization code
@@ -698,9 +694,9 @@ interface ISpotifyClientApiBuilder : ISpotifyApiBuilder<SpotifyClientApi, Spotif
698694
* [SpotifyClientApi] builder for api creation using client authorization
699695
*/
700696
class SpotifyClientApiBuilder(
701-
override var credentials: SpotifyCredentials = SpotifyCredentialsBuilder().build(),
702-
override var authorization: SpotifyUserAuthorization = SpotifyUserAuthorizationBuilder().build(),
703-
override var options: SpotifyApiOptions = SpotifyApiOptionsBuilder().build()
697+
override var credentials: SpotifyCredentials = SpotifyCredentialsBuilder().build(),
698+
override var authorization: SpotifyUserAuthorization = SpotifyUserAuthorizationBuilder().build(),
699+
override var options: SpotifyApiOptions = SpotifyApiOptionsBuilder().build()
704700
) : ISpotifyClientApiBuilder {
705701
override fun getAuthorizationUrl(vararg scopes: SpotifyScope, state: String?): String {
706702
require(credentials.redirectUri != null && credentials.clientId != null) { "You didn't specify a redirect uri or client id in the credentials block!" }
@@ -718,7 +714,7 @@ class SpotifyClientApiBuilder(
718714
val redirectUri = credentials.redirectUri
719715

720716
// either application credentials, or a token is required
721-
require((clientId != null && clientSecret != null && redirectUri != null) || (clientId != null && redirectUri != null && authorization.pkceCodeVerifier != null) || authorization.token != null || authorization.tokenString != null) { "You need to specify a valid clientId, clientSecret, and redirectUri in the credentials block!" }
717+
require((clientId != null && clientSecret != null && redirectUri != null) || (clientId != null && redirectUri != null && authorization.pkceCodeVerifier != null) || authorization.token != null || authorization.tokenString != null) { "You need to specify a valid clientId, clientSecret, and redirectUri in the credentials block!" }
722718
return when {
723719
authorization.authorizationCode != null && authorization.pkceCodeVerifier == null -> try {
724720
require(clientId != null && clientSecret != null && redirectUri != null) { "You need to specify a valid clientId, clientSecret, and redirectUri in the credentials block!" }
@@ -863,9 +859,9 @@ interface ISpotifyAppApiBuilder : ISpotifyApiBuilder<SpotifyAppApi, SpotifyAppAp
863859
* [SpotifyAppApi] builder for api creation using client authorization
864860
*/
865861
class SpotifyAppApiBuilder(
866-
override var credentials: SpotifyCredentials = SpotifyCredentialsBuilder().build(),
867-
override var authorization: SpotifyUserAuthorization = SpotifyUserAuthorizationBuilder().build(),
868-
override var options: SpotifyApiOptions = SpotifyApiOptionsBuilder().build()
862+
override var credentials: SpotifyCredentials = SpotifyCredentialsBuilder().build(),
863+
override var authorization: SpotifyUserAuthorization = SpotifyUserAuthorizationBuilder().build(),
864+
override var options: SpotifyApiOptions = SpotifyApiOptionsBuilder().build()
869865
) : ISpotifyAppApiBuilder {
870866
/**
871867
* Build a public [SpotifyAppApi] using the provided credentials
@@ -988,11 +984,11 @@ data class SpotifyCredentials(val clientId: String?, val clientSecret: String?,
988984
* limited time constraint on these before the API automatically refreshes them
989985
*/
990986
class SpotifyUserAuthorizationBuilder(
991-
var authorizationCode: String? = null,
992-
var tokenString: String? = null,
993-
var token: Token? = null,
994-
var refreshTokenString: String? = null,
995-
var pkceCodeVerifier: String? = null
987+
var authorizationCode: String? = null,
988+
var tokenString: String? = null,
989+
var token: Token? = null,
990+
var refreshTokenString: String? = null,
991+
var pkceCodeVerifier: String? = null
996992
) {
997993
fun build() = SpotifyUserAuthorization(authorizationCode, tokenString, token, refreshTokenString, pkceCodeVerifier)
998994
}
@@ -1010,11 +1006,11 @@ class SpotifyUserAuthorizationBuilder(
10101006
* @property pkceCodeVerifier The code verifier generated that the client authenticated with (using its code challenge)
10111007
*/
10121008
data class SpotifyUserAuthorization(
1013-
var authorizationCode: String? = null,
1014-
var tokenString: String? = null,
1015-
var token: Token? = null,
1016-
var refreshTokenString: String? = null,
1017-
var pkceCodeVerifier: String? = null
1009+
var authorizationCode: String? = null,
1010+
var tokenString: String? = null,
1011+
var token: Token? = null,
1012+
var refreshTokenString: String? = null,
1013+
var pkceCodeVerifier: String? = null
10181014
)
10191015

10201016
/**
@@ -1035,18 +1031,18 @@ data class SpotifyUserAuthorization(
10351031
*
10361032
*/
10371033
class SpotifyApiOptionsBuilder(
1038-
var useCache: Boolean = true,
1039-
var cacheLimit: Int? = 200,
1040-
var automaticRefresh: Boolean = true,
1041-
var retryWhenRateLimited: Boolean = true,
1042-
var enableLogger: Boolean = true,
1043-
var testTokenValidity: Boolean = false,
1044-
var enableAllOptions: Boolean = false,
1045-
var defaultLimit: Int = 50,
1046-
var allowBulkRequests: Boolean = true,
1047-
var requestTimeoutMillis: Long? = null,
1048-
var json: Json = nonstrictJson,
1049-
var refreshTokenProducer: (suspend (SpotifyApi<*, *>) -> Token)? = null
1034+
var useCache: Boolean = true,
1035+
var cacheLimit: Int? = 200,
1036+
var automaticRefresh: Boolean = true,
1037+
var retryWhenRateLimited: Boolean = true,
1038+
var enableLogger: Boolean = true,
1039+
var testTokenValidity: Boolean = false,
1040+
var enableAllOptions: Boolean = false,
1041+
var defaultLimit: Int = 50,
1042+
var allowBulkRequests: Boolean = true,
1043+
var requestTimeoutMillis: Long? = null,
1044+
var json: Json = nonstrictJson,
1045+
var refreshTokenProducer: (suspend (SpotifyApi<*, *>) -> Token)? = null
10501046
) {
10511047
fun build() =
10521048
if (enableAllOptions)
@@ -1097,17 +1093,17 @@ class SpotifyApiOptionsBuilder(
10971093
*/
10981094

10991095
data class SpotifyApiOptions(
1100-
var useCache: Boolean,
1101-
var cacheLimit: Int?,
1102-
var automaticRefresh: Boolean,
1103-
var retryWhenRateLimited: Boolean,
1104-
var enableLogger: Boolean,
1105-
var testTokenValidity: Boolean,
1106-
var defaultLimit: Int,
1107-
var allowBulkRequests: Boolean,
1108-
var requestTimeoutMillis: Long?,
1109-
var json: Json,
1110-
var refreshTokenProducer: (suspend (SpotifyApi<*, *>) -> Token)?
1096+
var useCache: Boolean,
1097+
var cacheLimit: Int?,
1098+
var automaticRefresh: Boolean,
1099+
var retryWhenRateLimited: Boolean,
1100+
var enableLogger: Boolean,
1101+
var testTokenValidity: Boolean,
1102+
var defaultLimit: Int,
1103+
var allowBulkRequests: Boolean,
1104+
var requestTimeoutMillis: Long?,
1105+
var json: Json,
1106+
var refreshTokenProducer: (suspend (SpotifyApi<*, *>) -> Token)?
11111107
)
11121108

11131109
@Deprecated("Name has been replaced by `options`", ReplaceWith("SpotifyApiOptions"))

0 commit comments

Comments
 (0)