Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
924c960
[FEAT/#372] splash를 통해 Route 이동 로직
leeeyubin Mar 29, 2025
7127bf2
[FEAT/#372]t terning Scheme 등록
leeeyubin Mar 29, 2025
a4a5593
[FEAT/#372] 불필요한 navigateUp 함수 제거
leeeyubin Mar 29, 2025
61cf878
[FEAT/#372] 불필요한 임포트 제거
leeeyubin Mar 29, 2025
4693063
[FEAT/#372] 마이페이지 딥링크 작성
leeeyubin Mar 29, 2025
6bea3e0
[DEL/#372] Splash를 통한 Route 이동로직 제거
leeeyubin Mar 29, 2025
99dabb2
[DEL/#372] Firebase 모듈 local 의존성 제거
leeeyubin Mar 29, 2025
8ee3b49
[CHORE/#372] SplashNavigation 실험
leeeyubin Mar 29, 2025
ee4efc2
[CHORE/#372] conflict 해결
leeeyubin Mar 29, 2025
0ca66a0
[CHORE/#372] TODO 작성
leeeyubin Mar 29, 2025
7c02dce
[CHORE/#372] :core:navigator 모듈 추가
leeeyubin Mar 29, 2025
82d19f2
[FEAT/#372] NavigatorModule 정의
leeeyubin Mar 29, 2025
82abc22
[DEL/#372] MyPageNavigation 예시 삭제
leeeyubin Apr 6, 2025
7ef1add
[CHORE/#372] :core:firebase 그래들 파일 정리
leeeyubin Apr 6, 2025
87bd555
[CHORE/#372] splash 패키지 onboarding 모듈로 옮기기
leeeyubin Apr 9, 2025
f6d1ac2
[CHORE/#372] firebase 모듈 아이콘 관련 설정
leeeyubin Apr 9, 2025
993df4f
[CHORE/#372] 사소한 코드 정리
leeeyubin Apr 9, 2025
3967a66
[FEAT/#372] terning message service 구현
leeeyubin Apr 9, 2025
92cf693
[FEAT/#372] git pull from develop
leeeyubin Apr 9, 2025
98ddcb2
[FIX/#372] resolve conflict
leeeyubin Apr 9, 2025
c854e53
[FEAT/#372] :feature:splash 모듈 추가
leeeyubin Apr 9, 2025
2c4da3f
[CHORE/#372] 코드 줄 변경
leeeyubin Apr 9, 2025
0c8fb7f
[DEL/#372] 불필요한 코드 삭제
leeeyubin Apr 11, 2025
5aae771
[CHORE/#372] 경로 통일
leeeyubin Apr 11, 2025
1ecb161
[CHORE/#372] 코드 일부 수정
leeeyubin Apr 11, 2025
7464a5e
[FEAT/#372] Update dependency graph
leeeyubin Apr 11, 2025
d0dd408
[DEL/#372] get() 삭제
leeeyubin Apr 11, 2025
ccdba03
[CHORE/#372] 함수명 변경
leeeyubin Apr 12, 2025
c49309a
[CHORE/#372] @JvmStatic 삭제
leeeyubin Apr 12, 2025
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
7 changes: 6 additions & 1 deletion core/firebase/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import com.terning.build_logic.extension.setNamespace


plugins {
alias(libs.plugins.terning.library)
}
Expand All @@ -10,8 +9,14 @@ android {
}

dependencies {
//core
implementation(projects.core.navigator)
implementation(projects.core.local)

// timber
implementation(libs.timber)

// firebase
implementation(platform(libs.firebase.bom))
implementation(libs.firebase.analytics)
implementation(libs.firebase.messaging)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
package com.terning.core.firebase.remoteconfig.messageservice

import android.app.NotificationChannel
import android.app.NotificationManager
import android.app.PendingIntent
import android.content.Intent
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import androidx.core.content.getSystemService
import androidx.core.net.toUri
import com.google.firebase.messaging.FirebaseMessagingService
import com.google.firebase.messaging.RemoteMessage
import com.terning.core.firebase.R
import com.terning.core.local.TerningDataStore
import com.terning.navigator.NavigatorProvider
import dagger.hilt.android.AndroidEntryPoint
import timber.log.Timber
import java.util.Random
import javax.inject.Inject

@AndroidEntryPoint
class TerningMessagingService : FirebaseMessagingService() {

@Inject
lateinit var terningDataStore: TerningDataStore

@Inject
lateinit var navigatorProvider: NavigatorProvider

override fun onNewToken(token: String) {
super.onNewToken(token)

Timber.tag("okhttp").d("ON NEW TOKEN")
}

override fun handleIntent(intent: Intent?) {
super.handleIntent(intent)

if (intent?.getStringExtra(TITLE)?.isEmpty() == true) return

val title = intent?.getStringExtra(TITLE).orEmpty()
val body = intent?.getStringExtra(BODY).orEmpty()
val type = intent?.getStringExtra(TYPE).orEmpty()

sendNotification(title = title, body = body, type = type)
}

override fun onMessageReceived(message: RemoteMessage) {
super.onMessageReceived(message)

if (message.data.isEmpty())
// TODO: 조건 추가 by 이유빈 -> || !terningDataStore.alarmAvailable
return

val title = message.data[TITLE].orEmpty()
val body = message.data[BODY].orEmpty()
val type = message.data[TYPE].orEmpty()

sendNotification(title = title, body = body, type = type)
}

private fun sendNotification(title: String, body: String, type: String) {
val notifyId = Random().nextInt()
val intent = navigatorProvider.getMainActivityIntent(deeplink = type).apply {
action = Intent.ACTION_VIEW
data = type.toUri()
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP
}
val pendingIntent = PendingIntent.getActivity(
this@TerningMessagingService,
notifyId,
intent,
PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_MUTABLE
)
val channelId: String = CHANNEL_ID
val notificationBuilder =
NotificationCompat.Builder(this, channelId).apply {
setSmallIcon(R.mipmap.ic_terning_launcher)
setContentTitle(title)
setContentText(body)
setPriority(NotificationManagerCompat.IMPORTANCE_HIGH)
setContentIntent(pendingIntent)
}

getSystemService<NotificationManager>()?.run {
createNotificationChannel(
NotificationChannel(
channelId,
channelId,
NotificationManager.IMPORTANCE_HIGH,
),
)
notify(notifyId, notificationBuilder.build())
}
}

companion object {
private const val CHANNEL_ID: String = "terning"
private const val TITLE: String = "title"
private const val BODY: String = "body"
private const val TYPE: String = "type"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions core/navigator/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
9 changes: 9 additions & 0 deletions core/navigator/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import com.terning.build_logic.extension.setNamespace

plugins {
alias(libs.plugins.terning.library)
}

android {
setNamespace("core.navigator")
}
4 changes: 4 additions & 0 deletions core/navigator/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,9 @@
package com.terning.navigator

import android.content.Intent

interface NavigatorProvider {
fun getMainActivityIntent(
deeplink: String?,
): Intent
}
11 changes: 8 additions & 3 deletions feature/main/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ android {
}

dependencies {
// core
implementation(projects.core.firebase)
implementation(projects.core.navigator)

//domain
implementation(projects.domain.token)

// feature
implementation(projects.feature.calendar)
implementation(projects.feature.dialog)
Expand All @@ -18,7 +25,5 @@ dependencies {
implementation(projects.feature.mypage)
implementation(projects.feature.onboarding)
implementation(projects.feature.search)

//domain
implementation(projects.domain.token)
implementation(projects.feature.splash)
}
20 changes: 19 additions & 1 deletion feature/main/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,26 @@

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />

</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data android:scheme="terning" />
</intent-filter>
</activity>
<service
android:name="com.terning.core.firebase.remoteconfig.messageservice.TerningMessagingService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<meta-data
android:name="com.google.firebase.messaging.default_notification_channel_id"
android:value="@string/default_notification_channel_id" />
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.terning.feature.main

import android.content.Context
import android.content.Intent
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
Expand All @@ -22,11 +24,24 @@ class MainActivity : ComponentActivity() {
enableEdgeToEdge()
setContent {
val navigator: MainNavigator = rememberMainNavigator()
val redirect: String? = intent.data?.getQueryParameter(REDIRECT)

TerningPointTheme {
CompositionLocalProvider(LocalTracker provides tracker) {
MainScreen(navigator)
MainScreen(
redirect = redirect,
navigator = navigator
)
}
}
}
}

companion object {
private const val REDIRECT: String = "redirect"

fun getIntent(
context: Context,
) = Intent(context, MainActivity::class.java)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,18 @@ import androidx.navigation.navOptions
import com.terning.feature.calendar.calendar.navigation.navigateCalendar
import com.terning.feature.home.navigation.navigateHome
import com.terning.feature.mypage.mypage.navigation.navigateMyPage
import com.terning.feature.onboarding.splash.navigation.Splash
import com.terning.feature.search.search.navigation.navigateSearch
import com.terning.feature.splash.navigation.Splash

class MainNavigator(
val navController: NavHostController,
) {

private val currentDestination: NavDestination?
@Composable get() = navController
.currentBackStackEntryAsState().value?.destination

val startDestination = Splash
fun getStartDestination(redirect: String?) = Splash(redirect = redirect)

val currentTab: MainTab?
@Composable get() = MainTab.find { tab ->
Expand All @@ -30,12 +31,12 @@ class MainNavigator(

fun navigate(tab: MainTab) {
val navOptions = navOptions {
navController.currentDestination?.route?.let {
popUpTo(it){
inclusive = true
saveState = true
}
}
navController.currentDestination?.route?.let {
popUpTo(it) {
inclusive = true
saveState = true
}
}
launchSingleTop = true
restoreState = true
}
Expand All @@ -48,10 +49,6 @@ class MainNavigator(
}
}

fun navigateUp() {
navController.navigateUp()
}

@Composable
fun showBottomBar() = MainTab.contains {
currentDestination?.hasRoute(it::class) == true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import androidx.navigation.NavOptions
import androidx.navigation.compose.NavHost
import androidx.navigation.navOptions
import com.terning.core.analytics.EventType
import com.terning.core.analytics.LocalTracker
import com.terning.core.designsystem.component.snackbar.TerningBasicSnackBar
import com.terning.core.designsystem.theme.White
import com.terning.feature.calendar.calendar.navigation.calendarNavGraph
Expand All @@ -48,16 +49,17 @@ import com.terning.feature.onboarding.signin.navigation.navigateSignIn
import com.terning.feature.onboarding.signin.navigation.signInNavGraph
import com.terning.feature.onboarding.signup.navigation.navigateSignUp
import com.terning.feature.onboarding.signup.navigation.signUpNavGraph
import com.terning.feature.onboarding.splash.navigation.Splash
import com.terning.feature.onboarding.splash.navigation.splashNavGraph
import com.terning.feature.search.search.navigation.searchNavGraph
import com.terning.feature.search.searchprocess.navigation.navigateSearchProcess
import com.terning.feature.search.searchprocess.navigation.searchProcessNavGraph
import com.terning.feature.splash.navigation.Splash
import com.terning.feature.splash.navigation.splashNavGraph
import kotlinx.collections.immutable.toImmutableList
import kotlinx.coroutines.launch

@Composable
fun MainScreen(
redirect: String?,
navigator: MainNavigator = rememberMainNavigator(),
) {
val context = LocalContext.current
Expand All @@ -67,7 +69,7 @@ fun MainScreen(
val snackBarHostState = remember { SnackbarHostState() }
val coroutineScope = rememberCoroutineScope()

val amplitudeTracker = com.terning.core.analytics.LocalTracker.current
val amplitudeTracker = LocalTracker.current

BackHandler(enabled = backPressedState) {
if (System.currentTimeMillis() - backPressedTime <= 3000) {
Expand Down Expand Up @@ -135,25 +137,25 @@ fun MainScreen(
ExitTransition.None
},
navController = navigator.navController,
startDestination = navigator.startDestination
startDestination = navigator.getStartDestination(redirect)
) {
splashNavGraph(
navigateHome = {
navigator.navController.navigateHome(
navOptions = NavOptions.Builder().setPopUpTo(
route = Splash,
route = Splash(redirect),
inclusive = true
).build()
)
},
navigateSignIn = {
navigator.navController.navigateSignIn(
navOptions = NavOptions.Builder().setPopUpTo(
route = Splash,
route = Splash(redirect),
inclusive = true
).build()
)
}
},
)
homeNavGraph(
paddingValues = paddingValues,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.terning.feature.main.navigator

import android.content.Context
import android.content.Intent
import com.terning.feature.main.MainActivity
import com.terning.navigator.NavigatorProvider
import dagger.hilt.android.qualifiers.ApplicationContext
import javax.inject.Inject

class NavigatorProviderIntent @Inject constructor(
@ApplicationContext private val context: Context,
) : NavigatorProvider {
override fun getMainActivityIntent(deeplink: String?): Intent =
MainActivity.getIntent(context = context)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.terning.feature.main.navigator.di

import com.terning.feature.main.navigator.NavigatorProviderIntent
import com.terning.navigator.NavigatorProvider
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
interface NavigatorModule {
@Binds
@Singleton
fun bindNavigatorIntent(navigatorProviderIntent: NavigatorProviderIntent): NavigatorProvider
}
Loading