Skip to content
Snippets Groups Projects
Commit 5c395ea7 authored by Andreas Traczyk's avatar Andreas Traczyk
Browse files

calls: adds optional messaging frame to the call page

- adds the ability to split the call page into a video area and a
  messaging area

Change-Id: I6fd25b7256f3b14b9da1f5de175b606def928712
Tuleap: #1052
parent 21e55dd5
No related branches found
No related tags found
No related merge requests found
......@@ -242,6 +242,45 @@ RingClientUWP::RingD::startDaemon()
}));
}
}),
DRing::exportable_callback<DRing::CallSignal::IncomingMessage>([&](
const std::string& callId,
const std::string& from,
const std::map<std::string, std::string>& payloads)
{
MSG_("<IncomingMessage>");
MSG_("callId = " + callId);
MSG_("from = " + from);
auto callId2 = toPlatformString(callId);
auto from2 = toPlatformString(from);
from2 = Utils::TrimRingId2(from2);
Call^ call = CallsViewModel::instance->findCall(callId2);
if (!call)
return;
String^ accountId2 = call->accountId;
const std::string PROFILE_VCF = "x-ring/ring.profile.vcard";
static const unsigned int profileSize = PROFILE_VCF.size();
for (auto i : payloads) {
if (i.first.compare(0, profileSize, PROFILE_VCF) == 0) {
MSG_("VCARD");
return;
}
MSG_("payload.first = " + i.first);
MSG_("payload.second = " + i.second);
auto payload = Utils::toPlatformString(i.second);
CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(
CoreDispatcherPriority::Low, ref new DispatchedHandler([=]()
{
incomingAccountMessage(accountId2, from2, payload);
}));
}
}),
DRing::exportable_callback<DRing::ConfigurationSignal::RegistrationStateChanged>([this](
const std::string& account_id, const std::string& state,
int detailsCode, const std::string& detailsStr)
......
......@@ -291,7 +291,7 @@
<StackPanel Grid.Column="1"
VerticalAlignment="Bottom">
<TextBlock x:Name="_selectedAccountName_"
Text="default name"
Text="[TEXT MISSING]"
Margin="10"
Style="{StaticResource TextStyle2}"/>
<StackPanel Orientation="Horizontal">
......
......@@ -124,6 +124,20 @@ Platform::String^ TrimRingId(Platform::String^ s)
return ref new Platform::String(first, static_cast<unsigned int>(last - first));
}
/* fix some issue in the daemon --> remove "@..." */
Platform::String^ TrimRingId2(Platform::String^ s)
{
const WCHAR* first = s->Begin();
const WCHAR* last = s->End();
while (first != last && last[-1] != '@')
--last;
last--;
return ref new Platform::String(first, static_cast<unsigned int>(last - first));
}
Platform::String^ GetNewGUID()
{
GUID result;
......
......@@ -3,6 +3,8 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:RingClientUWP"
xmlns:views="using:RingClientUWP.Views"
xmlns:ctl="using:RingClientUWP.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
......@@ -27,6 +29,102 @@
<LinearDoubleKeyFrame Value="0" KeyTime="0:0:4" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
<!-- bubble -->
<views:BubbleBackground x:Key="_bubbleBackground_" />
<views:BubbleHorizontalAlignement x:Key="_bubbleHorizontalAlignement_" />
<DataTemplate x:Key="ConversationMessageTemplate"
x:DataType="local:ConversationMessage">
<Grid Margin="0"
HorizontalAlignment="{x:Bind FromContact, Converter={StaticResource _bubbleHorizontalAlignement_}}" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="8*" />
</Grid.ColumnDefinitions>
<Border Background="{x:Bind FromContact, Converter={StaticResource _bubbleBackground_}}"
CornerRadius="10"
Grid.Column="1"
Width="auto"
Height="auto"
Padding="5"
Margin="5" >
<ContentPresenter>
<!--Text="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."-->
<TextBlock x:Name="_msgContent_"
TextWrapping="Wrap"
Text="{x:Bind Payload}"
Foreground="White"/>
</ContentPresenter>
</Border>
</Grid>
</DataTemplate>
<!-- barre d'envoi de message -->
<Style TargetType="TextBox">
<Setter Property="MinWidth" Value="{ThemeResource TextControlThemeMinWidth}" />
<Setter Property="MinHeight" Value="{ThemeResource TextControlThemeMinHeight}" />
<Setter Property="Foreground" Value="Black" />
<Setter Property="Background" Value="white" />
<Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}" />
<Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}" />
<Setter Property="ScrollViewer.HorizontalScrollMode" Value="Auto" />
<Setter Property="ScrollViewer.VerticalScrollMode" Value="Auto" />
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Hidden" />
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Hidden" />
<Setter Property="ScrollViewer.IsDeferredScrollingEnabled" Value="False" />
<Setter Property="Padding" Value="4,4"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="TextBox">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Border x:Name="BackgroundElement"
Grid.Row="1"
Background="{TemplateBinding Background}"
Margin="{TemplateBinding BorderThickness}"
Opacity="1"
Grid.ColumnSpan="2"
BorderBrush="LightBlue"
BorderThickness="1"
Grid.RowSpan="1"/>
<ScrollViewer x:Name="ContentElement"
Grid.Row="1"
HorizontalScrollMode="{TemplateBinding ScrollViewer.HorizontalScrollMode}"
HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
VerticalScrollMode="{TemplateBinding ScrollViewer.VerticalScrollMode}"
VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}"
IsHorizontalRailEnabled="{TemplateBinding ScrollViewer.IsHorizontalRailEnabled}"
IsVerticalRailEnabled="{TemplateBinding ScrollViewer.IsVerticalRailEnabled}"
IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}"
Margin="{TemplateBinding BorderThickness}"
Padding="{TemplateBinding Padding}"
IsTabStop="False"
AutomationProperties.AccessibilityView="Raw"
ZoomMode="Disabled" />
<Button x:Name="_sendBtn_"
Background="Transparent"
Grid.Row="1"
FontFamily="Segoe MDL2 Assets"
Foreground="LightBlue"
Content="&#xE122;"
IsTabStop="False"
Grid.Column="1"
Click="_sendBtn__Click"
Visibility="Visible"
MinWidth="34"
FontSize="20"
VerticalAlignment="Stretch"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Page.Resources>
<SplitView x:Name="_videoSplitView_" IsPaneOpen="False" OpenPaneLength="400" PanePlacement="Right">
......@@ -34,10 +132,14 @@
<Frame x:Name="_chatPanel_"/>
</SplitView.Pane>
<SplitView.Content>
<Grid Background="#000000">
<Image x:Name="_videoControl_"
PointerMoved="_videoControl__PointerMoved"
Stretch="UniformToFill"/>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition x:Name="_rowChatBx_" Height="0"/>
</Grid.RowDefinitions>
<Grid Background="#000000"
Grid.Row="0"
PointerMoved="_videoControl__PointerMoved">
<StackPanel x:Name="_headerBar_"
Background="{StaticResource SemiTransparentBlack}"
HorizontalAlignment="Stretch"
......@@ -201,6 +303,41 @@
</Button>
</StackPanel>
</Grid>
<!-- in call chat box -->
<Grid Grid.Row="1">
<Grid Background="#FFF2F2F2">
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="*"/>
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<ScrollViewer x:Name="_scrollView_"
Grid.Row="1">
<StackPanel>
<ListBox x:Name="_messagesList_"
Margin="0"
Padding="0"
ItemContainerStyle="{StaticResource messageBubleStyle}"
ItemTemplate="{StaticResource ConversationMessageTemplate}">
</ListBox>
</StackPanel>
</ScrollViewer>
<Grid Height="50"
Grid.Row="2"
Margin="0"
Padding="0"
Background="#FFF2F2F2">
<TextBox x:Name="_messageTextBox_"
HorizontalAlignment="Stretch"
TextWrapping="NoWrap"
VerticalAlignment="Bottom"
Margin="10"
Background="White"
KeyDown="_messageTextBox__KeyDown"/>
</Grid>
</Grid>
</Grid>
</Grid>
</SplitView.Content>
</SplitView>
</Page>
\ No newline at end of file
......@@ -46,6 +46,11 @@ VideoPage::VideoPage()
void
RingClientUWP::Views::VideoPage::OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e)
{
RingD::instance->incomingAccountMessage += ref new IncomingAccountMessage([&](String^ accountId,
String^ from, String^ payload) {
scrollDown();
});
updatePageContent();
}
......@@ -59,6 +64,46 @@ void RingClientUWP::Views::VideoPage::updatePageContent()
return;
_callee_->Text = contact->name_;
_messagesList_->ItemsSource = contact->_conversation->_messages;
scrollDown();
}
void RingClientUWP::Views::VideoPage::scrollDown()
{
_scrollView_->UpdateLayout();
_scrollView_->ScrollToVerticalOffset(_scrollView_->ScrollableHeight);
}
void
RingClientUWP::Views::VideoPage::_sendBtn__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
sendMessage();
}
void
RingClientUWP::Views::VideoPage::_messageTextBox__KeyDown(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e)
{
if (e->Key == Windows::System::VirtualKey::Enter) {
sendMessage();
}
}
void
RingClientUWP::Views::VideoPage::sendMessage()
{
auto contact = ViewModel::ContactsViewModel::instance->selectedContact;
auto txt = _messageTextBox_->Text;
/* empty the textbox */
_messageTextBox_->Text = "";
if (!contact || txt->IsEmpty())
return;
RingD::instance->sendAccountTextMessage(txt);
scrollDown();
}
void RingClientUWP::Views::VideoPage::Button_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
......@@ -91,8 +136,15 @@ void RingClientUWP::Views::VideoPage::_btnPause__Tapped(Platform::Object^ sender
void RingClientUWP::Views::VideoPage::_btnChat__Tapped(Platform::Object^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e)
{
chatOpen = !chatOpen;
if (chatOpen) {
_rowChatBx_->Height = 200;
chatPanelCall();
}
else {
_rowChatBx_->Height = 0;
}
}
void RingClientUWP::Views::VideoPage::_btnAddFriend__Tapped(Platform::Object^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e)
......
......@@ -18,6 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
**************************************************************************/
#include "VideoPage.g.h"
#include "MessageTextPage.xaml.h"
using namespace Windows::Media::Capture;
using namespace Windows::UI::Xaml::Navigation;
......@@ -56,6 +57,20 @@ public:
}
}
property bool chatOpen
{
bool get()
{
return chatOpen_;
}
void set(bool value)
{
chatOpen_ = value;
}
}
void scrollDown();
protected:
virtual void OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e) override;
......@@ -73,6 +88,11 @@ internal:
private:
bool barFading_;
bool chatOpen_;
void _sendBtn__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void _messageTextBox__KeyDown(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e);
void sendMessage();
void Button_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void _btnCancel__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment