Skip to content

Commit

Permalink
Implement google login
Browse files Browse the repository at this point in the history
  • Loading branch information
bywindow committed Jul 27, 2024
1 parent fd3ee77 commit e928b4c
Show file tree
Hide file tree
Showing 52 changed files with 738 additions and 212 deletions.
9 changes: 7 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,17 @@ android {

buildTypes {
release {
isMinifyEnabled = false
getByName("debug")
isMinifyEnabled = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
buildFeatures {
buildConfig = true
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
Expand All @@ -57,4 +61,5 @@ dependencies {
implementation(project(":feature:main"))
implementation(project(":feature:login"))
implementation(project(":core:designsystem"))
}
implementation(project(":core:data"))
}
6 changes: 4 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

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

<application
android:name=".MainApplication"
android:allowBackup="true"
Expand All @@ -12,7 +14,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Missionmate"
tools:targetApi="31">
</application>
android:networkSecurityConfig="@xml/network_security_config"
tools:targetApi="31"/>

</manifest>
6 changes: 6 additions & 0 deletions app/src/main/res/xml/network_security_config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">223.130.130.31</domain>
</domain-config>
</network-security-config>
4 changes: 4 additions & 0 deletions core/data/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,8 @@ dependencies {

ksp(libs.hilt.compiler)
implementation(libs.hilt.android)

implementation(project(":core:domain"))
implementation(project(":core:model"))
implementation(project(":core:network"))
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.goalpanzi.mission_mate.core.data.di

import com.goalpanzi.mission_mate.core.data.repository.LoginRepositoryImpl
import com.goalpanzi.mission_mate.core.domain.repository.LoginRepository
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent

@Module
@InstallIn(SingletonComponent::class)
internal abstract class DataModule {

@Binds
abstract fun bindLoginRepository(impl: LoginRepositoryImpl): LoginRepository
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.goalpanzi.mission_mate.core.data.di

import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.Dispatchers
import javax.inject.Qualifier

@Qualifier
@Retention(AnnotationRetention.RUNTIME)
annotation class Dispatcher(val dispatchers: MissionMateDispatcher)

enum class MissionMateDispatcher {
IO
}

@Module
@InstallIn(SingletonComponent::class)
interface DispatchersModule {

@Provides
@Dispatcher(MissionMateDispatcher.IO)
fun providesIODispatcher(): CoroutineDispatcher = Dispatchers.IO

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.goalpanzi.mission_mate.core.data.repository

import com.goalpanzi.mission_mate.core.domain.repository.LoginRepository
import com.goalpanzi.mission_mate.core.network.service.LoginService
import com.luckyoct.model.GoogleLogin
import com.luckyoct.model.request.GoogleLoginRequest
import javax.inject.Inject

class LoginRepositoryImpl @Inject constructor(
private val loginService: LoginService
): LoginRepository {

override suspend fun requestGoogleLogin(token: String, email: String): GoogleLogin {
val request = GoogleLoginRequest(identityToken = token, email = email)
val response = loginService.requestGoogleLogin(request)
return response
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ val Pink80 = Color(0xFFEFB8C8)

val Purple40 = Color(0xFF6650a4)
val PurpleGrey40 = Color(0xFF625b71)
val Pink40 = Color(0xFF7D5260)
val Pink40 = Color(0xFF7D5260)

val Orange01 = Color(0xFFF5EDEA)
2 changes: 2 additions & 0 deletions core/domain/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,6 @@ dependencies {

ksp(libs.hilt.compiler)
implementation(libs.hilt.android)

implementation(project(":core:model"))
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.goalpanzi.mission_mate.core.domain.repository

import com.luckyoct.model.GoogleLogin

interface LoginRepository {
suspend fun requestGoogleLogin(token: String, email: String): GoogleLogin
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.goalpanzi.mission_mate.core.domain.usecase

import com.goalpanzi.mission_mate.core.domain.repository.LoginRepository
import com.luckyoct.model.GoogleLogin
import javax.inject.Inject

class LoginUseCase @Inject constructor(
private val loginRepository: LoginRepository
) {

suspend fun requestGoogleLogin(token: String, email: String): GoogleLogin = loginRepository.requestGoogleLogin(token, email)

}
1 change: 1 addition & 0 deletions core/model/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
42 changes: 42 additions & 0 deletions core/model/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.jetbrains.kotlin.android)
alias(libs.plugins.kotlin.plugin.serialization)
}

android {
namespace = "com.luckyoct.model"
compileSdk = 34

defaultConfig {
minSdk = 24

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")
}

buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
}

dependencies {

implementation(libs.kotlin.serialization.json)
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
}
Empty file added core/model/consumer-rules.pro
Empty file.
21 changes: 21 additions & 0 deletions core/model/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
4 changes: 4 additions & 0 deletions core/model/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

</manifest>
10 changes: 10 additions & 0 deletions core/model/src/main/java/com/luckyoct/model/GoogleLogin.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.luckyoct.model

import kotlinx.serialization.Serializable

@Serializable
data class GoogleLogin(
val accessToken: String,
val refreshToken: String,
val isProfileSet: Boolean
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.luckyoct.model.request

import kotlinx.serialization.Serializable

@Serializable
data class GoogleLoginRequest(
val identityToken: String,
val email: String
)
17 changes: 17 additions & 0 deletions core/model/src/test/java/com/luckyoct/model/ExampleUnitTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.luckyoct.model

import org.junit.Test

import org.junit.Assert.*

/**
* Example local unit test, which will execute on the development machine (host).
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
class ExampleUnitTest {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
}

This file was deleted.

This file was deleted.

Loading

0 comments on commit e928b4c

Please sign in to comment.