From 74de9c82c0db83822e884985915d738e6609fb43 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 1 Jun 2022 16:07:18 +0200 Subject: [PATCH] Small rework --- .../app/core/pushers/UnifiedPushHelper.kt | 20 ++++++++--------- .../TestAvailableUnifiedPushDistributors.kt | 22 +++++++++---------- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/vector/src/main/java/im/vector/app/core/pushers/UnifiedPushHelper.kt b/vector/src/main/java/im/vector/app/core/pushers/UnifiedPushHelper.kt index 57810b659b..11b71493fe 100644 --- a/vector/src/main/java/im/vector/app/core/pushers/UnifiedPushHelper.kt +++ b/vector/src/main/java/im/vector/app/core/pushers/UnifiedPushHelper.kt @@ -136,11 +136,13 @@ class UnifiedPushHelper @Inject constructor( up.saveDistributor(context, context.packageName) val distributors = up.getDistributors(context).toMutableList() - val internalDistributorName = if (FcmHelper.isPushSupported()) { - stringProvider.getString(R.string.unifiedpush_distributor_fcm_fallback) - } else { - stringProvider.getString(R.string.unifiedpush_distributor_background_sync) - } + val internalDistributorName = stringProvider.getString( + if (FcmHelper.isPushSupported()) { + R.string.unifiedpush_distributor_fcm_fallback + } else { + R.string.unifiedpush_distributor_background_sync + } + ) if (distributors.size == 1 && !force) { @@ -217,11 +219,9 @@ class UnifiedPushHelper @Inject constructor( // register app_id type upfcm on sygnal // the pushkey if FCM key if (up.getDistributor(context) == context.packageName) { - stringProvider.getString(R.string.pusher_http_url).let { - storePushGateway(it) - onDoneRunnable?.run() - return - } + storePushGateway(stringProvider.getString(R.string.pusher_http_url)) + onDoneRunnable?.run() + return } // else, unifiedpush, and pushkey is an endpoint val gateway = stringProvider.getString(R.string.default_push_gateway_http_url) diff --git a/vector/src/main/java/im/vector/app/features/settings/troubleshoot/TestAvailableUnifiedPushDistributors.kt b/vector/src/main/java/im/vector/app/features/settings/troubleshoot/TestAvailableUnifiedPushDistributors.kt index cc529d64a0..9eb8cd35c4 100644 --- a/vector/src/main/java/im/vector/app/features/settings/troubleshoot/TestAvailableUnifiedPushDistributors.kt +++ b/vector/src/main/java/im/vector/app/features/settings/troubleshoot/TestAvailableUnifiedPushDistributors.kt @@ -31,19 +31,17 @@ class TestAvailableUnifiedPushDistributors @Inject constructor( override fun perform(activityResultLauncher: ActivityResultLauncher) { val distributors = unifiedPushHelper.getExternalDistributors() - if (distributors.isEmpty()) { - description = if (FcmHelper.isPushSupported()) { - stringProvider.getString(R.string.settings_troubleshoot_test_distributors_gplay) - } else { - stringProvider.getString(R.string.settings_troubleshoot_test_distributors_fdroid) - } - status = TestStatus.SUCCESS - } else { - description = stringProvider.getString( - R.string.settings_troubleshoot_test_distributors_many, - distributors.size + 1 + description = if (distributors.isEmpty()) { + stringProvider.getString( + if (FcmHelper.isPushSupported()) { + R.string.settings_troubleshoot_test_distributors_gplay + } else { + R.string.settings_troubleshoot_test_distributors_fdroid + } ) - status = TestStatus.SUCCESS + } else { + stringProvider.getString(R.string.settings_troubleshoot_test_distributors_many, distributors.size + 1) } + status = TestStatus.SUCCESS } }