Commit 7f34b772 authored by Nicolas Jager's avatar Nicolas Jager

UI : visual updates

- stretches menus vertically.
- manages too long time lookup.
- moves element on welcomePage.
- adds profil name on the message text page.
- does lookups during incoming messages.
- show contact's avatar.

Change-Id: I2d482978281ecb0fb088cc93112a032e04e7501b
Tuleap: #790
parent f11cbec8
......@@ -36,7 +36,8 @@ using namespace ViewModel;
Contact::Contact(String^ name,
String^ ringID,
String^ GUID,
unsigned int unreadmessages)
unsigned int unreadmessages,
ContactStatus contactStatus)
{
vCard_ = ref new VCardUtils::VCard(this);
......@@ -73,6 +74,8 @@ Contact::Contact(String^ name,
_vcardUID = "";
_avatarImage = ref new String(L"ms-appx:///Assets/TESTS/contactAvatar.png");
_displayName = "";
contactStatus_ = contactStatus;
}
void
......
......@@ -43,12 +43,23 @@ ref class Conversation;
public ref class Contact sealed : public INotifyPropertyChanged
{
public:
Contact(String^ name, String^ ringID, String^ GUID, unsigned int unreadmessages);
Contact(String^ name, String^ ringID, String^ GUID, unsigned int unreadmessages, ContactStatus contactStatus);
JsonObject^ ToJsonObject();
virtual event PropertyChangedEventHandler^ PropertyChanged;
property String^ name_;
property String^ _name
{
String^ get()
{
return name_;
}
void set(String^ value)
{
name_ = value;
NotifyPropertyChanged("_name");
}
}
property String^ ringID_;
property String^ GUID_;
......@@ -122,6 +133,19 @@ public:
}
}
property ContactStatus _contactStatus
{
ContactStatus get()
{
return contactStatus_;
}
void set(ContactStatus value)
{
contactStatus_ = value;
NotifyPropertyChanged("_contactStatus");
}
}
VCardUtils::VCard^ getVCard();
internal:
......@@ -142,6 +166,8 @@ private:
String^ avatarImage_;
String^ displayName_;
Windows::UI::Xaml::GridLength contactBarHeight_ = 0;
ContactStatus contactStatus_;
String^ name_;
};
}
......@@ -51,6 +51,8 @@ ContactsViewModel::ContactsViewModel()
return;
}
RingD::instance->lookUpAddress(fromRingId);
contact->_conversation->addMessage(""/* date not yet used*/, MSG_FROM_CONTACT, payload);
/* save contacts conversation to disk */
......@@ -67,6 +69,9 @@ ContactsViewModel::ContactsViewModel()
});
RingD::instance->incomingMessage +=
ref new RingClientUWP::IncomingMessage(this, &RingClientUWP::ViewModel::ContactsViewModel::OnincomingMessage);
RingD::instance->registeredNameFound += ref new RingClientUWP::RegisteredNameFound(this, &RingClientUWP::ViewModel::ContactsViewModel::OnregisteredNameFound);
}
Contact^ // refacto : remove "byName"
......@@ -74,7 +79,7 @@ ContactsViewModel::findContactByName(String^ name)
{
auto trimmedName = Utils::Trim(name);
for each (Contact^ contact in contactsList_)
if (contact->name_ == trimmedName)
if (contact->_name == trimmedName)
return contact;
return nullptr;
......@@ -90,12 +95,12 @@ Contact ^ RingClientUWP::ViewModel::ContactsViewModel::findContactByRingId(Strin
}
Contact^
ContactsViewModel::addNewContact(String^ name, String^ ringId)
ContactsViewModel::addNewContact(String^ name, String^ ringId, ContactStatus contactStatus)
{
auto trimmedName = Utils::Trim(name);
if (contactsList_ && !findContactByName(trimmedName)) {
//if (contactsList_ && !findContactByName(trimmedName) && !findContactByRingId(ringId)) {
Contact^ contact = ref new Contact(trimmedName, ringId, nullptr, 0);
Contact^ contact = ref new Contact(trimmedName, ringId, nullptr, 0, contactStatus);
contactsList_->Append(contact);
saveContactsToFile();
contactAdded(contact);
......@@ -178,13 +183,13 @@ ContactsViewModel::Destringify(String^ data)
accountIdAssociated = contactObject->GetNamedString(accountIdAssociatedKey);
vcardUID = contactObject->GetNamedString(vcardUIDKey);
}
auto contact = ref new Contact(name, ringid, guid, unreadmessages);
auto contact = ref new Contact(name, ringid, guid, unreadmessages, ContactStatus::READY);
contact->_displayName = displayname;
contact->_accountIdAssociated = accountIdAssociated;
// contact image
contact->_vcardUID = vcardUID;
std::string contactImageFile = RingD::instance->getLocalFolder() + ".vcards\\"
+ Utils::toString(contact->_vcardUID) + ".png";
+ Utils::toString(contact->_vcardUID) + ".png";
if (Utils::fileExists(contactImageFile)) {
contact->_avatarImage = Utils::toPlatformString(contactImageFile);
}
......@@ -233,10 +238,23 @@ void RingClientUWP::ViewModel::ContactsViewModel::OnincomingMessage(Platform::St
saveContactsToFile();
}
}
}
void
ContactsViewModel::modifyContact(Contact^ contact)
{
contactDataModified(contact);
}
}
void RingClientUWP::ViewModel::ContactsViewModel::OnregisteredNameFound(RingClientUWP::LookupStatus status, const std::string &address, const std::string &name)
{
if (status == LookupStatus::SUCCESS) {
for each (Contact^ contact in contactsList_)
if (contact->ringID_ == Utils::toPlatformString(address)) {
contact->_name = Utils::toPlatformString(name);
saveContactsToFile();
}
}
}
......@@ -47,7 +47,7 @@ internal:
/* functions */
Contact^ findContactByName(String^ name);
Contact^ findContactByRingId(String^ ringId);
Contact^ addNewContact(String^ name, String^ ringId);
Contact^ addNewContact(String^ name, String^ ringId, ContactStatus contactStatus = ContactStatus::READY);
void saveContactsToFile();
void openContactsFromFile();
String^ Stringify();
......@@ -76,6 +76,7 @@ private:
Contact^ oldItem_;
void OnincomingMessage(Platform::String ^callId, Platform::String ^payload);
void OnregisteredNameFound(RingClientUWP::LookupStatus status, const std::string &address, const std::string &name);
};
}
}
......@@ -20,4 +20,9 @@ public enum class LookupStatus {
ERRORR // one cannot simply use ERROR
};
public enum class ContactStatus {
WAITING_FOR_ACTIVATION, // waiting for lookup
READY
};
}
\ No newline at end of file
......@@ -96,7 +96,7 @@ MainPage::MainPage()
RingD::instance->registrationStateRegistered += ref new RingClientUWP::RegistrationStateRegistered(this, &RingClientUWP::MainPage::OnregistrationStateRegistered);
RingD::instance->callPlaced += ref new RingClientUWP::CallPlaced(this, &RingClientUWP::MainPage::OncallPlaced);
RingD::instance->setLoadingStatusText += ref new SetLoadingStatusText([this](String^ statusText, String^ color){
RingD::instance->setLoadingStatusText += ref new SetLoadingStatusText([this](String^ statusText, String^ color) {
_loadingStatus_->Text = statusText;
auto col = Utils::ColorFromString(color);
auto brush = ref new Windows::UI::Xaml::Media::SolidColorBrush(col);
......
......@@ -136,13 +136,13 @@
<Grid Background="#FFF2F2F2">
<Grid.RowDefinitions>
<RowDefinition Height="61" />
<RowDefinition Height="auto" />
<RowDefinition Height="*"/>
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<Grid Grid.Row="0"
Background="White"
Height="61">
Height="auto">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="60"/>
<ColumnDefinition Width="auto"/>
......@@ -157,7 +157,8 @@
</Ellipse>
<Grid Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="31" />
<RowDefinition Height="25" />
<RowDefinition Height="25" />
<RowDefinition Height="30" />
</Grid.RowDefinitions>
<Grid Grid.Row="0">
......@@ -169,7 +170,7 @@
</Grid>
<TextBlock x:Name="_title_"
Grid.Column="0"
Text="[TEXT MISSING]"
Text=""
TextWrapping="NoWrap"
TextTrimming="CharacterEllipsis"
VerticalAlignment="Center"
......@@ -186,7 +187,14 @@
</ComboBox.ItemTemplate>
</ComboBox>
</Grid>
<Grid Grid.Row="1">
<TextBlock x:Name="_profilName_"
Grid.Row="1"
Text=""
FontStyle="Italic"
VerticalAlignment="Center"
FontSize="16"
Margin="4,0,4,0" />
<Grid Grid.Row="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
......
......@@ -42,6 +42,7 @@ using namespace Windows::UI::Core;
using namespace Windows::UI::Popups;
// refacto : the message text page should be
MessageTextPage::MessageTextPage()
{
InitializeComponent();
......@@ -69,13 +70,18 @@ RingClientUWP::Views::MessageTextPage::updatePageContent()
return;
/* show the name of contact on the page */
_title_->Text = contact->name_;
_title_->Text = contact->_name;
_profilName_->Text = contact->_displayName;
String^ image_path = Utils::toPlatformString(RingD::instance->getLocalFolder()) + ".vcards\\" + contact->_vcardUID + ".png";
if (Utils::fileExists(Utils::toString(image_path))) {
auto uri = ref new Windows::Foundation::Uri(image_path);
_contactBarAvatar_->ImageSource = ref new Windows::UI::Xaml::Media::Imaging::BitmapImage(uri);
}
else {
auto uri = ref new Windows::Foundation::Uri("ms-appx:///Assets/TESTS/contactAvatar.png");
_contactBarAvatar_->ImageSource = ref new Windows::UI::Xaml::Media::Imaging::BitmapImage(uri);
}
/* show messages */
_messagesList_->ItemsSource = contact->_conversation->_messages;
......
......@@ -151,7 +151,7 @@ void RingConsolePanel::sendCommand()
auto list = ContactsViewModel::instance->contactsList;
MSG_("list of calls returned by the daemon :");
for (auto contact : list) {
MSG_("name : " + Utils::toString(contact->name_));
MSG_("name : " + Utils::toString(contact->_name));
MSG_("ringId : " + Utils::toString(contact->ringID_));
}
return;
......
......@@ -906,7 +906,9 @@ RingD::dequeueTasks()
item->_callId = Utils::toPlatformString(callId);
//MSG_("$1 place call with id : " + Utils::toString(item->_callId));
callPlaced(Utils::toPlatformString(callId));
/* if for any reason there is no callid, do not propagate the event*/
if (!callId.empty())
callPlaced(Utils::toPlatformString(callId));
}));
}
......@@ -1118,7 +1120,7 @@ RingD::dequeueTasks()
}
case Request::LookUpAddress:
{
//DRing::lookupAddress(accountID.toStdString(), nameServiceURL.toStdString(), address.toStdString());
DRing::lookupAddress("", "", Utils::toString(task->_address));
break;
}
case Request::RegisterName:
......@@ -1129,12 +1131,14 @@ RingD::dequeueTasks()
if (accountDetails[DRing::Account::ConfProperties::USERNAME].empty())
registerName_new(task->_accountId_new, task->_password_new, task->_publicUsername_new);
else
{
result = DRing::registerName(task->_accountId_new, task->_password_new, task->_publicUsername_new);
CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::High,
ref new DispatchedHandler([=]() {
nameRegistred(result);
}));
CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::High,
ref new DispatchedHandler([=]() {
nameRegistred(result);
}));
}
//const wchar_t* toto = task->_accountId->Data();
......
This diff is collapsed.
This diff is collapsed.
......@@ -80,6 +80,13 @@ public:
CollapseEmptyString();
};
public ref class ContactStatusNotification sealed : IValueConverter {
public:
virtual Object^ Convert(Object^ value, Windows::UI::Xaml::Interop::TypeName targetType, Object^ parameter, String^ language);
virtual Object^ ConvertBack(Object^ value, Windows::UI::Xaml::Interop::TypeName targetType, Object^ parameter, String^ language);
ContactStatusNotification();
};
public ref class SmartPanel sealed
{
public:
......@@ -172,6 +179,16 @@ private:
void _PINTextBox__GotFocus(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void OnregistrationStateRegistered();
void OncallPlaced(Platform::String ^callId);
enum class MenuOpen {
CONTACTS_LIST,
ACCOUNTS_LIST,
SHARE,
DEVICE,
SETTINGS
};
MenuOpen menuOpen;
};
}
}
......@@ -169,7 +169,7 @@ void RingClientUWP::Views::VideoPage::updatePageContent()
if (!contact)
return;
_callee_->Text = contact->name_;
_callee_->Text = contact->_name;
_messagesList_->ItemsSource = contact->_conversation->_messages;
......
......@@ -28,28 +28,26 @@
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="2*"/>
<RowDefinition Height="2*"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<StackPanel x:Name="_welcomePage_" Grid.Row="1">
<!--<TextBlock x:Uid="_welcomeMsg"
x:Name="_welcomeMsg_"
Style="{StaticResource TextStyle1}"
HorizontalAlignment="Center"
VerticalAlignment="Center"
TextWrapping="Wrap" />-->
<Image x:Name="_welcomeImage_"
<StackPanel Grid.Row="1">
<Image x:Name="_welcomeImage_"
Source="Assets\Wide310x150Logo.scale-200.png"
Width="310"
HorizontalAlignment="Center"
Margin="0 10 0 30"
Height="150"/>
<TextBlock Text="Ring is free software for universal communication wich respects the freedoms and privacy of its users."
<TextBlock Text="Ring is free software for universal communication wich respects the freedoms and privacy of its users."
Foreground="#707370"
MaxWidth="410"
TextWrapping="WrapWholeWords"
MaxWidth="500"
Width="310"
TextWrapping="Wrap"
TextAlignment="Justify"
FontSize="18"
FontSize="12"
FontWeight="Bold"
HorizontalAlignment="Center"/>
</StackPanel>
......
......@@ -33,12 +33,12 @@ WelcomePage::WelcomePage()
void
WelcomePage::PositionImage()
{
Rect imageBounds;
/*Rect imageBounds;
imageBounds.Width = static_cast<float>(_welcomePage_->ActualWidth);
imageBounds.Height = static_cast<float>(_welcomePage_->ActualHeight);
_welcomeImage_->SetValue(Canvas::LeftProperty, imageBounds.Width * 0.5 - _welcomeImage_->Width * 0.5);
_welcomeImage_->SetValue(Canvas::TopProperty, imageBounds.Height * 0.5 - _welcomeImage_->Height * 0.5);
_welcomeImage_->SetValue(Canvas::TopProperty, imageBounds.Height * 0.5 - _welcomeImage_->Height * 0.5);*/
}
void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment