bool ValidateCredentials() { var req = (HttpWebRequest)WebRequest.Create(instapaperAddUri); req.Method = "POST"; req.Headers.Add("Authorization", MakeAuth(userElement.Value, passwordElement.Value)); try { req.GetResponse(); BeginInvokeOnMainThread(delegate { hud.Progress = 0.5f; }); } catch (WebException we) { var response = we.Response as HttpWebResponse; if (response != null) { if (response.StatusCode == HttpStatusCode.Forbidden) { BeginInvokeOnMainThread(delegate { DestroyHud(); alert = new UIAlertView(Locale.GetText("Login error"), Locale.GetText("Invalid password"), null, Locale.GetText("Close")); alert.WillDismiss += delegate { userElement.BecomeFirstResponder(true); alert = null; }; alert.Show(); }); return(false); } } } // We got a valid password Util.Defaults.SetString(instapaper.username = userElement.Value, kUser); Util.Defaults.SetString(instapaper.password = passwordElement.Value, kPass); instapaper.passwordError = false; return(true); }
public override void ViewDidAppear(bool animated) { base.ViewDidAppear(animated); // Reset when we come back to this username.Value = string.Empty; password.Value = string.Empty; username.BecomeFirstResponder(false); }
public InstapaperSignInController(InstapaperBookmark instapaper, Action <bool> callback) { this.instapaper = instapaper; this.callback = callback; var root = new RootElement("Instapaper") { new Section("", Locale.GetText("Get your account at instapaper.com")) { (userElement = new EntryElement(Locale.GetText("Username"), Locale.GetText("or email address"), instapaper.username)), (passwordElement = new EntryElement(Locale.GetText("Password"), "", instapaper.password, true)) } }; dvc = new DialogViewController(UITableViewStyle.Grouped, root, true); dvc.NavigationItem.SetLeftBarButtonItem(new UIBarButtonItem(Locale.GetText("Close"), UIBarButtonItemStyle.Plain, delegate { Close(false); }), false); dvc.NavigationItem.RightBarButtonItem = new UIBarButtonItem(Locale.GetText("Save"), UIBarButtonItemStyle.Plain, delegate { Save(); }); SetViewControllers(new UIViewController [] { dvc }, false); userElement.BecomeFirstResponder(false); }
private RootElement CreateRootElement() { var captionLabel = UIHelper.CreateLabel( "cross copy", true, 32, 32, UITextAlignment.Center, UIColor.Black ); UILabel subcaptionLabel = UIHelper.CreateLabel( WELCOME_LABEL_TEXT, false, 14, 85, UITextAlignment.Center, lightTextColor ); subcaptionLabel.Tag = 3; captionLabel.Frame = new Rectangle(0, 10, 320, 40); subcaptionLabel.Frame = new Rectangle(20, 55, 280, 100); UIView header = new UIView(new Rectangle(0, 0, 300, 145)); header.AddSubviews(captionLabel, subcaptionLabel); var root = new RootElement("Secrets") { new Section(header), (secretsSection = new Section("Secrets")), new Section() { (secretEntry = new AdvancedEntryElement("Secret", "enter new phrase", "", null)) } }; secretsSection.AddAll(from s in AppDelegate.HistoryData.Secrets select(Element) CreateImageButtonStringElement(s)); secretEntry.AutocapitalizationType = UITextAutocapitalizationType.None; secretEntry.ShouldReturn += delegate { if (String.IsNullOrEmpty(secretEntry.Value)) { return(false); } var newSecret = new Secret(secretEntry.Value); AppDelegate.HistoryData.Secrets.Add(newSecret); if (root.Count == 2) { root.Insert(1, secretsSection); } secretsSection.Insert( secretsSection.Elements.Count, UITableViewRowAnimation.Fade, CreateImageButtonStringElement(newSecret) ); secretEntry.Value = ""; secretEntry.ResignFirstResponder(false); DisplaySecretDetail(newSecret); return(true); }; secretEntry.ReturnKeyType = UIReturnKeyType.Go; if (secretsSection.Count == 0) { secretEntry.BecomeFirstResponder(true); root.RemoveAt(1); } return(root); }
public override void ViewDidAppear(bool animated) { base.ViewDidAppear(animated); login.BecomeFirstResponder(); }