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 java.io.IOException
import javax.inject.Inject import javax.inject.Inject
private const val NEW_ACCOUNT = "HomeActivity_NEW_ACCOUNT"
private const val FROM_ONBOARDING = "HomeActivity_FROM_ONBOARDING"
@AndroidEntryPoint @AndroidEntryPoint
class HomeActivity : PassphraseRequiredActionBarActivity(), class HomeActivity : PassphraseRequiredActionBarActivity(),
ConversationClickListener, ConversationClickListener,
GlobalSearchInputLayout.GlobalSearchInputLayoutListener { 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 binding: ActivityHomeBinding
private lateinit var glide: GlideRequests 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 // region Lifecycle
override fun onCreate(savedInstanceState: Bundle?, isReady: Boolean) { override fun onCreate(savedInstanceState: Bundle?, isReady: Boolean) {
@ -266,8 +265,7 @@ class HomeActivity : PassphraseRequiredActionBarActivity(),
} }
} }
EventBus.getDefault().register(this@HomeActivity) EventBus.getDefault().register(this@HomeActivity)
if (intent.hasExtra(FROM_ONBOARDING) if (isFromOnboarding) {
&& intent.getBooleanExtra(FROM_ONBOARDING, false)) {
if (Build.VERSION.SDK_INT >= 33 && if (Build.VERSION.SDK_INT >= 33 &&
(getSystemService(NOTIFICATION_SERVICE) as NotificationManager).areNotificationsEnabled().not()) { (getSystemService(NOTIFICATION_SERVICE) as NotificationManager).areNotificationsEnabled().not()) {
Permissions.with(this) 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 { Intent(this, HomeActivity::class.java).apply {
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
putExtra(HomeActivity.NEW_ACCOUNT, true) putExtra(NEW_ACCOUNT, isNewAccount)
putExtra(HomeActivity.FROM_ONBOARDING, true) putExtra(FROM_ONBOARDING, isFromOnboarding)
}.also(::startActivity) }.also(::startActivity)
} }

View File

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

View File

@ -49,7 +49,7 @@ class MessageNotificationsActivity : BaseActionBarActivity() {
viewModel.events.collect { viewModel.events.collect {
when (it) { when (it) {
Event.Loading -> start<LoadingActivity>() 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 { viewModel.events.collect {
when (it) { when (it) {
is Event.CreateAccount -> startMessageNotificationsActivity(it.profileName) is Event.CreateAccount -> startMessageNotificationsActivity(it.profileName)
Event.LoadAccountComplete -> startHomeActivity(isNewAccount = false) Event.LoadAccountComplete -> startHomeActivity(isNewAccount = false, isFromOnboarding = true)
} }
} }
} }