Commit b9893560 authored by Leonardo Aramaki's avatar Leonardo Aramaki

Few renames

parent 87d0435d
...@@ -39,7 +39,7 @@ import java.util.* ...@@ -39,7 +39,7 @@ import java.util.*
import java.util.concurrent.atomic.AtomicInteger import java.util.concurrent.atomic.AtomicInteger
import kotlin.collections.HashMap import kotlin.collections.HashMap
typealias HostTotalMsgTuple<A, B> = Pair<A, B> typealias HostIdAndMessageCountTuple = Pair<Int, AtomicInteger>
object PushManager { object PushManager {
const val REPLY_LABEL = "REPLY" const val REPLY_LABEL = "REPLY"
...@@ -49,7 +49,7 @@ object PushManager { ...@@ -49,7 +49,7 @@ object PushManager {
private val messageStack = SparseArray<ArrayList<CharSequence>>() private val messageStack = SparseArray<ArrayList<CharSequence>>()
// Notifications received from the same server are grouped in a single bundled notification. // Notifications received from the same server are grouped in a single bundled notification.
// This map associates a host to a group id. // This map associates a host to a group id.
private val groupMap = HashMap<String, HostTotalMsgTuple<Int, AtomicInteger>>() private val groupMap = HashMap<String, HostIdAndMessageCountTuple<Int, AtomicInteger>>()
private val randomizer = Random() private val randomizer = Random()
/** /**
...@@ -114,16 +114,16 @@ object PushManager { ...@@ -114,16 +114,16 @@ object PushManager {
private fun isAndroidVersionAtLeast(minVersion: Int) = Build.VERSION.SDK_INT >= minVersion private fun isAndroidVersionAtLeast(minVersion: Int) = Build.VERSION.SDK_INT >= minVersion
private fun addGroupToBundle(host: String) { private fun bundleNotificationsToHost(host: String) {
val size = groupMap.size val size = groupMap.size
if (groupMap.get(host) == null) { if (groupMap.get(host) == null) {
groupMap.put(host, HostTotalMsgTuple(size + 1, AtomicInteger(0))) groupMap.put(host, HostIdAndMessageCountTuple(size + 1, AtomicInteger(0)))
} }
} }
private fun createGroupNotification(context: Context, pushMessage: PushMessage): Notification { private fun createGroupNotification(context: Context, pushMessage: PushMessage): Notification {
// Create notification group. // Create notification group.
addGroupToBundle(pushMessage.host) bundleNotificationsToHost(pushMessage.host)
val id = pushMessage.notificationId.toInt() val id = pushMessage.notificationId.toInt()
val contentIntent = getContentIntent(context, id, pushMessage, group = true) val contentIntent = getContentIntent(context, id, pushMessage, group = true)
val deleteIntent = getDismissIntent(context, id) val deleteIntent = getDismissIntent(context, id)
...@@ -253,7 +253,7 @@ object PushManager { ...@@ -253,7 +253,7 @@ object PushManager {
if (messageCount > 1) { if (messageCount > 1) {
val summary = summaryText.replace("%n%", messageCount.toString()) val summary = summaryText.replace("%n%", messageCount.toString())
.fromHtml() .fromHtml()
val inbox = NotificationCompat.InboxStyle() val inbox = Notification.InboxStyle()
.setBigContentTitle(title.fromHtml()) .setBigContentTitle(title.fromHtml())
.setSummaryText(summary) .setSummaryText(summary)
...@@ -263,7 +263,7 @@ object PushManager { ...@@ -263,7 +263,7 @@ object PushManager {
notificationBuilder.setStyle(inbox) notificationBuilder.setStyle(inbox)
} else { } else {
val bigText = NotificationCompat.BigTextStyle() val bigText = Notification.BigTextStyle()
.bigText(message.fromHtml()) .bigText(message.fromHtml())
.setBigContentTitle(title.fromHtml()) .setBigContentTitle(title.fromHtml())
...@@ -489,10 +489,10 @@ object PushManager { ...@@ -489,10 +489,10 @@ object PushManager {
.firstElement() .firstElement()
.toSingle() .toSingle()
val roomUserTuple: Single<HostTotalMsgTuple<Room, User>> = Single.zip( val roomUserTuple: Single<HostIdAndMessageCountTuple<Room, User>> = Single.zip(
singleRoom, singleRoom,
singleUser, singleUser,
BiFunction { room, user -> HostTotalMsgTuple(room, user) }) BiFunction { room, user -> HostIdAndMessageCountTuple(room, user) })
roomUserTuple.flatMap { tuple -> messageInteractor.send(tuple.first, tuple.second, message as String) } roomUserTuple.flatMap { tuple -> messageInteractor.send(tuple.first, tuple.second, message as String) }
.subscribeOn(AndroidSchedulers.from(BackgroundLooper.get())) .subscribeOn(AndroidSchedulers.from(BackgroundLooper.get()))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment