Skip to content

Commit

Permalink
Prepare for release 0.0.1.
Browse files Browse the repository at this point in the history
  • Loading branch information
petersamokhin committed Apr 27, 2020
0 parents commit 8c47272
Show file tree
Hide file tree
Showing 52 changed files with 2,822 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/docs_prepare.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash
# From: https://github.com/cashapp/sqldelight

# The website is built using MkDocs with the Material theme.
# https://squidfunk.github.io/mkdocs-material/
# It requires Python to run.
# Install the packages with the following command:
# pip install mkdocs mkdocs-material

PROJECT_NAME='VK SDK Android'

# Should be changed after each major and minor release.
# Also, previous docs subdirectory should be added to .gitignore file.
CURRENT_VERSION_DOCS_DIR_PREFIX='0.0'

set -ex

# Generate the API docs
./gradlew dokka

# Dokka filenames like `-http-url/index.md` don't work well with MkDocs <title> tags.
# Assign metadata to the file's first Markdown heading.
# https://www.mkdocs.org/user-guide/writing-your-docs/#meta-data
title_markdown_file() {
TITLE_PATTERN="s/^[#]+ *(.*)/title: \1 - $PROJECT_NAME/"
echo "---" > "$1.fixed"
# shellcheck disable=SC2129
# shellcheck disable=SC2002
cat "$1" | sed -E "$TITLE_PATTERN" | grep "title: " | head -n 1 >> "$1.fixed"
echo "---" >> "$1.fixed"
echo >> "$1.fixed"
cat "$1" >> "$1.fixed"
mv "$1.fixed" "$1"
}

set +x
# shellcheck disable=SC2044
for MARKDOWN_FILE in $(find docs/$CURRENT_VERSION_DOCS_DIR_PREFIX.x -name '*.md'); do
echo "$MARKDOWN_FILE"
title_markdown_file "$MARKDOWN_FILE"
done
set -x

# Copy in special files that GitHub wants in the project root.
cp README.md docs/index.md
cp auth/CHANGELOG.md docs/changelog-auth.md

# Project README.md is also used as the main page for the docs,
# but all links are relative, so we must fix it when copying
sed -i -e 's+docs/images+images+g' docs/index.md
25 changes: 25 additions & 0 deletions .github/workflows/docs_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Documentation

on:
push:
branches:
- master

jobs:
deploy-website:
runs-on: ubuntu-latest

steps:
- name: Checkout the repo
uses: actions/checkout@v2

- name: Prepare mkdocs
run: .github/workflows/docs_prepare.sh

- name: Deploy documentation
uses: mhausenblas/mkdocs-deploy-gh-pages@master
env:
PERSONAL_TOKEN: ${{ secrets.PERSONAL_TOKEN }}

env:
GRADLE_OPTS: -Dorg.gradle.configureondemand=true -Dorg.gradle.parallel=true -Dkotlin.incremental=false -Dorg.gradle.jvmargs="-Xmx3g -XX:MaxPermSize=2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8"
24 changes: 24 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Release

on:
push:
tags:
- '*'

jobs:
macos-build:
runs-on: ubuntu-latest

steps:
- name: Checkout the repo
uses: actions/checkout@v2
- name: Publish the artifacts for Android
env:
ORG_GRADLE_PROJECT_SONATYPE_NEXUS_USERNAME: ${{ secrets.ORG_GRADLE_PROJECT_SONATYPE_NEXUS_USERNAME }}
ORG_GRADLE_PROJECT_SONATYPE_NEXUS_PASSWORD: ${{ secrets.ORG_GRADLE_PROJECT_SONATYPE_NEXUS_PASSWORD }}
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.ORG_GRADLE_PROJECT_signingKey }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.ORG_GRADLE_PROJECT_signingPassword }}
run: ./gradlew uploadArchives --no-daemon

env:
GRADLE_OPTS: -Dorg.gradle.configureondemand=true -Dorg.gradle.parallel=false -Dkotlin.incremental=false -Dorg.gradle.jvmargs="-Xmx3g -XX:MaxPermSize=2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8"
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# ItelliJ, Gradle
build
.gradle
.idea
*.iml
local.properties

# MacOS
.DS_Store

# Docs
/docs/0.0.x
/docs/index.md
/docs/changelog-auth.md
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Peter Samokhin

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.
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# VK SDK Android
![cover](docs/images/android_cover.png)

<p align="center">Some Android-specific features built into Unofficial VK SDK for Android</p>

---

![Build](https://github.com/vksdk/vk-sdk-android/workflows/Release/badge.svg) ![Documentation](https://github.com/vksdk/vk-sdk-android/workflows/Documentation/badge.svg) [![Kotlin 1.3.72](https://img.shields.io/badge/Kotlin-1.3.72-blue.svg?style=flat)](http://kotlinlang.org) [![API version](https://img.shields.io/badge/API%20version-5.103-blue?style=flat&logo=vk&logoColor=white)](https://vk.com/dev/versions)
[![GitHub license](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat)](https://github.com/vksdk/vk-sdk-android/blob/master/LICENSE)

The official VK Android SDK is monstrous, has poor API, does not contain some important features and their code leaves much to be desired.
This is the reason why this SDK is created.
See the available features below.

See the documentation: [https://vksdk.github.io/vk-sdk-android](https://vksdk.github.io/vk-sdk-android)

Latest versions: [![maven-central](https://img.shields.io/badge/Maven%20Central-0.0.1-yellowgreen?style=flat)](https://search.maven.org/search?q=g:com.petersamokhin.vksdk.android)

## Authorize
[![Android minSdkVersion](https://img.shields.io/badge/minSdkVersion-16-yellowgreen)](https://img.shields.io/badge/minSdkVersion-16-yellowgreen) [![Android targetSdkVersion](https://img.shields.io/badge/targetSdkVersion-29-green)](https://img.shields.io/badge/targetSdkVersion-29-green)

[Authorization code flow](https://vk.com/dev/authcode_flow_user) is not supported by the official VK SDK and by the official app.
But it is supported by this auth feature.

Easiest way to authorize user with VK and get the token:

```kotlin
// From here: https://vk.com/apps?act=manage
// Choose the app and get the ID from here: https://vk.com/editapp?id=XXX
// Or go here: https://vk.com/editapp?id=XXX&section=options and see the App ID
val appId = 1
val scopes = listOf(VkAuth.Scope.Offline, VkAuth.Scope.Email)

VkAuth.login(activity, appId, VkAuth.ResponseType.AccessToken, scopes) { result ->
when (result) {
is VkAuthResult.AccessToken -> {
// do something with result.accessToken
}
is VkAuthResult.Error -> {
// do something with result.error
}
}
}
```

For other information and for details, see the documentation: [https://vksdk.github.io/vk-sdk-android/auth/](https://vksdk.github.io/vk-sdk-android/auth/)

## License
See the [License](https://github.com/vksdk/vk-sdk-android/blob/master/LICENSE)
13 changes: 13 additions & 0 deletions RELEASING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Releasing

1. Change the version in `gradle.properties` to a non-SNAPSHOT verson.
2. Update the `CHANGELOG.md` for the impending release.
3. Update the `README.md` with the new version.
4. `git commit -am "Prepare for release X.Y.Z."` (where X.Y.Z is the new version)
5. `git tag -a X.Y.Z -m "Version X.Y.Z"` (where X.Y.Z is the new version)
6. Update the `gradle.properties` to the next SNAPSHOT version.
7. `git push && git push --tags`
8. Wait until the "Publish a release" action completes, then visit [Sonatype Nexus](https://oss.sonatype.org/) and promote the artifacts.
9. Update the sample app to the release version and send a PR.

If some step fails, drop the Sonatype repo, fix the problem, commit, and start again at step 5.
6 changes: 6 additions & 0 deletions auth/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Change log

Version 0.0.1 *(2020-04-27)*
----------------------------

First release.
61 changes: 61 additions & 0 deletions auth/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
plugins {
id("com.android.library")
kotlin("android")
kotlin("android.extensions")
id("kotlin-android")
id("kotlin-android-extensions")
}

android {
compileSdkVersion(Config.Android.compileSdk)
defaultConfig {
minSdkVersion(Config.Android.minSdk)
targetSdkVersion(Config.Android.compileSdk)
buildToolsVersion(Config.Android.buildToolsVersion)
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

// applicationId = "${project.property("GROUP").toString()}.auth"
versionCode = 1
versionName = "0.0.1"
}
buildTypes {
getByName("release") {
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
consumerProguardFile("consumer-rules.pro")
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}
sourceSets {
val main by getting {}
val test by getting {}
val androidTest by getting {}
main.java.srcDirs("src/main/kotlin")
test.java.srcDirs("src/test/kotlin")
androidTest.java.srcDirs("src/androidTest/kotlin")
}
}

dependencies {
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
implementation(kotlin("stdlib-jdk8", Config.Versions.Kotlin.kotlin))

implementation("androidx.appcompat:appcompat:${Config.Versions.Android.appCompat}")
implementation("androidx.core:core-ktx:${Config.Versions.Android.coreKtx}")
implementation("androidx.constraintlayout:constraintlayout:${Config.Versions.Android.constraintLayout}")

testImplementation("junit:junit:${Config.Versions.Test.junit}")

androidTestImplementation("androidx.test:runner:${Config.Versions.AndroidTest.runner}")
androidTestImplementation("androidx.test.ext:junit:${Config.Versions.AndroidTest.extJunit}")
androidTestImplementation("androidx.test.espresso:espresso-core:${Config.Versions.AndroidTest.espressoCore}")
androidTestImplementation("org.mockito:mockito-android:${Config.Versions.Test.mockito}")
}

apply(from = "$rootDir/gradle/mavenpublish.gradle")
7 changes: 7 additions & 0 deletions auth/consumer-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-keep class com.petersamokhin.vksdk.android.auth.VkAuth$** { *; }
-keep class com.petersamokhin.vksdk.android.model.* { *; }
-keep class com.petersamokhin.vksdk.android.error.* { *; }

-keepnames @kotlin.Metadata class com.petersamokhin.vksdk.android.auth.VkAuth$**
-keepnames @kotlin.Metadata class com.petersamokhin.vksdk.android.model.*
-keepnames @kotlin.Metadata class com.petersamokhin.vksdk.android.error.*
3 changes: 3 additions & 0 deletions auth/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
POM_ARTIFACT_ID=auth
POM_NAME=VK SDK Android Auth
POM_DESCRIPTION=VK SDK Android, module Auth
21 changes: 21 additions & 0 deletions auth/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.petersamokhin.vksdk.android.auth

import org.junit.Assert.*
import org.junit.Test

class VkAuthParamsInstrumentationTest {
@Test
fun shouldCorrectlyBuildBundle() {
val params = VkAuth.AuthParams(
1, VkAuth.ResponseType.AccessToken, "https://oauth.vk.com/blank.html", "offline"
)
val bundle = params.asBundle(false)

assertEquals(params.clientId, bundle.getInt("client_id"))
assertEquals(params.redirectUri, bundle.getString("redirect_uri"))
assertEquals(params.scope, bundle.getString("scope"))
assertEquals(params.revoke, bundle.getBoolean("revoke"))
}

@Test
fun shouldCorrectlyBuildBundleWithIgnored() {
val params = VkAuth.AuthParams(
1, VkAuth.ResponseType.AccessToken, "https://oauth.vk.com/blank.html", "offline"
)
val bundle = params.asBundle(true)

assertEquals(params.clientId, bundle.getInt("client_id"))
assertEquals(params.redirectUri, bundle.getString("redirect_uri"))
assertEquals(params.scope, bundle.getString("scope"))
assertEquals(params.revoke, bundle.getBoolean("revoke"))
assertEquals(params.responseType.stringValue, bundle.getString("response_type"))
assertEquals(params.display.stringValue, bundle.getString("display"))
assertEquals(params.state, bundle.getString("state"))
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.petersamokhin.vksdk.android.auth.activity

import android.app.Activity
import com.petersamokhin.vksdk.android.auth.VkAuth
import org.junit.Test
import org.junit.Assert.*
import org.mockito.Mockito.mock

class VkAuthActivityTest {
@Test
fun intent() {
val activity = mock(Activity::class.java)
val params = VkAuth.AuthParams(
1, VkAuth.ResponseType.AccessToken, "https://oauth.vk.com/blank.html", "offline"
)
val intent = VkAuthActivity.intent(activity, params)

assertEquals(params.asQuery(), intent.getStringExtra(VkAuthActivity.EXTRA_AUTH_QUERY))
assertEquals(params.redirectUri, intent.getStringExtra(VkAuthActivity.EXTRA_AUTH_REDIRECT_URI))
}
}
Loading

0 comments on commit 8c47272

Please sign in to comment.