summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjh5.cho <jh5.cho@samsung.com>2017-07-04 02:48:01 (GMT)
committerKangho Hur <kangho.hur@samsung.com>2017-10-23 04:34:39 (GMT)
commit2b96d68e90168b4dc8a3f5ecf128cf2193132665 (patch)
tree1bc5fbd9ab215c72600e20d848feaaaedc892446
parent4dcc3c1f7f9fd6f39c3829711b61c8f0305e1c34 (diff)
downloadxamarin-forms-2b96d68e90168b4dc8a3f5ecf128cf2193132665.zip
xamarin-forms-2b96d68e90168b4dc8a3f5ecf128cf2193132665.tar.gz
xamarin-forms-2b96d68e90168b4dc8a3f5ecf128cf2193132665.tar.bz2
[MAPS] Give user time to provide consent before app launches
TASK=TCAPI-2422 Change-Id: I3c529fdaff6c1331013389d200ea34f824362bac
-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 0fd7029..1961fad 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 4399efb..cae21e2 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);