Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(deps): Update dependencies (Kotlin 1.6) #521

Merged
merged 10 commits into from
Jul 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 23 additions & 23 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,13 @@ repositories {
}

android {
compileSdkVersion 30
buildToolsVersion "29.0.3"
compileSdkVersion 32
ndkVersion '21.3.6528147'

defaultConfig {
applicationId "tech.relaycorp.courier"
minSdkVersion 21
targetSdkVersion 30
targetSdkVersion 32
versionCode 1
versionName project.findProperty("versionName") ?: "0.1"

Expand Down Expand Up @@ -106,29 +105,29 @@ android {

dependencies {
// Java 8
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.1'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'

// Kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinCoroutinesVersion"

// Android
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.4.1'

// Dependency Injection
api 'com.google.dagger:dagger:2.37'
kapt 'com.google.dagger:dagger-compiler:2.28.1'
api 'com.google.dagger:dagger:2.42'
kapt 'com.google.dagger:dagger-compiler:2.42'

// Awala
implementation 'tech.relaycorp:awala:1.48.5'
implementation 'tech.relaycorp:cogrpc:1.1.11'
implementation 'tech.relaycorp:cogrpc-okhttp:1.1.10'
implementation 'tech.relaycorp:doh:1.0.1'
implementation 'tech.relaycorp:awala:1.65.0'
implementation 'tech.relaycorp:cogrpc:1.1.27'
implementation 'tech.relaycorp:cogrpc-okhttp:1.1.15'
implementation 'tech.relaycorp:doh:1.0.10'

// ORM
implementation "androidx.room:room-runtime:$roomVersion"
Expand All @@ -137,7 +136,7 @@ dependencies {

// Preferences
implementation 'androidx.preference:preference:1.1.1'
gnarea marked this conversation as resolved.
Show resolved Hide resolved
implementation 'com.github.tfcporciuncula:flow-preferences:1.1.0'
implementation 'com.github.tfcporciuncula:flow-preferences:1.3.4'

// gRPC
implementation "io.grpc:grpc-netty:$grpcVersion"
Expand All @@ -147,7 +146,7 @@ dependencies {
// Android TLS support for Netty
implementation "io.netty:netty-handler:$nettyVersion"
implementation 'org.conscrypt:conscrypt-android:2.5.2'
implementation 'org.bouncycastle:bcpkix-jdk15on:1.67'
implementation 'org.bouncycastle:bcpkix-jdk15on:1.70'

// Display open-source licenses
implementation "com.mikepenz:aboutlibraries:$aboutLibsVersion"
Expand All @@ -156,24 +155,25 @@ dependencies {
testImplementation "org.junit.jupiter:junit-jupiter:$junitVersion"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitVersion"
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$kotlinCoroutinesVersion"
testImplementation 'org.mockito:mockito-inline:3.7.7'
testImplementation 'org.mockito:mockito-inline:4.6.0'
testImplementation 'com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0'
testImplementation "io.grpc:grpc-testing:$grpcVersion"

// Instrumentation Testing
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test:runner:1.4.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$kotlinCoroutinesVersion"
androidTestImplementation "io.grpc:grpc-testing:$grpcVersion"
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
androidTestImplementation('com.adevinta.android:barista:4.0.0') {
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation('com.adevinta.android:barista:4.2.0') {
exclude group: 'org.jetbrains.kotlin'
}
kaptAndroidTest 'com.google.dagger:dagger-compiler:2.28'
kaptAndroidTest 'com.google.dagger:dagger-compiler:2.42'
}

spotless {
kotlin {
ktlint('0.36.0').userData(['disabled_rules': 'import-ordering'])
ktlint('0.43.2').userData(['disabled_rules': 'import-ordering'])
target '**/*.kt'
}
}
Expand Down
12 changes: 0 additions & 12 deletions app/firebase-test-lab.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,6 @@ spec:
test: app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk
timeout: 30m
device:
# Nexus 4 (virtual)
- model: Nexus4
version: 21 # Android 5.0
locale: en
orientation: portrait

# Nexus 5 (virtual)
- model: Nexus5
version: 23 # Android 6.0
locale: en
orientation: portrait

# Nexus 5X (virtual)
- model: Nexus5X
version: 24 # Android 7.0
Expand Down
7 changes: 6 additions & 1 deletion app/lint.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@
<issue id="NewerVersionAvailable" severity="ignore"/>
<issue id="GradleDependency" severity="ignore"/>
<issue id="LockedOrientationActivity" severity="ignore"/>

<issue id="ConvertToWebp" severity="ignore"/>
<issue id="CheckResult" severity="informational"/>
<issue id="InvalidPackage">
<!-- Ignore errors about BC importing javax.naming because we don't use those modules -->
<ignore path="**/bcpkix-*.jar" />
<!-- Temporary until https://github.com/Kotlin/kotlinx.coroutines/issues/2004 is resolved. -->
<ignore path="**/kotlinx-coroutines-core-*.jar" />
<!-- Ignore errors about GRPC importing javax.naming because we don’t use those modules -->
<ignore path="**/grpc-core/**" />
<!-- Ignore errors about jacoco importing javax.management because we don’t use those modules -->
<ignore path="**/org.jacoco/**" />
</issue>
<issue id="TrustAllX509TrustManager">
<ignore path="org/bouncycastle/est/jcajce/*.class" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ package tech.relaycorp.courier.data.database

import androidx.test.ext.junit.runners.AndroidJUnit4
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.test.runBlockingTest
import kotlinx.coroutines.test.runTest
import org.junit.Assert.assertEquals
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import tech.relaycorp.courier.data.model.StorageSize
import tech.relaycorp.courier.test.AppTestProvider.database
import tech.relaycorp.courier.test.AppTestProvider.testDispatcher
import tech.relaycorp.courier.test.factory.StoredMessageFactory
import java.util.Date

Expand All @@ -23,7 +24,7 @@ class StoredMessageDaoTest {
}

@Test
fun insertAndGet() = runBlockingTest {
fun insertAndGet() = runTest(testDispatcher) {
val messages = StoredMessageFactory.build()
storedMessageDao.insert(messages)
assertEquals(
Expand All @@ -33,7 +34,7 @@ class StoredMessageDaoTest {
}

@Test
fun observeTotalSize() = runBlockingTest {
fun observeTotalSize() = runTest(testDispatcher) {
assertEquals(
StorageSize.ZERO,
storedMessageDao.observeTotalSize().first()
Expand All @@ -43,14 +44,15 @@ class StoredMessageDaoTest {
(1..3)
.map { StoredMessageFactory.build() }
.also { it.map { c -> storedMessageDao.insert(c) } }

assertEquals(
messages.map { it.size.bytes }.sum(),
storedMessageDao.observeTotalSize().first().bytes
)
}

@Test
fun getExpiredBy() = runBlockingTest {
fun getExpiredBy() = runTest(testDispatcher) {
val date = Date()
val expiredMessage = StoredMessageFactory.build()
.copy(expirationTimeUtc = Date(date.time - 1))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package tech.relaycorp.courier.data.preference

import kotlinx.coroutines.flow.first
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.test.runTest
import org.junit.After
import org.junit.Assert.assertEquals
import org.junit.Before
import org.junit.Test
import tech.relaycorp.courier.data.model.StorageSize
import tech.relaycorp.courier.test.AppTestProvider.flowSharedPreferences
import javax.inject.Provider
import tech.relaycorp.courier.test.AppTestProvider.testDispatcher

class StoragePreferencesTest {

private val preferences = StoragePreferences(Provider { flowSharedPreferences })
private val preferences = StoragePreferences { flowSharedPreferences }

@Before
fun setUp() {
Expand All @@ -25,7 +25,7 @@ class StoragePreferencesTest {
}

@Test
fun maxStorage() = runBlocking {
fun maxStorage() = runTest(testDispatcher) {
assertEquals(
StoragePreferences.DEFAULT_MAX_STORAGE_SIZE,
preferences.getMaxStorageSize().first()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@ class PrivateSyncTest {
}

private val client by lazy {
MetadataUtils.attachHeaders(
CargoRelayGrpc.newStub(clientChannel),
AuthorizationMetadata.makeMetadata("CCA".toByteArray())
CargoRelayGrpc.newStub(clientChannel).withInterceptors(
MetadataUtils.newAttachHeadersInterceptor(
AuthorizationMetadata.makeMetadata("CCA".toByteArray())
)
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ object AppTestProvider {
val flowSharedPreferences
get() = FlowSharedPreferences(PreferenceManager.getDefaultSharedPreferences(context), testDispatcher)

private val testDispatcher by lazy { TestCoroutineDispatcher() }
val testDispatcher by lazy { TestCoroutineDispatcher() }
}
3 changes: 3 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
<application
android:name=".App"
android:allowBackup="false"
android:dataExtractionRules="@xml/data_extraction_rules"
android:extractNativeLibs="false"
android:fullBackupContent="@xml/data_extraction_old_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
Expand All @@ -18,6 +20,7 @@

<activity
android:name=".ui.main.MainActivity"
android:exported="true"
android:screenOrientation="portrait"
android:theme="@style/Theme.Courier.Splash">
<intent-filter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import tech.relaycorp.relaynet.cogrpc.AuthorizationMetadata

internal object AuthorizationContext {
// Context values are bound to the current thread
internal val contextKey = Context.key<ByteArray>("Authorization")
internal val contextKey: Context.Key<ByteArray> = Context.key("Authorization")

internal val interceptor by lazy {
object : ServerInterceptor {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package tech.relaycorp.cogrpc.server
import io.grpc.Attributes
import io.grpc.Grpc
import io.grpc.ServerTransportFilter
import kotlinx.coroutines.channels.sendBlocking
import kotlinx.coroutines.channels.trySendBlocking
import kotlinx.coroutines.flow.asFlow
import kotlinx.coroutines.flow.map
import tech.relaycorp.courier.common.BehaviorChannel
Expand All @@ -15,7 +15,7 @@ class ClientsConnectedFilter : ServerTransportFilter() {

override fun transportReady(transportAttrs: Attributes): Attributes {
transportAttrs.calledIpAddress?.let {
clients.sendBlocking((clients.value + it).distinct())
clients.trySendBlocking((clients.value + it).distinct())
}
return super.transportReady(transportAttrs)
}
Expand All @@ -25,7 +25,7 @@ class ClientsConnectedFilter : ServerTransportFilter() {
// case with JS gRPC clients employing this workaround:
// https://github.com/grpc/grpc-node/issues/663#issuecomment-624000152
transportAttrs?.calledIpAddress?.let {
clients.sendBlocking(clients.value - it)
clients.trySendBlocking(clients.value - it)
}
super.transportTerminated(transportAttrs)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import android.net.Network
import android.net.NetworkCapabilities
import android.net.NetworkRequest
import kotlinx.coroutines.channels.ConflatedBroadcastChannel
import kotlinx.coroutines.channels.sendBlocking
import kotlinx.coroutines.channels.trySendBlocking
import kotlinx.coroutines.flow.asFlow
import kotlinx.coroutines.flow.distinctUntilChanged
import javax.inject.Inject
Expand All @@ -26,15 +26,15 @@ class InternetConnectionObserver

private val networkCallback = object : ConnectivityManager.NetworkCallback() {
override fun onAvailable(network: Network) {
state.sendBlocking(InternetConnection.Online)
state.trySendBlocking(InternetConnection.Online)
}

override fun onUnavailable() {
state.sendBlocking(InternetConnection.Offline)
state.trySendBlocking(InternetConnection.Offline)
}

override fun onLost(network: Network) {
state.sendBlocking(InternetConnection.Offline)
state.trySendBlocking(InternetConnection.Offline)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.net.wifi.WifiManager
import kotlinx.coroutines.channels.sendBlocking
import kotlinx.coroutines.channels.trySendBlocking
import kotlinx.coroutines.flow.asFlow
import kotlinx.coroutines.flow.distinctUntilChanged
import tech.relaycorp.courier.common.BehaviorChannel
Expand Down Expand Up @@ -35,7 +35,7 @@ class WifiHotspotStateReceiver

val stateFlag = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, 0)
logger.info("Wifi State $stateFlag")
state.sendBlocking(
state.trySendBlocking(
if (stateFlag == WIFI_AP_STATE_ENABLED) {
WifiHotspotState.Enabled
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package tech.relaycorp.courier.domain

import kotlinx.coroutines.channels.sendBlocking
import kotlinx.coroutines.channels.trySendBlocking
import kotlinx.coroutines.flow.asFlow
import tech.relaycorp.cogrpc.server.CogRPCServer
import tech.relaycorp.courier.common.BehaviorChannel
Expand All @@ -23,14 +23,14 @@ class PrivateSync

state.send(State.Starting)
cogRPCServer.start(service) {
state.sendBlocking(State.Error)
state.trySendBlocking(State.Error)
}
if (state.value == State.Starting) state.send(State.Syncing)
}

fun stopSync() {
cogRPCServer.stop()
state.sendBlocking(State.Stopped)
state.trySendBlocking(State.Stopped)
}

enum class State {
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/java/tech/relaycorp/courier/ui/BaseActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ abstract class BaseActivity : AppCompatActivity() {
// Setup edge-to-edge UI
window.decorView.systemUiVisibility =
window.decorView.systemUiVisibility or
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or
View.SYSTEM_UI_FLAG_LAYOUT_STABLE

if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
}
Expand Down
Loading