From 09a25cce4e7e14edf5084dcc95bc9bf60ff96dc3 Mon Sep 17 00:00:00 2001 From: Alex Baker Date: Fri, 24 Sep 2021 16:28:00 -0500 Subject: [PATCH] Add Android Auto notification support Signed-off-by: Alex Baker --- changelog.d/240.feature | 1 + vector/src/main/AndroidManifest.xml | 4 ++++ .../app/features/notifications/NotificationUtils.kt | 12 ++++++++---- vector/src/main/res/xml/automotive_app_desc.xml | 4 ++++ 4 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 changelog.d/240.feature create mode 100644 vector/src/main/res/xml/automotive_app_desc.xml diff --git a/changelog.d/240.feature b/changelog.d/240.feature new file mode 100644 index 0000000000..ee4d07a975 --- /dev/null +++ b/changelog.d/240.feature @@ -0,0 +1 @@ +Android Auto notification support diff --git a/vector/src/main/AndroidManifest.xml b/vector/src/main/AndroidManifest.xml index 6c9453a564..01ca5cecd9 100644 --- a/vector/src/main/AndroidManifest.xml +++ b/vector/src/main/AndroidManifest.xml @@ -83,6 +83,10 @@ android:name="android.max_aspect" android:value="9.9" /> + + 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 c575063ce9..29654ec3e1 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 @@ -597,10 +597,12 @@ class NotificationUtils @Inject constructor(private val context: Context, val markRoomReadPendingIntent = PendingIntent.getBroadcast(context, System.currentTimeMillis().toInt(), markRoomReadIntent, PendingIntent.FLAG_UPDATE_CURRENT) - addAction(NotificationCompat.Action( - R.drawable.ic_material_done_all_white, - stringProvider.getString(R.string.action_mark_room_read), - markRoomReadPendingIntent)) + NotificationCompat.Action.Builder(R.drawable.ic_material_done_all_white, + stringProvider.getString(R.string.action_mark_room_read), markRoomReadPendingIntent) + .setSemanticAction(NotificationCompat.Action.SEMANTIC_ACTION_MARK_AS_READ) + .setShowsUserInterface(false) + .build() + .let { addAction(it) } // Quick reply if (!roomInfo.hasSmartReplyError) { @@ -611,6 +613,8 @@ class NotificationUtils @Inject constructor(private val context: Context, NotificationCompat.Action.Builder(R.drawable.vector_notification_quick_reply, stringProvider.getString(R.string.action_quick_reply), replyPendingIntent) .addRemoteInput(remoteInput) + .setSemanticAction(NotificationCompat.Action.SEMANTIC_ACTION_REPLY) + .setShowsUserInterface(false) .build() .let { addAction(it) } } diff --git a/vector/src/main/res/xml/automotive_app_desc.xml b/vector/src/main/res/xml/automotive_app_desc.xml new file mode 100644 index 0000000000..66dd335d1a --- /dev/null +++ b/vector/src/main/res/xml/automotive_app_desc.xml @@ -0,0 +1,4 @@ + + + +