public async void ListView_ItemClick(object sender, ItemClickEventArgs e) { if (e.ClickedItem is TelemetryLevelDisplay item) { switch (item.Level) { case DevicePortalUtil.FullTelemetryValue: case DevicePortalUtil.BasicTelemetryValue: // Clear the current status SetTelemetryLevelResult = string.Empty; // Display error if not logged in or level change failed if (!await LoginPopupControl.SignInAsync(Common.GetLocalizedText("PrivacySignInDescription")) || !await UpdatePrivacyLevelAsync(item.Level)) { SetTelemetryLevelResult = Common.GetLocalizedText("PrivacyLevelChangeFailed"); RevertToPreviousLevel(); } break; } } }
private async Task <bool> UpdatePrivacyLevelAsync(int level, bool promptUser = true) { // Return false if we're not signed in and we're not allowed to prompt the user if (!promptUser && !await DevicePortalUtil.IsSignedInAsync()) { return(false); } // Prompt the user for credentials if not logged in if (await LoginPopupControl.SignInAsync(Common.GetLocalizedText("PrivacySignInDescription"))) { var cred = DevicePortalUtil.GetCredential(); if (cred != null) { if (await DevicePortalUtil.SetTelemetryLevelAsync(cred.UserName, cred.Password, level)) { _previousLevel = level; return(true); } } } return(false); }