Skip to content

Commit

Permalink
Merge branch 'dev' into feat/#444
Browse files Browse the repository at this point in the history
# Conflicts:
#	backend/src/main/java/com/festago/auth/application/AuthService.java
  • Loading branch information
BGuga committed Sep 20, 2023
2 parents 9eb300d + c1f8456 commit 0eb447a
Show file tree
Hide file tree
Showing 68 changed files with 1,314 additions and 296 deletions.
16 changes: 14 additions & 2 deletions android/festago/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ plugins {
id("com.google.gms.google-services")
id("com.google.firebase.crashlytics")
id("org.jlleitschuh.gradle.ktlint")
id("com.google.dagger.hilt.android")
}

android {
Expand Down Expand Up @@ -63,13 +64,24 @@ kotlin {
jvmToolchain(17)
}

kapt {
correctErrorTypes = true
}

dependencies {
// domain
implementation(project(":domain"))

// android
implementation("androidx.core:core-ktx:1.10.1")
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("com.google.android.material:material:1.9.0")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")

// hilt
implementation("com.google.dagger:hilt-android:2.44")
kapt("com.google.dagger:hilt-android-compiler:2.44")

// recyclerview
implementation("androidx.recyclerview:recyclerview:1.3.1-rc01")

Expand Down Expand Up @@ -137,8 +149,8 @@ dependencies {
// Encrypted SharedPreference
implementation("androidx.security:security-crypto-ktx:1.1.0-alpha06")

// domain
implementation(project(":domain"))
// turbine
testImplementation("app.cash.turbine:turbine:1.0.0")
}

fun getSecretKey(propertyKey: String): String {
Expand Down
10 changes: 5 additions & 5 deletions android/festago/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
xmlns:tools="http://schemas.android.com/tools">

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

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

<application
Expand All @@ -18,6 +17,9 @@
android:theme="@style/Theme.Festago"
android:usesCleartextTraffic="true"
tools:targetApi="31">
<activity
android:name=".presentation.ui.studentverification.StudentVerificationActivity"
android:exported="false" />
<activity
android:name=".presentation.ui.signin.SignInActivity"
android:exported="false" />
Expand Down Expand Up @@ -54,11 +56,9 @@
android:scheme="@string/kakao_redirection_scheme" />
</intent-filter>
</activity>

<activity
android:name=".presentation.ui.tickethistory.TicketHistoryActivity"
android:exported="false">
</activity>
android:exported="false" />
</application>

</manifest>
</manifest>
Original file line number Diff line number Diff line change
@@ -1,58 +1,18 @@
package com.festago.festago

import android.app.Application
import com.festago.festago.analytics.FirebaseAnalyticsHelper
import com.festago.festago.di.AnalysisContainer
import com.festago.festago.di.AuthServiceContainer
import com.festago.festago.di.LocalDataSourceContainer
import com.festago.festago.di.NormalServiceContainer
import com.festago.festago.di.RepositoryContainer
import com.festago.festago.di.TokenContainer
import com.kakao.sdk.common.KakaoSdk
import dagger.hilt.android.HiltAndroidApp

@HiltAndroidApp
class FestagoApplication : Application() {

override fun onCreate() {
super.onCreate()
initKakaoSdk()
initRepositoryContainer()
initFirebaseContainer()
}

private fun initKakaoSdk() {
KakaoSdk.init(this, BuildConfig.KAKAO_NATIVE_APP_KEY)
}

private fun initRepositoryContainer() {
normalServiceContainer = NormalServiceContainer(BuildConfig.BASE_URL)

tokenContainer = TokenContainer(
normalServiceContainer = normalServiceContainer,
localDataSourceContainer = LocalDataSourceContainer(applicationContext),
)

authServiceContainer = AuthServiceContainer(
baseUrl = BuildConfig.BASE_URL,
tokenContainer = tokenContainer,
)

repositoryContainer = RepositoryContainer(
authServiceContainer = authServiceContainer,
normalServiceContainer = normalServiceContainer,
tokenContainer = tokenContainer,
)
}

private fun initFirebaseContainer() {
FirebaseAnalyticsHelper.init(applicationContext)
analysisContainer = AnalysisContainer()
}

companion object DependencyContainer {
lateinit var normalServiceContainer: NormalServiceContainer
lateinit var authServiceContainer: AuthServiceContainer
lateinit var repositoryContainer: RepositoryContainer
lateinit var analysisContainer: AnalysisContainer
lateinit var tokenContainer: TokenContainer
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ package com.festago.festago.analytics
import android.content.Context
import android.os.Bundle
import com.google.firebase.analytics.FirebaseAnalytics
import dagger.hilt.android.qualifiers.ApplicationContext
import javax.inject.Inject

object FirebaseAnalyticsHelper : AnalyticsHelper {
class FirebaseAnalyticsHelper @Inject constructor(
@ApplicationContext context: Context
) : AnalyticsHelper {

private const val LOG_NAME = "festago_log"
private lateinit var firebaseAnalytics: FirebaseAnalytics

fun init(context: Context) {
if (::firebaseAnalytics.isInitialized) return
firebaseAnalytics = FirebaseAnalytics.getInstance(context.applicationContext)
private val firebaseAnalytics: FirebaseAnalytics by lazy {
FirebaseAnalytics.getInstance(context.applicationContext)
}

override fun logEvent(event: AnalyticsEvent) {
Expand All @@ -22,4 +22,8 @@ object FirebaseAnalyticsHelper : AnalyticsHelper {
}
firebaseAnalytics.logEvent(LOG_NAME, params)
}

companion object {
private const val LOG_NAME = "festago_log"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ import android.content.Context
import android.content.SharedPreferences
import androidx.security.crypto.EncryptedSharedPreferences
import androidx.security.crypto.MasterKey
import dagger.hilt.android.qualifiers.ApplicationContext
import javax.inject.Inject

class TokenLocalDataSource(context: Context) : TokenDataSource {
class TokenLocalDataSource @Inject constructor(
@ApplicationContext context: Context
) : TokenDataSource {

private val sharedPreference: SharedPreferences by lazy {
val masterKeyAlias = MasterKey
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.festago.festago.data.di

import com.festago.festago.data.repository.ReservationTicketDefaultRepository
import com.festago.festago.data.repository.StudentVerificationDefaultRepository
import com.festago.festago.data.repository.UserDefaultRepository
import com.festago.festago.repository.ReservationTicketRepository
import com.festago.festago.repository.StudentVerificationRepository
import com.festago.festago.repository.UserRepository
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ViewModelComponent
import dagger.hilt.android.scopes.ViewModelScoped

@InstallIn(ViewModelComponent::class)
@Module
interface ViewModelScopeModule {

@Binds
@ViewModelScoped
fun bindsReservationTicketDefaultRepository(reservationTicketRepository: ReservationTicketDefaultRepository): ReservationTicketRepository

@Binds
@ViewModelScoped
fun bindsStudentVerificationDefaultRepository(studentVerificationRepository: StudentVerificationDefaultRepository): StudentVerificationRepository

@Binds
@ViewModelScoped
fun binsUserDefaultRepository(userRepository: UserDefaultRepository): UserRepository
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.festago.festago.data.di.singletonscope

import com.festago.festago.analytics.AnalyticsHelper
import com.festago.festago.analytics.FirebaseAnalyticsHelper
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

@InstallIn(SingletonComponent::class)
@Module
interface AnalyticsModule {
@Binds
@Singleton
fun bindsFirebaseAnalyticsHelper(
analyticsHelper: FirebaseAnalyticsHelper
): AnalyticsHelper
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package com.festago.festago.data.di.singletonscope

import com.festago.festago.BuildConfig
import com.festago.festago.data.retrofit.AuthInterceptor
import com.festago.festago.data.retrofit.TokenManager
import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import kotlinx.serialization.json.Json
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.OkHttpClient
import retrofit2.Retrofit
import javax.inject.Qualifier
import javax.inject.Singleton

@Qualifier
@Retention(AnnotationRetention.BINARY)
annotation class NormalRetrofitQualifier

@Qualifier
@Retention(AnnotationRetention.BINARY)
annotation class AuthRetrofitQualifier

@Qualifier
@Retention(AnnotationRetention.BINARY)
annotation class BaseUrlQualifier

@InstallIn(SingletonComponent::class)
@Module
object ApiModule {

@Provides
@Singleton
fun provideOkHttpClient(tokenManager: TokenManager): OkHttpClient = OkHttpClient
.Builder()
.addInterceptor(AuthInterceptor(tokenManager))
.build()

@Provides
@Singleton
@NormalRetrofitQualifier
fun providesNormalRetrofit(@BaseUrlQualifier baseUrl: String): Retrofit = Retrofit.Builder()
.baseUrl(baseUrl)
.addConverterFactory(Json.asConverterFactory("application/json".toMediaType()))
.build()

@Provides
@Singleton
@AuthRetrofitQualifier
fun providesAuthRetrofit(
@BaseUrlQualifier baseUrl: String,
okHttpClient: OkHttpClient
): Retrofit = Retrofit.Builder()
.baseUrl(baseUrl)
.client(okHttpClient)
.addConverterFactory(Json.asConverterFactory("application/json".toMediaType()))
.build()

@Provides
@Singleton
@BaseUrlQualifier
fun providesBaseUrl(): String = BuildConfig.BASE_URL
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.festago.festago.data.di.singletonscope

import com.festago.festago.data.datasource.TokenDataSource
import com.festago.festago.data.datasource.TokenLocalDataSource
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

@InstallIn(SingletonComponent::class)
@Module
interface DataSourceModule {
@Binds
@Singleton
fun bindsLocalTokenDataSource(tokenDataSource: TokenLocalDataSource): TokenDataSource
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.festago.festago.data.di.singletonscope

import com.festago.festago.data.repository.AuthDefaultRepository
import com.festago.festago.data.repository.FestivalDefaultRepository
import com.festago.festago.data.repository.SchoolDefaultRepository
import com.festago.festago.data.repository.TicketDefaultRepository
import com.festago.festago.data.repository.TokenDefaultRepository
import com.festago.festago.repository.AuthRepository
import com.festago.festago.repository.FestivalRepository
import com.festago.festago.repository.SchoolRepository
import com.festago.festago.repository.TicketRepository
import com.festago.festago.repository.TokenRepository
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

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

@Binds
fun bindsTokenDefaultRepository(tokenRepository: TokenDefaultRepository): TokenRepository

@Binds
fun bindsAuthDefaultRepository(authRepository: AuthDefaultRepository): AuthRepository

@Binds
@Singleton
fun bindsFestivalDefaultRepository(festivalRepository: FestivalDefaultRepository): FestivalRepository

@Binds
@Singleton
fun bindsSchoolDefaultRepository(schoolRepository: SchoolDefaultRepository): SchoolRepository

@Binds
@Singleton
fun bindsTicketDefaultRepository(ticketRepository: TicketDefaultRepository): TicketRepository
}
Loading

0 comments on commit 0eb447a

Please sign in to comment.