Skip to content

Commit

Permalink
version 3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleg Smirnov committed Apr 16, 2021
1 parent 32898fa commit 9417300
Show file tree
Hide file tree
Showing 808 changed files with 39,816 additions and 10,310 deletions.
38 changes: 22 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
VK SDK for Android
==========

[![Maven Central](https://img.shields.io/maven-central/v/com.vk/androidsdk.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22com.vk%22%20AND%20a:%22androidsdk%22)
[![Maven Central](https://img.shields.io/maven-central/v/com.vk/android-sdk-core.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22com.vk%22%20AND%20a:%22android-sdk-core%22)

Library for working with VK API, authorization through VK app, using VK functions. Minimal version of Android is 5.0

Expand Down Expand Up @@ -52,23 +52,27 @@ Connecting VK SDK to Your Android Application

Connecting With Maven
----------
[![Core Release](https://img.shields.io/maven-central/v/com.vk/android-sdk-core.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22com.vk%22%20AND%20a:%22android-sdk-core%22)


You can add next maven dependency in your project:

You may also need to add the following to your `project/build.gradle` file.
The available library modules are listed below.

* `android-sdk-core`: Core functionality (required).
* `android-sdk-api` : Api generated models and methods.

`implementation 'com.vk:androidsdk:2.4.0`
* `androidsdk`: deprecated copy version of the android-sdk-core(will be removed in future releases).
* `androidsdkapi` : deprecated copy version of the android-sdk-api(will be removed in future releases).

For example, your `app/build.gradle` script will contains such dependencies:
```
dependencies {
implementation 'com.vk:androidsdk:2.4.0
implementation 'com.vk:android-sdk-core:3.0.0
implementation 'com.vk:android-sdk-api:3.0.0 // generated models and api methods
}
```

Older version
----------
Older version of sdk can be found **[here](https://github.com/VKCOM/vk-android-sdk/releases/tag/1.6.7)**

Using SDK
==========

Expand Down Expand Up @@ -136,18 +140,20 @@ class SampleApplication: Application() {
API Requests
==========

Run request with VK.execute:

Run request with VK.execute and auto generated methods(android-sdk-api dependency is required):

```kotlin
VK.execute(UsersGet(), object: VKApiCallback<List<UsersUserXtrCounters>> {
override fun success(result: List<UsersUserXtrCounters>) {
}
override fun fail(error: VKApiExecutionException) {
}
})
VK.execute(FriendsService().friendsGet(fields = fields), object: VKApiCallback<FriendsGetFieldsResponse> {
override fun success(result: FriendsGetFieldsResponse) {
// you stuff is here
}
override fun fail(error: Exception) {
Log.e(TAG, error.toString())
}
})
```


If you are using RxJava in your project, you can do something like this:

```kotlin
Expand Down
9 changes: 7 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,14 @@ apply from: 'dependencies.gradle'
subprojects { Project subproject ->
buildscript {
repositories {
jcenter {
content {
includeModule("com.jfrog.bintray.gradle", "gradle-bintray-plugin")
includeModule("org.codehaus.groovy.modules.http-builder", "http-builder")
}
}
google()
mavenCentral()
jcenter()
maven { url 'https://maven.google.com' }
}

Expand All @@ -42,7 +47,7 @@ subprojects { Project subproject ->

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

Expand Down
12 changes: 8 additions & 4 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ SOFTWARE.
*/

ext.sdkVersions = [
code : '21',
name : '2.6.0',
code : '23',
name : '3.0.0',

minSdk : 21,
targetSdk : 29,
Expand Down Expand Up @@ -68,17 +68,21 @@ ext.testLibraries = [
ext.sdkGradlePlugins = [
android : "com.android.tools.build:gradle:$sdkVersions.androidGradlePlugin",
kotlinGradle : "org.jetbrains.kotlin:kotlin-gradle-plugin:$sdkVersions.kotlin",
bintryRelease : "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4",
bintryRelease : "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5",
]

ext.sdkPublish = [
POM_NAME : "VK API library",
POM_ARTIFACT_ID : 'androidsdk',
POM_ARTIFACT_ID : 'android-sdk-core',
POM_DESCRIPTION : 'Main VK Android API library',
POM_URL : 'https://github.com/VKCOM/vk-android-sdk',
POM_SCM_URL : 'https://github.com/VKCOM/vk-android-sdk',
POM_SCM_CONNECTION : 'scm:git:git://github.com/VKCOM/vk-android-sdk.git',
POM_SCM_DEV_CONNECTION : 'scm:git:git://github.com/VKCOM/vk-android-sdk.git',
POM_LICENCE_URL : 'https://github.com/VKCOM/vk-android-sdk/raw/master/LICENSE',

POM_API_NAME : 'VK API Models library',
POM_API_ARTIFACT_ID : 'android-sdk-api',
POM_API_DESCRIPTION : 'VK Android API generated library',
]

9 changes: 6 additions & 3 deletions publish.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
* SOFTWARE.
******************************************************************************/

apply from: '../dependencies.gradle'

static def getRepoUrl() {
return "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
}
Expand All @@ -35,6 +33,11 @@ static def getRepoPassword() {
return System.getenv('NEXUS_PASSWORD')
}

def getArtifactId() {
def envArtifactId = System.getenv('POM_ARTIFACT_ID')
return envArtifactId != null ? envArtifactId : sdkPublish.POM_ARTIFACT_ID
}

if (System.getenv('SDK_UPDATE') == "1") {
apply plugin: 'com.jfrog.bintray'
apply plugin: 'maven-publish'
Expand All @@ -50,7 +53,7 @@ if (System.getenv('SDK_UPDATE') == "1") {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }

pom.artifactId = sdkPublish.POM_ARTIFACT_ID
pom.artifactId = getArtifactId()

repository(url: sonatypeRepositoryUrl) {
authentication(userName: getRepoUsername(), password: getRepoPassword())
Expand Down
1 change: 1 addition & 0 deletions samples/app/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/build
notTranslatedStrings/
2 changes: 0 additions & 2 deletions samples/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ android {
}

dependencies {
implementation fileTree(dir: 'libs', include: '*.jar')
implementation sdkLibraries.kotlin
implementation sdkLibrariesSupport.recyclerView
implementation sdkLibrariesSupport.appCompat
Expand All @@ -62,5 +61,4 @@ dependencies {

implementation project(':libapi-sdk-core')
implementation project(':libapi-sdk-api')
//implementation 'com.vk:androidsdk:2.0.0'
}
2 changes: 1 addition & 1 deletion samples/app/sdk/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<resources>
<string name="login">Войти</string>
<string name="logout">Выйти</string>
<string name="share_to_wall">Post on wall</string>
<string name="share_to_wall">Отправить на стену</string>
<string name="message_hint">Ваше сообщение</string>
<string name="wall_ok">Posted</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ package com.vk.sdk.sample

import android.app.Application
import com.vk.api.sdk.VK
import com.vk.api.sdk.VKApiConfig
import com.vk.api.sdk.VKTokenExpiredHandler

class SampleApplication: Application() {
Expand Down
8 changes: 4 additions & 4 deletions samples/app/src/main/java/com/vk/sdk/sample/UserActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ 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.friends.FriendsService
import com.vk.sdk.api.friends.dto.FriendsGetFieldsResponse
import com.vk.sdk.api.users.dto.UsersFields
import com.vk.sdk.sample.models.VKUser
import com.vk.sdk.sample.requests.VKUsersCommand
Expand Down Expand Up @@ -96,8 +96,8 @@ class UserActivity: Activity() {

private fun requestFriends() {
val fields = listOf(UsersFields.PHOTO_200)
VK.execute(FriendsGetFields(fields = fields), object: VKApiCallback<FriendsGetFieldsResponseDto> {
override fun success(result: FriendsGetFieldsResponseDto) {
VK.execute(FriendsService().friendsGet(fields = fields), object: VKApiCallback<FriendsGetFieldsResponse> {
override fun success(result: FriendsGetFieldsResponse) {
val friends = result.items
if (!isFinishing && friends.isNotEmpty()) {
val vkUsers = friends.map { friend ->
Expand Down
8 changes: 8 additions & 0 deletions samples/app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="login">Войти</string>
<string name="logout">Выйти</string>
<string name="share_to_wall">Отправить на стену</string>
<string name="message_hint">Ваше сообщение</string>
<string name="wall_ok">Запись опубликована</string>
</resources>
8 changes: 8 additions & 0 deletions samples/app/src/main/res/values-kk/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="login">Войти</string>
<string name="logout">Выйти</string>
<string name="share_to_wall">Отправить на стену</string>
<string name="message_hint">Ваше сообщение</string>
<string name="wall_ok">Запись опубликована</string>
</resources>
8 changes: 8 additions & 0 deletions samples/app/src/main/res/values-pt/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="login">Войти</string>
<string name="logout">Выйти</string>
<string name="share_to_wall">Отправить на стену</string>
<string name="message_hint">Ваше сообщение</string>
<string name="wall_ok">Запись опубликована</string>
</resources>
1 change: 1 addition & 0 deletions samples/app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
<string name="share_to_wall">Отправить на стену</string>
<string name="message_hint">Ваше сообщение</string>
<string name="wall_ok">Запись опубликована</string>
<string name="app_name" translatable="false">VK SDK sample</string>
</resources>
8 changes: 8 additions & 0 deletions samples/app/src/main/res/values-uk/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="login">Войти</string>
<string name="logout">Выйти</string>
<string name="share_to_wall">Отправить на стену</string>
<string name="message_hint">Ваше сообщение</string>
<string name="wall_ok">Запись опубликована</string>
</resources>
4 changes: 4 additions & 0 deletions samples/app/src/main/res/values/integers.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<integer name="com_vk_sdk_AppId">0</integer> //put your app id here
</resources>
13 changes: 5 additions & 8 deletions samples/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name" translatable="false">VK SDK sample</string>
<string name="login">Login</string>
<string name="logout">Logout</string>
<string name="share_to_wall">Send to my wall</string>
<string name="message_hint">Your message</string>
<string name="wall_ok">Post has been published</string>

<integer name="com_vk_sdk_AppId">6681226</integer>
<string name="login">Войти</string>
<string name="logout">Выйти</string>
<string name="share_to_wall">Отправить на стену</string>
<string name="message_hint">Ваше сообщение</string>
<string name="wall_ok">Запись опубликована</string>
</resources>
12 changes: 2 additions & 10 deletions vk-sdk-api/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
VK SDK api for Android
VK SDK generated api for Android
==========

Current version is 5.126

there are 3 packages now

dto - all needed dto objects
responses - all possible responses object
methods - all methods except: newsfeed.get, newsfeed.getRecommended, newfeed.getComments, users.getSubscriptions, newsfeed.getSuggestedSources

It will be handled in future releases
Current generated version is 5.130
13 changes: 13 additions & 0 deletions vk-sdk-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply from: "../dependencies.gradle"

version = sdkVersions.name
group = 'com.vk'
sdkPublish.POM_ARTIFACT_ID = sdkPublish.POM_API_ARTIFACT_ID
sdkPublish.POM_NAME = sdkPublish.POM_API_NAME
sdkPublish.POM_DESCRIPTION = sdkPublish.POM_API_DESCRIPTION

android {
compileSdkVersion "$sdkVersions.compileSdk".toInteger()
buildToolsVersion "$sdkVersions.buildTools"
Expand All @@ -24,9 +30,16 @@ android {
}
}

configurations {
// Used for correct javadoc generation
javadocDeps
}

dependencies {
implementation project(':libapi-sdk-core')

implementation sdkLibraries.kotlin
implementation sdkLibraries.gson
}

apply from: "../publish.gradle"
34 changes: 34 additions & 0 deletions vk-sdk-api/src/main/java/com/vk/sdk/api/ApiResponseParser.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* 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.
*/
// *********************************************************************
// THIS FILE IS AUTO GENERATED!
// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING.
// *********************************************************************
package com.vk.sdk.api

import com.google.gson.JsonElement

internal fun interface ApiResponseParser<T> {
fun parseResponse(json: JsonElement): T
}
Loading

0 comments on commit 9417300

Please sign in to comment.