public override void RowSelected(UITableView tableView, NSIndexPath indexPath) { if (!(ion is RemoteIosION)) { var userID = KeychainAccess.ValueForKey("userID"); if (selectedUser != null) { if (tableItems[indexPath.Row].deviceId == UIDevice.CurrentDevice.IdentifierForVendor.ToString() && ion.portal.isUploading) { return; } if (selectedUser.Contains(tableItems[indexPath.Row])) { selectedUser.Clear(); NSUserDefaults.StandardUserDefaults.SetString("", "viewedUser"); NSUserDefaults.StandardUserDefaults.SetString("", "viewedLayout"); } else if (tableItems[indexPath.Row].isUserOnline) { selectedUser.Clear(); selectedUser.Add(tableItems[indexPath.Row]); NSUserDefaults.StandardUserDefaults.SetString(tableItems[indexPath.Row].id.ToString(), "viewedUser"); NSUserDefaults.StandardUserDefaults.SetString(tableItems[indexPath.Row].layoutId.ToString(), "viewedLayout"); } tableView.ReloadData(); } } }
public override void ViewWillAppear(bool animated) { base.ViewWillAppear(animated); Console.WriteLine("AccessRequestViewController userID stored " + KeychainAccess.ValueForKey("userID")); if (string.IsNullOrEmpty(KeychainAccess.ValueForKey("userID"))) { requestManager.pendingTable.DataSource = null; requestManager.pendingTable.ReloadData(); UIView.Transition( fromView: settingsManager.settingsView, toView: requestManager.accessView, duration: .1, options: UIViewAnimationOptions.TransitionNone, completion: () => { settingsManager.settingsView.Hidden = true; requestManager.accessView.Hidden = true; loggedOutLabel.Hidden = false; accessHolderView.SendSubviewToBack(settingsManager.settingsView); accessHolderView.BringSubviewToFront(requestManager.accessView); } ); this.NavigationItem.RightBarButtonItem = null; } else { requestManager.getAllRequests(this, EventArgs.Empty); requestManager.accessView.Hidden = false; settingsManager.settingsView.Hidden = false; this.NavigationItem.RightBarButtonItem = settingsButton; loggedOutLabel.Hidden = true; } }
/// <summary> /// Removes the saved settings for a user and returns them to the log in screen /// </summary> /// <param name="sender">Sender.</param> /// <param name="e">E.</param> public async void LogOutUser(object sender, EventArgs e) { var userID = KeychainAccess.ValueForKey("userID"); await ion.portal.LogoutAsync(); ion.settings._portal.rememberMe = false; ion.settings._portal.userId = 0; ion.settings._portal.username = ""; ion.settings._portal.password = ""; loginView = new RemoteLoginView(remoteHolderView); loginView.submitButton.TouchUpInside += credentialsCheck; remoteHolderView.AddSubview(loginView.loginView); portalControl.portalView.RemoveFromSuperview(); portalControl.uploadButton.TouchUpInside -= showUploads; portalControl.codeButton.TouchUpInside -= showCodeManager; portalControl.accessButton.TouchUpInside -= showAccessManager; portalControl.remoteButton.TouchUpInside -= showRemoteViewing; portalControl = null; profileView.profileView.RemoveFromSuperview(); profileView = null; this.NavigationItem.RightBarButtonItem = register; }
public async void startUploadStatus() { var window = UIApplication.SharedApplication.KeyWindow; var rootVC = window.RootViewController as IONPrimaryScreenController; var userID = KeychainAccess.ValueForKey("userID"); var uploadingDevice = new PhysicalDevice { name = UIDevice.CurrentDevice.Name, model = UIDevice.CurrentDevice.Model, uniqueIdentifier = UIDevice.CurrentDevice.IdentifierForVendor.ToString(), }; ////CREATE OR UPDATE A LAYOUT ENTRY FOR A DEVICE UNDER THE LOGGED IN ACCOUNT AND SET THAT LAYOUT ENTRY TO BE UPDATED THIS SESSION var response = ion.portal.BeginAppStateUpload(ion); // todo [email protected]: this needs to be localized. also, we can use error codes instead of strings /* * if(feedback != null){ * var textResponse = await feedback.Content.ReadAsStringAsync(); * Console.WriteLine(textResponse); * //parse the text string into a json object to be deserialized * JObject response = JObject.Parse(textResponse); * * var success = response.GetValue("success"); * var errorMessage = response.GetValue("message").ToString(); * * if(success.ToString() == "true"){ * var layoutID = response.GetValue("layoutid").ToString(); * KeychainAccess.SetValueForKey(layoutID,"layoutid"); * * var alert = UIAlertController.Create ("Begin Upload", errorMessage, UIAlertControllerStyle.Alert); * alert.AddAction (UIAlertAction.Create ("Ok", UIAlertActionStyle.Cancel, null)); * rootVC.PresentViewController (alert, animated: true, completionHandler: null); * * startUploading(); * uploadButton = new UIBarButtonItem(stopButton); * this.NavigationItem.RightBarButtonItem = uploadButton; * } else { * ////AN UPLOADING SESSION FAILED TO BE UPDATED. MOST LIKELY DUE TO A SECOND DEVICE STARTING AN UPLOAD ON THE SAME ACCOUNT * var alert = UIAlertController.Create ("Start Upload", errorMessage.ToString(), UIAlertControllerStyle.Alert); * alert.AddAction (UIAlertAction.Create ("Ok", UIAlertActionStyle.Cancel, null)); * rootVC.PresentViewController (alert, animated: true, completionHandler: null); * } * * } else { * var alert = UIAlertController.Create ("Begin Upload", "Unable to begin upload. Please try again.", UIAlertControllerStyle.Alert); * alert.AddAction (UIAlertAction.Create ("Ok", UIAlertActionStyle.Cancel, null)); * rootVC.PresentViewController (alert, animated: true, completionHandler: null); * } */ selectionView.GetAccessList(); }
public async void startUploading() { await Task.Delay(TimeSpan.FromMilliseconds(2)); var userID = KeychainAccess.ValueForKey("userID"); var layoutID = KeychainAccess.ValueForKey("layoutid"); /////A LAYOUT ID WAS CREATED OR RETRIEVED AND CAN BE USED FOR UPLOADING THE CURRENT DEVICE LAYOUT // todo [email protected]: this needs to be localized. also, we can use error codes instead of strings ion.portal.BeginAppStateUpload(ion); /* * while(ion.webServices.uploading){ * var feedback = await ion.webServices.uploadSystemLayout(ion, userID, layoutID); * if(feedback != null){ * var textResponse = await feedback.Content.ReadAsStringAsync(); * JObject response = JObject.Parse(textResponse); * var success = response.GetValue("success").ToString(); * * if(success.ToString() == "false"){ * var window = UIApplication.SharedApplication.KeyWindow; * var rootVC = window.RootViewController as IONPrimaryScreenController; * * ion.webServices.uploading = false; * * var errorMessage = response.GetValue("message").ToString(); * * var alert = UIAlertController.Create ("End Upload", errorMessage, UIAlertControllerStyle.Alert); * alert.AddAction (UIAlertAction.Create ("Ok", UIAlertActionStyle.Cancel, null)); * rootVC.PresentViewController (alert, animated: true, completionHandler: null); * selectionView.GetAccessList(); * uploadButton = new UIBarButtonItem(startButton); * this.NavigationItem.RightBarButtonItem = uploadButton; * } else { * var logging = response.GetValue("logging").ToString(); * * /////CHECK LOGGING STATUS TO BEGIN DATA LOGGING FROM REMOTE CONTROL * if(logging == "1" && !ion.dataLogManager.isRecording){ * await ion.dataLogManager.BeginRecording(TimeSpan.FromSeconds(NSUserDefaults.StandardUserDefaults.IntForKey("settings_default_logging_interval"))); * } * /////CHECK LOGGING STATUS TO END DATA LOGGING FROM REMOTE CONTROL * else if (logging == "0" && ion.dataLogManager.isRecording){ * await ion.dataLogManager.StopRecording(); * } * } * } else { * ion.webServices.uploading = false; * } * await Task.Delay(TimeSpan.FromSeconds(1)); * } */ }
public void makeCellData(double cellWidth, double cellHeight, ConnectionData user) { ion = AppState.context as IosION; var currentlyViewing = NSUserDefaults.StandardUserDefaults.StringForKey("viewedUser"); header = new UILabel(new CGRect(0, 0, .5 * cellWidth, .5 * cellHeight)); header.TextAlignment = UITextAlignment.Left; header.AdjustsFontSizeToFitWidth = true; deviceInfo = new UILabel(new CGRect(0, .5 * cellHeight, .5 * cellWidth, .5 * cellHeight)); deviceInfo.Font = UIFont.ItalicSystemFontOfSize(18f); deviceInfo.Text = user.deviceName; deviceInfo.AdjustsFontSizeToFitWidth = true; status = new UILabel(new CGRect(.5 * cellWidth, 0, .3 * cellWidth, cellHeight)); status.TextAlignment = UITextAlignment.Left; status.TextColor = UIColor.FromRGB(49, 111, 18); status.AdjustsFontSizeToFitWidth = true; header.Text = " " + user.displayName; if (Convert.ToInt32(KeychainAccess.ValueForKey("userID")) == user.id) { header.Text = " Your Account"; if (ion is RemoteIosION && UIDevice.CurrentDevice.IdentifierForVendor.ToString() == user.deviceId) { status.TextColor = UIColor.Red; status.Text = "Uploading"; } else { status.Text = "Viewable"; } } else if (ion is RemoteIosION && !String.IsNullOrEmpty(currentlyViewing) && currentlyViewing == user.id.ToString()) { status.Text += "Viewing"; status.TextColor = UIColor.Blue; } else { if (user.isUserOnline) { status.Text += "Viewable"; } } this.AddSubview(header); this.AddSubview(deviceInfo); this.AddSubview(status); }
/// <summary> /// Post to the server and get the list of open requests for the user /// </summary> /// <param name="sender">Sender.</param> /// <param name="e">E.</param> public async void getAllRequests(object sender, EventArgs e) { refreshButton.Enabled = false; loadingRequests.StartAnimating(); await Task.Delay(TimeSpan.FromMilliseconds(1)); pendingUsers = new List <requestData>(); var userID = KeychainAccess.ValueForKey("userID"); // todo [email protected]: this needs to be localized. also, we can use error codes instead of strings var response = await ion.portal.RequestPendingAccessCodesAsync(); /* * * var feedback = await ion.webServices.getAllRequests(userID); * var window = UIApplication.SharedApplication.KeyWindow; * var rootVC = window.RootViewController as IONPrimaryScreenController; * * if(feedback != null){ * var textResponse = await feedback.Content.ReadAsStringAsync(); * Console.WriteLine(textResponse); * //parse the text string into a json object to be deserialized * JObject response = JObject.Parse(textResponse); * var success = response.GetValue("success"); * * if(success.ToString() == "true"){ * var users = response.GetValue("users"); * * foreach(var user in users){ * var deserializedToken = JsonConvert.DeserializeObject<requestData>(user.ToString()); * pendingUsers.Add(deserializedToken); * } * } else { * var errorMessage = response.GetValue("message").ToString(); * * var alert = UIAlertController.Create ("Access Requests", errorMessage, UIAlertControllerStyle.Alert); * alert.AddAction (UIAlertAction.Create ("Ok", UIAlertActionStyle.Cancel, null)); * rootVC.PresentViewController (alert, animated: true, completionHandler: null); * } * } else { * var alert = UIAlertController.Create ("Access Requests", "There was no response. Please try again.", UIAlertControllerStyle.Alert); * alert.AddAction (UIAlertAction.Create ("Ok", UIAlertActionStyle.Cancel, null)); * rootVC.PresentViewController (alert, animated: true, completionHandler: null); * } */ pendingTable.Source = new AccessRequestTableSource(pendingUsers, .1 * accessView.Bounds.Height); pendingTable.ReloadData(); loadingRequests.StopAnimating(); refreshButton.Enabled = true; }
public async Task DeleteUserRequests(UITableView tableView, Foundation.NSIndexPath indexPath) { await Task.Delay(TimeSpan.FromMilliseconds(1)); WebClient wc = new WebClient(); wc.Proxy = null; var userID = KeychainAccess.ValueForKey("userID"); //Create the data package to send for the post request //Key value pair for post variable check var data = new System.Collections.Specialized.NameValueCollection(); data.Add("deleteViewerAccess", "true"); data.Add("userID", userID); data.Add("accessID", tableItems[indexPath.Row].id.ToString()); try{ //initiate the post request and get the request result in a byte array byte[] result = wc.UploadValues(deleteRequestUrl, data); //get the string conversion for the byte array var textResponse = Encoding.UTF8.GetString(result); Console.WriteLine(textResponse); //parse the text string into a json object to be deserialized JObject response = JObject.Parse(textResponse); var success = response.GetValue("success"); var window = UIApplication.SharedApplication.KeyWindow; var rootVC = window.RootViewController as IONPrimaryScreenController; var responseMessage = response.GetValue("message"); var alert = UIAlertController.Create("Delete Request", responseMessage.ToString(), UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Cancel, null)); rootVC.PresentViewController(alert, animated: true, completionHandler: null); if (success.ToString() == "false") { tableItems.Add(new accessUserData() { displayName = tableItems[indexPath.Row].displayName, id = tableItems[indexPath.Row].id, userEmail = tableItems[indexPath.Row].userEmail }); tableView.ReloadData(); } } catch (Exception exception) { Console.WriteLine("Exception: " + exception); var window = UIApplication.SharedApplication.KeyWindow; var rootVC = window.RootViewController as IONPrimaryScreenController; var alert = UIAlertController.Create("Delete Request", "There was no response. Please try again.", UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Cancel, null)); rootVC.PresentViewController(alert, animated: true, completionHandler: null); } }
public async void stopUploadStatus() { var window = UIApplication.SharedApplication.KeyWindow; var rootVC = window.RootViewController as IONPrimaryScreenController; var userID = KeychainAccess.ValueForKey("userID"); var layoutID = KeychainAccess.ValueForKey("layoutid"); // todo [email protected]: this needs to be localized. also, we can use error codes instead of strings // todo [email protected]: are we changing the fact that they are logging in or that they are uploading? /* * online and uploading should be distinct. for instance, i can envision a situation in which a amanager or * employee would like to ping an account requsting remote access. this would require that that we maintain the * distinction between online and uploading */ ion.portal.EndAppStateUpload(); /* * var feedback = await ion.webServices.updateOnlineStatus(userID, layoutID); * * if(feedback != null){ * KeychainAccess.SetValueForKey(null,"layoutid"); * * var textResponse = await feedback.Content.ReadAsStringAsync(); * Console.WriteLine(textResponse); * //parse the text string into a json object to be deserialized * JObject response = JObject.Parse(textResponse); * * uploadButton = new UIBarButtonItem(startButton); * this.NavigationItem.RightBarButtonItem = uploadButton; * * var errorMessage = response.GetValue("message").ToString(); * * var alert = UIAlertController.Create ("End Upload", errorMessage, UIAlertControllerStyle.Alert); * alert.AddAction (UIAlertAction.Create ("Ok", UIAlertActionStyle.Cancel, null)); * rootVC.PresentViewController (alert, animated: true, completionHandler: null); * } else { * var alert = UIAlertController.Create ("End Upload", "There was an issue during the status update. Please try again.", UIAlertControllerStyle.Alert); * alert.AddAction (UIAlertAction.Create ("Ok", UIAlertActionStyle.Cancel, null)); * rootVC.PresentViewController (alert, animated: true, completionHandler: null); * } */ selectionView.GetAccessList(); }
/// <summary> /// Posts the entered code and checks for a match to link users together /// </summary> /// <param name="sender">Sender.</param> /// <param name="e">E.</param> public async void submitCode(object sender, EventArgs e) { if (submitCodeField.Text.Length >= 8 && submitCodeField.Text.Length <= 10) { var userID = KeychainAccess.ValueForKey("userID"); // todo [email protected]: this needs to be localized. also, we can use error codes instead of strings var response = await ion.portal.SubmitAccessCodeAsync(submitCodeField.Text); /* * var feedback = await ion.webServices.submitAccessCode(submitCodeField.Text,userID); * * var window = UIApplication.SharedApplication.KeyWindow; * var rootVC = window.RootViewController as IONPrimaryScreenController; * * if(feedback != null){ * var textResponse = await feedback.Content.ReadAsStringAsync(); * Console.WriteLine(textResponse); * //parse the text string into a json object to be deserialized * JObject response = JObject.Parse(textResponse); * var responseMessage = response.GetValue("message").ToString(); * * var alert = UIAlertController.Create ("Confirm Code", responseMessage, UIAlertControllerStyle.Alert); * alert.AddAction (UIAlertAction.Create ("Ok", UIAlertActionStyle.Cancel, null)); * rootVC.PresentViewController (alert, animated: true, completionHandler: null); * } else { * var alert = UIAlertController.Create ("Confirm Code", "There was no response. Please try again.", UIAlertControllerStyle.Alert); * alert.AddAction (UIAlertAction.Create ("Ok", UIAlertActionStyle.Cancel, null)); * rootVC.PresentViewController (alert, animated: true, completionHandler: null); * } * submitCodeField.Text = ""; */ } else { var window = UIApplication.SharedApplication.KeyWindow; var rootVC = window.RootViewController as IONPrimaryScreenController; var alert = UIAlertController.Create("Confirm Code", "Code entered does not match the required length", UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Cancel, null)); rootVC.PresentViewController(alert, animated: true, completionHandler: null); } }
/// <summary> /// Disconnects all gauges, stops data logging, and remote viewing /// </summary> private async void OnShutdownClicked() { await Task.Delay(TimeSpan.FromMilliseconds(1)); Console.WriteLine("Clicked shutdown"); var alert = UIAlertController.Create(Strings.Exit.SHUTDOWN, "This will disconnect all gauges, end data logging, and disconnect any remote operations", UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create(Strings.OK, UIAlertActionStyle.Default, (action) => { Console.WriteLine("Turn everything off"); var ion = AppState.context as IosION; var userID = KeychainAccess.ValueForKey("userID"); foreach (var device in ion.deviceManager.devices) { if (device.isConnected) { device.connection.Disconnect(); } } if (ion.dataLogManager.isRecording) { ion.dataLogManager.StopRecording(); } if (ion.portal.isUploading) { ion.portal.EndAppStateUpload(); } if (ion is RemoteIosION) { AppState.context = new LocalIosION(ion.portal); setMainMenu(); } ion.portal.LogoutAsync(); })); alert.AddAction(UIAlertAction.Create(Strings.CANCEL, UIAlertActionStyle.Cancel, (action) => { Console.WriteLine("Cancel shutdown"); })); alert.Show(); }
public async void startUpload(object sender, EventArgs e) { uploadActivity = new UIActivityIndicatorView(new CGRect(0, 0, settingsView.Bounds.Width, settingsView.Bounds.Height)); uploadActivity.BackgroundColor = UIColor.Black; uploadActivity.Alpha = .8f; settingsView.AddSubview(uploadActivity); settingsView.BringSubviewToFront(uploadActivity); uploadActivity.StartAnimating(); sessionButton.BackgroundColor = UIColor.FromRGB(255, 215, 101); var window = UIApplication.SharedApplication.KeyWindow; var rootVC = window.RootViewController as IONPrimaryScreenController; var ID = KeychainAccess.ValueForKey("userID"); // todo [email protected]: this needs to be localized. also, we can use error codes instead of strings var response = await ion.portal.RequestUploadSessionsAsync(ion, selectedSessions); /* * var uploadResponse = await ion.webServices.getSession(ion, selectedSessions,ID); * uploadActivity.StopAnimating(); * * if(uploadResponse != null){ * var textResponse = await uploadResponse.Content.ReadAsStringAsync(); * Console.WriteLine(textResponse); * //parse the text string into a json object to be deserialized * JObject response = JObject.Parse(textResponse); * //var isregistered = response.GetValue("success").ToString(); * var message = response.GetValue("message").ToString(); * * var alert = UIAlertController.Create ("Session Upload", message, UIAlertControllerStyle.Alert); * alert.AddAction (UIAlertAction.Create ("Ok", UIAlertActionStyle.Cancel, null)); * rootVC.PresentViewController (alert, animated: true, completionHandler: null); * * } else { * var alert = UIAlertController.Create ("Session Upload", "Upload connection was lost. Please try again.", UIAlertControllerStyle.Alert); * alert.AddAction (UIAlertAction.Create ("Ok", UIAlertActionStyle.Cancel, null)); * rootVC.PresentViewController (alert, animated: true, completionHandler: null); * } */ }
public override void ViewDidLoad() { base.ViewDidLoad(); View.BackgroundColor = UIColor.FromPatternImage(UIImage.FromBundle("CarbonBackground")); InitNavigationBar("ic_nav_workbench", false); backAction = () => { root.navigation.ToggleMenu(); }; ion = AppState.context as IosION; NavigationItem.Title = Strings.AccessManager.SELF.FromResources(); var button = new UIButton(new CGRect(0, 0, 40, 40)); button.SetImage(UIImage.FromBundle("ic_settings"), UIControlState.Normal); button.TouchUpInside += SetupAccessView; settingsButton = new UIBarButtonItem(button); this.NavigationItem.RightBarButtonItem = settingsButton; loggedOutLabel = new UILabel(new CGRect(0, 0, View.Bounds.Width, View.Bounds.Height)); loggedOutLabel.TextAlignment = UITextAlignment.Center; loggedOutLabel.Text = "Must Log In To Use Manager"; loggedOutLabel.Lines = 0; loggedOutLabel.Hidden = true; accessHolderView.Bounds = View.Bounds; requestManager = new AccessRequestManager(accessHolderView); settingsManager = new AccessSettings(accessHolderView); if (string.IsNullOrEmpty(KeychainAccess.ValueForKey("userID"))) { requestManager.accessView.Hidden = true; this.NavigationItem.RightBarButtonItem = null; } accessHolderView.AddSubview(requestManager.accessView); accessHolderView.AddSubview(settingsManager.settingsView); accessHolderView.AddSubview(loggedOutLabel); }
public async void UpdateName(object sender, EventArgs e) { changeNameButton.BackgroundColor = UIColor.FromRGB(255, 215, 101); await Task.Delay(TimeSpan.FromMilliseconds(1)); var window = UIApplication.SharedApplication.KeyWindow; var rootVC = window.RootViewController as IONPrimaryScreenController; var userID = KeychainAccess.ValueForKey("userID"); var response = await ion.portal.RequestChangeDisplayName(firstNameField.Text, lastNameField.Text); if (response.success) { // TODO [email protected]: this needs to be localized. Also, we can return error codes instead of strings. /* * var textResponse = await updateResponse.Content.ReadAsStringAsync(); * Console.WriteLine(textResponse); * //parse the text string into a json object to be deserialized * JObject response = JObject.Parse(textResponse); * * var errorMessage = response.GetValue("message").ToString(); */ var errorMessage = "null"; var alert = UIAlertController.Create("Name Update", errorMessage, UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Cancel, null)); rootVC.PresentViewController(alert, animated: true, completionHandler: null); } else { var alert = UIAlertController.Create("Name Update", "Connection was lost. Please try again.", UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Cancel, null)); rootVC.PresentViewController(alert, animated: true, completionHandler: null); } }
private async void RecordDevices() { var recordingMessage = ""; if (ion.portal.isUploading) { Console.WriteLine("Workbench currently uploading and want to update datalogging for userid " + KeychainAccess.ValueForKey("userID") + " and layoutid " + KeychainAccess.ValueForKey("layoutid")); if (ion.dataLogManager.isRecording) { await ion.portal.RequestRemoteSetDataLoggingAsync(false); ion.dataLogManager.StopRecording(); recordingMessage = "Session recording has stopped"; } else { await ion.portal.RequestRemoteSetDataLoggingAsync(false); ion.dataLogManager.BeginRecording(TimeSpan.FromSeconds(NSUserDefaults.StandardUserDefaults.IntForKey("settings_default_logging_interval"))); recordingMessage = "Session recording has started"; } } else { if (ion.dataLogManager.isRecording) { recordButton.SetImage(UIImage.FromBundle("ic_record"), UIControlState.Normal); recordButton.BackgroundColor = UIColor.Clear; ion.dataLogManager.StopRecording(); recordingMessage = "Session recording has stopped"; } else { recordButton.SetImage(UIImage.FromBundle("ic_stop"), UIControlState.Normal); recordButton.BackgroundColor = UIColor.Clear; ion.dataLogManager.BeginRecording(TimeSpan.FromSeconds(NSUserDefaults.StandardUserDefaults.IntForKey("settings_default_logging_interval"))); recordingMessage = "Session recording has started"; } } showRecordingToast(recordingMessage); }
/// <summary> /// Post to the server and get the list of open requests for the user /// </summary> /// <param name="sender">Sender.</param> /// <param name="e">E.</param> public async void getAllUserAccess(UIView parentView) { loadingRequests.StartAnimating(); await Task.Delay(TimeSpan.FromMilliseconds(1)); followingUsers = new List <accessUserData>(); followerUsers = new List <accessUserData>(); var window = UIApplication.SharedApplication.KeyWindow; var rootVC = window.RootViewController as IONPrimaryScreenController; var ID = KeychainAccess.ValueForKey("userID"); var connectionData = await ion.portal.RequestConnectionData(); // At this point we can call ion.portal.followingConnections to get the list // todo [email protected]: this needs to be localized. also, we can use error codes instead of strings /* * if(feedback != null){ * var textResponse = await feedback.Content.ReadAsStringAsync(); * //parse the text string into a json object to be deserialized * JObject response = JObject.Parse(textResponse); * var success = response.GetValue("success"); * * if(success.ToString() == "true"){ * var viewing = response.GetValue("viewing"); * foreach(var user in viewing){ * var deserializedToken = JsonConvert.DeserializeObject<accessUserData>(user.ToString()); * followingUsers.Add(deserializedToken); * } * * var granting = response.GetValue("allowing"); * * foreach(var user in granting){ * var deserializedToken = JsonConvert.DeserializeObject<accessUserData>(user.ToString()); * followerUsers.Add(deserializedToken); * } * viewingTable.Source = new AccessViewingTableSource(followingUsers, .1 * accessView.Bounds.Height); * viewingTable.ReloadData(); * allowingTable.Source = new AccessAllowingTableSource(followerUsers, .1 * accessView.Bounds.Height); * allowingTable.ReloadData(); * * } else { * var errorMessage = response.GetValue("message").ToString(); * * var alert = UIAlertController.Create ("Viewer Access", errorMessage, UIAlertControllerStyle.Alert); * alert.AddAction (UIAlertAction.Create ("Ok", UIAlertActionStyle.Cancel, null)); * rootVC.PresentViewController (alert, animated: true, completionHandler: null); * } * } else { * var alert = UIAlertController.Create ("Viewer Access", "There was no response. Please try again.", UIAlertControllerStyle.Alert); * alert.AddAction (UIAlertAction.Create ("Ok", UIAlertActionStyle.Cancel, null)); * rootVC.PresentViewController (alert, animated: true, completionHandler: null); * } */ followingRefresh.EndRefreshing(); followerRefresh.EndRefreshing(); loadingRequests.StopAnimating(); }
public PortalMenu(UIView parentView) { portalView = new UIView(new CGRect(0, 0, parentView.Bounds.Width, parentView.Bounds.Height)); portalView.BackgroundColor = UIColor.White; menuHeader = new UILabel(new CGRect(0, 0, parentView.Bounds.Width, .1 * parentView.Bounds.Height)); menuHeader.TextAlignment = UITextAlignment.Center; menuHeader.Font = UIFont.BoldSystemFontOfSize(20); menuHeader.Text = "Portal Menu"; menuHeader.BackgroundColor = UIColor.Black; menuHeader.TextColor = UIColor.FromRGB(255, 215, 101); uploadButton = new UIButton(new CGRect(.05 * parentView.Bounds.Width, .15 * parentView.Bounds.Height, .42 * parentView.Bounds.Width, .1 * parentView.Bounds.Height)); uploadButton.SetTitle("Upload Session", UIControlState.Normal); uploadButton.SetTitleColor(UIColor.Black, UIControlState.Normal); uploadButton.Layer.BorderWidth = 1f; uploadButton.Layer.CornerRadius = 5f; uploadButton.BackgroundColor = UIColor.FromRGB(255, 215, 101); uploadButton.TouchDown += (sender, e) => { uploadButton.BackgroundColor = UIColor.Blue; }; uploadButton.TouchUpOutside += (sender, e) => { uploadButton.BackgroundColor = UIColor.FromRGB(255, 215, 101); }; codeButton = new UIButton(new CGRect(.53 * parentView.Bounds.Width, .15 * parentView.Bounds.Height, .42 * parentView.Bounds.Width, .1 * parentView.Bounds.Height)); codeButton.SetTitle("Access Codes", UIControlState.Normal); codeButton.SetTitleColor(UIColor.Black, UIControlState.Normal); codeButton.Layer.BorderWidth = 1f; codeButton.Layer.CornerRadius = 5f; codeButton.BackgroundColor = UIColor.FromRGB(255, 215, 101); codeButton.TouchDown += (sender, e) => { codeButton.BackgroundColor = UIColor.Blue; }; codeButton.TouchUpOutside += (sender, e) => { codeButton.BackgroundColor = UIColor.FromRGB(255, 215, 101); }; accessButton = new UIButton(new CGRect(.05 * parentView.Bounds.Width, .3 * parentView.Bounds.Height, .42 * parentView.Bounds.Width, .1 * parentView.Bounds.Height)); accessButton.SetTitle("Manage Access", UIControlState.Normal); accessButton.SetTitleColor(UIColor.Black, UIControlState.Normal); accessButton.Layer.BorderWidth = 1f; accessButton.Layer.CornerRadius = 5f; accessButton.BackgroundColor = UIColor.FromRGB(255, 215, 101); accessButton.TouchDown += (sender, e) => { accessButton.BackgroundColor = UIColor.Blue; }; accessButton.TouchUpOutside += (sender, e) => { accessButton.BackgroundColor = UIColor.FromRGB(255, 215, 101); }; remoteButton = new UIButton(new CGRect(.53 * parentView.Bounds.Width, .3 * parentView.Bounds.Height, .42 * parentView.Bounds.Width, .1 * parentView.Bounds.Height)); remoteButton.SetTitle("Remote Viewing", UIControlState.Normal); remoteButton.SetTitleColor(UIColor.Black, UIControlState.Normal); remoteButton.Layer.BorderWidth = 1f; remoteButton.Layer.CornerRadius = 5f; remoteButton.BackgroundColor = UIColor.FromRGB(255, 215, 101); remoteButton.TouchDown += (sender, e) => { remoteButton.BackgroundColor = UIColor.Blue; }; remoteButton.TouchUpOutside += (sender, e) => { remoteButton.BackgroundColor = UIColor.FromRGB(255, 215, 101); }; webPortalButton = new UIButton(new CGRect(.05 * parentView.Bounds.Width, .8 * parentView.Bounds.Height, .9 * parentView.Bounds.Width, .1 * parentView.Bounds.Height)); webPortalButton.SetTitle("Web Portal", UIControlState.Normal); webPortalButton.SetTitleColor(UIColor.Black, UIControlState.Normal); webPortalButton.Layer.BorderWidth = 1f; webPortalButton.Layer.CornerRadius = 5f; webPortalButton.BackgroundColor = UIColor.FromRGB(255, 215, 101); webPortalButton.TouchDown += (sender, e) => { webPortalButton.BackgroundColor = UIColor.Blue; }; webPortalButton.TouchUpOutside += (sender, e) => { webPortalButton.BackgroundColor = UIColor.FromRGB(255, 215, 101); }; webPortalButton.TouchUpInside += (sender, e) => { webPortalButton.BackgroundColor = UIColor.FromRGB(255, 215, 101); var uEmail = KeychainAccess.ValueForKey("userEmail"); var uPword = KeychainAccess.ValueForKey("userPword"); var url = "http://portal.appioninc.com/joomla/modules/mod_processing/appWebLogin.php?usrEmail=" + uEmail + "&usrPass=" + uPword; if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0)) { UIApplication.SharedApplication.OpenUrl(new NSUrl(url), new NSDictionary(), null); } else { UIApplication.SharedApplication.OpenUrl(new NSUrl(url)); } }; portalView.AddSubview(menuHeader); portalView.AddSubview(uploadButton); portalView.AddSubview(codeButton); portalView.AddSubview(accessButton); portalView.AddSubview(remoteButton); portalView.AddSubview(webPortalButton); }
public async void UpdatePassword(object sender, EventArgs e) { changePassButton.BackgroundColor = UIColor.FromRGB(255, 215, 101); updatingLabel.Text = "Updating password. Please Wait."; updatingLabel.Hidden = false; await Task.Delay(TimeSpan.FromMilliseconds(1)); var userID = KeychainAccess.ValueForKey("userID"); if (string.IsNullOrEmpty(passwordField.Text) || string.IsNullOrEmpty(confirmPasswordField.Text)) { passwordField.BackgroundColor = UIColor.Red; passwordField.Alpha = .6f; confirmPasswordField.BackgroundColor = UIColor.Red; confirmPasswordField.Alpha = .6f; updatingLabel.Hidden = true; } else if (!passwordField.Text.Equals(confirmPasswordField.Text)) { passwordField.BackgroundColor = UIColor.Red; passwordField.Alpha = .6f; confirmPasswordField.BackgroundColor = UIColor.Red; confirmPasswordField.Alpha = .6f; var window = UIApplication.SharedApplication.KeyWindow; var rootVC = window.RootViewController as IONPrimaryScreenController; var alert = UIAlertController.Create("Password Update", "Passwords do not match", UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Cancel, null)); rootVC.PresentViewController(alert, animated: true, completionHandler: null); } else if (passwordField.Text.Length < 8 || !passwordField.Text.Any(char.IsUpper)) { var window = UIApplication.SharedApplication.KeyWindow; var rootVC = window.RootViewController as IONPrimaryScreenController; var alert = UIAlertController.Create("Password Update", "Passwords must be 8 characters long and have at least 1 uppercase character", UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Cancel, null)); rootVC.PresentViewController(alert, animated: true, completionHandler: null); } else { passwordField.BackgroundColor = UIColor.White; passwordField.Alpha = 1f; confirmPasswordField.BackgroundColor = UIColor.White; confirmPasswordField.Alpha = 1f; var window = UIApplication.SharedApplication.KeyWindow; var rootVC = window.RootViewController as IONPrimaryScreenController; var response = await ion.portal.RequestUpdatePassword(passwordField.Text); updatingLabel.Hidden = true; if (response.success) { // todo [email protected]: this needs to be localized. also, we can use error codes instead of strings /* * var textResponse = await updateResponse.Content.ReadAsStringAsync(); * Console.WriteLine(textResponse); * //parse the text string into a json object to be deserialized * JObject response = JObject.Parse(textResponse); * * var errorMessage = response.GetValue("message").ToString(); */ var errorMessage = "null"; var alert = UIAlertController.Create("Password Update", errorMessage, UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Cancel, null)); rootVC.PresentViewController(alert, animated: true, completionHandler: null); } else { var alert = UIAlertController.Create("Password Update", "Connection was lost. Please try again.", UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Cancel, null)); rootVC.PresentViewController(alert, animated: true, completionHandler: null); } } updatingLabel.Hidden = true; passwordField.Text = ""; confirmPasswordField.Text = ""; }