private async void RefreshUserTrialStatus() { if (MSAAuthenticator.HasUserUniqueId()) { var userId = await MSAAuthenticator.GetUserUniqueIdAsync(); await TrialHelper.RefreshUserTrialStatusAsync(userId); } }
private async void UpgradeButton_Tapped(object sender, TappedRoutedEventArgs e) { #if !DEBUG App.Tracker.Send(HitBuilder.CreateCustomEvent("Settings", "TryUpgrade", "Windows").Build()); #endif await TrialHelper.AskForUpgrade(); Model.CheckTrialStatus(); }
private async void Upgrade_Tapped(object sender, TappedRoutedEventArgs e) { UpgradeButton.IsEnabled = false; CancelButton.IsEnabled = false; progressRing.Visibility = Visibility.Visible; progressRing.IsActive = true; await TrialHelper.TryUpgrade(); TrialHelper.UpgradeFlyoutCompletion.SetResult(true); FlyoutCloseRequest?.Invoke(this, new EventArgs()); }
protected override async void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); #if !DEBUG App.Tracker.Send(HitBuilder.CreateScreenView("Send").Build()); #endif PersistentDisplay.ActivatePersistentDisplay(); if (Frame.BackStackDepth > 0) { if (Frame.BackStack[Frame.BackStackDepth - 1].SourcePageType == typeof(MainSend)) { Frame.BackStack.RemoveAt(Frame.BackStackDepth - 1); } } var rs = MainPage.Current.GetSelectedSystem(); bool isDestinationAndroid; IRomePackageManager packageManager; if (rs is NormalizedRemoteSystem) { isDestinationAndroid = true; packageManager = MainPage.Current.AndroidPackageManager; var nrs = rs as NormalizedRemoteSystem; if ((!string.IsNullOrEmpty(nrs.AppVersion)) && (Version.TryParse(nrs.AppVersion, out Version remoteAppVersion)) && (remoteAppVersion < new Version("2.1.4"))) { MainPage.Current.AndroidPackageManager.Mode = AndroidRomePackageManager.AndroidPackageManagerMode.MessageCarrier; } else { PackageManagerHelper.InitAndroidPackageManagerMode(); } } else { isDestinationAndroid = false; packageManager = MainPage.Current.PackageManager; } string deviceName = (new Windows.Security.ExchangeActiveSyncProvisioning.EasClientDeviceInformation()).FriendlyName; var mode = e.Parameter.ToString(); if ((mode == "file") && (!(await IsAllowedToSendAsync()))) { ViewModel.SendStatus = ""; await TrialHelper.AskForUpgradeWhileSending(); if (!(await IsAllowedToSendAsync())) { #if !DEBUG App.Tracker.Send(HitBuilder.CreateCustomEvent("Send", "AskedToUpgrade", "Rejected").Build()); #endif PersistentDisplay.ReleasePersistentDisplay(); Frame.GoBack(); return; } #if !DEBUG App.Tracker.Send(HitBuilder.CreateCustomEvent("Send", "AskedToUpgrade", "Accepted").Build()); #endif ViewModel.SendStatus = "Connecting..."; } bool succeed = true; FileTransferResult fileTransferResult = FileTransferResult.Successful; try { if (mode == "launchUri") { await LaunchUri(rs); } else if (mode == "text") { string text = SendDataTemporaryStorage.Text; bool fastSendResult = await TrySendFastClipboard(text, rs, deviceName); if (fastSendResult) { SendTextFinished(""); } else { ViewModel.ProgressPercentIndicatorVisibility = Visibility.Visible; RomeAppServiceConnectionStatus result = await Connect(rs); if (result != RomeAppServiceConnectionStatus.Success) { HideEverything(); succeed = false; string errorMessage; if ((result == RomeAppServiceConnectionStatus.RemoteSystemUnavailable) && (packageManager is AndroidRomePackageManager)) { errorMessage = "Can't connect to device. Open Roamit on your Android device and then try again."; } else { errorMessage = result.ToString(); } await(new MessageDialog(errorMessage, "Can't connect")).ShowAsync(); Frame.GoBack(); return; } ViewModel.UnlockNoticeVisibility = Visibility.Collapsed; await SendText(packageManager, deviceName, text); } } else if (mode == "file") { ViewModel.ProgressPercentIndicatorVisibility = Visibility.Visible; RomeAppServiceConnectionStatus result = await Connect(rs); if (result != RomeAppServiceConnectionStatus.Success) { HideEverything(); succeed = false; string errorMessage; if ((result == RomeAppServiceConnectionStatus.RemoteSystemUnavailable) && (packageManager is AndroidRomePackageManager)) { errorMessage = "Can't connect to device. Open Roamit on your Android device and then try again."; } else { errorMessage = result.ToString(); } await(new MessageDialog(errorMessage, "Can't connect")).ShowAsync(); Frame.GoBack(); return; } ViewModel.UnlockNoticeVisibility = Visibility.Collapsed; if (!isDestinationAndroid) { ViewModel.LeaveScreenOnNoticeVisibility = Visibility.Visible; } fileTransferResult = await SendFile(rs, packageManager, deviceName); if (fileTransferResult != FileTransferResult.Successful) { HideEverything(); succeed = false; Frame.GoBack(); return; } if (!isDestinationAndroid) { ViewModel.LeaveScreenOnNoticeVisibility = Visibility.Collapsed; } } else { succeed = false; await(new MessageDialog("MainSend::Invalid parameter.")).ShowAsync(); Frame.GoBack(); return; } } finally { PersistentDisplay.ReleasePersistentDisplay(); #if !DEBUG if (rs is NormalizedRemoteSystem) { App.Tracker.Send(HitBuilder.CreateCustomEvent("SendToAndroid", mode, succeed ? "Success" : ((mode == "file") ? fileTransferResult.ToString() : "Failed")).Build()); } else { App.Tracker.Send(HitBuilder.CreateCustomEvent("SendToWindows", mode, succeed ? "Success" : ((mode == "file") ? fileTransferResult.ToString() : "Failed")).Build()); } #endif sendingFile = false; } if (SendDataTemporaryStorage.IsSharingTarget) { if (App.ShareOperation == null) { #if !DEBUG App.Tracker.Send(HitBuilder.CreateCustomEvent("Send", "UriTarget").Build()); #endif await Task.Delay(TimeSpan.FromSeconds(1.5)); App.Current.Exit(); } else { #if !DEBUG App.Tracker.Send(HitBuilder.CreateCustomEvent("Send", "ShareTarget").Build()); #endif await Task.Delay(TimeSpan.FromSeconds(1.5)); App.ShareOperation.ReportCompleted(); } SendDataTemporaryStorage.IsSharingTarget = false; App.ShareOperation = null; } else { ViewModel.GoBackButtonVisibility = Visibility.Visible; GoBackButtonShowStoryboard.Begin(); if (succeed) { await AskForReviewIfNecessary(); } #if !DEBUG App.Tracker.Send(HitBuilder.CreateCustomEvent("Send", "WithinApp").Build()); #endif } }
protected override async void OnActivated(IActivatedEventArgs e) { Debug.WriteLine("Activated."); Frame rootFrame = Window.Current.Content as Frame; bool isJustLaunched = (rootFrame == null); if (e is ToastNotificationActivatedEventArgs) { var toastActivationArgs = e as ToastNotificationActivatedEventArgs; // Parse the query string QueryString args = QueryString.Parse(toastActivationArgs.Argument); if (!args.Contains("action")) { LaunchRootFrameIfNecessary(ref rootFrame, true); return; } HistoryRow hr; switch (args["action"]) { case "cloudClipboard": LaunchRootFrameIfNecessary(ref rootFrame, false); rootFrame.Navigate(typeof(ClipboardReceive), "CLOUD_CLIPBOARD"); break; case "clipboardReceive": LaunchRootFrameIfNecessary(ref rootFrame, false); rootFrame.Navigate(typeof(ClipboardReceive), args["guid"]); break; case "fileProgress": LaunchRootFrameIfNecessary(ref rootFrame, false); if (rootFrame.Content is MainPage) { break; } rootFrame.Navigate(typeof(MainPage)); break; case "fileFinished": LaunchRootFrameIfNecessary(ref rootFrame, false); if (rootFrame.Content is MainPage) { break; } rootFrame.Navigate(typeof(MainPage), "history"); break; case "openFolder": hr = await GetHistoryItemGuid(Guid.Parse(args["guid"])); await LaunchOperations.LaunchFolderFromPathAsync((hr.Data as ReceivedFileCollection).StoreRootPath); if (isJustLaunched) { Application.Current.Exit(); } break; case "openFolderSingleFile": hr = await GetHistoryItemGuid(Guid.Parse(args["guid"])); await LaunchOperations.LaunchFolderFromPathAndSelectSingleItemAsync((hr.Data as ReceivedFileCollection).Files[0].StorePath, (hr.Data as ReceivedFileCollection).Files[0].Name); if (isJustLaunched) { Application.Current.Exit(); } break; case "openSingleFile": hr = await GetHistoryItemGuid(Guid.Parse(args["guid"])); await LaunchOperations.LaunchFileFromPathAsync((hr.Data as ReceivedFileCollection).Files[0].StorePath, (hr.Data as ReceivedFileCollection).Files[0].Name); if (isJustLaunched) { Application.Current.Exit(); } break; case "saveAsSingleFile": case "saveAs": LaunchRootFrameIfNecessary(ref rootFrame, false); rootFrame.Navigate(typeof(ProgressPage)); var guid = Guid.Parse(args["guid"]); await ReceivedSaveAsHelper.SaveAs(guid); if ((isJustLaunched) || (DeviceInfo.FormFactorType != DeviceInfo.DeviceFormFactorType.Desktop)) { Application.Current.Exit(); } else { rootFrame.GoBack(); } break; default: LaunchRootFrameIfNecessary(ref rootFrame, true); break; } } else if (e.Kind == ActivationKind.Protocol) { ProtocolActivatedEventArgs pEventArgs = e as ProtocolActivatedEventArgs; if ((pEventArgs.Uri.AbsoluteUri.ToLower() == "roamit://wake") || (pEventArgs.Uri.AbsoluteUri.ToLower() == "roamit://wake/")) { Debug.WriteLine("Wake request received"); Application.Current.Exit(); } else { string clipboardData = ParseFastClipboardUri(pEventArgs.Uri.AbsoluteUri); string launchUriData = ParseLaunchUri(pEventArgs.Uri.AbsoluteUri); bool isUpgrade = ParseUpgrade(pEventArgs.Uri.AbsoluteUri); bool isSettings = ParseSettings(pEventArgs.Uri.AbsoluteUri); bool isReceiveDialog = ParseReceive(pEventArgs.Uri.AbsoluteUri); if (isUpgrade) { if (rootFrame == null) { LaunchRootFrameIfNecessary(ref rootFrame, false); rootFrame.Navigate(typeof(MainPage), "upgrade"); } else { #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed TrialHelper.AskForUpgrade(); #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed } } else if (isSettings) { if (rootFrame == null) { LaunchRootFrameIfNecessary(ref rootFrame, false); } rootFrame.Navigate(typeof(MainPage), "settings"); } else if (isReceiveDialog) { if (rootFrame == null) { LaunchRootFrameIfNecessary(ref rootFrame, false); } rootFrame.Navigate(typeof(MainPage), "receiveDialog"); } else if (clipboardData.Length > 0) { string[] parts = clipboardData.Split('?'); var guid = await TextReceiver.QuickTextReceivedAsync(parts[0].DecodeBase64(), parts[1].DecodeBase64()); LaunchRootFrameIfNecessary(ref rootFrame, false); rootFrame.Navigate(typeof(ClipboardReceive), guid.ToString()); } else if (launchUriData.Length > 0) { #if !DEBUG App.Tracker.Send(HitBuilder.CreateCustomEvent("ExtensionCalled", "").Build()); #endif string type = ExternalContentHelper.SetUriData(new Uri(launchUriData.DecodeBase64())); SendDataTemporaryStorage.IsSharingTarget = true; if (rootFrame == null) { LaunchRootFrameIfNecessary(ref rootFrame, false); rootFrame.Navigate(typeof(MainPage), new ShareTargetDetails { Type = type, }); } else { MainPage.Current.BeTheShareTarget(new ShareTargetDetails { Type = type, }); } } else { LaunchRootFrameIfNecessary(ref rootFrame, true); } } } else { LaunchRootFrameIfNecessary(ref rootFrame, true); } base.OnActivated(e); }