Remove annotation '@JvmField'

Replace the '@JvmField' with the Kotlin way 'lateinit'.

Signed-off-by: Tim Krüger <t@timkrueger.me>
This commit is contained in:
Tim Krüger 2022-06-23 10:59:12 +02:00
parent 5b5db208ee
commit 58c40e6ee2
No known key found for this signature in database
GPG key ID: FECE3A7222C52A4E

View file

@ -2,6 +2,8 @@
* Nextcloud Talk application * Nextcloud Talk application
* *
* @author Mario Danic * @author Mario Danic
* @author Tim Krüger
* Copyright (C) 2022 Tim Krüger <t@timkrueger.me>
* Copyright (C) 2017-2019 Mario Danic <mario@lovelyhq.com> * Copyright (C) 2017-2019 Mario Danic <mario@lovelyhq.com>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -82,31 +84,28 @@ import javax.inject.Inject
@SuppressLint("LongLogTag") @SuppressLint("LongLogTag")
@AutoInjector(NextcloudTalkApplication::class) @AutoInjector(NextcloudTalkApplication::class)
class ChatAndCallMessagingService : FirebaseMessagingService() { class ChatAndCallMessagingService : FirebaseMessagingService() {
@JvmField
@Inject
var appPreferences: AppPreferences? = null
var isServiceInForeground: Boolean = false @Inject
lateinit var appPreferences: AppPreferences
private var isServiceInForeground: Boolean = false
private var decryptedPushMessage: DecryptedPushMessage? = null private var decryptedPushMessage: DecryptedPushMessage? = null
private var signatureVerification: SignatureVerification? = null private var signatureVerification: SignatureVerification? = null
private var handler: Handler = Handler() private var handler: Handler = Handler()
@JvmField
@Inject @Inject
var retrofit: Retrofit? = null lateinit var retrofit: Retrofit
@JvmField
@Inject @Inject
var okHttpClient: OkHttpClient? = null lateinit var okHttpClient: OkHttpClient
@JvmField
@Inject @Inject
var eventBus: EventBus? = null lateinit var eventBus: EventBus
override fun onCreate() { override fun onCreate() {
super.onCreate() super.onCreate()
sharedApplication!!.componentApplication.inject(this) sharedApplication!!.componentApplication.inject(this)
eventBus?.register(this) eventBus.register(this)
} }
@Subscribe(threadMode = ThreadMode.BACKGROUND) @Subscribe(threadMode = ThreadMode.BACKGROUND)
@ -119,7 +118,7 @@ class ChatAndCallMessagingService : FirebaseMessagingService() {
override fun onDestroy() { override fun onDestroy() {
Log.d(TAG, "onDestroy") Log.d(TAG, "onDestroy")
isServiceInForeground = false isServiceInForeground = false
eventBus?.unregister(this) eventBus.unregister(this)
stopForeground(true) stopForeground(true)
handler.removeCallbacksAndMessages(null) handler.removeCallbacksAndMessages(null)
super.onDestroy() super.onDestroy()
@ -128,7 +127,7 @@ class ChatAndCallMessagingService : FirebaseMessagingService() {
override fun onNewToken(token: String) { override fun onNewToken(token: String) {
super.onNewToken(token) super.onNewToken(token)
sharedApplication!!.componentApplication.inject(this) sharedApplication!!.componentApplication.inject(this)
appPreferences!!.pushToken = token appPreferences.pushToken = token
Log.d(TAG, "onNewToken. token = $token") Log.d(TAG, "onNewToken. token = $token")
val data: Data = Data.Builder().putString(PushRegistrationWorker.ORIGIN, "onNewToken").build() val data: Data = Data.Builder().putString(PushRegistrationWorker.ORIGIN, "onNewToken").build()
@ -225,7 +224,7 @@ class ChatAndCallMessagingService : FirebaseMessagingService() {
} }
) )
val soundUri = getCallRingtoneUri(applicationContext!!, appPreferences!!) val soundUri = getCallRingtoneUri(applicationContext!!, appPreferences)
val notificationChannelId = NotificationUtils.NOTIFICATION_CHANNEL_CALLS_V4 val notificationChannelId = NotificationUtils.NOTIFICATION_CHANNEL_CALLS_V4
val uri = Uri.parse(signatureVerification!!.userEntity!!.baseUrl) val uri = Uri.parse(signatureVerification!!.userEntity!!.baseUrl)
val baseUrl = uri.host val baseUrl = uri.host
@ -268,8 +267,8 @@ class ChatAndCallMessagingService : FirebaseMessagingService() {
decryptedPushMessage: DecryptedPushMessage decryptedPushMessage: DecryptedPushMessage
) { ) {
Log.d(TAG, "checkIfCallIsActive") Log.d(TAG, "checkIfCallIsActive")
val ncApi = retrofit!!.newBuilder() val ncApi = retrofit.newBuilder()
.client(okHttpClient!!.newBuilder().cookieJar(JavaNetCookieJar(CookieManager())).build()).build() .client(okHttpClient.newBuilder().cookieJar(JavaNetCookieJar(CookieManager())).build()).build()
.create(NcApi::class.java) .create(NcApi::class.java)
var hasParticipantsInCall = true var hasParticipantsInCall = true
var inCallOnDifferentDevice = false var inCallOnDifferentDevice = false
@ -297,9 +296,7 @@ class ChatAndCallMessagingService : FirebaseMessagingService() {
} }
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.subscribe(object : Observer<ParticipantsOverall> { .subscribe(object : Observer<ParticipantsOverall> {
override fun onSubscribe(d: Disposable) { override fun onSubscribe(d: Disposable) = Unit
// unused atm
}
override fun onNext(participantsOverall: ParticipantsOverall) { override fun onNext(participantsOverall: ParticipantsOverall) {
val participantList: List<Participant> = participantsOverall.ocs!!.data!! val participantList: List<Participant> = participantsOverall.ocs!!.data!!
@ -321,9 +318,7 @@ class ChatAndCallMessagingService : FirebaseMessagingService() {
} }
} }
override fun onError(e: Throwable) { override fun onError(e: Throwable) = Unit
// unused atm
}
override fun onComplete() { override fun onComplete() {
stopForeground(true) stopForeground(true)