From 143d4c462a4cb83f7c3da9575a034854dedab8cc Mon Sep 17 00:00:00 2001 From: bemusementpark Date: Fri, 26 Jul 2024 09:47:57 +0930 Subject: [PATCH] Show Account Created empty view only for newAccounts --- .../securesms/home/HomeActivity.kt | 20 +++++++++---------- .../onboarding/loading/LoadingActivity.kt | 2 +- .../MessageNotificationsActivity.kt | 2 +- .../pickname/PickDisplayNameActivity.kt | 2 +- 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/home/HomeActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/home/HomeActivity.kt index ee82a708c4..ff520f3e81 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/home/HomeActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/home/HomeActivity.kt @@ -80,16 +80,14 @@ import org.thoughtcrime.securesms.util.start import java.io.IOException import javax.inject.Inject +private const val NEW_ACCOUNT = "HomeActivity_NEW_ACCOUNT" +private const val FROM_ONBOARDING = "HomeActivity_FROM_ONBOARDING" + @AndroidEntryPoint class HomeActivity : PassphraseRequiredActionBarActivity(), ConversationClickListener, GlobalSearchInputLayout.GlobalSearchInputLayoutListener { - companion object { - const val NEW_ACCOUNT = "HomeActivity_NEW_ACCOUNT" - const val FROM_ONBOARDING = "HomeActivity_FROM_ONBOARDING" - } - private lateinit var binding: ActivityHomeBinding private lateinit var glide: GlideRequests @@ -137,7 +135,8 @@ class HomeActivity : PassphraseRequiredActionBarActivity(), } } - private val isNewAccount: Boolean get() = intent.getBooleanExtra(FROM_ONBOARDING, false) + private val isFromOnboarding: Boolean get() = intent.getBooleanExtra(FROM_ONBOARDING, false) + private val isNewAccount: Boolean get() = intent.getBooleanExtra(NEW_ACCOUNT, false) // region Lifecycle override fun onCreate(savedInstanceState: Bundle?, isReady: Boolean) { @@ -266,8 +265,7 @@ class HomeActivity : PassphraseRequiredActionBarActivity(), } } EventBus.getDefault().register(this@HomeActivity) - if (intent.hasExtra(FROM_ONBOARDING) - && intent.getBooleanExtra(FROM_ONBOARDING, false)) { + if (isFromOnboarding) { if (Build.VERSION.SDK_INT >= 33 && (getSystemService(NOTIFICATION_SERVICE) as NotificationManager).areNotificationsEnabled().not()) { Permissions.with(this) @@ -639,10 +637,10 @@ class HomeActivity : PassphraseRequiredActionBarActivity(), } } -fun Context.startHomeActivity(isNewAccount: Boolean) { +fun Context.startHomeActivity(isFromOnboarding: Boolean, isNewAccount: Boolean) { Intent(this, HomeActivity::class.java).apply { flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK - putExtra(HomeActivity.NEW_ACCOUNT, true) - putExtra(HomeActivity.FROM_ONBOARDING, true) + putExtra(NEW_ACCOUNT, isNewAccount) + putExtra(FROM_ONBOARDING, isFromOnboarding) }.also(::startActivity) } diff --git a/app/src/main/java/org/thoughtcrime/securesms/onboarding/loading/LoadingActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/onboarding/loading/LoadingActivity.kt index 9c8a1869d4..abf0471598 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/onboarding/loading/LoadingActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/onboarding/loading/LoadingActivity.kt @@ -32,7 +32,7 @@ class LoadingActivity: BaseActionBarActivity() { when { loadFailed -> startPickDisplayNameActivity(loadFailed = true) - else -> startHomeActivity(isNewAccount = false) + else -> startHomeActivity(isNewAccount = false, isFromOnboarding = true) } finish() diff --git a/app/src/main/java/org/thoughtcrime/securesms/onboarding/messagenotifications/MessageNotificationsActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/onboarding/messagenotifications/MessageNotificationsActivity.kt index 42cf49bce8..9ea4fd2bd6 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/onboarding/messagenotifications/MessageNotificationsActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/onboarding/messagenotifications/MessageNotificationsActivity.kt @@ -49,7 +49,7 @@ class MessageNotificationsActivity : BaseActionBarActivity() { viewModel.events.collect { when (it) { Event.Loading -> start() - Event.OnboardingComplete -> startHomeActivity(isNewAccount = true) + Event.OnboardingComplete -> startHomeActivity(isNewAccount = true, isFromOnboarding = true) } } } diff --git a/app/src/main/java/org/thoughtcrime/securesms/onboarding/pickname/PickDisplayNameActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/onboarding/pickname/PickDisplayNameActivity.kt index 97aacf82e6..8ade5b4e8e 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/onboarding/pickname/PickDisplayNameActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/onboarding/pickname/PickDisplayNameActivity.kt @@ -45,7 +45,7 @@ class PickDisplayNameActivity : BaseActionBarActivity() { viewModel.events.collect { when (it) { is Event.CreateAccount -> startMessageNotificationsActivity(it.profileName) - Event.LoadAccountComplete -> startHomeActivity(isNewAccount = false) + Event.LoadAccountComplete -> startHomeActivity(isNewAccount = false, isFromOnboarding = true) } } }