Better summary for pre N devices
This commit is contained in:
parent
9224fcabfa
commit
0bdde4d994
|
@ -20,13 +20,13 @@ import android.content.Context
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import androidx.core.app.NotificationCompat
|
import androidx.core.app.NotificationCompat
|
||||||
import androidx.core.app.Person
|
import androidx.core.app.Person
|
||||||
import im.vector.matrix.android.api.Matrix
|
|
||||||
import im.vector.matrix.android.api.session.content.ContentUrlResolver
|
import im.vector.matrix.android.api.session.content.ContentUrlResolver
|
||||||
import im.vector.riotredesign.BuildConfig
|
import im.vector.riotredesign.BuildConfig
|
||||||
import im.vector.riotredesign.R
|
import im.vector.riotredesign.R
|
||||||
import im.vector.riotredesign.core.di.ActiveSessionHolder
|
import im.vector.riotredesign.core.di.ActiveSessionHolder
|
||||||
import im.vector.riotredesign.core.utils.SecretStoringUtils
|
import im.vector.riotredesign.core.utils.SecretStoringUtils
|
||||||
import im.vector.riotredesign.features.settings.PreferencesManager
|
import im.vector.riotredesign.features.settings.PreferencesManager
|
||||||
|
import me.gujun.android.span.span
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileInputStream
|
import java.io.FileInputStream
|
||||||
|
@ -275,9 +275,32 @@ class NotificationDrawerManager @Inject constructor(private val context: Context
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
val summaryLine = context.resources.getQuantityString(
|
if (events.size == 1) {
|
||||||
R.plurals.notification_compat_summary_line_for_room, events.size, roomName, events.size)
|
val event = events[0]
|
||||||
summaryInboxStyle.addLine(summaryLine)
|
if (roomEventGroupInfo.isDirect) {
|
||||||
|
val line = span {
|
||||||
|
span {
|
||||||
|
textStyle = "bold"
|
||||||
|
+String.format("%s: ", event.senderName)
|
||||||
|
}
|
||||||
|
+(event.description ?: "")
|
||||||
|
}
|
||||||
|
summaryInboxStyle.addLine(line)
|
||||||
|
} else {
|
||||||
|
val line = span {
|
||||||
|
span {
|
||||||
|
textStyle = "bold"
|
||||||
|
+String.format("%s: %s ", roomName, event.senderName)
|
||||||
|
}
|
||||||
|
+(event.description ?: "")
|
||||||
|
}
|
||||||
|
summaryInboxStyle.addLine(line)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
val summaryLine = context.resources.getQuantityString(
|
||||||
|
R.plurals.notification_compat_summary_line_for_room, events.size, roomName, events.size)
|
||||||
|
summaryInboxStyle.addLine(summaryLine)
|
||||||
|
}
|
||||||
} catch (e: Throwable) {
|
} catch (e: Throwable) {
|
||||||
//String not found or bad format
|
//String not found or bad format
|
||||||
Timber.v("%%%%%%%% REFRESH NOTIFICATION DRAWER failed to resolve string")
|
Timber.v("%%%%%%%% REFRESH NOTIFICATION DRAWER failed to resolve string")
|
||||||
|
@ -343,6 +366,11 @@ class NotificationDrawerManager @Inject constructor(private val context: Context
|
||||||
val sumTitle = context.resources.getQuantityString(
|
val sumTitle = context.resources.getQuantityString(
|
||||||
R.plurals.notification_compat_summary_title, nbEvents, nbEvents)
|
R.plurals.notification_compat_summary_title, nbEvents, nbEvents)
|
||||||
summaryInboxStyle.setBigContentTitle(sumTitle)
|
summaryInboxStyle.setBigContentTitle(sumTitle)
|
||||||
|
//TODO get latest event?
|
||||||
|
.setSummaryText(
|
||||||
|
context.resources
|
||||||
|
.getQuantityString(R.plurals.notification_unread_notified_messages, nbEvents, nbEvents))
|
||||||
|
|
||||||
NotificationUtils.buildSummaryListNotification(
|
NotificationUtils.buildSummaryListNotification(
|
||||||
context,
|
context,
|
||||||
summaryInboxStyle,
|
summaryInboxStyle,
|
||||||
|
|
|
@ -606,7 +606,7 @@ object NotificationUtils {
|
||||||
* Build the summary notification
|
* Build the summary notification
|
||||||
*/
|
*/
|
||||||
fun buildSummaryListNotification(context: Context,
|
fun buildSummaryListNotification(context: Context,
|
||||||
style: NotificationCompat.Style,
|
style: NotificationCompat.InboxStyle,
|
||||||
compatSummary: String,
|
compatSummary: String,
|
||||||
noisy: Boolean,
|
noisy: Boolean,
|
||||||
lastMessageTimestamp: Long): Notification? {
|
lastMessageTimestamp: Long): Notification? {
|
||||||
|
|
Loading…
Reference in New Issue