Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ android {

dependencies {
implementation(projects.core.ui)
implementation(projects.core.analytics)
implementation(projects.core.android)
implementation(projects.core.designSystem)
implementation(projects.core.common)
implementation(projects.core.model)
Expand Down
46 changes: 24 additions & 22 deletions app/src/main/java/com/moneymong/moneymong/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.viewModels
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.platform.LocalContext
import androidx.lifecycle.compose.LifecycleStartEffect
import com.moneymong.moneymong.common.event.EventTracker
import com.moneymong.moneymong.analytics.AnalyticsTracker
import com.moneymong.moneymong.analytics.LocalAnalyticsTracker
import com.moneymong.moneymong.design_system.error.ErrorDialog
import com.moneymong.moneymong.design_system.theme.MMTheme
import com.moneymong.moneymong.domain.repository.token.TokenRepository
Expand All @@ -30,12 +32,10 @@ class MainActivity : ComponentActivity() {
lateinit var tokenRepository: TokenRepository

@Inject
lateinit var eventTracker: EventTracker
lateinit var analyticsTracker: AnalyticsTracker

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
eventTracker.initialize()

setContent {
val context = LocalContext.current
val state by viewModel.collectAsState()
Expand All @@ -53,27 +53,29 @@ class MainActivity : ComponentActivity() {
onStopOrDispose { }
})

MMTheme {
if (shouldUpdate) {
ErrorDialog(
message = "안정적인 머니몽 사용을 위해\n최신 버전으로 업데이트가 필요해요!",
confirmText = "업데이트",
onConfirm = {
val playStoreUrl =
"https://play.google.com/store/apps/details?id=${BuildConfig.APPLICATION_ID}"
val intent = Intent(Intent.ACTION_VIEW).apply {
data = Uri.parse(playStoreUrl)
setPackage("com.android.vending")
CompositionLocalProvider(LocalAnalyticsTracker provides analyticsTracker) {
MMTheme {
if (shouldUpdate) {
ErrorDialog(
message = "안정적인 머니몽 사용을 위해\n최신 버전으로 업데이트가 필요해요!",
confirmText = "업데이트",
onConfirm = {
val playStoreUrl =
"https://play.google.com/store/apps/details?id=${BuildConfig.APPLICATION_ID}"
val intent = Intent(Intent.ACTION_VIEW).apply {
data = Uri.parse(playStoreUrl)
setPackage("com.android.vending")
}
context.startActivity(intent)
}
context.startActivity(intent)
}
)
}

MoneyMongApp(
expired = expired,
onChangeExpired = { expired = false }
)
}

MoneyMongApp(
expired = expired,
onChangeExpired = { expired = false }
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.moneymong.moneymong

import com.moneymong.moneymong.common.base.SideEffect
import com.moneymong.moneymong.android.SideEffect

sealed class MainSideEffect: SideEffect {
}
2 changes: 1 addition & 1 deletion app/src/main/java/com/moneymong/moneymong/MainState.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.moneymong.moneymong

import com.moneymong.moneymong.common.base.State
import com.moneymong.moneymong.android.State

data class MainState(
val shouldUpdate: Boolean = false
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/moneymong/moneymong/MainViewModel.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.moneymong.moneymong

import com.moneymong.moneymong.common.base.BaseViewModel
import com.moneymong.moneymong.android.BaseViewModel
import com.moneymong.moneymong.domain.usecase.version.CheckVersionUpdateUseCase
import dagger.hilt.android.lifecycle.HiltViewModel
import org.orbitmvi.orbit.syntax.simple.intent
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
15 changes: 15 additions & 0 deletions core/analytics/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed
plugins {
alias(libs.plugins.moneymong.android.library)
alias(libs.plugins.moneymong.android.hilt)
}

android {
namespace = "com.moneymong.moneymong.analytics"
}

dependencies {
implementation(platform(libs.firebase.bom))
implementation(libs.firebase.analytics)
implementation(libs.firebase.crashlytics)
}
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,24 @@
package com.moneymong.moneymong.analytics

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

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.moneymong.moneymong.analytics.test", appContext.packageName)
}
}
4 changes: 4 additions & 0 deletions core/analytics/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>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.moneymong.moneymong.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"
const val SCREEN_NAME = "screen_name"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.moneymong.moneymong.analytics

import com.google.firebase.Firebase
import com.google.firebase.analytics.FirebaseAnalytics
import com.google.firebase.analytics.analytics
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 bindsAnalyticsTracker(firebaseAnalyticsTracker: FirebaseAnalyticsTracker): AnalyticsTracker

companion object {
@Provides
@Singleton
fun provideFirebaseAnalytics(): FirebaseAnalytics = Firebase.analytics
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.moneymong.moneymong.analytics

interface AnalyticsTracker {
fun logEvent(event: AnalyticsEvent)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.moneymong.moneymong.analytics

import androidx.compose.runtime.staticCompositionLocalOf

val LocalAnalyticsTracker = staticCompositionLocalOf<AnalyticsTracker> {
NoOpAnalyticsTracker()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.moneymong.moneymong.analytics

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

class FirebaseAnalyticsTracker @Inject constructor(
private val firebaseAnalytics: FirebaseAnalytics
) : AnalyticsTracker {
override fun logEvent(event: AnalyticsEvent) {
firebaseAnalytics.logEvent(event.type) {
for (extra in event.extras) {
param(
key = extra.key.take(MAX_KEY_TAKE_COUNT),
value = extra.value.take(MAX_VALUE_TAKE_COUNT),
)
}
}
}

companion object {
private const val MAX_KEY_TAKE_COUNT = 40
private const val MAX_VALUE_TAKE_COUNT = 100
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.moneymong.moneymong.analytics

class NoOpAnalyticsTracker : AnalyticsTracker {
override fun logEvent(event: AnalyticsEvent) = Unit
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.moneymong.moneymong.analytics

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)
}
}
1 change: 1 addition & 0 deletions core/android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
23 changes: 23 additions & 0 deletions core/android/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed
plugins {
alias(libs.plugins.moneymong.android.library)
alias(libs.plugins.moneymong.android.hilt)
}

android {
namespace = "com.moneymong.moneymong.android"
}

dependencies {
implementation(libs.orbit.core)
implementation(libs.orbit.compose)
implementation(libs.orbit.viewModel)
implementation(libs.okhttp)

implementation(libs.androidx.core.ktx)
implementation(libs.appcompat)
implementation(libs.material)
testImplementation(libs.junit4)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.test.espresso.core)
}
Empty file added core/android/consumer-rules.pro
Empty file.
21 changes: 21 additions & 0 deletions core/android/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,24 @@
package com.moneymong.moneymong.android

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

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.moneymong.moneymong.android.test", appContext.packageName)
}
}
4 changes: 4 additions & 0 deletions core/android/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>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.moneymong.moneymong.common.base
package com.moneymong.moneymong.android

import androidx.lifecycle.ViewModel
import org.orbitmvi.orbit.ContainerHost
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.moneymong.moneymong.android

interface SideEffect {
}
Loading