From 62d258e207ad8e81ede6e8f4a6b0dfae6ce5143f Mon Sep 17 00:00:00 2001 From: SessionHero01 <180888785+SessionHero01@users.noreply.github.com> Date: Tue, 28 Oct 2025 09:08:43 +1100 Subject: [PATCH 1/7] Bump version code --- app/build.gradle.kts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 8af9930684..00de34d28a 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -26,8 +26,8 @@ configurations.configureEach { exclude(module = "commons-logging") } -val canonicalVersionCode = 426 -val canonicalVersionName = "1.28.1" +val canonicalVersionCode = 427 +val canonicalVersionName = "1.28.2" val postFixSize = 10 val abiPostFix = mapOf( From 307a0817c86f3a87d2675a93c207231d588f62ce Mon Sep 17 00:00:00 2001 From: SessionHero01 <180888785+SessionHero01@users.noreply.github.com> Date: Tue, 28 Oct 2025 09:09:18 +1100 Subject: [PATCH 2/7] Fix crashes when re-uploading avatar fails --- .../attachments/AvatarUploadManager.kt | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/attachments/AvatarUploadManager.kt b/app/src/main/java/org/thoughtcrime/securesms/attachments/AvatarUploadManager.kt index bbd7d83918..92a4bd51f2 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/attachments/AvatarUploadManager.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/attachments/AvatarUploadManager.kt @@ -2,6 +2,7 @@ package org.thoughtcrime.securesms.attachments import android.app.Application import android.os.FileObserver +import kotlinx.coroutines.CancellationException import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -95,11 +96,17 @@ class AvatarUploadManager @Inject constructor( } Log.d(TAG, "Avatar expired, re-uploading") - uploadAvatar( - pictureData = localEncryptedFileInputStreamFactory.create(localFile) - .use { it.readBytes() }, - isReupload = true, - ) + try { + uploadAvatar( + pictureData = localEncryptedFileInputStreamFactory.create(localFile) + .use { it.readBytes() }, + isReupload = true, + ) + } catch (e: CancellationException) { + throw e + } catch (e: Exception) { + Log.w(TAG, "Failed to re-upload avatar", e) + } } } else { emptyFlow() From 130425a02008979bd1ba9bd25e51b6d705b42cb5 Mon Sep 17 00:00:00 2001 From: ThomasSession Date: Tue, 14 Oct 2025 15:15:09 +1100 Subject: [PATCH 3/7] Do not crash in conversation without an address, instead take the user back home (cherry picked from commit 1e05b7a05d874276549489fdf7aa62501a2cd20c) --- .../conversation/v2/ConversationActivityV2.kt | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) 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 9fa6a86079..6f3f4258f8 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 @@ -173,6 +173,7 @@ import org.thoughtcrime.securesms.dependencies.ConfigFactory import org.thoughtcrime.securesms.giph.ui.GiphyActivity import org.thoughtcrime.securesms.groups.GroupMembersActivity import org.thoughtcrime.securesms.groups.OpenGroupManager +import org.thoughtcrime.securesms.home.HomeActivity import org.thoughtcrime.securesms.home.search.searchName import org.thoughtcrime.securesms.linkpreview.LinkPreviewRepository import org.thoughtcrime.securesms.linkpreview.LinkPreviewUtil @@ -283,9 +284,7 @@ class ConversationActivityV2 : ScreenLockActionBarActivity(), InputBarDelegate, } private val address: Address.Conversable by lazy { - requireNotNull(IntentCompat.getParcelableExtra(intent, ADDRESS, Address.Conversable::class.java)) { - "Address must be provided in the intent extras" - } + IntentCompat.getParcelableExtra(intent, ADDRESS, Address.Conversable::class.java)!! // safe to do !! since we check for this in onCreate } private val viewModel: ConversationViewModel by viewModels(extrasProducer = { @@ -522,6 +521,18 @@ class ConversationActivityV2 : ScreenLockActionBarActivity(), InputBarDelegate, override fun onCreate(savedInstanceState: Bundle?, isReady: Boolean) { super.onCreate(savedInstanceState, isReady) + + // Check if address is null before proceeding with initialization + if (IntentCompat.getParcelableExtra(intent, ADDRESS, Address.Conversable::class.java) == null) { + Log.w(TAG, "ConversationActivityV2 launched without ADDRESS extra - Returning home") + val intent = Intent(this, HomeActivity::class.java).apply { + flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK + } + startActivity(intent) + finish() + return + } + binding = ActivityConversationV2Binding.inflate(layoutInflater) setContentView(binding.root) From a2ebe464cf2bbc6f01fd122f2e56b0191b5a4b13 Mon Sep 17 00:00:00 2001 From: SessionHero01 <180888785+SessionHero01@users.noreply.github.com> Date: Tue, 28 Oct 2025 09:15:52 +1100 Subject: [PATCH 4/7] Potential fixes for logout issue --- .../securesms/configs/ConfigToDatabaseSync.kt | 27 +++++++++------- .../database/BlindMappingRepository.kt | 31 ++++++++++--------- .../securesms/database/RecipientRepository.kt | 11 +++++-- 3 files changed, 41 insertions(+), 28 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/configs/ConfigToDatabaseSync.kt b/app/src/main/java/org/thoughtcrime/securesms/configs/ConfigToDatabaseSync.kt index 15d3a7fede..4fae3a59fb 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/configs/ConfigToDatabaseSync.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/configs/ConfigToDatabaseSync.kt @@ -8,6 +8,7 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.distinctUntilChanged +import kotlinx.coroutines.flow.emptyFlow import kotlinx.coroutines.flow.filterNotNull import kotlinx.coroutines.flow.flatMapLatest import kotlinx.coroutines.flow.map @@ -58,6 +59,7 @@ import org.thoughtcrime.securesms.util.castAwayType import java.util.EnumSet import java.util.concurrent.TimeUnit import javax.inject.Inject +import kotlin.math.log private const val TAG = "ConfigToDatabaseSync" @@ -93,17 +95,20 @@ class ConfigToDatabaseSync @Inject constructor( // Sync conversations from config -> database scope.launch { preferences.watchLocalNumber() - .filterNotNull() - .take(1) - .flatMapLatest { - combine( - conversationRepository.conversationListAddressesFlow, - configFactory.userConfigsChanged(EnumSet.of(UserConfigType.CONVO_INFO_VOLATILE)) - .castAwayType() - .onStart { emit(Unit) } - .map { _ -> configFactory.withUserConfigs { it.convoInfoVolatile.all() } }, - ::Pair - ) + .map { it != null } + .flatMapLatest { loggedIn -> + if (loggedIn) { + combine( + conversationRepository.conversationListAddressesFlow, + configFactory.userConfigsChanged(EnumSet.of(UserConfigType.CONVO_INFO_VOLATILE)) + .castAwayType() + .onStart { emit(Unit) } + .map { _ -> configFactory.withUserConfigs { it.convoInfoVolatile.all() } }, + ::Pair + ) + } else { + emptyFlow() + } } .distinctUntilChanged() .collectLatest { (conversations, convoInfo) -> diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/BlindMappingRepository.kt b/app/src/main/java/org/thoughtcrime/securesms/database/BlindMappingRepository.kt index 630663cc05..fe1959dc78 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/database/BlindMappingRepository.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/database/BlindMappingRepository.kt @@ -5,7 +5,7 @@ import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.distinctUntilChanged -import kotlinx.coroutines.flow.filterNotNull +import kotlinx.coroutines.flow.emptyFlow import kotlinx.coroutines.flow.flatMapLatest import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.onStart @@ -43,21 +43,24 @@ class BlindMappingRepository @Inject constructor( */ @Suppress("OPT_IN_USAGE") val mappings: StateFlow>> = prefs.watchLocalNumber() - .filterNotNull() .flatMapLatest { localAddress -> - configFactory - .userConfigsChanged(setOf(UserConfigType.USER_GROUPS, UserConfigType.CONTACTS)) - .castAwayType() - .onStart { emit(Unit) } - .map { - configFactory.withUserConfigs { configs -> - Pair( - configs.userGroups.allCommunityInfo().map { it.community }, - configs.contacts.all().map { Address.Standard(AccountId(it.id)) } - + Address.Standard(AccountId(localAddress)) - ) + if (localAddress.isNullOrBlank()) { + emptyFlow() + } else { + configFactory + .userConfigsChanged(setOf(UserConfigType.USER_GROUPS, UserConfigType.CONTACTS)) + .castAwayType() + .onStart { emit(Unit) } + .map { + configFactory.withUserConfigs { configs -> + Pair( + configs.userGroups.allCommunityInfo().map { it.community }, + configs.contacts.all().map { Address.Standard(AccountId(it.id)) } + + Address.Standard(AccountId(localAddress)) + ) + } } - } + } } .distinctUntilChanged() .map { (allCommunities, allContacts) -> diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/RecipientRepository.kt b/app/src/main/java/org/thoughtcrime/securesms/database/RecipientRepository.kt index 70d252701e..d36ad9b6bc 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/database/RecipientRepository.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/database/RecipientRepository.kt @@ -12,6 +12,7 @@ import kotlinx.coroutines.flow.SharedFlow import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.debounce import kotlinx.coroutines.flow.distinctUntilChanged +import kotlinx.coroutines.flow.emptyFlow import kotlinx.coroutines.flow.filter import kotlinx.coroutines.flow.filterIsInstance import kotlinx.coroutines.flow.filterNotNull @@ -93,9 +94,13 @@ class RecipientRepository @Inject constructor( fun observeSelf(): Flow { return preferences.watchLocalNumber() - .filterNotNull() - .distinctUntilChanged() - .flatMapLatest { observeRecipient(it.toAddress()) } + .flatMapLatest { + if (it.isNullOrBlank()) { + emptyFlow() + } else { + observeRecipient(it.toAddress()) + } + } } fun getSelf(): Recipient { From bd1b64a2c8bd31e4176d01392f26bf71693e1ec2 Mon Sep 17 00:00:00 2001 From: ThomasSession Date: Tue, 14 Oct 2025 15:21:43 +1100 Subject: [PATCH 5/7] Make sure we reset our observable prefs (cherry picked from commit 3ef4235a1b81b28c6324c77afe7c73a2f9af8e3b) --- .../utilities/TextSecurePreferences.kt | 16 +++++++++------- .../securesms/util/ClearDataUtils.kt | 4 +++- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/org/session/libsession/utilities/TextSecurePreferences.kt b/app/src/main/java/org/session/libsession/utilities/TextSecurePreferences.kt index 6db04761b8..811771e60d 100644 --- a/app/src/main/java/org/session/libsession/utilities/TextSecurePreferences.kt +++ b/app/src/main/java/org/session/libsession/utilities/TextSecurePreferences.kt @@ -930,12 +930,6 @@ interface TextSecurePreferences { setBooleanPreference(context, FINGERPRINT_KEY_GENERATED, true) } - @JvmStatic - fun clearAll(context: Context) { - getDefaultSharedPreferences(context).edit().clear().commit() - } - - // ----- Get / set methods for if we have already warned the user that saving attachments will allow other apps to access them ----- // Note: We only ever show the warning dialog about this ONCE - when the user accepts this fact we write true to the flag & never show again. @JvmStatic @@ -1656,8 +1650,16 @@ class AppTextSecurePreferences @Inject constructor( return getBooleanPreference(AUTOPLAY_AUDIO_MESSAGES, false) } + /** + * Clear all prefs and reset or observables + */ override fun clearAll() { - getDefaultSharedPreferences(context).edit().clear().commit() + pushEnabled.update { false } + localNumberState.update { null } + postProLaunchState.update { false } + hiddenPasswordState.update { false } + + getDefaultSharedPreferences(context).edit(commit = true) { clear() } } override fun getHidePassword() = getBooleanPreference(HIDE_PASSWORD, false) diff --git a/app/src/main/java/org/thoughtcrime/securesms/util/ClearDataUtils.kt b/app/src/main/java/org/thoughtcrime/securesms/util/ClearDataUtils.kt index dbd8da93d9..1ab547998e 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/util/ClearDataUtils.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/util/ClearDataUtils.kt @@ -49,7 +49,9 @@ class ClearDataUtils @Inject constructor( application.deleteDatabase(DatabaseMigrationManager.CIPHER4_DB_NAME) application.deleteDatabase(DatabaseMigrationManager.CIPHER3_DB_NAME) - TextSecurePreferences.clearAll(application) + // clear all prefs + prefs.clearAll() + application.getSharedPreferences(ApplicationContext.PREFERENCES_NAME, 0).edit(commit = true) { clear() } application.cacheDir.deleteRecursively() application.filesDir.deleteRecursively() From a44f8b70efbf8544e73c84593b745d2926bc7841 Mon Sep 17 00:00:00 2001 From: ThomasSession Date: Wed, 15 Oct 2025 12:13:02 +1100 Subject: [PATCH 6/7] PR feedback (cherry picked from commit 480523d6f7931a9f425efd3df1adb430cdce0283) --- .../securesms/conversation/v2/ConversationActivityV2.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 6f3f4258f8..b181a7b1a2 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 @@ -284,7 +284,9 @@ class ConversationActivityV2 : ScreenLockActionBarActivity(), InputBarDelegate, } private val address: Address.Conversable by lazy { - IntentCompat.getParcelableExtra(intent, ADDRESS, Address.Conversable::class.java)!! // safe to do !! since we check for this in onCreate + requireNotNull(IntentCompat.getParcelableExtra(intent, ADDRESS, Address.Conversable::class.java)) { + "Address must be provided in the intent extras to open a conversation" + } } private val viewModel: ConversationViewModel by viewModels(extrasProducer = { From 98af979fc944df48bec5096dfb698d6257370003 Mon Sep 17 00:00:00 2001 From: SessionHero01 <180888785+SessionHero01@users.noreply.github.com> Date: Tue, 28 Oct 2025 09:49:32 +1100 Subject: [PATCH 7/7] Bump version code to 248 --- app/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 00de34d28a..ffd6173dba 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -26,7 +26,7 @@ configurations.configureEach { exclude(module = "commons-logging") } -val canonicalVersionCode = 427 +val canonicalVersionCode = 428 val canonicalVersionName = "1.28.2" val postFixSize = 10