void FabSend_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtContent.Text.Trim())) { if (!ViewModel.CurrentlyOpenDTO.OtherUserActivate) { DialogUtils.ShowOKDialog(this, "Warning", "User is inactive to receive message"); return; } var model = new AddPrivateChatHistoryItemRequest() { SENDER_ID = ViewModel.CurrentlyOpenDTO.MyUserId, OTHER_USER_ID = ViewModel.CurrentlyOpenDTO.OtherUserId, MSG_TYPE = GlobalConstants.CHAT_HISTORY_ITEM_TEXT, MSG_CONTENT = txtContent.Text.Trim(), THREAD_ID = ViewModel.CurrentlyOpenDTO.EntryID }; if (CrossConnectivity.Current.IsConnected) { ViewModel.SendPrivateMessageCommand.Execute(model); } else { DialogUtils.ShowOKDialog(this, @"Warning", @"No Internet Connection"); } RunOnUiThread(() => { txtContent.Text = ""; }); } }
void RecDialog_OnFinishRecording(object sender, StringEventArgs e) { if (!string.IsNullOrEmpty(e.FilePath) && CrossConnectivity.Current.IsConnected) { var filePath = ChatDetailViewUtils.SetNewFileNameOfVoice(e.FilePath); ViewModel.AudioFileToBeSent.Add(filePath); var ItemModel = new AddPrivateChatHistoryItemRequest() { SENDER_ID = ViewModel.CurrentlyOpenDTO.MyUserId, OTHER_USER_ID = ViewModel.CurrentlyOpenDTO.OtherUserId, MSG_TYPE = GlobalConstants.CHAT_HISTORY_ITEM_AUDIO, MSG_CONTENT = "", THREAD_ID = ViewModel.CurrentlyOpenDTO.EntryID }; var bArray = File.ReadAllBytes(filePath); var fileName = Path.GetFileName(filePath); var requestModel = new AddPrivateVoiceMessageItemRequest() { FilebArray = bArray, FileName = fileName, ItemRequest = ItemModel }; ViewModel.SendVoiceMessageCommand.Execute(requestModel); } else { DialogUtils.ShowOKDialog(this, @"Warning", @"No Internet Connection"); } }
async void AttachVideoChooseHandler(object sender, EventArgs e) { RemoveAttachToolBoxFragment(); if (!CrossConnectivity.Current.IsConnected) { DialogUtils.ShowOKDialog(this, @"Warning", @"No Internet Connection"); return; } if (!ViewModel.CurrentlyOpenDTO.OtherUserActivate) { DialogUtils.ShowOKDialog(this, "Warning", "User is inactive to receive message"); return; } var PermStorage = await CheckNecessaryPermissions(Plugin.Permissions.Abstractions.Permission.Storage); var PermMic = await CheckNecessaryPermissions(Plugin.Permissions.Abstractions.Permission.Microphone); if (PermStorage && CrossConnectivity.Current.IsConnected) { if (!CrossMedia.Current.IsPickVideoSupported) { DialogUtils.ShowOKDialog(this, @"Warning", @"No gallery available."); return; } if (ViewModel.PhotoFileToBeSent == null) { ViewModel.PhotoFileToBeSent = new List <MediaFile>(); } var mediaFile = await CrossMedia.Current.PickVideoAsync(); if (mediaFile != null) { if (new FileInfo(mediaFile.Path).Length / 1048576 > 45) { DialogUtils.ShowOKDialog(this, @"Warning", @"Large File."); return; } ViewModel.PhotoFileToBeSent.Add(mediaFile); var model = new AddPrivateChatHistoryItemRequest() { SENDER_ID = ViewModel.CurrentlyOpenDTO.MyUserId, OTHER_USER_ID = ViewModel.CurrentlyOpenDTO.OtherUserId, MSG_TYPE = GlobalConstants.CHAT_HISTORY_ITEM_VIDEO, MSG_CONTENT = "", THREAD_ID = ViewModel.CurrentlyOpenDTO.EntryID }; ViewModel.SendPrivateMessageCommand.Execute(model); } } else { ViewModel.PhotoFileToBeSent.Clear(); } }
async void AttachImageTakeHandler(object sender, EventArgs e) { RemoveAttachToolBoxFragment(); if (!CrossConnectivity.Current.IsConnected) { DialogUtils.ShowOKDialog(this, @"Warning", @"No Internet Connection"); return; } if (!ViewModel.CurrentlyOpenDTO.OtherUserActivate) { DialogUtils.ShowOKDialog(this, "Warning", "User is inactive to receive message"); return; } var PermStorage = await CheckNecessaryPermissions(Plugin.Permissions.Abstractions.Permission.Storage); if (PermStorage && CrossConnectivity.Current.IsConnected) { if (!CrossMedia.Current.IsCameraAvailable && !CrossMedia.Current.IsTakePhotoSupported) { DialogUtils.ShowOKDialog(this, @"Warning", @"No Camera available."); return; } if (ViewModel.PhotoFileToBeSent == null) { ViewModel.PhotoFileToBeSent = new List <MediaFile>(); } var mediaFile = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions { Directory = "Private", PhotoSize = PhotoSize.Large, Name = string.Format("{0}.jpg", DateConverter.GetUnixTimeSpanFromDate(DateTime.Now)) }); if (mediaFile != null) { ViewModel.PhotoFileToBeSent.Add(mediaFile); var model = new AddPrivateChatHistoryItemRequest() { SENDER_ID = ViewModel.CurrentlyOpenDTO.MyUserId, OTHER_USER_ID = ViewModel.CurrentlyOpenDTO.OtherUserId, MSG_TYPE = GlobalConstants.CHAT_HISTORY_ITEM_IMAGE, MSG_CONTENT = "", THREAD_ID = ViewModel.CurrentlyOpenDTO.EntryID }; ViewModel.SendPrivateMessageCommand.Execute(model); } } else { ViewModel.PhotoFileToBeSent.Clear(); } }
async void AttachFileTakeHandler(object sender, EventArgs e) { RemoveAttachToolBoxFragment(); if (!CrossConnectivity.Current.IsConnected) { DialogUtils.ShowOKDialog(this, @"Warning", @"No Internet Connection"); return; } if (!ViewModel.CurrentlyOpenDTO.OtherUserActivate) { DialogUtils.ShowOKDialog(this, "Warning", "User is inactive to receive message"); return; } var PermStorage = await CheckNecessaryPermissions(Permission.Storage); if (PermStorage && CrossConnectivity.Current.IsConnected) { try { FileData fileData = await CrossFilePicker.Current.PickFile(); if (fileData == null) { return; } var extFile = Path.GetExtension(fileData.FilePath); if (!string.Equals(extFile.ToLower(), ".pdf")) { DialogUtils.ShowOKDialog(this, "Warning", "Only Pdf is available to send"); return; } if (ViewModel.BinaryFileToBeSent == null) { ViewModel.BinaryFileToBeSent = new List <FileData>(); } ViewModel.BinaryFileToBeSent.Add(fileData); var model = new AddPrivateChatHistoryItemRequest() { SENDER_ID = ViewModel.CurrentlyOpenDTO.MyUserId, OTHER_USER_ID = ViewModel.CurrentlyOpenDTO.OtherUserId, MSG_TYPE = GlobalConstants.CHAT_HISTORY_ITEM_PDF, MSG_CONTENT = "", THREAD_ID = ViewModel.CurrentlyOpenDTO.EntryID }; ViewModel.SendPrivateMessageCommand.Execute(model); } catch (Exception ex) { } } else { ViewModel.BinaryFileToBeSent.Clear(); } }