Show Account Created empty view only for newAccounts

This commit is contained in:
bemusementpark 2024-07-26 09:47:57 +09:30
parent 66c78847d8
commit 143d4c462a
4 changed files with 12 additions and 14 deletions

View File

@ -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)
}

View File

@ -32,7 +32,7 @@ class LoadingActivity: BaseActionBarActivity() {
when {
loadFailed -> startPickDisplayNameActivity(loadFailed = true)
else -> startHomeActivity(isNewAccount = false)
else -> startHomeActivity(isNewAccount = false, isFromOnboarding = true)
}
finish()

View File

@ -49,7 +49,7 @@ class MessageNotificationsActivity : BaseActionBarActivity() {
viewModel.events.collect {
when (it) {
Event.Loading -> start<LoadingActivity>()
Event.OnboardingComplete -> startHomeActivity(isNewAccount = true)
Event.OnboardingComplete -> startHomeActivity(isNewAccount = true, isFromOnboarding = true)
}
}
}

View File

@ -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)
}
}
}