Commit e673a50a by Kim Peace

Rearranged communication code

parent 76b07967
......@@ -102,6 +102,7 @@ public interface ABookCommConstants {
String IS_ONLINE = "isOnline";
String IS_MOBILE = "isMobile";
String PLATFORM = "platform";
String COLLABORATION_TYPE = "collaborationType";
}
interface FLAG {
......
......@@ -10,11 +10,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import jp.agentec.abook.abv.bl.common.constant.ABookCommConstants;
import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.bl.common.util.JsonUtil;
import jp.agentec.abook.abv.bl.data.dao.AbstractCommunicationDao;
import jp.agentec.abook.abv.bl.data.dao.AbstractDao;
import jp.agentec.abook.abv.bl.data.dao.ArchiveDao;
......@@ -24,13 +21,11 @@ import jp.agentec.abook.abv.bl.data.dao.ChatRoomDao;
import jp.agentec.abook.abv.bl.data.dao.ContentDao;
import jp.agentec.abook.abv.bl.data.dao.ShopMemberDao;
import jp.agentec.abook.abv.bl.dto.ArchiveDto;
import jp.agentec.abook.abv.bl.dto.ChatGroupDto;
import jp.agentec.abook.abv.bl.dto.ChatMessageDto;
import jp.agentec.abook.abv.bl.dto.ChatRoomDto;
import jp.agentec.abook.abv.bl.dto.ChatGroupDto;
import jp.agentec.abook.abv.bl.dto.ContentDto;
import jp.agentec.abook.abv.bl.dto.ShopMemberDto;
import jp.agentec.adf.util.ArrayUtil;
import jp.agentec.adf.util.CollectionUtil;
import jp.agentec.adf.util.DateTimeUtil;
import jp.agentec.adf.util.StringUtil;
......@@ -40,14 +35,14 @@ import jp.agentec.adf.util.StringUtil;
public class CommunicationLogic extends AbstractLogic {
private static final String TAG = "CommunicationLogic";
private ChatRoomDao chatRoomDao = AbstractCommunicationDao.getDao(ChatRoomDao.class);
private ChatMessageDao chatMessageDao = AbstractCommunicationDao.getDao(ChatMessageDao.class);
private ShopMemberDao shopMemberDao = AbstractCommunicationDao.getDao(ShopMemberDao.class);
private ChatGroupDao chatGroupDao = AbstractCommunicationDao.getDao(ChatGroupDao.class);
private ContentDao contentDao = AbstractDao.getDao(ContentDao.class);
private final ChatRoomDao chatRoomDao = AbstractCommunicationDao.getDao(ChatRoomDao.class);
private final ChatMessageDao chatMessageDao = AbstractCommunicationDao.getDao(ChatMessageDao.class);
private final ShopMemberDao shopMemberDao = AbstractCommunicationDao.getDao(ShopMemberDao.class);
private final ChatGroupDao chatGroupDao = AbstractCommunicationDao.getDao(ChatGroupDao.class);
private final ContentDao contentDao = AbstractDao.getDao(ContentDao.class);
private String localFilePath;
private ArchiveDao archiveDao = AbstractCommunicationDao.getDao(ArchiveDao.class);
private final ArchiveDao archiveDao = AbstractCommunicationDao.getDao(ArchiveDao.class);
/**
* {@link CommunicationLogic} クラスのインスタンスを初期化します。
......@@ -100,8 +95,7 @@ public class CommunicationLogic extends AbstractLogic {
JSONObject jsonObject = new JSONObject(chatRoomMap);
resultJsonArray.put(jsonObject);
}
String roomListToStr = resultJsonArray.toString();
return roomListToStr;
return resultJsonArray.toString();
}
public String getUsersInRoom(Integer roomId) {
......@@ -115,8 +109,7 @@ public class CommunicationLogic extends AbstractLogic {
JSONObject jsonObject = new JSONObject(userMap);
attendUsers.put(jsonObject);
}
String attendUsersStr = attendUsers.toString();
return attendUsersStr;
return attendUsers.toString();
}
public String getMessages(Integer roomId) {
......@@ -142,8 +135,7 @@ public class CommunicationLogic extends AbstractLogic {
JSONObject jsonObject = new JSONObject(chatMessageMap);
resultJsonArray.put(jsonObject);
}
String messageListStr = resultJsonArray.toString();
return messageListStr;
return resultJsonArray.toString();
}
public String getMessagesFromMessageId(Integer roomId, String messageId) {
......@@ -170,8 +162,7 @@ public class CommunicationLogic extends AbstractLogic {
JSONObject jsonObject = new JSONObject(chatMessageMap);
resultJsonArray.put(jsonObject);
}
String messageListStr = resultJsonArray.toString();
return messageListStr;
return resultJsonArray.toString();
}
public String searMessages(Integer roomId, String keyword, String userList) {
......@@ -197,8 +188,7 @@ public class CommunicationLogic extends AbstractLogic {
JSONObject jsonObject = new JSONObject(chatMessageMap);
resultJsonArray.put(jsonObject);
}
String messageListStr = resultJsonArray.toString();
return messageListStr;
return resultJsonArray.toString();
}
public String getNameCardInfo(Integer shopMemberId) {
......@@ -223,7 +213,7 @@ public class CommunicationLogic extends AbstractLogic {
resultJson.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, shopMemberDto.shopMemberName);
resultJson.put(ABookCommConstants.KEY.PROFILE_URL, getProfileUrlPath(shopMemberDto.profileUrl));
resultJson.put(ABookCommConstants.KEY.GROUP_PATH_LIST, groupPathJsonArray);
boolean hasRegisteredDate = StringUtil.isNullOrEmpty(shopMemberDto.favoriteRegisterDate) == false;
boolean hasRegisteredDate = !StringUtil.isNullOrEmpty(shopMemberDto.favoriteRegisterDate);
resultJson.put(ABookCommConstants.KEY.IS_FAVORITE, hasRegisteredDate);
return resultJson.toString();
......@@ -237,8 +227,7 @@ public class CommunicationLogic extends AbstractLogic {
myInfoJson.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, myInfo.shopMemberName);
myInfoJson.put(ABookCommConstants.KEY.PROFILE_URL, getProfileUrlPath(myInfo.profileUrl));
myInfoJson.put(ABookCommConstants.KEY.GROUP_PATH_LIST, groupPathList);
String myInfoStr = myInfoJson.toString();
return myInfoStr;
return myInfoJson.toString();
}
public String getUserListByLoginId(String loginIdList) {
......@@ -259,8 +248,7 @@ public class CommunicationLogic extends AbstractLogic {
joinedMemberArray.put(myInfoJson);
}
String myInfoStr = joinedMemberArray.toString();
return myInfoStr;
return joinedMemberArray.toString();
}
public String getMyGroupUsers() {
......@@ -279,19 +267,14 @@ public class CommunicationLogic extends AbstractLogic {
myGroupUserMap.put(ABookCommConstants.KEY.CHECKED, "");
myGroupUserMap.put(ABookCommConstants.KEY.PROFILE_URL, getProfileUrlPath(groupUser.profileUrl));
myGroupUserMap.put(ABookCommConstants.KEY.GROUP_PATH_LIST, groupUser);
if (StringUtil.isNullOrEmpty(groupUser.favoriteRegisterDate)) {
myGroupUserMap.put(ABookCommConstants.KEY.IS_FAVORITE, false);
} else {
myGroupUserMap.put(ABookCommConstants.KEY.IS_FAVORITE, true);
}
myGroupUserMap.put(ABookCommConstants.KEY.IS_FAVORITE, !StringUtil.isNullOrEmpty(groupUser.favoriteRegisterDate));
JSONObject jsonObject = new JSONObject(myGroupUserMap);
groupUserArray.put(jsonObject);
}
groupUserJson.put(ABookCommConstants.KEY.GROUP_USER_LIST, groupUserArray);
myGroupUsersJson.put(groupUserJson);
}
String myInfoStr = myGroupUsersJson.toString();
return myInfoStr;
return myGroupUsersJson.toString();
}
public String getMyGroupUsersNotInRoom(Integer roomId) {
......@@ -310,19 +293,14 @@ public class CommunicationLogic extends AbstractLogic {
myGroupUserMap.put(ABookCommConstants.KEY.CHECKED, "");
myGroupUserMap.put(ABookCommConstants.KEY.PROFILE_URL, getProfileUrlPath(groupUser.profileUrl));
myGroupUserMap.put(ABookCommConstants.KEY.GROUP_PATH_LIST, groupUser);
if (StringUtil.isNullOrEmpty(groupUser.favoriteRegisterDate)) {
myGroupUserMap.put(ABookCommConstants.KEY.IS_FAVORITE, false);
} else {
myGroupUserMap.put(ABookCommConstants.KEY.IS_FAVORITE, true);
}
myGroupUserMap.put(ABookCommConstants.KEY.IS_FAVORITE, !StringUtil.isNullOrEmpty(groupUser.favoriteRegisterDate));
JSONObject jsonObject = new JSONObject(myGroupUserMap);
groupUserArray.put(jsonObject);
}
groupUserJson.put(ABookCommConstants.KEY.GROUP_USER_LIST, groupUserArray);
myGroupUsersJson.put(groupUserJson);
}
String myInfoStr = myGroupUsersJson.toString();
return myInfoStr;
return myGroupUsersJson.toString();
}
public String getMyGroupUserByName(String keyword) {
......@@ -346,17 +324,12 @@ public class CommunicationLogic extends AbstractLogic {
userMap.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, shopMember.shopMemberName);
userMap.put(ABookCommConstants.KEY.PROFILE_URL, getProfileUrlPath(shopMember.profileUrl));
userMap.put(ABookCommConstants.KEY.GROUP_PATH_LIST, groupPathArray);
if (StringUtil.isNullOrEmpty(shopMember.favoriteRegisterDate)) {
userMap.put(ABookCommConstants.KEY.IS_FAVORITE, false);
} else {
userMap.put(ABookCommConstants.KEY.IS_FAVORITE, true);
}
userMap.put(ABookCommConstants.KEY.IS_FAVORITE, !StringUtil.isNullOrEmpty(shopMember.favoriteRegisterDate));
JSONObject jsonObject = new JSONObject(userMap);
resultJsonArray.put(jsonObject);
}
String searchUserStr = resultJsonArray.toString();
return searchUserStr;
return resultJsonArray.toString();
}
public String getMyGroupUserNotInRoomByName(String keywords, Integer roomId) {
......@@ -380,17 +353,12 @@ public class CommunicationLogic extends AbstractLogic {
userMap.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, shopMember.shopMemberName);
userMap.put(ABookCommConstants.KEY.PROFILE_URL, getProfileUrlPath(shopMember.profileUrl));
userMap.put(ABookCommConstants.KEY.GROUP_PATH_LIST, groupPathArray);
if (StringUtil.isNullOrEmpty(shopMember.favoriteRegisterDate)) {
userMap.put(ABookCommConstants.KEY.IS_FAVORITE, false);
} else {
userMap.put(ABookCommConstants.KEY.IS_FAVORITE, true);
}
userMap.put(ABookCommConstants.KEY.IS_FAVORITE, !StringUtil.isNullOrEmpty(shopMember.favoriteRegisterDate));
JSONObject jsonObject = new JSONObject(userMap);
resultJsonArray.put(jsonObject);
}
String searchUserStr = resultJsonArray.toString();
return searchUserStr;
return resultJsonArray.toString();
}
public String getAllGroupShopMemberByName(String keyword) {
......@@ -413,17 +381,12 @@ public class CommunicationLogic extends AbstractLogic {
userMap.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, shopMember.shopMemberName);
userMap.put(ABookCommConstants.KEY.PROFILE_URL, getProfileUrlPath(shopMember.profileUrl));
userMap.put(ABookCommConstants.KEY.GROUP_PATH_LIST, groupPathArray);
if (StringUtil.isNullOrEmpty(shopMember.favoriteRegisterDate)) {
userMap.put(ABookCommConstants.KEY.IS_FAVORITE, false);
} else {
userMap.put(ABookCommConstants.KEY.IS_FAVORITE, true);
}
userMap.put(ABookCommConstants.KEY.IS_FAVORITE, !StringUtil.isNullOrEmpty(shopMember.favoriteRegisterDate));
JSONObject jsonObject = new JSONObject(userMap);
resultJsonArray.put(jsonObject);
}
String searchUserStr = resultJsonArray.toString();
return searchUserStr;
return resultJsonArray.toString();
}
public String getAllGroupShopMemberNotInRoomByName(String keywords, Integer roomId) {
......@@ -448,17 +411,12 @@ public class CommunicationLogic extends AbstractLogic {
userMap.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, shopMember.shopMemberName);
userMap.put(ABookCommConstants.KEY.PROFILE_URL, getProfileUrlPath(shopMember.profileUrl));
userMap.put(ABookCommConstants.KEY.GROUP_PATH_LIST, groupPathArray);
if (StringUtil.isNullOrEmpty(shopMember.favoriteRegisterDate)) {
userMap.put(ABookCommConstants.KEY.IS_FAVORITE, false);
} else {
userMap.put(ABookCommConstants.KEY.IS_FAVORITE, true);
}
userMap.put(ABookCommConstants.KEY.IS_FAVORITE, !StringUtil.isNullOrEmpty(shopMember.favoriteRegisterDate));
JSONObject jsonObject = new JSONObject(userMap);
resultJsonArray.put(jsonObject);
}
String searchUserStr = resultJsonArray.toString();
return searchUserStr;
return resultJsonArray.toString();
}
public String getGroupByName(String keyword) {
......@@ -470,29 +428,24 @@ public class CommunicationLogic extends AbstractLogic {
Map<String, Object> groupMap = new HashMap<String, Object>();
groupMap.put(ABookCommConstants.KEY.GROUP_NAME, group.groupName);
groupMap.put(ABookCommConstants.KEY.GROUP_ID, group.groupId);
if (StringUtil.isNullOrEmpty(group.favoriteRegisterDate)) {
groupMap.put(ABookCommConstants.KEY.IS_FAVORITE, false);
} else {
groupMap.put(ABookCommConstants.KEY.IS_FAVORITE, true);
}
groupMap.put(ABookCommConstants.KEY.IS_FAVORITE, !StringUtil.isNullOrEmpty(group.favoriteRegisterDate));
JSONObject jsonObject = new JSONObject(groupMap);
resultJsonArray.put(jsonObject);
}
String groupsStr = resultJsonArray.toString();
return groupsStr;
return resultJsonArray.toString();
}
public String getMyGroupIds() {
List<ChatGroupDto> myGroupList = chatGroupDao.getMyGroups();
String groupIds = "";
StringBuilder groupIds = new StringBuilder();
for (ChatGroupDto myGroup : myGroupList) {
if (!groupIds.equals("")) {
groupIds = groupIds + ",";
if (!groupIds.toString().equals("")) {
groupIds.append(",");
}
groupIds = groupIds + myGroup.groupId;
groupIds.append(myGroup.groupId);
}
return groupIds;
return groupIds.toString();
}
public List<ChatGroupDto> getAllGroup() {
......@@ -528,8 +481,7 @@ public class CommunicationLogic extends AbstractLogic {
resultJsonArray.put(jsonObject);
}
String favoriteUsersStr = resultJsonArray.toString();
return favoriteUsersStr;
return resultJsonArray.toString();
}
public String getFavoriteUsersNotInRoom(Integer roomId) {
......@@ -558,8 +510,7 @@ public class CommunicationLogic extends AbstractLogic {
resultJsonArray.put(jsonObject);
}
String favoriteUsersStr = resultJsonArray.toString();
return favoriteUsersStr;
return resultJsonArray.toString();
}
public String getFavoriteGroups() {
......@@ -576,8 +527,7 @@ public class CommunicationLogic extends AbstractLogic {
resultJsonArray.put(jsonObject);
}
String favoriteGroupsStr = resultJsonArray.toString();
return favoriteGroupsStr;
return resultJsonArray.toString();
}
public Integer getFavoriteCount() {
......@@ -628,11 +578,7 @@ public class CommunicationLogic extends AbstractLogic {
Map<String, Object> groupTreeMap = new HashMap<String, Object>();
groupTreeMap.put(ABookCommConstants.KEY.GROUP_NAME, group.groupName);
groupTreeMap.put(ABookCommConstants.KEY.GROUP_ID, group.groupId);
if (StringUtil.isNullOrEmpty(group.favoriteRegisterDate)) {
groupTreeMap.put(ABookCommConstants.KEY.IS_FAVORITE, false);
} else {
groupTreeMap.put(ABookCommConstants.KEY.IS_FAVORITE, true);
}
groupTreeMap.put(ABookCommConstants.KEY.IS_FAVORITE, !StringUtil.isNullOrEmpty(group.favoriteRegisterDate));
JSONObject jsonObject = new JSONObject(groupTreeMap);
childGroupJSONArray.put(jsonObject);
}
......@@ -648,18 +594,13 @@ public class CommunicationLogic extends AbstractLogic {
shopMemberMap.put(ABookCommConstants.KEY.PROFILE_URL, getProfileUrlPath(shopMember.profileUrl));
shopMemberMap.put(ABookCommConstants.KEY.CHECKED, "");
shopMemberMap.put(ABookCommConstants.KEY.GROUP_PATH_LIST, chatGroupDao.getUserGroupPathList(shopMember.shopMemberId));
if (StringUtil.isNullOrEmpty(shopMember.favoriteRegisterDate)) {
shopMemberMap.put(ABookCommConstants.KEY.IS_FAVORITE, false);
} else {
shopMemberMap.put(ABookCommConstants.KEY.IS_FAVORITE, true);
}
shopMemberMap.put(ABookCommConstants.KEY.IS_FAVORITE, !StringUtil.isNullOrEmpty(shopMember.favoriteRegisterDate));
JSONObject jsonObject = new JSONObject(shopMemberMap);
shopMemberJSONArray.put(jsonObject);
}
groupSearchData.put(ABookCommConstants.KEY.GROUP_USER_LIST,shopMemberJSONArray);
String groupSearchDataStr = groupSearchData.toString();
return groupSearchDataStr;
return groupSearchData.toString();
}
public String getGroupSearchDataForAddUser(Integer groupId, Integer roomId) {
......@@ -671,12 +612,7 @@ public class CommunicationLogic extends AbstractLogic {
ChatGroupDto myGroup = chatGroupDao.getMyGroups().get(0);
ChatGroupDto rootGroup = chatGroupDao.getRootGroup();
Integer targetGroupId;
if (groupId == 0) {
targetGroupId = rootGroup.groupId;
} else {
targetGroupId = groupId;
}
Integer targetGroupId = groupId == 0 ? rootGroup.groupId : groupId;
ChatGroupDto parentGroup = chatGroupDao.getParentGroup(targetGroupId);
if (parentGroup != null) {
......@@ -704,11 +640,7 @@ public class CommunicationLogic extends AbstractLogic {
Map<String, Object> groupTreeMap = new HashMap<String, Object>();
groupTreeMap.put(ABookCommConstants.KEY.GROUP_NAME, group.groupName);
groupTreeMap.put(ABookCommConstants.KEY.GROUP_ID, group.groupId);
if (StringUtil.isNullOrEmpty(group.favoriteRegisterDate)) {
groupTreeMap.put(ABookCommConstants.KEY.IS_FAVORITE, false);
} else {
groupTreeMap.put(ABookCommConstants.KEY.IS_FAVORITE, true);
}
groupTreeMap.put(ABookCommConstants.KEY.IS_FAVORITE, !StringUtil.isNullOrEmpty(group.favoriteRegisterDate));
JSONObject jsonObject = new JSONObject(groupTreeMap);
childGroupJSONArray.put(jsonObject);
}
......@@ -724,18 +656,13 @@ public class CommunicationLogic extends AbstractLogic {
shopMemberMap.put(ABookCommConstants.KEY.PROFILE_URL, getProfileUrlPath(shopMember.profileUrl));
shopMemberMap.put(ABookCommConstants.KEY.CHECKED, "");
shopMemberMap.put(ABookCommConstants.KEY.GROUP_PATH_LIST, chatGroupDao.getUserGroupPathList(shopMember.shopMemberId));
if (StringUtil.isNullOrEmpty(shopMember.favoriteRegisterDate)) {
shopMemberMap.put(ABookCommConstants.KEY.IS_FAVORITE, false);
} else {
shopMemberMap.put(ABookCommConstants.KEY.IS_FAVORITE, true);
}
shopMemberMap.put(ABookCommConstants.KEY.IS_FAVORITE, !StringUtil.isNullOrEmpty(shopMember.favoriteRegisterDate));
JSONObject jsonObject = new JSONObject(shopMemberMap);
shopMemberJSONArray.put(jsonObject);
}
groupSearchData.put(ABookCommConstants.KEY.GROUP_USER_LIST,shopMemberJSONArray);
String groupSearchDataStr = groupSearchData.toString();
return groupSearchDataStr;
return groupSearchData.toString();
}
public void insertChatRoomList(List<ChatRoomDto> roomList) {
......@@ -766,10 +693,6 @@ public class CommunicationLogic extends AbstractLogic {
chatRoomDao.insertChatRoomUsers(userIdList, roomId);
}
public void insertChatMessage(ChatMessageDto chatMessageDto) {
chatMessageDao.insertChatMessage(chatMessageDto);
}
public void updateChatRoomName(String roomName, Integer roomId) {
chatRoomDao.updateChatRoomName(roomName, roomId);
}
......@@ -789,22 +712,16 @@ public class CommunicationLogic extends AbstractLogic {
ShopMemberDto myInfo = shopMemberDao.getMyInfo();
List<ShopMemberDto> insertList = new ArrayList<ShopMemberDto>();
List<ShopMemberDto> deleteList = new ArrayList<ShopMemberDto>();
for (ShopMemberDto shopMemberDto : shopMemberDtoList) {
//if (ABookCommConstants.FLAG.DEL_FLAG.EXIST.equals(shopMemberDto.delFlg)) {
if (myInfo.shopMemberId.equals(shopMemberDto.shopMemberId)) {
shopMemberDto.selfFlg = 1;
} else {
shopMemberDto.selfFlg = 0;
}
insertList.add(shopMemberDto);
//} else {
// deleteList.add(shopMemberDto);
//}
}
shopMemberDao.insertShopMember(insertList);
//shopMemberDao.deleteShopMemberByList(deleteList);
}
......@@ -884,12 +801,7 @@ public class CommunicationLogic extends AbstractLogic {
}
public ShopMemberDto getMyShopMemberDto() {
ShopMemberDto myInfo = shopMemberDao.getMyInfo();
return myInfo;
}
public void deleteChatRoomList() {
chatRoomDao.deleteChatRoom();
return shopMemberDao.getMyInfo();
}
public void insertMyInfo(ShopMemberDto shopMemberDto) {
......@@ -940,13 +852,6 @@ public class CommunicationLogic extends AbstractLogic {
archiveDao.deleteArchiveAllData();
}
public void initChatData() {
chatGroupDao.deleteChatGroup();
chatMessageDao.deleteChatMessage();
shopMemberDao.deleteShopMember();
archiveDao.deleteArchiveAllData();
}
public void roomDisplayOff(Integer roomId, Integer viewFlg) {
chatRoomDao.changeRoomViewFlg(roomId, viewFlg);
}
......@@ -963,7 +868,7 @@ public class CommunicationLogic extends AbstractLogic {
attendUsers.put(jsonObject);
}
return attendUsers.toString();
};
}
public String getProfileUrlPath(String profileUrl) {
if (profileUrl == null) {
......@@ -974,12 +879,11 @@ public class CommunicationLogic extends AbstractLogic {
String filePath = localFilePath + fileName;
File file = new File(filePath);
if (file.exists()) {
String uri = file.toURI().toString();
return uri;
return file.toURI().toString();
} else {
return profileUrl;
}
};
}
public String getFileUrlPath(String fileUrlPath) {
if (!fileUrlPath.contains("fileName=")) {
......@@ -999,7 +903,7 @@ public class CommunicationLogic extends AbstractLogic {
} else {
return fileUrlPath;
}
};
}
public void setPackagePath(String localFilePath) {
this.localFilePath = localFilePath;
......@@ -1097,21 +1001,6 @@ public class CommunicationLogic extends AbstractLogic {
return resultJsonArray.toString();
}
public String getCollaborationMemberList(Integer collaborationDetailId) {
List<ShopMemberDto> shopMemberDtoListDtoList = shopMemberDao.getCollaborationMemberList(collaborationDetailId);
JSONArray resultJsonArray = new JSONArray();
for (ShopMemberDto dto : shopMemberDtoListDtoList) {
Map<String, Object> userMap = new HashMap<String, Object>();
userMap.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, dto.shopMemberId);
userMap.put(ABookCommConstants.KEY.LOGIN_ID, dto.loginId);
userMap.put(ABookCommConstants.KEY.PROFILE_URL, getProfileUrlPath(dto.profileUrl));
userMap.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, dto.shopMemberName);
JSONObject jsonObject = new JSONObject(userMap);
resultJsonArray.put(jsonObject);
}
return resultJsonArray.toString();
}
public Map<Integer, ChatGroupDto> convertGroupListToMap(List<ChatGroupDto> groupList) {
Map<Integer, ChatGroupDto> map = new HashMap<Integer, ChatGroupDto>();
for (ChatGroupDto group : groupList) {
......
......@@ -144,20 +144,25 @@ public class ChatData {
}
public void updateMyInfoFromServer() throws NetworkDisconnectedException, AcmsException {
MyInfoJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getMyInfo(sid);
MyInfoJSON resultJson = AcmsClient
.getInstance(ABVEnvironment.getInstance().networkAdapter)
.getMyInfo(sid);
if (resultJson.shopMemberDto != null) {
communicationLogic.insertMyInfo(resultJson.shopMemberDto);
}
}
public void updateUserInfoFromServer(String shopMemberId) throws NetworkDisconnectedException, AcmsException {
MyInfoJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter)
MyInfoJSON resultJson = AcmsClient
.getInstance(ABVEnvironment.getInstance().networkAdapter)
.getNameCard(sid, shopMemberId);
communicationLogic.insertShopMember(resultJson.shopMemberDto);
}
public boolean insertFavoriteUser(String shopMemberId) throws NetworkDisconnectedException, AcmsException {
boolean result = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).insertFavoriteUser(sid,Integer.parseInt(shopMemberId));
boolean result = AcmsClient
.getInstance(ABVEnvironment.getInstance().networkAdapter)
.insertFavoriteUser(sid,Integer.parseInt(shopMemberId));
if (!result) { return false; }
List<Integer> shopMeberIds = new ArrayList<>();
shopMeberIds.add(Integer.parseInt(shopMemberId));
......@@ -166,7 +171,8 @@ public class ChatData {
}
public boolean deleteFavoriteUser(String shopMemberId) throws NetworkDisconnectedException, AcmsException {
boolean result = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter)
boolean result = AcmsClient
.getInstance(ABVEnvironment.getInstance().networkAdapter)
.deleteFavoriteUser(sid, Integer.parseInt(shopMemberId));
if (result) {
List<Integer> deleteFavoriteList = new ArrayList<Integer>();
......@@ -177,18 +183,23 @@ public class ChatData {
}
public boolean insertFavoriteGroup(String groupId) throws NetworkDisconnectedException, AcmsException {
boolean result = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter)
boolean result = AcmsClient
.getInstance(ABVEnvironment.getInstance().networkAdapter)
.insertFavoriteGroup(sid, Integer.parseInt(groupId));
return result;
}
public void updateUnreadCount() throws NetworkDisconnectedException, AcmsException {
UnreadCountJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getMessagesUnreadCount(sid, Integer.toString(roomId.intValue()));
UnreadCountJSON resultJson = AcmsClient
.getInstance(ABVEnvironment.getInstance().networkAdapter)
.getMessagesUnreadCount(sid, Integer.toString(roomId.intValue()));
communicationLogic.updateUnreadCount(resultJson.chatMessageDtoArrayList, Integer.toString(roomId.intValue()));
}
public void updateMessageFromMessageId(String messageId) throws NetworkDisconnectedException, AcmsException {
MessageInfoListJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getMessages(sid, Integer.toString(roomId.intValue()), messageId, null);
MessageInfoListJSON resultJson = AcmsClient
.getInstance(ABVEnvironment.getInstance().networkAdapter)
.getMessages(sid, Integer.toString(roomId.intValue()), messageId, null);
for (ChatMessageDto chatMessageDto : resultJson.chatMessageDtoArrayList) {
chatMessageDto.chatRoomId = roomId.intValue();
}
......@@ -198,7 +209,9 @@ public class ChatData {
}
public void updateRoomList() throws NetworkDisconnectedException, AcmsException {
RoomListJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getRoomList(sid);
RoomListJSON resultJson = AcmsClient
.getInstance(ABVEnvironment.getInstance().networkAdapter)
.getRoomList(sid);
communicationLogic.insertChatRoomList(resultJson.roomList);
}
......@@ -209,7 +222,9 @@ public class ChatData {
* @throws AcmsException
*/
public void changeRoomName(String changeRoomName) throws NetworkDisconnectedException, AcmsException {
ChangeRoomNameJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).changeRoomName(sid, changeRoomName, roomId.intValue());
ChangeRoomNameJSON resultJson = AcmsClient
.getInstance(ABVEnvironment.getInstance().networkAdapter)
.changeRoomName(sid, changeRoomName, roomId.intValue());
if (resultJson.status != 200) { return; }
communicationLogic.updateChatRoomName(changeRoomName, roomId.intValue());
......@@ -227,7 +242,9 @@ public class ChatData {
public void updateArchiveList() throws NetworkDisconnectedException, AcmsException {
SharedPreferences pref = context.getSharedPreferences(ABookCommConstants.TAG, Context.MODE_PRIVATE);
String updateDate = pref.getString(ABookCommConstants.KEY.ARCHIVE_UPDATED_DATE, ABookCommConstants.DEFAULT_CHECKSUM);
ArchiveListJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getArchives(sid, updateDate);
ArchiveListJSON resultJson = AcmsClient
.getInstance(ABVEnvironment.getInstance().networkAdapter)
.getArchives(sid, updateDate);
communicationLogic.updateArchives(resultJson.archiveList);
if (StringUtil.isNullOrEmpty(resultJson.archiveLastUpdateDate)) { return; }
SharedPreferences.Editor editor = pref.edit();
......@@ -237,7 +254,9 @@ public class ChatData {
public void updateArchiveDetail(String archiveId) throws NetworkDisconnectedException, AcmsException {
ArchiveDto archiveDto = communicationLogic.getArchive(Integer.parseInt(archiveId));
RoomJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getRoom(sid, archiveDto.roomId.toString());
RoomJSON resultJson = AcmsClient
.getInstance(ABVEnvironment.getInstance().networkAdapter)
.getRoom(sid, archiveDto.roomId.toString());
archiveDto.roomName = resultJson.chatRoomDto.chatRoomName;
communicationLogic.updateArchiveDetial(archiveDto);
}
......@@ -276,12 +295,16 @@ public class ChatData {
finishAllCollaboration(sid, roomId.intValue());
}
private void updateFavoriteUser() throws NetworkDisconnectedException, AcmsException {
GetFavoriteUserJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getFavoriteUser(sid);
GetFavoriteUserJSON resultJson = AcmsClient
.getInstance(ABVEnvironment.getInstance().networkAdapter)
.getFavoriteUser(sid);
communicationLogic.updateFavoriteUser(resultJson.favoriteUserIds);
}
public void updateFavoriteGroup() throws NetworkDisconnectedException, AcmsException {
GetFavoriteGroupJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getFavoriteGroup(sid);
GetFavoriteGroupJSON resultJson = AcmsClient
.getInstance(ABVEnvironment.getInstance().networkAdapter)
.getFavoriteGroup(sid);
communicationLogic.updateFavoriteGroup(resultJson.favoriteGroupIds);
}
......@@ -294,12 +317,13 @@ public class ChatData {
updateFavoriteGroup();
}
public void updateGroupInfoFromServer() throws NetworkDisconnectedException, AcmsException {
ArrayList<String> checkSumList = new ArrayList<String>();
public void updateGroupInfoFromServer() throws NetworkDisconnectedException {
SharedPreferences pref = context.getSharedPreferences(ABookCommConstants.TAG, Context.MODE_PRIVATE);
String lastUpdatedDate = pref.getString(ABookCommConstants.KEY.GROUP_MEMBER_UPDATED_DATE, ABookCommConstants.DEFAULT_CHECKSUM);
try {
GroupListJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getGroupInfo(sid, lastUpdatedDate);
GroupListJSON resultJson = AcmsClient
.getInstance(ABVEnvironment.getInstance().networkAdapter)
.getGroupInfo(sid, lastUpdatedDate);
if (CollectionUtil.isNotEmpty(resultJson.groupList)) {
communicationLogic.updateGroup(resultJson.groupList);
SharedPreferences.Editor editor = pref.edit();
......
......@@ -23,8 +23,6 @@ import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.provider.BaseColumns;
import android.provider.MediaStore;
import android.support.annotation.RequiresApi;
import android.util.Log;
import android.view.KeyEvent;
......@@ -56,8 +54,6 @@ import java.util.TimerTask;
import jp.agentec.abook.abv.bl.acms.client.AcmsClient;
import jp.agentec.abook.abv.bl.acms.client.json.CreatedRoomJSON;
import jp.agentec.abook.abv.bl.acms.client.json.GetFavoriteGroupJSON;
import jp.agentec.abook.abv.bl.acms.client.json.GetFavoriteUserJSON;
import jp.agentec.abook.abv.bl.acms.client.json.MessageInfoListJSON;
import jp.agentec.abook.abv.bl.acms.client.json.UserInviteResultJSON;
import jp.agentec.abook.abv.bl.common.ABVEnvironment;
......@@ -71,7 +67,6 @@ import jp.agentec.abook.abv.bl.data.ABVDataCache;
import jp.agentec.abook.abv.bl.dto.ChatMessageDto;
import jp.agentec.abook.abv.bl.dto.ChatRoomDto;
import jp.agentec.abook.abv.bl.dto.MeetingDto;
import jp.agentec.abook.abv.bl.dto.PushMessageDto;
import jp.agentec.abook.abv.bl.dto.ShopMemberDto;
import jp.agentec.abook.abv.bl.logic.AbstractLogic;
import jp.agentec.abook.abv.bl.logic.CommunicationLogic;
......@@ -102,28 +97,28 @@ import static org.chromium.net.NetError.ERR_FAILED;
*/
public class ChatWebViewActivity extends CommunicationWebViewActivity {
public ChatWebView mChatWebView;
private ChatWebView mChatWebView;
private String chatWebviewUrl;
private final String TAG = "ChatWebViewActivity";
private ValueCallback<Uri[]> mUploadMessage;
public ChatData chatData;
public String selectedUserIdList;
public String mSkey;
private ChatData chatData;
private String selectedUserIdList;
private String mSkey;
private boolean isPIP;
private boolean isStop;
private String encodedFilePath;
public MeetingManager meetingManager = MeetingManager.getInstance();
public AlertDialog myAlertDialog;
private MeetingManager meetingManager = MeetingManager.getInstance();
private AlertDialog myAlertDialog;
private BroadcastReceiver receiver;
private CommunicationLogic communicationLogic = AbstractLogic.getLogic(CommunicationLogic.class);
private final CommunicationLogic communicationLogic = AbstractLogic.getLogic(CommunicationLogic.class);
public boolean needHostAlert = false;
private boolean needHostAlert = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
......@@ -133,7 +128,10 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity {
}
initializeWebView();
FrameLayout layout = new FrameLayout(this);
FrameLayout.LayoutParams param = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
FrameLayout.LayoutParams param = new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
);
setContentView(mChatWebView, param);
}
......@@ -150,13 +148,13 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity {
private void initiateDatas(Intent intent) {
communicationLogic.setPackagePath(getFilesDir().getAbsolutePath() + "/");
chatData = ChatData.getInstance();
chatData.setSid(intent.getStringExtra("sid"));
chatData.setRoomID(intent.getLongExtra("roomId", 0));
chatData.roomName = intent.getStringExtra("roomName");
chatData.roomType = intent.getStringExtra("roomType");
chatData.loginId = intent.getStringExtra("loginId");
chatData.shopName = intent.getStringExtra("shopName");
chatData.setStrCollaborationType(intent.getStringExtra("collaborationType"));
chatData.setSid(intent.getStringExtra(ABookCommConstants.KEY.SID));
chatData.setRoomID(intent.getLongExtra(ABookCommConstants.KEY.ROOM_ID, 0));
chatData.roomName = intent.getStringExtra(ABookCommConstants.KEY.ROOM_NAME);
chatData.roomType = intent.getStringExtra(ABookCommConstants.KEY.ROOM_TYPE);
chatData.loginId = intent.getStringExtra(ABookCommConstants.KEY.LOGIN_ID);
chatData.shopName = intent.getStringExtra(ABookCommConstants.KEY.SHOP_NAME);
chatData.setStrCollaborationType(intent.getStringExtra(ABookCommConstants.KEY.COLLABORATION_TYPE));
chatData.setIsOnline(false);
chatData.setContext(ChatWebViewActivity.this);
chatData.setIsMobile(!isNormalSize());
......@@ -164,7 +162,7 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity {
private void setupChatWebView() {
mChatWebView = new ChatWebView(ChatWebViewActivity.this);
mChatWebView.init(chatData);
mChatWebView.configue(chatData);
}
private void setupDefaultChatWebViewURL() {
......@@ -220,11 +218,22 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity {
private void registChatRoomPageLoader() {
// 最後のチャットのルーム名
String lastRoomName = PreferenceUtil.getUserPref(getApplicationContext(), AppDefType.UserPrefKey.CHAT_LAST_ROOMNAME, "");
String lastRoomName = PreferenceUtil
.getUserPref(
getApplicationContext(),
AppDefType.UserPrefKey.CHAT_LAST_ROOMNAME,
""
);
// 最後のチャットのルーム
String lastRoomId = PreferenceUtil.getUserPref(getApplicationContext(), AppDefType.UserPrefKey.CHAT_LAST_ROOMID, "");
String fixedParam = "&platform=android&isMobile=true&chatServerUrl=" + ABVEnvironment.getInstance().websocketServerHttpUrl;
String lastRoomId = PreferenceUtil
.getUserPref(
getApplicationContext(),
AppDefType.UserPrefKey.CHAT_LAST_ROOMID,
""
);
String fixedParam = "&platform=android&isMobile=true&chatServerUrl="
+ ABVEnvironment.getInstance().websocketServerHttpUrl;
//ページをロード
if (chatData.roomId != 0 && chatData.roomName != null) { // by push message
try {
......@@ -237,25 +246,38 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity {
chatData.roomType = communicationLogic.getChatRoom(integerRoomId).type.toString();
}
if (StringUtil.isNullOrEmpty(chatData.getStrCollaborationType())) {
String parameterData = "sid=" + chatData.sid + "&loginId=" + chatData.loginId + "&shopName=" + chatData.shopName + "&roomId=" + chatData.roomId + "&roomName=" + chatData.roomName + fixedParam;
String parameterData = "sid=" + chatData.sid
+ "&loginId=" + chatData.loginId
+ "&shopName=" + chatData.shopName
+ "&roomId=" + chatData.roomId
+ "&roomName=" + chatData.roomName
+ fixedParam;
mChatWebView.postUrl(ABookCommConstants.CHAT_ROOM_PAGE_URL, parameterData.getBytes());
} else {
chatData.setCollaborationJoinFlg(ABookCommConstants.FLAG.COLLABORATION_JOIN_FLG.INVITE);
try {
AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).joinCollaboration(chatData.sid, chatData.roomId.intValue());
} catch (NetworkDisconnectedException e) {
e.printStackTrace();
} catch (AcmsException e) {
AcmsClient
.getInstance(ABVEnvironment.getInstance().networkAdapter)
.joinCollaboration(chatData.sid, chatData.roomId.intValue());
} catch (NetworkDisconnectedException | AcmsException e) {
e.printStackTrace();
}
moveCollaborationScreen(Integer.parseInt(chatData.getStrCollaborationType()));
}
} else { // Chat
if (lastRoomName.length() > 0 && lastRoomId.length() > 0) {
String parameterData = "sid=" + chatData.sid + "&loginId=" + chatData.loginId + "&shopName=" + chatData.shopName + "&roomId=" + lastRoomId + "&roomName=" + lastRoomName + fixedParam;
String parameterData = "sid=" + chatData.sid
+ "&loginId=" + chatData.loginId
+ "&shopName=" + chatData.shopName
+ "&roomId=" + lastRoomId
+ "&roomName=" + lastRoomName
+ fixedParam;
mChatWebView.postUrl(chatWebviewUrl, parameterData.getBytes());
} else {
String parameterData = "sid=" + chatData.sid + "&loginId=" + chatData.loginId + "&shopName=" + chatData.shopName + fixedParam;
String parameterData = "sid=" + chatData.sid
+ "&loginId=" + chatData.loginId
+ "&shopName=" + chatData.shopName
+ fixedParam;
mChatWebView.postUrl(chatWebviewUrl, parameterData.getBytes());
}
}
......@@ -274,10 +296,10 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity {
public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, FileChooserParams fileChooserParams) {
boolean result = false;
// 画像が選択された場合
if (fileChooserParams.getAcceptTypes()[0].toLowerCase().indexOf(ABookKeys.IMAGE) != -1) {
if (fileChooserParams.getAcceptTypes()[0].toLowerCase().contains(ABookKeys.IMAGE)) {
result = startCameraIntent(ABOOK_CHECK_TASK_IMAGE, "Camera", ABookKeys.IMAGE, true);
// 動画が選択された場合
} else if (fileChooserParams.getAcceptTypes()[0].toLowerCase().indexOf(ABookKeys.VIDEO) != -1) {
} else if (fileChooserParams.getAcceptTypes()[0].toLowerCase().contains(ABookKeys.VIDEO)) {
result = startCameraIntent(ABOOK_CHECK_TASK_VIDEO, "Camera", ABookKeys.VIDEO, true);
}
if (result) {
......@@ -293,9 +315,8 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity {
// message.equals で、 fermi側のHTMLを解析して、処理を分けている。
@Override
public boolean onJsAlert(WebView view, String url, String message, final JsResult result) {
if (mChatWebView.getUrl() != null && mChatWebView.getUrl().equals(ABookCommConstants.COLLABORATION_PAGE_URL)) {
mChatWebView.loadUrl("javascript:coview_api.HeartBeatUser(globalUserInfo.loginId);");
}
mChatWebView.extendHeartBeatIfNeeded();
if (myAlertDialog != null && myAlertDialog.isShowing()) {
result.confirm();
return true;
......@@ -326,13 +347,13 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity {
} else if (message.equals("SC_FORBIDDEN")) {
message = getString(R.string.msg_error_chat_room_sc_forbidden);
} else if (message.contains("Send owner complete")) {
mChatWebView.loadUrl("javascript:$('#userNameCardInCollaboration').modal('hide');");
mChatWebView.hideNameCardInCollaboaration();
result.confirm();
return true;
} else if (message.contains("REJECT for owner user")) {
mChatWebView.loadUrl("javascript:$('#userNameCardInCollaboration').modal('hide');");
mChatWebView.loadUrl("javascript:$('#hostRequestModal').modal('hide');");
mChatWebView.loadUrl("javascript:$('#userNameCardInCollaboration').modal('hide');");
mChatWebView.hideNameCardInCollaboaration();
mChatWebView.hideHostRequestModal();
mChatWebView.hideNameCardInCollaboaration();
message = getString(R.string.msg_rejected_by_host);
} else if (message.contains("Invalid Parameters")) {
message = getString(R.string.msg_invalid_parameters);
......@@ -344,7 +365,8 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity {
final String tempMessage = message;
ABookAlertDialog dialog = AlertDialogUtil.createAlertDialog(ChatWebViewActivity.this, R.string.app_name);
ABookAlertDialog dialog = AlertDialogUtil
.createAlertDialog(ChatWebViewActivity.this, R.string.app_name);
dialog.setMessage(message);
dialog.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
......@@ -357,8 +379,10 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity {
public void onDismiss(DialogInterface dialog) {
// サーバと接続された場合、チャット画面を閉じる
if (tempMessage.equals(getString(R.string.msg_error_chat_disconnected)) || tempMessage.equals(getString(R.string.msg_error_chat_room_sc_forbidden))) {
mChatWebView.loadUrl("javascript:ReverseDelegate.leaveRoom()");
if (tempMessage.equals(getString(R.string.msg_error_chat_disconnected))
|| tempMessage.equals(getString(R.string.msg_error_chat_room_sc_forbidden)))
{
mChatWebView.leaveRoom();
finish();
} else if (tempMessage.equals(getString(R.string.msg_error_chat_join))) {
finish();
......@@ -369,7 +393,7 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity {
mChatWebView.loadUrl(ABookCommConstants.CHAT_PAGE_URL);
}
} else if (tempMessage.equals(getString(R.string.error_fail_record))) {
mChatWebView.loadUrl("javascript:recordFinished()");
mChatWebView.recordFinished();
}
}
});
......@@ -398,9 +422,9 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity {
} else if (message.equals("방장 권한을 전달 받으시겠습니까?")){
message = getString(R.string.msg_confirm_send_host_change);
if (chatData.getHostRequestFlg() == 1) {
mChatWebView.loadUrl("javascript:penOff();");
mChatWebView.loadUrl("javascript:$('#hostRequestModal').modal('hide');");
mChatWebView.loadUrl("javascript:$('#userNameCardInCollaboration').modal('hide');");
mChatWebView.penOff();
mChatWebView.hideHostRequestModal();
mChatWebView.hideNameCardInCollaboaration();
if (meetingManager.isConnected() && meetingManager.isSubscribed()) {
sendPromoteRequest();
}
......@@ -412,47 +436,65 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity {
} else if (message.contains("Create room anyway?")) {
message = getString(R.string.msg_destroy_exist_collaboration);
}
final ABookAlertDialog confirmAlert = AlertDialogUtil.createAlertDialog(ChatWebViewActivity.this, R.string.app_name);
final ABookAlertDialog confirmAlert = AlertDialogUtil
.createAlertDialog(ChatWebViewActivity.this, R.string.app_name);
confirmAlert.setMessage(message);
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();
}
});
confirmAlert.setButton(
DialogInterface.BUTTON_POSITIVE,
getResources().getString(R.string.move),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
result.confirm();
}
}
);
} else if (message.equals(getString(R.string.msg_confirm_send_host_change))){
confirmAlert.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(R.string.confirm), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
mChatWebView.loadUrl("javascript:penOff();");
mChatWebView.loadUrl("javascript:$('#hostRequestModal').modal('hide');");
mChatWebView.loadUrl("javascript:$('#userNameCardInCollaboration').modal('hide');");
if (meetingManager.isConnected() && meetingManager.isSubscribed()) {
sendPromoteRequest();
confirmAlert.setButton(
DialogInterface.BUTTON_POSITIVE,
getResources().getString(R.string.confirm),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
mChatWebView.penOff();
mChatWebView.hideHostRequestModal();
mChatWebView.hideNameCardInCollaboaration();
if (meetingManager.isConnected() && meetingManager.isSubscribed()) {
sendPromoteRequest();
}
result.confirm();
}
}
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_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) {
result.cancel();
}
});
confirmAlert.setButton(
DialogInterface.BUTTON_NEGATIVE,
getResources().getString(R.string.cancel),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
result.cancel();
}
}
);
confirmAlert.setCancelable(false);
showAlertDialog(confirmAlert);
if (message.equals(getString(R.string.msg_confirm_send_host_change))
|| message.contains(getString(R.string.host_confirm))
|| message.equals(getString(R.string.msg_confirm_share_image))) {
|| message.equals(getString(R.string.msg_confirm_share_image)))
{
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
......@@ -478,9 +520,11 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity {
private void addDownloadListener() {
mChatWebView.setDownloadListener(new DownloadListener() {
@Override
public void onDownloadStart(String url, String userAgent,
String contentDisposition, String mimetype,
long contentLength) {
public void onDownloadStart(
String url, String userAgent,
String contentDisposition, String mimetype,
long contentLength)
{
Uri uri = Uri.parse(url);
DownloadManager.Request request = new DownloadManager.Request(uri);
......@@ -499,8 +543,11 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity {
if (dm != null) {
dm.enqueue(request);
}
Toast.makeText(getApplicationContext(), getString(R.string.download_start), //To notify the Client that the file is being downloaded
Toast.LENGTH_LONG).show();
Toast.makeText(
getApplicationContext(),
getString(R.string.download_start), //To notify the Client that the file is being downloaded
Toast.LENGTH_LONG
).show();
}
});
}
......@@ -510,22 +557,25 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity {
receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
ConnectivityManager connectivityManager = (ConnectivityManager) getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE);
ConnectivityManager connectivityManager = (ConnectivityManager) getApplicationContext()
.getSystemService(Context.CONNECTIVITY_SERVICE);
if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(intent.getAction())) {
mChatWebView.loadUrl("javascript:Common.dismissLoadingIndicator()");
mChatWebView.dismissLoadingIndicator();
}
if (intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
if (networkInfo == null || !networkInfo.isConnectedOrConnecting()) {
chatData.setIsOnline(false);
mChatWebView.loadUrl("javascript:Common.refreshForOffline();");
mChatWebView.refreshForOffline();
} else {
chatData.setIsOnline(true);
mChatWebView.loadUrl("javascript:Common.refreshForOnline();");
if (mChatWebView.getUrl() != null && mChatWebView.getUrl().equals(ABookCommConstants.CHAT_ROOM_PAGE_URL)) {
mChatWebView.loadUrl("javascript:window.location.reload();");
mChatWebView.refreshForOnline();
if (mChatWebView.getUrl() != null
&& mChatWebView.getUrl().equals(ABookCommConstants.CHAT_ROOM_PAGE_URL))
{
mChatWebView.windowReload();
}
}
}
......@@ -587,12 +637,15 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity {
String fileName = new File(Objects.requireNonNull(uri.getPath())).getName();
// イメージをダウンロードする(png, jpg, jpeg, mp4, mov)
if (url.toLowerCase().endsWith(".png") || url.toLowerCase().endsWith(".jpg") || url.toLowerCase().endsWith(".jpeg")
|| url.toLowerCase().endsWith(".mov") || url.toLowerCase().endsWith(".mp4")) {
if (url.toLowerCase().endsWith(".png")
|| url.toLowerCase().endsWith(".jpg")
|| url.toLowerCase().endsWith(".jpeg")
|| url.toLowerCase().endsWith(".mov")
|| url.toLowerCase().endsWith(".mp4"))
{
view.loadUrl("javascript:Common.showLoadingIndicator()");
DownloadManager mdDownloadManager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
DownloadManager.Request request = new DownloadManager.Request(
Uri.parse(url));
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
File destinationFile = new File(Environment.getExternalStorageDirectory(), fileName);
request.setDescription("Downloading ...");
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
......@@ -622,140 +675,98 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity {
// 保存するファイルをjpgに固定する
public String getFileName(String url) {
String filenameWithoutExtension = "";
filenameWithoutExtension = String.valueOf(System.currentTimeMillis()
+ ".jpg");
return filenameWithoutExtension;
return System.currentTimeMillis() + ".jpg";
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Uri[] result = null;
Uri dataUri = null;
if (data != null && resultCode == RESULT_OK) {
String dataString = data.getDataString();
if (dataString != null) {
dataUri = Uri.parse(dataString);
result = new Uri[]{dataUri};
}
}
if (requestCode == ABOOK_CHECK_TASK_IMAGE) {
if (mUploadMessage == null) {
return;
}
// 画像
try {
if (dataUri == null) {
dataUri = imageUri;
}
Uri responseUri = attachmentImageProcessing(dataUri);
if (responseUri != null) {
mUploadMessage.onReceiveValue(new Uri[]{responseUri});
} else {
mUploadMessage.onReceiveValue(null);
}
} catch (Exception e) {
Logger.e(TAG, e);
mUploadMessage.onReceiveValue(null);
ErrorMessage.showErrorMessageToast(getApplicationContext(), ErrorCode.E107);
}
activityResultReceivedImage(dataUri);
} else if (requestCode == ABOOK_CHECK_TASK_VIDEO) {
if (mUploadMessage == null) {
return;
}
if (dataUri != null) {
mChatWebView.loadChatViewUrl("javascript:Common.showLoadingIndicator();");
Cursor cursor = getContentResolver().query(dataUri, null, null, null, null);
cursor.moveToNext();
final String filePath = cursor.getString(cursor.getColumnIndex("_data"));
cursor.close();
Runnable r = new Runnable() {
@Override
public void run() {
try {
//CallBack
Runnable callBack = new Runnable() {
@Override
public void run() {
runOnUiThread(new Runnable() {
@Override
public void run() {
mChatWebView.loadUrl("javascript:ChatMediaHandler.videoEncodeEnd('" +encodedFilePath + "')");
}
});
}
};
Context c = getApplicationContext();
File file = new File(filePath);
String encodedPath = new VideoEncoder().changeResolution(file, callBack);
encodedFilePath = encodedPath;
} catch (Throwable throwable) {
mChatWebView.loadUrl("javascript:ChatMediaHandler.videoEncodeFail();)");
}
}
};
r.run();
}
mUploadMessage.onReceiveValue(null);
activityResultReceivedMovie(dataUri);
}
mUploadMessage = null;
}
public static Uri getImageContentUri(Context context, File file) {
if (!file.exists()) {
return null;
private void activityResultReceivedImage(Uri dataUri) {
if (mUploadMessage == null) {
return;
}
String filePath = file.getAbsolutePath();
Cursor cursor = context.getContentResolver().query(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
new String[] {BaseColumns._ID},
MediaStore.MediaColumns.DATA + "=? ",
new String[] { filePath }, null);
if (cursor != null && cursor.moveToFirst()) {
int id = cursor.getInt(cursor
.getColumnIndex(BaseColumns._ID));
Uri baseUri = Uri.parse("content://media/external/video/media");
return Uri.withAppendedPath(baseUri, "" + id);
} else {
if (!file.exists()) { return null; }
ContentValues values = new ContentValues();
values.put(MediaStore.MediaColumns.DATA, filePath);
return context.getContentResolver().insert(
MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
values);
// 画像
try {
if (dataUri == null) {
dataUri = imageUri;
}
Uri responseUri = attachmentImageProcessing(dataUri);
if (responseUri != null) {
mUploadMessage.onReceiveValue(new Uri[]{responseUri});
} else {
mUploadMessage.onReceiveValue(null);
}
} catch (Exception e) {
Logger.e(TAG, e);
mUploadMessage.onReceiveValue(null);
ErrorMessage.showErrorMessageToast(getApplicationContext(), ErrorCode.E107);
}
}
/**
* 未読のプッシュメッセージが存在するかチェック
* @param pushMessageDtoList チェックするリスト
* @return
*/
private boolean checkUnReadCommunication(List<PushMessageDto> pushMessageDtoList) {
boolean existUnreadFlg = false;
for (PushMessageDto pushMessageDto : pushMessageDtoList) {
if (!pushMessageDto.readingFlg) {
existUnreadFlg = true;
break;
}
private void activityResultReceivedMovie(Uri dataUri) {
if (mUploadMessage == null) {
return;
}
return existUnreadFlg;
if (dataUri != null) {
mChatWebView.showLoadingIndicator();
Cursor cursor = getContentResolver().query(dataUri, null, null, null, null);
cursor.moveToNext();
final String filePath = cursor.getString(cursor.getColumnIndex("_data"));
cursor.close();
Runnable r = new Runnable() {
@Override
public void run() {
try {
//CallBack
Runnable callBack = new Runnable() {
@Override
public void run() {
runOnUiThread(new Runnable() {
@Override
public void run() {
mChatWebView.finishedVideoEncoding(encodedFilePath);
}
});
}
};
Context c = getApplicationContext();
File file = new File(filePath);
encodedFilePath = new VideoEncoder().changeResolution(file, callBack);
} catch (Throwable throwable) {
mChatWebView.failedVideoEncoding();
}
}
};
r.run();
}
mUploadMessage.onReceiveValue(null);
}
/**
* 作業一覧へ遷移
*/
public void backToHome() {
mChatWebView.loadUrl("javascript:ReverseDelegate.leaveRoom()");
mChatWebView.leaveRoom();
exitAndDeleteMeetingRoom();
finish();
Intent intent = new Intent();
......@@ -772,10 +783,11 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity {
}
public void finishPIPmode() {
if (isPIP) {
getApplication().startActivity(new Intent(this, ChatWebViewActivity.class)
.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK));
}
if (!isPIP) { return; }
getApplication()
.startActivity(new Intent(this, ChatWebViewActivity.class)
.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK)
);
}
public void startPIPmode() {
......@@ -822,15 +834,16 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity {
public void moveCollaborationScreen(Integer collaborationType) {
if (collaborationType.equals(ABookCommConstants.FLAG.COLLABORATION_TYPE.DOCUMENT) && !isValidVersion()) {
mChatWebView.loadUrl("javascript:alert(getLocalizedString('not_support_version'));");
mChatWebView.showAlert("getLocalizedString('not_support_version')");
return;
}
chatData.setJoinCollaborationType(collaborationType.intValue());
chatData.setJoinCollaborationType(collaborationType);
mChatWebView.loadChatViewUrl(ABookCommConstants.COLLABORATION_PAGE_URL);
}
public boolean deleteFavoriteGroup(String groupId) throws NetworkDisconnectedException, AcmsException {
boolean result = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter)
boolean result = AcmsClient
.getInstance(ABVEnvironment.getInstance().networkAdapter)
.deleteFavoriteGroup(chatData.sid, Integer.parseInt(groupId));
if (!result) { return false; }
......@@ -841,29 +854,24 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity {
return true;
}
private void updateFavoriteUser() throws NetworkDisconnectedException, AcmsException {
GetFavoriteUserJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getFavoriteUser(chatData.sid);
communicationLogic.updateFavoriteUser(resultJson.favoriteUserIds);
}
@Override
public void onPictureInPictureModeChanged (boolean isInPictureInPictureMode, Configuration newConfig) {
isPIP = isInPictureInPictureMode;
if (isInPictureInPictureMode) {
mChatWebView.loadUrl("javascript:$('.pip_indicator').removeClass('none');");
} else {
if (isStop) {
mChatWebView.loadUrl("javascript:CoviewBridge.exitCollaboration();");
Intent intent = new Intent();
Activity currentActivity = ActivityHandlingHelper.getInstance().getCurrentActivity();
intent.setClass(currentActivity, OperationListActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent, NaviConsts.Left);
}
mChatWebView.loadUrl("javascript:$('.pip_indicator').addClass('none');");
if (!meetingManager.isConnected()) {
mChatWebView.loadUrl("javascript:$('.start_pip_btn').addClass('none');");
}
mChatWebView.removePIPIndicator();
return;
}
if (isStop) {
mChatWebView.exitCollaboration();
Intent intent = new Intent();
Activity currentActivity = ActivityHandlingHelper.getInstance().getCurrentActivity();
intent.setClass(currentActivity, OperationListActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent, NaviConsts.Left);
}
mChatWebView.addPIPIndicator();
if (!meetingManager.isConnected()) {
mChatWebView.addPIPButton();
}
}
......@@ -909,10 +917,8 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity {
f.createNewFile();
Bitmap bitmap = resultBitmap;
ByteArrayOutputStream bos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 0, bos);
resultBitmap.compress(Bitmap.CompressFormat.PNG, 0, bos);
byte[] bitmapData = bos.toByteArray();
FileOutputStream fos = new FileOutputStream(f);
......@@ -930,7 +936,7 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity {
isStop = false;
super.onResume();
if (mChatWebView.getUrl() != null && mChatWebView.getUrl().equals(ABookCommConstants.CHAT_ROOM_PAGE_URL)) {
mChatWebView.loadUrl("javascript:CHAT_SOCKET.socketCheck();");
mChatWebView.socketCheck();
}
}
......@@ -953,20 +959,15 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity {
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
boolean eventPrevent = false;
switch (keyCode) {
case KeyEvent.KEYCODE_BACK:
backToHome();
eventPrevent = true;
break;
if (keyCode == KeyEvent.KEYCODE_BACK) {
backToHome();
eventPrevent = true;
}
return eventPrevent;
}
public boolean isValidVersion() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
return false;
}
return true;
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.O;
}
public void sendPromoteRequest() {
......@@ -974,7 +975,13 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity {
JSONObject json = new JSONObject();
json.put(MeetingManager.ID, meetingManager.getSkey());
json.put(MeetingManager.LOGIN_ID, ABVDataCache.getInstance().getMemberInfo().loginId);
meetingManager.sendWs(MeetingManager.CMD_PRESENTERREQUEST, contentViewActivity != null ? contentViewActivity.getContentId() : 0, null, null, json);
meetingManager.sendWs(
MeetingManager.CMD_PRESENTERREQUEST,
contentViewActivity != null ? contentViewActivity.getContentId() : 0,
null,
null,
json
);
}
public void setSelectedUserIdList(String userList) {
......@@ -995,12 +1002,21 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity {
chatData.updateGroupInfoFromServer();
}
public void createChatRoom(String roomType, String userIdList, String encodedRoomName, String screenFlg, boolean isVoice) throws NetworkDisconnectedException, AcmsException {
CreatedRoomJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).createRoom(chatData.sid, roomType, userIdList, encodedRoomName, chatData.loginId);
public void createChatRoom(
String roomType,
String userIdList,
String encodedRoomName,
String screenFlg,
boolean isVoice)
throws NetworkDisconnectedException, AcmsException
{
CreatedRoomJSON resultJson = AcmsClient
.getInstance(ABVEnvironment.getInstance().networkAdapter)
.createRoom(chatData.sid, roomType, userIdList, encodedRoomName, chatData.loginId);
if (ABookCommConstants.FLAG.SCREEN_FLG.MAKE_ROOM.equals(Integer.parseInt(screenFlg))) {
final ChatRoomDto chatRoomDto = communicationLogic.getChatRoom(resultJson.chatRoomDto.chatRoomId);
if (chatRoomDto != null) {
mChatWebView.loadChatViewUrl(String.format("javascript:ReverseDelegate.displayExistRoom('%s');", chatRoomDto.chatRoomId.toString()));
mChatWebView.displayExistRoom(chatRoomDto.chatRoomId);
return;
}
}
......@@ -1011,7 +1027,7 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity {
if (isVoice) {
chatData.roomId = chatRoomId.longValue();
chatData.roomName = chatRoomName;
mChatWebView.loadChatViewUrl(String.format("javascript:Common.startCollaboration('%s');", ABookCommConstants.FLAG.COLLABORATION_TYPE.AUDIO));
mChatWebView.startAudioCollaboration();
} else {
joinRoom(chatRoomId.toString(), chatRoomName);
}
......@@ -1034,12 +1050,14 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity {
}
public void inviteUsers(String userIds) throws NetworkDisconnectedException, AcmsException {
final UserInviteResultJSON result = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).inviteUsers(chatData.sid, chatData.roomId.intValue(), chatData.roomName, userIds);
final UserInviteResultJSON result = AcmsClient
.getInstance(ABVEnvironment.getInstance().networkAdapter)
.inviteUsers(chatData.sid, chatData.roomId.intValue(), chatData.roomName, userIds);
if (result.roomId == null) {
communicationLogic.addUserInRoom(userIds, chatData.roomId.intValue());
mChatWebView.loadChatViewUrl(ABookCommConstants.CHAT_ROOM_PAGE_URL);
} else {
mChatWebView.loadChatViewUrl(String.format("javascript:ReverseDelegate.displayExistRoom('%s');", result.roomId.toString()));
mChatWebView.displayExistRoom(result.roomId);
}
}
......@@ -1058,7 +1076,9 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity {
public void updateMessages(String roomId) throws NetworkDisconnectedException, AcmsException {
SharedPreferences pref = getSharedPreferences(ABookCommConstants.TAG, MODE_PRIVATE);
String lastUpdatedDate = pref.getString(ABookCommConstants.KEY.MESSAGE_UPDATED_DATE + roomId, DEFAULT_CHECKSUM);
MessageInfoListJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getMessages(chatData.sid, roomId, null, lastUpdatedDate);
MessageInfoListJSON resultJson = AcmsClient
.getInstance(ABVEnvironment.getInstance().networkAdapter)
.getMessages(chatData.sid, roomId, null, lastUpdatedDate);
for (ChatMessageDto chatMessageDto : resultJson.chatMessageDtoArrayList) {
chatMessageDto.chatRoomId = Integer.parseInt(roomId);
}
......@@ -1101,19 +1121,19 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity {
public boolean addFavoriteUser(String shopMemberId) throws AcmsException {
Integer favoriteCount = communicationLogic.getFavoriteCount();
if (favoriteCount >= ABookCommConstants.SIZE.MAX_FAVORITE_COUNT ) {
mChatWebView.loadChatViewUrl("javascript:alert('" + getString(R.string.msg_error_favorites_100_over) + "');");
mChatWebView.showAlert(getString(R.string.msg_error_favorites_100_over));
return false;
} else {
boolean result = false;
try {
result = chatData.insertFavoriteUser(shopMemberId);
if (!result) { return false; }
mChatWebView.loadChatViewUrl("javascript:Common.refreshContactScreen();");
return true;
} catch (NetworkDisconnectedException e) {
mChatWebView.loadChatViewUrl("javascript:alert('" + getString(R.string.msg_eroor_network_offline) + "');");
}
}
try {
boolean result = chatData.insertFavoriteUser(shopMemberId);
if (!result) { return false; }
mChatWebView.refreshContactScreen();
return true;
} catch (NetworkDisconnectedException e) {
mChatWebView.showAlert(getString(R.string.msg_eroor_network_offline));
}
return false;
}
......@@ -1123,10 +1143,10 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity {
if (!result) {
return false;
}
mChatWebView.loadChatViewUrl("javascript:Common.refreshContactScreen();");
mChatWebView.refreshContactScreen();
return true;
} catch (NetworkDisconnectedException e) {
mChatWebView.loadChatViewUrl("javascript:alert('" + getString(R.string.msg_eroor_network_offline) + "');");
mChatWebView.showAlert(getString(R.string.msg_eroor_network_offline));
}
return false;
}
......@@ -1134,35 +1154,34 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity {
public boolean addFavoriteGroup(String groupId) throws AcmsException {
Integer favoriteCount = communicationLogic.getFavoriteCount();
if (favoriteCount >= ABookCommConstants.SIZE.MAX_FAVORITE_COUNT) {
mChatWebView.loadChatViewUrl("javascript:alert('" + getString(R.string.msg_error_favorites_100_over) + "');");
mChatWebView.showAlert(getString(R.string.msg_error_favorites_100_over));
return false;
} else {
boolean result = false;
try {
result = chatData.insertFavoriteGroup(groupId);
if (!result) {
return false;
}
mChatWebView.loadChatViewUrl("javascript:Common.refreshContactScreen();");
return true;
} catch (NetworkDisconnectedException e) {
mChatWebView.loadChatViewUrl("javascript:alert('" + getString(R.string.msg_eroor_network_offline) + "');");
}
try {
boolean result = chatData.insertFavoriteGroup(groupId);
if (!result) {
return false;
}
mChatWebView.refreshContactScreen();
return true;
} catch (NetworkDisconnectedException e) {
mChatWebView.showAlert(getString(R.string.msg_eroor_network_offline));
}
return false;
}
public boolean removeFavoriteGroup(String groupId) throws AcmsException {
boolean result = false;
try {
result = deleteFavoriteGroup(groupId);
boolean result = deleteFavoriteGroup(groupId);
if (!result) {
return false;
}
mChatWebView.loadChatViewUrl("javascript:Common.refreshContactScreen();");
mChatWebView.refreshContactScreen();
return true;
} catch (NetworkDisconnectedException e) {
mChatWebView.loadChatViewUrl("javascript:alert('" + getString(R.string.msg_eroor_network_offline) + "');");
mChatWebView.showAlert(getString(R.string.msg_eroor_network_offline));
}
return false;
}
......@@ -1189,30 +1208,29 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity {
meetingManager.join(meetingId, mSkey, chatData.roomId.toString(), true);
meetingManager.setCollaboration(true);
} catch (Exception e) {
mChatWebView.loadUrl("javascript:alert('" + getString(R.string.msg_error_connection_error_meeting_room) + "');");
mChatWebView.showAlert(getString(R.string.msg_error_connection_error_meeting_room));
}
startContentListActivity(true);
return meetingId.intValue();
return meetingId;
}
public void startContentView() throws InterruptedException {
public void startContentView() {
finishBeforeContentListActivity();
PictureInPictureParams.Builder mPipBuilder = new PictureInPictureParams.Builder();
enterPictureInPictureMode(mPipBuilder.build());
meetingManager.close();
try {
connectMeetingServer();
List<MeetingDto> meetingList= meetingManager.getMeetingList(mSkey);
List<MeetingDto> meetingList = meetingManager.getMeetingList(mSkey);
meetingManager.join(chatData.joinMeetingId, mSkey, chatData.roomId.toString(), false);
meetingManager.setCollaboration(true);
} catch (Exception e) {
mChatWebView.loadUrl("javascript:alert('" + getString(R.string.msg_error_connection_error_meeting_room) + "');");
mChatWebView.showAlert(getString(R.string.msg_error_connection_error_meeting_room));
}
startContentListActivity(false);
}
public void joinMeetingRoom(int newMeetingId) throws InterruptedException {
public void joinMeetingRoom(int newMeetingId) {
finishBeforeContentListActivity();
PictureInPictureParams.Builder mPipBuilder = new PictureInPictureParams.Builder();
enterPictureInPictureMode(mPipBuilder.build());
......@@ -1223,7 +1241,7 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity {
meetingManager.join(chatData.joinMeetingId, mSkey, chatData.roomId.toString(), false);
meetingManager.setCollaboration(true);
} catch (Exception e) {
mChatWebView.loadUrl("javascript:alert('" + getString(R.string.msg_error_connection_error_meeting_room) + "');");
mChatWebView.showAlert(getString(R.string.msg_error_connection_error_meeting_room));
}
startContentListActivity(false);
}
......
package jp.agentec.abook.abv.ui.home.view;
import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Build;
import android.view.View;
......@@ -20,7 +21,7 @@ import jp.agentec.abook.abv.ui.home.helper.ActivityHandlingHelper;
public class ChatWebView extends WebView {
private ChatWebViewActivity chatActivity;
private final ChatWebViewActivity chatActivity;
private ChatData chatData;
public ChatWebView(Context context) {
......@@ -28,7 +29,8 @@ public class ChatWebView extends WebView {
chatActivity = (ChatWebViewActivity)context;
}
public void init(ChatData chatData) {
@SuppressLint("SetJavaScriptEnabled")
public void configue(ChatData chatData) {
setOverScrollMode(View.OVER_SCROLL_NEVER); //オーバースクロールしない。
setVerticalScrollBarEnabled(false); //スクロールバーを消す。
addJavascriptInterface(this, "android");
......@@ -121,7 +123,9 @@ public class ChatWebView extends WebView {
@JavascriptInterface
public void test() {
OperationRelatedContentActivity testact = ActivityHandlingHelper.getInstance().getActivity(OperationRelatedContentActivity.class);
OperationRelatedContentActivity testact = ActivityHandlingHelper
.getInstance()
.getActivity(OperationRelatedContentActivity.class);
testact.finish();
}
......@@ -141,7 +145,14 @@ public class ChatWebView extends WebView {
}
@JavascriptInterface
public void createChatRoom(String roomType, String userIdList, String encodedRoomName, String screenFlg, boolean isVoice) throws NetworkDisconnectedException, AcmsException {
public void createChatRoom(
String roomType,
String userIdList,
String encodedRoomName,
String screenFlg,
boolean isVoice)
throws NetworkDisconnectedException, AcmsException
{
chatActivity.createChatRoom(roomType, userIdList, encodedRoomName, screenFlg, isVoice);
}
......@@ -341,17 +352,23 @@ public class ChatWebView extends WebView {
}
@JavascriptInterface
public void joinCollaboration(String collaborationType, String meetingId) throws NetworkDisconnectedException, AcmsException {
public void joinCollaboration(String collaborationType, String meetingId)
throws NetworkDisconnectedException, AcmsException
{
chatActivity.joinCollaboration(collaborationType, meetingId);
}
@JavascriptInterface
public void joinChangedCollaboration(String collaborationType, String meetingId) throws NetworkDisconnectedException, AcmsException {
public void joinChangedCollaboration(String collaborationType, String meetingId)
throws NetworkDisconnectedException, AcmsException
{
chatData.joinChangedCollaboration(collaborationType, meetingId);
}
@JavascriptInterface
public void inviteCollaboration(String inviteUserIds, String collaborationType) throws NetworkDisconnectedException, AcmsException {
public void inviteCollaboration(String inviteUserIds, String collaborationType)
throws NetworkDisconnectedException, AcmsException
{
chatData.inviteCollaboration(inviteUserIds, collaborationType);
}
......@@ -400,7 +417,6 @@ public class ChatWebView extends WebView {
return chatData.getUserListByLoginId(loginIdList);
}
@JavascriptInterface
public int createContentView() {
return chatActivity.createContentView();
......@@ -442,7 +458,9 @@ public class ChatWebView extends WebView {
}
@JavascriptInterface
public void changeCollaboration(int changeCollaborationType, int meetingId) throws NetworkDisconnectedException, AcmsException {
public void changeCollaboration(int changeCollaborationType, int meetingId)
throws NetworkDisconnectedException, AcmsException
{
chatData.changeCollaboration(changeCollaborationType, meetingId);
}
......@@ -485,7 +503,9 @@ public class ChatWebView extends WebView {
}
@JavascriptInterface
public void updatePreMessage(String messageId) throws NetworkDisconnectedException, AcmsException {
public void updatePreMessage(String messageId)
throws NetworkDisconnectedException, AcmsException
{
chatData.updatePreMessage(messageId);
}
......@@ -522,4 +542,98 @@ public class ChatWebView extends WebView {
}
});
}
public void showAlert(String message) {
loadChatViewUrl("javascript:alert('" + message + "');");
}
public void extendHeartBeat() {
loadUrl("javascript:coview_api.HeartBeatUser(globalUserInfo.loginId);");
}
public void extendHeartBeatIfNeeded() {
if (getUrl() != null && getUrl().equals(ABookCommConstants.COLLABORATION_PAGE_URL)) {
extendHeartBeat();
}
}
public void hideNameCardInCollaboaration() {
loadUrl("javascript:$('#userNameCardInCollaboration').modal('hide');");
}
public void hideHostRequestModal() {
loadUrl("javascript:$('#hostRequestModal').modal('hide');");
}
public void leaveRoom() {
loadUrl("javascript:ReverseDelegate.leaveRoom()");
}
public void recordFinished() {
loadUrl("javascript:recordFinished()");
}
public void penOff() {
loadUrl("javascript:penOff();");
}
public void showLoadingIndicator() {
loadChatViewUrl("javascript:Common.showLoadingIndicator();");
}
public void dismissLoadingIndicator() {
loadUrl("javascript:Common.dismissLoadingIndicator()");
}
public void refreshForOffline() {
loadUrl("javascript:Common.refreshForOffline();");
}
public void refreshForOnline() {
loadUrl("javascript:Common.refreshForOnline();");
}
public void windowReload() {
loadUrl("javascript:window.location.reload();");
}
public void finishedVideoEncoding(String encodedFilePath) {
loadUrl("javascript:ChatMediaHandler.videoEncodeEnd('" +encodedFilePath + "')");
}
public void failedVideoEncoding() {
loadUrl("javascript:ChatMediaHandler.videoEncodeFail();)");
}
public void removePIPIndicator() {
loadUrl("javascript:$('.pip_indicator').removeClass('none');");
}
public void exitCollaboration() {
loadUrl("javascript:CoviewBridge.exitCollaboration();");
}
public void addPIPIndicator() {
loadUrl("javascript:$('.pip_indicator').addClass('none');");
}
public void addPIPButton() {
loadUrl("javascript:$('.start_pip_btn').addClass('none');");
}
public void socketCheck() {
loadUrl("javascript:CHAT_SOCKET.socketCheck();");
}
public void displayExistRoom(Integer chatRoomId) {
loadChatViewUrl(String.format("javascript:ReverseDelegate.displayExistRoom('%s');", chatRoomId.toString()));
}
public void startAudioCollaboration() {
loadChatViewUrl(String.format("javascript:Common.startCollaboration('%s');", ABookCommConstants.FLAG.COLLABORATION_TYPE.AUDIO ));
}
public void refreshContactScreen() {
loadChatViewUrl("javascript:Common.refreshContactScreen();");
}
}
package jp.agentec.abook.abv.ui.viewer.activity;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.provider.MediaStore;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.LinearLayout;
......@@ -16,45 +10,11 @@ import android.widget.ProgressBar;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import jp.agentec.abook.abv.bl.acms.client.json.content.ContentJSON;
import jp.agentec.abook.abv.bl.acms.type.OperationType;
import jp.agentec.abook.abv.bl.common.ABVEnvironment;
import jp.agentec.abook.abv.bl.common.Callback;
import jp.agentec.abook.abv.bl.common.CommonExecutor;
import jp.agentec.abook.abv.bl.common.Constant;
import jp.agentec.abook.abv.bl.common.constant.ABookKeys;
import jp.agentec.abook.abv.bl.common.exception.ABVExceptionCode;
import jp.agentec.abook.abv.bl.common.exception.AcmsException;
import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.bl.data.dao.AbstractDao;
import jp.agentec.abook.abv.bl.data.dao.ContentDao;
import jp.agentec.abook.abv.bl.dto.ContentDto;
import jp.agentec.abook.abv.bl.logic.AbstractLogic;
import jp.agentec.abook.abv.bl.logic.ContentObjectLogLogic;
import jp.agentec.abook.abv.bl.logic.OperationLogic;
import jp.agentec.abook.abv.cl.util.ContentLogUtil;
import jp.agentec.abook.abv.cl.util.PreferenceUtil;
import jp.agentec.abook.abv.launcher.android.R;
import jp.agentec.abook.abv.ui.common.activity.ABVAuthenticatedActivity;
import jp.agentec.abook.abv.ui.common.activity.ABVContentViewActivity;
import jp.agentec.abook.abv.ui.common.appinfo.AppDefType;
import jp.agentec.abook.abv.ui.common.constant.ErrorCode;
import jp.agentec.abook.abv.ui.common.constant.ErrorMessage;
import jp.agentec.abook.abv.ui.common.dialog.ABookAlertDialog;
import jp.agentec.abook.abv.ui.common.util.AlertDialogUtil;
import jp.agentec.abook.abv.ui.common.util.PatternStringUtil;
import jp.agentec.abook.abv.ui.home.activity.ABookSettingActivity;
import jp.agentec.abook.abv.ui.home.helper.ABookCheckWebViewHelper;
import jp.agentec.abook.abv.ui.home.helper.ABookPermissionHelper;
import jp.agentec.abook.abv.ui.home.helper.ActivityHandlingHelper;
import jp.agentec.abook.abv.ui.home.helper.ContentViewHelper;
import jp.agentec.adf.util.DateTimeFormat;
import jp.agentec.adf.util.DateTimeUtil;
import jp.agentec.adf.util.FileUtil;
public class CommunicationWebViewActivity extends ABVAuthenticatedActivity {
private static final String TAG = "CommunicationWebViewActivity";
......
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