diff --git a/SmartPanel.xaml.cpp b/SmartPanel.xaml.cpp index 5df2299affa9ccb1e6331abdca86240bcfbf4ad8..d5536708962607a65b22ff24c087c7ac2b4b4871 100644 --- a/SmartPanel.xaml.cpp +++ b/SmartPanel.xaml.cpp @@ -104,6 +104,14 @@ SmartPanel::SmartPanel() auto item = SmartPanelItemsViewModel::instance->findItem(contact); item->_callId = callId; + /* move the item of the top of the list */ + unsigned int index; + if (_smartList_->Items->IndexOf(item, &index)) { + SmartPanelItemsViewModel::instance->moveItemToTheTop(item); + _smartList_->UpdateLayout(); + _smartList_->ScrollIntoView(item); + } + }); RingD::instance->stateChange += ref new StateChange([this](String^ callId, CallStatus state, int code) { @@ -136,14 +144,14 @@ SmartPanel::SmartPanel() } case CallStatus::IN_PROGRESS: { - _smartList_->SelectedItem = item; + SmartPanelItemsViewModel::instance->_selectedItem = item; summonVideoPage(); break; } case CallStatus::PEER_PAUSED: case CallStatus::PAUSED: { - _smartList_->SelectedItem = item; + SmartPanelItemsViewModel::instance->_selectedItem = item; summonVideoPage(); break; } @@ -170,6 +178,7 @@ SmartPanel::SmartPanel() RingD::instance->registrationStateErrorGeneric += ref new RingClientUWP::RegistrationStateErrorGeneric(this, &RingClientUWP::Views::SmartPanel::OnregistrationStateErrorGeneric); RingD::instance->registrationStateRegistered += ref new RingClientUWP::RegistrationStateRegistered(this, &RingClientUWP::Views::SmartPanel::OnregistrationStateRegistered); RingD::instance->callPlaced += ref new RingClientUWP::CallPlaced(this, &RingClientUWP::Views::SmartPanel::OncallPlaced); + RingD::instance->incomingAccountMessage += ref new RingClientUWP::IncomingAccountMessage(this, &RingClientUWP::Views::SmartPanel::OnincomingAccountMessage); menuOpen = MenuOpen::CONTACTS_LIST; } @@ -214,9 +223,10 @@ RingClientUWP::Views::SmartPanel::updatePageContent() } +// refacto : rm me void RingClientUWP::Views::SmartPanel::unselectContact() { - _smartList_->SelectedItem = nullptr; + // _smartList_->SelectedItem = nullptr; } void RingClientUWP::Views::SmartPanel::_smartGridButton__Clicked(Object^ sender, RoutedEventArgs^ e) @@ -535,6 +545,13 @@ SmartPanel::_callContact__Click(Platform::Object^ sender, Windows::UI::Xaml::Rou RingD::instance->placeCall(contact); } + /* move the item of the top of the list */ + unsigned int index; + if (_smartList_->Items->IndexOf(item, &index)) { + SmartPanelItemsViewModel::instance->moveItemToTheTop(item); + _smartList_->UpdateLayout(); + _smartList_->ScrollIntoView(item); + } } } } @@ -577,17 +594,17 @@ void RingClientUWP::Views::SmartPanel::Grid_PointerExited(Platform::Object^ send } } - +// refacto : rm void RingClientUWP::Views::SmartPanel::_contactItem__PointerReleased(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e) { - auto listBoxItem = dynamic_cast<ListBoxItem^>(sender); + /*auto listBoxItem = dynamic_cast<ListBoxItem^>(sender); auto smartPanelItem = dynamic_cast<SmartPanelItem^>(listBoxItem->DataContext); if (_smartList_->SelectedItem != smartPanelItem) _smartList_->SelectedItem = smartPanelItem; else _smartList_->SelectedItem = nullptr; - + */ } void RingClientUWP::Views::SmartPanel::generateQRcode() @@ -1646,10 +1663,9 @@ SmartPanel::populateVideoRateSettingsComboBox() void RingClientUWP::Views::SmartPanel::_ringTxtBx__KeyUp(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e) { if (e->Key == Windows::System::VirtualKey::Enter) { - /// (XXX) RingD::instance->lookUpName(_ringTxtBx_->Text); for (auto item : SmartPanelItemsViewModel::instance->itemsList) { if (item->_contact->_name == _ringTxtBx_->Text) { - _smartList_->SelectedItem = item; + SmartPanelItemsViewModel::instance->_selectedItem = item; return; } } @@ -1744,7 +1760,7 @@ void RingClientUWP::Views::SmartPanel::OnregistrationStateRegistered() void RingClientUWP::Views::SmartPanel::OncallPlaced(Platform::String ^callId) { - _smartList_->SelectedItem = nullptr; + SmartPanelItemsViewModel::instance->_selectedItem = nullptr; } Object ^ RingClientUWP::Views::ContactStatusNotification::Convert(Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Object ^ parameter, String ^ language) @@ -1783,14 +1799,12 @@ void RingClientUWP::Views::SmartPanel::Grid_PointerReleased(Platform::Object^ se } if (contact->_contactStatus == ContactStatus::WAITING_FOR_ACTIVATION) { - //_smartList_->SelectedItem = nullptr; return; } /* if the contact was already selected, just do a deselection and live the message text page*/ if (item == SmartPanelItemsViewModel::instance->_selectedItem) { - //_smartList_->SelectedItem = nullptr; SmartPanelItemsViewModel::instance->_selectedItem = nullptr; summonWelcomePage(); return; @@ -1834,3 +1848,18 @@ Object ^ RingClientUWP::Views::boolToVisibility::ConvertBack(Object ^ value, Win RingClientUWP::Views::boolToVisibility::boolToVisibility() {} + + +void RingClientUWP::Views::SmartPanel::OnincomingAccountMessage(Platform::String ^accountId, Platform::String ^from, Platform::String ^payload) +{ + auto contact = ContactsViewModel::instance->findContactByRingId(from); + auto item = SmartPanelItemsViewModel::instance->findItem(contact); + + /* move the item of the top of the list */ + unsigned int index; + if (_smartList_->Items->IndexOf(item, &index)) { + SmartPanelItemsViewModel::instance->moveItemToTheTop(item); + _smartList_->UpdateLayout(); + _smartList_->ScrollIntoView(item); + } +} diff --git a/SmartPanel.xaml.h b/SmartPanel.xaml.h index 93926ce108165d0a6241d9ffaa8ca6d1d4abba9e..72e47a51785fd7048aa7a1f17cb22254cae014c4 100644 --- a/SmartPanel.xaml.h +++ b/SmartPanel.xaml.h @@ -197,6 +197,7 @@ private: MenuOpen menuOpen; void Grid_PointerReleased(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e); + void OnincomingAccountMessage(Platform::String ^accountId, Platform::String ^from, Platform::String ^payload); }; } } diff --git a/SmartPanelItemsViewModel.cpp b/SmartPanelItemsViewModel.cpp index 8147ff0d21f9402a7c3d9e62d3856d47597861ab..b06cd067f9431fe749590b0bde4ca12af1c6091a 100644 --- a/SmartPanelItemsViewModel.cpp +++ b/SmartPanelItemsViewModel.cpp @@ -84,3 +84,16 @@ void RingClientUWP::ViewModel::SmartPanelItemsViewModel::removeItem(SmartPanelIt if (itemsList->IndexOf(item, &index)) itemsList->RemoveAt(index); } + +void RingClientUWP::ViewModel::SmartPanelItemsViewModel::moveItemToTheTop(SmartPanelItem ^ item) +{ + unsigned int index; + + if (itemsList->IndexOf(item, &index)) { + if (index != 0) { + itemsList->RemoveAt(index); + itemsList->InsertAt(0, item); + item->_isHovered = false; + } + } +} diff --git a/SmartPanelItemsViewModel.h b/SmartPanelItemsViewModel.h index e3656999068f14e50d48e5a62dcebebf38d0dcde..ea854e071334a2d14301f95055a9592063b73c45 100644 --- a/SmartPanelItemsViewModel.h +++ b/SmartPanelItemsViewModel.h @@ -47,6 +47,7 @@ internal: unsigned int getIndex(String^ callId); unsigned int getIndex(Contact^ contact); void removeItem(SmartPanelItem^ item); + void moveItemToTheTop(SmartPanelItem^ item); property Vector<SmartPanelItem^>^ itemsList {