Skip to content

Commit

Permalink
Merge pull request #163 from pknu-wap/feature/jaino/#160
Browse files Browse the repository at this point in the history
Feature/jaino/#160
  • Loading branch information
jeongjaino authored Mar 29, 2024
2 parents d9af2a9 + ab45c86 commit bc31171
Show file tree
Hide file tree
Showing 54 changed files with 495 additions and 170 deletions.
4 changes: 3 additions & 1 deletion .idea/gradle.xml

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

2 changes: 2 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ dependencies {
implementation(project(":feature:management-survey"))
implementation(project(":feature:management-event"))
implementation(project(":feature:splash"))
implementation(project(":core:common"))
implementation(project(":core:analytics"))
implementation(project(":core:designresource"))
implementation(project(":core:designsystem"))
implementation(project(":core:domain"))
Expand Down
81 changes: 44 additions & 37 deletions app/src/main/java/com/wap/wapp/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import androidx.compose.foundation.layout.navigationBars
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.windowInsetsPadding
import androidx.compose.material3.Scaffold
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
Expand All @@ -24,6 +25,8 @@ import androidx.navigation.compose.currentBackStackEntryAsState
import androidx.navigation.compose.rememberNavController
import com.wap.designsystem.WappTheme
import com.wap.wapp.component.WappBottomBar
import com.wap.wapp.core.analytics.AnalyticsHelper
import com.wap.wapp.core.analytics.LocalAnalyticsHelper
import com.wap.wapp.core.domain.usecase.auth.SignInUseCase
import com.wap.wapp.feature.attendance.management.navigation.attendanceManagementNavigationRoute
import com.wap.wapp.feature.auth.signin.navigation.signInNavigationRoute
Expand All @@ -47,50 +50,54 @@ class MainActivity : ComponentActivity() {
@Inject
lateinit var signInUseCase: SignInUseCase

@Inject
lateinit var analyticsHelper: AnalyticsHelper

override fun onCreate(savedInstanceState: Bundle?) {
setSystemBarStyle()
super.onCreate(savedInstanceState)
setContent {
WappTheme {
val navController = rememberNavController()

Scaffold(
containerColor = WappTheme.colors.backgroundBlack,
bottomBar = {
val navBackStackEntry by
navController.currentBackStackEntryAsState()
val navController = rememberNavController()
val navBackStackEntry by navController.currentBackStackEntryAsState()
val currentRoute = navBackStackEntry?.destination?.route
var bottomBarState by rememberSaveable { mutableStateOf(false) }

val currentRoute = navBackStackEntry?.destination?.route
var bottomBarState by rememberSaveable { mutableStateOf(false) }

handleBottomBarState(
currentRoute,
setBottomBarState = { boolean ->
bottomBarState = boolean
},
)
CompositionLocalProvider(
LocalAnalyticsHelper provides analyticsHelper,
) {
WappTheme {
Scaffold(
containerColor = WappTheme.colors.backgroundBlack,
bottomBar = {
handleBottomBarState(
currentRoute,
setBottomBarState = { boolean ->
bottomBarState = boolean
},
)

WappBottomBar(
currentRoute = currentRoute,
bottomBarState = bottomBarState,
onNavigateToDestination = { destination ->
navigateToTopLevelDestination(
navController,
destination,
)
},
modifier = Modifier.height(70.dp),
WappBottomBar(
currentRoute = currentRoute,
bottomBarState = bottomBarState,
onNavigateToDestination = { destination ->
navigateToTopLevelDestination(
navController,
destination,
)
},
modifier = Modifier.height(70.dp),
)
},
modifier = Modifier
.windowInsetsPadding(WindowInsets.navigationBars)
.fillMaxSize(),
) { innerPadding ->
WappNavHost(
signInUseCase = signInUseCase,
navController = navController,
modifier = Modifier.padding(innerPadding),
)
},
modifier = Modifier
.windowInsetsPadding(WindowInsets.navigationBars)
.fillMaxSize(),
) { innerPadding ->
WappNavHost(
signInUseCase = signInUseCase,
navController = navController,
modifier = Modifier.padding(innerPadding),
)
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions core/analytics/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
29 changes: 29 additions & 0 deletions core/analytics/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
plugins {
id("com.wap.wapp.library")
id("com.wap.wapp.hilt")
id("com.wap.wapp.compose")
}

android {
namespace = "com.wap.wapp.core.analytics"

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

buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro",
)
}
}
}

dependencies {
implementation(platform(libs.firebase.bom))
implementation(libs.firebase.analytics)
}
Empty file.
21 changes: 21 additions & 0 deletions core/analytics/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
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.wap.wapp.core.analytics

data class AnalyticsEvent(
val type: String,
val extras: List<Param> = emptyList(),
) {
data class Param(
val key: String,
val value: String,
)

companion object {
const val SCREEN_VIEW = "screen_view" // TYPE
const val SCREEN_NAME = "screen_name" // EXTRA_KEY
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.wap.wapp.core.analytics

interface AnalyticsHelper {
fun logEvent(event: AnalyticsEvent)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.wap.wapp.core.analytics

import com.google.firebase.analytics.FirebaseAnalytics
import com.google.firebase.analytics.ktx.logEvent
import javax.inject.Inject

class AnalyticsHelperImpl @Inject constructor(
private val firebaseAnalytics: FirebaseAnalytics,
) : AnalyticsHelper {
override fun logEvent(event: AnalyticsEvent) {
firebaseAnalytics.logEvent(event.type) {
for (extra in event.extras) {
// Key, Value Max Length에 따른 slicing
param(
key = extra.key.take(40),
value = extra.value.take(100),
)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.wap.wapp.core.analytics

import androidx.compose.runtime.staticCompositionLocalOf

val LocalAnalyticsHelper = staticCompositionLocalOf<AnalyticsHelper> {
error("Any AnalyticsHelper Did Not Provided")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.wap.wapp.core.analytics.di

import com.google.firebase.analytics.FirebaseAnalytics
import com.google.firebase.analytics.ktx.analytics
import com.google.firebase.ktx.Firebase
import com.wap.wapp.core.analytics.AnalyticsHelper
import com.wap.wapp.core.analytics.AnalyticsHelperImpl
import dagger.Binds
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
abstract class AnalyticsModule {
@Binds
@Singleton
abstract fun bindsAnalyticsHelper(analyticsHelperImpl: AnalyticsHelperImpl): AnalyticsHelper

companion object {
@Provides
@Singleton
fun provideFirebaseAnalytics(): FirebaseAnalytics {
return Firebase.analytics
}
}
}
3 changes: 2 additions & 1 deletion core/common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

android {
namespace = "com.wap.wapp.core.base"
namespace = "com.wap.wapp.core.common"

defaultConfig {
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
Expand All @@ -22,6 +22,7 @@ android {
}

dependencies {
implementation(project(":core:analytics"))
implementation(libs.bundles.androidx)
implementation(platform(libs.firebase.bom))
implementation(libs.firebase.auth)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.wap.wapp.core.commmon.extensions

import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import com.wap.wapp.core.analytics.AnalyticsEvent
import com.wap.wapp.core.analytics.AnalyticsEvent.Param
import com.wap.wapp.core.analytics.AnalyticsHelper
import com.wap.wapp.core.analytics.LocalAnalyticsHelper

fun AnalyticsHelper.logScreenView(screenName: String) {
logEvent(
AnalyticsEvent(
type = AnalyticsEvent.SCREEN_VIEW,
extras = listOf(
Param(AnalyticsEvent.SCREEN_NAME, screenName),
),
),
)
}

fun AnalyticsHelper.logUserSignedIn(userId: String, userName: String) {
logEvent(
AnalyticsEvent(
type = "signed_in",
extras = listOf(
Param("user_id", userId),
Param("user_name", userName),
),
),
)
}

@Composable
fun TrackScreenViewEvent(
screenName: String,
analyticsHelper: AnalyticsHelper = LocalAnalyticsHelper.current,
) = LaunchedEffect(Unit) {
analyticsHelper.logScreenView(screenName)
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import com.wap.wapp.core.data.repository.user.UserRepository
import com.wap.wapp.core.domain.usecase.user.GetUserRoleUseCase
import com.wap.wapp.core.model.user.UserRole
import javax.inject.Inject
import javax.inject.Singleton

@Singleton
class DeleteUserUseCase @Inject constructor(
private val authRepository: AuthRepository,
private val userRepository: UserRepository,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ import com.wap.wapp.core.data.repository.user.UserRepository
import com.wap.wapp.core.domain.model.AuthState
import com.wap.wapp.core.domain.model.AuthState.SIGN_IN
import com.wap.wapp.core.domain.model.AuthState.SIGN_UP
import dagger.hilt.android.scopes.ActivityScoped
import javax.inject.Inject

@ActivityScoped
class SignInUseCase @Inject constructor(
private val signInRepository: SignInRepository,
private val userRepository: UserRepository,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ package com.wap.wapp.core.domain.usecase.auth

import com.wap.wapp.core.data.repository.auth.AuthRepository
import javax.inject.Inject
import javax.inject.Singleton

@Singleton
class SignOutUseCase @Inject constructor(
private val authRepository: AuthRepository,
) {
Expand Down
Loading

0 comments on commit bc31171

Please sign in to comment.