private async void Authenticate_Tapped(object sender, TappedRoutedEventArgs e) { try { this.IsEnabled = false; progressRing.Visibility = Visibility.Visible; var graph = new Graph(await MSAAuthenticator.GetAccessTokenAsync("User.Read")); //await (new MessageDialog(await graph.GetUserUniqueIdAsync())).ShowAsync(); var userId = await graph.GetUserUniqueIdAsync(); SecureKeyStorage.SetUserId(userId); } catch (Exception ex) { Debug.WriteLine($"Authenticate failed. {ex.ToString()}"); MainPage.Current.IsAskedAboutMSAPermission = false; MainPage.Current.isAskedAboutMSAPermissionThisTime = true; } finally { this.IsEnabled = true; FlyoutCloseRequest?.Invoke(this, new EventArgs()); } }
private async void BtnSignIn_Click(object sender, EventArgs e) { ((Button)sender).Enabled = false; signInSpinner.Visibility = ViewStates.Visible; var result = await AuthenticateDialog.ShowAsync(this, MsaAuthPurpose.App); if (result == MsaAuthResult.Success) { layouts.Add(Resource.Layout.Intro6); UpdateViewPagerLayout(); GoToNextPage(); } else { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.SetTitle(result.ToString() + "\n" + "Please try again later."); alert.SetPositiveButton("OK", (senderAlert, args) => { }); RunOnUiThread(() => { alert.Show(); }); MSAAuthenticator.DeleteUserUniqueId(); ((Button)sender).Enabled = true; } signInSpinner.Visibility = ViewStates.Gone; }
private async void InitAndroidPushNotifier() { Common.AndroidPushNotifier = new AndroidPushNotifier(await MSAAuthenticator.GetUserUniqueIdAsync()); Common.AndroidPushNotifier.Devices.CollectionChanged += DevicesCollectionChanged; await Common.AndroidPushNotifier.DiscoverAndroidDevices(ServiceFunctions.GetDeviceUniqueId()); }
private async void RefreshUserTrialStatus() { if (MSAAuthenticator.HasUserUniqueId()) { var userId = await MSAAuthenticator.GetUserUniqueIdAsync(); await TrialHelper.RefreshUserTrialStatusAsync(userId); } }
protected override void OnCreate(Bundle savedInstanceState) { RequestWindowFeature(WindowFeatures.NoTitle); base.OnCreate(savedInstanceState); if (MSAAuthenticator.HasUserUniqueId() || CloudServiceAuthenticationHelper.IsAuthenticatedForApiV3()) { LaunchHomeScreen(); return; } (new Classes.WhatsNew(this)).Shown(); //Don't show what's new dialog if this is the first time user opens the app. Instance = this; SetTheme(Resource.Style.MyTheme_Dark); Window.SetFlags(WindowManagerFlags.Fullscreen, WindowManagerFlags.Fullscreen); if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop) { Window.SetNavigationBarColor(Android.Graphics.Color.Black); Window.DecorView.SystemUiVisibility = StatusBarVisibility.Hidden; } SetContentView(Resource.Layout.Intro); viewPager = FindViewById <ViewPager>(Resource.Id.intro_viewPager); dots = FindViewById <TextView>(Resource.Id.intro_dotsText); btnNext = FindViewById <Button>(Resource.Id.intro_btnNext); btnSkip = FindViewById <Button>(Resource.Id.intro_btnSkip); layouts = new List <int>() { Resource.Layout.Intro1, Resource.Layout.Intro2, Resource.Layout.Intro3, Resource.Layout.Intro4, Resource.Layout.Intro4_1, Resource.Layout.Intro5, }; AddBottomDots(0); introViewPagerAdapter = new IntroViewPagerAdapter(this); viewPager.Adapter = introViewPagerAdapter; viewPagerPageChangeListener = new ViewPagerPageChangeListener(); viewPager.AddOnPageChangeListener(viewPagerPageChangeListener); OSHelper.ClearWebViewCache(ApplicationContext); btnNext.Click += BtnNext_Click; btnSkip.Click += BtnSkip_Click; }
protected override void OnCreate(Bundle savedInstanceState) { RequestWindowFeature(WindowFeatures.NoTitle); base.OnCreate(savedInstanceState); if (MSAAuthenticator.HasUserUniqueId()) { LaunchHomeScreen(); return; } (new Classes.WhatsNew(this)).Shown(); //Don't show what's new dialog if this is the first time user opens the app. Instance = this; if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop) { Window.DecorView.SystemUiVisibility = StatusBarVisibility.Hidden; } SetContentView(Resource.Layout.Intro); viewPager = FindViewById <ViewPager>(Resource.Id.intro_viewPager); dots = FindViewById <TextView>(Resource.Id.intro_dotsText); btnNext = FindViewById <Button>(Resource.Id.intro_btnNext); btnSkip = FindViewById <Button>(Resource.Id.intro_btnSkip); layouts = new List <int>() { Resource.Layout.Intro1, Resource.Layout.Intro2, Resource.Layout.Intro3, Resource.Layout.Intro4, Resource.Layout.Intro4_1, Resource.Layout.Intro5, }; AddBottomDots(0); introViewPagerAdapter = new IntroViewPagerAdapter(this); viewPager.Adapter = introViewPagerAdapter; viewPagerPageChangeListener = new ViewPagerPageChangeListener(); viewPager.AddOnPageChangeListener(viewPagerPageChangeListener); btnNext.Click += BtnNext_Click; btnSkip.Click += BtnSkip_Click; }
private async void ActivateFindingOtherDevices() { var graph = new Graph(await MSAAuthenticator.GetAccessTokenAsync("User.Read")); var userId = await graph.GetUserUniqueIdAsync(); SecureKeyStorage.SetUserId(userId); findOtherDevices = true; OnPropertyChanged("FindOtherDevices"); FindOtherDevicesProgressRingActive = false; FindOtherDevicesEnabled = true; #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed MainPage.Current.DiscoverOtherDevices(true); #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed }
private async void LogOutDialogClickListener(object sender, DialogClickEventArgs e) { if (await ServiceFunctions.RemoveDevice(this) == false) { Android.App.AlertDialog.Builder alert = new Android.App.AlertDialog.Builder(this); alert.SetTitle("Failed to log out.\nPlease make sure you have a working internet connection. If the problem persists, contact us."); alert.SetPositiveButton("OK", (IDialogInterfaceOnClickListener)null); RunOnUiThread(() => { alert.Show(); }); return; } MSAAuthenticator.DeleteUserUniqueId(); OSHelper.ClearAppDataAndExit(); FinishAffinity(); }