mirror of
https://github.com/oxen-io/session-android.git
synced 2025-08-11 19:07:40 +00:00
Merge remote-tracking branch 'upstream/dev'
# Conflicts: # app/build.gradle
This commit is contained in:
@@ -23,12 +23,13 @@ dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
|
||||
implementation 'androidx.core:core-ktx:1.3.2'
|
||||
implementation 'androidx.appcompat:appcompat:1.2.0'
|
||||
implementation 'androidx.preference:preference-ktx:1.1.1'
|
||||
implementation 'com.google.android.material:material:1.2.1'
|
||||
implementation "com.google.protobuf:protobuf-java:$protobufVersion"
|
||||
testImplementation 'junit:junit:4.+'
|
||||
implementation "com.google.dagger:hilt-android:$daggerVersion"
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
||||
implementation 'com.github.bumptech.glide:glide:4.11.0'
|
||||
implementation "com.github.bumptech.glide:glide:$glideVersion"
|
||||
implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
|
||||
implementation 'com.annimon:stream:1.1.8'
|
||||
implementation 'com.makeramen:roundedimageview:2.1.0'
|
||||
@@ -39,10 +40,19 @@ dependencies {
|
||||
implementation "com.squareup.okhttp3:okhttp:$okhttpVersion"
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
|
||||
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion"
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.2"
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutinesVersion"
|
||||
implementation "nl.komponents.kovenant:kovenant:$kovenantVersion"
|
||||
testImplementation "junit:junit:3.8.2"
|
||||
testImplementation "org.assertj:assertj-core:1.7.1"
|
||||
testImplementation 'junit:junit:4.12'
|
||||
testImplementation 'org.assertj:assertj-core:3.11.1'
|
||||
testImplementation "org.mockito:mockito-inline:4.0.0"
|
||||
testImplementation "org.mockito.kotlin:mockito-kotlin:$mockitoKotlinVersion"
|
||||
testImplementation 'org.powermock:powermock-api-mockito:1.6.1'
|
||||
testImplementation 'org.powermock:powermock-module-junit4:1.6.1'
|
||||
testImplementation 'org.powermock:powermock-module-junit4-rule:1.6.1'
|
||||
testImplementation 'org.powermock:powermock-classloading-xstream:1.6.1'
|
||||
testImplementation 'androidx.test:core:1.3.0'
|
||||
testImplementation "androidx.arch.core:core-testing:2.1.0"
|
||||
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutinesVersion"
|
||||
testImplementation "org.conscrypt:conscrypt-openjdk-uber:2.0.0"
|
||||
implementation 'org.greenrobot:eventbus:3.0.0'
|
||||
}
|
@@ -45,7 +45,7 @@ class BatchMessageReceiveJob(
|
||||
|
||||
fun executeAsync(): Promise<Unit, Exception> {
|
||||
return task {
|
||||
messages.forEach { messageParameters ->
|
||||
messages.iterator().forEach { messageParameters ->
|
||||
val (data, serverHash, openGroupMessageServerID) = messageParameters
|
||||
try {
|
||||
val (message, proto) = MessageReceiver.parse(data, openGroupMessageServerID)
|
||||
|
@@ -1,11 +1,18 @@
|
||||
package org.session.libsession.messaging.jobs
|
||||
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.CoroutineDispatcher
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
import kotlinx.coroutines.asCoroutineDispatcher
|
||||
import kotlinx.coroutines.channels.Channel
|
||||
import kotlinx.coroutines.channels.Channel.Factory.UNLIMITED
|
||||
import kotlinx.coroutines.isActive
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.plus
|
||||
import org.session.libsession.messaging.MessagingModuleConfiguration
|
||||
import org.session.libsignal.utilities.Log
|
||||
import java.util.*
|
||||
import java.util.Timer
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import java.util.concurrent.Executors
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
@@ -25,7 +32,10 @@ class JobQueue : JobDelegate {
|
||||
|
||||
val timer = Timer()
|
||||
|
||||
private fun CoroutineScope.processWithDispatcher(channel: Channel<Job>, dispatcher: CoroutineDispatcher) = launch(dispatcher) {
|
||||
private fun CoroutineScope.processWithDispatcher(
|
||||
channel: Channel<Job>,
|
||||
dispatcher: CoroutineDispatcher
|
||||
) = launch(dispatcher) {
|
||||
for (job in channel) {
|
||||
if (!isActive) break
|
||||
job.delegate = this@JobQueue
|
||||
@@ -74,7 +84,7 @@ class JobQueue : JobDelegate {
|
||||
|
||||
fun add(job: Job) {
|
||||
addWithoutExecuting(job)
|
||||
queue.offer(job) // offer always called on unlimited capacity
|
||||
queue.trySend(job) // offer always called on unlimited capacity
|
||||
}
|
||||
|
||||
private fun addWithoutExecuting(job: Job) {
|
||||
@@ -97,7 +107,7 @@ class JobQueue : JobDelegate {
|
||||
Log.e("Loki","tried to re-queue pending/in-progress job")
|
||||
return
|
||||
}
|
||||
queue.offer(job)
|
||||
queue.trySend(job)
|
||||
Log.d("Loki", "resumed pending send message $id")
|
||||
}
|
||||
|
||||
@@ -114,7 +124,7 @@ class JobQueue : JobDelegate {
|
||||
}
|
||||
pendingJobs.sortedBy { it.id }.forEach { job ->
|
||||
Log.i("Loki", "Resuming pending job of type: ${job::class.simpleName}.")
|
||||
queue.offer(job) // Offer always called on unlimited capacity
|
||||
queue.trySend(job) // Offer always called on unlimited capacity
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,7 +180,7 @@ class JobQueue : JobDelegate {
|
||||
Log.i("Loki", "${job::class.simpleName} failed; scheduling retry (failure count is ${job.failureCount}).")
|
||||
timer.schedule(delay = retryInterval) {
|
||||
Log.i("Loki", "Retrying ${job::class.simpleName}.")
|
||||
queue.offer(job)
|
||||
queue.trySend(job)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -155,7 +155,7 @@ object MessageSender {
|
||||
var isSuccess = false
|
||||
val promiseCount = promises.size
|
||||
var errorCount = 0
|
||||
promises.forEach { promise: RawResponsePromise ->
|
||||
promises.iterator().forEach { promise: RawResponsePromise ->
|
||||
promise.success {
|
||||
if (isSuccess) { return@success } // Succeed as soon as the first promise succeeds
|
||||
isSuccess = true
|
||||
|
@@ -237,7 +237,7 @@ fun MessageReceiver.handleVisibleMessage(message: VisibleMessage, proto: SignalS
|
||||
val messageID = storage.persist(message, quoteModel, linkPreviews, message.groupPublicKey, openGroupID, attachments) ?: throw MessageReceiver.Error.DuplicateMessage
|
||||
// Parse & persist attachments
|
||||
// Start attachment downloads if needed
|
||||
storage.getAttachmentsForMessage(messageID).forEach { attachment ->
|
||||
storage.getAttachmentsForMessage(messageID).iterator().forEach { attachment ->
|
||||
attachment.attachmentId?.let { id ->
|
||||
val downloadJob = AttachmentDownloadJob(id.rowId, messageID)
|
||||
JobQueue.shared.add(downloadJob)
|
||||
|
@@ -52,7 +52,7 @@ object PushNotificationAPI {
|
||||
// Unsubscribe from all closed groups
|
||||
val allClosedGroupPublicKeys = MessagingModuleConfiguration.shared.storage.getAllClosedGroupPublicKeys()
|
||||
val userPublicKey = MessagingModuleConfiguration.shared.storage.getUserPublicKey()!!
|
||||
allClosedGroupPublicKeys.forEach { closedGroup ->
|
||||
allClosedGroupPublicKeys.iterator().forEach { closedGroup ->
|
||||
performOperation(ClosedGroupOperation.Unsubscribe, closedGroup, userPublicKey)
|
||||
}
|
||||
}
|
||||
@@ -81,7 +81,7 @@ object PushNotificationAPI {
|
||||
}
|
||||
// Subscribe to all closed groups
|
||||
val allClosedGroupPublicKeys = MessagingModuleConfiguration.shared.storage.getAllClosedGroupPublicKeys()
|
||||
allClosedGroupPublicKeys.forEach { closedGroup ->
|
||||
allClosedGroupPublicKeys.iterator().forEach { closedGroup ->
|
||||
performOperation(ClosedGroupOperation.Subscribe, closedGroup, publicKey)
|
||||
}
|
||||
}
|
||||
|
@@ -39,7 +39,7 @@ class ClosedGroupPollerV2 {
|
||||
fun start() {
|
||||
val storage = MessagingModuleConfiguration.shared.storage
|
||||
val allGroupPublicKeys = storage.getAllClosedGroupPublicKeys()
|
||||
allGroupPublicKeys.forEach { startPolling(it) }
|
||||
allGroupPublicKeys.iterator().forEach { startPolling(it) }
|
||||
}
|
||||
|
||||
fun startPolling(groupPublicKey: String) {
|
||||
@@ -51,7 +51,7 @@ class ClosedGroupPollerV2 {
|
||||
fun stop() {
|
||||
val storage = MessagingModuleConfiguration.shared.storage
|
||||
val allGroupPublicKeys = storage.getAllClosedGroupPublicKeys()
|
||||
allGroupPublicKeys.forEach { stopPolling(it) }
|
||||
allGroupPublicKeys.iterator().forEach { stopPolling(it) }
|
||||
}
|
||||
|
||||
fun stopPolling(groupPublicKey: String) {
|
||||
@@ -100,7 +100,7 @@ class ClosedGroupPollerV2 {
|
||||
}
|
||||
promise.success { envelopes ->
|
||||
if (!isPolling(groupPublicKey)) { return@success }
|
||||
envelopes.forEach { (envelope, serverHash) ->
|
||||
envelopes.iterator().forEach { (envelope, serverHash) ->
|
||||
val job = MessageReceiveJob(envelope.toByteArray(), serverHash)
|
||||
JobQueue.shared.add(job)
|
||||
}
|
||||
|
@@ -73,7 +73,7 @@ class OpenGroupPollerV2(private val server: String, private val executorService:
|
||||
builder.build() to message.serverID
|
||||
}
|
||||
|
||||
envelopes.chunked(20).forEach { list ->
|
||||
envelopes.chunked(256).forEach { list ->
|
||||
val parameters = list.map { (message, serverId) ->
|
||||
MessageReceiveParameters(message.toByteArray(), openGroupMessageServerID = serverId)
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -22,6 +22,7 @@ import java.util.concurrent.CountDownLatch
|
||||
import java.util.concurrent.ExecutorService
|
||||
import java.util.concurrent.ThreadPoolExecutor
|
||||
import java.util.concurrent.TimeUnit
|
||||
import kotlin.math.min
|
||||
|
||||
object Util {
|
||||
@Volatile
|
||||
@@ -216,7 +217,7 @@ object Util {
|
||||
val results: MutableList<List<T>> = LinkedList()
|
||||
var index = 0
|
||||
while (index < list.size) {
|
||||
val subListSize = Math.min(partitionSize, list.size - index)
|
||||
val subListSize = min(partitionSize, list.size - index)
|
||||
results.add(list.subList(index, index + subListSize))
|
||||
index += partitionSize
|
||||
}
|
||||
|
@@ -2,7 +2,6 @@
|
||||
<resources>
|
||||
|
||||
<string-array name="language_entries">
|
||||
<item>@string/preferences__default</item>
|
||||
<item>English</item>
|
||||
<item>Arabic العربية</item>
|
||||
<item>Azərbaycan</item>
|
||||
@@ -119,18 +118,6 @@
|
||||
<item>vi</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="pref_led_color_entries">
|
||||
<item>@string/preferences__green</item>
|
||||
<item>@string/preferences__red</item>
|
||||
<item>@string/preferences__blue</item>
|
||||
<item>@string/preferences__orange</item>
|
||||
<item>@string/preferences__cyan</item>
|
||||
<item>@string/preferences__magenta</item>
|
||||
<item>@string/preferences__white</item>
|
||||
<item>@string/preferences__none</item>
|
||||
</string-array>
|
||||
|
||||
|
||||
<string-array name="pref_led_color_values" translatable="false">
|
||||
<item>green</item>
|
||||
<item>red</item>
|
||||
@@ -142,27 +129,12 @@
|
||||
<item>none</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="pref_led_blink_pattern_entries">
|
||||
<item>@string/preferences__fast</item>
|
||||
<item>@string/preferences__normal</item>
|
||||
<item>@string/preferences__slow</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="pref_led_blink_pattern_values" translatable="false">
|
||||
<item>300,300</item>
|
||||
<item>500,2000</item>
|
||||
<item>3000,3000</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="pref_repeat_alerts_entries">
|
||||
<item>@string/preferences__never</item>
|
||||
<item>@string/preferences__one_time</item>
|
||||
<item>@string/preferences__two_times</item>
|
||||
<item>@string/preferences__three_times</item>
|
||||
<item>@string/preferences__five_times</item>
|
||||
<item>@string/preferences__ten_times</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="pref_repeat_alerts_values" translatable="false">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
@@ -177,25 +149,6 @@
|
||||
<item>custom</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="default_or_custom_entries">
|
||||
<item>@string/arrays__use_default</item>
|
||||
<item>@string/arrays__use_custom</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="mute_durations">
|
||||
<item>@string/arrays__mute_for_one_hour</item>
|
||||
<item>@string/arrays__mute_for_two_hours</item>
|
||||
<item>@string/arrays__mute_for_one_day</item>
|
||||
<item>@string/arrays__mute_for_seven_days</item>
|
||||
<item>@string/arrays__mute_for_one_year</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="pref_notification_privacy_entries">
|
||||
<item>@string/arrays__name_and_message</item>
|
||||
<item>@string/arrays__name_only</item>
|
||||
<item>@string/arrays__no_name_or_message</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="pref_notification_privacy_values">
|
||||
<item>all</item>
|
||||
<item>contact</item>
|
||||
@@ -247,12 +200,6 @@
|
||||
<item>#000000</item>
|
||||
</array>
|
||||
|
||||
<string-array name="pref_notification_priority_entries">
|
||||
<item>@string/arrays__default</item>
|
||||
<item>@string/arrays__high</item>
|
||||
<item>@string/arrays__max</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="pref_notification_priority_values">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
|
@@ -121,6 +121,7 @@
|
||||
<attr name="menu_info_icon" format="reference" />
|
||||
<attr name="menu_pin_icon" format="reference" />
|
||||
<attr name="menu_unpin_icon" format="reference" />
|
||||
<attr name="menu_mark_all_as_read" format="reference" />
|
||||
|
||||
<attr name="pref_icon_tint" format="color"/>
|
||||
|
||||
|
Reference in New Issue
Block a user