Skip to content

Commit

Permalink
Merge branch 'dev' into feature/50-domain-data-acc
Browse files Browse the repository at this point in the history
# Conflicts:
#	settings.gradle.kts
  • Loading branch information
artwist-polyakov committed Feb 12, 2024
2 parents 8ae8dc9 + a3f8ef1 commit 63cdff0
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/checkPRToDev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ jobs:
STORE_PASSWORD: ${{ secrets.STORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
VKIDCLIENTID: ${{ secrets.VKIDCLIENTID }}
VKIDCLIENTSECRET: ${{ secrets.VKIDCLIENTSECRET }}
run: |
./gradlew :app:build
Expand Down
27 changes: 25 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties

import com.google.firebase.appdistribution.gradle.firebaseAppDistribution
import com.android.build.api.dsl.ApplicationDefaultConfig

plugins {
alias(libs.plugins.android.application)
Expand All @@ -26,6 +26,8 @@ android {
versionCode = 1
versionName = "1.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

initVKID()
}

signingConfigs {
Expand All @@ -43,7 +45,7 @@ android {
System.getenv("KEY_PASSWORD") ?: localProperties.getProperty("keyPassword")
?: "keyPasswordEmpty"

storeFile = file("keyStore/cashadvisor.jks" )
storeFile = file("keyStore/cashadvisor.jks")
storePassword = storePasswordLocal
keyAlias = keyAliasLocal
keyPassword = keyPasswordLocal
Expand Down Expand Up @@ -180,6 +182,9 @@ dependencies {
implementation(libs.firebase.analytics)
implementation(platform(libs.firebase.bom))

// Auth vk
implementation(libs.vk.auth)

// Ui Kit Library
implementation(project(":uikit"))

Expand All @@ -193,4 +198,22 @@ dependencies {

kapt {
correctErrorTypes = true
}

fun ApplicationDefaultConfig.initVKID() {
val localProperties = gradleLocalProperties(rootDir)

val clientId = System.getenv("VKIDCLIENTID") ?: localProperties.getProperty("VKIDCLIENTID")
?: throw GradleException("There is no VKIDClientID. Please specify it by ENV.VKIDCLIENTID or VKIDCLIENTID=xxx in local.properties")
val clientSecret =
System.getenv("VKIDCLIENTSECRET") ?: localProperties.getProperty("VKIDCLIENTSECRET")
?: throw GradleException("There is no VKIDClientSecret. Please specify it by ENV.VKIDCLIENTSECRET or VKIDCLIENTSECRET=xxx in local.properties")
addManifestPlaceholders(
mapOf(
"VKIDRedirectHost" to "vk.com",
"VKIDRedirectScheme" to "vk$clientId",
"VKIDClientID" to clientId,
"VKIDClientSecret" to clientSecret
)
)
}
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.INTERNET"/>

<application
android:name=".App"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import android.view.ViewGroup
import androidx.activity.result.ActivityResult
import androidx.activity.result.ActivityResultLauncher
import androidx.activity.result.contract.ActivityResultContracts
import android.widget.Toast
import androidx.fragment.app.Fragment
import androidx.navigation.fragment.findNavController
import app.cashadvisor.R
Expand All @@ -19,13 +20,39 @@ import com.google.android.gms.auth.api.signin.GoogleSignInClient
import com.google.android.gms.auth.api.signin.GoogleSignInOptions
import com.google.android.gms.common.api.ApiException
import com.google.android.gms.tasks.Task
import com.vk.id.AccessToken
import com.vk.id.VKID
import com.vk.id.VKIDAuthFail

class EntryFragment : Fragment() {
private var _binding: FragmentEntryBinding? = null
private val binding get() = _binding!!
private lateinit var mGoogleSignInClient: GoogleSignInClient
private lateinit var startResultSignIn: ActivityResultLauncher<Intent>

private val vkAuthCallback = object : VKID.AuthCallback {
override fun onSuccess(accessToken: AccessToken) {
val token = accessToken.token
Toast.makeText(requireContext(), "token: ${token}", Toast.LENGTH_SHORT).show()
Toast.makeText(
requireContext(),
"${accessToken.userData.firstName} ${accessToken.userData.lastName}",
Toast.LENGTH_LONG
).show()
}

override fun onFail(fail: VKIDAuthFail) {
Toast.makeText(requireContext(), "error: ${fail.description}", Toast.LENGTH_LONG).show()
when (fail) {
is VKIDAuthFail.Canceled -> {
//...
}
else -> {
//...
}
}
}
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand All @@ -45,7 +72,6 @@ class EntryFragment : Fragment() {

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

binding.btnLogin.setOnClickListener {
findNavController().navigate(R.id.action_entryFragment_to_loginFragment)
}
Expand All @@ -58,6 +84,11 @@ class EntryFragment : Fragment() {
val signIntent = mGoogleSignInClient.signInIntent
startResultSignIn.launch(signIntent)
}
binding.btnAuthVk.setOnClickListener {
val vkid = VKID(requireContext())
vkid.authorize(this, vkAuthCallback)
}

}

override fun onDestroyView() {
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/res/layout/fragment_entry.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,14 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintVertical_bias="0.7"/>

<Button
android:id="@+id/btn_auth_vk"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/login_via_vk"
android:layout_marginVertical="20dp"
app:layout_constraintStart_toStartOf="@id/btn_signup"
app:layout_constraintTop_toBottomOf="@id/btn_signup" />


</androidx.constraintlayout.widget.ConstraintLayout>
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@

<!-- Google authentication-->
<string name="client_id">409936335875-b2f0q0k1rt55vqb3oc751c7121dmd49q.apps.googleusercontent.com</string>
<string name="login_via_vk">Войти через vk</string>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
</resources>
11 changes: 11 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ dependencyResolutionManagement {
repositories {
google()
mavenCentral()
maven {
url =
java.net.URI("https://artifactory-external.vkpartner.ru/artifactory/vkid-sdk-andorid/")
}
}

versionCatalogs {
Expand Down Expand Up @@ -48,6 +52,8 @@ dependencyResolutionManagement {
version("android-library", "8.1.1")
version("gms-play-services-auth", "20.7.0")
version("crypto", "1.0.0-alpha02")
version("vkid", "1.0.0")


plugin(
"android-application",
Expand Down Expand Up @@ -310,6 +316,11 @@ dependencyResolutionManagement {
"security-crypto"
).versionRef("crypto")

// Auth vk
library("vk-auth",
"com.vk.id",
"vkid"
).versionRef("vkid")
}
}
}
Expand Down

0 comments on commit 63cdff0

Please sign in to comment.