Add Android Auto notification support

Signed-off-by: Alex Baker <alex@beeper.com>
This commit is contained in:
Alex Baker 2021-09-24 16:28:00 -05:00
parent cde6e8cc1b
commit 09a25cce4e
4 changed files with 17 additions and 4 deletions

1
changelog.d/240.feature Normal file
View File

@ -0,0 +1 @@
Android Auto notification support

View File

@ -83,6 +83,10 @@
android:name="android.max_aspect" android:name="android.max_aspect"
android:value="9.9" /> android:value="9.9" />
<meta-data
android:name="com.google.android.gms.car.application"
android:resource="@xml/automotive_app_desc" />
<activity <activity
android:name=".features.MainActivity" android:name=".features.MainActivity"
android:theme="@style/Theme.Vector.Launcher" /> android:theme="@style/Theme.Vector.Launcher" />

View File

@ -597,10 +597,12 @@ class NotificationUtils @Inject constructor(private val context: Context,
val markRoomReadPendingIntent = PendingIntent.getBroadcast(context, System.currentTimeMillis().toInt(), markRoomReadIntent, val markRoomReadPendingIntent = PendingIntent.getBroadcast(context, System.currentTimeMillis().toInt(), markRoomReadIntent,
PendingIntent.FLAG_UPDATE_CURRENT) PendingIntent.FLAG_UPDATE_CURRENT)
addAction(NotificationCompat.Action( NotificationCompat.Action.Builder(R.drawable.ic_material_done_all_white,
R.drawable.ic_material_done_all_white, stringProvider.getString(R.string.action_mark_room_read), markRoomReadPendingIntent)
stringProvider.getString(R.string.action_mark_room_read), .setSemanticAction(NotificationCompat.Action.SEMANTIC_ACTION_MARK_AS_READ)
markRoomReadPendingIntent)) .setShowsUserInterface(false)
.build()
.let { addAction(it) }
// Quick reply // Quick reply
if (!roomInfo.hasSmartReplyError) { if (!roomInfo.hasSmartReplyError) {
@ -611,6 +613,8 @@ class NotificationUtils @Inject constructor(private val context: Context,
NotificationCompat.Action.Builder(R.drawable.vector_notification_quick_reply, NotificationCompat.Action.Builder(R.drawable.vector_notification_quick_reply,
stringProvider.getString(R.string.action_quick_reply), replyPendingIntent) stringProvider.getString(R.string.action_quick_reply), replyPendingIntent)
.addRemoteInput(remoteInput) .addRemoteInput(remoteInput)
.setSemanticAction(NotificationCompat.Action.SEMANTIC_ACTION_REPLY)
.setShowsUserInterface(false)
.build() .build()
.let { addAction(it) } .let { addAction(it) }
} }

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<automotiveApp>
<uses name="notification" />
</automotiveApp>