From 06b3cc3f4b10cfa80271f2bda22e6d961bd7406a Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Fri, 22 Oct 2021 18:29:53 +0100 Subject: [PATCH 1/6] filters the unique notification uris from the link handling - fixes malformed url errors appearing for uri we only create to force uniqueness in the notifications --- .../app/core/extensions/UriExtensions.kt | 25 +++++++++++++++++++ .../notifications/NotificationUtils.kt | 25 ++++++++++--------- .../features/permalink/PermalinkHandler.kt | 25 +++++++++++-------- 3 files changed, 53 insertions(+), 22 deletions(-) create mode 100644 vector/src/main/java/im/vector/app/core/extensions/UriExtensions.kt diff --git a/vector/src/main/java/im/vector/app/core/extensions/UriExtensions.kt b/vector/src/main/java/im/vector/app/core/extensions/UriExtensions.kt new file mode 100644 index 0000000000..ec7a03bdbb --- /dev/null +++ b/vector/src/main/java/im/vector/app/core/extensions/UriExtensions.kt @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2021 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.app.core.extensions + +import android.net.Uri + +const val IGNORED_SCHEMA = "ignored" + +fun Uri.isIgnored() = scheme == IGNORED_SCHEMA + +fun createIgnoredUri(path: String): Uri = Uri.parse("$IGNORED_SCHEMA://$path") diff --git a/vector/src/main/java/im/vector/app/features/notifications/NotificationUtils.kt b/vector/src/main/java/im/vector/app/features/notifications/NotificationUtils.kt index 92feb3d038..89db5e7d8f 100755 --- a/vector/src/main/java/im/vector/app/features/notifications/NotificationUtils.kt +++ b/vector/src/main/java/im/vector/app/features/notifications/NotificationUtils.kt @@ -47,6 +47,7 @@ import androidx.core.graphics.drawable.IconCompat import androidx.fragment.app.Fragment import im.vector.app.BuildConfig import im.vector.app.R +import im.vector.app.core.extensions.createIgnoredUri import im.vector.app.core.resources.StringProvider import im.vector.app.core.services.CallService import im.vector.app.core.utils.startNotificationChannelSettingsIntent @@ -317,7 +318,7 @@ class NotificationUtils @Inject constructor(private val context: Context, mode = VectorCallActivity.INCOMING_RINGING ).apply { flags = Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP - data = Uri.parse("foobar://${call.callId}") + data = createIgnoredUri(call.callId) } val contentPendingIntent = PendingIntent.getActivity(context, System.currentTimeMillis().toInt(), contentIntent, 0) @@ -378,7 +379,7 @@ class NotificationUtils @Inject constructor(private val context: Context, call = call, mode = null).apply { flags = Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP - data = Uri.parse("foobar://$call.callId") + data = createIgnoredUri(call.callId) } val contentPendingIntent = PendingIntent.getActivity(context, System.currentTimeMillis().toInt(), contentIntent, 0) @@ -584,7 +585,7 @@ class NotificationUtils @Inject constructor(private val context: Context, // Mark room as read val markRoomReadIntent = Intent(context, NotificationBroadcastReceiver::class.java) markRoomReadIntent.action = MARK_ROOM_READ_ACTION - markRoomReadIntent.data = Uri.parse("foobar://${roomInfo.roomId}") + markRoomReadIntent.data = createIgnoredUri(roomInfo.roomId) markRoomReadIntent.putExtra(NotificationBroadcastReceiver.KEY_ROOM_ID, roomInfo.roomId) val markRoomReadPendingIntent = PendingIntent.getBroadcast(context, System.currentTimeMillis().toInt(), markRoomReadIntent, PendingIntent.FLAG_UPDATE_CURRENT) @@ -652,7 +653,7 @@ class NotificationUtils @Inject constructor(private val context: Context, // offer to type a quick reject button val rejectIntent = Intent(context, NotificationBroadcastReceiver::class.java) rejectIntent.action = REJECT_ACTION - rejectIntent.data = Uri.parse("foobar://$roomId&$matrixId") + rejectIntent.data = createIgnoredUri("$roomId&$matrixId") rejectIntent.putExtra(NotificationBroadcastReceiver.KEY_ROOM_ID, roomId) val rejectIntentPendingIntent = PendingIntent.getBroadcast(context, System.currentTimeMillis().toInt(), rejectIntent, PendingIntent.FLAG_UPDATE_CURRENT) @@ -665,7 +666,7 @@ class NotificationUtils @Inject constructor(private val context: Context, // offer to type a quick accept button val joinIntent = Intent(context, NotificationBroadcastReceiver::class.java) joinIntent.action = JOIN_ACTION - joinIntent.data = Uri.parse("foobar://$roomId&$matrixId") + joinIntent.data = createIgnoredUri("$roomId&$matrixId") joinIntent.putExtra(NotificationBroadcastReceiver.KEY_ROOM_ID, roomId) val joinIntentPendingIntent = PendingIntent.getBroadcast(context, System.currentTimeMillis().toInt(), joinIntent, PendingIntent.FLAG_UPDATE_CURRENT) @@ -677,7 +678,7 @@ class NotificationUtils @Inject constructor(private val context: Context, val contentIntent = HomeActivity.newIntent(context, inviteNotificationRoomId = inviteNotifiableEvent.roomId) contentIntent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP // pending intent get reused by system, this will mess up the extra params, so put unique info to avoid that - contentIntent.data = Uri.parse("foobar://" + inviteNotifiableEvent.eventId) + contentIntent.data = createIgnoredUri(inviteNotifiableEvent.eventId) setContentIntent(PendingIntent.getActivity(context, 0, contentIntent, 0)) if (inviteNotifiableEvent.noisy) { @@ -716,7 +717,7 @@ class NotificationUtils @Inject constructor(private val context: Context, val contentIntent = HomeActivity.newIntent(context) contentIntent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP // pending intent get reused by system, this will mess up the extra params, so put unique info to avoid that - contentIntent.data = Uri.parse("foobar://" + simpleNotifiableEvent.eventId) + contentIntent.data = createIgnoredUri(simpleNotifiableEvent.eventId) setContentIntent(PendingIntent.getActivity(context, 0, contentIntent, 0)) if (simpleNotifiableEvent.noisy) { @@ -738,7 +739,7 @@ class NotificationUtils @Inject constructor(private val context: Context, val roomIntentTap = RoomDetailActivity.newIntent(context, RoomDetailArgs(roomId)) roomIntentTap.action = TAP_TO_VIEW_ACTION // pending intent get reused by system, this will mess up the extra params, so put unique info to avoid that - roomIntentTap.data = Uri.parse("foobar://openRoom?$roomId") + roomIntentTap.data = createIgnoredUri("openRoom?$roomId") // Recreate the back stack return TaskStackBuilder.create(context) @@ -750,7 +751,7 @@ class NotificationUtils @Inject constructor(private val context: Context, private fun buildOpenHomePendingIntentForSummary(): PendingIntent { val intent = HomeActivity.newIntent(context, clearNotification = true) intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP - intent.data = Uri.parse("foobar://tapSummary") + intent.data = createIgnoredUri("tapSummary") return PendingIntent.getActivity(context, Random.nextInt(1000), intent, PendingIntent.FLAG_UPDATE_CURRENT) } @@ -766,7 +767,7 @@ class NotificationUtils @Inject constructor(private val context: Context, if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { intent = Intent(context, NotificationBroadcastReceiver::class.java) intent.action = SMART_REPLY_ACTION - intent.data = Uri.parse("foobar://$roomId") + intent.data = createIgnoredUri(roomId) intent.putExtra(NotificationBroadcastReceiver.KEY_ROOM_ID, roomId) return PendingIntent.getBroadcast(context, System.currentTimeMillis().toInt(), intent, PendingIntent.FLAG_UPDATE_CURRENT) @@ -781,7 +782,7 @@ class NotificationUtils @Inject constructor(private val context: Context, // the action must be unique else the parameters are ignored quickReplyIntent.action = QUICK_LAUNCH_ACTION - quickReplyIntent.data = Uri.parse("foobar://$roomId") + quickReplyIntent.data = _root_ide_package_.im.vector.app.core.extensions.createIgnoredUri($roomId") return PendingIntent.getActivity(context, 0, quickReplyIntent, 0) } */ @@ -835,7 +836,7 @@ class NotificationUtils @Inject constructor(private val context: Context, private fun getDismissSummaryPendingIntent(): PendingIntent { val intent = Intent(context, NotificationBroadcastReceiver::class.java) intent.action = DISMISS_SUMMARY_ACTION - intent.data = Uri.parse("foobar://deleteSummary") + intent.data = createIgnoredUri("deleteSummary") return PendingIntent.getBroadcast(context.applicationContext, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT) } diff --git a/vector/src/main/java/im/vector/app/features/permalink/PermalinkHandler.kt b/vector/src/main/java/im/vector/app/features/permalink/PermalinkHandler.kt index a02cfe7517..90bcee3d04 100644 --- a/vector/src/main/java/im/vector/app/features/permalink/PermalinkHandler.kt +++ b/vector/src/main/java/im/vector/app/features/permalink/PermalinkHandler.kt @@ -20,6 +20,7 @@ import android.content.Context import android.net.Uri import im.vector.app.R import im.vector.app.core.di.ActiveSessionHolder +import im.vector.app.core.extensions.isIgnored import im.vector.app.core.utils.toast import im.vector.app.features.navigation.Navigator import im.vector.app.features.roomdirectory.roompreview.RoomPreviewData @@ -53,15 +54,19 @@ class PermalinkHandler @Inject constructor(private val activeSessionHolder: Acti navigationInterceptor: NavigationInterceptor? = null, buildTask: Boolean = false ): Boolean { - if (deepLink == null || !isPermalinkSupported(context, deepLink.toString())) { - return false - } - return tryOrNull { - withContext(Dispatchers.Default) { - val permalinkData = PermalinkParser.parse(deepLink) - handlePermalink(permalinkData, deepLink, context, navigationInterceptor, buildTask) + return when { + deepLink == null -> false + deepLink.isIgnored() -> true + !isPermalinkSupported(context, deepLink.toString()) -> false + else -> { + tryOrNull { + withContext(Dispatchers.Default) { + val permalinkData = PermalinkParser.parse(deepLink) + handlePermalink(permalinkData, deepLink, context, navigationInterceptor, buildTask) + } + } ?: false } - } ?: false + } } private suspend fun handlePermalink( @@ -115,8 +120,8 @@ class PermalinkHandler @Inject constructor(private val activeSessionHolder: Acti private fun isPermalinkSupported(context: Context, url: String): Boolean { return url.startsWith(PermalinkService.MATRIX_TO_URL_BASE) || context.resources.getStringArray(R.array.permalink_supported_hosts).any { - url.startsWith(it) - } + url.startsWith(it) + } } private suspend fun PermalinkData.RoomLink.getRoomId(): String? { From 325e78106e99212c79921bd0af4dd427d89dd7fb Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Mon, 25 Oct 2021 10:51:40 +0100 Subject: [PATCH 2/6] fixing strange ide extract --- .../im/vector/app/features/notifications/NotificationUtils.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vector/src/main/java/im/vector/app/features/notifications/NotificationUtils.kt b/vector/src/main/java/im/vector/app/features/notifications/NotificationUtils.kt index 89db5e7d8f..f3b34e1269 100755 --- a/vector/src/main/java/im/vector/app/features/notifications/NotificationUtils.kt +++ b/vector/src/main/java/im/vector/app/features/notifications/NotificationUtils.kt @@ -782,7 +782,7 @@ class NotificationUtils @Inject constructor(private val context: Context, // the action must be unique else the parameters are ignored quickReplyIntent.action = QUICK_LAUNCH_ACTION - quickReplyIntent.data = _root_ide_package_.im.vector.app.core.extensions.createIgnoredUri($roomId") + quickReplyIntent.data = createIgnoredUri($roomId") return PendingIntent.getActivity(context, 0, quickReplyIntent, 0) } */ From 55c00a09750a062697252f868f2d05e28a47870e Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Mon, 25 Oct 2021 10:56:15 +0100 Subject: [PATCH 3/6] adding changelog entry --- changelog.d/4267.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/4267.bugfix diff --git a/changelog.d/4267.bugfix b/changelog.d/4267.bugfix new file mode 100644 index 0000000000..08aabd1e83 --- /dev/null +++ b/changelog.d/4267.bugfix @@ -0,0 +1 @@ +Fixing malformed link pop up when tapping on notifications \ No newline at end of file From b892331e42bda14a3cd1dbe4c59a2dc3bb280af1 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 25 Oct 2021 12:35:11 +0200 Subject: [PATCH 4/6] Towncrier --- CHANGES.md | 12 ++++++++++++ changelog.d/4267.bugfix | 1 - changelog.d/4276.bugfix | 1 - changelog.d/4279.bugfix | 1 - changelog.d/4283.bugfix | 1 - changelog.d/4313.bugfix | 1 - 6 files changed, 12 insertions(+), 5 deletions(-) delete mode 100644 changelog.d/4267.bugfix delete mode 100644 changelog.d/4276.bugfix delete mode 100644 changelog.d/4279.bugfix delete mode 100644 changelog.d/4283.bugfix delete mode 100644 changelog.d/4313.bugfix diff --git a/CHANGES.md b/CHANGES.md index 8de71eae62..bf855d66f9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,15 @@ +Changes in Element v1.3.5 (2021-10-25) +====================================== + +Bugfixes 🐛 +---------- + - Fixing malformed link pop up when tapping on notifications ([#4267](https://github.com/vector-im/element-android/issues/4267)) + - Fix Broken EditText when using FromEditTextItem ([#4276](https://github.com/vector-im/element-android/issues/4276)) + - Fix crash when clicking on ViewEvent source actions ([#4279](https://github.com/vector-im/element-android/issues/4279)) + - Fix voice message record button wrong visibility ([#4283](https://github.com/vector-im/element-android/issues/4283)) + - Fix unread marker not showing ([#4313](https://github.com/vector-im/element-android/issues/4313)) + + Changes in Element v1.3.4 (2021-10-20) ====================================== diff --git a/changelog.d/4267.bugfix b/changelog.d/4267.bugfix deleted file mode 100644 index 08aabd1e83..0000000000 --- a/changelog.d/4267.bugfix +++ /dev/null @@ -1 +0,0 @@ -Fixing malformed link pop up when tapping on notifications \ No newline at end of file diff --git a/changelog.d/4276.bugfix b/changelog.d/4276.bugfix deleted file mode 100644 index 8cb2ed6977..0000000000 --- a/changelog.d/4276.bugfix +++ /dev/null @@ -1 +0,0 @@ -Fix Broken EditText when using FromEditTextItem diff --git a/changelog.d/4279.bugfix b/changelog.d/4279.bugfix deleted file mode 100644 index 1b0ea424fa..0000000000 --- a/changelog.d/4279.bugfix +++ /dev/null @@ -1 +0,0 @@ -Fix crash when clicking on ViewEvent source actions \ No newline at end of file diff --git a/changelog.d/4283.bugfix b/changelog.d/4283.bugfix deleted file mode 100644 index 030418c405..0000000000 --- a/changelog.d/4283.bugfix +++ /dev/null @@ -1 +0,0 @@ -Fix voice message record button wrong visibility \ No newline at end of file diff --git a/changelog.d/4313.bugfix b/changelog.d/4313.bugfix deleted file mode 100644 index da28469ed0..0000000000 --- a/changelog.d/4313.bugfix +++ /dev/null @@ -1 +0,0 @@ -Fix unread marker not showing \ No newline at end of file From 201d558925bb5ed395a8b93555108dd52990f3ad Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 25 Oct 2021 12:37:41 +0200 Subject: [PATCH 5/6] Update previous Changelog (the file was not in the correct folder) --- CHANGES.md | 1 + newsfragment/3313.feature | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 newsfragment/3313.feature diff --git a/CHANGES.md b/CHANGES.md index bf855d66f9..d3bc0cc414 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -17,6 +17,7 @@ Features ✨ ---------- - Implement /part command, with or without parameter ([#2909](https://github.com/vector-im/element-android/issues/2909)) - Handle Presence support, for Direct Message room ([#4090](https://github.com/vector-im/element-android/issues/4090)) + - Priority conversations for Android 11+ ([#3313](https://github.com/vector-im/element-android/issues/3313)) Bugfixes 🐛 ---------- diff --git a/newsfragment/3313.feature b/newsfragment/3313.feature deleted file mode 100644 index 3d243fa1ef..0000000000 --- a/newsfragment/3313.feature +++ /dev/null @@ -1 +0,0 @@ -Priority conversations for Android 11+ From f877965550edf2db874555ad23eb0b19519459ce Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 25 Oct 2021 12:38:53 +0200 Subject: [PATCH 6/6] Fastlane files --- fastlane/metadata/android/en-US/changelogs/40103040.txt | 2 +- fastlane/metadata/android/en-US/changelogs/40103050.txt | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 fastlane/metadata/android/en-US/changelogs/40103050.txt diff --git a/fastlane/metadata/android/en-US/changelogs/40103040.txt b/fastlane/metadata/android/en-US/changelogs/40103040.txt index 06b32c8dff..a6af2efe00 100644 --- a/fastlane/metadata/android/en-US/changelogs/40103040.txt +++ b/fastlane/metadata/android/en-US/changelogs/40103040.txt @@ -1,2 +1,2 @@ -Main changes in this version: Add Presence support, for Direct Message room (note: presence is disabled on matrix.org. Add again Android Auto support. +Main changes in this version: Add Presence support, for Direct Message room (note: presence is disabled on matrix.org). Add again Android Auto support. Full changelog: https://github.com/vector-im/element-android/releases/tag/v1.3.4 \ No newline at end of file diff --git a/fastlane/metadata/android/en-US/changelogs/40103050.txt b/fastlane/metadata/android/en-US/changelogs/40103050.txt new file mode 100644 index 0000000000..93227f1a6d --- /dev/null +++ b/fastlane/metadata/android/en-US/changelogs/40103050.txt @@ -0,0 +1,2 @@ +Main changes in this version: Add Presence support, for Direct Message room (note: presence is disabled on matrix.org). Add again Android Auto support. +Full changelog: https://github.com/vector-im/element-android/releases/tag/v1.3.5 \ No newline at end of file