Skip to content

Commit

Permalink
Android Auto bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelkourlas committed Jan 26, 2021
1 parent 0e9c13c commit 57dcaed
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 30 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.6.12 ##

* Bug fixes

## 0.6.11 ##

* Bug fixes
Expand Down
4 changes: 2 additions & 2 deletions voipms-sms/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
applicationId 'net.kourlas.voipms_sms'
minSdkVersion 21
targetSdkVersion 30
versionCode 131
versionName '0.6.11'
versionCode 132
versionName '0.6.12'
}
flavorDimensions 'version', 'demo'
productFlavors {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,31 +418,13 @@ class Notifications private constructor(
notification.setStyle(style)

// Reply button
val replyPendingIntent: PendingIntent
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
// Send reply string directly to SendMessageService
val replyIntent = SendMessageService.getIntent(
context, did, contact)
replyIntent.component = ComponentName(
context, SendMessageReceiver::class.java)
replyPendingIntent = PendingIntent.getBroadcast(
context, (did + contact).hashCode(),
replyIntent, PendingIntent.FLAG_CANCEL_CURRENT)
} else {
// Inline reply is not supported, so just show the conversation
// activity
val replyIntent = Intent(context, ConversationActivity::class.java)
replyIntent.putExtra(context.getString(
R.string.conversation_did), did)
replyIntent.putExtra(context.getString(
R.string.conversation_contact), contact)
replyIntent.putExtra(context.getString(
R.string.conversation_extra_focus), true)
replyIntent.flags = Intent.FLAG_ACTIVITY_NEW_DOCUMENT
replyPendingIntent = PendingIntent.getActivity(
context, (did + contact + "reply").hashCode(),
replyIntent, PendingIntent.FLAG_CANCEL_CURRENT)
}
val replyIntent = SendMessageService.getIntent(
context, did, contact)
replyIntent.component = ComponentName(
context, SendMessageReceiver::class.java)
val replyPendingIntent = PendingIntent.getBroadcast(
context, (did + contact + "reply").hashCode(),
replyIntent, PendingIntent.FLAG_CANCEL_CURRENT)
val remoteInput = RemoteInput.Builder(context.getString(
R.string.notifications_reply_key))
.setLabel(context.getString(R.string.notifications_button_reply))
Expand All @@ -455,14 +437,43 @@ class Notifications private constructor(
.setShowsUserInterface(false)
.setAllowGeneratedReplies(true)
.addRemoteInput(remoteInput)
notification.addAction(replyActionBuilder.build())

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
notification.addAction(replyActionBuilder.build())
} else {
notification.addInvisibleAction(replyActionBuilder.build())

// Inline reply is not supported, so just show the conversation
// activity
val visibleReplyIntent = Intent(context,
ConversationActivity::class.java)
visibleReplyIntent.putExtra(context.getString(
R.string.conversation_did), did)
visibleReplyIntent.putExtra(context.getString(
R.string.conversation_contact), contact)
visibleReplyIntent.putExtra(context.getString(
R.string.conversation_extra_focus), true)
visibleReplyIntent.flags = Intent.FLAG_ACTIVITY_NEW_DOCUMENT
val visibleReplyPendingIntent = PendingIntent.getActivity(
context, (did + contact + "replyVisible").hashCode(),
visibleReplyIntent, PendingIntent.FLAG_CANCEL_CURRENT)
val visibleReplyActionBuilder = NotificationCompat.Action.Builder(
R.drawable.ic_reply_toolbar_24dp,
context.getString(R.string.notifications_button_reply),
visibleReplyPendingIntent)
.setSemanticAction(
NotificationCompat.Action.SEMANTIC_ACTION_REPLY)
.setShowsUserInterface(true)
.addRemoteInput(remoteInput)
notification.addAction(visibleReplyActionBuilder.build())
}

// Mark as read button
val markReadIntent = MarkReadService.getIntent(context, did, contact)
markReadIntent.component = ComponentName(
context, MarkReadReceiver::class.java)
val markReadPendingIntent = PendingIntent.getBroadcast(
context, (did + contact).hashCode(),
context, (did + contact + "markRead").hashCode(),
markReadIntent, PendingIntent.FLAG_CANCEL_CURRENT)
val markReadAction = NotificationCompat.Action.Builder(
R.drawable.ic_drafts_toolbar_24dp,
Expand Down
2 changes: 1 addition & 1 deletion voipms-sms/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@
<string name="retrieve_dids_auto_add" translatable="false">retrieve_dids_auto_add</string>

<!-- SendMessageService -->
<string name="send_message_action" translatable="false">send_message_action</string>
<string name="send_message_action" translatable="false">net.kourlas.voipms_sms.SEND_MESSAGE_ACTION</string>
<string name="send_message_contact" translatable="false">send_message_contact</string>
<string name="send_message_database_id" translatable="false">send_message_database_id</string>
<string name="send_message_did" translatable="false">send_message_did</string>
Expand Down

0 comments on commit 57dcaed

Please sign in to comment.