use the BigTextStyle notification style at received SMS
This commit is contained in:
parent
1fe2f10d53
commit
a3e89719b1
|
@ -8,6 +8,7 @@ import android.app.PendingIntent
|
||||||
import android.content.BroadcastReceiver
|
import android.content.BroadcastReceiver
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.graphics.BitmapFactory
|
||||||
import android.media.AudioAttributes
|
import android.media.AudioAttributes
|
||||||
import android.media.AudioManager
|
import android.media.AudioManager
|
||||||
import android.media.RingtoneManager
|
import android.media.RingtoneManager
|
||||||
|
@ -64,6 +65,7 @@ class SmsReceiver : BroadcastReceiver() {
|
||||||
setBypassDnd(false)
|
setBypassDnd(false)
|
||||||
enableLights(true)
|
enableLights(true)
|
||||||
setSound(soundUri, audioAttributes)
|
setSound(soundUri, audioAttributes)
|
||||||
|
enableVibration(true)
|
||||||
notificationManager.createNotificationChannel(this)
|
notificationManager.createNotificationChannel(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,11 +77,14 @@ class SmsReceiver : BroadcastReceiver() {
|
||||||
}
|
}
|
||||||
|
|
||||||
val pendingIntent = PendingIntent.getActivity(context, threadID, intent, PendingIntent.FLAG_UPDATE_CURRENT)
|
val pendingIntent = PendingIntent.getActivity(context, threadID, intent, PendingIntent.FLAG_UPDATE_CURRENT)
|
||||||
|
val summaryText = context.getString(R.string.new_message)
|
||||||
|
|
||||||
val builder = NotificationCompat.Builder(context, channelId)
|
val builder = NotificationCompat.Builder(context, channelId)
|
||||||
.setContentTitle(address)
|
.setContentTitle(address)
|
||||||
.setContentText(body)
|
.setContentText(body)
|
||||||
.setSmallIcon(R.drawable.ic_launcher_foreground)
|
.setSmallIcon(R.drawable.ic_launcher_foreground)
|
||||||
|
.setLargeIcon(BitmapFactory.decodeResource(context.resources, R.drawable.ic_launcher_foreground))
|
||||||
|
.setStyle(NotificationCompat.BigTextStyle().setSummaryText(summaryText).bigText(body))
|
||||||
.setContentIntent(pendingIntent)
|
.setContentIntent(pendingIntent)
|
||||||
.setPriority(NotificationCompat.PRIORITY_MAX)
|
.setPriority(NotificationCompat.PRIORITY_MAX)
|
||||||
.setDefaults(Notification.DEFAULT_LIGHTS)
|
.setDefaults(Notification.DEFAULT_LIGHTS)
|
||||||
|
|
|
@ -6,4 +6,5 @@
|
||||||
|
|
||||||
<!-- Notifications -->
|
<!-- Notifications -->
|
||||||
<string name="channel_received_sms">Received SMS</string>
|
<string name="channel_received_sms">Received SMS</string>
|
||||||
|
<string name="new_message">New message</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in New Issue