Commit 5a32c06c by Lee Daehyun

Merge branch 'features/#577_ユーザ招待でメッセージを表示' into 'features/abcomm_sp6'

ユーザ招待で同じルームがあればポップアップを表示

See merge request !121
parents 9f112e63 45177967
......@@ -44,6 +44,7 @@ import jp.agentec.abook.abv.bl.acms.client.json.RoomListJSON;
import jp.agentec.abook.abv.bl.acms.client.json.SceneEntryJSON;
import jp.agentec.abook.abv.bl.acms.client.json.ServerTimeZoneJSON;
import jp.agentec.abook.abv.bl.acms.client.json.ServiceOptionsJSON;
import jp.agentec.abook.abv.bl.acms.client.json.UserInviteResultJSON;
import jp.agentec.abook.abv.bl.acms.client.json.WorkerGroupJSON;
import jp.agentec.abook.abv.bl.acms.client.parameters.AbstractAcmsLoginParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.AcmsContentParameters;
......@@ -663,9 +664,10 @@ public class AcmsClient implements AcmsClientResponseListener {
* @throws NetworkDisconnectedException
* @throws AcmsException
*/
public boolean inviteUsers(String sid, Integer roomId, String roomName, String userIds) throws NetworkDisconnectedException, AcmsException {
public UserInviteResultJSON inviteUsers(String sid, Integer roomId, String roomName, String userIds) throws NetworkDisconnectedException, AcmsException {
HttpResponse response = send(AcmsApis.ApigetUser, new InviteUsersParameters(sid, AcmsApis.UserCmds.inviteUsers, roomId, roomName, userIds));
return response.httpResponseCode == 200;
UserInviteResultJSON json = new UserInviteResultJSON(response.httpResponseBody);
return json;
}
/**
......
package jp.agentec.abook.abv.bl.acms.client.json;
import org.json.adf.JSONArray;
import org.json.adf.JSONObject;
import java.util.ArrayList;
import jp.agentec.abook.abv.bl.common.constant.ABookCommConstants;
import jp.agentec.abook.abv.bl.common.exception.AcmsException;
import jp.agentec.abook.abv.bl.common.exception.JSONValidationException;
import jp.agentec.abook.abv.bl.dto.ShopMemberDto;
public class UserInviteResultJSON extends AcmsCommonJSON {
public Integer roomId;
public UserInviteResultJSON(String jsonString) throws AcmsException {
super(jsonString);
}
@Override
protected void parse(JSONObject json) throws JSONValidationException {
if (!json.has(ABookCommConstants.KEY.BODY)) { return; }
JSONObject invateResultJson = json.getJSONObject(ABookCommConstants.KEY.BODY);
if (invateResultJson == null) { return; }
if (invateResultJson.has(ABookCommConstants.KEY.ROOM_ID)) {
roomId = invateResultJson.getInt(ABookCommConstants.KEY.ROOM_ID);
}
}
}
......@@ -61,6 +61,7 @@ import jp.agentec.abook.abv.bl.acms.client.json.GroupListJSON;
import jp.agentec.abook.abv.bl.acms.client.json.MessageInfoListJSON;
import jp.agentec.abook.abv.bl.acms.client.json.MyInfoJSON;
import jp.agentec.abook.abv.bl.acms.client.json.RoomListJSON;
import jp.agentec.abook.abv.bl.acms.client.json.UserInviteResultJSON;
import jp.agentec.abook.abv.bl.common.ABVEnvironment;
import jp.agentec.abook.abv.bl.common.constant.ABookCommConstants;
import jp.agentec.abook.abv.bl.common.constant.ABookKeys;
......@@ -326,17 +327,30 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
// #36128
} else if (message.equals("Do you want to delete this room?")) {
message = getString(R.string.msg_chat_confirm_delete);
} else if (message.equals("error_already_exist_same_user")) {
message = getString(R.string.msg_error_already_exist_same_room);
} else {
message = "Confirm ?";
}
ABookAlertDialog confirmAlert = AlertDialogUtil.createAlertDialog(ChatWebviewActivity.this, R.string.app_name);
confirmAlert.setMessage(message);
confirmAlert.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(R.string.confirm), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
result.confirm();
}
});
if (message.equals(getString(R.string.msg_error_already_exist_same_room))) {
confirmAlert.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(R.string.move), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
result.confirm();
}
});
} else {
confirmAlert.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(R.string.confirm), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
result.confirm();
}
});
}
confirmAlert.setButton(DialogInterface.BUTTON_NEGATIVE, getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
......@@ -857,8 +871,8 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
@JavascriptInterface
public void joinRoom(String joinRoomId, String joinRoomName) {
ChatRoomDto chatRoom = communicationLogic.getChatRoom(Integer.parseInt(joinRoomId));
roomId = Long.parseLong(joinRoomId);
roomName = joinRoomName;
roomId = chatRoom.chatRoomId.longValue();
roomName = chatRoom.chatRoomName;
roomType = chatRoom.type.toString();
beforeRoomType = chatRoom.type.toString();
mChatWebView.post(new Runnable() {
......@@ -883,15 +897,23 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
@JavascriptInterface
public void inviteUsers(String userIds) throws NetworkDisconnectedException, AcmsException {
boolean result = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).inviteUsers(sid, roomId.intValue(), roomName, userIds);
if (!result) { return; }
communicationLogic.addUserInRoom(userIds, roomId.intValue());
mChatWebView.post(new Runnable() {
@Override
public void run() {
mChatWebView.loadUrl(CHAT_ROOM_PAGE_URL);
}
});
final UserInviteResultJSON result = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).inviteUsers(sid, roomId.intValue(), roomName, userIds);
if (result.roomId == null) {
communicationLogic.addUserInRoom(userIds, roomId.intValue());
mChatWebView.post(new Runnable() {
@Override
public void run() {
mChatWebView.loadUrl(CHAT_ROOM_PAGE_URL);
}
});
} else {
mChatWebView.post(new Runnable() {
@Override
public void run() {
mChatWebView.loadUrl(String.format("javascript:CHAT_UI.displayExistRoom('%s');", result.roomId.toString()));
}
});
}
}
@JavascriptInterface
......
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