diff --git a/dependencies.gradle b/dependencies.gradle index c56c66a0bd..993a5d760f 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -23,8 +23,8 @@ SOFTWARE. */ ext.sdkVersions = [ - code : '19', - name : '2.4.0', + code : '21', + name : '2.6.0', minSdk : 21, targetSdk : 29, diff --git a/samples/app/sdk/src/.gitignore b/samples/app/sdk/src/.gitignore new file mode 100644 index 0000000000..796b96d1c4 --- /dev/null +++ b/samples/app/sdk/src/.gitignore @@ -0,0 +1 @@ +/build diff --git a/samples/app/sdk/src/build.gradle b/samples/app/sdk/src/build.gradle new file mode 100644 index 0000000000..65f75acc52 --- /dev/null +++ b/samples/app/sdk/src/build.gradle @@ -0,0 +1,66 @@ +/******************************************************************************* + * The MIT License (MIT) + * + * Copyright (c) 2019 vk.com + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + ******************************************************************************/ + +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply from: '../../dependencies.gradle' + +android { + compileSdkVersion "$sdkVersions.compileSdk".toInteger() + buildToolsVersion "$sdkVersions.buildTools" + + defaultConfig { + applicationId = "com.vk.sdk.sample" + minSdkVersion "$sdkVersions.minSdk" + targetSdkVersion "$sdkVersions.targetSdk" + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + lintOptions { + abortOnError true + checkReleaseBuilds true + } + + dexOptions { + preDexLibraries true + javaMaxHeapSize "5g" + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: '*.jar') + implementation sdkLibraries.kotlin + implementation sdkLibrariesSupport.recyclerView + implementation sdkLibrariesSupport.appCompat + implementation (sdkLibraries.picasso) { transitive = false } + implementation sdkLibraries.okHttp + + implementation project(':libapi-sdk-core') + implementation project(':libapi-sdk-api') + //implementation 'com.vk:androidsdk:2.0.0' +} diff --git a/samples/app/sdk/src/main/AndroidManifest.xml b/samples/app/sdk/src/main/AndroidManifest.xml new file mode 100644 index 0000000000..1846374115 --- /dev/null +++ b/samples/app/sdk/src/main/AndroidManifest.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + diff --git a/samples/app/sdk/src/main/java/com/vk/sdk/sample/PathUtils.kt b/samples/app/sdk/src/main/java/com/vk/sdk/sample/PathUtils.kt new file mode 100644 index 0000000000..8233032c4a --- /dev/null +++ b/samples/app/sdk/src/main/java/com/vk/sdk/sample/PathUtils.kt @@ -0,0 +1,43 @@ +/******************************************************************************* + * The MIT License (MIT) + * + * Copyright (c) 2019 vk.com + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + ******************************************************************************/ + +package com.vk.sdk.sample + +import android.content.Context +import android.net.Uri +import android.provider.MediaStore + +object PathUtils { + fun getPath(context: Context, uri: Uri): String { + if (uri.scheme == "file") { + 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) + val columnIndex = cursor!!.getColumnIndexOrThrow(MediaStore.Images.Media.DATA) + cursor.moveToFirst() + return "file://" + cursor.getString(columnIndex) + } +} \ No newline at end of file diff --git a/samples/app/sdk/src/main/java/com/vk/sdk/sample/SampleApplication.kt b/samples/app/sdk/src/main/java/com/vk/sdk/sample/SampleApplication.kt new file mode 100644 index 0000000000..61301210ff --- /dev/null +++ b/samples/app/sdk/src/main/java/com/vk/sdk/sample/SampleApplication.kt @@ -0,0 +1,42 @@ +/******************************************************************************* + * The MIT License (MIT) + * + * Copyright (c) 2019 vk.com + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + ******************************************************************************/ + +package com.vk.sdk.sample + +import android.app.Application +import com.vk.api.sdk.VK +import com.vk.api.sdk.VKTokenExpiredHandler + +class SampleApplication: Application() { + override fun onCreate() { + super.onCreate() + VK.addTokenExpiredHandler(tokenTracker) + } + + private val tokenTracker = object: VKTokenExpiredHandler { + override fun onTokenExpired() { + WelcomeActivity.startFrom(this@SampleApplication) + } + } +} \ No newline at end of file diff --git a/samples/app/sdk/src/main/java/com/vk/sdk/sample/UserActivity.kt b/samples/app/sdk/src/main/java/com/vk/sdk/sample/UserActivity.kt new file mode 100644 index 0000000000..d132bb57d6 --- /dev/null +++ b/samples/app/sdk/src/main/java/com/vk/sdk/sample/UserActivity.kt @@ -0,0 +1,217 @@ +/******************************************************************************* + * The MIT License (MIT) + * + * Copyright (c) 2019 vk.com + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + ******************************************************************************/ + +package com.vk.sdk.sample + +import android.app.Activity +import android.content.Context +import android.content.Intent +import android.net.Uri +import android.os.Bundle +import android.text.TextUtils +import android.util.Log +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.* +import androidx.recyclerview.widget.RecyclerView +import com.squareup.picasso.Picasso +import com.vk.api.sdk.VK +import com.vk.api.sdk.VKApiCallback +import com.vk.sdk.api.friends.dto.FriendsGetFieldsResponseDto +import com.vk.sdk.api.friends.methods.FriendsGetFields +import com.vk.sdk.api.users.dto.UsersFields +import com.vk.sdk.sample.models.VKUser +import com.vk.sdk.sample.requests.VKUsersCommand +import com.vk.sdk.sample.requests.VKWallPostCommand + +class UserActivity: Activity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_user) + + val logoutBtn = findViewById