Benachrichtigungen:

Ist das Fenster minimiert oder im Hintergrund, wird bei einem Klick auf die Benachrichtigung der richtige Chat ausgewählt und das Fenster zurück in den Vordergrund geholt.
This commit is contained in:
Lyndon
2019-09-02 19:04:55 +02:00
parent 968beec709
commit 69cb1cf509
2 changed files with 44 additions and 4 deletions

View File

@@ -6,7 +6,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
classpath 'com.android.tools.build:gradle:3.4.2'
classpath 'io.realm:realm-gradle-plugin:5.3.0'
// NOTE: Do not place your application dependencies here; they belong

View File

@@ -40,7 +40,22 @@ namespace ChatController
private readonly Dictionary<int, SyncFileInfoStruct> _GroupId2DateTime = new Dictionary<int, SyncFileInfoStruct>();
public Window ContainingWindow { get; set; }
private Window _ContainingWindow;
public Window ContainingWindow
{
get => _ContainingWindow;
set
{
_ContainingWindow = value;
if(value != null)
{
_ContainingWindow.Deactivated += ContainingWindowOnDeactivated;
_ContainingWindow.Activated += ContainingWindowOnActivated;
}
}
}
private Chat _Chat;
private CurrentContact _CurrentContact;
@@ -59,6 +74,8 @@ namespace ChatController
private bool _IsDesktopVersion = true;
private bool _IsInBackground;
public ChatMainControl()
{
InitializeComponent();
@@ -66,6 +83,16 @@ namespace ChatController
ReloadGruppen.Visibility = Visibility.Collapsed;
}
private void ContainingWindowOnDeactivated(object sender, EventArgs e)
{
_IsInBackground = true;
}
private void ContainingWindowOnActivated(object sender, EventArgs e)
{
_IsInBackground = false;
}
public void InitMitChatdaten(ChatDatenUebergabe cdu)
{
_Chat = new Chat(cdu);
@@ -119,6 +146,13 @@ namespace ChatController
{
DisposeAndRemoveNotification((NotifyIcon)sender, pGroupId);
if (_ContainingWindow.WindowState == WindowState.Minimized)
{
_ContainingWindow.WindowState = WindowState.Normal;
}
_ContainingWindow.Activate();
SelectContact(_ContactList.FirstOrDefault(f => f.GroupId.Equals(pGroupId)));
};
@@ -202,7 +236,12 @@ namespace ChatController
AktChatUserList.Items.Add(currentContact);
_CurrentContact = currentContact;
if(Clientlist.Items.Contains(pContact))
{
Clientlist.SelectedItem = pContact;
}
var chatMessages = _Chat.LoadChatMessagesForContact(currentContact);
ChatListBox.ItemsSource = chatMessages;
@@ -667,7 +706,8 @@ namespace ChatController
contact.ReceivedMessage = newContact.ReceivedMessage;
contact.TimeStamp = newContact.TimeStamp;
if (Clientlist.SelectedItem != null && !((Contact)Clientlist.SelectedItem).GroupId.Equals(newContact.GroupId) || Clientlist.SelectedItem == null)
// TODO: Prüfen, ob die App im Hintergrund oder minimiert ist
if ((Clientlist.SelectedItem != null && !((Contact)Clientlist.SelectedItem).GroupId.Equals(newContact.GroupId) || Clientlist.SelectedItem == null) || _IsInBackground)
{
ContainingWindow.Icon = Utils.GetImageSourceFromIcon(Resource.oC_favico_NewMessage);
ShowNotification(newContact.Name, "Sie haben eine neue Nachricht", newContact.GroupId);