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
ff46d5b3
Unverified
Commit
ff46d5b3
authored
May 22, 2018
by
Filipe de Lima Brito
Committed by
GitHub
May 22, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1297 from RocketChat/fix/test-notifications-not-showing
[FIX] Test notifications not showing
parents
744cdeb2
cf48262f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
114 additions
and
83 deletions
+114
-83
MessageViewHolder.kt
...chat/rocket/android/chatroom/adapter/MessageViewHolder.kt
+1
-1
PushManager.kt
app/src/main/java/chat/rocket/android/push/PushManager.kt
+112
-82
gradle-wrapper.properties
gradle/wrapper/gradle-wrapper.properties
+1
-0
No files found.
app/src/main/java/chat/rocket/android/chatroom/adapter/MessageViewHolder.kt
View file @
ff46d5b3
...
...
@@ -37,7 +37,7 @@ class MessageViewHolder(
if
(
data
.
isTemporary
)
Color
.
GRAY
else
Color
.
BLACK
)
data
.
message
.
let
{
text_edit_indicator
.
isVisible
=
it
.
isSystemMessage
()
&&
it
.
editedBy
!=
null
text_edit_indicator
.
isVisible
=
!
it
.
isSystemMessage
()
&&
it
.
editedBy
!=
null
image_star_indicator
.
isVisible
=
it
.
starred
?.
isNotEmpty
()
?:
false
}
}
...
...
app/src/main/java/chat/rocket/android/push/PushManager.kt
View file @
ff46d5b3
...
...
@@ -26,6 +26,7 @@ import chat.rocket.android.server.domain.siteName
import
chat.rocket.android.server.ui.changeServerIntent
import
chat.rocket.common.model.RoomType
import
chat.rocket.common.model.roomTypeOf
import
chat.rocket.common.util.ifNull
import
com.squareup.moshi.Json
import
com.squareup.moshi.Moshi
import
kotlinx.coroutines.experimental.runBlocking
...
...
@@ -48,7 +49,8 @@ class PushManager @Inject constructor(
private
val
getSettingsInteractor
:
GetSettingsInteractor
,
private
val
context
:
Context
)
{
private
val
randomizer
=
Random
()
private
val
random
=
Random
()
/**
* Handles a receiving push by creating and displaying an appropriate notification based
...
...
@@ -59,7 +61,7 @@ class PushManager @Inject constructor(
val
message
=
data
[
"message"
]
as
String
?
val
ejson
=
data
[
"ejson"
]
as
String
?
val
title
=
data
[
"title"
]
as
String
?
val
notId
=
data
[
"notId"
]
as
String
?
?:
random
izer
.
nextInt
().
toString
()
val
notId
=
data
[
"notId"
]
as
String
?
?:
random
.
nextInt
().
toString
()
val
image
=
data
[
"image"
]
as
String
?
val
style
=
data
[
"style"
]
as
String
?
val
summaryText
=
data
[
"summaryText"
]
as
String
?
...
...
@@ -67,9 +69,13 @@ class PushManager @Inject constructor(
try
{
val
adapter
=
moshi
.
adapter
<
PushInfo
>(
PushInfo
::
class
.
java
)
val
info
=
adapter
.
fromJson
(
ejson
)
val
pushMessage
=
PushMessage
(
title
!!
,
message
!!
,
info
!!
,
image
,
count
,
notId
,
summaryText
,
style
)
val
pushMessage
=
if
(
ejson
!=
null
)
{
val
info
=
adapter
.
fromJson
(
ejson
)
PushMessage
(
title
!!
,
message
!!
,
info
!!
,
image
,
count
,
notId
,
summaryText
,
style
)
}
else
{
PushMessage
(
title
!!
,
message
!!
,
PushInfo
.
EMPTY
,
image
,
count
,
notId
,
summaryText
,
style
)
}
Timber
.
d
(
"Received push message: $pushMessage"
)
...
...
@@ -82,13 +88,17 @@ class PushManager @Inject constructor(
@SuppressLint
(
"NewApi"
)
suspend
fun
showNotification
(
pushMessage
:
PushMessage
)
{
if
(!
hasAccount
(
pushMessage
.
info
.
host
))
{
Timber
.
d
(
"ignoring push message: $pushMessage"
)
val
notId
=
pushMessage
.
notificationId
.
toInt
()
val
host
=
pushMessage
.
info
.
host
if
(!
hasAccount
(
host
))
{
createSingleNotification
(
pushMessage
)
?.
let
{
NotificationManagerCompat
.
from
(
context
).
notify
(
notId
,
it
)
}
Timber
.
d
(
"ignoring push message: $pushMessage (maybe a test notification?)"
)
return
}
val
notId
=
pushMessage
.
notificationId
.
toInt
()
val
host
=
pushMessage
.
info
.
host
val
groupTuple
=
getGroupForHost
(
host
)
groupTuple
.
second
.
incrementAndGet
()
...
...
@@ -103,7 +113,7 @@ class PushManager @Inject constructor(
val
pushMessageList
=
groupedPushes
.
hostToPushMessageList
[
host
]
notification
?.
let
{
manager
.
notify
(
notId
,
notification
)
manager
.
notify
(
notId
,
it
)
}
pushMessageList
?.
let
{
...
...
@@ -182,7 +192,7 @@ class PushManager @Inject constructor(
if
(
style
==
null
||
"inbox"
==
style
)
{
val
pushMessageList
=
groupedPushes
.
hostToPushMessageList
.
get
(
host
)
pushMessageList
?.
let
{
if
(
pushMessageList
!=
null
)
{
val
userMessages
=
pushMessageList
.
filter
{
it
.
notificationId
==
pushMessage
.
notificationId
}
...
...
@@ -206,6 +216,12 @@ class PushManager @Inject constructor(
.
bigText
(
message
.
fromHtml
())
builder
.
setStyle
(
bigTextStyle
)
}
}
else
{
// We don't know which kind of push is this - maybe a test push, so just show it
val
bigTextStyle
=
NotificationCompat
.
BigTextStyle
()
.
bigText
(
message
.
fromHtml
())
builder
.
setStyle
(
bigTextStyle
)
return
builder
.
build
()
}
}
else
{
val
bigTextStyle
=
NotificationCompat
.
BigTextStyle
()
...
...
@@ -213,8 +229,7 @@ class PushManager @Inject constructor(
builder
.
setStyle
(
bigTextStyle
)
}
return
builder
.
addReplyAction
(
pushMessage
)
.
build
()
return
builder
.
addReplyAction
(
pushMessage
).
build
()
}
}
...
...
@@ -236,12 +251,23 @@ class PushManager @Inject constructor(
.
setMessageNotification
()
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
val
channel
=
NotificationChannel
(
host
,
host
,
NotificationManager
.
IMPORTANCE_HIGH
)
val
channelId
:
String
val
channelName
:
String
if
(
host
.
isEmpty
())
{
builder
.
setContentIntent
(
deleteIntent
)
channelName
=
"Test Notification"
channelId
=
"test-channel"
}
else
{
channelName
=
host
channelId
=
host
}
val
channel
=
NotificationChannel
(
channelId
,
channelName
,
NotificationManager
.
IMPORTANCE_HIGH
)
channel
.
lockscreenVisibility
=
Notification
.
VISIBILITY_PUBLIC
channel
.
enableLights
(
false
)
channel
.
enableVibration
(
true
)
channel
.
setShowBadge
(
true
)
manager
.
createNotificationChannel
(
channel
)
builder
.
setChannelId
(
channelId
)
}
//TODO: Get Site_Name PublicSetting from cache
...
...
@@ -276,7 +302,7 @@ class PushManager @Inject constructor(
/*if (!grouped) {
notificationIntent.putExtra(EXTRA_ROOM_ID, pushMessage.info.roomId)
}*/
return
PendingIntent
.
getActivity
(
context
,
random
izer
.
nextInt
(),
notificationIntent
,
PendingIntent
.
FLAG_UPDATE_CURRENT
)
return
PendingIntent
.
getActivity
(
context
,
random
.
nextInt
(),
notificationIntent
,
PendingIntent
.
FLAG_UPDATE_CURRENT
)
}
// CharSequence extensions
...
...
@@ -318,14 +344,14 @@ class PushManager @Inject constructor(
return
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
N
)
{
PendingIntent
.
getBroadcast
(
context
,
randomizer
.
nextInt
(),
random
.
nextInt
(),
replyIntent
,
PendingIntent
.
FLAG_UPDATE_CURRENT
)
}
else
{
PendingIntent
.
getActivity
(
context
,
randomizer
.
nextInt
(),
random
.
nextInt
(),
replyIntent
,
PendingIntent
.
FLAG_UPDATE_CURRENT
)
...
...
@@ -359,6 +385,7 @@ data class PushMessage(
val
summaryText
:
String
?
=
null
,
val
style
:
String
?
=
null
)
:
Parcelable
{
constructor
(
parcel
:
Parcel
)
:
this
(
parcel
.
readString
(),
parcel
.
readString
(),
...
...
@@ -438,6 +465,9 @@ data class PushInfo @KotshiConstructor constructor(
}
companion
object
CREATOR
:
Parcelable
.
Creator
<
PushInfo
>
{
val
EMPTY
=
PushInfo
(
hostname
=
""
,
roomId
=
""
,
type
=
RoomType
.
CHANNEL
,
name
=
""
,
sender
=
null
)
override
fun
createFromParcel
(
parcel
:
Parcel
):
PushInfo
{
return
PushInfo
(
parcel
)
}
...
...
gradle/wrapper/gradle-wrapper.properties
View file @
ff46d5b3
...
...
@@ -4,3 +4,4 @@ distributionPath=wrapper/dists
zipStoreBase
=
GRADLE_USER_HOME
zipStorePath
=
wrapper/dists
distributionUrl
=
https
\:
//services.gradle.org/distributions/gradle-4.6-all.zip
distributionSha256Sum
=
9af7345c199f1731c187c96d3fe3d31f5405192a42046bafa71d846c3d9adacb
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