Skip to content

Commit c421a26

Browse files
committed
Merge remote-tracking branch 'origin/dev' into release/1.27.1
# Conflicts: # app/build.gradle.kts
2 parents 1c84cbc + a697d14 commit c421a26

File tree

596 files changed

+24397
-56800
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

596 files changed

+24397
-56800
lines changed

.github/workflows/build_and_test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- variant: 'play'
2626
run_test: true
2727
steps:
28-
- uses: actions/checkout@v4
28+
- uses: actions/checkout@v5
2929
with:
3030
submodules: 'recursive'
3131

@@ -38,14 +38,14 @@ jobs:
3838
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', 'gradle.properties') }}-${{ matrix.variant }}
3939

4040
- name: Set up JDK 21
41-
uses: actions/setup-java@v4
41+
uses: actions/setup-java@v5
4242
with:
4343
distribution: 'temurin'
4444
java-version: '21'
4545

4646
- name: Build with gradle
4747
id: build
48-
run: ./gradlew assemble${{ matrix.variant }}${{ matrix.build_type }} ${{ matrix.extra_build_command_options }}
48+
run: ./gradlew assemble${{ matrix.variant }}${{ matrix.build_type }} ${{ matrix.extra_build_command_options }} --stacktrace
4949

5050
- name: Run unit tests
5151
if: ${{ matrix.run_test == true }}

app/build.gradle.kts

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ plugins {
1212
alias(libs.plugins.hilt.android)
1313
alias(libs.plugins.dependency.analysis)
1414
alias(libs.plugins.google.services)
15+
alias(libs.plugins.protobuf.compiler)
1516

1617
id("generate-ip-country-data")
1718
id("rename-apk")
@@ -47,6 +48,7 @@ val getGitHash = providers
4748

4849
val firebaseEnabledVariants = listOf("play", "fdroid")
4950
val nonPlayVariants = listOf("fdroid", "website") + if (huaweiEnabled) listOf("huawei") else emptyList()
51+
val nonDebugBuildTypes = listOf("release", "qa", "automaticQa")
5052

5153
fun VariantDimension.devNetDefaultOn(defaultOn: Boolean) {
5254
val fqEnumClass = "org.session.libsession.utilities.Environment"
@@ -84,6 +86,23 @@ kotlin {
8486
}
8587
}
8688

89+
protobuf {
90+
protoc {
91+
artifact = libs.protoc.get().toString()
92+
}
93+
94+
plugins {
95+
generateProtoTasks {
96+
all().forEach {
97+
it.builtins {
98+
create("java") {
99+
}
100+
}
101+
}
102+
}
103+
}
104+
}
105+
87106
android {
88107
namespace = "network.loki.messenger"
89108
useLibrary("org.apache.http.legacy")
@@ -114,10 +133,6 @@ android {
114133
buildConfig = true
115134
}
116135

117-
composeOptions {
118-
kotlinCompilerExtensionVersion = libs.versions.kotlinComposeCompilerVersion.get()
119-
}
120-
121136
defaultConfig {
122137
versionCode = canonicalVersionCode * postFixSize
123138
versionName = canonicalVersionName
@@ -208,6 +223,14 @@ android {
208223
resources.srcDirs("$nonPlayCommonDir/resources")
209224
}
210225
}
226+
227+
val nonDebugDir = "src/nonDebug"
228+
nonDebugBuildTypes.forEach { buildType ->
229+
maybeCreate(buildType).apply {
230+
java.srcDirs("$nonDebugDir/kotlin")
231+
resources.srcDirs("$nonDebugDir/resources")
232+
}
233+
}
211234
}
212235

213236

@@ -329,6 +352,7 @@ dependencies {
329352
implementation(libs.androidx.activity.compose)
330353
implementation(libs.androidx.fragment.ktx)
331354
implementation(libs.androidx.core.ktx)
355+
implementation(libs.androidx.interpolator)
332356

333357
// Add firebase dependencies to specific variants
334358
for (variant in firebaseEnabledVariants) {
@@ -355,15 +379,13 @@ dependencies {
355379
implementation(libs.android)
356380
implementation(libs.photoview)
357381
implementation(libs.glide)
358-
implementation(libs.compose)
359-
implementation(libs.eventbus)
382+
implementation(libs.glide.compose)
383+
implementation(libs.coil.compose)
384+
implementation(libs.coil.gif)
360385
implementation(libs.android.image.cropper)
361386
implementation(libs.subsampling.scale.image.view) {
362387
exclude(group = "com.android.support", module = "support-annotations")
363388
}
364-
implementation(libs.tooltips) {
365-
exclude(group = "com.android.support", module = "appcompat-v7")
366-
}
367389
implementation(libs.stream)
368390
implementation(libs.androidx.sqlite.ktx)
369391
implementation(libs.sqlcipher.android)
@@ -450,6 +472,8 @@ dependencies {
450472
implementation(libs.zxing.core)
451473

452474
implementation(libs.androidx.biometric)
475+
476+
debugImplementation(libs.sqlite.web.viewer)
453477
}
454478

455479
fun getLastCommitTimestamp(): String {
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package org.thoughtcrime.securesms.debugmenu
2+
3+
import dev.fanchao.sqliteviewer.StartedInstance
4+
import dev.fanchao.sqliteviewer.model.SupportQueryable
5+
import dev.fanchao.sqliteviewer.startDatabaseViewerServer
6+
import kotlinx.coroutines.CoroutineScope
7+
import kotlinx.coroutines.flow.MutableStateFlow
8+
import kotlinx.coroutines.flow.SharingStarted
9+
import kotlinx.coroutines.flow.StateFlow
10+
import kotlinx.coroutines.flow.flatMapLatest
11+
import kotlinx.coroutines.flow.flowOf
12+
import kotlinx.coroutines.flow.map
13+
import kotlinx.coroutines.flow.stateIn
14+
import kotlinx.coroutines.flow.update
15+
import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper
16+
import org.thoughtcrime.securesms.dependencies.ManagerScope
17+
import org.thoughtcrime.securesms.util.CurrentActivityObserver
18+
import javax.inject.Inject
19+
import javax.inject.Provider
20+
import javax.inject.Singleton
21+
22+
@Singleton
23+
class DatabaseInspector @Inject constructor(
24+
@param:ManagerScope private val coroutineScope: CoroutineScope,
25+
private val currentActivityObserver: CurrentActivityObserver,
26+
private val openHelper: Provider<SQLCipherOpenHelper>,
27+
) {
28+
val available: Boolean get() = true
29+
30+
private val instance = MutableStateFlow<StartedInstance?>(null)
31+
32+
val enabled: StateFlow<Boolean> = instance
33+
.flatMapLatest { st ->
34+
st?.state?.map {
35+
it is StartedInstance.State.Running
36+
} ?: flowOf(false)
37+
}
38+
.stateIn(coroutineScope, SharingStarted.Eagerly, false)
39+
40+
fun start() {
41+
instance.update { inst ->
42+
inst?.takeIf { it.state.value !is StartedInstance.State.Stopped } ?: startDatabaseViewerServer(
43+
currentActivityObserver.currentActivity.value!!,
44+
port = 3000,
45+
queryable = SupportQueryable(openHelper.get().writableDatabase)
46+
)
47+
}
48+
}
49+
50+
fun stop() {
51+
instance.update {
52+
it?.stop()
53+
null
54+
}
55+
}
56+
}

app/src/main/AndroidManifest.xml

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,10 @@
167167
android:theme="@style/Theme.Session.DayNight.NoActionBar"
168168
android:label="@string/sessionSettings"
169169
android:screenOrientation="portrait" />
170+
<activity
171+
android:name="org.thoughtcrime.securesms.preferences.prosettings.ProSettingsActivity"
172+
android:theme="@style/Theme.Session.DayNight.NoActionBar"
173+
android:screenOrientation="portrait" />
170174
<activity
171175
android:name="org.thoughtcrime.securesms.recoverypassword.RecoveryPasswordActivity"
172176
android:screenOrientation="portrait" />
@@ -395,14 +399,6 @@
395399
android:name="android.support.FILE_PROVIDER_PATHS"
396400
android:resource="@xml/file_provider_paths" />
397401
</provider>
398-
<provider
399-
android:name="org.thoughtcrime.securesms.database.DatabaseContentProviders$Conversation"
400-
android:authorities="network.loki.securesms.database.conversation${authority_postfix}"
401-
android:exported="false" />
402-
<provider
403-
android:name="org.thoughtcrime.securesms.database.DatabaseContentProviders$ConversationList"
404-
android:authorities="network.loki.securesms.database.conversationlist${authority_postfix}"
405-
android:exported="false" />
406402
<provider
407403
android:name="org.thoughtcrime.securesms.database.DatabaseContentProviders$Attachment"
408404
android:authorities="network.loki.securesms.database.attachment${authority_postfix}"
@@ -415,10 +411,6 @@
415411
android:name="org.thoughtcrime.securesms.database.DatabaseContentProviders$StickerPack"
416412
android:authorities="network.loki.securesms.database.stickerpack${authority_postfix}"
417413
android:exported="false" />
418-
<provider
419-
android:name="org.thoughtcrime.securesms.database.DatabaseContentProviders$Recipient"
420-
android:authorities="network.loki.securesms.database.recipient${authority_postfix}"
421-
android:exported="false" />
422414

423415
<receiver android:name="org.thoughtcrime.securesms.service.BootReceiver"
424416
android:exported="true">
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
package org.session.libsession.avatars
2+
3+
import android.app.Application
4+
import kotlinx.coroutines.CoroutineScope
5+
import kotlinx.coroutines.Dispatchers
6+
import kotlinx.coroutines.launch
7+
import kotlinx.coroutines.withContext
8+
import org.session.libsession.utilities.recipients.RemoteFile
9+
import org.session.libsignal.utilities.Log
10+
import org.thoughtcrime.securesms.attachments.RemoteFileDownloadWorker
11+
import org.thoughtcrime.securesms.database.RecipientSettingsDatabase
12+
import org.thoughtcrime.securesms.dependencies.ManagerScope
13+
import org.thoughtcrime.securesms.glide.RecipientAvatarDownloadManager
14+
import java.io.File
15+
import javax.inject.Inject
16+
import javax.inject.Singleton
17+
18+
@Singleton
19+
class AvatarCacheCleaner @Inject constructor(
20+
private val application: Application,
21+
private val recipientAvatarDownloadManager: RecipientAvatarDownloadManager,
22+
private val recipientSettingsDatabase: RecipientSettingsDatabase,
23+
@param:ManagerScope private val coroutineScope: CoroutineScope
24+
) {
25+
26+
companion object {
27+
const val TAG = "AvatarCacheCleaner"
28+
}
29+
30+
/**
31+
* Deletes avatar files under cache/remote_files that are no longer referenced
32+
* in the current config. Returns number of files deleted.
33+
*/
34+
private suspend fun cleanUpAvatars(): Int = withContext(Dispatchers.IO) {
35+
// 1) Build the set of still-wanted Avatars from:
36+
// -> Config
37+
// -> Recipient Settings DB
38+
39+
// config
40+
val avatarsFromConfig: Set<RemoteFile> = recipientAvatarDownloadManager.getAllAvatars()
41+
// recipient_settings
42+
val recipientAvatars : Set<RemoteFile> = recipientSettingsDatabase.getAllReferencedAvatarFiles()
43+
44+
// 3) Union of everything we want to keep
45+
val filesToKeep: Set<RemoteFile> =
46+
(avatarsFromConfig + recipientAvatars).toSet()
47+
48+
// 4) Map to actual files (same hashing/location as downloader)
49+
val wantedFiles: Set<File> = filesToKeep
50+
.map { RemoteFileDownloadWorker.computeFileName(application, it) }
51+
.toSet()
52+
53+
// 5) Delete everything not wanted in cache/remote_files
54+
val files = RemoteFileDownloadWorker.listDownloadedFiles(application)
55+
var deleted = 0
56+
for (file in files) {
57+
if (file !in wantedFiles && file.delete()) deleted++
58+
}
59+
60+
deleted
61+
}
62+
63+
fun launchAvatarCleanup() {
64+
coroutineScope.launch(Dispatchers.IO) {
65+
val deleted = cleanUpAvatars()
66+
Log.d(TAG, "Avatar cache removed: $deleted files")
67+
}
68+
}
69+
}

app/src/main/java/org/session/libsession/avatars/AvatarHelper.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@
1919
import java.util.LinkedList;
2020
import java.util.List;
2121

22+
/**
23+
* @deprecated We no longer use these address-based avatars. All avatars are now stored as sha256 of
24+
* urls encrypted locally. Look at {@link org.thoughtcrime.securesms.attachments.LocalEncryptedFileOutputStream},
25+
* {@link org.thoughtcrime.securesms.attachments.RemoteFileDownloadWorker},
26+
* {@link org.thoughtcrime.securesms.glide.RecipientAvatarDownloadManager} for more information.
27+
*
28+
* Once the migration grace period is over, this class shall be removed.
29+
*/
30+
@Deprecated(forRemoval = true)
2231
public class AvatarHelper {
2332

2433
private static final String AVATAR_DIRECTORY = "avatars";

app/src/main/java/org/session/libsession/avatars/ContactColors.java

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

app/src/main/java/org/session/libsession/avatars/ContactPhoto.java

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

app/src/main/java/org/session/libsession/avatars/FallbackContactPhoto.java

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

0 commit comments

Comments
 (0)