diff --git a/CallsViewModel.cpp b/CallsViewModel.cpp index af9f832f1bed13a64d19609f1f62e41d8f77cc86..b71479020dd6f5659d43f6f25461721631a3f932 100644 --- a/CallsViewModel.cpp +++ b/CallsViewModel.cpp @@ -1,6 +1,7 @@ -/*************************************************************************** +/************************************************************************** * Copyright (C) 2016 by Savoir-faire Linux * * Author: J�ger Nicolas <nicolas.jager@savoirfairelinux.com> * +* Author: Traczyk Andreas <andreas.traczyk@savoirfairelinux.com> * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -44,10 +45,14 @@ CallsViewModel::CallsViewModel() if (state == "OVER") { delete call; call->stateChange("", code); + callEnded(); callStatusUpdated(call); // used ? RingD::instance->hangUpCall(call); return; } + else if (state == "CURRENT") { + callStarted(); + } call->stateChange(state, code); callStatusUpdated(call); // same... return; diff --git a/CallsViewModel.h b/CallsViewModel.h index 4bc06a317ba76e7467690b886dd88ac22068c2c0..4938249637c21cc7a9eda065c974d8da3d8aa56d 100644 --- a/CallsViewModel.h +++ b/CallsViewModel.h @@ -2,6 +2,7 @@ /************************************************************************** * Copyright (C) 2016 by Savoir-faire Linux * * Author: J�ger Nicolas <nicolas.jager@savoirfairelinux.com> * +* Author: Traczyk Andreas <andreas.traczyk@savoirfairelinux.com> * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -23,6 +24,8 @@ namespace RingClientUWP /* delegate */ delegate void CallRecieved(Call^ call); delegate void CallStatusUpdated(Call^ call); +delegate void CallStarted(); +delegate void CallEnded(); namespace ViewModel { public ref class CallsViewModel sealed @@ -56,6 +59,8 @@ internal: /* events */ event CallRecieved^ callRecieved; event CallStatusUpdated^ callStatusUpdated; + event CallStarted^ callStarted; + event CallEnded^ callEnded; private: CallsViewModel(); // singleton diff --git a/MainPage.xaml.cpp b/MainPage.xaml.cpp index 6a7569d8475280473b1ada4a67f78c6d682bad8c..d804a8fe31bc0365f0101047c64c5e882a7cfa1d 100644 --- a/MainPage.xaml.cpp +++ b/MainPage.xaml.cpp @@ -61,10 +61,28 @@ MainPage::MainPage() /* connect to delegates */ ContactsViewModel::instance->newContactSelected += ref new NewContactSelected([&]() { - showFrame(_messageTextFrame_); + Contact^ selectedContact = ContactsViewModel::instance->selectedContact; + auto call = selectedContact? + SmartPanelItemsViewModel::instance->findItem(selectedContact)->_call: + nullptr; + if (call != nullptr) { + if (call->state == "CURRENT") + showFrame(_videoFrame_); + else + showFrame(_messageTextFrame_); + } + else { + showFrame(_messageTextFrame_); + } }); ContactsViewModel::instance->noContactSelected += ref new NoContactSelected([&]() { showFrame(_welcomeFrame_); + }); + CallsViewModel::instance->callStarted += ref new CallStarted([&]() { + showFrame(_videoFrame_); + }); + CallsViewModel::instance->callEnded += ref new CallEnded([&]() { + showFrame(_messageTextFrame_); }); DisplayInformation^ displayInformation = DisplayInformation::GetForCurrentView(); @@ -105,6 +123,7 @@ RingClientUWP::MainPage::showFrame(Windows::UI::Xaml::Controls::Frame^ frame) _navGrid_->SetRow(_welcomeFrame_, 1); } else if (frame == _videoFrame_) { _navGrid_->SetRow(_videoFrame_, 1); + dynamic_cast<VideoPage^>(_videoFrame_->Content)->updatePageContent(); } else if (frame == _messageTextFrame_) { _navGrid_->SetRow(_messageTextFrame_, 1); dynamic_cast<MessageTextPage^>(_messageTextFrame_->Content)->updatePageContent(); diff --git a/VideoPage.xaml b/VideoPage.xaml index e7f5ed8c6fee7e464a45345d6987d499085f43bc..e3f3123d4e89bf63dbb844b461be0c3f77f08200 100644 --- a/VideoPage.xaml +++ b/VideoPage.xaml @@ -5,10 +5,11 @@ xmlns:local="using:RingClientUWP" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - mc:Ignorable="d"> + mc:Ignorable="d" + NavigationCacheMode="Enabled"> <Page.Resources> - <SolidColorBrush x:Key="SemiTransparentBlack" Color="#000000" Opacity="0.5"/> + <SolidColorBrush x:Key="SemiTransparentBlack" Color="#808080" Opacity="0.5"/> <Storyboard x:Name="myStoryboard"> <DoubleAnimationUsingKeyFrames Storyboard.TargetName="_controlsBar_" Storyboard.TargetProperty="Opacity" @@ -33,9 +34,8 @@ <Frame x:Name="_chatPanel_"/> </SplitView.Pane> <SplitView.Content> - <Grid> + <Grid Background="#000000"> <Image x:Name="_videoControl_" - Source="ms-appx:///fond-video.png" PointerMoved="_videoControl__PointerMoved" Stretch="UniformToFill"/> <StackPanel x:Name="_headerBar_" @@ -57,8 +57,91 @@ <Setter Property="Margin" Value="10,30"/> <Setter Property="Width" Value="40"/> <Setter Property="Height" Value="40"/> + <Setter Property="Background" Value="Black"/> <Setter Property="Foreground" Value="White"/> - <Setter Property="BorderBrush" Value="White"/> + <Setter Property="BorderBrush" Value="Gray"/> + <Setter Property="BorderThickness" Value="{ThemeResource ButtonBorderThemeThickness}"/> + <Setter Property="Template"> + <Setter.Value> + <ControlTemplate TargetType="Button"> + <Grid x:Name="RootGrid" Background="{TemplateBinding Background}"> + <VisualStateManager.VisualStateGroups> + <VisualStateGroup x:Name="CommonStates"> + <VisualState x:Name="PointerOver"> + <Storyboard> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" + Storyboard.TargetName="ContentPresenter"> + <DiscreteObjectKeyFrame KeyTime="0" + Value="Gray"/> + </ObjectAnimationUsingKeyFrames> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" + Storyboard.TargetName="ContentPresenter"> + <DiscreteObjectKeyFrame KeyTime="0" + Value="White"/> + </ObjectAnimationUsingKeyFrames> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" + Storyboard.TargetName="ContentPresenter"> + <DiscreteObjectKeyFrame KeyTime="0" + Value="White"/> + </ObjectAnimationUsingKeyFrames> + </Storyboard> + </VisualState> + <VisualState x:Name="Normal"> + <Storyboard> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" + Storyboard.TargetName="ContentPresenter"> + <DiscreteObjectKeyFrame KeyTime="0" + Value="Black"/> + </ObjectAnimationUsingKeyFrames> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" + Storyboard.TargetName="ContentPresenter"> + <DiscreteObjectKeyFrame KeyTime="0" + Value="White"/> + </ObjectAnimationUsingKeyFrames> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" + Storyboard.TargetName="ContentPresenter"> + <DiscreteObjectKeyFrame KeyTime="0" + Value="Gray"/> + </ObjectAnimationUsingKeyFrames> + <PointerUpThemeAnimation Storyboard.TargetName="RootGrid"/> + </Storyboard> + </VisualState> + <VisualState x:Name="Pressed"> + <Storyboard> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" + Storyboard.TargetName="ContentPresenter"> + <DiscreteObjectKeyFrame KeyTime="0" + Value="White"/> + </ObjectAnimationUsingKeyFrames> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" + Storyboard.TargetName="ContentPresenter"> + <DiscreteObjectKeyFrame KeyTime="0" + Value="Black"/> + </ObjectAnimationUsingKeyFrames> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" + Storyboard.TargetName="ContentPresenter"> + <DiscreteObjectKeyFrame KeyTime="0" + Value="Gray"/> + </ObjectAnimationUsingKeyFrames> + <PointerDownThemeAnimation Storyboard.TargetName="RootGrid"/> + </Storyboard> + </VisualState> + </VisualStateGroup> + </VisualStateManager.VisualStateGroups> + <ContentPresenter x:Name="ContentPresenter" + AutomationProperties.AccessibilityView="Raw" + BorderBrush="{TemplateBinding BorderBrush}" + BorderThickness="{TemplateBinding BorderThickness}" + ContentTemplate="{TemplateBinding ContentTemplate}" + ContentTransitions="{TemplateBinding ContentTransitions}" + Content="{TemplateBinding Content}" + HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" + Padding="{TemplateBinding Padding}" + VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/> + </Grid> + </ControlTemplate> + </Setter.Value> + </Setter> </Style> </StackPanel.Resources> @@ -78,7 +161,7 @@ PointerEntered="btnAny_entered" PointerExited="btnAny_exited" Tapped="_btnChat__Tapped"> - <SymbolIcon Symbol="Message"/> + <SymbolIcon Symbol="Message" HorizontalAlignment="Left" Width="20"/> </Button> <Button x:Name="_btnAddFriend_" PointerEntered="btnAny_entered" @@ -108,16 +191,16 @@ PointerEntered="btnAny_entered" PointerExited="btnAny_exited" Tapped="_btnMemo__Tapped"> - <SymbolIcon Symbol="Memo"/> + <SymbolIcon Symbol="Memo"/> </Button> <Button x:Name="_btnHQ_" PointerEntered="btnAny_entered" PointerExited="btnAny_exited" Tapped="_btnHQ__Tapped"> - <TextBlock Text="HQ"/> + <TextBlock FontSize="12" Text="HQ"/> </Button> </StackPanel> </Grid> </SplitView.Content> </SplitView> -</Page> +</Page> \ No newline at end of file diff --git a/VideoPage.xaml.cpp b/VideoPage.xaml.cpp index 0751885169dbbef8c41ce939c49a8fbc4d4de098..e8ccc36242588765c26b75e8b52f93b6d0df598e 100644 --- a/VideoPage.xaml.cpp +++ b/VideoPage.xaml.cpp @@ -1,3 +1,21 @@ +/************************************************************************** +* Copyright (C) 2016 by Savoir-faire Linux * +* Author: J�ger Nicolas <nicolas.jager@savoirfairelinux.com> * +* Author: Traczyk Andreas <andreas.traczyk@savoirfairelinux.com> * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 3 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program. If not, see <http://www.gnu.org/licenses/>. * +**************************************************************************/ #include "pch.h" #include "VideoPage.xaml.h" @@ -17,13 +35,31 @@ using namespace Windows::UI::Xaml::Input; using namespace Windows::UI::Xaml::Media; using namespace Windows::UI::Xaml::Navigation; using namespace Windows::Media::Capture; +using namespace Windows::ApplicationModel::Core; +using namespace Windows::UI::Core; VideoPage::VideoPage() { InitializeComponent(); } +void +RingClientUWP::Views::VideoPage::OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e) +{ + updatePageContent(); +} +void RingClientUWP::Views::VideoPage::updatePageContent() +{ + auto selectedContact = ViewModel::ContactsViewModel::instance->selectedContact; + Contact^ contact = selectedContact? + ViewModel::SmartPanelItemsViewModel::instance->findItem(selectedContact)->_contact: + nullptr; + if (!contact) + return; + + _callee_->Text = contact->name_; +} void RingClientUWP::Views::VideoPage::Button_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) { @@ -37,6 +73,12 @@ void RingClientUWP::Views::VideoPage::_btnCancel__Click(Platform::Object^ sender void RingClientUWP::Views::VideoPage::_btnHangUp__Tapped(Platform::Object^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e) { + Contact^ selectedContact = ViewModel::ContactsViewModel::instance->selectedContact; + Call^ call = selectedContact? + ViewModel::SmartPanelItemsViewModel::instance->findItem(selectedContact)->_call: + nullptr; + if (call) + RingD::instance->hangUpCall(call); pressHangUpCall(); } @@ -107,14 +149,4 @@ void RingClientUWP::Views::VideoPage::btnAny_entered(Platform::Object^ sender, W void RingClientUWP::Views::VideoPage::btnAny_exited(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e) { barFading_ = true; -} - -void -RingClientUWP::Views::VideoPage::OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e) -{ - updatePageContent(); -} - -void RingClientUWP::Views::VideoPage::updatePageContent() -{ } \ No newline at end of file diff --git a/VideoPage.xaml.h b/VideoPage.xaml.h index 6d2dff88ba5b8610c0c6fa435fd3dc07a70ba53b..4b76ee8dccf67918706564cb99ad2383ec85c3ec 100644 --- a/VideoPage.xaml.h +++ b/VideoPage.xaml.h @@ -1,5 +1,22 @@ #pragma once - +/************************************************************************** +* Copyright (C) 2016 by Savoir-faire Linux * +* Author: J�ger Nicolas <nicolas.jager@savoirfairelinux.com> * +* Author: Traczyk Andreas <andreas.traczyk@savoirfairelinux.com> * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 3 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program. If not, see <http://www.gnu.org/licenses/>. * +**************************************************************************/ #include "VideoPage.g.h" using namespace Windows::Media::Capture; @@ -25,6 +42,8 @@ public ref class VideoPage sealed { public: VideoPage(); + void updatePageContent(); + property bool barFading { bool get() @@ -38,10 +57,7 @@ public: } protected: - // Template Support virtual void OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e) override; - /*virtual void OnNavigatedFrom(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e) override;*/ - internal: /* events */ @@ -58,10 +74,6 @@ internal: private: bool barFading_; - void updatePageContent(); - - //void OnNavigatedToPage(Object^ sender, NavigationEventArgs^ e); - void Button_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void _btnCancel__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void _btnHangUp__Tapped(Platform::Object^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e); diff --git a/WelcomePage.xaml.h b/WelcomePage.xaml.h index 1f37c15f4dc370886f8a4154c75bdfd046f17c52..cd8a716476f357ac81aa8361e78c76372cab0c52 100644 --- a/WelcomePage.xaml.h +++ b/WelcomePage.xaml.h @@ -2,6 +2,7 @@ /************************************************************************** * Copyright (C) 2016 by Savoir-faire Linux * * Author: J�ger Nicolas <nicolas.jager@savoirfairelinux.com> * +* Author: Traczyk Andreas <andreas.traczyk@savoirfairelinux.com> * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by *