diff --git a/app/src/gplay/java/com/nextcloud/talk/jobs/GetFirebasePushTokenWorker.kt b/app/src/gplay/java/com/nextcloud/talk/jobs/GetFirebasePushTokenWorker.kt index 38206210a..afc7c7bb7 100644 --- a/app/src/gplay/java/com/nextcloud/talk/jobs/GetFirebasePushTokenWorker.kt +++ b/app/src/gplay/java/com/nextcloud/talk/jobs/GetFirebasePushTokenWorker.kt @@ -42,22 +42,27 @@ class GetFirebasePushTokenWorker(val context: Context, workerParameters: WorkerP @SuppressLint("LongLogTag") override fun doWork(): Result { - FirebaseMessaging.getInstance().token.addOnCompleteListener(OnCompleteListener { task -> - if (!task.isSuccessful) { - Log.w(TAG, "Fetching FCM registration token failed", task.exception) - return@OnCompleteListener + FirebaseMessaging.getInstance().token.addOnCompleteListener( + OnCompleteListener { task -> + if (!task.isSuccessful) { + Log.w(TAG, "Fetching FCM registration token failed", task.exception) + return@OnCompleteListener + } + + val token = task.result + + appPreferences?.pushToken = token + + val data: Data = + Data.Builder() + .putString(PushRegistrationWorker.ORIGIN, "GetFirebasePushTokenWorker") + .build() + val pushRegistrationWork = OneTimeWorkRequest.Builder(PushRegistrationWorker::class.java) + .setInputData(data) + .build() + WorkManager.getInstance(context).enqueue(pushRegistrationWork) } - - val token = task.result - - appPreferences?.pushToken = token - - val data: Data = Data.Builder().putString(PushRegistrationWorker.ORIGIN, "GetFirebasePushTokenWorker").build() - val pushRegistrationWork = OneTimeWorkRequest.Builder(PushRegistrationWorker::class.java) - .setInputData(data) - .build() - WorkManager.getInstance(context).enqueue(pushRegistrationWork) - }) + ) return Result.success() } diff --git a/app/src/gplay/java/com/nextcloud/talk/utils/ClosedInterfaceImpl.kt b/app/src/gplay/java/com/nextcloud/talk/utils/ClosedInterfaceImpl.kt index 7dc8ff74d..83edacd4a 100644 --- a/app/src/gplay/java/com/nextcloud/talk/utils/ClosedInterfaceImpl.kt +++ b/app/src/gplay/java/com/nextcloud/talk/utils/ClosedInterfaceImpl.kt @@ -75,7 +75,11 @@ class ClosedInterfaceImpl : ClosedInterface, ProviderInstaller.ProviderInstallLi } private fun registerLocalToken() { - val data: Data = Data.Builder().putString(PushRegistrationWorker.ORIGIN, "ClosedInterfaceImpl#registerLocalToken").build() + val data: Data = Data.Builder().putString( + PushRegistrationWorker.ORIGIN, + "ClosedInterfaceImpl#registerLocalToken" + ) + .build() val pushRegistrationWork = OneTimeWorkRequest.Builder(PushRegistrationWorker::class.java) .setInputData(data) .build() @@ -83,7 +87,11 @@ class ClosedInterfaceImpl : ClosedInterface, ProviderInstaller.ProviderInstallLi } private fun setUpPeriodicLocalTokenRegistration() { - val data: Data = Data.Builder().putString(PushRegistrationWorker.ORIGIN, "ClosedInterfaceImpl#setUpPeriodicLocalTokenRegistration").build() + val data: Data = Data.Builder().putString( + PushRegistrationWorker.ORIGIN, + "ClosedInterfaceImpl#setUpPeriodicLocalTokenRegistration" + ) + .build() val periodicTokenRegistration = PeriodicWorkRequest.Builder( PushRegistrationWorker::class.java, diff --git a/scripts/analysis/findbugs-results.txt b/scripts/analysis/findbugs-results.txt index c02176735..8d28c8c9e 100644 --- a/scripts/analysis/findbugs-results.txt +++ b/scripts/analysis/findbugs-results.txt @@ -1 +1 @@ -558 \ No newline at end of file +554 \ No newline at end of file diff --git a/scripts/analysis/lint-results.txt b/scripts/analysis/lint-results.txt index 7d0dd5fec..96101281e 100644 --- a/scripts/analysis/lint-results.txt +++ b/scripts/analysis/lint-results.txt @@ -1,2 +1,2 @@ DO NOT TOUCH; GENERATED BY DRONE - Lint Report: 1 error and 224 warnings + Lint Report: 1 error and 222 warnings