mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
feat: show unique messaging notifications per contact (#1381)
* Show unique notifications per contact Instead of a single notification for all messages, each contact now has its own, unique notification. This uses the `NotificationCompat.MessagingStyle` and the contact's name to create distinct notifications, enhancing message organization. * feat: Add notification tap action to open contacts tab This is done by: - Adding an intent extra to the notification with the contact key for future use to navigate to the message thread. - Adding a new action to the MainActivity to handle the intent. - Updating the message notification to include the intent. * Open message notification to the correct conversation Adds an extra to the message notification intent to open the correct conversation. This ensures that when a user taps on a message notification, they are taken to the conversation with the sender of that message.
This commit is contained in:
parent
eea62e6533
commit
80e915a36c
3 changed files with 45 additions and 14 deletions
|
|
@ -270,6 +270,14 @@ class MainActivity : AppCompatActivity(), Logging {
|
|||
// We now wait for the device to connect, once connected, we ask the user if they want to switch to the new channel
|
||||
}
|
||||
|
||||
MeshServiceNotifications.OPEN_MESSAGE_ACTION -> {
|
||||
val contactKey =
|
||||
intent.getStringExtra(MeshServiceNotifications.OPEN_MESSAGE_EXTRA_CONTACT_KEY)
|
||||
val contactName =
|
||||
intent.getStringExtra(MeshServiceNotifications.OPEN_MESSAGE_EXTRA_CONTACT_NAME)
|
||||
showMessages(contactKey, contactName)
|
||||
}
|
||||
|
||||
UsbManager.ACTION_USB_DEVICE_ATTACHED -> {
|
||||
showSettingsPage()
|
||||
}
|
||||
|
|
@ -599,6 +607,13 @@ class MainActivity : AppCompatActivity(), Logging {
|
|||
binding.pager.currentItem = 5
|
||||
}
|
||||
|
||||
private fun showMessages(contactKey: String?, contactName: String?) {
|
||||
model.setCurrentTab(0)
|
||||
if (contactKey != null && contactName != null) {
|
||||
supportFragmentManager.navigateToMessages(contactKey, contactName)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
// Inflate the menu; this adds items to the action bar if it is present.
|
||||
menuInflater.inflate(R.menu.menu_main, menu)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue