Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AloqaIM-Android
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
AloqaIM-Android
Commits
b9893560
Commit
b9893560
authored
Oct 20, 2017
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Few renames
parent
87d0435d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
9 deletions
+9
-9
PushManager.kt
app/src/main/java/chat/rocket/android/push/PushManager.kt
+9
-9
No files found.
app/src/main/java/chat/rocket/android/push/PushManager.kt
View file @
b9893560
...
@@ -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
Host
TotalMsgTuple
<
A
,
B
>
=
Pair
<
A
,
B
>
typealias
Host
IdAndMessageCountTuple
=
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
,
Host
TotalMsg
Tuple
<
Int
,
AtomicInteger
>>()
private
val
groupMap
=
HashMap
<
String
,
Host
IdAndMessageCount
Tuple
<
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
,
Host
TotalMsg
Tuple
(
size
+
1
,
AtomicInteger
(
0
)))
groupMap
.
put
(
host
,
Host
IdAndMessageCount
Tuple
(
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
=
Notification
Compat
.
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
=
Notification
Compat
.
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
<
Host
TotalMsg
Tuple
<
Room
,
User
>>
=
Single
.
zip
(
val
roomUserTuple
:
Single
<
Host
IdAndMessageCount
Tuple
<
Room
,
User
>>
=
Single
.
zip
(
singleRoom
,
singleRoom
,
singleUser
,
singleUser
,
BiFunction
{
room
,
user
->
Host
TotalMsg
Tuple
(
room
,
user
)
})
BiFunction
{
room
,
user
->
Host
IdAndMessageCount
Tuple
(
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
()))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment