For #2890: Sending tab from another device shows empty title
parent
d825011fc0
commit
06bf7a4da7
|
@ -15,6 +15,7 @@ import android.os.Build
|
|||
import androidx.core.app.NotificationCompat
|
||||
import androidx.core.app.NotificationManagerCompat
|
||||
import mozilla.components.concept.sync.DeviceEvent
|
||||
import mozilla.components.concept.sync.TabData
|
||||
import org.mozilla.fenix.R
|
||||
|
||||
/**
|
||||
|
@ -51,7 +52,7 @@ class NotificationManager(private val context: Context) {
|
|||
|
||||
val builder = NotificationCompat.Builder(context, RECEIVE_TABS_CHANNEL_ID)
|
||||
.setSmallIcon(R.drawable.ic_status_logo)
|
||||
.setContentTitle(tab.title)
|
||||
.setTitle(event, tab)
|
||||
.setContentText(tab.url)
|
||||
.setContentIntent(pendingIntent)
|
||||
.setAutoCancel(true)
|
||||
|
@ -85,4 +86,21 @@ class NotificationManager(private val context: Context) {
|
|||
context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||
notificationManager.createNotificationChannel(channel)
|
||||
}
|
||||
|
||||
private fun NotificationCompat.Builder.setTitle(
|
||||
event: DeviceEvent.TabReceived,
|
||||
tab: TabData
|
||||
): NotificationCompat.Builder {
|
||||
event.from?.let { device ->
|
||||
setContentTitle(context.getString(R.string.fxa_tab_received_from_notification_name, device.displayName))
|
||||
return this
|
||||
}
|
||||
|
||||
if (tab.title.isEmpty()) {
|
||||
setContentTitle(context.getString(R.string.fxa_tab_received_notification_name))
|
||||
} else {
|
||||
setContentTitle(tab.title)
|
||||
}
|
||||
return this
|
||||
}
|
||||
}
|
||||
|
|
|
@ -171,6 +171,12 @@
|
|||
<string name="fxa_received_tab_channel_name">Received tabs</string>
|
||||
<!-- Description of the "receive tabs" notification channel. Displayed in the "App notifications" system settings for the app -->
|
||||
<string name="fxa_received_tab_channel_description">Notifications for tabs received from other Firefox devices.</string>
|
||||
<!-- The body for these is the URL of the tab received -->
|
||||
<string name="fxa_tab_received_notification_name">Tab Received</string>
|
||||
<!-- When multiple tabs have been received -->
|
||||
<string name="fxa_tabs_received_notification_name">Tabs Received</string>
|
||||
<!-- %s is the device name -->
|
||||
<string name="fxa_tab_received_from_notification_name">Tab from %s</string>
|
||||
|
||||
<!-- Advanced Preferences -->
|
||||
<!-- Preference for tracking protection settings -->
|
||||
|
|
Loading…
Reference in New Issue