Skip to content

Commit

Permalink
Merge branch 'release/v1.0.2'
Browse files Browse the repository at this point in the history
# Conflicts:
#	build.gradle
  • Loading branch information
juhwankim-dev committed Jan 8, 2023
2 parents 98122dd + 36d8ecc commit e5a27b3
Show file tree
Hide file tree
Showing 88 changed files with 1,174 additions and 164 deletions.
8 changes: 2 additions & 6 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 2
- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 11
cache: gradle
- run: sed -i "s/threeDaysAppVersionCode = [0-9]*/threeDaysAppVersionCode = $((`sed -n 's/threeDaysAppVersionCode = \([0-9]*\)/\1/p' build.gradle` + 1))/" build.gradle
- run: "git config --global user.email \"[email protected]\""
- run: "git config --global user.name \"depromeet-12th-team8\""
- run: git add build.gradle
- run: "git commit -m \"docs: Increment version code\""
- run: git push origin HEAD
- run: echo $DEBUG_KEYSTORE_FILE | base64 -d > debug.keystore
env:
DEBUG_KEYSTORE_FILE: ${{ secrets.DEBUG_KEYSTORE_FILE }}
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/update_version_code.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: 'Update version code'
on:
workflow_dispatch:
pull_request:
types: [opened, ready_for_review]
branches:
- develop

jobs:
update_version_code:
name: Update version code
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- run: sed -i "s/threeDaysAppVersionCode = [0-9]*/threeDaysAppVersionCode = $((`sed -n 's/threeDaysAppVersionCode = \([0-9]*\)/\1/p' build.gradle` + 1))/" build.gradle
- run: git config --local user.email `git log -1 --format='%ae'`
- run: git config --local user.name `git log -1 --format='%an'`
- run: git add build.gradle
- run: "git commit -m \"docs: Increment version code\""
- run: git push origin HEAD
2 changes: 2 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ dependencies {

implementation deps.login.kakao

implementation deps.mixpanel

implementation deps.timber

testImplementation(testDeps)
Expand Down
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@

<activity
android:name="com.depromeet.threedays.onboarding.OnboardingActivity"
android:noHistory="true"
android:exported="false" />

<activity
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.depromeet.threedays

import android.app.Application
import com.depromeet.threedays.core.analytics.AnalyticsUtil
import com.kakao.sdk.common.KakaoSdk
import dagger.hilt.android.HiltAndroidApp
import timber.log.Timber
Expand All @@ -12,6 +13,7 @@ class ThreeDaysApplication : Application() {

initTimber()
initKakaoSdk()
initAnalytics()
}

private fun initTimber() {
Expand All @@ -21,4 +23,8 @@ class ThreeDaysApplication : Application() {
private fun initKakaoSdk() {
KakaoSdk.init(this, "f0c0458b5837b0f245c73b5a22908319")
}

private fun initAnalytics() {
AnalyticsUtil.init(this)
}
}
20 changes: 19 additions & 1 deletion app/src/main/java/com/depromeet/threedays/firebase/FCMService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,34 @@ import android.content.Intent
import android.os.Build
import android.util.Log
import androidx.core.app.NotificationCompat
import com.depromeet.threedays.domain.usecase.notification.token.UpdateNotificationTokenUseCase
import com.depromeet.threedays.home.MainActivity
import com.google.firebase.messaging.FirebaseMessagingService
import com.google.firebase.messaging.RemoteMessage
import kotlinx.coroutines.runBlocking
import timber.log.Timber
import javax.inject.Inject
import com.depromeet.threedays.core_design_system.R as CoreDesignSystemResources

class FCMService : FirebaseMessagingService() {
class FCMService @Inject constructor() : FirebaseMessagingService() {
@Inject
lateinit var updateNotificationTokenUseCase: UpdateNotificationTokenUseCase

override fun onNewToken(token: String) {
super.onNewToken(token)
Log.i(TAG, "onNewToken: $token")
try {
// FIXME:
// - useCase initialize 안되었다는 에러 발생함.
// - 앱 처음 설치하면 스플래시 화면에서 호출되는데 이 때 memberId 없음
runBlocking {
updateNotificationTokenUseCase(token)
}
} catch (e: Exception) {
Timber.w(
e, "Failed to update fcm registration token"
)
}
}

override fun onMessageReceived(message: RemoteMessage) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.depromeet.threedays.firebase

import com.depromeet.threedays.data.datasource.notification.token.NotificationTokenLocalDataSource
import com.google.firebase.messaging.FirebaseMessaging
import dagger.Module
import dagger.Provides
Expand All @@ -14,4 +15,10 @@ object FirebaseModule {
@Singleton
@Provides
fun bindsFirebaseMessagingProvide(): FirebaseMessaging = FirebaseMessaging.getInstance()

@Singleton
@Provides
fun bindsFirebaseTokenDataSourceProvide(
firebaseTokenDataSource: FirebaseTokenDataSource
): NotificationTokenLocalDataSource = firebaseTokenDataSource
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.depromeet.threedays.firebase

import com.depromeet.threedays.data.datasource.notification.token.NotificationTokenLocalDataSource
import com.google.firebase.messaging.FirebaseMessaging
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.tasks.await
import timber.log.Timber
import javax.inject.Inject

class FirebaseTokenDataSource @Inject constructor() : NotificationTokenLocalDataSource {
override suspend fun getToken(): String? {
val registrationToken = runBlocking {
FirebaseMessaging.getInstance().token
.addOnCompleteListener {
if (!it.isSuccessful) {
Timber.e("Failed to get registration token")
}
}.await()
}
return registrationToken
}
}
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ buildscript {

ext {
threeDaysApplicationId = "com.depromeet.threedays"
threeDaysAppVersionCode = 5
threeDaysAppVersionName = "1.0.1"
threeDaysAppVersionCode = 6
threeDaysAppVersionName = "1.0.2"
}
}

Expand Down
12 changes: 12 additions & 0 deletions core-design-system/src/main/res/drawable/ic_star_check.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="54dp"
android:height="54dp"
android:viewportWidth="54"
android:viewportHeight="54">
<path
android:pathData="M34.816,1.588L38.528,14.623L51.972,16.352L44.095,27.382L51.125,38.97L37.59,39.689L32.914,52.41L23.913,42.277L11.051,46.552L13.362,33.197L2,25.807L13.883,19.287L12.576,5.796L25.083,11.021L34.816,1.588Z"
android:fillColor="#34C185"/>
<path
android:pathData="M25.759,32.838C25.408,32.838 25.056,32.721 24.822,32.37L19.438,26.986C18.853,26.4 18.853,25.581 19.438,24.996C20.023,24.41 20.843,24.41 21.428,24.996L25.759,29.326L33.484,21.601C34.07,21.016 34.889,21.016 35.474,21.601C36.06,22.186 36.06,23.006 35.474,23.591L26.812,32.253C26.461,32.721 26.11,32.838 25.759,32.838Z"
android:fillColor="#ffffff"/>
</vector>
8 changes: 8 additions & 0 deletions core-design-system/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,12 @@
<item name="android:textColorPrimary">@color/gray_800</item>
<item name="android:textAppearance">@style/Typography.Body1</item>
</style>

<style name="BottomNavigationView" parent="@style/TextAppearance.AppCompat.Caption">
<item name="android:textSize">11sp</item>
</style>

<style name="BottomNavigationView.Active" parent="@style/TextAppearance.AppCompat.Caption">
<item name="android:textSize">11sp</item>
</style>
</resources>
10 changes: 8 additions & 2 deletions core-design-system/src/main/res/values/typography.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,16 @@
<item name="fontFamily">@font/suit_semi_bold</item>
</style>

<!-- Button3 -->
<!-- Button2 -->
<style name="Typography.Button2">
<item name="android:textSize" tools:ignore="SpUsage">14dp</item>
<item name="fontFamily">@font/suit_bold</item>
<item name="fontFamily">@font/suit_semi_bold</item>
</style>

<!-- Button3 -->
<style name="Typography.Button3">
<item name="android:textSize" tools:ignore="SpUsage">13dp</item>
<item name="fontFamily">@font/suit_semi_bold</item>
</style>

<!-- Display1 -->
Expand Down
2 changes: 2 additions & 0 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ dependencies {

implementation deps.timber

implementation deps.mixpanel

testImplementation(testDeps)
androidTestImplementation(androidTestDeps)
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import androidx.annotation.LayoutRes
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.fragment.app.Fragment
import java.lang.IllegalStateException

abstract class BaseFragment<VB : ViewDataBinding, VM : BaseViewModel>(@LayoutRes private val layout: Int) : Fragment(layout) {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.depromeet.threedays.core.analytics

import android.content.Context

interface AnalyticsSdk {
fun init(context: Context)
fun isInitialized(): Boolean
fun event(name:String, properties: Map<String, Any>)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.depromeet.threedays.core.analytics

import android.content.Context

object AnalyticsUtil : AnalyticsSdk {
private const val MIXPANEL = "mixpanel"

private val analyticsSdkList: Map<String, AnalyticsSdk> =
mapOf(
MIXPANEL to MixpanelAnalyticsSdk()
)

override fun init(context: Context) {
analyticsSdkList.forEach { it.value.init(context) }
}

override fun isInitialized(): Boolean = analyticsSdkList.all { it.value.isInitialized() }


override fun event(name: String, properties: Map<String, Any>) {
analyticsSdkList.forEach { it.value.event(name = name, properties = properties) }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.depromeet.threedays.core.analytics

import android.content.Context

data class MixPanelEvent (
val eventName: String,
val properties: Map<String, String>
) {
companion object {
const val ScreenName: String = "ScreenName"
const val ButtonType: String = "ButtonType"
}
}

fun getViewedEventName(context: Context): String {
return getScreenName(context) + viewSuffix
}

fun getScreenName(context: Context): String {
val className = context.javaClass.simpleName
val suffixLength =
if(className.contains("Fragment")) fragmentLength
else if(className.contains("Activity")) activityLength
else 0

return className.substring(0, className.length - suffixLength)
}

const val viewSuffix = "Viewed"
const val activityLength = "Activity".length
const val fragmentLength = "Fragment".length
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.depromeet.threedays.core.analytics

import android.content.Context
import com.mixpanel.android.mpmetrics.MixpanelAPI
import org.json.JSONObject
import timber.log.Timber

class MixpanelAnalyticsSdk : AnalyticsSdk {
private lateinit var mixpanelAPI: MixpanelAPI
private var initialized = false

override fun init(context: Context) {
mixpanelAPI = MixpanelAPI.getInstance(context, "823f0e71338dd687bbe4d1b2f34e1272", true)
initialized = true
}

override fun isInitialized(): Boolean = initialized

override fun event(name: String, properties: Map<String, Any>) {
Timber.i("eventName : $name , properties : ${JSONObject(properties)}")
mixpanelAPI.track(name, JSONObject(properties))
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package com.depromeet.threedays.core.analytics

enum class ButtonType{
Next,
Save,
NewHabit,
Check,
NewMate,
Share,
SaveImg,
Insta,
Close,
MateClapOpen,
Carrot,
Sparta,
MateSave,
}

enum class Screen {
CreateHabit,
HomeDefault,
HomeActivated,
MateDefault,
MateHome,
MateClap,
MateLevelup,
MateCompleted,
MateShare,
MateMaking,
}

enum class ThreeDaysEvent {
SplashViewed,
OnboardingViewed,
SignupViewed,
ButtonClicked,
SignupCompletedViewed,
HomeDefaultViewed,
HomeHabitClicked,
HomeActivatedViewed,
CheckClicked,
MateOnboardingViewed,
MateDefaultViewed,
NewMateClicked,
MateHomeViewed,
MateShareClicked,
MateClapOpenClicked,
MateClapViewed,
NewHabitClicked,
SharedPathClicked,
MateMakingViewed,
MateSelected,
MateLevelupViewed,
MateCompletedViewed,
MateSaveClicked,
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,12 @@ package com.depromeet.threedays.core.extensions

val String.Companion.Empty
get() = ""


fun String.removeActivity(): String {
return this.substring(0, this.length - "Activity".length)
}

fun String.removeFragment(): String {
return this.substring(0, this.length - "Fragment".length)
}
Loading

0 comments on commit e5a27b3

Please sign in to comment.