Skip to content

Commit 5daf130

Browse files
Merge branch 'dev' into feature/update-crowdin-translations
2 parents 5170052 + c747da1 commit 5daf130

File tree

27 files changed

+72
-1154
lines changed

27 files changed

+72
-1154
lines changed

app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/MessageFormatter.kt

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package org.thoughtcrime.securesms.conversation.v2.messages
33
import android.content.Context
44
import android.text.Spannable
55
import android.text.SpannableString
6+
import android.text.SpannableStringBuilder
67
import android.text.style.ForegroundColorSpan
78
import com.squareup.phrase.Phrase
89
import network.loki.messenger.R
@@ -177,29 +178,34 @@ class MessageFormatter @Inject constructor(
177178
context.getString(R.string.communityInvitation)
178179
}
179180

180-
// Show a placeholder text for messages with attachments
181-
lastMessage is MmsMessageRecord -> {
182-
val placeholderBody = lastMessage.slideDeck.body
183-
val messageBody = lastMessage.body
184-
185-
if (placeholderBody.isNotBlank()) {
186-
if (messageBody.isNotBlank()) {
187-
"$placeholderBody: $messageBody"
188-
} else {
189-
placeholderBody
190-
}
191-
} else {
192-
messageBody
193-
}
194-
}
195-
196181
else -> {
197-
val text = formatMessageBody(
182+
val bodyText = formatMessageBody(
198183
context = context,
199184
message = lastMessage,
200185
threadRecipient = thread.recipient
201186
)
202187

188+
// This is used to show a placeholder text for MMS messages in the snippet,
189+
// for example, "<image> Attachment"
190+
val mmsPlaceholderBody = (lastMessage as? MmsMessageRecord)?.slideDeck?.body
191+
192+
val text = when {
193+
// If both body and placeholder are blank, return empty string
194+
bodyText.isBlank() && mmsPlaceholderBody.isNullOrBlank() -> ""
195+
196+
// If both body and placeholder are non-blank, combine them
197+
bodyText.isNotBlank() && !mmsPlaceholderBody.isNullOrBlank() ->
198+
SpannableStringBuilder(mmsPlaceholderBody)
199+
.append(": ")
200+
.append(bodyText)
201+
202+
// If only placeholder is non-blank, use it
203+
!mmsPlaceholderBody.isNullOrBlank() -> mmsPlaceholderBody
204+
205+
// Otherwise, use the body text
206+
else -> bodyText
207+
}
208+
203209
when {
204210
// There are certain messages that we want to keep their formatting
205211
lastMessage.groupUpdateMessage?.isGroupLeavingKind() == true ||

app/src/main/java/org/thoughtcrime/securesms/dependencies/ConfigFactory.kt

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.thoughtcrime.securesms.dependencies
22

3+
import androidx.collection.arrayMapOf
34
import androidx.collection.arraySetOf
45
import dagger.Lazy
56
import kotlinx.coroutines.CoroutineScope
@@ -141,6 +142,7 @@ class ConfigFactory @Inject constructor(
141142
lock.writeLock().lock()
142143
return configs to {
143144
val changed = arraySetOf<UserConfigType>()
145+
var dumped: MutableMap<UserConfigType, ByteArray>? = null
144146

145147
for (type in UserConfigType.entries) {
146148
val config = configs.getConfig(type)
@@ -149,17 +151,33 @@ class ConfigFactory @Inject constructor(
149151
}
150152

151153
if (config.needsDump()) {
152-
configDatabase.storeConfig(
153-
variant = type.configVariant,
154-
publicKey = requiresCurrentUserAccountId().hexString,
155-
data = config.dump(),
156-
timestamp = clock.currentTimeMills()
157-
)
154+
if (dumped == null) {
155+
dumped = arrayMapOf()
156+
}
157+
158+
dumped[type] = config.dump()
158159
}
159160
}
160161

161162
lock.writeLock().unlock()
162163

164+
// Persist dumped configs
165+
if (dumped != null) {
166+
coroutineScope.launch {
167+
val userAccountId = requiresCurrentUserAccountId()
168+
val currentTimeMs = clock.currentTimeMills()
169+
170+
for ((type, data) in dumped) {
171+
configDatabase.storeConfig(
172+
variant = type.configVariant,
173+
publicKey = userAccountId.hexString,
174+
data = data,
175+
timestamp = currentTimeMs
176+
)
177+
}
178+
}
179+
}
180+
163181
// Notify changes on a coroutine
164182
if (changed.isNotEmpty()) {
165183
coroutineScope.launch {
@@ -180,19 +198,31 @@ class ConfigFactory @Inject constructor(
180198
configs.groupKeys.needsDump() ||
181199
configs.groupKeys.needsRekey()
182200

183-
if (configs.groupInfo.needsDump() || configs.groupMembers.needsDump() ||
201+
val dumped = if (configs.groupInfo.needsDump() || configs.groupMembers.needsDump() ||
184202
configs.groupKeys.needsDump()) {
185-
configDatabase.storeGroupConfigs(
186-
publicKey = groupId.hexString,
187-
keysConfig = configs.groupKeys.dump(),
188-
infoConfig = configs.groupInfo.dump(),
189-
memberConfig = configs.groupMembers.dump(),
190-
timestamp = clock.currentTimeMills()
203+
Triple(
204+
configs.groupKeys.dump(),
205+
configs.groupInfo.dump(),
206+
configs.groupMembers.dump()
191207
)
208+
} else {
209+
null
192210
}
193211

194212
lock.writeLock().unlock()
195213

214+
if (dumped != null) {
215+
coroutineScope.launch {
216+
configDatabase.storeGroupConfigs(
217+
publicKey = groupId.hexString,
218+
keysConfig = dumped.first,
219+
infoConfig = dumped.second,
220+
memberConfig = dumped.third,
221+
timestamp = clock.currentTimeMills()
222+
)
223+
}
224+
}
225+
196226
// Notify changes on a coroutine
197227
if (changed) {
198228
coroutineScope.launch {

app/src/main/java/org/thoughtcrime/securesms/groups/compose/PromoteMembersScreen.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ fun PromoteMembers(
150150
.padding(horizontal = LocalDimensions.current.mediumSpacing)
151151
.fillMaxWidth()
152152
.wrapContentWidth(Alignment.CenterHorizontally),
153-
text = LocalResources.current.getString(if (!hasActiveMembers) R.string.noNonAdminsInGroup else R.string.adminCannotBeDemoted),
153+
text = LocalResources.current.getString(if (!hasActiveMembers) R.string.noNonAdminsInGroup else R.string.membersGroupPromotionAcceptInvite),
154154
textAlign = TextAlign.Center,
155155
style = LocalType.current.base,
156156
color = LocalColors.current.textSecondary

gradle/libs.versions.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,18 @@ exifinterfaceVersion = "1.4.1"
2121
firebaseMessagingVersion = "25.0.1"
2222
flexboxVersion = "3.0.0"
2323
fragmentKtxVersion = "1.8.9"
24-
gradlePluginVersion = "8.13.1"
24+
gradlePluginVersion = "8.13.2"
2525
dependenciesAnalysisVersion = "3.1.0"
2626
googleServicesVersion = "4.4.4"
2727
junit = "1.3.0"
2828
kotlinVersion = "2.2.21"
2929
kryoVersion = "5.6.2"
3030
kspVersion = "2.3.3"
3131
legacySupportV13Version = "1.0.0"
32-
libsessionUtilAndroidVersion = "1.0.9-11-g1b8d453"
32+
libsessionUtilAndroidVersion = "1.1.0"
3333
media3ExoplayerVersion = "1.8.0"
34-
mockitoCoreVersion = "5.20.0"
35-
navVersion = "2.9.5"
34+
mockitoCoreVersion = "5.21.0"
35+
navVersion = "2.9.6"
3636
appcompatVersion = "1.7.1"
3737
coreVersion = "1.16.0"
3838
coroutinesVersion = "1.10.2"
@@ -64,7 +64,7 @@ subsamplingScaleImageViewVersion = "3.10.0"
6464
testCoreVersion = "1.7.0"
6565
truthVersion = "1.4.5"
6666
turbineVersion = "1.2.1"
67-
uiTestJunit4Version = "1.9.4"
67+
uiTestJunit4Version = "1.10.0"
6868
workRuntimeKtxVersion = "2.11.0"
6969
zxingVersion = "3.5.4"
7070
huaweiPushVersion = "6.13.0.300"

libsession/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

libsession/build.gradle.kts

Lines changed: 0 additions & 84 deletions
This file was deleted.

0 commit comments

Comments
 (0)