Commit 1de52d48 authored by Nicolas Jager's avatar Nicolas Jager

smartpanel : add time stamp

- shows last call date in the smartpanel.
- shows "more user friendly", callstatus in smartpanel.
- store last call date in contacts.json.
- edit call button xaml.

Change-Id: I2caa9ddb9d45b5be54a456b67ff535d0c85a4e80
Tuleap: #790
parent 5c9e85d9
......@@ -76,6 +76,7 @@ Contact::Contact(String^ name,
_displayName = "";
contactStatus_ = contactStatus;
lastTime_ = "never";
}
void
......@@ -101,6 +102,7 @@ Contact::ToJsonObject()
contactObject->SetNamedValue(unreadMessagesKey, JsonValue::CreateNumberValue(unreadMessages_));
contactObject->SetNamedValue(accountIdAssociatedKey, JsonValue::CreateStringValue(_accountIdAssociated));
contactObject->SetNamedValue(vcardUIDKey, JsonValue::CreateStringValue(_vcardUID));
contactObject->SetNamedValue(lastTimeKey, JsonValue::CreateStringValue(_lastTime));
JsonObject^ jsonObject = ref new JsonObject();
jsonObject->SetNamedValue(contactKey, contactObject);
......
......@@ -35,6 +35,8 @@ String^ contactKey = "contact";
String^ contactListKey = "contactlist";
String^ accountIdAssociatedKey = "accountIdAssociated";
String^ vcardUIDKey = "vcardUID";
String^ lastTimeKey = "lastTime";
namespace RingClientUWP
{
......@@ -146,6 +148,20 @@ public:
}
}
property String^ _lastTime
{
String^ get()
{
return lastTime_;
}
void set(String^ value)
{
lastTime_ = value;
NotifyPropertyChanged("_lastTime");
}
}
VCardUtils::VCard^ getVCard();
internal:
......@@ -168,6 +184,7 @@ private:
Windows::UI::Xaml::GridLength contactBarHeight_ = 0;
ContactStatus contactStatus_;
String^ name_;
String^ lastTime_;
};
}
......@@ -167,6 +167,7 @@ ContactsViewModel::Destringify(String^ data)
unsigned int unreadmessages;
String^ accountIdAssociated;
String^ vcardUID;
String^ lastTime;
JsonArray^ contactlist = jsonObject->GetNamedArray(contactListKey, ref new JsonArray());
for (unsigned int i = 0; i < contactlist->Size; i++) {
......@@ -182,12 +183,18 @@ ContactsViewModel::Destringify(String^ data)
unreadmessages = static_cast<uint16_t>(contactObject->GetNamedNumber(unreadMessagesKey));
accountIdAssociated = contactObject->GetNamedString(accountIdAssociatedKey);
vcardUID = contactObject->GetNamedString(vcardUIDKey);
if (contactObject->HasKey(lastTimeKey))
lastTime = contactObject->GetNamedString(lastTimeKey);
}
auto contact = ref new Contact(name, ringid, guid, unreadmessages, ContactStatus::READY);
contact->_displayName = displayname;
contact->_accountIdAssociated = accountIdAssociated;
// contact image
contact->_vcardUID = vcardUID;
if (lastTime)
contact->_lastTime = lastTime;
std::string contactImageFile = RingD::instance->getLocalFolder() + ".vcards\\"
+ Utils::toString(contact->_vcardUID) + ".png";
if (Utils::fileExists(contactImageFile)) {
......
......@@ -3,6 +3,7 @@ namespace RingClientUWP
/* public enumerations. */
public enum class CallStatus {
NONE,
OUTGOING_REQUESTED,
INCOMING_RINGING,
OUTGOING_RINGING,
SEARCHING,
......
......@@ -20,6 +20,8 @@
/* daemon */
#include <dring.h>
#include "dring/call_const.h"
#include "callmanager_interface.h"
#include "configurationmanager_interface.h"
#include "presencemanager_interface.h"
......@@ -969,7 +971,9 @@ RingD::dequeueTasks()
case Request::HangUpCall:
{
auto callId = task->_callId;
DRing::hangUp(Utils::toString(callId));
}
break;
case Request::PauseCall:
......
......@@ -38,6 +38,7 @@
<views:CollapseEmptyString x:Key="_CollapseEmptyString_" />
<views:ContactStatusNotification x:Key="_ContactStatusNotification_" />
<views:boolToVisibility x:Key="_boolToVisibility_" />
<views:CallStatusToSpinnerVisibility x:Key="_CallStatusToSpinnerVisibility_" />
<!-- template for contacts. -->
<DataTemplate x:Key="ContactTemplate"
......@@ -228,27 +229,39 @@
<Grid Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="40"/>
<RowDefinition Height="30"/>
</Grid.RowDefinitions>
<!-- name of the contact. -->
<TextBlock x:Name="_contactName_"
Grid.Row="0"
Text="{x:Bind _contact._name, Mode=OneWay}"
TextTrimming="CharacterEllipsis">
</TextBlock>
<StackPanel Grid.Row="0">
<TextBlock x:Name="_contactName_"
Text="{x:Bind _contact._name, Mode=OneWay}"
TextTrimming="CharacterEllipsis">
</TextBlock>
<StackPanel Orientation="Horizontal">
<TextBlock x:Name="_contactLastTime_"
FontStyle="Italic"
Foreground="#333333"
FontSize="10"
Text="{x:Bind _contact._lastTime, Mode=OneWay}"/>
<ProgressBar Foreground="#333333"
Width="100"
Visibility="{x:Bind _callStatus, Converter={StaticResource _CallStatusToSpinnerVisibility_}, Mode=OneWay}"
IsIndeterminate="True"/>
</StackPanel>
</StackPanel>
<!-- call button. -->
<!-- Style="{StaticResource roundButtonTemplate}" old style, keep it until refacto -->
<Button Grid.Row="0"
Visibility="{x:Bind _isCallable, Converter={StaticResource _boolToVisibility_}, Mode=OneWay}"
Click="_callContact__Click"
VerticalAlignment="Bottom"
HorizontalAlignment="Left"
Margin="10,0"
Style="{StaticResource roundButtonTemplate}"
Style="{StaticResource ButtonStyleForCallBar}"
FontFamily="Segoe MDL2 Assets"
Content="&#xE116;">
<Button.RenderTransform>
<TranslateTransform X="90" Y="25"/>
<TranslateTransform X="0" Y="18"/>
</Button.RenderTransform>
</Button>
</Grid>
......@@ -263,13 +276,14 @@
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<TextBlock x:Name="_CallStatus_"
<!-- KEEP _CallStatus_ FOR DEBUG -->
<!--<TextBlock x:Name="_CallStatus_"
Grid.Row="0"
Foreground="White"
Text="{x:Bind _callStatus, Mode=OneWay}"
Visibility="{x:Bind _callStatus, Converter={StaticResource _HasAnActiveCall_}, Mode=OneWay}"
HorizontalAlignment="Center">
</TextBlock>
</TextBlock>-->
<StackPanel Orientation="Horizontal"
Visibility="Visible"
Grid.Row="1"
......
......@@ -122,14 +122,12 @@ SmartPanel::SmartPanel()
return;
}
item->_callStatus = state;
switch (state) {
case CallStatus::NONE:
case CallStatus::ENDED:
{
bool isInCall = false;
for (auto item : SmartPanelItemsViewModel::instance->itemsList) {
for (auto item : SmartPanelItemsViewModel::instance->itemsList) { // WTF!!! item instead of it!!!! (XXX)
if (item->_callId && item->_callStatus == CallStatus::IN_PROGRESS) {
isInCall = true;
RingD::instance->currentCallId = item->_callId;
......@@ -138,8 +136,6 @@ SmartPanel::SmartPanel()
}
if (!isInCall)
_settingsMenuButton_->Visibility = VIS::Visible;
item->_callId = "";
break;
}
case CallStatus::IN_PROGRESS:
......@@ -541,8 +537,9 @@ SmartPanel::_callContact__Click(Platform::Object^ sender, Windows::UI::Xaml::Rou
RingD::instance->pauseCall(Utils::toString(it->_callId));
if (item->_callStatus == CallStatus::ENDED || item->_callStatus == CallStatus::NONE) {
item->_callStatus == CallStatus::OUTGOING_REQUESTED;
item->_callStatus = CallStatus::OUTGOING_REQUESTED;
RingD::instance->placeCall(contact);
item->_contact->_lastTime = "looking for " + item->_contact->_name + ".";
}
/* move the item of the top of the list */
......@@ -1863,3 +1860,26 @@ void RingClientUWP::Views::SmartPanel::OnincomingAccountMessage(Platform::String
_smartList_->ScrollIntoView(item);
}
}
Object ^ RingClientUWP::Views::CallStatusToSpinnerVisibility::Convert(Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Object ^ parameter, String ^ language)
{
auto callStatus = static_cast<CallStatus>(value);
if (callStatus == CallStatus::INCOMING_RINGING
|| callStatus == CallStatus::OUTGOING_REQUESTED
|| callStatus == CallStatus::OUTGOING_RINGING
|| callStatus == CallStatus::SEARCHING)
return Windows::UI::Xaml::Visibility::Visible;
else
return Windows::UI::Xaml::Visibility::Collapsed;
}
Object ^ RingClientUWP::Views::CallStatusToSpinnerVisibility::ConvertBack(Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Object ^ parameter, String ^ language)
{
throw ref new Platform::NotImplementedException();
}
RingClientUWP::Views::CallStatusToSpinnerVisibility::CallStatusToSpinnerVisibility()
{}
......@@ -94,6 +94,13 @@ public:
boolToVisibility();
};
public ref class CallStatusToSpinnerVisibility 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);
CallStatusToSpinnerVisibility();
};
public ref class SmartPanel sealed
{
public:
......
......@@ -35,6 +35,7 @@ SmartPanelItem::SmartPanelItem()
videoMuted_ = false;
isSelected_ = false;
isHovered_ = false;
_callStatus = CallStatus::NONE;
RingD::instance->callPlaced += ref new RingClientUWP::CallPlaced(this, &RingClientUWP::Controls::SmartPanelItem::OncallPlaced);
}
......
......@@ -25,6 +25,7 @@ using namespace Windows::Data::Json;
using namespace Windows::Storage;
using namespace Windows::Storage::Streams;
using namespace Windows::UI::Core;
using namespace Windows::Globalization::DateTimeFormatting;
using namespace RingClientUWP;
......@@ -33,6 +34,7 @@ using namespace ViewModel;
SmartPanelItemsViewModel::SmartPanelItemsViewModel()
{
itemsList_ = ref new Vector<SmartPanelItem^>();
RingD::instance->stateChange += ref new RingClientUWP::StateChange(this, &RingClientUWP::ViewModel::SmartPanelItemsViewModel::OnstateChange);
}
SmartPanelItem^
......@@ -97,3 +99,55 @@ void RingClientUWP::ViewModel::SmartPanelItemsViewModel::moveItemToTheTop(SmartP
}
}
}
void RingClientUWP::ViewModel::SmartPanelItemsViewModel::OnstateChange(Platform::String ^callId, RingClientUWP::CallStatus state, int code)
{
auto item = SmartPanelItemsViewModel::instance->findItem(callId);
if (!item) {
WNG_("item not found");
return;
}
item->_callStatus = state;
Windows::Globalization::Calendar^ calendar = ref new Windows::Globalization::Calendar();
Windows::Foundation::DateTime dateTime = calendar->GetDateTime();
auto timestampFormatter = ref new DateTimeFormatter("day month year hour minute second");
switch (state) {
case CallStatus::ENDED:
{
item->_contact->_lastTime = "Last call : " + timestampFormatter->Format(dateTime) + ".";
ContactsViewModel::instance->saveContactsToFile();
break;
}
case CallStatus::IN_PROGRESS:
{
item->_contact->_lastTime = "in progress.";
break;
}
case CallStatus::PEER_PAUSED:
{
item->_contact->_lastTime = "paused by "+ item->_contact->_name+".";
break;
}
case CallStatus::PAUSED:
{
item->_contact->_lastTime = "paused.";
break;
}
case CallStatus::OUTGOING_REQUESTED:
case CallStatus::OUTGOING_RINGING:
case CallStatus::SEARCHING:
{
item->_contact->_lastTime = "looking for " + item->_contact->_name + ".";
break;
}
case CallStatus::INCOMING_RINGING:
item->_contact->_lastTime = "incoming call from " + item->_contact->_name + ".";
break;
default:
break;
}
}
......@@ -81,8 +81,7 @@ private:
Vector<SmartPanelItem^>^ itemsList_;
SmartPanelItem^ currentItem_;
SmartPanelItem^ oldItem_;
void OnstateChange(Platform::String ^callId, RingClientUWP::CallStatus state, int code);
};
}
}
......@@ -467,5 +467,14 @@
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ButtonStyleForCallBar"
TargetType="Button">
<Setter Property="Foreground"
Value="White"/>
<Setter Property="Background"
Value="#004c60"/>
<Setter Property="BorderThickness"
Value="0"/>
</Style>
</ResourceDictionary>
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