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
39e719ce
Commit
39e719ce
authored
Oct 22, 2017
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename intent extra constants
parent
59e7f90f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
26 deletions
+30
-26
AbstractAuthedActivity.java
.../chat/rocket/android/activity/AbstractAuthedActivity.java
+6
-7
PushManager.kt
app/src/main/java/chat/rocket/android/push/PushManager.kt
+24
-19
No files found.
app/src/main/java/chat/rocket/android/activity/AbstractAuthedActivity.java
View file @
39e719ce
...
...
@@ -11,7 +11,6 @@ import java.util.List;
import
chat.rocket.android.LaunchUtil
;
import
chat.rocket.android.RocketChatCache
;
import
chat.rocket.android.helper.Logger
;
import
chat.rocket.android.push.PushConstants
;
import
chat.rocket.android.push.PushManager
;
import
chat.rocket.android.service.ConnectivityManager
;
import
chat.rocket.core.models.ServerInfo
;
...
...
@@ -57,16 +56,16 @@ abstract class AbstractAuthedActivity extends AbstractFragmentActivity {
return
;
}
if
(
intent
.
hasExtra
(
Push
Constants
.
HOSTNAME
))
{
String
hostname
=
intent
.
getStringExtra
(
Push
Constants
.
HOSTNAME
);
if
(
intent
.
hasExtra
(
Push
Manager
.
EXTRA_
HOSTNAME
))
{
String
hostname
=
intent
.
getStringExtra
(
Push
Manager
.
EXTRA_
HOSTNAME
);
HttpUrl
url
=
HttpUrl
.
parse
(
hostname
);
if
(
url
!=
null
)
{
String
hostnameFromPush
=
url
.
host
();
String
loginHostname
=
rocketChatCache
.
getSiteUrlFor
(
hostnameFromPush
);
rocketChatCache
.
setSelectedServerHostname
(
loginHostname
);
if
(
intent
.
hasExtra
(
Push
Constants
.
ROOM_ID
))
{
rocketChatCache
.
setSelectedRoomId
(
intent
.
getStringExtra
(
Push
Constants
.
ROOM_ID
));
if
(
intent
.
hasExtra
(
Push
Manager
.
EXTRA_
ROOM_ID
))
{
rocketChatCache
.
setSelectedRoomId
(
intent
.
getStringExtra
(
Push
Manager
.
EXTRA_
ROOM_ID
));
}
}
PushManager
.
INSTANCE
.
clearHostNotifications
(
hostname
);
...
...
@@ -74,9 +73,9 @@ abstract class AbstractAuthedActivity extends AbstractFragmentActivity {
updateHostnameIfNeeded
(
rocketChatCache
.
getSelectedServerHostname
());
}
if
(
intent
.
hasExtra
(
Push
Constants
.
NOT_ID
))
{
if
(
intent
.
hasExtra
(
Push
Manager
.
EXTRA_
NOT_ID
))
{
isNotification
=
true
;
int
notificationId
=
intent
.
getIntExtra
(
Push
Constants
.
NOT_ID
,
0
);
int
notificationId
=
intent
.
getIntExtra
(
Push
Manager
.
EXTRA_
NOT_ID
,
0
);
PushManager
.
INSTANCE
.
clearNotificationIdStack
(
notificationId
);
}
}
...
...
app/src/main/java/chat/rocket/android/push/PushManager.kt
View file @
39e719ce
...
...
@@ -43,8 +43,12 @@ typealias TupleRoomUser = Pair<Room, User>
typealias
TupleGroupIdMessageCount
=
Pair
<
Int
,
AtomicInteger
>
object
PushManager
{
const
val
REPLY_LABEL
=
"REPLY"
const
val
REMOTE_INPUT_REPLY
=
"REMOTE_INPUT_REPLY"
const
val
EXTRA_NOT_ID
=
"chat.rocket.android.EXTRA_NOT_ID"
const
val
EXTRA_HOSTNAME
=
"chat.rocket.android.EXTRA_HOSTNAME"
const
val
EXTRA_PUSH_MESSAGE
=
"chat.rocket.android.EXTRA_PUSH_MESSAGE"
const
val
EXTRA_ROOM_ID
=
"chat.rocket.android.EXTRA_ROOM_ID"
private
const
val
REPLY_LABEL
=
"REPLY"
private
const
val
REMOTE_INPUT_REPLY
=
"REMOTE_INPUT_REPLY"
// Map associating a notification id to a list of corresponding messages ie. an id corresponds
// to a user and the corresponding list is all the messages sent by him.
...
...
@@ -367,18 +371,18 @@ object PushManager {
private
fun
getDismissIntent
(
context
:
Context
,
pushMessage
:
PushMessage
):
PendingIntent
{
val
deleteIntent
=
Intent
(
context
,
DeleteReceiver
::
class
.
java
)
deleteIntent
.
putExtra
(
"notId"
,
pushMessage
.
notificationId
.
toInt
())
deleteIntent
.
putExtra
(
"host"
,
pushMessage
.
host
)
deleteIntent
.
putExtra
(
EXTRA_NOT_ID
,
pushMessage
.
notificationId
.
toInt
())
deleteIntent
.
putExtra
(
EXTRA_HOSTNAME
,
pushMessage
.
host
)
return
PendingIntent
.
getBroadcast
(
context
,
pushMessage
.
notificationId
.
toInt
(),
deleteIntent
,
PendingIntent
.
FLAG_UPDATE_CURRENT
)
}
private
fun
getContentIntent
(
context
:
Context
,
notificationId
:
Int
,
pushMessage
:
PushMessage
,
singleConversation
:
Boolean
=
true
):
PendingIntent
{
val
notificationIntent
=
Intent
(
context
,
MainActivity
::
class
.
java
)
notificationIntent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_SINGLE_TOP
or
Intent
.
FLAG_ACTIVITY_CLEAR_TOP
)
notificationIntent
.
putExtra
(
PushConstants
.
NOT_ID
,
notificationId
)
notificationIntent
.
putExtra
(
PushConstants
.
HOSTNAME
,
pushMessage
.
host
)
notificationIntent
.
putExtra
(
EXTRA_
NOT_ID
,
notificationId
)
notificationIntent
.
putExtra
(
EXTRA_
HOSTNAME
,
pushMessage
.
host
)
if
(
singleConversation
)
{
notificationIntent
.
putExtra
(
PushConstants
.
ROOM_ID
,
pushMessage
.
rid
)
notificationIntent
.
putExtra
(
EXTRA_
ROOM_ID
,
pushMessage
.
rid
)
}
return
PendingIntent
.
getActivity
(
context
,
randomizer
.
nextInt
(),
notificationIntent
,
PendingIntent
.
FLAG_UPDATE_CURRENT
)
}
...
...
@@ -429,7 +433,7 @@ object PushManager {
.
setLabel
(
REPLY_LABEL
)
.
build
()
val
replyIntent
=
Intent
(
context
,
ReplyReceiver
::
class
.
java
)
replyIntent
.
putExtra
(
"push"
,
pushMessage
as
Serializable
)
replyIntent
.
putExtra
(
EXTRA_PUSH_MESSAGE
,
pushMessage
as
Serializable
)
val
pendingIntent
=
PendingIntent
.
getBroadcast
(
context
,
randomizer
.
nextInt
(),
replyIntent
,
0
)
val
replyAction
=
...
...
@@ -457,14 +461,15 @@ object PushManager {
return
this
}
private
data class
PushMessage
(
val
title
:
String
,
val
message
:
String
,
val
image
:
String
?,
val
ejson
:
String
,
val
count
:
String
,
val
notificationId
:
String
,
val
summaryText
:
String
,
val
style
:
String
)
:
Serializable
{
private
data class
PushMessage
(
val
title
:
String
,
val
message
:
String
,
val
image
:
String
?,
val
ejson
:
String
,
val
count
:
String
,
val
notificationId
:
String
,
val
summaryText
:
String
,
val
style
:
String
)
:
Serializable
{
val
host
:
String
val
rid
:
String
val
type
:
String
...
...
@@ -501,8 +506,8 @@ object PushManager {
*/
class
DeleteReceiver
:
BroadcastReceiver
()
{
override
fun
onReceive
(
context
:
Context
?,
intent
:
Intent
?)
{
val
notificationId
=
intent
?.
extras
?.
getInt
(
"notId"
)
val
host
=
intent
?.
extras
?.
getString
(
"host"
)
val
notificationId
=
intent
?.
extras
?.
getInt
(
EXTRA_NOT_ID
)
val
host
=
intent
?.
extras
?.
getString
(
EXTRA_HOSTNAME
)
notificationId
?.
let
{
clearNotificationIdStack
(
notificationId
)
}
...
...
@@ -527,7 +532,7 @@ object PushManager {
synchronized
(
this
)
{
val
manager
=
context
.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
)
as
NotificationManager
val
message
:
CharSequence
?
=
extractMessage
(
intent
)
val
pushMessage
=
intent
?.
extras
?.
getSerializable
(
"push"
)
as
PushMessage
?
val
pushMessage
=
intent
?.
extras
?.
getSerializable
(
EXTRA_PUSH_MESSAGE
)
as
PushMessage
?
pushMessage
?.
let
{
val
userNotId
=
pushMessage
.
notificationId
.
toInt
()
...
...
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