async public void DidSignIn(SignIn signIn, GoogleUser user, NSError error)
        {
            if (user != null && error == null)
            {
                ShowHud(Strings.Hud.please_wait);

                GoogleNameLabel.Text = user.Profile.Name;
                UserId = user.UserID;

                var outlet = new Outlet();
                outlet.Name   = user.Profile.Name;
                outlet.Handle = user.UserID;
                outlet.Type   = Outlet.outlet_type_google;
                RealmServices.SaveOutlet(outlet);


                var url = await GoogleAuthenticator.GetProfileURL(UserId);

                ImageView.Hidden = false;
                ImageView.SetImage(url, "NoProfile", "NoProfile", async() =>
                {
                    HideHud();

                    await Task.Delay(TimeSpan.FromSeconds(2));
                    SignIn.SharedInstance.SignOutUser();

                    var popToViewController = NavigationController.ViewControllers.Where(c => c.GetType() == typeof(MyOutletsViewController)).First();
                    NavigationController.PopToViewController(popToViewController, true);
                });
            }
        }
Exemplo n.º 2
0
        partial void SaveButtonClicked(Foundation.NSObject sender)
        {
            string name = null;

            if (URL.Contains("http://"))
            {
                name = URL.Substring(7);
            }
            else if (URL.Contains("https://"))
            {
                name = URL.Substring(8);
            }


            var outlet = new Outlet();

            outlet.Name   = name;
            outlet.Handle = URL;
            outlet.Type   = Outlet.outlet_type_website;
            RealmServices.SaveOutlet(outlet);

            var fromNewCardPage = false;

            if (Transporter.SharedInstance.ContainsKey(Transporter.NewOutletAddedTransporterKey))
            {
                fromNewCardPage = (bool)Transporter.SharedInstance.GetObjectForKey(Transporter.NewOutletAddedTransporterKey);
            }

            var popToViewController = fromNewCardPage ? NavigationController.ViewControllers.Where(c => c.GetType() == typeof(NewCardViewController)).First() : NavigationController.ViewControllers.Where(c => c.GetType() == typeof(MyOutletsViewController)).First();

            NavigationController.PopToViewController(popToViewController, true);
        }
Exemplo n.º 3
0
        async public void HandleSignInResult(GoogleSignInResult result)
        {
            if (result.IsSuccess)
            {
                // Signed in successfully, show authenticated UI.
                var acct = result.SignInAccount;
                TitleTextView.Text = acct.DisplayName;

                ImageView.SetImage(acct.PhotoUrl.ToString(), Resource.Drawable.ic_noprofilewhite, Resource.Drawable.ic_noprofilewhite, "Google", WebImageView.DefaultCircleTransformation);

                var outlet = new Outlet();
                outlet.Name   = acct.DisplayName;
                outlet.Handle = acct.Id;
                outlet.Type   = Outlet.outlet_type_google;
                RealmServices.SaveOutlet(outlet);

                await Task.Delay(TimeSpan.FromSeconds(2));

                var activity = Activity as BaseActivity;
                activity?.PopFragmentOverUntil(typeof(MyOutletsRecyclerViewFragment));
            }
            else
            {
            }
        }
Exemplo n.º 4
0
        async partial void NextButtonClicked(Foundation.NSObject sender)
        {
            View.EndEditing(true);

            string emailAddress = (string)Transporter.SharedInstance.GetObjectForKey("email");
            string code         = VerificationCodeTextField.Text.Trim();

            bool allFieldsValid = ValidateAllFields();

            if (!allFieldsValid)
            {
                return;
            }

            ShowHud(Strings.Hud.please_wait);

            try
            {
                var result = await WebServices.EmailController.UseValidationCode(emailAddress, code);

                if (result.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    var outlet = new Outlet();
                    outlet.Handle = emailAddress;
                    outlet.Type   = Outlet.outlet_type_email;
                    outlet.Name   = emailAddress;

                    var outletSaved = RealmServices.SaveOutlet(outlet);
                    if (outletSaved)
                    {
                        var popToViewController = NavigationController.ViewControllers.Where(c => c.GetType() == typeof(MyOutletsViewController)).First();
                        NavigationController.PopToViewController(popToViewController, true);
                    }
                    else
                    {
                        ShowDuplicateEntryAlert();
                    }
                }
                else
                {
                    VerificationCodeTextField.SetInvalid();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
            }

            HideHud();
        }
        async partial void NextButtonClicked(Foundation.NSObject sender)
        {
            View.EndEditing(true);

            string code = StringUtils.RemoveNonIntegers(VerificationCodeTextField.Text.Trim());

            bool allFieldsValid = ValidateAllFields();

            if (!allFieldsValid)
            {
                return;
            }

            ShowHud(Strings.Hud.please_wait);

            try
            {
                var result = await TwilioServices.VerifyPhoneAsync(PhoneNumber, code);

                if (result != null && result.success)
                {
                    var outlet = new Outlet();
                    outlet.Handle = PhoneNumber;
                    outlet.Type   = Outlet.outlet_type_phone;
                    outlet.Name   = PhoneNumber;

                    var outletSaved = RealmServices.SaveOutlet(outlet);
                    if (outletSaved)
                    {
                        var popToViewController = NavigationController.ViewControllers.Where(c => c.GetType() == typeof(MyOutletsViewController)).First();
                        NavigationController.PopToViewController(popToViewController, true);
                    }
                    else
                    {
                        ShowDuplicateEntryAlert();
                    }
                }
                else
                {
                    VerificationCodeTextField.SetInvalid();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
            }

            HideHud();
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            RemoveBackBarButtonTitle();

            Profile.Notifications.ObserveDidChange((sender, e) =>
            {
                if (e.NewProfile == null)
                {
                    return;
                }

                pictureView.ProfileId  = e.NewProfile.UserID;
                FacebookNameLabel.Text = e.NewProfile.Name;

                var outlet    = new Outlet();
                outlet.Name   = e.NewProfile.Name;
                outlet.Handle = e.NewProfile.UserID;
                outlet.Locked = true;
                outlet.Type   = Outlet.outlet_type_facebook;
                RealmServices.SaveOutlet(outlet);

                loginView.RemoveFromSuperview();
            });

            // Set the Read and Publish permissions you want to get
            loginView = new LoginButton(FacebookButtonSuperview.Bounds)
            {
                LoginBehavior   = LoginBehavior.Browser,
                ReadPermissions = readPermissions.ToArray()
            };

            // Handle actions once the user is logged in
            loginView.Completed += async(sender, e) =>
            {
                loginView.RemoveFromSuperview();

                await System.Threading.Tasks.Task.Delay(TimeSpan.FromSeconds(2));

                NavigationController.PopViewController(true);
            };
            FacebookButtonSuperview.AddSubview(loginView);

            pictureView = new ProfilePictureView(FacebookProfilePictureSuperview.Bounds);
            FacebookProfilePictureSuperview.AddSubview(pictureView);
        }
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var view = inflater.Inflate(Resource.Layout.EnterPhoneNumberVerificationCode, container, false);

            PhoneNumberTextField           = view.FindViewById <EditText>(Resource.Id.PhoneNumberTextField);
            PhoneNumberTextField.InputType = Android.Text.InputTypes.ClassNumber;

            var titleTextView = view.FindViewById <TextView>(Resource.Id.TitleTextView);

            titleTextView.Text = "Verify Email Address";

            var messageTextView = view.FindViewById <TextView>(Resource.Id.MessageTextView);

            messageTextView.Text = "We've sent you an email!";

            var progressButton = view.FindViewById <Button>(Resource.Id.ProgressButton);

            progressButton.Click += async(sender, e) =>
            {
                string emailAddress = (string)Transporter.SharedInstance.GetObjectForKey("email");
                string code         = PhoneNumberTextField.Text.Trim();

                bool allFieldsValid = ValidateAllFields();
                if (!allFieldsValid)
                {
                    return;
                }

                ShowHud(Strings.Hud.please_wait);

                try
                {
                    var result = await WebServices.EmailController.UseValidationCode(emailAddress, code);

                    if (result.StatusCode == System.Net.HttpStatusCode.OK)
                    {
                        var outlet = new Outlet();
                        outlet.Handle = emailAddress;
                        outlet.Type   = Outlet.outlet_type_email;
                        outlet.Name   = emailAddress;

                        var outletSaved = RealmServices.SaveOutlet(outlet);
                        if (outletSaved)
                        {
                            var activity = Activity as BaseActivity;
                            activity?.PopFragmentOverUntil(typeof(MyOutletsRecyclerViewFragment));
                        }
                        else
                        {
                            ShowDuplicateEntryAlert();
                        }
                    }
                    else
                    {
                        PhoneNumberTextField.SetInvalid(Resources);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    Console.WriteLine(ex.StackTrace);
                }

                HideHud();
            };


            return(view);
        }
Exemplo n.º 8
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var view = inflater.Inflate(Resource.Layout.Website, container, false);

            Activity.Title = "Website";

            CookieManager.Instance.RemoveAllCookies(null);
            CookieManager.Instance.Flush();

            WebView            = view.FindViewById <WebView>(Resource.Id.WebView);
            WebView.Visibility = ViewStates.Invisible;
            WebView.ClearHistory();
            WebView.ClearCache(true);

            var client = new BaseWebViewClient();

            client.ShouldOverrideUrlLoadingFunc += (arg) => { return(false); };
            client.OnPageFinishedAction         += (arg1, arg2) =>
            {
                ProgressBar.Visibility = ViewStates.Invisible;

                ProgressButton.Text = "Save";
            };
            WebView.SetWebViewClient(client);

            TextField              = view.FindViewById <EditText>(Resource.Id.WebsiteTextField);
            TextField.Hint         = "Website URL";
            TextField.InputType    = InputTypes.TextVariationWebEditText | InputTypes.TextFlagNoSuggestions;
            TextField.TextChanged += (sender, e) =>
            {
                WebView.Visibility     = ViewStates.Invisible;
                ProgressBar.Visibility = ViewStates.Invisible;
                ProgressButton.Text    = "Validate";
            };

            ProgressButton        = view.FindViewById <Button>(Resource.Id.ProgressButton);
            ProgressButton.Click += (sender, e) =>
            {
                if (String.IsNullOrEmpty(TextField.Text))
                {
                    return;
                }

                var activity = Activity as BaseActivity;

                if (ProgressButton.Text.Equals("Save", StringComparison.InvariantCultureIgnoreCase))
                {
                    string name = null;
                    if (URL.Contains("http://"))
                    {
                        name = URL.Substring(7);
                    }
                    else if (URL.Contains("https://"))
                    {
                        name = URL.Substring(8);
                    }


                    var outlet = new Outlet();
                    outlet.Name   = name;
                    outlet.Handle = URL;
                    outlet.Type   = Outlet.outlet_type_website;
                    RealmServices.SaveOutlet(outlet);

                    var fromNewCardPage = false;
                    if (Transporter.SharedInstance.ContainsKey(Transporter.NewOutletAddedTransporterKey))
                    {
                        fromNewCardPage = (bool)Transporter.SharedInstance.GetObjectForKey(Transporter.NewOutletAddedTransporterKey);
                    }

                    //var popToViewController = fromNewCardPage ? NavigationController.ViewControllers.Where(c => c.GetType() == typeof(NewCardViewController)).First() : NavigationController.ViewControllers.Where(c => c.GetType() == typeof(MyOutletsViewController)).First();
                    activity?.PopFragmentOverUntil(typeof(MyOutletsRecyclerViewFragment));

                    return;
                }


                URL = TextField.Text.Trim();
                if (!URL.Contains("http"))
                {
                    URL = "http://" + URL;
                }

                if (!StringUtils.IsValidURL(URL))
                {
                    return;
                }

                activity?.HideKeyboard();

                WebView.Visibility = ViewStates.Visible;
                WebView.LoadUrl(URL);
                ProgressBar.Visibility = ViewStates.Visible;
            };

            ProgressBar            = view.FindViewById <ProgressBar>(Resource.Id.ProgressBar);
            ProgressBar.Visibility = ViewStates.Invisible;

            return(view);
        }
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var view = inflater.Inflate(Resource.Layout.EnterPhoneNumberVerificationCode, container, false);

            PhoneNumberTextField           = view.FindViewById <EditText>(Resource.Id.PhoneNumberTextField);
            PhoneNumberTextField.InputType = Android.Text.InputTypes.ClassNumber;

            var titleTextView = view.FindViewById <TextView>(Resource.Id.TitleTextView);

            titleTextView.Text = "Verify Phone Number";

            var messageTextView = view.FindViewById <TextView>(Resource.Id.MessageTextView);

            messageTextView.Text = "We've sent you an text!";

            var progressButton = view.FindViewById <Button>(Resource.Id.ProgressButton);

            progressButton.Click += async(sender, e) =>
            {
                string code = StringUtils.RemoveNonIntegers(PhoneNumberTextField.Text.Trim());

                bool allFieldsValid = ValidateAllFields();
                if (!allFieldsValid)
                {
                    return;
                }

                ShowHud(Strings.Hud.please_wait);

                try
                {
                    var result = await TwilioServices.VerifyPhoneAsync(PhoneNumber, code);

                    if (result != null && result.success)
                    {
                        var outlet = new Outlet();
                        outlet.Handle = PhoneNumber;
                        outlet.Type   = Outlet.outlet_type_phone;
                        outlet.Name   = PhoneNumber;

                        var outletSaved = RealmServices.SaveOutlet(outlet);
                        if (outletSaved)
                        {
                            var activity = Activity as BaseActivity;
                            activity?.PopFragmentOverUntil(typeof(MyOutletsRecyclerViewFragment));
                        }
                        else
                        {
                            ShowDuplicateEntryAlert();
                        }
                    }
                    else
                    {
                        PhoneNumberTextField.SetInvalid(Resources);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    Console.WriteLine(ex.StackTrace);
                }

                HideHud();
            };


            return(view);
        }