diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt index fe5d41af11..49a1a033fa 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt @@ -248,6 +248,10 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe // assume created thread if (recipient.isContactRecipient && !recipient.isLocalNumber) { storage.setRecipientApproved(recipient, true) // assume approved when we CREATE the thread, not send first message + } else if (recipient.isLocalNumber) { + // this gets around the filtering of unapproved / unsent threads + // since the sql query would have to take into account whether address == local user address + threadDb.setHasSent(threadId, true) } } } ?: finish() diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/Storage.kt b/app/src/main/java/org/thoughtcrime/securesms/database/Storage.kt index 4c99e9fe66..7d3b0a672a 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/database/Storage.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/database/Storage.kt @@ -182,8 +182,9 @@ open class Storage(context: Context, helper: SQLCipherOpenHelper, private val co val ourRecipient = fromSerialized(getUserPublicKey()!!).let { Recipient.from(context, it, false) } - TextSecurePreferences.setProfilePictureURL(context, newProfilePicture) + ourRecipient.resolve().profileKey = newProfileKey TextSecurePreferences.setProfileKey(context, newProfileKey?.let { Base64.encodeBytes(it) }) + TextSecurePreferences.setProfilePictureURL(context, newProfilePicture) ApplicationContext.getInstance(context).jobManager.add(RetrieveProfileAvatarJob(ourRecipient, newProfilePicture)) } @@ -437,6 +438,7 @@ open class Storage(context: Context, helper: SQLCipherOpenHelper, private val co } else { // create note to self thread if needed (?) val ourThread = getOrCreateThreadIdFor(recipient.address) + DatabaseComponent.get(context).threadDatabase().setHasSent(ourThread, true) setPinned(ourThread, userProfile.getNtsPriority() > 0) } @@ -1008,7 +1010,10 @@ open class Storage(context: Context, helper: SQLCipherOpenHelper, private val co val communityInfo = groups.getOrConstructCommunityInfo(infoServer, infoRoom, pubKeyHex) groups.set(communityInfo) val volatile = volatileConfig.getOrConstructCommunity(infoServer, infoRoom, pubKey) - volatileConfig.set(volatile.copy(lastRead = 0)) + if (volatile.lastRead != 0L) { + val threadId = getThreadId(openGroup) ?: return + markConversationAsRead(threadId, volatile.lastRead) + } } override fun hasBackgroundGroupAddJob(groupJoinUrl: String): Boolean { diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/ThreadDatabase.java b/app/src/main/java/org/thoughtcrime/securesms/database/ThreadDatabase.java index c5f9fd2fd3..b8f90bd14d 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/database/ThreadDatabase.java +++ b/app/src/main/java/org/thoughtcrime/securesms/database/ThreadDatabase.java @@ -539,7 +539,8 @@ public class ThreadDatabase extends Database { public boolean setLastSeen(long threadId, long timestamp) { // edge case where we set the last seen time for a conversation before it loads messages (joining community for example) MmsSmsDatabase mmsSmsDatabase = DatabaseComponent.get(context).mmsSmsDatabase(); - if (mmsSmsDatabase.getConversationCount(threadId) <= 0) return false; + Recipient forThreadId = getRecipientForThreadId(threadId); + if (mmsSmsDatabase.getConversationCount(threadId) <= 0 && forThreadId != null && forThreadId.isOpenGroupRecipient()) return false; SQLiteDatabase db = databaseHelper.getWritableDatabase(); diff --git a/app/src/main/java/org/thoughtcrime/securesms/preferences/SettingsActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/preferences/SettingsActivity.kt index 635ee1becd..1e44574925 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/preferences/SettingsActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/preferences/SettingsActivity.kt @@ -2,7 +2,10 @@ package org.thoughtcrime.securesms.preferences import android.Manifest import android.app.Activity -import android.content.* +import android.content.ClipData +import android.content.ClipboardManager +import android.content.Context +import android.content.Intent import android.net.Uri import android.os.AsyncTask import android.os.Bundle @@ -232,16 +235,16 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() { // new config val url = TextSecurePreferences.getProfilePictureURL(this) val profileKey = ProfileKeyUtil.getProfileKey(this) - if (!url.isNullOrEmpty() && profileKey.isNotEmpty()) { + if (profilePicture == null) { + userConfig?.setPic(UserPic.DEFAULT) + } else if (!url.isNullOrEmpty() && profileKey.isNotEmpty()) { userConfig?.setPic(UserPic(url, profileKey)) } } - if (profilePicture != null || displayName != null) { - if (userConfig != null && userConfig.needsDump()) { - configFactory.persist(userConfig) - } - ConfigurationMessageUtilities.forceSyncConfigurationNowIfNeeded(this@SettingsActivity) + if (userConfig != null && userConfig.needsDump()) { + configFactory.persist(userConfig) } + ConfigurationMessageUtilities.forceSyncConfigurationNowIfNeeded(this@SettingsActivity) } compoundPromise.alwaysUi { if (displayName != null) {