diff --git a/app/src/main/java/com/echoist/linkedout/SharedPreferencesUtil.kt b/app/src/main/java/com/echoist/linkedout/SharedPreferencesUtil.kt index bd398d37..7abc432c 100644 --- a/app/src/main/java/com/echoist/linkedout/SharedPreferencesUtil.kt +++ b/app/src/main/java/com/echoist/linkedout/SharedPreferencesUtil.kt @@ -21,6 +21,7 @@ object SharedPreferencesUtil { private val minuteMap = (0..5).associateWith { (it * 10).toString().padStart(2, '0') } data class LocalAccountInfo(val id: String, val pw: String) + //셀프알림 리마인드 true, false 설정 fun saveWritingRemindNotification(context: Context, writingRemindNotification: Boolean) { val sharedPreferences: SharedPreferences = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE) with(sharedPreferences.edit()) { @@ -35,6 +36,7 @@ object SharedPreferencesUtil { return displayInfo } + //디스플레이 화이트, 다크 버전 fun saveDisplayInfo(context: Context, displayInfo: String) { val sharedPreferences: SharedPreferences = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE) with(sharedPreferences.edit()) { @@ -43,6 +45,13 @@ object SharedPreferencesUtil { } } + fun getDisplayInfo(context: Context) : String{ + val sharedPreferences: SharedPreferences = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE) + val displayInfo = sharedPreferences.getString(DISPLAY_INFO, "") + return displayInfo!! + } + + //자동로그인 아이디 비밀번호 저장 fun getLocalAccountInfo(context: Context) : LocalAccountInfo{ val sharedPreferences: SharedPreferences = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE) val accountInfoId = sharedPreferences.getString(ID_LOCAL_STORAGE, "") @@ -59,6 +68,7 @@ object SharedPreferencesUtil { } } + //자동로그인 클릭 변수저장 fun saveClickedAutoLogin(context: Context, isClickedAutoLogin: Boolean) { val sharedPreferences: SharedPreferences = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE) with(sharedPreferences.edit()) { @@ -73,12 +83,20 @@ object SharedPreferencesUtil { return isClickedAutoLogin } - fun getDisplayInfo(context: Context) : String{ + //온보딩 일회성 + fun saveIsOnboardingFinished(context: Context, isOnboardingFinished: Boolean) { val sharedPreferences: SharedPreferences = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE) - val displayInfo = sharedPreferences.getString(DISPLAY_INFO, "") - return displayInfo!! + with(sharedPreferences.edit()) { + putBoolean("isOnboardingFinished", isOnboardingFinished) + apply() + } } - + fun getIsOnboardingFinished(context: Context) : Boolean{ + val sharedPreferences: SharedPreferences = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE) + val isOnboardingFinished = sharedPreferences.getBoolean("isOnboardingFinished", false) + return isOnboardingFinished + } + //알림 시간 저장 fun saveTimeSelection(context: Context, timeSelection: TimeSelectionIndex) { val sharedPreferences: SharedPreferences = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE) with(sharedPreferences.edit()) { diff --git a/app/src/main/java/com/echoist/linkedout/page/login/LoginPage.kt b/app/src/main/java/com/echoist/linkedout/page/login/LoginPage.kt index f452747f..f8286941 100644 --- a/app/src/main/java/com/echoist/linkedout/page/login/LoginPage.kt +++ b/app/src/main/java/com/echoist/linkedout/page/login/LoginPage.kt @@ -193,12 +193,16 @@ class LoginPage : ComponentActivity() { //top,bottom 시스템 바 등의 설정 WindowCompat.setDecorFitsSystemWindows(window, false) + //온보딩을 한번 진행했다면 다음부턴 안나오게. + val isOnboardingFinished = SharedPreferencesUtil.getIsOnboardingFinished(this) + val startDestination = if (isOnboardingFinished) Routes.LoginPage else Routes.OnBoarding + setContent { val keyHash = Utility.getKeyHash(this) Log.d("Hash", keyHash) val navController = rememberNavController() - NavHost(navController = navController, startDestination = Routes.OnBoarding) { + NavHost(navController = navController, startDestination = startDestination) { composable(Routes.OnBoarding) { OnBoardingPage(navController) } @@ -503,6 +507,8 @@ fun LoginPage( //앱버전 체크 후 최신버전 아닌경우 마켓업데이트. LaunchedEffect(key1 = Unit) { viewModel.requestAppVersion(context) + //온보딩 확인했다는 체크 + SharedPreferencesUtil.saveIsOnboardingFinished(context,true) //자동로그인 체크시 로그인. if (SharedPreferencesUtil.getClickedAutoLogin(context = context)){