From 34fb5462002fbd114e961715eaceaca4335fd8f1 Mon Sep 17 00:00:00 2001 From: Konrad Pozniak Date: Sun, 22 Nov 2020 19:02:54 +0100 Subject: [PATCH] upgrade dependencies (#1990) * upgrade dependencies * fix tests --- app/build.gradle | 24 +++++++++---------- .../announcements/AnnouncementsActivity.kt | 8 +++---- .../announcements/AnnouncementsViewModel.kt | 2 +- .../components/compose/ComposeViewModel.kt | 3 --- .../keylesspalace/tusky/db/AccountManager.kt | 2 +- .../tusky/util/CustomEmojiHelper.kt | 4 ++-- .../tusky/ComposeActivityTest.kt | 9 ++++--- build.gradle | 4 ++-- 8 files changed, 28 insertions(+), 28 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 17ee5c91..efcb6eea 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -98,31 +98,31 @@ project.tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { ext.lifecycleVersion = "2.2.0" ext.roomVersion = '2.2.5' ext.retrofitVersion = '2.9.0' -ext.okhttpVersion = '4.8.1' +ext.okhttpVersion = '4.9.0' ext.glideVersion = '4.11.0' -ext.daggerVersion = '2.28.3' +ext.daggerVersion = '2.29.1' ext.materialdrawerVersion = '8.1.8' // if libraries are changed here, they should also be changed in LicenseActivity dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - implementation "androidx.core:core-ktx:1.3.1" + implementation "androidx.core:core-ktx:1.3.2" implementation "androidx.appcompat:appcompat:1.2.0" implementation "androidx.fragment:fragment-ktx:1.2.5" implementation "androidx.browser:browser:1.2.0" implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0" implementation "androidx.recyclerview:recyclerview:1.1.0" - implementation "androidx.exifinterface:exifinterface:1.2.0" + implementation "androidx.exifinterface:exifinterface:1.3.1" implementation "androidx.cardview:cardview:1.0.0" - implementation "androidx.preference:preference:1.1.1" + implementation "androidx.preference:preference-ktx:1.1.1" implementation "androidx.sharetarget:sharetarget:1.0.0" implementation "androidx.emoji:emoji:1.1.0" implementation "androidx.emoji:emoji-appcompat:1.1.0" implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycleVersion" implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycleVersion" implementation "androidx.lifecycle:lifecycle-reactivestreams-ktx:$lifecycleVersion" - implementation "androidx.constraintlayout:constraintlayout:1.1.3" + implementation "androidx.constraintlayout:constraintlayout:2.0.4" implementation "androidx.paging:paging-runtime-ktx:2.1.2" implementation "androidx.viewpager2:viewpager2:1.0.0" implementation "androidx.work:work-runtime:2.4.0" @@ -144,7 +144,7 @@ dependencies { implementation "com.github.bumptech.glide:glide:$glideVersion" implementation "com.github.bumptech.glide:okhttp3-integration:$glideVersion" - implementation "io.reactivex.rxjava2:rxjava:2.2.19" + implementation "io.reactivex.rxjava2:rxjava:2.2.20" implementation "io.reactivex.rxjava2:rxandroid:2.1.1" implementation "io.reactivex.rxjava2:rxkotlin:2.4.0" @@ -169,12 +169,12 @@ dependencies { implementation "de.c1710:filemojicompat:1.0.17" - testImplementation "androidx.test.ext:junit:1.1.1" - testImplementation "org.robolectric:robolectric:4.3.1" - testImplementation "org.mockito:mockito-inline:3.3.3" + testImplementation "androidx.test.ext:junit:1.1.2" + testImplementation "org.robolectric:robolectric:4.4" + testImplementation "org.mockito:mockito-inline:3.6.0" testImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0" - androidTestImplementation "androidx.test.espresso:espresso-core:3.2.0" + androidTestImplementation "androidx.test.espresso:espresso-core:3.3.0" androidTestImplementation "androidx.room:room-testing:$roomVersion" - androidTestImplementation "androidx.test.ext:junit:1.1.1" + androidTestImplementation "androidx.test.ext:junit:1.1.2" } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/announcements/AnnouncementsActivity.kt b/app/src/main/java/com/keylesspalace/tusky/components/announcements/AnnouncementsActivity.kt index f9c0ae72..5bfd17bc 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/announcements/AnnouncementsActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/announcements/AnnouncementsActivity.kt @@ -79,7 +79,7 @@ class AnnouncementsActivity : BaseActivity(), AnnouncementActionListener, OnEmoj announcementsList.addItemDecoration(divider) announcementsList.adapter = adapter - viewModel.announcements.observe(this, Observer { + viewModel.announcements.observe(this) { when (it) { is Success -> { progressBar.hide() @@ -104,11 +104,11 @@ class AnnouncementsActivity : BaseActivity(), AnnouncementActionListener, OnEmoj errorMessageView.show() } } - }) + } - viewModel.emojis.observe(this, Observer { + viewModel.emojis.observe(this) { picker.adapter = EmojiAdapter(it, this) - }) + } viewModel.load() progressBar.show() diff --git a/app/src/main/java/com/keylesspalace/tusky/components/announcements/AnnouncementsViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/components/announcements/AnnouncementsViewModel.kt index 2fd1fbae..964cc739 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/announcements/AnnouncementsViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/announcements/AnnouncementsViewModel.kt @@ -51,7 +51,7 @@ class AnnouncementsViewModel @Inject constructor( .map> { Either.Left(it) } .onErrorResumeNext( mastodonApi.getInstance() - .map { Either.Right(it) } + .map { Either.Right(it) } ) ) { emojis, either -> either.asLeftOrNull()?.copy(emojiList = emojis) diff --git a/app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeViewModel.kt index 63ab13ea..2c015899 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeViewModel.kt @@ -19,10 +19,8 @@ import android.net.Uri import android.util.Log import androidx.core.net.toUri import androidx.lifecycle.LiveData -import androidx.lifecycle.MediatorLiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.Observer -import androidx.work.impl.utils.LiveDataUtils import com.keylesspalace.tusky.adapter.ComposeAutoCompleteAdapter import com.keylesspalace.tusky.components.compose.ComposeActivity.QueuedMedia import com.keylesspalace.tusky.components.search.SearchType @@ -35,7 +33,6 @@ import com.keylesspalace.tusky.network.MastodonApi import com.keylesspalace.tusky.service.ServiceClient import com.keylesspalace.tusky.service.TootToSend import com.keylesspalace.tusky.util.* -import io.reactivex.Observable.empty import io.reactivex.Observable.just import io.reactivex.disposables.Disposable import io.reactivex.rxkotlin.Singles diff --git a/app/src/main/java/com/keylesspalace/tusky/db/AccountManager.kt b/app/src/main/java/com/keylesspalace/tusky/db/AccountManager.kt index aae0bf5a..138f71a3 100644 --- a/app/src/main/java/com/keylesspalace/tusky/db/AccountManager.kt +++ b/app/src/main/java/com/keylesspalace/tusky/db/AccountManager.kt @@ -62,7 +62,7 @@ class AccountManager @Inject constructor(db: AppDatabase) { accountDao.insertOrReplace(it) } - val maxAccountId = accounts.maxBy { it.id }?.id ?: 0 + val maxAccountId = accounts.maxByOrNull { it.id }?.id ?: 0 val newAccountId = maxAccountId + 1 activeAccount = AccountEntity(id = newAccountId, domain = domain.toLowerCase(Locale.ROOT), accessToken = accessToken, isActive = true) diff --git a/app/src/main/java/com/keylesspalace/tusky/util/CustomEmojiHelper.kt b/app/src/main/java/com/keylesspalace/tusky/util/CustomEmojiHelper.kt index 14a0ceb5..679f38d3 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/CustomEmojiHelper.kt +++ b/app/src/main/java/com/keylesspalace/tusky/util/CustomEmojiHelper.kt @@ -54,7 +54,7 @@ fun CharSequence.emojify(emojis: List?, view: View) : CharSequence { while(matcher.find()) { val span = EmojiSpan(WeakReference(view)) - builder.setSpan(span, matcher.start(), matcher.end(), 0); + builder.setSpan(span, matcher.start(), matcher.end(), 0) Glide.with(view) .asBitmap() .load(url) @@ -89,7 +89,7 @@ class EmojiSpan(val viewWeakReference: WeakReference) : ReplacementSpan() drawable.setBounds(0, 0, emojiSize, emojiSize) var transY = bottom - drawable.bounds.bottom - transY -= paint.fontMetricsInt.descent / 2; + transY -= paint.fontMetricsInt.descent / 2 canvas.translate(x, transY.toFloat()) drawable.draw(canvas) diff --git a/app/src/test/java/com/keylesspalace/tusky/ComposeActivityTest.kt b/app/src/test/java/com/keylesspalace/tusky/ComposeActivityTest.kt index 33d597a3..7f33a976 100644 --- a/app/src/test/java/com/keylesspalace/tusky/ComposeActivityTest.kt +++ b/app/src/test/java/com/keylesspalace/tusky/ComposeActivityTest.kt @@ -17,6 +17,7 @@ package com.keylesspalace.tusky import android.content.Intent +import android.os.Looper.getMainLooper import android.text.SpannedString import android.widget.EditText import androidx.test.ext.junit.runners.AndroidJUnit4 @@ -41,6 +42,7 @@ import org.junit.runner.RunWith import org.mockito.Mockito.`when` import org.mockito.Mockito.mock import org.robolectric.Robolectric +import org.robolectric.Shadows.shadowOf import org.robolectric.annotation.Config import org.robolectric.fakes.RoboMenuItem @@ -76,8 +78,8 @@ class ComposeActivityTest { notificationVibration = true, notificationLight = true ) - var instanceResponseCallback: (()->Instance)? = null - var composeOptions: ComposeActivity.ComposeOptions? = null + private var instanceResponseCallback: (()->Instance)? = null + private var composeOptions: ComposeActivity.ComposeOptions? = null @Before fun setupActivity() { @@ -185,6 +187,7 @@ class ComposeActivityTest { val customMaximum = 1000 instanceResponseCallback = { getInstanceWithMaximumTootCharacters(customMaximum) } setupActivity() + shadowOf(getMainLooper()).idle() assertEquals(customMaximum, activity.maximumTootCharacters) } @@ -230,7 +233,7 @@ class ComposeActivityTest { editor.setSelection(caretIndex) activity.prependSelectedWordsWith(insertText) // Text should be inserted at caret - assertEquals("Unexpected value at ${caretIndex}", insertText, editor.text.substring(caretIndex, caretIndex + insertText.length)) + assertEquals("Unexpected value at $caretIndex", insertText, editor.text.substring(caretIndex, caretIndex + insertText.length)) // Caret should be placed after inserted text assertEquals(caretIndex + insertText.length, editor.selectionStart) diff --git a/build.gradle b/build.gradle index 0f53851f..46e5b24b 100644 --- a/build.gradle +++ b/build.gradle @@ -1,11 +1,11 @@ buildscript { - ext.kotlin_version = '1.4.10' + ext.kotlin_version = '1.4.20' repositories { google() jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:4.1.0' + classpath 'com.android.tools.build:gradle:4.1.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } }