From 168814149b6d9d89396ffca3bec2745871721b5e Mon Sep 17 00:00:00 2001 From: ganfra Date: Thu, 13 Dec 2018 11:00:50 +0100 Subject: [PATCH] Update some dependencies --- .idea/misc.xml | 2 +- app/build.gradle | 6 ++++++ matrix-sdk-android-rx/build.gradle | 6 ++++++ matrix-sdk-android/build.gradle | 12 ++++++++---- .../session/events/prune/PruneEventWorker.kt | 4 ++-- .../internal/session/group/GetGroupDataRequest.kt | 3 +-- .../internal/session/group/GetGroupDataWorker.kt | 4 ++-- .../session/room/send/DefaultSendService.kt | 13 +++++++++---- .../internal/session/room/send/SendEventWorker.kt | 6 +++--- .../matrix/android/internal/util/CancelableWork.kt | 8 ++++---- 10 files changed, 42 insertions(+), 22 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 99202cc2d6..c0f68eddd7 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -25,7 +25,7 @@ - + diff --git a/app/build.gradle b/app/build.gradle index 3481c69425..98e9b05aca 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -23,6 +23,12 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + } diff --git a/matrix-sdk-android-rx/build.gradle b/matrix-sdk-android-rx/build.gradle index 0fdbb989d4..8f51158f89 100644 --- a/matrix-sdk-android-rx/build.gradle +++ b/matrix-sdk-android-rx/build.gradle @@ -24,6 +24,12 @@ android { } } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + } dependencies { diff --git a/matrix-sdk-android/build.gradle b/matrix-sdk-android/build.gradle index 09d01fceae..57dc3c02dc 100644 --- a/matrix-sdk-android/build.gradle +++ b/matrix-sdk-android/build.gradle @@ -10,7 +10,7 @@ buildscript { jcenter() } dependencies { - classpath "io.realm:realm-gradle-plugin:5.7.0" + classpath "io.realm:realm-gradle-plugin:5.8.0" } } @@ -43,6 +43,11 @@ android { installOptions "-g" } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + } dependencies { @@ -51,7 +56,6 @@ dependencies { def support_version = '28.0.0' def moshi_version = '1.8.0' def lifecycle_version = "1.1.1" - def powermock_version = "2.0.0-RC.4" implementation fileTree(dir: 'libs', include: ['*.aar']) implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" @@ -69,7 +73,7 @@ dependencies { implementation 'com.squareup.retrofit2:converter-gson:2.4.0' implementation 'com.squareup.okhttp3:okhttp:3.10.0' implementation 'com.squareup.okhttp3:logging-interceptor:3.10.0' - implementation 'com.squareup.okio:okio:1.15.0' + implementation 'com.squareup.okio:okio:1.16.0' implementation 'com.novoda:merlin:1.1.6' implementation 'com.google.code.gson:gson:2.8.5' implementation "com.squareup.moshi:moshi-adapters:$moshi_version" @@ -83,7 +87,7 @@ dependencies { implementation "android.arch.paging:runtime:1.0.1" // Work - implementation "android.arch.work:work-runtime-ktx:1.0.0-alpha10" + implementation "android.arch.work:work-runtime-ktx:1.0.0-alpha13" // FP implementation "io.arrow-kt:arrow-core:$arrow_version" diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/events/prune/PruneEventWorker.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/events/prune/PruneEventWorker.kt index cf0f6b6117..0f158d6103 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/events/prune/PruneEventWorker.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/events/prune/PruneEventWorker.kt @@ -33,7 +33,7 @@ internal class PruneEventWorker(context: Context, override fun doWork(): Result { val params = WorkerParamsFactory.fromData(inputData) - ?: return Result.FAILURE + ?: return Result.failure() val result = monarchy.tryTransactionAsync { realm -> params.updateIndexes.forEach { index -> @@ -41,7 +41,7 @@ internal class PruneEventWorker(context: Context, pruneEvent(realm, data) } } - return result.fold({ Result.RETRY }, { Result.SUCCESS }) + return result.fold({ Result.retry() }, { Result.success() }) } private fun pruneEvent(realm: Realm, redactionEvent: Event?) { diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/group/GetGroupDataRequest.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/group/GetGroupDataRequest.kt index 3ccea82971..47aa3308de 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/group/GetGroupDataRequest.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/group/GetGroupDataRequest.kt @@ -15,7 +15,6 @@ import im.vector.matrix.android.internal.session.group.model.GroupSummaryRespons import im.vector.matrix.android.internal.session.group.model.GroupUsers import im.vector.matrix.android.internal.util.CancelableCoroutine import im.vector.matrix.android.internal.util.MatrixCoroutineDispatchers -import im.vector.matrix.android.internal.util.retry import im.vector.matrix.android.internal.util.tryTransactionSync import io.realm.kotlin.createObject import kotlinx.coroutines.GlobalScope @@ -31,7 +30,7 @@ internal class GetGroupDataRequest( callback: MatrixCallback ): Cancelable { val job = GlobalScope.launch(coroutineDispatchers.main) { - val groupOrFailure = retry { getGroupData(groupId) } + val groupOrFailure = getGroupData(groupId) groupOrFailure.fold({ callback.onFailure(it) }, { callback.onSuccess(true) }) } return CancelableCoroutine(job) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/group/GetGroupDataWorker.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/group/GetGroupDataWorker.kt index bed103e42f..ce4a8c10eb 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/group/GetGroupDataWorker.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/group/GetGroupDataWorker.kt @@ -24,14 +24,14 @@ internal class GetGroupDataWorker(context: Context, override fun doWork(): Result { val params = WorkerParamsFactory.fromData(inputData) - ?: return Result.FAILURE + ?: return Result.failure() val results = params.updateIndexes.map { index -> val groupId = params.groupIds[index] fetchGroupData(groupId) } val isSuccessful = results.none { it.isFailure() } - return if (isSuccessful) Result.SUCCESS else Result.RETRY + return if (isSuccessful) Result.success() else Result.retry() } private fun fetchGroupData(groupId: String): Try { diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/DefaultSendService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/DefaultSendService.kt index a0feebc02c..1623df074c 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/DefaultSendService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/DefaultSendService.kt @@ -1,6 +1,11 @@ package im.vector.matrix.android.internal.session.room.send -import androidx.work.* +import androidx.work.BackoffPolicy +import androidx.work.Constraints +import androidx.work.ExistingWorkPolicy +import androidx.work.NetworkType +import androidx.work.OneTimeWorkRequestBuilder +import androidx.work.WorkManager import com.zhuinden.monarchy.Monarchy import im.vector.matrix.android.api.MatrixCallback import im.vector.matrix.android.api.session.events.model.Event @@ -32,7 +37,7 @@ internal class DefaultSendService(private val roomId: String, monarchy.tryTransactionAsync { realm -> val chunkEntity = ChunkEntity.findLastLiveChunkFromRoom(realm, roomId) - ?: return@tryTransactionAsync + ?: return@tryTransactionAsync chunkEntity.add(event, PaginationDirection.FORWARDS) chunkEntity.updateDisplayIndexes() } @@ -46,11 +51,11 @@ internal class DefaultSendService(private val roomId: String, .setBackoffCriteria(BackoffPolicy.LINEAR, 10_000, TimeUnit.MILLISECONDS) .build() - val work = WorkManager.getInstance() + WorkManager.getInstance() .beginUniqueWork(SEND_WORK, ExistingWorkPolicy.APPEND, sendWork) .enqueue() - return CancelableWork(work) + return CancelableWork(sendWork.id) } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/SendEventWorker.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/SendEventWorker.kt index 946b567cc7..4ed412070d 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/SendEventWorker.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/SendEventWorker.kt @@ -31,10 +31,10 @@ internal class SendEventWorker(context: Context, params: WorkerParameters) override fun doWork(): Result { val params = WorkerParamsFactory.fromData(inputData) - ?: return Result.FAILURE + ?: return Result.failure() if (params.event.eventId == null) { - return Result.FAILURE + return Result.failure() } val result = executeRequest { @@ -51,7 +51,7 @@ internal class SendEventWorker(context: Context, params: WorkerParameters) dummyEventEntity?.eventId = sendResponse.eventId } } - return result.fold({ Result.RETRY }, { Result.SUCCESS }) + return result.fold({ Result.retry() }, { Result.success() }) } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/util/CancelableWork.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/util/CancelableWork.kt index d78f204537..cdd83f7044 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/util/CancelableWork.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/util/CancelableWork.kt @@ -1,13 +1,13 @@ package im.vector.matrix.android.internal.util -import com.google.common.util.concurrent.ListenableFuture +import androidx.work.WorkManager import im.vector.matrix.android.api.util.Cancelable -import kotlinx.coroutines.Job +import java.util.* -internal class CancelableWork(private val work: ListenableFuture) : Cancelable { +internal class CancelableWork(private val workId: UUID) : Cancelable { override fun cancel() { - work.cancel(true) + WorkManager.getInstance().cancelWorkById(workId) } } \ No newline at end of file