From 0a1c441a79b54c61b9571593bc5a9d6bbe2aec35 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Fri, 22 Nov 2024 11:13:13 +0100 Subject: [PATCH] Update the code to improve readability --- .../call/impl/ui/ElementCallActivity.kt | 33 +++++++++++-------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/ElementCallActivity.kt b/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/ElementCallActivity.kt index 08ad912b54..2622c48529 100644 --- a/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/ElementCallActivity.kt +++ b/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/ElementCallActivity.kt @@ -198,21 +198,26 @@ class ElementCallActivity : ?: intent.dataString?.let(::parseUrl)?.let(::ExternalUrl) } val currentCallType = webViewTarget.value - if (currentCallType == null && callType == null) { - Timber.tag(loggerTag.value).d("Re-opened the activity but we have no url to load or a cached one, finish the activity") - finish() - } else if (currentCallType == null) { - Timber.tag(loggerTag.value).d("Set the call type and create the presenter") - webViewTarget.value = callType - presenter = presenterFactory.create(callType!!, this) - } else if (callType == null) { - Timber.tag(loggerTag.value).d("Coming back from notification, do nothing") - } else if (callType != currentCallType) { - Timber.tag(loggerTag.value).d("User starts another call, restart the Activity") - setIntent(intent) - recreate() + if (currentCallType == null) { + if (callType == null) { + Timber.tag(loggerTag.value).d("Re-opened the activity but we have no url to load or a cached one, finish the activity") + finish() + } else { + Timber.tag(loggerTag.value).d("Set the call type and create the presenter") + webViewTarget.value = callType + presenter = presenterFactory.create(callType, this) + } } else { - Timber.tag(loggerTag.value).d("Other case, do nothing") + if (callType == null) { + Timber.tag(loggerTag.value).d("Coming back from notification, do nothing") + } else if (callType != currentCallType) { + Timber.tag(loggerTag.value).d("User starts another call, restart the Activity") + setIntent(intent) + recreate() + } else { + // Starting the same call again, should not happen, the UI is preventing this. But maybe when using external links. + Timber.tag(loggerTag.value).d("Starting the same call again, do nothing") + } } }