@ -45,7 +45,7 @@ class SendStatusBroadcastReceiver : BroadcastReceiver() {
AndroidInjection . inject ( this , context )
AndroidInjection . inject ( this , context )
if ( intent . action == NotificationHelper . REPLY _ACTION ) {
if ( intent . action == NotificationHelper . REPLY _ACTION ) {
val n otificationId = intent . getInt Extra ( NotificationHelper . KEY _NOTIFICATION _ID , - 1 )
val serverN otificationId = intent . getString Extra ( NotificationHelper . KEY _SERVER _NOTIFICATION _ID )
val senderId = intent . getLongExtra ( NotificationHelper . KEY _SENDER _ACCOUNT _ID , - 1 )
val senderId = intent . getLongExtra ( NotificationHelper . KEY _SENDER _ACCOUNT _ID , - 1 )
val senderIdentifier = intent . getStringExtra (
val senderIdentifier = intent . getStringExtra (
NotificationHelper . KEY _SENDER _ACCOUNT _IDENTIFIER
NotificationHelper . KEY _SENDER _ACCOUNT _IDENTIFIER
@ -69,24 +69,23 @@ class SendStatusBroadcastReceiver : BroadcastReceiver() {
if ( account == null ) {
if ( account == null ) {
Log . w ( TAG , " Account \" $senderId \" not found in database. Aborting quick reply! " )
Log . w ( TAG , " Account \" $senderId \" not found in database. Aborting quick reply! " )
val builder = NotificationCompat . Builder (
val notification = NotificationCompat . Builder (
context ,
context ,
NotificationHelper . CHANNEL _MENTION + senderIdentifier
NotificationHelper . CHANNEL _MENTION + senderIdentifier
)
)
. setSmallIcon ( R . drawable . ic _notify )
. setSmallIcon ( R . drawable . ic _notify )
. setColor ( context . getColor ( R . color . tusky _blue ) )
. setColor ( context . getColor ( R . color . tusky _blue ) )
. setGroup ( senderFullName )
. setGroup ( senderFullName )
. setDefaults ( 0 ) // So it doesn't ring twice, notify only in Target callback
. setDefaults ( 0 ) // We don't want this to make any sound or vibration
. setOnlyAlertOnce ( true )
builder . setContentTitle ( context . getString ( R . string . error _generic ) )
. setContentTitle ( context . getString ( R . string . error _generic ) )
builder . setContentText ( context . getString ( R . string . error _sender _account _gone ) )
. setContentText ( context . getString ( R . string . error _sender _account _gone ) )
. setSubText ( senderFullName )
builder . setSubText ( senderFullName )
. setVisibility ( NotificationCompat . VISIBILITY _PUBLIC )
builder . setVisibility ( NotificationCompat . VISIBILITY _PUBLIC )
. setCategory ( NotificationCompat . CATEGORY _SOCIAL )
builder . setCategory ( NotificationCompat . CATEGORY _SOCIAL )
. build ( )
builder . setOnlyAlertOnce ( true )
notificationManager . notify ( serverNotificationId , senderId . toInt ( ) , notification )
notificationManager . notify ( notificationId , builder . build ( ) )
} else {
} else {
val text = mentions . joinToString ( " " , postfix = " " ) { " @ $it " } + message . toString ( )
val text = mentions . joinToString ( " " , postfix = " " ) { " @ $it " } + message . toString ( )
@ -114,25 +113,25 @@ class SendStatusBroadcastReceiver : BroadcastReceiver() {
context . startService ( sendIntent )
context . startService ( sendIntent )
val builder = NotificationCompat . Builder (
// Notifications with remote input active can't be cancelled, so let's replace it with another one that will dismiss automatically
val notification = NotificationCompat . Builder (
context ,
context ,
NotificationHelper . CHANNEL _MENTION + senderIdentifier
NotificationHelper . CHANNEL _MENTION + senderIdentifier
)
)
. setSmallIcon ( R . drawable . ic _notify )
. setSmallIcon ( R . drawable . ic _notify )
. setColor ( context . getColor ( R . color . notification _color ) )
. setColor ( context . getColor ( R . color . notification _color ) )
. setGroup ( senderFullName )
. setGroup ( senderFullName )
. setDefaults ( 0 ) // So it doesn't ring twice, notify only in Target callback
. setDefaults ( 0 ) // We don't want this to make any sound or vibration
. setOnlyAlertOnce ( true )
builder . setContentTitle ( context . getString ( R . string . post _sent ) )
. setContentTitle ( context . getString ( R . string . reply _sending ) )
builder . setContentText ( context . getString ( R . string . post _sent _long ) )
. setContentText ( context . getString ( R . string . reply _sending _long ) )
. setSubText ( senderFullName )
builder . setSubText ( senderFullName )
. setVisibility ( NotificationCompat . VISIBILITY _PUBLIC )
builder . setVisibility ( NotificationCompat . VISIBILITY _PUBLIC )
. setCategory ( NotificationCompat . CATEGORY _SOCIAL )
builder . setCategory ( NotificationCompat . CATEGORY _SOCIAL )
. setTimeoutAfter ( 5000 )
builder . setOnlyAlertOnce ( true )
. build ( )
// There is a separate "I am sending" notification, so simply remove the handled one.
notificationManager . notify ( serverNotificationId , senderId . toInt ( ) , notification )
notificationManager . cancel ( notificationId )
}
}
}
}
}
}