Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
abook_check
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abook_android
abook_check
Commits
a94c84ce
Commit
a94c84ce
authored
Aug 05, 2021
by
Kim Peace
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed not to display push notification for same chat room
parent
25eadc52
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
125 additions
and
84 deletions
+125
-84
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/push/ABVFcmListenerService.java
+122
-84
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/home/activity/ChatWebViewActivity.java
+3
-0
No files found.
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/push/ABVFcmListenerService.java
View file @
a94c84ce
package
jp
.
agentec
.
abook
.
abv
.
cl
.
push
;
import
android.app.Activity
;
import
android.app.Notification
;
import
android.app.NotificationChannel
;
import
android.app.NotificationManager
;
...
...
@@ -11,6 +12,7 @@ import android.util.Log;
import
com.google.firebase.messaging.FirebaseMessagingService
;
import
com.google.firebase.messaging.RemoteMessage
;
import
org.json.adf.JSONException
;
import
org.json.adf.JSONObject
;
import
java.util.Map
;
...
...
@@ -25,10 +27,11 @@ import jp.agentec.abook.abv.cl.util.AppUtil;
import
jp.agentec.abook.abv.launcher.android.R
;
import
jp.agentec.abook.abv.ui.common.activity.ShowPushMessageDailogActivity
;
import
jp.agentec.abook.abv.ui.common.appinfo.AppDefType
;
import
jp.agentec.abook.abv.ui.home.activity.ChatWebViewActivity
;
import
jp.agentec.abook.abv.ui.home.activity.SplashScreenActivity
;
import
jp.agentec.abook.abv.ui.home.helper.ActivityHandlingHelper
;
import
jp.agentec.adf.util.StringUtil
;
public
class
ABVFcmListenerService
extends
FirebaseMessagingService
{
private
static
final
String
TAG
=
"ABVFcmListenerService"
;
private
NotificationManager
mNotificationManager
;
...
...
@@ -58,79 +61,59 @@ public class ABVFcmListenerService extends FirebaseMessagingService {
try
{
UserAuthenticateLogic
logic
=
AbstractLogic
.
getLogic
(
UserAuthenticateLogic
.
class
);
MemberInfoDto
memberInfo
=
logic
.
getMemberInfo
();
if
(!
StringUtil
.
isNullOrWhiteSpace
(
msg
.
get
(
AppDefType
.
PushMessageKey
.
message
))
&&
this
.
getResources
().
getInteger
(
R
.
integer
.
push_message
)
==
1
&&
memberInfo
!=
null
)
{
boolean
hasMessageBody
=
!
StringUtil
.
isNullOrWhiteSpace
(
msg
.
get
(
AppDefType
.
PushMessageKey
.
message
));
boolean
isPushMessageEnabled
=
this
.
getResources
().
getInteger
(
R
.
integer
.
push_message
)
==
1
;
if
(
hasMessageBody
&&
isPushMessageEnabled
&&
memberInfo
!=
null
)
{
// Check pushmessage by chat
String
tempMsg
=
msg
.
get
(
AppDefType
.
PushMessageKey
.
message
);
String
pushMsg
;
Long
roomId
=
null
;
String
roomName
=
""
;
String
pushSendLoginId
=
""
;
long
pushSendDate
=
0
;
Integer
insertId
=
0
;
Integer
messageType
=
0
;
Integer
messageId
=
0
;
String
roomType
;
Log
.
d
(
TAG
,
"tempMsg : "
+
tempMsg
);
if
(
Objects
.
requireNonNull
(
tempMsg
).
indexOf
(
AppDefType
.
ChatPushMessageKey
.
pushSendLoginId
)
>
0
)
{
JSONObject
json
=
new
JSONObject
(
tempMsg
);
Object
Obj
=
json
.
getString
(
AppDefType
.
ChatPushMessageKey
.
pushSendLoginId
);
roomId
=
json
.
getLong
(
AppDefType
.
ChatPushMessageKey
.
roomId
);
roomName
=
json
.
getString
(
AppDefType
.
ChatPushMessageKey
.
roomName
);
pushSendLoginId
=
json
.
getString
(
AppDefType
.
ChatPushMessageKey
.
pushSendLoginId
);
pushSendDate
=
json
.
getLong
(
AppDefType
.
ChatPushMessageKey
.
pushSendDate
);
pushMsg
=
json
.
getString
(
AppDefType
.
PushMessageKey
.
message
);
String
textMessage
=
json
.
getString
(
AppDefType
.
PushMessageKey
.
message
);
//TODO pushメッセージが到着した際、新着メッセージかルーム招待か判別してDB格納が必要
//Integer insertId = 0;
//Integer messageType = 0;
//insertId = json.getString("insertId");
//ChatMessageDto chatMessageDto = new ChatMessageDto();
//chatMessageDto.chatRoomId =
//chatRoomId shopMemberId messge messageType insertDate
if
(
pushMsg
.
length
()
>
0
)
{
tempMsg
=
pushMsg
;
if
(
textMessage
.
length
()
>
0
)
{
tempMsg
=
textMessage
;
}
if
(
AppUtil
.
isAppForground
(
this
))
{
msg
.
put
(
AppDefType
.
PushMessageKey
.
message
,
pushMsg
);
msg
.
put
(
AppDefType
.
PushMessageKey
.
message
,
textMessage
);
}
if
(
pushMsg
.
contains
(
INVITE_COLLABORATION
))
{
roomType
=
Integer
.
toString
(
json
.
getInt
(
AppDefType
.
ChatPushMessageKey
.
roomType
));
String
[]
inviteMessage
=
pushMsg
.
split
(
CHAT_MESSAGE_SEPERATOR
);
tempMsg
=
getString
(
R
.
string
.
msg_invite_collaboration
);
Intent
pushMsgDialog
=
new
Intent
(
ABVFcmListenerService
.
this
,
ShowPushMessageDailogActivity
.
class
);
pushMsgDialog
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
pushMsgDialog
.
putExtra
(
AppDefType
.
PushMessageKey
.
message
,
tempMsg
);
pushMsgDialog
.
putExtra
(
AppDefType
.
ChatPushMessageKey
.
roomId
,
roomId
);
// Room Id
pushMsgDialog
.
putExtra
(
AppDefType
.
ChatPushMessageKey
.
roomName
,
roomName
);
// Room Name
pushMsgDialog
.
putExtra
(
AppDefType
.
ChatPushMessageKey
.
pushSendLoginId
,
pushSendLoginId
);
// sendLoginId
pushMsgDialog
.
putExtra
(
AppDefType
.
ChatPushMessageKey
.
pushSendDate
,
pushSendDate
);
pushMsgDialog
.
putExtra
(
AppDefType
.
ChatPushMessageKey
.
collaborationType
,
inviteMessage
[
1
]);
pushMsgDialog
.
putExtra
(
AppDefType
.
ChatPushMessageKey
.
roomType
,
roomType
);
startActivity
(
pushMsgDialog
);
if
(
textMessage
.
contains
(
INVITE_COLLABORATION
))
{
String
roomType
=
Integer
.
toString
(
json
.
getInt
(
AppDefType
.
ChatPushMessageKey
.
roomType
));
String
[]
inviteMessage
=
textMessage
.
split
(
CHAT_MESSAGE_SEPERATOR
);
showCollaborationPopUpMessage
(
roomId
,
roomName
,
roomType
,
pushSendLoginId
,
pushSendDate
,
inviteMessage
[
1
]);
return
;
}
}
if
(
AppUtil
.
isAppForground
(
this
))
{
Intent
pushMsgDialog
=
new
Intent
(
ABVFcmListenerService
.
this
,
ShowPushMessageDailogActivity
.
class
);
pushMsgDialog
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
pushMsgDialog
.
putExtra
(
AppDefType
.
PushMessageKey
.
message
,
tempMsg
);
pushMsgDialog
.
putExtra
(
AppDefType
.
PushMessageKey
.
data
,
msg
.
get
(
AppDefType
.
PushMessageKey
.
data
));
pushMsgDialog
.
putExtra
(
AppDefType
.
PushMessageKey
.
operationId
,
msg
.
get
(
AppDefType
.
PushMessageKey
.
operationId
));
// push message
String
data
=
msg
.
get
(
AppDefType
.
PushMessageKey
.
data
);
String
operationID
=
msg
.
get
(
AppDefType
.
PushMessageKey
.
operationId
);
if
(
roomName
.
length
()
>
0
)
{
pushMsgDialog
.
putExtra
(
AppDefType
.
ChatPushMessageKey
.
roomId
,
roomId
);
// Room Id
pushMsgDialog
.
putExtra
(
AppDefType
.
ChatPushMessageKey
.
roomName
,
roomName
);
// Room Name
pushMsgDialog
.
putExtra
(
AppDefType
.
ChatPushMessageKey
.
pushSendLoginId
,
pushSendLoginId
);
// sendLoginId
pushMsgDialog
.
putExtra
(
AppDefType
.
ChatPushMessageKey
.
pushSendDate
,
pushSendDate
);
showChatRoomPopupMessage
(
tempMsg
,
data
,
operationID
,
roomId
,
roomName
,
pushSendLoginId
,
pushSendDate
);
}
else
{
showOperationPopUpMessage
(
tempMsg
,
data
,
operationID
);
}
startActivity
(
pushMsgDialog
);
}
else
{
sendNotification
(
msg
);
}
...
...
@@ -138,60 +121,73 @@ public class ABVFcmListenerService extends FirebaseMessagingService {
}
catch
(
ABVException
e
)
{
// ignore
Logger
.
e
(
TAG
,
e
.
toString
());
}
catch
(
JSONException
e
)
{
Logger
.
e
(
TAG
,
e
.
toString
());
}
}
private
void
sendNotification
(
Map
<
String
,
String
>
message
)
{
Intent
intent
=
new
Intent
();
// 定期点検用
if
(
message
.
get
(
AppDefType
.
PushMessageKey
.
operationId
)
!=
null
)
{
intent
.
putExtra
(
AppDefType
.
PushMessageKey
.
operationId
,
message
.
get
(
AppDefType
.
PushMessageKey
.
operationId
));
intent
.
putExtra
(
AppDefType
.
PushMessageKey
.
message
,
message
.
get
(
AppDefType
.
PushMessageKey
.
message
));
}
else
{
// Check pushmessage by chat
try
{
// チャットプッシュメッセージがある場合
UserAuthenticateLogic
logic
=
AbstractLogic
.
getLogic
(
UserAuthenticateLogic
.
class
);
MemberInfoDto
memberInfo
=
logic
.
getMemberInfo
();
if
(!
StringUtil
.
isNullOrWhiteSpace
(
message
.
get
(
AppDefType
.
PushMessageKey
.
message
)))
{
String
tempMsg
=
message
.
get
(
AppDefType
.
PushMessageKey
.
message
);
String
pushMsg
=
""
;
Long
roomId
=
null
;
String
roomName
=
""
;
String
pushSendLoginId
=
""
;
long
pushSendDate
=
0
;
Log
.
d
(
TAG
,
"tempMsg : "
+
tempMsg
);
if
(
Objects
.
requireNonNull
(
tempMsg
).
indexOf
(
AppDefType
.
ChatPushMessageKey
.
pushSendLoginId
)
>
0
)
{
JSONObject
json
=
new
JSONObject
(
tempMsg
);
Object
Obj
=
json
.
getString
(
AppDefType
.
ChatPushMessageKey
.
pushSendLoginId
);
roomId
=
json
.
getLong
(
AppDefType
.
ChatPushMessageKey
.
roomId
);
roomName
=
json
.
getString
(
AppDefType
.
ChatPushMessageKey
.
roomName
);
pushSendLoginId
=
json
.
getString
(
AppDefType
.
ChatPushMessageKey
.
pushSendLoginId
);
pushSendDate
=
json
.
getLong
(
AppDefType
.
ChatPushMessageKey
.
pushSendDate
);
pushMsg
=
json
.
getString
(
AppDefType
.
PushMessageKey
.
message
);
message
.
put
(
AppDefType
.
PushMessageKey
.
message
,
pushMsg
);
private
void
showCollaborationPopUpMessage
(
Long
roomId
,
String
roomName
,
String
roomType
,
String
pushSendLoginId
,
long
pushSendDate
,
String
collaborationType
)
{
Intent
pushMsgDialog
=
new
Intent
(
ABVFcmListenerService
.
this
,
ShowPushMessageDailogActivity
.
class
);
String
collaobrationInvitedMessage
=
getString
(
R
.
string
.
msg_invite_collaboration
);
// push message
if
(
roomName
.
length
()
>
0
)
{
intent
.
putExtra
(
AppDefType
.
ChatPushMessageKey
.
roomId
,
roomId
);
// Room Id
intent
.
putExtra
(
AppDefType
.
ChatPushMessageKey
.
roomName
,
roomName
);
// Room Name
intent
.
putExtra
(
AppDefType
.
ChatPushMessageKey
.
pushSendLoginId
,
pushSendLoginId
);
// sendLoginId
intent
.
putExtra
(
AppDefType
.
ChatPushMessageKey
.
pushSendDate
,
pushSendDate
);
pushMsgDialog
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
pushMsgDialog
.
putExtra
(
AppDefType
.
PushMessageKey
.
message
,
collaobrationInvitedMessage
);
pushMsgDialog
.
putExtra
(
AppDefType
.
ChatPushMessageKey
.
roomId
,
roomId
);
pushMsgDialog
.
putExtra
(
AppDefType
.
ChatPushMessageKey
.
roomName
,
roomName
);
pushMsgDialog
.
putExtra
(
AppDefType
.
ChatPushMessageKey
.
pushSendLoginId
,
pushSendLoginId
);
pushMsgDialog
.
putExtra
(
AppDefType
.
ChatPushMessageKey
.
pushSendDate
,
pushSendDate
);
pushMsgDialog
.
putExtra
(
AppDefType
.
ChatPushMessageKey
.
collaborationType
,
collaborationType
);
pushMsgDialog
.
putExtra
(
AppDefType
.
ChatPushMessageKey
.
roomType
,
roomType
);
startActivity
(
pushMsgDialog
);
}
private
void
showChatRoomPopupMessage
(
String
textMessage
,
String
data
,
String
operationID
,
Long
roomID
,
String
roomName
,
String
pushSendLoginId
,
long
pushSendDate
)
{
Activity
currentActivity
=
ActivityHandlingHelper
.
getInstance
().
getCurrentActivity
();
if
(
currentActivity
.
getClass
().
equals
(
ChatWebViewActivity
.
class
))
{
ChatWebViewActivity
chatWebViewActivity
=
(
ChatWebViewActivity
)
currentActivity
;
if
(
chatWebViewActivity
.
getRoomID
().
equals
(
roomID
))
{
// push messageと同じ部屋にいる場合はpushmessageを送信しない。
return
;
}
}
}
catch
(
ABVException
e
)
{
// ignore
Logger
.
e
(
TAG
,
e
.
toString
());
Intent
pushMsgDialog
=
new
Intent
(
ABVFcmListenerService
.
this
,
ShowPushMessageDailogActivity
.
class
);
pushMsgDialog
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
pushMsgDialog
.
putExtra
(
AppDefType
.
PushMessageKey
.
message
,
textMessage
);
pushMsgDialog
.
putExtra
(
AppDefType
.
PushMessageKey
.
data
,
data
);
pushMsgDialog
.
putExtra
(
AppDefType
.
PushMessageKey
.
operationId
,
operationID
);
pushMsgDialog
.
putExtra
(
AppDefType
.
ChatPushMessageKey
.
roomId
,
roomID
);
pushMsgDialog
.
putExtra
(
AppDefType
.
ChatPushMessageKey
.
roomName
,
roomName
);
pushMsgDialog
.
putExtra
(
AppDefType
.
ChatPushMessageKey
.
pushSendLoginId
,
pushSendLoginId
);
pushMsgDialog
.
putExtra
(
AppDefType
.
ChatPushMessageKey
.
pushSendDate
,
pushSendDate
);
startActivity
(
pushMsgDialog
);
}
private
void
showOperationPopUpMessage
(
String
textMessage
,
String
data
,
String
operationID
)
{
Intent
pushMsgDialog
=
new
Intent
(
ABVFcmListenerService
.
this
,
ShowPushMessageDailogActivity
.
class
);
pushMsgDialog
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
pushMsgDialog
.
putExtra
(
AppDefType
.
PushMessageKey
.
message
,
textMessage
);
pushMsgDialog
.
putExtra
(
AppDefType
.
PushMessageKey
.
data
,
data
);
pushMsgDialog
.
putExtra
(
AppDefType
.
PushMessageKey
.
operationId
,
operationID
);
startActivity
(
pushMsgDialog
);
}
intent
.
setClassName
(
getApplicationContext
(),
SplashScreenActivity
.
class
.
getName
());
private
void
sendNotification
(
Map
<
String
,
String
>
message
)
{
Intent
intent
=
instantiatePushNotificationIntent
(
message
);
Notification
notification
;
...
...
@@ -230,6 +226,48 @@ public class ABVFcmListenerService extends FirebaseMessagingService {
}
}
Intent
instantiatePushNotificationIntent
(
Map
<
String
,
String
>
message
)
{
Intent
intent
=
new
Intent
();
intent
.
setClassName
(
getApplicationContext
(),
SplashScreenActivity
.
class
.
getName
());
// 定期点検用
if
(
message
.
get
(
AppDefType
.
PushMessageKey
.
operationId
)
!=
null
)
{
intent
.
putExtra
(
AppDefType
.
PushMessageKey
.
operationId
,
message
.
get
(
AppDefType
.
PushMessageKey
.
operationId
));
intent
.
putExtra
(
AppDefType
.
PushMessageKey
.
message
,
message
.
get
(
AppDefType
.
PushMessageKey
.
message
));
return
intent
;
}
// Check pushmessage by chat
// チャットプッシュメッセージがある場合
if
(
StringUtil
.
isNullOrWhiteSpace
(
message
.
get
(
AppDefType
.
PushMessageKey
.
message
)))
{
return
intent
;
}
String
tempMsg
=
message
.
get
(
AppDefType
.
PushMessageKey
.
message
);
Log
.
d
(
TAG
,
"tempMsg : "
+
tempMsg
);
if
(
Objects
.
requireNonNull
(
tempMsg
).
indexOf
(
AppDefType
.
ChatPushMessageKey
.
pushSendLoginId
)
<=
0
)
{
return
intent
;
}
JSONObject
json
=
new
JSONObject
(
tempMsg
);
String
roomName
=
json
.
getString
(
AppDefType
.
ChatPushMessageKey
.
roomName
);
String
pushMsg
=
json
.
getString
(
AppDefType
.
PushMessageKey
.
message
);
message
.
put
(
AppDefType
.
PushMessageKey
.
message
,
pushMsg
);
if
(
roomName
.
length
()
<=
0
)
{
return
intent
;
}
long
roomId
=
json
.
getLong
(
AppDefType
.
ChatPushMessageKey
.
roomId
);
long
pushSendDate
=
json
.
getLong
(
AppDefType
.
ChatPushMessageKey
.
pushSendDate
);
String
pushSendLoginId
=
json
.
getString
(
AppDefType
.
ChatPushMessageKey
.
pushSendLoginId
);
intent
.
putExtra
(
AppDefType
.
ChatPushMessageKey
.
roomId
,
roomId
);
intent
.
putExtra
(
AppDefType
.
ChatPushMessageKey
.
roomName
,
roomName
);
intent
.
putExtra
(
AppDefType
.
ChatPushMessageKey
.
pushSendLoginId
,
pushSendLoginId
);
intent
.
putExtra
(
AppDefType
.
ChatPushMessageKey
.
pushSendDate
,
pushSendDate
);
return
intent
;
}
private
Notification
.
Builder
getNotificationBuilder
(
PendingIntent
pendingIntent
,
Map
<
String
,
String
>
message
)
{
return
new
Notification
.
Builder
(
this
)
.
setDefaults
(
Notification
.
DEFAULT_ALL
)
...
...
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/home/activity/ChatWebViewActivity.java
View file @
a94c84ce
...
...
@@ -124,6 +124,9 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity implements
private
boolean
needHostAlert
=
false
;
public
Long
getRoomID
()
{
return
chatData
.
roomId
;
}
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
...
...
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