Skip to content

Commit dbde1fd

Browse files
Merge pull request #1688 from session-foundation/release/1.29.2
Prepare for Release 1.29.2
2 parents 37c6673 + 9680e33 commit dbde1fd

20 files changed

+114
-110
lines changed

app/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ configurations.configureEach {
2626
exclude(module = "commons-logging")
2727
}
2828

29-
val canonicalVersionCode = 430
30-
val canonicalVersionName = "1.29.1"
29+
val canonicalVersionCode = 431
30+
val canonicalVersionName = "1.29.2"
3131

3232
val postFixSize = 10
3333
val abiPostFix = mapOf(

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ import androidx.recyclerview.widget.RecyclerView
5959
import com.annimon.stream.Stream
6060
import com.bumptech.glide.Glide
6161
import com.squareup.phrase.Phrase
62+
import dagger.Lazy
6263
import dagger.hilt.android.AndroidEntryPoint
6364
import dagger.hilt.android.lifecycle.withCreationCallback
6465
import kotlinx.coroutines.CancellationException
@@ -263,7 +264,6 @@ class ConversationActivityV2 : ScreenLockActionBarActivity(), InputBarDelegate,
263264
@Inject lateinit var typingStatusRepository: TypingStatusRepository
264265
@Inject lateinit var typingStatusSender: TypingStatusSender
265266
@Inject lateinit var openGroupManager: OpenGroupManager
266-
@Inject lateinit var attachmentDatabase: AttachmentDatabase
267267
@Inject lateinit var clock: SnodeClock
268268
@Inject @ManagerScope
269269
lateinit var scope: CoroutineScope
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
package org.thoughtcrime.securesms.conversation.v2.input_bar.mentions
22

3-
import android.view.View
43
import network.loki.messenger.databinding.ViewMentionCandidateV2Binding
54
import org.thoughtcrime.securesms.conversation.v2.mention.MentionViewModel
65
import org.thoughtcrime.securesms.ui.components.Avatar
76
import org.thoughtcrime.securesms.ui.setThemedContent
87
import org.thoughtcrime.securesms.ui.theme.LocalDimensions
8+
import org.thoughtcrime.securesms.util.AvatarBadge
99

1010
fun ViewMentionCandidateV2Binding.update(candidate: MentionViewModel.Candidate) {
1111
mentionCandidateNameTextView.text = candidate.nameHighlighted
1212
profilePictureView.setThemedContent {
1313
Avatar(
1414
size = LocalDimensions.current.iconMediumAvatar,
1515
data = candidate.member.avatarData,
16+
badge = if (candidate.member.showAdminCrown) AvatarBadge.Admin else AvatarBadge.None
1617
)
1718
}
18-
19-
moderatorIconImageView.visibility = if (candidate.member.showAdminCrown) View.VISIBLE else View.GONE
2019
}

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ import org.thoughtcrime.securesms.ui.theme.LocalColors
6161
import org.thoughtcrime.securesms.ui.theme.LocalDimensions
6262
import org.thoughtcrime.securesms.ui.theme.LocalType
6363
import org.thoughtcrime.securesms.ui.theme.bold
64+
import org.thoughtcrime.securesms.util.AvatarBadge
6465
import org.thoughtcrime.securesms.util.AvatarUtils
6566
import org.thoughtcrime.securesms.util.DateUtils
6667
import org.thoughtcrime.securesms.util.disableClipping
@@ -176,7 +177,6 @@ class VisibleMessageView : FrameLayout {
176177
val isStartOfMessageCluster = isStartOfMessageCluster(message, previous, isGroupThread)
177178
val isEndOfMessageCluster = isEndOfMessageCluster(message, next, isGroupThread)
178179
// Show profile picture and sender name if this is a group thread AND the message is incoming
179-
binding.moderatorIconImageView.isVisible = false
180180
binding.profilePictureView.visibility = when {
181181
threadRecipient.isGroupOrCommunityRecipient && !message.isOutgoing && isEndOfMessageCluster -> View.VISIBLE
182182
threadRecipient.isGroupOrCommunityRecipient -> View.INVISIBLE
@@ -200,22 +200,22 @@ class VisibleMessageView : FrameLayout {
200200

201201
if (isGroupThread && !message.isOutgoing) {
202202
if (isEndOfMessageCluster) {
203+
val showProBadge = if (sender.address is Address.WithAccountId) {
204+
(threadRecipient.data as? RecipientData.GroupLike)
205+
?.shouldShowAdminCrown(sender.address.accountId) == true
206+
} else {
207+
false
208+
}
203209
binding.profilePictureView.setThemedContent {
204210
Avatar(
205211
size = LocalDimensions.current.iconMediumAvatar,
206212
data = avatarUtils.getUIDataFromRecipient(sender),
213+
badge = if(showProBadge) AvatarBadge.Admin else AvatarBadge.None,
207214
modifier = Modifier.clickable {
208215
delegate?.showUserProfileModal(message.recipient)
209216
}
210217
)
211218
}
212-
213-
binding.moderatorIconImageView.isVisible = if (sender.address is Address.WithAccountId) {
214-
(threadRecipient.data as? RecipientData.GroupLike)
215-
?.shouldShowAdminCrown(sender.address.accountId) == true
216-
} else {
217-
false
218-
}
219219
}
220220
}
221221
if(!message.isOutgoing && (isStartOfMessageCluster && isGroupThread)){

app/src/main/java/org/thoughtcrime/securesms/database/AttachmentDatabase.java

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,16 @@
2626
import android.text.TextUtils;
2727
import android.util.Pair;
2828

29-
import androidx.annotation.NonNull;
30-
import androidx.annotation.Nullable;
3129
import androidx.annotation.VisibleForTesting;
3230

3331
import com.bumptech.glide.Glide;
3432

3533
import net.zetetic.database.sqlcipher.SQLiteDatabase;
3634

37-
import org.apache.commons.lang3.StringUtils;
3835
import org.json.JSONArray;
3936
import org.json.JSONException;
37+
import org.jspecify.annotations.NonNull;
38+
import org.jspecify.annotations.Nullable;
4039
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
4140
import org.session.libsession.messaging.sending_receiving.attachments.AttachmentId;
4241
import org.session.libsession.messaging.sending_receiving.attachments.AttachmentState;
@@ -80,14 +79,19 @@
8079
import java.util.concurrent.ExecutionException;
8180
import java.util.concurrent.ExecutorService;
8281

82+
import javax.inject.Inject;
8383
import javax.inject.Provider;
84+
import javax.inject.Singleton;
8485

86+
import dagger.Lazy;
87+
import dagger.hilt.android.qualifiers.ApplicationContext;
8588
import kotlin.jvm.Synchronized;
8689
import kotlinx.coroutines.channels.BufferOverflow;
8790
import kotlinx.coroutines.flow.MutableSharedFlow;
8891
import kotlinx.coroutines.flow.SharedFlow;
8992
import kotlinx.coroutines.flow.SharedFlowKt;
9093

94+
@Singleton
9195
public class AttachmentDatabase extends Database {
9296

9397
private static final String TAG = AttachmentDatabase.class.getSimpleName();
@@ -161,13 +165,18 @@ public class AttachmentDatabase extends Database {
161165

162166
final ExecutorService thumbnailExecutor = Util.newSingleThreadedLifoExecutor();
163167

164-
private final AttachmentSecret attachmentSecret;
168+
private final Lazy<@NonNull AttachmentSecret> attachmentSecret;
165169

166170
private final MutableSharedFlow<Object> mutableChangesNotification = SharedFlowKt.MutableSharedFlow(
167171
0, 100, BufferOverflow.DROP_OLDEST
168172
);
169173

170-
public AttachmentDatabase(Context context, Provider<SQLCipherOpenHelper> databaseHelper, AttachmentSecret attachmentSecret) {
174+
@Inject
175+
public AttachmentDatabase(
176+
@ApplicationContext Context context,
177+
Provider<SQLCipherOpenHelper> databaseHelper,
178+
Lazy<@NonNull AttachmentSecret> attachmentSecret
179+
) {
171180
super(context, databaseHelper);
172181
this.attachmentSecret = attachmentSecret;
173182
}
@@ -535,9 +544,9 @@ public void setTransferState(@NonNull AttachmentId attachmentId, int transferSta
535544

536545
try {
537546
if (dataInfo.random != null && dataInfo.random.length == 32) {
538-
return ModernDecryptingPartInputStream.createFor(attachmentSecret, dataInfo.random, dataInfo.file, offset);
547+
return ModernDecryptingPartInputStream.createFor(attachmentSecret.get(), dataInfo.random, dataInfo.file, offset);
539548
} else {
540-
InputStream stream = ClassicDecryptingPartInputStream.createFor(attachmentSecret, dataInfo.file);
549+
InputStream stream = ClassicDecryptingPartInputStream.createFor(attachmentSecret.get(), dataInfo.file);
541550
long skipped = stream.skip(offset);
542551

543552
if (skipped != offset) {
@@ -607,7 +616,7 @@ public void setTransferState(@NonNull AttachmentId attachmentId, int transferSta
607616
File dataFile = File.createTempFile("part", ".mms", partsDirectory);
608617

609618
Log.d("AttachmentDatabase", "Writing attachment data to: " + dataFile.getAbsolutePath());
610-
Pair<byte[], OutputStream> out = ModernEncryptingPartOutputStream.createFor(attachmentSecret, dataFile, false);
619+
Pair<byte[], OutputStream> out = ModernEncryptingPartOutputStream.createFor(attachmentSecret.get(), dataFile, false);
611620
long length = Util.copy(in, out.second);
612621

613622
return new DataInfo(dataFile, length, out.first);
@@ -894,7 +903,7 @@ private ThumbnailData generateVideoThumbnail(AttachmentId attachmentId) {
894903
return null;
895904
}
896905

897-
EncryptedMediaDataSource dataSource = new EncryptedMediaDataSource(attachmentSecret, dataInfo.file, dataInfo.random, dataInfo.length);
906+
EncryptedMediaDataSource dataSource = new EncryptedMediaDataSource(attachmentSecret.get(), dataInfo.file, dataInfo.random, dataInfo.length);
898907
MediaMetadataRetriever retriever = new MediaMetadataRetriever();
899908
retriever.setDataSource(dataSource);
900909

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,6 @@ object DatabaseModule {
5454
return manager.openHelper
5555
}
5656

57-
@Provides
58-
@Singleton
59-
fun provideAttachmentDatabase(@ApplicationContext context: Context,
60-
openHelper: Provider<SQLCipherOpenHelper>,
61-
attachmentSecret: AttachmentSecret) = AttachmentDatabase(context, openHelper, attachmentSecret)
6257
@Provides
6358
@Singleton
6459
fun provideMediaDatbase(@ApplicationContext context: Context, openHelper: Provider<SQLCipherOpenHelper>) = MediaDatabase(context, openHelper)

app/src/main/java/org/thoughtcrime/securesms/glide/cache/EncryptedBitmapCacheDecoder.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@
22

33

44
import android.graphics.Bitmap;
5+
56
import androidx.annotation.NonNull;
67
import androidx.annotation.Nullable;
7-
import org.session.libsignal.utilities.Log;
88

99
import com.bumptech.glide.load.Options;
1010
import com.bumptech.glide.load.ResourceDecoder;
1111
import com.bumptech.glide.load.engine.Resource;
1212
import com.bumptech.glide.load.resource.bitmap.StreamBitmapDecoder;
1313

14+
import org.session.libsignal.utilities.Log;
15+
import org.thoughtcrime.securesms.crypto.AttachmentSecretProvider;
16+
1417
import java.io.File;
1518
import java.io.IOException;
1619
import java.io.InputStream;
@@ -20,10 +23,10 @@ public class EncryptedBitmapCacheDecoder extends EncryptedCoder implements Resou
2023
private static final String TAG = EncryptedBitmapCacheDecoder.class.getSimpleName();
2124

2225
private final StreamBitmapDecoder streamBitmapDecoder;
23-
private final byte[] secret;
26+
private final AttachmentSecretProvider attachmentSecretProvider;
2427

25-
public EncryptedBitmapCacheDecoder(@NonNull byte[] secret, @NonNull StreamBitmapDecoder streamBitmapDecoder) {
26-
this.secret = secret;
28+
public EncryptedBitmapCacheDecoder(@NonNull AttachmentSecretProvider attachmentSecretProvider, @NonNull StreamBitmapDecoder streamBitmapDecoder) {
29+
this.attachmentSecretProvider = attachmentSecretProvider;
2730
this.streamBitmapDecoder = streamBitmapDecoder;
2831
}
2932

@@ -33,7 +36,7 @@ public boolean handles(@NonNull File source, @NonNull Options options)
3336
{
3437
Log.i(TAG, "Checking item for encrypted Bitmap cache decoder: " + source.toString());
3538

36-
try (InputStream inputStream = createEncryptedInputStream(secret, source)) {
39+
try (InputStream inputStream = createEncryptedInputStream(attachmentSecretProvider.getOrCreateAttachmentSecret().getModernKey(), source)) {
3740
return streamBitmapDecoder.handles(inputStream, options);
3841
} catch (IOException e) {
3942
Log.w(TAG, e);
@@ -47,7 +50,7 @@ public Resource<Bitmap> decode(@NonNull File source, int width, int height, @Non
4750
throws IOException
4851
{
4952
Log.i(TAG, "Encrypted Bitmap cache decoder running: " + source.toString());
50-
try (InputStream inputStream = createEncryptedInputStream(secret, source)) {
53+
try (InputStream inputStream = createEncryptedInputStream(attachmentSecretProvider.getOrCreateAttachmentSecret().getModernKey(), source)) {
5154
return streamBitmapDecoder.decode(inputStream, width, height, options);
5255
}
5356
}

app/src/main/java/org/thoughtcrime/securesms/glide/cache/EncryptedBitmapResourceEncoder.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import android.graphics.Bitmap;
55
import androidx.annotation.NonNull;
66
import org.session.libsignal.utilities.Log;
7+
import org.thoughtcrime.securesms.crypto.AttachmentSecretProvider;
78

89
import com.bumptech.glide.load.EncodeStrategy;
910
import com.bumptech.glide.load.Options;
@@ -19,10 +20,10 @@ public class EncryptedBitmapResourceEncoder extends EncryptedCoder implements Re
1920

2021
private static final String TAG = EncryptedBitmapResourceEncoder.class.getSimpleName();
2122

22-
private final byte[] secret;
23+
private final AttachmentSecretProvider secretProvider;
2324

24-
public EncryptedBitmapResourceEncoder(@NonNull byte[] secret) {
25-
this.secret = secret;
25+
public EncryptedBitmapResourceEncoder(@NonNull AttachmentSecretProvider secretProvider) {
26+
this.secretProvider = secretProvider;
2627
}
2728

2829
@Override
@@ -39,7 +40,7 @@ public boolean encode(@NonNull Resource<Bitmap> data, @NonNull File file, @NonNu
3940
Bitmap.CompressFormat format = getFormat(bitmap, options);
4041
int quality = options.get(BitmapEncoder.COMPRESSION_QUALITY);
4142

42-
try (OutputStream os = createEncryptedOutputStream(secret, file)) {
43+
try (OutputStream os = createEncryptedOutputStream(secretProvider.getOrCreateAttachmentSecret().getModernKey(), file)) {
4344
bitmap.compress(format, quality, os);
4445
os.close();
4546
return true;

app/src/main/java/org/thoughtcrime/securesms/glide/cache/EncryptedCacheEncoder.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,31 @@
11
package org.thoughtcrime.securesms.glide.cache;
22

33

4-
import androidx.annotation.NonNull;
54

65
import com.bumptech.glide.load.Encoder;
76
import com.bumptech.glide.load.Options;
87
import com.bumptech.glide.load.engine.bitmap_recycle.ArrayPool;
98

9+
import org.jspecify.annotations.NonNull;
1010
import org.session.libsignal.utilities.Log;
11+
import org.thoughtcrime.securesms.crypto.AttachmentSecretProvider;
1112

1213
import java.io.File;
1314
import java.io.IOException;
1415
import java.io.InputStream;
1516
import java.io.OutputStream;
1617

18+
import dagger.Lazy;
19+
1720
public class EncryptedCacheEncoder extends EncryptedCoder implements Encoder<InputStream> {
1821

1922
private static final String TAG = EncryptedCacheEncoder.class.getSimpleName();
2023

21-
private final byte[] secret;
24+
private final AttachmentSecretProvider attachmentSecretProvider;
2225
private final ArrayPool byteArrayPool;
2326

24-
public EncryptedCacheEncoder(@NonNull byte[] secret, @NonNull ArrayPool byteArrayPool) {
25-
this.secret = secret;
27+
public EncryptedCacheEncoder(AttachmentSecretProvider attachmentSecretProvider, @NonNull ArrayPool byteArrayPool) {
28+
this.attachmentSecretProvider = attachmentSecretProvider;
2629
this.byteArrayPool = byteArrayPool;
2730
}
2831

@@ -33,7 +36,7 @@ public boolean encode(@NonNull InputStream data, @NonNull File file, @NonNull Op
3336

3437
byte[] buffer = byteArrayPool.get(ArrayPool.STANDARD_BUFFER_SIZE_BYTES, byte[].class);
3538

36-
try (OutputStream outputStream = createEncryptedOutputStream(secret, file)) {
39+
try (OutputStream outputStream = createEncryptedOutputStream(attachmentSecretProvider.getOrCreateAttachmentSecret().getModernKey(), file)) {
3740
int read;
3841

3942
while ((read = data.read(buffer)) != -1) {

app/src/main/java/org/thoughtcrime/securesms/glide/cache/EncryptedGifCacheDecoder.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import androidx.annotation.NonNull;
55
import androidx.annotation.Nullable;
66
import org.session.libsignal.utilities.Log;
7+
import org.thoughtcrime.securesms.crypto.AttachmentSecretProvider;
78

89
import com.bumptech.glide.load.Options;
910
import com.bumptech.glide.load.ResourceDecoder;
@@ -19,19 +20,19 @@ public class EncryptedGifCacheDecoder extends EncryptedCoder implements Resource
1920

2021
private static final String TAG = EncryptedGifCacheDecoder.class.getSimpleName();
2122

22-
private final byte[] secret;
23+
private final AttachmentSecretProvider attachmentSecretProvider;
2324
private final StreamGifDecoder gifDecoder;
2425

25-
public EncryptedGifCacheDecoder(@NonNull byte[] secret, @NonNull StreamGifDecoder gifDecoder) {
26-
this.secret = secret;
26+
public EncryptedGifCacheDecoder(@NonNull AttachmentSecretProvider attachmentSecretProvider, @NonNull StreamGifDecoder gifDecoder) {
27+
this.attachmentSecretProvider = attachmentSecretProvider;
2728
this.gifDecoder = gifDecoder;
2829
}
2930

3031
@Override
3132
public boolean handles(@NonNull File source, @NonNull Options options) {
3233
Log.i(TAG, "Checking item for encrypted GIF cache decoder: " + source.toString());
3334

34-
try (InputStream inputStream = createEncryptedInputStream(secret, source)) {
35+
try (InputStream inputStream = createEncryptedInputStream(attachmentSecretProvider.getOrCreateAttachmentSecret().getModernKey(), source)) {
3536
return gifDecoder.handles(inputStream, options);
3637
} catch (IOException e) {
3738
Log.w(TAG, e);
@@ -43,7 +44,7 @@ public boolean handles(@NonNull File source, @NonNull Options options) {
4344
@Override
4445
public Resource<GifDrawable> decode(@NonNull File source, int width, int height, @NonNull Options options) throws IOException {
4546
Log.i(TAG, "Encrypted GIF cache decoder running...");
46-
try (InputStream inputStream = createEncryptedInputStream(secret, source)) {
47+
try (InputStream inputStream = createEncryptedInputStream(attachmentSecretProvider.getOrCreateAttachmentSecret().getModernKey(), source)) {
4748
return gifDecoder.decode(inputStream, width, height, options);
4849
}
4950
}

0 commit comments

Comments
 (0)