mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-19 19:48:27 +00:00
Cleanup new account empty logic
This commit is contained in:
parent
e001ccb283
commit
85ee87f619
@ -156,8 +156,6 @@ public class ApplicationContext extends Application implements DefaultLifecycleO
|
||||
|
||||
private volatile boolean isAppVisible;
|
||||
|
||||
public boolean newAccount = false;
|
||||
|
||||
@Override
|
||||
public Object getSystemService(String name) {
|
||||
if (MessagingModuleConfiguration.MESSAGING_MODULE_SERVICE.equals(name)) {
|
||||
|
@ -4,7 +4,6 @@ import android.content.Context
|
||||
import android.content.res.Resources
|
||||
import android.graphics.Typeface
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.text.SpannableString
|
||||
import android.text.TextUtils
|
||||
import android.util.AttributeSet
|
||||
import android.util.TypedValue
|
||||
@ -22,7 +21,6 @@ import org.thoughtcrime.securesms.database.RecipientDatabase.NOTIFY_TYPE_ALL
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.NOTIFY_TYPE_NONE
|
||||
import org.thoughtcrime.securesms.database.model.ThreadRecord
|
||||
import org.thoughtcrime.securesms.dependencies.ConfigFactory
|
||||
import org.thoughtcrime.securesms.mms.GlideRequests
|
||||
import org.thoughtcrime.securesms.util.DateUtils
|
||||
import org.thoughtcrime.securesms.util.getAccentColor
|
||||
import org.thoughtcrime.securesms.util.getConversationUnread
|
||||
@ -50,7 +48,7 @@ class ConversationView : LinearLayout {
|
||||
// endregion
|
||||
|
||||
// region Updating
|
||||
fun bind(thread: ThreadRecord, isTyping: Boolean, glide: GlideRequests) {
|
||||
fun bind(thread: ThreadRecord, isTyping: Boolean) {
|
||||
this.thread = thread
|
||||
if (thread.isPinned) {
|
||||
binding.conversationViewDisplayNameTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(
|
||||
@ -141,11 +139,10 @@ class ConversationView : LinearLayout {
|
||||
else -> recipient.toShortString() // Internally uses the Contact API
|
||||
}
|
||||
|
||||
private fun ThreadRecord.getSnippet(): CharSequence =
|
||||
concatSnippet(getSnippetPrefix(), getDisplayBody(context))
|
||||
|
||||
private fun concatSnippet(prefix: CharSequence?, body: CharSequence): CharSequence =
|
||||
prefix?.let { TextUtils.concat(it, ": ", body) } ?: body
|
||||
private fun ThreadRecord.getSnippet(): CharSequence = listOfNotNull(
|
||||
getSnippetPrefix(),
|
||||
getDisplayBody(context)
|
||||
).joinToString { ": " }
|
||||
|
||||
private fun ThreadRecord.getSnippetPrefix(): CharSequence? = when {
|
||||
recipient.isLocalNumber || lastMessage?.isControlMessage == true -> null
|
||||
|
@ -86,6 +86,7 @@ class HomeActivity : PassphraseRequiredActionBarActivity(),
|
||||
GlobalSearchInputLayout.GlobalSearchInputLayoutListener {
|
||||
|
||||
companion object {
|
||||
const val NEW_ACCOUNT = "HomeActivity_NEW_ACCOUNT"
|
||||
const val FROM_ONBOARDING = "HomeActivity_FROM_ONBOARDING"
|
||||
}
|
||||
|
||||
@ -136,6 +137,8 @@ class HomeActivity : PassphraseRequiredActionBarActivity(),
|
||||
}
|
||||
}
|
||||
|
||||
private val isNewAccount: Boolean get() = intent.getBooleanExtra(FROM_ONBOARDING, false)
|
||||
|
||||
// region Lifecycle
|
||||
override fun onCreate(savedInstanceState: Bundle?, isReady: Boolean) {
|
||||
super.onCreate(savedInstanceState, isReady)
|
||||
@ -176,7 +179,7 @@ class HomeActivity : PassphraseRequiredActionBarActivity(),
|
||||
|
||||
// Set up empty state view
|
||||
binding.emptyStateContainer.setThemedContent {
|
||||
EmptyView(ApplicationContext.getInstance(this).newAccount)
|
||||
EmptyView(isNewAccount)
|
||||
}
|
||||
|
||||
IP2Country.configureIfNeeded(this@HomeActivity)
|
||||
@ -636,9 +639,10 @@ class HomeActivity : PassphraseRequiredActionBarActivity(),
|
||||
}
|
||||
}
|
||||
|
||||
fun Context.startHomeActivity() {
|
||||
fun Context.startHomeActivity(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)
|
||||
}.also(::startActivity)
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package org.thoughtcrime.securesms.home
|
||||
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.DiffUtil
|
||||
import androidx.recyclerview.widget.ListUpdateCallback
|
||||
@ -12,8 +11,6 @@ import network.loki.messenger.R
|
||||
import network.loki.messenger.databinding.ViewMessageRequestBannerBinding
|
||||
import org.thoughtcrime.securesms.dependencies.ConfigFactory
|
||||
import org.thoughtcrime.securesms.mms.GlideRequests
|
||||
import org.thoughtcrime.securesms.util.DateUtils
|
||||
import java.util.Locale
|
||||
|
||||
class HomeAdapter(
|
||||
private val context: Context,
|
||||
@ -115,7 +112,7 @@ class HomeAdapter(
|
||||
val offset = if (hasHeaderView()) position - 1 else position
|
||||
val thread = data.threads[offset]
|
||||
val isTyping = data.typingThreadIDs.contains(thread.threadId)
|
||||
holder.view.bind(thread, isTyping, glide)
|
||||
holder.view.bind(thread, isTyping)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ import androidx.lifecycle.lifecycleScope
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import kotlinx.coroutines.launch
|
||||
import org.session.libsession.utilities.TextSecurePreferences
|
||||
import org.thoughtcrime.securesms.ApplicationContext
|
||||
import org.thoughtcrime.securesms.BaseActionBarActivity
|
||||
import org.thoughtcrime.securesms.dependencies.ConfigFactory
|
||||
import org.thoughtcrime.securesms.home.startHomeActivity
|
||||
@ -33,7 +32,7 @@ class LoadingActivity: BaseActionBarActivity() {
|
||||
|
||||
when {
|
||||
loadFailed -> startPickDisplayNameActivity(loadFailed = true)
|
||||
else -> startHomeActivity()
|
||||
else -> startHomeActivity(isNewAccount = false)
|
||||
}
|
||||
|
||||
finish()
|
||||
@ -44,8 +43,6 @@ class LoadingActivity: BaseActionBarActivity() {
|
||||
|
||||
setUpActionBarSessionLogo()
|
||||
|
||||
ApplicationContext.getInstance(this).newAccount = false
|
||||
|
||||
setComposeContent {
|
||||
val progress by viewModel.progress.collectAsState()
|
||||
LoadingScreen(progress)
|
||||
|
@ -49,7 +49,7 @@ class MessageNotificationsActivity : BaseActionBarActivity() {
|
||||
viewModel.events.collect {
|
||||
when (it) {
|
||||
Event.Loading -> start<LoadingActivity>()
|
||||
Event.OnboardingComplete -> startHomeActivity()
|
||||
Event.OnboardingComplete -> startHomeActivity(isNewAccount = true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ class PickDisplayNameActivity : BaseActionBarActivity() {
|
||||
viewModel.events.collect {
|
||||
when (it) {
|
||||
is Event.CreateAccount -> startMessageNotificationsActivity(it.profileName)
|
||||
Event.LoadAccountComplete -> startHomeActivity()
|
||||
Event.LoadAccountComplete -> startHomeActivity(isNewAccount = false)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -72,8 +72,6 @@ class PickDisplayNameActivity : BaseActionBarActivity() {
|
||||
}
|
||||
|
||||
fun Context.startPickDisplayNameActivity(loadFailed: Boolean = false, flags: Int = 0) {
|
||||
ApplicationContext.getInstance(this).newAccount = !loadFailed
|
||||
|
||||
Intent(this, PickDisplayNameActivity::class.java)
|
||||
.apply { putExtra(EXTRA_LOAD_FAILED, loadFailed) }
|
||||
.also { it.flags = flags }
|
||||
|
@ -91,14 +91,14 @@ class MentionViewModelTest {
|
||||
contactDatabase = mock {
|
||||
on { getContacts(any()) } doAnswer {
|
||||
val ids = it.arguments[0] as Collection<String>
|
||||
memberContacts.filter { contact -> contact.accountID in ids }
|
||||
memberContacts.filter { it.accountID in ids }
|
||||
}
|
||||
},
|
||||
memberDatabase = mock {
|
||||
on { getGroupMembersRoles(eq(openGroup.id), any()) } doAnswer {
|
||||
val memberIDs = it.arguments[1] as Collection<String>
|
||||
memberIDs.associateWith { id ->
|
||||
threadMembers.first { m -> m.pubKey == id }.roles
|
||||
threadMembers.first { it.pubKey == id }.roles
|
||||
}
|
||||
}
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user