private async void UserInputBar_OnSendMessageButtonClicked() { if (string.IsNullOrEmpty(UserInputBar.InputText) && SelectedFile == null) { var filePicker = new FileOpenPicker(); filePicker.FileTypeFilter.Add("*"); // Without this the file picker throws an exception, this is not documented SelectedFile = await filePicker.PickSingleFileAsync(); if (SelectedFile != null) { AddedAttachmentDisplay.ShowAttachment(SelectedFile.Name); UpdateSendButtonIcon(); UserInputBar.FocusTextBox(); } else { AddedAttachmentDisplay.HideAttachment(); } } else { bool sendMessageResult = await GetMainPageVm().SendMessage(UserInputBar.InputText, SelectedFile); if (sendMessageResult) { ResetInput(); } } }
private void UpdateSendButtonIcon() { if (UserInputBar.InputText != string.Empty || SelectedFile != null) { UserInputBar.SetSendButtonIcon(Symbol.Send); } else { UserInputBar.SetSendButtonIcon(Symbol.Attach); } }
public void Load(SignalConversation conversation) { bool conversationThreadIdChanged = SignalConversation?.ThreadId != conversation?.ThreadId; SignalConversation = conversation; if (SignalConversation is SignalContact contact) { Blocked = contact.Blocked; SendMessageVisible = !Blocked; } else { // Need to make sure to reset the Blocked and SendMessageVisible values in case // a group chat is selected. Group chats can never be blocked. Blocked = false; SendMessageVisible = !Blocked; } LastMarkReadRequest = -1; SendButtonEnabled = false; /* * On app resume this method (Load()) gets called with the same conversation, but new object. * Only load draft if it is acutally a different conversation, * because on mobile app gets supended during file picking and * the new conversation does not have the DraftFileTokens */ if (conversationThreadIdChanged) { // We don't need to wait for this _ = LoadDraft(); } UserInputBar.FocusTextBox(); DisposeCurrentThread(); UpdateHeader(conversation); SpellCheckEnabled = GlobalSettingsManager.SpellCheckSetting; /* * When selecting a small (~650 messages) conversation after a bigger (~1800 messages) one, * ScrollToBottom would scroll so far south that the entire screen was white. Seems like the * scrollbar is not properly notified that the collection changed. I tried things like throwing * CollectionChanged (reset) event, but to no avail. This hack works, though. */ ConversationItemsControl.ItemsSource = new List <object>(); UpdateLayout(); Collection = new VirtualizedCollection(conversation); ConversationItemsControl.ItemsSource = Collection; UpdateLayout(); SendButtonEnabled = conversation.CanReceive; ScrollToUnread(); }
private async void UserInputBar_OnEnterKeyPressed() { bool shift = CoreWindow.GetForCurrentThread().GetKeyState(VirtualKey.Shift).HasFlag(CoreVirtualKeyStates.Down); if (shift) { UserInputBar.AddLinefeed(); } else { bool sendMessageResult = await GetMainPageVm().SendMessage(UserInputBar.InputText, SelectedFile); if (sendMessageResult) { ResetInput(); } } }
private async Task LoadDraft() { UserInputBar.InputText = SignalConversation.Draft ?? string.Empty; UserInputBar.SetCursorPositionToEnd(); SetSelectedFile(null); try { StorageFile file = !string.IsNullOrWhiteSpace(SignalConversation.DraftFileTokens) && StorageApplicationPermissions.FutureAccessList.ContainsItem(SignalConversation.DraftFileTokens) ? await StorageApplicationPermissions.FutureAccessList.GetFileAsync(SignalConversation.DraftFileTokens) : null; if (file != null) { SetSelectedFile(file); } } catch (Exception e) { Logger.LogError("LoadDraft() load file failed: {0}\n{1}", e.Message, e.StackTrace); } }
private async void UserInputBar_OnEnterKeyPressed() { CoreWindow coreWindow = CoreWindow.GetForCurrentThread(); bool shift = coreWindow.GetKeyState(VirtualKey.Shift).HasFlag(CoreVirtualKeyStates.Down); bool control = coreWindow.GetKeyState(VirtualKey.Control).HasFlag(CoreVirtualKeyStates.Down); // If SendMessageWithEnterSetting is true then add new if shift key is pressed. // If SendMessageWithEnterSetting is false then send message if control key is pressed. if (GlobalSettingsManager.SendMessageWithEnterSetting ? shift : !control) { UserInputBar.AddLinefeed(); } else { bool sendMessageResult = await GetMainPageVm().SendMessage(UserInputBar.InputText, SelectedFile); if (sendMessageResult) { ResetInput(); } } }
public void Load(SignalConversation conversation) { SignalConversation = conversation; if (SignalConversation is SignalContact contact) { Blocked = contact.Blocked; SendMessageVisible = !Blocked; } else { // Need to make sure to reset the Blocked and SendMessageVisible values in case // a group chat is selected. Group chats can never be blocked. Blocked = false; SendMessageVisible = !Blocked; } LastMarkReadRequest = -1; SendButtonEnabled = false; ResetInput(); UserInputBar.FocusTextBox(); DisposeCurrentThread(); UpdateHeader(conversation); SpellCheckEnabled = GlobalSettingsManager.SpellCheckSetting; /* * When selecting a small (~650 messages) conversation after a bigger (~1800 messages) one, * ScrollToBottom would scroll so far south that the entire screen was white. Seems like the * scrollbar is not properly notified that the collection changed. I tried things like throwing * CollectionChanged (reset) event, but to no avail. This hack works, though. */ ConversationItemsControl.ItemsSource = new List <object>(); UpdateLayout(); Collection = new VirtualizedCollection(conversation); ConversationItemsControl.ItemsSource = Collection; UpdateLayout(); SendButtonEnabled = conversation.CanReceive; ScrollToUnread(); }