Skip to content

Commit

Permalink
Merge pull request #6 from EvgenyTerebenin/release_v0.1
Browse files Browse the repository at this point in the history
Minor release v0.1
  • Loading branch information
EvgenyTerebenin authored Mar 5, 2021
2 parents 273a74e + 7fcc276 commit 55ceef8
Show file tree
Hide file tree
Showing 77 changed files with 1,592 additions and 320 deletions.
19 changes: 16 additions & 3 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 57 additions & 9 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,82 @@ apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

apply plugin: 'kotlin-kapt'

android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.terebenin.durov_return_the_wall"
minSdkVersion 16
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "1.0"
versionName "v0.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

buildConfigField("String", "REDIRECT_URI", "\"https://oauth.vk.com/blank.html\"")
buildConfigField("String", "AUTHORIZE_URI", "\"https://oauth.vk.com/authorize\"")
buildConfigField("String", "SCOPE", "\"friends,offline,wall\"")
buildConfigField("String", "API_VERSION", "\"5.103\"")
buildConfigField("String", "RESPONSE_TYPE", "\"token\"")
buildConfigField("String", "DISPLAY_TYPE", "\"page\"")
buildConfigField("String", "APP_ID", "\"7312625\"")
buildConfigField("String", "BASE_API_URL", "\"https://api.vk.com/\"")

}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

dataBinding {
enabled = true
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.core:core-ktx:1.0.2'

implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation "androidx.lifecycle:lifecycle-common-java8:2.2.0"
implementation "androidx.fragment:fragment-ktx:1.2.5"
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "com.google.android.material:material:1.1.0"
// alternately - if using Java8, use the following instead of lifecycle-compiler

implementation "com.squareup.retrofit2:retrofit:2.8.2"
implementation "com.squareup.retrofit2:converter-gson:2.6.1"
implementation 'com.squareup.okhttp3:logging-interceptor:4.7.2'
implementation "com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2"

implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.7"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.7"

kapt 'com.android.databinding:compiler:3.1.4'

implementation 'com.github.bumptech.glide:glide:4.11.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'

implementation "com.jakewharton.threetenabp:threetenabp:1.2.4"

testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package com.terebenin.durov_return_the_wall

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import androidx.test.platform.app.InstrumentationRegistry
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
Expand Down
12 changes: 10 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,25 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.terebenin.durov_return_the_wall">

<uses-permission android:name="android.permission.INTERNET" />
<application
android:name="com.terebenin.durov_return_the_wall.presentation.global.VkApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<activity
android:name=".presentation.global.MainActivity"
android:label="@string/title_feed"
android:screenOrientation="portrait" />
<activity
android:name=".presentation.auth.AuthActivity"
android:label="@string/app_name"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.terebenin.durov_return_the_wall.data.datasource.network

import com.terebenin.durov_return_the_wall.data.newsfeed.response.NewsfeedResponse
import retrofit2.Response
import retrofit2.http.GET

interface VkApi {

companion object {
const val METHOD_PATH = "method"
}

@GET("$METHOD_PATH/newsfeed.get")
suspend fun getNewsfeed(): Response<NewsfeedResponse>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.terebenin.durov_return_the_wall.data.datasource.network

import com.jakewharton.retrofit2.adapter.kotlin.coroutines.CoroutineCallAdapterFactory
import com.terebenin.durov_return_the_wall.BuildConfig
import com.terebenin.durov_return_the_wall.presentation.global.VkApplication.Companion.prefs
import okhttp3.Interceptor
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory


object VkApiFactory {

private val authInterceptor = Interceptor { chain ->
val newUrl = chain.request().url
.newBuilder()
.addQueryParameter("access_token", prefs.accessToken.token)
.addQueryParameter("v", BuildConfig.API_VERSION)
.build()

val newRequest = chain.request()
.newBuilder()
.url(newUrl)
.build()

chain.proceed(newRequest)
}

private fun initOkHttpClient(): OkHttpClient {
val okHttpClientBuilder = OkHttpClient.Builder().apply {
addInterceptor(authInterceptor)
val logInterceptor = HttpLoggingInterceptor()
logInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY)
addInterceptor(logInterceptor)
}
return okHttpClientBuilder.build()
}

private fun retrofit(): Retrofit = Retrofit.Builder()
.client(initOkHttpClient())
.baseUrl(BuildConfig.BASE_API_URL)
.addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(CoroutineCallAdapterFactory())
.build()

val vkApi: VkApi = retrofit().create(VkApi::class.java)

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.terebenin.durov_return_the_wall.data.datasource.storage

import android.content.Context
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.terebenin.durov_return_the_wall.domain.global.AccessToken

class Prefs(
private val context: Context,
private val gson: Gson
) {
private fun getSharedPreferences(prefsName: String) =
context.getSharedPreferences(prefsName, Context.MODE_PRIVATE)

private val AUTH_DATA = "auth_data"
private val ACCESS_TOKEN = "access_token"
private val authPrefs by lazy { getSharedPreferences(AUTH_DATA) }

private val accessTokenType = object : TypeToken<AccessToken>() {}.type

var accessToken: AccessToken
get() {
return gson.fromJson(authPrefs.getString(ACCESS_TOKEN, ""), accessTokenType)
}
set(value) {
authPrefs.edit().putString(ACCESS_TOKEN, gson.toJson(value)).apply()

}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.terebenin.durov_return_the_wall.data.newsfeed

import com.terebenin.durov_return_the_wall.data.datasource.network.VkApi
import com.terebenin.durov_return_the_wall.data.newsfeed.response.toDomainModel
import com.terebenin.durov_return_the_wall.domain.newsfeed.NewsfeedRepository
import com.terebenin.durov_return_the_wall.domain.newsfeed.model.NewsfeedResponseDomainModel

class NewsfeedRepositoryImpl(private val vkApi: VkApi) : NewsfeedRepository {
override suspend fun getNewsfeed(): NewsfeedResponseDomainModel? {
return vkApi.getNewsfeed().body()?.response?.toDomainModel()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.terebenin.durov_return_the_wall.data.newsfeed.response


import android.os.Parcelable
import com.google.gson.annotations.SerializedName
import kotlinx.android.parcel.Parcelize

@Parcelize
data class Attachments(

@field:SerializedName("photo")
val photo: Photo? = null,

@field:SerializedName("type")
val type: String? = null,

@field:SerializedName("video")
val video: Video? = null
) : Parcelable
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.terebenin.durov_return_the_wall.data.newsfeed.response

import com.google.gson.annotations.SerializedName


data class Comments(

@field:SerializedName("count")
val count: Int? = null,

@field:SerializedName("groups_can_post")
val groupsCanPost: Boolean? = null,

@field:SerializedName("can_post")
val canPost: Int? = null
)
Loading

0 comments on commit 55ceef8

Please sign in to comment.