|
|
|
@ -19,6 +19,7 @@ import androidx.core.app.NotificationManagerCompat
|
|
|
|
|
import androidx.core.content.getSystemService
|
|
|
|
|
import mozilla.components.concept.sync.DeviceEvent
|
|
|
|
|
import mozilla.components.concept.sync.TabData
|
|
|
|
|
import mozilla.components.support.base.ids.notify
|
|
|
|
|
import mozilla.components.support.base.log.logger.Logger
|
|
|
|
|
import org.mozilla.fenix.R
|
|
|
|
|
|
|
|
|
@ -29,6 +30,8 @@ class NotificationManager(private val context: Context) {
|
|
|
|
|
companion object {
|
|
|
|
|
const val RECEIVE_TABS_TAG = "ReceivedTabs"
|
|
|
|
|
const val RECEIVE_TABS_CHANNEL_ID = "ReceivedTabsChannel"
|
|
|
|
|
const val DEFAULT_CHANNEL_TAG = "Default"
|
|
|
|
|
const val DEFAULT_CHANEL_ID = "DefaultChannel"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
init {
|
|
|
|
@ -44,6 +47,13 @@ class NotificationManager(private val context: Context) {
|
|
|
|
|
context.getString(R.string.fxa_received_tab_channel_name),
|
|
|
|
|
context.getString(R.string.fxa_received_tab_channel_description)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
createNotificationChannel(
|
|
|
|
|
DEFAULT_CHANEL_ID,
|
|
|
|
|
NotificationManager.IMPORTANCE_DEFAULT,
|
|
|
|
|
context.getString(R.string.app_name),
|
|
|
|
|
""
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -88,6 +98,21 @@ class NotificationManager(private val context: Context) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun showMessage(message: String) {
|
|
|
|
|
val builder = NotificationCompat.Builder(context, DEFAULT_CHANEL_ID)
|
|
|
|
|
.setSmallIcon(R.drawable.ic_status_logo)
|
|
|
|
|
.setContentTitle(context.getString(R.string.app_name))
|
|
|
|
|
.setContentText(message)
|
|
|
|
|
.setWhen(System.currentTimeMillis())
|
|
|
|
|
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
|
|
|
|
.setDefaults(Notification.DEFAULT_VIBRATE or Notification.DEFAULT_SOUND)
|
|
|
|
|
|
|
|
|
|
val notification = builder.build()
|
|
|
|
|
with(NotificationManagerCompat.from(context)) {
|
|
|
|
|
notify(context, DEFAULT_CHANNEL_TAG, notification)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@TargetApi(Build.VERSION_CODES.O)
|
|
|
|
|
private fun createNotificationChannel(
|
|
|
|
|
channelId: String,
|
|
|
|
|