summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKangho Hur <kangho.hur@samsung.com>2017-07-18 07:21:32 +0000
committerGerrit Code Review <gerrit@review.ap-northeast-2.compute.internal>2017-07-18 07:21:32 +0000
commit360bf6c887d512f47e5f854afa1b28e2d7cd3439 (patch)
tree12704e932db849ae2f6812bbdbfca6b870ab2efe
parent7f092c8b1504249bc092df6347a3b484c4b5c9a7 (diff)
parentae5b227f63124eede542db664d842315acb3b041 (diff)
downloadxamarin-forms-360bf6c887d512f47e5f854afa1b28e2d7cd3439.tar.gz
xamarin-forms-360bf6c887d512f47e5f854afa1b28e2d7cd3439.tar.bz2
xamarin-forms-360bf6c887d512f47e5f854afa1b28e2d7cd3439.zip
Merge "[MAPS] Give user time to provide consent before app launches" into tizen
-rw-r--r--[-rwxr-xr-x]Xamarin.Forms.Maps.Tizen/FormsMaps.cs39
-rw-r--r--Xamarin.Forms.Platform.Tizen/FormsApplication.cs19
2 files changed, 41 insertions, 17 deletions
diff --git a/Xamarin.Forms.Maps.Tizen/FormsMaps.cs b/Xamarin.Forms.Maps.Tizen/FormsMaps.cs
index 0fd7029c..1961fada 100755..100644
--- a/Xamarin.Forms.Maps.Tizen/FormsMaps.cs
+++ b/Xamarin.Forms.Maps.Tizen/FormsMaps.cs
@@ -1,6 +1,9 @@
-using System.Diagnostics;
+using System;
+using System.Diagnostics;
+using System.Threading.Tasks;
using Tizen.Maps;
using Xamarin.Forms.Maps.Tizen;
+using Xamarin.Forms.Platform.Tizen;
namespace Xamarin
{
@@ -27,22 +30,36 @@ namespace Xamarin
{
ProviderName = provider;
AuthenticationToken = authenticationToken;
- Init();
- }
- internal static async void Init()
- {
if (IsInitialized)
return;
- var requestResult = await MapService.RequestUserConsent(ProviderName);
- if (requestResult)
+
+ FormsApplication.RequestingUserConsentFunc = new Func<Task>(() =>
{
- _mapService = new MapService(ProviderName, AuthenticationToken);
- if (_mapService != null)
+ TaskCompletionSource<bool> userConsentWaiter = new TaskCompletionSource<bool>();
+ UserConsentAction(userConsentWaiter);
+ return userConsentWaiter.Task;
+ });
+ }
+
+ static async void UserConsentAction(TaskCompletionSource<bool> tcs)
+ {
+ var result = await MapService.RequestUserConsent(ProviderName);
+ {
+ if (result)
+ {
+ _mapService = new MapService(ProviderName, AuthenticationToken);
+ if (_mapService != null)
+ {
+ GeocoderBackend.Register();
+ IsInitialized = true;
+ }
+ }
+ else
{
- GeocoderBackend.Register();
- IsInitialized = true;
+ Debug.WriteLine("Failed to get user consent which is required to use map service");
}
+ tcs.SetResult(result);
}
}
}
diff --git a/Xamarin.Forms.Platform.Tizen/FormsApplication.cs b/Xamarin.Forms.Platform.Tizen/FormsApplication.cs
index 4399efb4..cae21e27 100644
--- a/Xamarin.Forms.Platform.Tizen/FormsApplication.cs
+++ b/Xamarin.Forms.Platform.Tizen/FormsApplication.cs
@@ -1,13 +1,13 @@
using System;
using System.ComponentModel;
using System.Diagnostics;
-using Xamarin.Forms.Internals;
-using Tizen.Applications;
+using System.Threading.Tasks;
using ElmSharp;
+using Tizen.Applications;
+using Xamarin.Forms.Internals;
using EButton = ElmSharp.Button;
-using EProgressBar = ElmSharp.ProgressBar;
using EColor = ElmSharp.Color;
-using ELabel = ElmSharp.Label;
+using EProgressBar = ElmSharp.ProgressBar;
namespace Xamarin.Forms.Platform.Tizen
{
@@ -92,8 +92,16 @@ namespace Xamarin.Forms.Platform.Tizen
}
}
- public void LoadApplication(Application application)
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static Func<Task> RequestingUserConsentFunc { get; set; } = null;
+
+ public async void LoadApplication(Application application)
{
+ if (RequestingUserConsentFunc != null)
+ {
+ await RequestingUserConsentFunc();
+ }
+
if (null == MainWindow)
{
throw new NullReferenceException("MainWindow is not prepared. This method should be called in OnCreated().");
@@ -104,7 +112,6 @@ namespace Xamarin.Forms.Platform.Tizen
throw new ArgumentNullException("application");
}
_application = application;
-
Application.Current = application;
application.SendStart();
application.PropertyChanged += new PropertyChangedEventHandler(this.AppOnPropertyChanged);