Skip to content

Commit 830fef0

Browse files
style: Use KTX extension
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
1 parent 5c0188d commit 830fef0

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

app/src/main/java/com/nextcloud/talk/activities/MainActivity.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import io.reactivex.disposables.CompositeDisposable
4949
import io.reactivex.disposables.Disposable
5050
import io.reactivex.schedulers.Schedulers
5151
import javax.inject.Inject
52+
import androidx.core.net.toUri
5253

5354
@AutoInjector(NextcloudTalkApplication::class)
5455
class MainActivity :
@@ -386,7 +387,7 @@ class MainActivity :
386387
* 3. Current active user as fallback (if server matches)
387388
*/
388389
private fun resolveTargetUser(users: List<User>, deepLinkResult: DeepLinkHandler.DeepLinkResult): User? {
389-
val deepLinkHost = Uri.parse(deepLinkResult.serverUrl).host?.lowercase()
390+
val deepLinkHost = deepLinkResult.serverUrl.toUri().host?.lowercase()
390391
if (deepLinkHost.isNullOrBlank()) {
391392
return currentUserProviderOld.currentUser.blockingGet()
392393
}
@@ -395,21 +396,21 @@ class MainActivity :
395396
val username = deepLinkResult.username
396397
val exactMatch = if (username != null) {
397398
users.find { user ->
398-
val userHost = user.baseUrl?.let { Uri.parse(it).host?.lowercase() }
399+
val userHost = user.baseUrl?.let { it.toUri().host?.lowercase() }
399400
userHost == deepLinkHost && user.username?.lowercase() == username.lowercase()
400401
}
401402
} else {
402403
null
403404
}
404405

405406
val serverMatch = users.find { user ->
406-
val userHost = user.baseUrl?.let { Uri.parse(it).host?.lowercase() }
407+
val userHost = user.baseUrl?.let { it.toUri().host?.lowercase() }
407408
userHost == deepLinkHost
408409
}
409410

410411
val currentUser = currentUserProviderOld.currentUser.blockingGet()
411412
val currentUserMatch = currentUser?.takeIf {
412-
it.baseUrl?.let { url -> Uri.parse(url).host?.lowercase() } == deepLinkHost
413+
it.baseUrl?.let { url -> url.toUri().host?.lowercase() } == deepLinkHost
413414
}
414415

415416
return exactMatch ?: serverMatch ?: currentUserMatch

app/src/main/java/com/nextcloud/talk/utils/DeepLinkHandler.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
package com.nextcloud.talk.utils
88

99
import android.net.Uri
10+
import androidx.core.net.toUri
1011

1112
/**
1213
* Handles parsing of deep links for opening conversations.
@@ -110,7 +111,7 @@ object DeepLinkHandler {
110111
*/
111112
fun createConversationUri(roomToken: String, serverUrl: String, username: String? = null): Uri {
112113
// Extract host from server URL
113-
val serverUri = Uri.parse(serverUrl)
114+
val serverUri = serverUrl.toUri()
114115
val host = serverUri.host ?: return Uri.EMPTY
115116

116117
// Build authority with optional username

0 commit comments

Comments
 (0)