Skip to content

Commit

Permalink
version: 2.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleg Smirnov committed Dec 22, 2019
1 parent 6faddf9 commit 9721030
Show file tree
Hide file tree
Showing 14 changed files with 44 additions and 29 deletions.
10 changes: 5 additions & 5 deletions dependencies.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
ext.sdkVersions = [
code : '14',
name : '2.2.0',
code : '15',
name : '2.2.1',

minSdk : 16,
targetSdk : 28,
compileSdk : '28',
buildTools : '28.0.3',
compileSdk : '29',
buildTools : '29.0.2',

kotlin : '1.3.41',
kotlin : '1.3.61',
androidX : '1.0.0',
okHttp : '3.12.1',

Expand Down
3 changes: 2 additions & 1 deletion samples/app/src/main/java/com/vk/sdk/sample/PathUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ import android.provider.MediaStore
object PathUtils {
fun getPath(context: Context, uri: Uri): String {
if (uri.scheme == "file") {
return uri.path
if (uri.path != null) return uri.path!!
return ""
}
val proj = arrayOf(MediaStore.Images.Media.DATA)
val cursor = context.contentResolver.query(uri, proj, null, null, null)
Expand Down
4 changes: 2 additions & 2 deletions samples/app/src/main/java/com/vk/sdk/sample/UserActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ class UserActivity: Activity() {
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == IMAGE_REQ_CODE) {
if (resultCode == RESULT_OK && data != null) {
sharePost(Uri.parse(PathUtils.getPath(this, data.data)))
if (resultCode == RESULT_OK && data != null && data.data != null) {
sharePost(Uri.parse(PathUtils.getPath(this, data.data!!)))
} else {
sharePost()
}
Expand Down
6 changes: 3 additions & 3 deletions samples/app/src/main/java/com/vk/sdk/sample/models/VKUser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ data class VKUser(

constructor(parcel: Parcel) : this(
parcel.readInt(),
parcel.readString(),
parcel.readString(),
parcel.readString(),
parcel.readString()!!,
parcel.readString()!!,
parcel.readString()!!,
parcel.readByte() != 0.toByte())

override fun writeToParcel(parcel: Parcel, flags: Int) {
Expand Down
4 changes: 4 additions & 0 deletions vk-sdk-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply from: '../dependencies.gradle'

ext.POM_GROUP_ID = "com.vk"
ext.POM_ARTIFACT_ID = sdkPublish.POM_ARTIFACT_ID
ext.POM_VERSION = sdkVersions.name

android {
compileSdkVersion "$sdkVersions.compileSdk".toInteger()
buildToolsVersion "$sdkVersions.buildTools"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ interface VKApiValidationHandler {
}
}
class Credentials(val secret: String?, val token: String?, val uid: Int?) {
val isValid = !(token.isNullOrBlank() || secret.isNullOrEmpty())
val isValid = !token.isNullOrBlank()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class VKAccessToken(params: Map<String, String?>) {
Pair(SECRET, secret),
Pair(HTTPS_REQUIRED, "1")))

val userId: Int?
val userId: Int
val accessToken: String
val secret: String?
val created: Long
Expand All @@ -48,7 +48,7 @@ class VKAccessToken(params: Map<String, String?>) {
get() = expirationDate <= 0 || created + expirationDate * 1000 > System.currentTimeMillis()

init {
this.userId = params[USER_ID]?.toIntOrNull()
this.userId = params[USER_ID]?.toInt()!!
this.accessToken = params[ACCESS_TOKEN]!!
this.secret = params[SECRET]
this.httpsRequired = "1" == params[HTTPS_REQUIRED]
Expand Down Expand Up @@ -84,7 +84,7 @@ class VKAccessToken(params: Map<String, String?>) {
result[HTTPS_REQUIRED] = if (httpsRequired) "1" else "0"
result[CREATED] = created.toString()
result[EXPIRES_IN] = expirationDate.toString()
result[USER_ID] = userId?.toString()
result[USER_ID] = userId.toString()
result[EMAIL] = email
result[PHONE] = phone
result[PHONE_ACCESS_KEY] = phoneAccessKey
Expand Down
10 changes: 9 additions & 1 deletion vk-sdk-core/src/main/java/com/vk/api/sdk/auth/VKAuthManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import android.app.Activity
import android.content.Context
import android.content.Intent
import android.content.SharedPreferences
import android.util.Log
import com.vk.api.sdk.VK
import com.vk.api.sdk.ui.VKWebViewAuthActivity
import com.vk.api.sdk.utils.VKUtils
Expand Down Expand Up @@ -105,7 +106,14 @@ internal class VKAuthManager {
else -> return null
}

return if (tokenParams != null && tokenParams[VK_AUTH_ERROR] == null) VKAuthResult(VKAccessToken(tokenParams)) else null
return if (tokenParams != null && tokenParams[VK_AUTH_ERROR] == null) {
try {
VKAuthResult(VKAccessToken(tokenParams))
} catch (e: Exception) {
Log.e(VKAuthManager::class.java.simpleName, "Failed to get VK token", e)
null
}
} else null
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ object VKApiCodes {
const val CODE_ACCESS_POLLS_WITHOUT_VOTE = 253
const val CODE_PHOTO_ALBUM_LIMIT_EXCEED = 300
const val CODE_OPERATION_NOT_PERMITTED = 500
const val CODE_NOT_ENOUGH_MONEY_ON_OWNER_BALANCE = 504
const val CODE_ADVERTISE_CABINET_NO_PERMISSIONS_FOR_OPERATION = 600
const val CODE_ADVERTISE_CABINET_ERROR = 603
const val CODE_VIDEO_ALREADY_ADDED = 800
Expand Down Expand Up @@ -94,6 +95,7 @@ object VKApiCodes {
const val CODE_INVALID_SID = 1113
const val CODE_SIGN_UP_CODE_INCORRECT = 1110
const val CODE_SIGN_UP_PASSWORD_UNALLOWABLE = 1111
const val CODE_STICKERS_DISABLED = 1191

const val CODE_ACCOUNT_INVALID_SCREEN_NAME = 1260

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ import com.vk.api.sdk.VK
class VKInitProvider: ContentProvider() {
override fun onCreate(): Boolean {
try {
VK.initialize(context)
VK.initialize(context!!)
} catch (e: Exception) {
Log.e(VKInitProvider::class.java.simpleName, "Failed to initialize the VK SDK", e)
}
return false
}

override fun insert(uri: Uri?, p1: ContentValues?): Uri? = null
override fun insert(uri: Uri, p1: ContentValues?): Uri? = null

override fun query(uri: Uri?, p1: Array<out String>?, p2: String?, p3: Array<out String>?, p4: String?): Cursor? = null
override fun query(uri: Uri, p1: Array<out String>?, p2: String?, p3: Array<out String>?, p4: String?): Cursor? = null

override fun update(uri: Uri?, p1: ContentValues?, p2: String?, p3: Array<out String>?): Int = 0
override fun update(uri: Uri, p1: ContentValues?, p2: String?, p3: Array<out String>?): Int = 0

override fun delete(uri: Uri?, p1: String?, p2: Array<out String>?): Int = 0
override fun delete(uri: Uri, p1: String?, p2: Array<out String>?): Int = 0

override fun getType(uri: Uri?): String? = null
override fun getType(uri: Uri): String? = null
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,10 @@ import okhttp3.MediaType
import okhttp3.RequestBody
import okio.BufferedSink

internal class FileFullRequestBody(private val context: Context?, private val fileUri: Uri?) : RequestBody() {
internal class FileFullRequestBody(private val context: Context?, private val fileUri: Uri) : RequestBody() {

init {
if (context == null) {
throw IllegalArgumentException("context is null")
}
requireNotNull(context) { "context is null" }
if (fileUri == null) {
throw IllegalArgumentException("fileUri is null")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ open class VKWebViewAuthActivity: Activity() {
if (uri.getQueryParameter("success") != null) {
val token = uri.getQueryParameter("access_token")
val secret = uri.getQueryParameter("secret")
val userId = uri.getQueryParameter("user_id").toInt()
val userId = uri.getQueryParameter("user_id")?.toInt()
validationResult = VKApiValidationHandler.Credentials(secret, token, userId)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ internal class ThreadLocalDelegateImpl<T>(val factory: () -> T) : ThreadLocalDel
}

override fun get(): T {
return value.get()
return value.get()!!
}
}

Expand Down
4 changes: 3 additions & 1 deletion vk-sdk-core/src/main/java/com/vk/api/sdk/utils/VKUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ object VKUtils {

for (keyValueString in keyValuePairs) {
val keyValueArray = keyValueString.split("=")
parameters[keyValueArray[0]] = keyValueArray[1]
if (keyValueArray.size > 1) {
parameters[keyValueArray[0]] = keyValueArray[1]
}
}
return parameters
}
Expand Down

0 comments on commit 9721030

Please sign in to comment.