Commit 6cae7a66 authored by atraczyk's avatar atraczyk Committed by Andreas Traczyk

ui/ux: fix loading screen

- delays the loading screen image positioning to prevent incorrect
  placement due to variable times on screen rescaling
- removes the app suspension signal response which can't be
  differentiated from app termination
- removes lodepng which was used for vcards

Change-Id: I4cd46a9bdca40ef95fde89bd98e3b9f12bd8304b
Tuleap: #790
parent 4ed42ea7
......@@ -53,11 +53,11 @@
</Rectangle>
<Canvas Canvas.ZIndex="6">
<Image x:Name="_loadingImage_"
Source="Assets/Tests/logo-ring.scale-100.png"
Source="Assets/SplashScreen.scale-200.png"
Width="620"
Height="300"/>
<ProgressRing Foreground="#19a0b7"
Name="_splashProgressRing_"
<ProgressRing x:Name="_splashProgressRing_"
Foreground="#19a0b7"
IsActive="True"
MaxWidth="200"
MaxHeight="200"
......
/**************************************************************************
* Copyright (C) 2016 by Savoir-faire Linux *
* Author: Jäger Nicolas <nicolas.jager@savoirfairelinux.com> *
* Author: Traczyk Andreas <andreas.traczyk@savoirfairelinux.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
......@@ -48,6 +49,7 @@ using namespace Windows::ApplicationModel::Activation;
using namespace Windows::Graphics::Display;
using namespace Windows::System;
using namespace Concurrency;
using namespace Windows::System::Threading;
MainPage::MainPage()
{
......@@ -77,14 +79,17 @@ MainPage::MainPage()
auto messageTextFrame = dynamic_cast<MessageTextPage^>(_messageTextFrame_->Content);
messageTextFrame->closeMessageTextPage += ref new RingClientUWP::CloseMessageTextPage(this, &RingClientUWP::MainPage::OncloseMessageTextPage);
DisplayInformation^ displayInformation = DisplayInformation::GetForCurrentView();
dpiChangedtoken = (displayInformation->DpiChanged += ref new TypedEventHandler<DisplayInformation^,
dpiChangedtoken = (DisplayInformation::GetForCurrentView()->DpiChanged += ref new TypedEventHandler<DisplayInformation^,
Platform::Object^>(this, &MainPage::DisplayProperties_DpiChanged));
visibilityChangedEventToken = Window::Current->VisibilityChanged +=
ref new WindowVisibilityChangedEventHandler(this, &MainPage::Application_VisibilityChanged);
ref new EventHandler<Object^>(this, &MainPage::Application_Resuming);
applicationSuspendingEventToken = Application::Current->Suspending +=
ref new SuspendingEventHandler(this, &MainPage::Application_Suspending);
applicationResumingEventToken = Application::Current->Resuming +=
ref new EventHandler<Object^>(this, &MainPage::Application_Resuming);
RingD::instance->registrationStateErrorGeneric += ref new RingClientUWP::RegistrationStateErrorGeneric(this, &RingClientUWP::MainPage::OnregistrationStateErrorGeneric);
RingD::instance->registrationStateRegistered += ref new RingClientUWP::RegistrationStateRegistered(this, &RingClientUWP::MainPage::OnregistrationStateRegistered);
}
......@@ -150,7 +155,17 @@ RingClientUWP::MainPage::showLoadingOverlay(bool load, bool modal)
_loadingOverlayRect_->Fill = whiteBrush;
_loadingOverlayRect_->Opacity = 1.0;
}
OnResize(nullptr, nullptr);
TimeSpan delay;
delay.Duration = 500000;
ThreadPoolTimer^ delayTimer = ThreadPoolTimer::CreateTimer(
ref new TimerElapsedHandler([this](ThreadPoolTimer^ source)
{
Dispatcher->RunAsync(CoreDispatcherPriority::High,
ref new DispatchedHandler([this]()
{
OnResize(nullptr, nullptr);
}));
}), delay);
}
else if (!load) {
isLoading = false;
......@@ -167,10 +182,7 @@ RingClientUWP::MainPage::PositionImage()
auto bitmapImage = ref new Windows::UI::Xaml::Media::Imaging::BitmapImage();
Windows::Foundation::Uri^ uri;
if (bounds.Width < 1200)
uri = ref new Windows::Foundation::Uri("ms-appx:///Assets/TESTS/logo-ring.scale-200.png");
else
uri = ref new Windows::Foundation::Uri("ms-appx:///Assets/TESTS/logo-ring.scale-150.png");
uri = ref new Windows::Foundation::Uri("ms-appx:///Assets/SplashScreen.scale-200.png");
bitmapImage->UriSource = uri;
img->Source = bitmapImage;
......@@ -185,27 +197,26 @@ RingClientUWP::MainPage::PositionRing()
{
double left;
double top;
if (bounds.Width < 1200) {
_splashProgressRing_->Width = 280;
_splashProgressRing_->Height = 280;
left = bounds.Width * 0.5 - _loadingImage_->Width * 0.5 - 300;
top = bounds.Height * 0.5 - _loadingImage_->Height * 0.5 - 100;
}
else {
_splashProgressRing_->Width = 384;
_splashProgressRing_->Height = 384;
left = bounds.Width * 0.5 - _loadingImage_->Width * 0.5 - 400;
top = bounds.Height * 0.5 - _loadingImage_->Height * 0.5 - 135;
}
_splashProgressRing_->SetValue(Canvas::LeftProperty, left + _loadingImage_->Width * 0.5);
_splashProgressRing_->SetValue(Canvas::TopProperty, top + _loadingImage_->Height * 0.5);
_splashProgressRing_->Width = 144;
_splashProgressRing_->Height = 144;
left = bounds.Width * 0.5 - _loadingImage_->Width * 0.5 + 139;
top = bounds.Height * 0.5 - _loadingImage_->Height * 0.5 + 78;
_splashProgressRing_->SetValue(Canvas::LeftProperty, left);
_splashProgressRing_->SetValue(Canvas::TopProperty, top);
}
void
RingClientUWP::MainPage::OnResize(Platform::Object^ sender, Windows::UI::Core::WindowSizeChangedEventArgs^ e)
{
PositionImage();
PositionRing();
Dispatcher->RunAsync(CoreDispatcherPriority::High,
ref new DispatchedHandler([this]()
{
PositionImage();
PositionRing();
}));
}
void
......@@ -282,7 +293,11 @@ void
MainPage::Application_Suspending(Object^, Windows::ApplicationModel::SuspendingEventArgs^ e)
{
MSG_("Application_Suspending");
if (Frame->CurrentSourcePageType.Name ==
auto deferral = e->SuspendingOperation->GetDeferral();
MSG_("Hang up calls...");
RingD::instance->deinit();
deferral->Complete();
/*if (Frame->CurrentSourcePageType.Name ==
Interop::TypeName(MainPage::typeid).Name) {
auto deferral = e->SuspendingOperation->GetDeferral();
BeginExtendedExecution()
......@@ -305,7 +320,7 @@ MainPage::Application_Suspending(Object^, Windows::ApplicationModel::SuspendingE
deferral->Complete();
}
});
}
}*/
}
void
......
#pragma once
/**************************************************************************
/**************************************************************************
* Copyright (C) 2016 by Savoir-faire Linux *
* Author: Jäger Nicolas <nicolas.jager@savoirfairelinux.com> *
* Author: Traczyk Andreas <andreas.traczyk@savoirfairelinux.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
......@@ -16,6 +16,8 @@
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
**************************************************************************/
#pragma once
#include "MainPage.g.h"
using namespace Windows::UI::Xaml::Controls;
......@@ -36,6 +38,7 @@ public:
void hideLoadingOverlay();
property bool isLoading;
property bool isModal;
protected:
virtual void OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e) override;
......@@ -53,8 +56,6 @@ private:
EventRegistrationToken visibilityChangedEventToken;
void Application_Resuming(Object^ sender, Object^ args);
EventRegistrationToken applicationResumingEventToken;
//void Application_Closing(Object^ sender, Windows::UI::Core::^ e);
//EventRegistrationToken applicationClosingEventToken;
ExtendedExecutionSession^ session;
void SessionRevoked(Object^ sender, ExtendedExecutionRevokedEventArgs^ args);
......
......@@ -21,7 +21,6 @@
#include <direct.h>
#include "SmartPanel.xaml.h"
#include "qrencode.h"
#include "lodepng.h"
#include <MemoryBuffer.h> // IMemoryBufferByteAccess
using namespace Platform;
......@@ -1176,12 +1175,15 @@ RingClientUWP::Views::SmartPanel::_selectedAccountAvatarContainer__PointerReleas
auto bitmapImage = ref new Windows::UI::Xaml::Media::Imaging::BitmapImage();
bitmapImage->UriSource = uri;
unsigned char* buffer;
size_t buffSize;
lodepng_load_file(&buffer, &buffSize, Utils::toString(photoFile->Path).c_str());
std::string fileBuffer = Utils::getStringFromFile(Utils::toString(photoFile->Path));
std::string profilePath = RingD::instance->getLocalFolder() + ".profile";
_mkdir(profilePath.c_str());
lodepng_save_file(buffer, buffSize, (profilePath + "\\profile_image.png").c_str());
std::ofstream file((profilePath + "\\profile_image.png"),
std::ios::out | std::ios::trunc | std::ios::binary);
if (file.is_open()) {
file << fileBuffer;
file.close();
}
Configuration::UserPreferences::instance->PREF_PROFILE_HASPHOTO = true;
Configuration::UserPreferences::instance->save();
......
......@@ -213,7 +213,7 @@ GetNewGUID()
std::string
getStringFromFile(const std::string& filename)
{
std::ifstream file(filename);
std::ifstream file(filename, std::ios::binary);
return std::string((std::istreambuf_iterator<char>(file)),
(std::istreambuf_iterator<char>()));
}
......
......@@ -28,8 +28,8 @@
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
<RowDefinition Height="1.5*"/>
<RowDefinition Height="2*"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<StackPanel x:Name="_welcomePage_" Grid.Row="1">
<!--<TextBlock x:Uid="_welcomeMsg"
......@@ -42,9 +42,10 @@
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."
Foreground="DarkGray"
Foreground="#707370"
MaxWidth="410"
TextWrapping="WrapWholeWords"
TextAlignment="Justify"
......
......@@ -44,5 +44,5 @@ WelcomePage::PositionImage()
void
WelcomePage::OnResize(Platform::Object^ sender, Windows::UI::Core::WindowSizeChangedEventArgs^ e)
{
PositionImage();
//PositionImage();
}
\ No newline at end of file
#include "pch.h"
#include "lodepng.h"
#include <direct.h>
#include "Wizard.xaml.h"
#include "MainPage.xaml.h"
......@@ -97,16 +96,18 @@ Wizard::_avatarWebcamCaptureBtn__Click(Platform::Object^ sender, Windows::UI::Xa
auto bitmapImage = ref new Windows::UI::Xaml::Media::Imaging::BitmapImage();
bitmapImage->UriSource = uri;
unsigned char* buffer;
size_t buffSize;
lodepng_load_file(&buffer, &buffSize, Utils::toString(photoFile->Path).c_str());
std::string fileBuffer = Utils::getStringFromFile(Utils::toString(photoFile->Path));
std::string profilePath = RingD::instance->getLocalFolder() + ".profile";
_mkdir(profilePath.c_str());
lodepng_save_file(buffer, buffSize, (profilePath + "\\profile_image.png").c_str());
std::ofstream file((profilePath + "\\profile_image.png"),
std::ios::out | std::ios::trunc | std::ios::binary);
if (file.is_open()) {
file << fileBuffer;
file.close();
}
Configuration::UserPreferences::instance->PREF_PROFILE_HASPHOTO = true;
Configuration::UserPreferences::instance->save();
//Configuration::UserPreferences::instance->saveProfileToVCard();
brush->ImageSource = bitmapImage;
circle->Fill = brush;
......
This diff is collapsed.
This diff is collapsed.
......@@ -179,7 +179,6 @@
<ClInclude Include="LoadingPage.xaml.h">
<DependentUpon>LoadingPage.xaml</DependentUpon>
</ClInclude>
<ClInclude Include="lodepng.h" />
<ClInclude Include="MessageTextPage.xaml.h">
<DependentUpon>MessageTextPage.xaml</DependentUpon>
</ClInclude>
......@@ -293,7 +292,6 @@
<Image Include="Assets\TESTS\logo-ring.scale-150.png" />
<Image Include="Assets\TESTS\logo-ring.scale-200.png" />
<Image Include="Assets\TESTS\logo-ring.scale-400.png" />
<Image Include="Assets\TESTS\logo-ring.square-100.png" />
<Image Include="Assets\Wide310x150Logo.scale-200.png" />
</ItemGroup>
<ItemGroup>
......@@ -311,7 +309,6 @@
<ClCompile Include="LoadingPage.xaml.cpp">
<DependentUpon>LoadingPage.xaml</DependentUpon>
</ClCompile>
<ClCompile Include="lodepng.cpp" />
<ClCompile Include="MainPage.xaml.cpp">
<DependentUpon>MainPage.xaml</DependentUpon>
</ClCompile>
......
......@@ -77,9 +77,6 @@
<ClCompile Include="VCardUtils.cpp">
<Filter>Common</Filter>
</ClCompile>
<ClCompile Include="lodepng.cpp">
<Filter>Common</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="LoadingPage.xaml.h" />
......@@ -153,9 +150,6 @@
<ClInclude Include="VCardUtils.h">
<Filter>Common</Filter>
</ClInclude>
<ClInclude Include="lodepng.h">
<Filter>Common</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Image Include="Assets\AccountTypeRING.png">
......@@ -185,9 +179,6 @@
<Image Include="Assets\TESTS\logo-ring.scale-400.png">
<Filter>Assets\TESTS</Filter>
</Image>
<Image Include="Assets\TESTS\logo-ring.square-100.png">
<Filter>Assets\TESTS</Filter>
</Image>
<Image Include="Assets\LockScreenLogo.scale-200.png">
<Filter>Assets</Filter>
</Image>
......
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