hide secrets in notifications, closes #416 (#424)

* terminal: hide secrets in notifications #416

* ios: hide secrets in notifications

* android: hide secrets in notifications
This commit is contained in:
Evgeny Poberezkin
2022-03-13 20:13:47 +00:00
committed by GitHub
parent 806f417e99
commit 1f539fc8be
4 changed files with 42 additions and 22 deletions
@@ -36,7 +36,7 @@ class NtfManager(val context: Context) {
val notification = NotificationCompat.Builder(context, MessageChannel)
.setContentTitle(cInfo.displayName)
.setContentText(cItem.content.text)
.setContentText(hideSecrets(cItem))
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setGroup(MessageGroup)
.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_CHILDREN)
@@ -62,6 +62,19 @@ class NtfManager(val context: Context) {
}
}
private fun hideSecrets(cItem: ChatItem): String {
val md = cItem.formattedText
return if (md == null) {
cItem.content.text
} else {
var res = ""
for (ft in md) {
res += if (ft.format is Format.Secret) "..." else ft.text
}
res
}
}
private fun getMsgPendingIntent(cInfo: ChatInfo) : PendingIntent{
Log.d(TAG, "getMsgPendingIntent ${cInfo.id}")
val uniqueInt = (System.currentTimeMillis() and 0xfffffff).toInt()