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