|
|
|
@ -69,27 +69,13 @@ class SessionNotificationService : Service() {
|
|
|
|
|
return NotificationCompat.Builder(this, NOTIFICATION_CHANNEL_ID)
|
|
|
|
|
.setOngoing(true)
|
|
|
|
|
.setSmallIcon(R.drawable.ic_pbm_notification)
|
|
|
|
|
.setContentTitle(getString(R.string.app_name_private_2))
|
|
|
|
|
.setContentText(getString(R.string.notification_pbm_delete_text))
|
|
|
|
|
.setContentTitle(getString(R.string.app_name_private_3))
|
|
|
|
|
.setContentText(getString(R.string.notification_pbm_delete_text_2))
|
|
|
|
|
.setContentIntent(createNotificationIntent())
|
|
|
|
|
.setVisibility(NotificationCompat.VISIBILITY_SECRET)
|
|
|
|
|
.setShowWhen(false)
|
|
|
|
|
.setLocalOnly(true)
|
|
|
|
|
.setColor(ContextCompat.getColor(this, R.color.pbm_notification_color))
|
|
|
|
|
.addAction(
|
|
|
|
|
NotificationCompat.Action(
|
|
|
|
|
0,
|
|
|
|
|
getString(R.string.notification_pbm_action_open),
|
|
|
|
|
createOpenActionIntent()
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
.addAction(
|
|
|
|
|
NotificationCompat.Action(
|
|
|
|
|
0,
|
|
|
|
|
getString(R.string.notification_pbm_action_delete_and_open),
|
|
|
|
|
createOpenAndEraseActionIntent()
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
.build()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -100,23 +86,6 @@ class SessionNotificationService : Service() {
|
|
|
|
|
return PendingIntent.getService(this, 0, intent, PendingIntent.FLAG_ONE_SHOT)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun createOpenActionIntent(): PendingIntent {
|
|
|
|
|
val intent = Intent(this, HomeActivity::class.java)
|
|
|
|
|
intent.putExtra(HomeActivity.EXTRA_OPENED_FROM_NOTIFICATION, true)
|
|
|
|
|
intent.putExtra(HomeActivity.PRIVATE_BROWSING_MODE, true)
|
|
|
|
|
|
|
|
|
|
return PendingIntent.getActivity(this, 1, intent, PendingIntent.FLAG_UPDATE_CURRENT)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun createOpenAndEraseActionIntent(): PendingIntent {
|
|
|
|
|
val intent = Intent(this, HomeActivity::class.java)
|
|
|
|
|
|
|
|
|
|
intent.putExtra(HomeActivity.EXTRA_DELETE_PRIVATE_TABS, true)
|
|
|
|
|
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
|
|
|
|
|
|
|
|
|
|
return PendingIntent.getActivity(this, 2, intent, PendingIntent.FLAG_CANCEL_CURRENT)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun createNotificationChannelIfNeeded() {
|
|
|
|
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
|
|
|
|
// Notification channels are only available on Android O or higher.
|
|
|
|
|