Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QA] 권한 분기처리 로직 수정 #72

Merged
merged 2 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ class MotivooStorageImpl @Inject constructor(@ApplicationContext context: Contex
set(value) = pref.edit { putBoolean(IS_ONBOARDING_FINISHED, value) }
get() = pref.getBoolean(IS_ONBOARDING_FINISHED, false)

override var isFinishedPermission: Boolean
set(value) = pref.edit { putBoolean(IS_PERMISSION_FINISHED, value) }
get() = pref.getBoolean(IS_PERMISSION_FINISHED, false)

override var myGoalStepCount: Int
get() = pref.getInt(MY_GOAL_STEP_COUNT, 0)
set(value) = pref.edit { putInt(MY_GOAL_STEP_COUNT, value) }
Expand Down Expand Up @@ -121,5 +125,6 @@ class MotivooStorageImpl @Inject constructor(@ApplicationContext context: Contex
private const val OTHER_GOAL_STEP_COUNT = "other_goal_step_count"
private const val INVITE_CODE = "inviteCode"
private const val IS_ONBOARDING_FINISHED = "isOnboardingFinished"
private const val IS_PERMISSION_FINISHED = "isPermissionFinished"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ interface MotivooStorage {
var isUserMatched: Boolean
var userId: Long
var isFinishedOnboarding: Boolean
var isFinishedPermission: Boolean
var inviteCode: String
var otherId: Long
var myGoalStepCount: Int
Expand Down
18 changes: 16 additions & 2 deletions app/src/main/java/sopt/motivoo/presentation/SplashFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,24 @@ import android.view.View
import androidx.lifecycle.lifecycleScope
import androidx.navigation.NavOptions
import androidx.navigation.fragment.findNavController
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import sopt.motivoo.R
import sopt.motivoo.databinding.FragmentSplashBinding
import sopt.motivoo.domain.entity.MotivooStorage
import sopt.motivoo.util.binding.BindingFragment
import sopt.motivoo.util.findStartDestination
import javax.inject.Inject

@AndroidEntryPoint
class SplashFragment : BindingFragment<FragmentSplashBinding>(R.layout.fragment_splash) {

@Inject
lateinit var motivooStorage: MotivooStorage

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

showSplash()
}

Expand All @@ -34,6 +40,14 @@ class SplashFragment : BindingFragment<FragmentSplashBinding>(R.layout.fragment_
.setPopUpTo(startDestinationId, true)
.build()

navController.navigate(R.id.action_splashFragment_to_permissionFragment, null, navOptions)
if (motivooStorage.isFinishedPermission) {
navController.navigate(R.id.action_splashFragment_to_loginFragment, null, navOptions)
} else {
navController.navigate(
R.id.action_splashFragment_to_permissionFragment,
null,
navOptions
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ class PermissionFragment :
initRequiredPermissions()
if (checkPermissionsStatus() || isAllPermissionsGranted()) {
navigateToNextFragment()
} else if (areAllDeniedPermissionsRationale()) {
navigateToNextFragment()
} else {
getPermission()
}
Expand Down Expand Up @@ -109,13 +107,8 @@ class PermissionFragment :
requestMultiplePermissionsLauncher.launch(permissions)
}

private fun areAllDeniedPermissionsRationale(): Boolean {
return deniedPermissions.isNotEmpty() && deniedPermissions.all {
shouldShowRequestPermissionRationale(it)
}
}

private fun navigateToNextFragment() {
motivooStorage.isFinishedPermission = true
val navOptions = NavOptions.Builder()
.setPopUpTo(R.id.permissionFragment, true)
.build()
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/navigation/navigation_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
<action
android:id="@+id/action_splashFragment_to_permissionFragment"
app:destination="@id/permissionFragment" />
<action
android:id="@+id/action_splashFragment_to_loginFragment"
app:destination="@id/loginFragment" />
</fragment>
<fragment
android:id="@+id/loginFragment"
Expand Down
Loading