From 58d839ef0d2159c85b4793512358d9b407703140 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 | 26 +++++++++---------- .../announcements/AnnouncementsActivity.kt | 8 +++--- .../announcements/AnnouncementsViewModel.kt | 2 +- .../components/compose/ComposeViewModel.kt | 2 -- .../keylesspalace/tusky/db/AccountManager.kt | 2 +- .../tusky/util/CustomEmojiHelper.kt | 4 +-- .../tusky/ComposeActivityTest.kt | 11 +++++--- build.gradle | 4 +-- 8 files changed, 30 insertions(+), 29 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index a9669a20..bafc3287 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -113,24 +113,24 @@ 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" @@ -138,8 +138,8 @@ dependencies { 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.paging:paging-runtime-ktx:2.1.1" + 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" implementation "androidx.room:room-runtime:$roomVersion" @@ -162,7 +162,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" @@ -190,12 +190,12 @@ dependencies { implementation "de.c1710:filemojicompat:1.0.17" implementation 'com.github.Tunous:MarkdownEdit:1.0.0' - 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 05f067ba..dcd93685 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.common.CommonComposeViewModel import com.keylesspalace.tusky.components.common.MediaUploader 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 5a72411e..1811aecf 100644 --- a/app/src/main/java/com/keylesspalace/tusky/db/AccountManager.kt +++ b/app/src/main/java/com/keylesspalace/tusky/db/AccountManager.kt @@ -63,7 +63,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 99aa74f2..fc84d6f0 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/CustomEmojiHelper.kt +++ b/app/src/main/java/com/keylesspalace/tusky/util/CustomEmojiHelper.kt @@ -62,7 +62,7 @@ fun CharSequence.emojify(emojis: List?, view: View, forceSmallEmoji: Bool EmojiSpan(WeakReference(view)) } - builder.setSpan(span, matcher.start(), matcher.end(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + builder.setSpan(span, matcher.start(), matcher.end(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE) Glide.with(view) .asDrawable() .load(url) @@ -101,7 +101,7 @@ open class EmojiSpan(val viewWeakReference: WeakReference) : ReplacementSp 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 4669ca96..12b7ff07 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,9 +78,9 @@ class ComposeActivityTest { notificationVibration = true, notificationLight = true ) - var instanceResponseCallback: (()->Instance)? = null - var nodeinfoResponseCallback: (()->NodeInfo)? = null - var composeOptions: ComposeActivity.ComposeOptions? = null + private var instanceResponseCallback: (()->Instance)? = null + private var nodeinfoResponseCallback: (()->NodeInfo)? = null + private var composeOptions: ComposeActivity.ComposeOptions? = null @Before fun setupActivity() { @@ -217,6 +219,7 @@ class ComposeActivityTest { val customMaximum = 2147483647 instanceResponseCallback = { getInstanceWithMaximumTootCharacters(customMaximum) } setupActivity() + shadowOf(getMainLooper()).idle() assertEquals(customMaximum, activity.maximumTootCharacters) } @@ -316,7 +319,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 84be8210..4383c093 100644 --- a/build.gradle +++ b/build.gradle @@ -1,11 +1,11 @@ buildscript { - ext.kotlin_version = '1.3.61' + 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" } }