diff --git a/BeWoPlanerChat/bewoplaner-chat-android/build.gradle b/BeWoPlanerChat/bewoplaner-chat-android/build.gradle index b39a065..f70304d 100644 --- a/BeWoPlanerChat/bewoplaner-chat-android/build.gradle +++ b/BeWoPlanerChat/bewoplaner-chat-android/build.gradle @@ -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 diff --git a/ChatController/ChatMainControl.xaml.cs b/ChatController/ChatMainControl.xaml.cs index b7c34f2..8b14784 100644 --- a/ChatController/ChatMainControl.xaml.cs +++ b/ChatController/ChatMainControl.xaml.cs @@ -40,7 +40,22 @@ namespace ChatController private readonly Dictionary _GroupId2DateTime = new Dictionary(); - 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);