Skip to content

Commit

Permalink
feat : Onboarding skip
Browse files Browse the repository at this point in the history
온보딩을 한번 확인했다면 스킵
  • Loading branch information
kkh725 committed Aug 21, 2024
1 parent e512605 commit 60c21d2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
26 changes: 22 additions & 4 deletions app/src/main/java/com/echoist/linkedout/SharedPreferencesUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -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()) {
Expand All @@ -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, "")
Expand All @@ -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()) {
Expand All @@ -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()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -503,6 +507,8 @@ fun LoginPage(
//앱버전 체크 후 최신버전 아닌경우 마켓업데이트.
LaunchedEffect(key1 = Unit) {
viewModel.requestAppVersion(context)
//온보딩 확인했다는 체크
SharedPreferencesUtil.saveIsOnboardingFinished(context,true)

//자동로그인 체크시 로그인.
if (SharedPreferencesUtil.getClickedAutoLogin(context = context)){
Expand Down

0 comments on commit 60c21d2

Please sign in to comment.