Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
6 changes: 3 additions & 3 deletions Near/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:icon="@mipmap/ic_launcher_round"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
Expand All @@ -20,7 +20,7 @@
<meta-data
android:name="com.kakao.sdk.AppKey"
android:value="${kakaoAppKey}" />

<!-- 카카오톡 로그인 콜백을 위한 Activity -->
<activity
android:name="com.kakao.sdk.auth.AuthCodeHandlerActivity"
Expand All @@ -33,7 +33,7 @@
android:scheme="kakao${kakaoAppKey}" />
</intent-filter>
</activity>

<activity
android:name=".presentation.feature.main.MainActivity"
android:exported="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private fun LoginIntroductionSection(modifier: Modifier = Modifier) {
Image(
modifier = modifier.wrapContentSize(Alignment.Center),
alignment = Alignment.Center,
painter = painterResource(R.drawable.ic_near_logo_title),
painter = painterResource(R.drawable.ic_near_logo_title_primary),
contentDescription = stringResource(R.string.near_logo_title),
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
import androidx.navigation.navOptions
import com.alarmy.near.presentation.feature.friendprofile.navigation.friendProfileNavGraph
import com.alarmy.near.presentation.feature.friendprofile.navigation.navigateToFriendProfile
import com.alarmy.near.presentation.feature.friendprofileedittor.navigation.friendProfileEditorNavGraph
import com.alarmy.near.presentation.feature.home.navigation.RouteHome
import com.alarmy.near.presentation.feature.home.navigation.homeNavGraph
import com.alarmy.near.presentation.feature.home.navigation.navigateToHome
import com.alarmy.near.presentation.feature.login.navigation.RouteLogin
import com.alarmy.near.presentation.feature.login.navigation.loginNavGraph
import com.alarmy.near.presentation.feature.login.navigation.navigateToLogin
import com.alarmy.near.presentation.feature.splash.navigation.RouteSplash
import com.alarmy.near.presentation.feature.splash.navigation.splashNavGraph

@Composable
internal fun NearNavHost(
Expand All @@ -25,20 +28,39 @@ internal fun NearNavHost(
NavHost(
modifier = modifier,
navController = navController,
startDestination = RouteLogin,
startDestination = RouteSplash,
) {

// 스플래쉬 화면 NavGraph
splashNavGraph(
onNavigateToLogin = {
navController.navigateToLogin(
navOptions = navOptions {
popUpTo(RouteSplash) { inclusive = true }
}
)
},
onNavigateToHome = {
navController.navigateToHome(
navOptions = navOptions {
popUpTo(RouteSplash) { inclusive = true }
}
)
}
)

// 로그인 화면 NavGraph
loginNavGraph(
onShowErrorSnackBar = onShowSnackbar,
onNavigateToHome = {
navController.navigateToHome(
navOptions = androidx.navigation.navOptions {
navOptions = navOptions {
popUpTo(RouteLogin) { inclusive = true }
}
)
}
)

// 홈 화면 NavGraph
homeNavGraph(
onShowErrorSnackBar = onShowSnackbar,
Expand All @@ -49,15 +71,15 @@ internal fun NearNavHost(
onAlarmClick = {},
onAddContactClick = {},
)

// 친구 프로필 화면 NavGraph
friendProfileNavGraph(
onShowErrorSnackBar = onShowSnackbar,
onClickBackButton = {
navController.popBackStack()
}
)

// 친구 프로필 편집 화면 NavGraph
friendProfileEditorNavGraph(
onShowErrorSnackBar = onShowSnackbar,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package com.alarmy.near.presentation.feature.splash

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.hilt.navigation.compose.hiltViewModel
import com.alarmy.near.R

@Composable
fun SplashScreen(
onNavigateToLogin: () -> Unit,
onNavigateToHome: () -> Unit,
viewModel: SplashViewModel = hiltViewModel(),
) {
LaunchedEffect(Unit) {
viewModel.checkLoginStatusAndNavigate(
onNavigateToLogin = onNavigateToLogin,
onNavigateToHome = onNavigateToHome,
)
}

SplashContent()
}

@Composable
private fun SplashContent() {
Box(
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.Center,
) {
Image(
modifier = Modifier.fillMaxSize(),
painter = painterResource(id = R.drawable.img_bg),
contentDescription = stringResource(R.string.near_splash_background),
contentScale = ContentScale.Crop,
)

Image(
painter = painterResource(id = R.drawable.ic_near_logo_title_white),
contentDescription = stringResource(R.string.near_logo_title),
)
}
}


@Preview
@Composable
fun SplashScreenPreview() {
SplashContent()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.alarmy.near.presentation.feature.splash

import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.alarmy.near.data.repository.AuthRepository
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import javax.inject.Inject

@HiltViewModel
class SplashViewModel @Inject constructor(
private val authRepository: AuthRepository,
): ViewModel() {

// 로그인 상태 확인 및 화면 전환
fun checkLoginStatusAndNavigate(
onNavigateToLogin: () -> Unit,
onNavigateToHome: () -> Unit,
) {
viewModelScope.launch {
runCatching {
delay(SPLASH_DELAY_MILLIS)
authRepository.isLoggedIn()
}.onSuccess { isLoggedIn ->
when(isLoggedIn) {
true -> { onNavigateToHome() }
false -> { onNavigateToLogin() }
}
}.onFailure { exception ->
onNavigateToLogin()
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

현재 checkLoginStatusAndNavigate 함수는 delay를 먼저 실행한 후 로그인 상태를 확인하고 있어, 앱 시작 시간이 불필요하게 길어질 수 있습니다. 예를 들어, 로그인 상태 확인에 200ms가 걸린다면, 총 스플래시 시간은 1000ms + 200ms = 1200ms가 됩니다.

로그인 상태 확인과 최소 스플래시 시간 보장을 병렬로 처리하여 사용자 경험을 개선하는 것이 좋습니다. 아래와 같이 수정하면 로그인 상태를 확인하는 동안 최소 스플래시 시간을 보장할 수 있어, 전체 대기 시간을 줄일 수 있습니다.

            val startTime = System.currentTimeMillis()
            val isLoggedInResult = runCatching { authRepository.isLoggedIn() }
            val elapsedTime = System.currentTimeMillis() - startTime

            val remainingDelay = SPLASH_DELAY_MILLIS - elapsedTime
            if (remainingDelay > 0) {
                delay(remainingDelay)
            }

            if (isLoggedInResult.getOrNull() == true) {
                onNavigateToHome()
            } else {
                onNavigateToLogin()
            }

}
}

companion object {
const val SPLASH_DELAY_MILLIS = 1000L
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

companion object는 이 클래스에서 하나의 상수를 선언하기 위해 사용하기에는 다소 과합니다. Kotlin에서는 파일 최상단에 private const val로 선언하는 것이 더 일반적이고 간결한 방법입니다.

아래와 같이 companion object를 제거하고, 파일 상단(package 선언 아래)에 상수를 이동하는 것을 권장합니다.

// Near/app/src/main/java/com/alarmy/near/presentation/feature/splash/SplashViewModel.kt
package com.alarmy.near.presentation.feature.splash

import ...

private const val SPLASH_DELAY_MILLIS = 1000L

@HiltViewModel
class SplashViewModel ... {
    // ...
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.alarmy.near.presentation.feature.splash.navigation

import androidx.navigation.NavGraphBuilder
import androidx.navigation.compose.composable
import com.alarmy.near.presentation.feature.splash.SplashScreen
import kotlinx.serialization.Serializable

@Serializable
object RouteSplash

fun NavGraphBuilder.splashNavGraph(
onNavigateToLogin: () -> Unit,
onNavigateToHome: () -> Unit,
) {
composable<RouteSplash> {
SplashScreen(
onNavigateToLogin = onNavigateToLogin,
onNavigateToHome = onNavigateToHome,
)
}
}
Binary file added Near/app/src/main/res/drawable-hdpi/img_bg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Near/app/src/main/res/drawable-xhdpi/img_bg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Near/app/src/main/res/drawable-xxhdpi/img_bg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Near/app/src/main/res/drawable-xxxhdpi/img_bg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 31 additions & 28 deletions Near/app/src/main/res/drawable/ic_launcher_foreground.xml
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
<aapt:attr name="android:fillColor">
<gradient
android:endX="85.84757"
android:endY="92.4963"
android:startX="42.9492"
android:startY="49.59793"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
</vector>
android:width="100dp"
android:height="101dp"
android:viewportWidth="100"
android:viewportHeight="101">
<path
android:pathData="M49.68,12C66.06,12 79.88,22.94 84.24,37.9C88.31,36.32 93.04,37.89 95.29,41.79C97.78,46.1 96.3,51.6 92,54.09L86.8,57.09C85.98,57.56 85.12,57.89 84.25,58.08C79.88,73.06 66.06,84 49.68,84C33.25,84 19.4,73 15.08,57.96C14.36,57.77 13.66,57.48 12.99,57.09L7.8,54.09C3.49,51.6 2.02,46.1 4.5,41.79C6.68,38.02 11.18,36.42 15.16,37.76C19.57,22.87 33.35,12 49.68,12Z">
<aapt:attr name="android:fillColor">
<gradient
android:centerX="59.58"
android:centerY="55.13"
android:gradientRadius="54.35"
android:type="radial">
<item android:offset="0.17" android:color="#FF8ACCFF"/>
<item android:offset="1" android:color="#FFD9EEFF"/>
</gradient>
</aapt:attr>
</path>
<path
android:pathData="M43.25,40.25m-2.25,0a2.25,2.25 0,1 1,4.5 0a2.25,2.25 0,1 1,-4.5 0"
android:fillColor="#1A1A1A"/>
<path
android:pathData="M52.47,44.38C52.76,44.38 53.01,44.61 52.95,44.9C52.91,45.06 52.86,45.23 52.8,45.38C52.67,45.7 52.47,45.99 52.23,46.23C51.99,46.48 51.7,46.67 51.38,46.8C51.06,46.93 50.72,47 50.38,47C50.03,47 49.69,46.93 49.37,46.8C49.05,46.67 48.76,46.48 48.52,46.23C48.28,45.99 48.08,45.7 47.95,45.38C47.89,45.23 47.84,45.06 47.8,44.9C47.74,44.61 47.99,44.38 48.28,44.38L50.38,44.38H52.47Z"
android:fillColor="#1A1A1A"/>
<path
android:pathData="M56.75,40.25m-2.25,0a2.25,2.25 0,1 1,4.5 0a2.25,2.25 0,1 1,-4.5 0"
android:fillColor="#1A1A1A"/>
<path
android:pathData="M33,92a16,3 0,1 0,32 0a16,3 0,1 0,-32 0z"
android:fillColor="#8ACCFF"
android:fillAlpha="0.17"/>
</vector>
18 changes: 18 additions & 0 deletions Near/app/src/main/res/drawable/ic_near_logo_title_white.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="100dp"
android:height="27dp"
android:viewportWidth="100"
android:viewportHeight="27">
<path
android:pathData="M85.89,26V1H89.64V7.15C89.77,6.72 90.02,6.15 90.39,5.45C90.79,4.72 91.36,3.98 92.09,3.25C92.82,2.52 93.74,1.9 94.84,1.4C95.97,0.87 97.31,0.6 98.84,0.6H99.09V4.35H98.64C96.77,4.35 95.16,4.87 93.79,5.9C92.46,6.9 91.42,8.22 90.69,9.85C89.99,11.45 89.64,13.17 89.64,15V26H85.89Z"
android:fillColor="#ffffff"/>
<path
android:pathData="M66.83,26.4C64.39,26.4 62.26,25.83 60.43,24.7C58.63,23.53 57.23,21.97 56.23,20C55.23,18.03 54.73,15.87 54.73,13.5C54.73,11.1 55.23,8.93 56.23,7C57.23,5.03 58.63,3.48 60.43,2.35C62.26,1.18 64.39,0.6 66.83,0.6C68.89,0.6 70.66,1 72.13,1.8C73.63,2.6 74.84,3.68 75.78,5.05V1H79.53V26H75.78V22C74.84,23.33 73.63,24.4 72.13,25.2C70.66,26 68.89,26.4 66.83,26.4ZM67.33,23C69.19,23 70.76,22.57 72.03,21.7C73.33,20.83 74.31,19.68 74.98,18.25C75.64,16.78 75.98,15.2 75.98,13.5C75.98,11.77 75.64,10.18 74.98,8.75C74.31,7.32 73.33,6.17 72.03,5.3C70.76,4.43 69.19,4 67.33,4C65.49,4 63.91,4.43 62.58,5.3C61.24,6.17 60.23,7.32 59.53,8.75C58.83,10.18 58.48,11.77 58.48,13.5C58.48,15.2 58.83,16.78 59.53,18.25C60.23,19.68 61.24,20.83 62.58,21.7C63.91,22.57 65.49,23 67.33,23Z"
android:fillColor="#ffffff"/>
<path
android:pathData="M39.67,26.4C37.14,26.4 34.92,25.83 33.02,24.7C31.12,23.53 29.64,21.97 28.57,20C27.54,18.03 27.02,15.87 27.02,13.5C27.02,11.1 27.52,8.93 28.52,7C29.52,5.03 30.96,3.48 32.82,2.35C34.69,1.18 36.89,0.6 39.42,0.6C41.99,0.6 44.19,1.18 46.02,2.35C47.89,3.48 49.32,5.03 50.32,7C51.32,8.93 51.82,11.1 51.82,13.5V15H30.87C31.07,16.47 31.54,17.82 32.27,19.05C33.04,20.25 34.06,21.22 35.32,21.95C36.59,22.65 38.06,23 39.72,23C41.49,23 42.97,22.62 44.17,21.85C45.37,21.05 46.31,20.03 46.97,18.8H51.07C50.21,21.03 48.82,22.87 46.92,24.3C45.06,25.7 42.64,26.4 39.67,26.4ZM30.92,11.5H47.92C47.59,9.37 46.69,7.58 45.22,6.15C43.76,4.72 41.82,4 39.42,4C37.02,4 35.09,4.72 33.62,6.15C32.19,7.58 31.29,9.37 30.92,11.5Z"
android:fillColor="#ffffff"/>
<path
android:pathData="M0.38,26V1H4.13V4.9C5.03,3.7 6.13,2.68 7.43,1.85C8.73,1.02 10.39,0.6 12.43,0.6C14.16,0.6 15.77,1.02 17.27,1.85C18.81,2.65 20.04,3.87 20.98,5.5C21.94,7.1 22.42,9.08 22.42,11.45V26H18.67V11.55C18.67,9.28 18.02,7.47 16.73,6.1C15.43,4.7 13.74,4 11.68,4C10.27,4 9.01,4.32 7.88,4.95C6.74,5.58 5.82,6.48 5.13,7.65C4.46,8.78 4.13,10.1 4.13,11.6V26H0.38Z"
android:fillColor="#ffffff"/>
</vector>
6 changes: 0 additions & 6 deletions Near/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml

This file was deleted.

6 changes: 2 additions & 4 deletions Near/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
<foreground android:drawable="@mipmap/ic_launcher"/>
</adaptive-icon>
Binary file added Near/app/src/main/res/mipmap-hdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed Near/app/src/main/res/mipmap-hdpi/ic_launcher.webp
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file added Near/app/src/main/res/mipmap-mdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed Near/app/src/main/res/mipmap-mdpi/ic_launcher.webp
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed Near/app/src/main/res/mipmap-xhdpi/ic_launcher.webp
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed Near/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
3 changes: 3 additions & 0 deletions Near/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
<string name="common_back_button_description">뒤로 가기</string>
<string name="common_menu_button_description">메뉴</string>

<!-- 스플래쉬 (Splash) -->
<string name="near_splash_background">스플래쉬 배경</string>

<!-- 로그인 (Login) -->
<string name="near_logo">Near 로고</string>
<string name="near_logo_title">Near 타이틀</string>
Expand Down