mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-20 05:58:27 +00:00
fix: startup performance fixes
This commit is contained in:
parent
4d5296bb1c
commit
dd01b2968f
@ -142,7 +142,7 @@ dependencies {
|
||||
testImplementation 'org.robolectric:shadows-multidex:4.2'
|
||||
}
|
||||
|
||||
def canonicalVersionCode = 211
|
||||
def canonicalVersionCode = 214
|
||||
def canonicalVersionName = "1.11.7"
|
||||
|
||||
def postFixSize = 10
|
||||
|
@ -9,13 +9,15 @@ import org.thoughtcrime.securesms.database.model.MessageRecord
|
||||
object MentionManagerUtilities {
|
||||
|
||||
fun populateUserPublicKeyCacheIfNeeded(threadID: Long, context: Context) {
|
||||
// exit early if we need to
|
||||
if (MentionsManager.userPublicKeyCache[threadID] != null) return
|
||||
|
||||
val result = mutableSetOf<String>()
|
||||
val recipient = DatabaseFactory.getThreadDatabase(context).getRecipientForThreadId(threadID)
|
||||
if (recipient != null && recipient.address.isClosedGroup) {
|
||||
val members = DatabaseFactory.getGroupDatabase(context).getGroupMembers(recipient.address.toGroupString(), false).map { it.address.serialize() }
|
||||
result.addAll(members)
|
||||
} else {
|
||||
if (MentionsManager.userPublicKeyCache[threadID] != null) { return }
|
||||
val messageDatabase = DatabaseFactory.getMmsSmsDatabase(context)
|
||||
val reader = messageDatabase.readerFor(messageDatabase.getConversation(threadID))
|
||||
var record: MessageRecord? = reader.next
|
||||
|
@ -12,6 +12,8 @@ import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import kotlinx.android.synthetic.main.view_conversation.view.*
|
||||
import kotlinx.android.synthetic.main.view_profile_picture.view.*
|
||||
import kotlinx.coroutines.*
|
||||
import network.loki.messenger.R
|
||||
import org.session.libsession.utilities.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.conversation.v2.utilities.MentionManagerUtilities.populateUserPublicKeyCacheIfNeeded
|
||||
@ -40,7 +42,8 @@ class ConversationView : LinearLayout {
|
||||
// region Updating
|
||||
fun bind(thread: ThreadRecord, isTyping: Boolean, glide: GlideRequests) {
|
||||
this.thread = thread
|
||||
populateUserPublicKeyCacheIfNeeded(thread.threadId, context) // FIXME: This is a bad place to do this
|
||||
profilePictureView.glide = glide
|
||||
post {
|
||||
val unreadCount = thread.unreadCount
|
||||
if (thread.recipient.isBlocked) {
|
||||
accentView.setBackgroundResource(R.color.destructive)
|
||||
@ -55,9 +58,8 @@ class ConversationView : LinearLayout {
|
||||
unreadCountTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, textSize)
|
||||
unreadCountTextView.setTypeface(Typeface.DEFAULT, if (unreadCount < 100) Typeface.BOLD else Typeface.NORMAL)
|
||||
unreadCountIndicator.isVisible = (unreadCount != 0)
|
||||
profilePictureView.glide = glide
|
||||
profilePictureView.update(thread.recipient, thread.threadId)
|
||||
val senderDisplayName = getUserDisplayName(thread.recipient) ?: thread.recipient.address.toString()
|
||||
val senderDisplayName = getUserDisplayName(thread.recipient)
|
||||
?: thread.recipient.address.toString()
|
||||
conversationViewDisplayNameTextView.text = senderDisplayName
|
||||
timestampTextView.text = DateUtils.getDisplayFormattedTimeSpanString(context, Locale.getDefault(), thread.date)
|
||||
val recipient = thread.recipient
|
||||
@ -91,6 +93,13 @@ class ConversationView : LinearLayout {
|
||||
thread.isRead -> statusIndicatorImageView.setImageResource(R.drawable.ic_filled_circle_check)
|
||||
else -> statusIndicatorImageView.setImageResource(R.drawable.ic_circle_check)
|
||||
}
|
||||
GlobalScope.launch(Dispatchers.IO) {
|
||||
populateUserPublicKeyCacheIfNeeded(thread.threadId, context) // FIXME: This is a bad place to do this
|
||||
withContext(Dispatchers.Main) {
|
||||
profilePictureView.update(thread.recipient, thread.threadId)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun recycle() {
|
||||
|
@ -80,8 +80,7 @@ class HomeActivity : PassphraseRequiredActionBarActivity(), ConversationClickLis
|
||||
// Set up seed reminder view
|
||||
val hasViewedSeed = TextSecurePreferences.getHasViewedSeed(this)
|
||||
if (!hasViewedSeed) {
|
||||
seedReminderStub.isVisible = true
|
||||
seedReminderStub.apply {
|
||||
seedReminderStub.inflate().apply {
|
||||
val seedReminderView = this.seedReminderView
|
||||
val seedReminderViewTitle = SpannableString("You're almost finished! 80%") // Intentionally not yet translated
|
||||
seedReminderViewTitle.setSpan(ForegroundColorSpan(resources.getColorWithID(R.color.accent, theme)), 24, 27, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||
|
Loading…
x
Reference in New Issue
Block a user