diff --git a/app/src/main/java/org/sopt/official/feature/home/HomeActivity.kt b/app/src/main/java/org/sopt/official/feature/home/HomeActivity.kt index 9724cd2b..d6ba20e5 100644 --- a/app/src/main/java/org/sopt/official/feature/home/HomeActivity.kt +++ b/app/src/main/java/org/sopt/official/feature/home/HomeActivity.kt @@ -152,7 +152,7 @@ class HomeActivity : AppCompatActivity() { tracker.track(type = EventType.CLICK, name = "mypage", properties = mapOf("view_type" to args?.userStatus?.value)) lifecycleScope.launch { startActivity( - MyPageActivity.getIntent(this@HomeActivity, MyPageActivity.Argument(viewModel.userActiveState.value)) + MyPageActivity.getIntent(this@HomeActivity, MyPageActivity.StartArgs(viewModel.userActiveState.value)) ) } } diff --git a/app/src/main/java/org/sopt/official/feature/navigator/NavigatorProviderIntent.kt b/app/src/main/java/org/sopt/official/feature/navigator/NavigatorProviderIntent.kt index 775ef803..c0ce58b8 100644 --- a/app/src/main/java/org/sopt/official/feature/navigator/NavigatorProviderIntent.kt +++ b/app/src/main/java/org/sopt/official/feature/navigator/NavigatorProviderIntent.kt @@ -54,7 +54,7 @@ class NavigatorProviderIntent @Inject constructor( override fun getMyPageActivityIntent(name: String) = MyPageActivity.getIntent( context, - MyPageActivity.Argument(UserActiveState.valueOf(name)) + MyPageActivity.StartArgs(UserActiveState.valueOf(name)) ) override fun getAttendanceActivityIntent() = AttendanceActivity.newInstance(context) diff --git a/app/src/main/java/org/sopt/official/feature/notification/SchemeActivity.kt b/app/src/main/java/org/sopt/official/feature/notification/SchemeActivity.kt index da1295bc..ca36e463 100644 --- a/app/src/main/java/org/sopt/official/feature/notification/SchemeActivity.kt +++ b/app/src/main/java/org/sopt/official/feature/notification/SchemeActivity.kt @@ -45,70 +45,94 @@ import javax.inject.Inject @AndroidEntryPoint class SchemeActivity : AppCompatActivity() { - @Inject - lateinit var dataStore: SoptDataStore - private val args by serializableExtra(Argument("", "")) - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - handleDeepLink() - } + @Inject + lateinit var dataStore: SoptDataStore + private val args by serializableExtra( + Argument( + "", + "" + ) + ) - private fun handleDeepLink() { - val link = args?.link - val linkIntent = when (link.isNullOrBlank()) { - true -> NotificationDetailActivity.getIntent(this, args?.notificationId.orEmpty()) - false -> checkLinkExpiration(link) + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + handleDeepLink() } - when (!isTaskRoot) { - true -> startActivity(linkIntent) - false -> TaskStackBuilder.create(this).apply { - if (!isIntentToHome(linkIntent)) { - addNextIntentWithParentStack( - DeepLinkType.getHomeIntent(UserStatus.of(dataStore.userStatus)) - ) + private fun handleDeepLink() { + val link = args?.link + val linkIntent = when (link.isNullOrBlank()) { + true -> NotificationDetailActivity.getIntent( + this, + args?.notificationId.orEmpty() + ) + + false -> checkLinkExpiration(link) + } + + when (!isTaskRoot) { + true -> startActivity(linkIntent) + false -> TaskStackBuilder.create(this).apply { + if (!isIntentToHome()) { + addNextIntentWithParentStack( + DeepLinkType.getHomeIntent(UserStatus.of(dataStore.userStatus)) + ) + } + addNextIntent(linkIntent) + }.startActivities() } - addNextIntent(linkIntent) - }.startActivities() + finish() } - finish() - } - private fun checkLinkExpiration(link: String): Intent { - return try { - val expiredAt = link.extractQueryParameter("expiredAt") - when (expiredAt.isExpiredDate()) { - true -> DeepLinkType.getHomeIntent( - UserStatus.of(dataStore.userStatus), DeepLinkType.EXPIRED - ) + private fun checkLinkExpiration(link: String): Intent { + return try { + val expiredAt = link.extractQueryParameter("expiredAt") + when (expiredAt.isExpiredDate()) { + true -> DeepLinkType.getHomeIntent( + UserStatus.of(dataStore.userStatus), + DeepLinkType.EXPIRED + ) + + else -> when (link.contains("http://") || link.contains("https://")) { + true -> Intent( + Intent.ACTION_VIEW, + Uri.parse(link) + ) - else -> when (link.contains("http://") || link.contains("https://")) { - true -> Intent(Intent.ACTION_VIEW, Uri.parse(link)) - false -> DeepLinkType.of(link).getIntent( - this, UserStatus.of(dataStore.userStatus), link - ) + false -> DeepLinkType.of(link).getIntent( + this, + UserStatus.of(dataStore.userStatus), + link + ) + } + } + } catch (exception: Exception) { + Timber.e(exception) + DeepLinkType.getHomeIntent( + UserStatus.of(dataStore.userStatus), + DeepLinkType.UNKNOWN + ) } - } - } catch (exception: Exception) { - Timber.e(exception) - DeepLinkType.getHomeIntent( - UserStatus.of(dataStore.userStatus), DeepLinkType.UNKNOWN - ) } - } - private fun Intent.isIntentToHome(): Boolean = - intent.component?.className == HomeActivity::class.java.name - } - } + private fun isIntentToHome(): Boolean = intent.component?.className == HomeActivity::class.java.name - data class Argument( - val notificationId: String, val link: String - ) : Serializable + data class Argument( + val notificationId: String, + val link: String + ) : Serializable - companion object { - @JvmStatic - fun getIntent(context: Context, args: Argument) = Intent(context, SchemeActivity::class.java).putExtra("args", args) - } + companion object { + @JvmStatic + fun getIntent( + context: Context, + args: Argument + ) = Intent( + context, + SchemeActivity::class.java + ).putExtra( + "args", + args + ) + } }