From 0ede5d66264e91886d9ef34a26f7a175e94eced6 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 5 Jun 2024 18:52:57 +0200 Subject: [PATCH] Fix quality issues --- .../android/features/share/impl/ShareIntentHandler.kt | 5 ++--- .../io/element/android/features/share/impl/ShareNode.kt | 2 +- .../io/element/android/features/share/impl/SharePresenter.kt | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/features/share/impl/src/main/kotlin/io/element/android/features/share/impl/ShareIntentHandler.kt b/features/share/impl/src/main/kotlin/io/element/android/features/share/impl/ShareIntentHandler.kt index 91ec95cda2..2a0f3bb04c 100644 --- a/features/share/impl/src/main/kotlin/io/element/android/features/share/impl/ShareIntentHandler.kt +++ b/features/share/impl/src/main/kotlin/io/element/android/features/share/impl/ShareIntentHandler.kt @@ -102,18 +102,17 @@ class DefaultShareIntentHandler @Inject constructor( } val resInfoList: List = context.packageManager.queryIntentActivitiesCompat(data, PackageManager.MATCH_DEFAULT_ONLY) uriList.forEach { - for (resolveInfo in resInfoList) { + resInfoList.forEach resolve@{ resolveInfo -> val packageName: String = resolveInfo.activityInfo.packageName // Replace implicit intent by an explicit to fix crash on some devices like Xiaomi. // see https://juejin.cn/post/7031736325422186510 try { context.grantUriPermission(packageName, it, Intent.FLAG_GRANT_READ_URI_PERMISSION) } catch (e: Exception) { - continue + return@resolve } data.action = null data.component = ComponentName(packageName, resolveInfo.activityInfo.name) - break } } return uriList.map { uri -> diff --git a/features/share/impl/src/main/kotlin/io/element/android/features/share/impl/ShareNode.kt b/features/share/impl/src/main/kotlin/io/element/android/features/share/impl/ShareNode.kt index 85041a8c97..ad360b09ea 100644 --- a/features/share/impl/src/main/kotlin/io/element/android/features/share/impl/ShareNode.kt +++ b/features/share/impl/src/main/kotlin/io/element/android/features/share/impl/ShareNode.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) 20244 New Vector Ltd + * Copyright (c) 2024 New Vector Ltd * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/features/share/impl/src/main/kotlin/io/element/android/features/share/impl/SharePresenter.kt b/features/share/impl/src/main/kotlin/io/element/android/features/share/impl/SharePresenter.kt index 47513e282b..985e1fab12 100644 --- a/features/share/impl/src/main/kotlin/io/element/android/features/share/impl/SharePresenter.kt +++ b/features/share/impl/src/main/kotlin/io/element/android/features/share/impl/SharePresenter.kt @@ -104,7 +104,7 @@ class SharePresenter @AssistedInject constructor( } ) if (!result) { - throw Exception("Failed to handle incoming share intent") + error("Failed to handle incoming share intent") } roomIds }.runCatchingUpdatingState(shareActionState)