atraczyk | e9919eb | 2016-09-15 15:58:18 -0400 | [diff] [blame] | 1 | /**************************************************************************
|
| 2 | * Copyright (C) 2016 by Savoir-faire Linux *
|
| 3 | * Author: Jäger Nicolas <nicolas.jager@savoirfairelinux.com> *
|
| 4 | * Author: Traczyk Andreas <andreas.traczyk@savoirfairelinux.com> *
|
| 5 | * *
|
| 6 | * This program is free software; you can redistribute it and/or modify *
|
| 7 | * it under the terms of the GNU General Public License as published by *
|
| 8 | * the Free Software Foundation; either version 3 of the License, or *
|
| 9 | * (at your option) any later version. *
|
| 10 | * *
|
| 11 | * This program is distributed in the hope that it will be useful, *
|
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
| 14 | * GNU General Public License for more details. *
|
| 15 | * *
|
| 16 | * You should have received a copy of the GNU General Public License *
|
| 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
| 18 | **************************************************************************/
|
Nicolas Jager | e069c41 | 2016-08-15 15:00:17 -0400 | [diff] [blame] | 19 | #include "pch.h"
|
| 20 |
|
| 21 | #include "VideoPage.xaml.h"
|
| 22 |
|
| 23 | using namespace RingClientUWP::Views;
|
Nicolas Jager | c551c36 | 2016-10-01 19:24:50 -0400 | [diff] [blame^] | 24 | using namespace ViewModel;
|
Nicolas Jager | e069c41 | 2016-08-15 15:00:17 -0400 | [diff] [blame] | 25 |
|
| 26 | using namespace Concurrency;
|
| 27 | using namespace Platform;
|
| 28 | using namespace Windows::Devices::Enumeration;
|
| 29 | using namespace Windows::Foundation;
|
| 30 | using namespace Windows::Foundation::Collections;
|
| 31 | using namespace Windows::UI::Xaml;
|
| 32 | using namespace Windows::UI::Xaml::Controls;
|
| 33 | using namespace Windows::UI::Xaml::Controls::Primitives;
|
| 34 | using namespace Windows::UI::Xaml::Data;
|
| 35 | using namespace Windows::UI::Xaml::Input;
|
| 36 | using namespace Windows::UI::Xaml::Media;
|
| 37 | using namespace Windows::UI::Xaml::Navigation;
|
| 38 | using namespace Windows::Media::Capture;
|
atraczyk | e9919eb | 2016-09-15 15:58:18 -0400 | [diff] [blame] | 39 | using namespace Windows::ApplicationModel::Core;
|
| 40 | using namespace Windows::UI::Core;
|
Nicolas Jager | e069c41 | 2016-08-15 15:00:17 -0400 | [diff] [blame] | 41 |
|
| 42 | VideoPage::VideoPage()
|
| 43 | {
|
| 44 | InitializeComponent();
|
| 45 | }
|
| 46 |
|
atraczyk | e9919eb | 2016-09-15 15:58:18 -0400 | [diff] [blame] | 47 | void
|
| 48 | RingClientUWP::Views::VideoPage::OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e)
|
| 49 | {
|
atraczyk | 5c395ea | 2016-09-20 17:28:09 -0400 | [diff] [blame] | 50 | RingD::instance->incomingAccountMessage += ref new IncomingAccountMessage([&](String^ accountId,
|
| 51 | String^ from, String^ payload) {
|
| 52 | scrollDown();
|
| 53 | });
|
| 54 |
|
atraczyk | e9919eb | 2016-09-15 15:58:18 -0400 | [diff] [blame] | 55 | updatePageContent();
|
| 56 | }
|
Nicolas Jager | e069c41 | 2016-08-15 15:00:17 -0400 | [diff] [blame] | 57 |
|
atraczyk | e9919eb | 2016-09-15 15:58:18 -0400 | [diff] [blame] | 58 | void RingClientUWP::Views::VideoPage::updatePageContent()
|
| 59 | {
|
Nicolas Jager | c551c36 | 2016-10-01 19:24:50 -0400 | [diff] [blame^] | 60 | auto item = SmartPanelItemsViewModel::instance->_selectedItem;
|
| 61 | auto contact = (item) ? item->_contact : nullptr;
|
| 62 |
|
atraczyk | e9919eb | 2016-09-15 15:58:18 -0400 | [diff] [blame] | 63 | if (!contact)
|
| 64 | return;
|
| 65 |
|
| 66 | _callee_->Text = contact->name_;
|
atraczyk | 5c395ea | 2016-09-20 17:28:09 -0400 | [diff] [blame] | 67 |
|
| 68 | _messagesList_->ItemsSource = contact->_conversation->_messages;
|
| 69 |
|
| 70 | scrollDown();
|
| 71 | }
|
| 72 |
|
| 73 | void RingClientUWP::Views::VideoPage::scrollDown()
|
| 74 | {
|
| 75 | _scrollView_->UpdateLayout();
|
| 76 | _scrollView_->ScrollToVerticalOffset(_scrollView_->ScrollableHeight);
|
| 77 | }
|
| 78 |
|
| 79 | void
|
| 80 | RingClientUWP::Views::VideoPage::_sendBtn__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
|
| 81 | {
|
| 82 | sendMessage();
|
| 83 | }
|
| 84 |
|
| 85 | void
|
| 86 | RingClientUWP::Views::VideoPage::_messageTextBox__KeyDown(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e)
|
| 87 | {
|
| 88 | if (e->Key == Windows::System::VirtualKey::Enter) {
|
| 89 | sendMessage();
|
| 90 | }
|
| 91 | }
|
| 92 |
|
| 93 | void
|
| 94 | RingClientUWP::Views::VideoPage::sendMessage()
|
| 95 | {
|
Nicolas Jager | c551c36 | 2016-10-01 19:24:50 -0400 | [diff] [blame^] | 96 | auto item = SmartPanelItemsViewModel::instance->_selectedItem;
|
| 97 | auto contact = item->_contact;
|
| 98 |
|
atraczyk | 5c395ea | 2016-09-20 17:28:09 -0400 | [diff] [blame] | 99 | auto txt = _messageTextBox_->Text;
|
| 100 |
|
| 101 | /* empty the textbox */
|
| 102 | _messageTextBox_->Text = "";
|
| 103 |
|
| 104 | if (!contact || txt->IsEmpty())
|
| 105 | return;
|
| 106 |
|
| 107 | RingD::instance->sendAccountTextMessage(txt);
|
| 108 | scrollDown();
|
atraczyk | e9919eb | 2016-09-15 15:58:18 -0400 | [diff] [blame] | 109 | }
|
Nicolas Jager | e069c41 | 2016-08-15 15:00:17 -0400 | [diff] [blame] | 110 |
|
| 111 | void RingClientUWP::Views::VideoPage::Button_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
|
| 112 | {
|
| 113 | }
|
| 114 |
|
| 115 |
|
| 116 | void RingClientUWP::Views::VideoPage::_btnCancel__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
|
| 117 | {
|
| 118 |
|
| 119 | }
|
| 120 |
|
| 121 | void RingClientUWP::Views::VideoPage::_btnHangUp__Tapped(Platform::Object^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e)
|
| 122 | {
|
Nicolas Jager | c551c36 | 2016-10-01 19:24:50 -0400 | [diff] [blame^] | 123 | auto item = SmartPanelItemsViewModel::instance->_selectedItem;
|
| 124 | auto call = item->_call;
|
| 125 |
|
atraczyk | e9919eb | 2016-09-15 15:58:18 -0400 | [diff] [blame] | 126 | if (call)
|
| 127 | RingD::instance->hangUpCall(call);
|
Nicolas Jager | e069c41 | 2016-08-15 15:00:17 -0400 | [diff] [blame] | 128 | pressHangUpCall();
|
| 129 | }
|
| 130 |
|
| 131 |
|
| 132 | void RingClientUWP::Views::VideoPage::_btnPause__Tapped(Platform::Object^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e)
|
| 133 | {
|
| 134 | pauseCall();
|
| 135 | }
|
| 136 |
|
| 137 |
|
| 138 | void RingClientUWP::Views::VideoPage::_btnChat__Tapped(Platform::Object^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e)
|
| 139 | {
|
atraczyk | 5c395ea | 2016-09-20 17:28:09 -0400 | [diff] [blame] | 140 | chatOpen = !chatOpen;
|
| 141 | if (chatOpen) {
|
| 142 | _rowChatBx_->Height = 200;
|
| 143 | chatPanelCall();
|
| 144 | }
|
| 145 | else {
|
| 146 | _rowChatBx_->Height = 0;
|
| 147 | }
|
Nicolas Jager | e069c41 | 2016-08-15 15:00:17 -0400 | [diff] [blame] | 148 | }
|
| 149 |
|
| 150 |
|
| 151 | void RingClientUWP::Views::VideoPage::_btnAddFriend__Tapped(Platform::Object^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e)
|
| 152 | {
|
| 153 | addContactCall();
|
| 154 | }
|
| 155 |
|
| 156 |
|
| 157 | void RingClientUWP::Views::VideoPage::_btnSwitch__Tapped(Platform::Object^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e)
|
| 158 | {
|
| 159 | transferCall();
|
| 160 | }
|
| 161 |
|
| 162 |
|
| 163 | void RingClientUWP::Views::VideoPage::_btnMicrophone__Tapped(Platform::Object^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e)
|
| 164 | {
|
| 165 | switchMicrophoneStateCall();
|
| 166 | }
|
| 167 |
|
| 168 |
|
| 169 | void RingClientUWP::Views::VideoPage::_btnMemo__Tapped(Platform::Object^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e)
|
| 170 | {
|
| 171 | reccordVideoCall();
|
| 172 | }
|
| 173 |
|
| 174 |
|
| 175 | void RingClientUWP::Views::VideoPage::_btnHQ__Tapped(Platform::Object^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e)
|
| 176 | {
|
| 177 | qualityVideoLevelCall();
|
| 178 | }
|
| 179 |
|
| 180 |
|
| 181 | void RingClientUWP::Views::VideoPage::_btnVideo__Tapped(Platform::Object^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e)
|
| 182 | {
|
| 183 | switchVideoStateCall();
|
| 184 | }
|
| 185 |
|
| 186 |
|
| 187 | void RingClientUWP::Views::VideoPage::_videoControl__PointerMoved(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e)
|
| 188 | {
|
| 189 | if (barFading)
|
| 190 | myStoryboard->Begin();
|
| 191 | barFading_ = true;
|
| 192 | }
|
| 193 |
|
| 194 |
|
| 195 | void RingClientUWP::Views::VideoPage::btnAny_entered(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e)
|
| 196 | {
|
| 197 | barFading_ = false;
|
| 198 | myStoryboard->Stop();
|
| 199 | }
|
| 200 |
|
| 201 |
|
| 202 | void RingClientUWP::Views::VideoPage::btnAny_exited(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e)
|
| 203 | {
|
| 204 | barFading_ = true;
|
Nicolas Jager | e069c41 | 2016-08-15 15:00:17 -0400 | [diff] [blame] | 205 | } |