Commit adb49f48 by onuma

Merge branch 'communication/develop_onuma' into 'communication/develop'

バックグラウンドでプッシュメッセージ受信時の動作をiOSと同じにした。

See merge request !202
parents 9c9c14d1 8f8d1e29
......@@ -59,6 +59,10 @@ public class ABVFcmListenerService extends FirebaseMessagingService {
}
}
/**
* プッシュメッセージ受信時処理
* @param remoteMessage プッシュメッセージ
*/
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Map<String, String> msg = remoteMessage.getData();
......@@ -76,6 +80,8 @@ public class ABVFcmListenerService extends FirebaseMessagingService {
String roomName = "";
String pushSendLoginId = "";
long pushSendDate = 0;
String textMessage = "";
String strRoomType = "";
Log.d(TAG,"tempMsg : "+ tempMsg);
......@@ -86,8 +92,8 @@ public class ABVFcmListenerService extends FirebaseMessagingService {
roomName = json.getString(AppDefType.ChatPushMessageKey.roomName);
pushSendLoginId = json.getString(AppDefType.ChatPushMessageKey.pushSendLoginId);
pushSendDate = json.getLong(AppDefType.ChatPushMessageKey.pushSendDate);
String textMessage = json.getString(AppDefType.PushMessageKey.message);
textMessage = json.getString(AppDefType.PushMessageKey.message);
strRoomType = Integer.toString(json.getInt(AppDefType.ChatPushMessageKey.roomType));
//TODO pushメッセージが到着した際、新着メッセージかルーム招待か判別してDB格納が必要
//Integer insertId = 0;
//Integer messageType = 0;
......@@ -99,30 +105,26 @@ public class ABVFcmListenerService extends FirebaseMessagingService {
if (textMessage.length() > 0) {
tempMsg = textMessage;
}
}
if (AppUtil.isAppForground(this)) {
msg.put(AppDefType.PushMessageKey.message, textMessage);
}
if (AppUtil.isAppForground(this)) {
String data = msg.get(AppDefType.PushMessageKey.data);
String operationID = msg.get(AppDefType.PushMessageKey.operationId);
msg.put(AppDefType.PushMessageKey.message, textMessage);
if (textMessage.contains(INVITE_COLLABORATION)) {
String roomType = Integer.toString(json.getInt(AppDefType.ChatPushMessageKey.roomType));
// 協業に招待された場合
String[] inviteMessage = textMessage.split(CHAT_MESSAGE_SEPERATOR);
showChatRoomPopupMessage(getString(R.string.msg_invite_collaboration),
"",
"",
roomId,
roomName,
roomType,
strRoomType,
pushSendLoginId,
pushSendDate,
inviteMessage[1]);
return;
}
}
if (AppUtil.isAppForground(this)) {
String data = msg.get(AppDefType.PushMessageKey.data);
String operationID = msg.get(AppDefType.PushMessageKey.operationId);
if (roomName.length() > 0) {
showChatRoomPopupMessage(tempMsg,
data,
......@@ -137,6 +139,7 @@ public class ABVFcmListenerService extends FirebaseMessagingService {
showOperationPopUpMessage(tempMsg, data, operationID);
}
} else {
// 通知用Intent作成(アプリがバックグラウンド時用)
sendNotification(msg);
}
}
......@@ -310,17 +313,20 @@ public class ABVFcmListenerService extends FirebaseMessagingService {
String pushMsg = json.getString(AppDefType.PushMessageKey.message);
message.put(AppDefType.PushMessageKey.message, pushMsg);
if (roomName.length() <= 0) { return intent; }
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);
String strRoomType = Integer.toString(json.getInt(AppDefType.ChatPushMessageKey.roomType));
intent.putExtra(AppDefType.ChatPushMessageKey.roomId, roomId);
intent.putExtra(AppDefType.ChatPushMessageKey.roomName, roomName);
intent.putExtra(AppDefType.ChatPushMessageKey.pushSendLoginId, pushSendLoginId);
intent.putExtra(AppDefType.ChatPushMessageKey.pushSendDate, pushSendDate);
intent.putExtra(AppDefType.ChatPushMessageKey.roomType, strRoomType);
return intent;
}
......
......@@ -1296,7 +1296,7 @@ public abstract class ABVAuthenticatedActivity extends ABVActivity implements Co
return;
}
if (StringUtil.isNullOrEmpty(collaborationType)) {
ActivityHandlingHelper.getInstance().startChatWebViewActivity(fromClassName, roomId, roomName);
ActivityHandlingHelper.getInstance().startChatWebViewActivity(fromClassName, roomId, roomName, roomType);
} else {
ActivityHandlingHelper.getInstance().startChatWebViewActivityWithCollaboration(fromClassName, roomId, roomName, collaborationType, roomType);
}
......
......@@ -390,7 +390,8 @@ public abstract class ABVNoAuthenticatedActivity extends ABVActivity {
intent.putExtra(AppDefType.ChatPushMessageKey.roomId, extras.getLong(AppDefType.ChatPushMessageKey.roomId)); // Room Id
intent.putExtra(AppDefType.ChatPushMessageKey.roomName, extras.getString(AppDefType.ChatPushMessageKey.roomName)); // Room Name
intent.putExtra(AppDefType.ChatPushMessageKey.pushSendLoginId, extras.getString(AppDefType.ChatPushMessageKey.pushSendLoginId)); // sendLoginId
intent.putExtra(AppDefType.ChatPushMessageKey.pushSendDate, extras.getString(AppDefType.ChatPushMessageKey.pushSendDate));
intent.putExtra(AppDefType.ChatPushMessageKey.pushSendDate, extras.getLong(AppDefType.ChatPushMessageKey.pushSendDate));
intent.putExtra(AppDefType.ChatPushMessageKey.roomType, extras.getString(AppDefType.ChatPushMessageKey.roomType));
}
}
intent.setClassName(getApplicationContext().getPackageName(), getMainActivityClassName()).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
......
......@@ -146,5 +146,7 @@ public interface AppDefType {
String collaborationType = "collaborationType";
String roomType = "roomType";
String fromClassName = "fromClassName";
String shopName = "shopName";
String loginId = "loginId";
}
}
......@@ -514,7 +514,8 @@ public class OperationListActivity extends ABVUIActivity {
public void run() {
ActivityHandlingHelper.getInstance().startChatWebViewActivity("",
getIntent().getLongExtra(AppDefType.ChatPushMessageKey.roomId, '0'),
getIntent().getStringExtra(AppDefType.ChatPushMessageKey.roomName));
getIntent().getStringExtra(AppDefType.ChatPushMessageKey.roomName),
getIntent().getStringExtra(AppDefType.ChatPushMessageKey.roomType));
}
},1000);
return;
......
......@@ -551,7 +551,8 @@ public class OperationRelatedContentActivity extends ABVUIActivity {
public void run() {
ActivityHandlingHelper.getInstance().startChatWebViewActivity("",
getIntent().getLongExtra(AppDefType.ChatPushMessageKey.roomId, '0'),
getIntent().getStringExtra(AppDefType.ChatPushMessageKey.roomName));
getIntent().getStringExtra(AppDefType.ChatPushMessageKey.roomName),
getIntent().getStringExtra(AppDefType.ChatPushMessageKey.roomType));
}
},1000);
return;
......
......@@ -1640,12 +1640,11 @@ public class ActivityHandlingHelper extends ABookHelper implements RemoteObserve
intent.putExtra("sid", sid);
String loginId = ABVDataCache.getInstance().getMemberInfo().loginId;
String shopName = ABVDataCache.getInstance().getUrlPath();
intent.putExtra("loginId", loginId);
intent.putExtra("shopName", shopName);
if(dto != null)
{
intent.putExtra("roomId",dto.roomId);
intent.putExtra("roomName", dto.roomName);
intent.putExtra(AppDefType.ChatPushMessageKey.loginId, loginId);
intent.putExtra(AppDefType.ChatPushMessageKey.shopName, shopName);
if (dto != null) {
intent.putExtra(AppDefType.ChatPushMessageKey.roomId, dto.roomId);
intent.putExtra(AppDefType.ChatPushMessageKey.roomName, dto.roomName);
}
intent.setClassName(mContext.getPackageName(), className);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
......@@ -1662,8 +1661,8 @@ public class ActivityHandlingHelper extends ABookHelper implements RemoteObserve
intent.putExtra("sid", sid);
String loginId = ABVDataCache.getInstance().getMemberInfo().loginId;
String shopName = ABVDataCache.getInstance().getUrlPath();
intent.putExtra("loginId", loginId);
intent.putExtra("shopName", shopName);
intent.putExtra(AppDefType.ChatPushMessageKey.loginId, loginId);
intent.putExtra(AppDefType.ChatPushMessageKey.shopName, shopName);
intent.setClassName(mContext.getPackageName(), className);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
getCurrentActivity().startActivity(intent);
......@@ -1672,7 +1671,7 @@ public class ActivityHandlingHelper extends ABookHelper implements RemoteObserve
/**
* プシュメッセージからチャットに入る
*/
public void startChatWebViewActivity(String fromClassName, Long roomId, String roomName) {
public void startChatWebViewActivity(String fromClassName, Long roomId, String roomName, String roomType) {
String className = ChatWebViewActivity.class.getName();
boolean isNormalSize = (mContext.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_NORMAL;
Intent intent = new Intent();
......@@ -1681,10 +1680,11 @@ public class ActivityHandlingHelper extends ABookHelper implements RemoteObserve
intent.putExtra("sid", sid);
String loginId = ABVDataCache.getInstance().getMemberInfo().loginId;
String shopName = ABVDataCache.getInstance().getUrlPath();
intent.putExtra("loginId", loginId);
intent.putExtra("shopName", shopName);
intent.putExtra("roomId", roomId);
intent.putExtra("roomName", roomName);
intent.putExtra(AppDefType.ChatPushMessageKey.loginId, loginId);
intent.putExtra(AppDefType.ChatPushMessageKey.shopName, shopName);
intent.putExtra(AppDefType.ChatPushMessageKey.roomId, roomId);
intent.putExtra(AppDefType.ChatPushMessageKey.roomName, roomName);
intent.putExtra(AppDefType.ChatPushMessageKey.roomType, roomType);
String nextActivity = null;
if (fromClassName.equals(HTMLWebViewActivity.class.getName())) {
......@@ -1718,12 +1718,12 @@ public class ActivityHandlingHelper extends ABookHelper implements RemoteObserve
intent.putExtra("sid", sid);
String loginId = ABVDataCache.getInstance().getMemberInfo().loginId;
String shopName = ABVDataCache.getInstance().getUrlPath();
intent.putExtra("loginId", loginId);
intent.putExtra("collaborationType", collaborationType);
intent.putExtra("shopName", shopName);
intent.putExtra("roomId", roomId);
intent.putExtra("roomName", roomName);
intent.putExtra("roomType", roomType);
intent.putExtra(AppDefType.ChatPushMessageKey.loginId, loginId);
intent.putExtra(AppDefType.ChatPushMessageKey.collaborationType, collaborationType);
intent.putExtra(AppDefType.ChatPushMessageKey.shopName, shopName);
intent.putExtra(AppDefType.ChatPushMessageKey.roomId, roomId);
intent.putExtra(AppDefType.ChatPushMessageKey.roomName, roomName);
intent.putExtra(AppDefType.ChatPushMessageKey.roomType, roomType);
String nextActivity = null;
if (fromClassName.equals(HTMLWebViewActivity.class.getName())) {
......
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