diff --git a/README.md b/README.md index e77f646..8726748 100644 --- a/README.md +++ b/README.md @@ -1,305 +1,295 @@ -ASNETutorial +ASNETutorial [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-ASNETutorial-brightgreen.svg?style=flat)](https://android-arsenal.com/details/3/921) [![Habrahabr](https://img.shields.io/badge/Habrahabr-article-99CCCC.svg?style=flat)](http://habrahabr.ru/post/237095/) ============ -Simple example project for https://github.com/gorbin/ASNE library +Пример применения библиотеки [ASNE](https://github.com/gorbin/ASNE) -Today social network integration to your android application is common practice - it makes user easily login to your app and share their actions. There are a lot of way to do it - usually developers add native social network SDK or use API for every network. It provides login via installed social network application or native dialogs. You have to spend time and nerves to learn and use different social network SDKs. +В данной статье я покажу как можно легко добавить поддержку VK и Odnoklassniki в андроид приложении, используя соответсвующие [модули ASNE](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.github.asne%22). Это упрощенный пример, включающий добавления логина, шаринга ссылки и вывода списка друзей. -What if you need to add one more social network for your application? Sometimes you have to reorganize or redo all your integrations. This leads to idea to create and implement common interface for all social networks. Fortunately there is an open source modular library [ASNE](https://github.com/gorbin/ASNE) that allows you to choose necessary social network and provides full sdk and common interface for most oftenly used requests(login, share, friendslist & etc) It saves your time and simplifies adding another networks in the future. Moreover you can easily add any other social network as new module - the similar way as it done in other modules. +##Регистрация приложения в социальной сети +Для добавления социальной сети в ваше приложение потребуется ключ для совершения запросов. Поэтому первым шагом необходимо зарегистрировать приложение - по ссылкам вы увидите краткое руководство по созданию приложения для -In this tutorial you can learn how easily integrate Facebook, Twitter in android application using [ASNE modules](https://github.com/gorbin/ASNE). This is very basic tutorial with login, share link and showing friends list. - - -##Registering app - getting keys for your application -In order to implement Social networks in your application you need keys to make API calls. So register a new social network application and get the keys. Check small tutorial how to get it: + - [VK](https://github.com/gorbin/ASNE/wiki/Create-Vkontakte-App) + - [Odnoklassniki](https://github.com/gorbin/ASNE/wiki/Create-Odnoklassniki-App) - - [Facebook](https://github.com/gorbin/ASNE/wiki/Create-Facebook-App) - - [Twitter](https://github.com/gorbin/ASNE/wiki/Create-Twitter-App) - - [LInkedIn](https://github.com/gorbin/ASNE/wiki/Create-LinkedIn-App) +для продолжения вам необходимы ключи, которые используются в SDK социальных сетей +- VK App ID +- Ok App ID +- Ok публичный ключ +- Ok секретный ключ -To continue you need -- Facebook App ID -- Twitter consumer key and consumer secret -- LinkedIn consumer key and consumer secret -##Integrating Facebook, Twitter and LinkedIn to your application +##Интеграция ВК и Одноклассники в приложение -1. Create new Project in Android Studio -2. Let's save our social network keys in `values/strings.xml` +1. Создайте новый проект +2. Сохраните ключи в `values/strings.xml` - **strings.xml**(full [source](https://github.com/gorbin/ASNETutorial/blob/master/app/src/main/res/values/strings.xml)) + **strings.xml**([source](https://github.com/gorbin/ASNETutorial/blob/ru/app/src/main/res/values/strings.xml)) ```xml ASNE-tutorial - - 1646388738920557 - - - BBQAUAVKYzmYtvEcNhUEvGiKd - - byZzHPxE1tkGmnPEj5zUyc7MG464Q1LgNRcwbBJV1Ap86575os - - - 75ubsp337ll7sf - - - 8DVk4hi3wvEyzjbh - + 4542602 + + 1096125440 + CBANIGFCEBABABABA + FF5161844C04525B64FA41A7 ``` -3. Add permissions and meta data - open `AndroidManifest.xml` file and add uses-permission for INTERNET, ACCESS_NETWORK_STATE and add meta-data for facebook(add appId key) +3. Добавим разрешения и активити для интегарции с Одноклассниками - откроем `AndroidManifest.xml` и добавим uses-permission - INTERNET, ACCESS_NETWORK_STATE и добавим ru.ok.android.sdk.OkAuthActivity - **AndroidManifest.xml**(full [source](https://github.com/gorbin/ASNETutorial/blob/master/app/src/main/AndroidManifest.xml)) + **AndroidManifest.xml**([код](https://github.com/gorbin/ASNETutorial/blob/ru/app/src/main/AndroidManifest.xml)) ```xml - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + ``` -4. Set dependecies for [asne-modules](https://github.com/gorbin/ASNE): +4. Добавим зависимости для [модулей ASNE](https://github.com/gorbin/ASNE): - Open _Project Structure_ => choose your module and open _Dependecies_ => _Add new library dependency_ + Например в Android Studio Откойте _Project Structure_ => выберите модуль приложения и откройте _Dependencies_ => _Add new library dependency_ ![add library dependecy](http://i.imgur.com/4k62Ux1.png) - Then search for `asne` and add **asne-facebook, asne-twitter, asne-linkedin** + Затем по запросу `asne` вы увидите все модули доступные в библиотеке и добавьте в зависимость **asne-vk, asne-odnoklassniki** ![search asne](http://i.imgur.com/gYou0Uf.png) - or just add them manualy to `build.gradle` + либо вручную добавьте зависимоси в `build.gradle` - **build.gradle**(full [source](https://github.com/gorbin/ASNETutorial/blob/master/app/build.gradle)) + **build.gradle**([код](https://github.com/gorbin/ASNETutorial/blob/ru/app/build.gradle)) ``` apply plugin: 'com.android.application' - android { - compileSdkVersion 19 - buildToolsVersion '20.0.0' - - defaultConfig { - applicationId "asne_tutorial.githubgorbin.com.asne_tutorial" - minSdkVersion 10 - targetSdkVersion 19 - versionCode 1 - versionName "1.0" - } - buildTypes { - release { - runProguard false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } + android { + compileSdkVersion 19 + buildToolsVersion '20.0.0' + + defaultConfig { + applicationId "com.github.gorbin.asnetutorial" + minSdkVersion 10 + targetSdkVersion 19 + versionCode 1 + versionName "1.0" } - - dependencies { - compile fileTree(include: ['*.jar'], dir: 'libs') - compile 'com.android.support:appcompat-v7:20.0.0' - compile 'com.github.asne:asne-facebook:0.2.1' - compile 'com.github.asne:asne-linkedin:0.2.1' - compile 'com.github.asne:asne-twitter:0.2.1' - } + buildTypes { + release { + runProguard false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + } + + dependencies { + compile fileTree(include: ['*.jar'], dir: 'libs') + compile 'com.android.support:appcompat-v7:20.0.0' + compile 'com.github.asne:asne-vk:0.3.1' + compile 'com.github.asne:asne-odnoklassniki:0.3.1' + } ``` -5. Lets create some layouts - Just login buttons in main fragment - **main_fragment.xml**(full [source](https://github.com/gorbin/ASNETutorial/blob/master/app/src/main/res/layout/main_fragment.xml)) +5. Теперь немного украсим наше приложение + В главном фрагменте расположим 2 кнопки отвечающие за логин в социальные сети + **main_fragment.xml**([код](https://github.com/gorbin/ASNETutorial/blob/ru/app/src/main/res/layout/main_fragment.xml)) ```xml - - -