Ejemplo n.º 1
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            if (container == null)
            {
                // Currently in a layout without a container, so no reason to create our view.
                return(null);
            }

            View view = inflater.Inflate(Resource.Layout.Register, container, false);

            view.SetBackgroundColor(Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BackgroundColor));
            view.SetOnTouchListener(this);

            ScrollView = view.FindViewById <ScrollView>(Resource.Id.scroll_background);

            RelativeLayout layoutView = view.FindViewById <RelativeLayout>(Resource.Id.scroll_linear_background);

            ProgressBarBlocker                         = view.FindViewById <RelativeLayout>(Resource.Id.progressBarBlocker);
            ProgressBarBlocker.Visibility              = ViewStates.Gone;
            ProgressBarBlocker.LayoutParameters        = new RelativeLayout.LayoutParams(0, 0);
            ProgressBarBlocker.LayoutParameters.Width  = NavbarFragment.GetFullDisplayWidth( );
            ProgressBarBlocker.LayoutParameters.Height = this.Resources.DisplayMetrics.HeightPixels;

            ResultView = new UIResultView(layoutView, new System.Drawing.RectangleF(0, 0, NavbarFragment.GetFullDisplayWidth( ), this.Resources.DisplayMetrics.HeightPixels), OnResultViewDone);

            RelativeLayout navBar = view.FindViewById <RelativeLayout>(Resource.Id.navbar_relative_layout);

            navBar.SetBackgroundColor(Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BackgroundColor));


            // setup the username
            UserNameLayer = view.FindViewById <RelativeLayout>(Resource.Id.username_background);
            ControlStyling.StyleBGLayer(UserNameLayer);

            UserNameText = UserNameLayer.FindViewById <EditText>(Resource.Id.userNameText);
            ControlStyling.StyleTextField(UserNameText, RegisterStrings.UsernamePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            UserNameBGColor         = ControlStylingConfig.BG_Layer_Color;
            UserNameText.InputType |= InputTypes.TextFlagCapWords;

            View borderView = UserNameLayer.FindViewById <View>(Resource.Id.username_border);

            borderView.SetBackgroundColor(Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BG_Layer_BorderColor));

            // password
            PasswordLayer = view.FindViewById <RelativeLayout>(Resource.Id.password_background);
            ControlStyling.StyleBGLayer(PasswordLayer);

            PasswordText            = PasswordLayer.FindViewById <EditText>(Resource.Id.passwordText);
            PasswordText.InputType |= InputTypes.TextVariationPassword;
            ControlStyling.StyleTextField(PasswordText, RegisterStrings.PasswordPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            PasswordBGColor = ControlStylingConfig.BG_Layer_Color;

            borderView = PasswordLayer.FindViewById <View>(Resource.Id.password_border);
            borderView.SetBackgroundColor(Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BG_Layer_BorderColor));



            ConfirmPasswordLayer = view.FindViewById <RelativeLayout>(Resource.Id.confirmPassword_background);
            ControlStyling.StyleBGLayer(ConfirmPasswordLayer);

            ConfirmPasswordText            = ConfirmPasswordLayer.FindViewById <EditText>(Resource.Id.confirmPasswordText);
            ConfirmPasswordText.InputType |= InputTypes.TextVariationPassword;
            ControlStyling.StyleTextField(ConfirmPasswordText, RegisterStrings.ConfirmPasswordPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            ConfirmPasswordBGColor = ControlStylingConfig.BG_Layer_Color;



            // setup the name section
            NickNameLayer = view.FindViewById <RelativeLayout>(Resource.Id.firstname_background);
            ControlStyling.StyleBGLayer(NickNameLayer);

            NickNameText = NickNameLayer.FindViewById <EditText>(Resource.Id.nickNameText);
            ControlStyling.StyleTextField(NickNameText, RegisterStrings.NickNamePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            NickNameBGColor         = ControlStylingConfig.BG_Layer_Color;
            NickNameText.InputType |= InputTypes.TextFlagCapWords;

            borderView = NickNameLayer.FindViewById <View>(Resource.Id.middle_border);
            borderView.SetBackgroundColor(Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BG_Layer_BorderColor));

            LastNameLayer = view.FindViewById <RelativeLayout>(Resource.Id.lastname_background);
            ControlStyling.StyleBGLayer(LastNameLayer);

            LastNameText = LastNameLayer.FindViewById <EditText>(Resource.Id.lastNameText);
            ControlStyling.StyleTextField(LastNameText, RegisterStrings.LastNamePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            LastNameBGColor         = ControlStylingConfig.BG_Layer_Color;
            LastNameText.InputType |= InputTypes.TextFlagCapWords;


            // setup the cell phone section
            CellPhoneLayer = view.FindViewById <RelativeLayout>(Resource.Id.cellphone_background);
            ControlStyling.StyleBGLayer(CellPhoneLayer);

            CellPhoneText = CellPhoneLayer.FindViewById <EditText>(Resource.Id.cellPhoneText);
            ControlStyling.StyleTextField(CellPhoneText, RegisterStrings.CellPhonePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            CellPhoneText.AddTextChangedListener(new PhoneNumberFormattingTextWatcher());


            // email layer
            EmailLayer = view.FindViewById <RelativeLayout>(Resource.Id.email_background);
            ControlStyling.StyleBGLayer(EmailLayer);

            borderView = EmailLayer.FindViewById <View>(Resource.Id.middle_border);
            borderView.SetBackgroundColor(Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BG_Layer_BorderColor));

            EmailText = EmailLayer.FindViewById <EditText>(Resource.Id.emailAddressText);
            ControlStyling.StyleTextField(EmailText, RegisterStrings.EmailPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            EmailBGColor = ControlStylingConfig.BG_Layer_Color;


            // Register button
            RegisterButton = view.FindViewById <Button>(Resource.Id.registerButton);
            ControlStyling.StyleButton(RegisterButton, RegisterStrings.RegisterButton, ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize);

            CancelButton = view.FindViewById <Button>(Resource.Id.cancelButton);
            ControlStyling.StyleButton(CancelButton, GeneralStrings.Cancel, ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize);
            CancelButton.Background = null;

            RegisterButton.Click += (object sender, EventArgs e) =>
            {
                RegisterUser( );
            };

            CancelButton.Click += (object sender, EventArgs e) =>
            {
                // Since they made changes, confirm they want to save them.
                AlertDialog.Builder builder = new AlertDialog.Builder(Activity);
                builder.SetTitle(RegisterStrings.ConfirmCancelReg);

                Java.Lang.ICharSequence [] strings = new Java.Lang.ICharSequence[]
                {
                    new Java.Lang.String(GeneralStrings.Yes),
                    new Java.Lang.String(GeneralStrings.No)
                };

                builder.SetItems(strings, delegate(object s, DialogClickEventArgs clickArgs)
                {
                    Rock.Mobile.Threading.Util.PerformOnUIThread(delegate
                    {
                        switch (clickArgs.Which)
                        {
                        case 0: SpringboardParent.ModalFragmentDone(null); break;

                        case 1: break;
                        }
                    });
                });

                builder.Show( );
            };

            return(view);
        }
Ejemplo n.º 2
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            if (container == null)
            {
                // Currently in a layout without a container, so no reason to create our view.
                return(null);
            }

            View view = inflater.Inflate(Resource.Layout.Profile, container, false);

            view.SetBackgroundColor(Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BackgroundColor));

            RelativeLayout navBar = view.FindViewById <RelativeLayout>(Resource.Id.navbar_relative_layout);

            navBar.SetBackgroundColor(Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BackgroundColor));

            // setup the name section
            NickNameLayer = view.FindViewById <RelativeLayout>(Resource.Id.firstname_background);
            ControlStyling.StyleBGLayer(NickNameLayer);

            NickNameText = NickNameLayer.FindViewById <EditText>(Resource.Id.nickNameText);
            ControlStyling.StyleTextField(NickNameText, RegisterStrings.NickNamePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            NickNameBGColor                = ControlStylingConfig.BG_Layer_Color;
            NickNameText.InputType        |= InputTypes.TextFlagCapWords;
            NickNameText.AfterTextChanged += (sender, e) => { Dirty = true; };

            View borderView = NickNameLayer.FindViewById <View>(Resource.Id.middle_border);

            borderView.SetBackgroundColor(Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BG_Layer_BorderColor));

            LastNameLayer = view.FindViewById <RelativeLayout>(Resource.Id.lastname_background);
            ControlStyling.StyleBGLayer(LastNameLayer);

            LastNameText = LastNameLayer.FindViewById <EditText>(Resource.Id.lastNameText);
            ControlStyling.StyleTextField(LastNameText, RegisterStrings.LastNamePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            LastNameBGColor                = ControlStylingConfig.BG_Layer_Color;
            LastNameText.InputType        |= InputTypes.TextFlagCapWords;
            LastNameText.AfterTextChanged += (sender, e) => { Dirty = true; };


            // setup the contact section
            EmailLayer = view.FindViewById <RelativeLayout>(Resource.Id.email_background);
            ControlStyling.StyleBGLayer(EmailLayer);
            EmailBGColor = ControlStylingConfig.BG_Layer_Color;

            EmailField = EmailLayer.FindViewById <EditText>(Resource.Id.emailAddressText);
            ControlStyling.StyleTextField(EmailField, ProfileStrings.EmailPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            EmailField.AfterTextChanged += (sender, e) => { Dirty = true; };

            View backgroundView = view.FindViewById <RelativeLayout>(Resource.Id.cellphone_background);

            ControlStyling.StyleBGLayer(backgroundView);

            borderView = backgroundView.FindViewById <View>(Resource.Id.middle_border);
            borderView.SetBackgroundColor(Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BG_Layer_BorderColor));

            CellPhoneField = backgroundView.FindViewById <EditText>(Resource.Id.cellPhoneText);
            ControlStyling.StyleTextField(CellPhoneField, ProfileStrings.CellPhonePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            CellPhoneField.AfterTextChanged += (sender, e) => { Dirty = true; };
            CellPhoneField.AddTextChangedListener(new PhoneNumberFormattingTextWatcher());


            // setup the address section
            backgroundView = view.FindViewById <RelativeLayout>(Resource.Id.address_background);
            ControlStyling.StyleBGLayer(backgroundView);

            StreetField = backgroundView.FindViewById <EditText>(Resource.Id.streetAddressText);
            ControlStyling.StyleTextField(StreetField, ProfileStrings.StreetPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            StreetField.AfterTextChanged += (sender, e) => { Dirty = true; };
            StreetField.InputType        |= InputTypes.TextFlagCapWords;

            borderView = backgroundView.FindViewById <View>(Resource.Id.street_border);
            borderView.SetBackgroundColor(Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BG_Layer_BorderColor));

            CityField = backgroundView.FindViewById <EditText>(Resource.Id.cityAddressText);
            ControlStyling.StyleTextField(CityField, ProfileStrings.CityPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            CityField.AfterTextChanged += (sender, e) => { Dirty = true; };
            CityField.InputType        |= InputTypes.TextFlagCapWords;

            borderView = backgroundView.FindViewById <View>(Resource.Id.city_border);
            borderView.SetBackgroundColor(Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BG_Layer_BorderColor));

            StateField = backgroundView.FindViewById <EditText>(Resource.Id.stateAddressText);
            ControlStyling.StyleTextField(StateField, ProfileStrings.StatePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            StateField.AfterTextChanged += (sender, e) => { Dirty = true; };
            StateField.InputType        |= InputTypes.TextFlagCapWords;

            borderView = backgroundView.FindViewById <View>(Resource.Id.state_border);
            borderView.SetBackgroundColor(Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BG_Layer_BorderColor));

            ZipField = backgroundView.FindViewById <EditText>(Resource.Id.zipAddressText);
            ControlStyling.StyleTextField(ZipField, ProfileStrings.ZipPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            ZipField.AfterTextChanged += (sender, e) => { Dirty = true; };


            // personal
            backgroundView = view.FindViewById <RelativeLayout>(Resource.Id.personal_background);
            ControlStyling.StyleBGLayer(backgroundView);

            BirthdateField = backgroundView.FindViewById <EditText>(Resource.Id.birthdateText);
            ControlStyling.StyleTextField(BirthdateField, ProfileStrings.BirthdatePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            BirthdateField.FocusableInTouchMode = false;
            BirthdateField.Focusable            = false;
            Button birthdateButton = backgroundView.FindViewById <Button>(Resource.Id.birthdateButton);

            birthdateButton.Click += (object sender, EventArgs e) =>
            {
                // setup the initial date to use ( either now, or the date in the field )
                DateTime initialDateTime = DateTime.Now;
                if (string.IsNullOrWhiteSpace(BirthdateField.Text) == false)
                {
                    initialDateTime = DateTime.Parse(BirthdateField.Text);
                }

                // build our
                LayoutInflater dateInflate = LayoutInflater.From(Activity);
                DatePicker     newPicker   = (DatePicker)dateInflate.Inflate(Resource.Layout.DatePicker, null);
                newPicker.Init(initialDateTime.Year, initialDateTime.Month - 1, initialDateTime.Day, this);

                Dialog dialog = new Dialog(Activity);
                dialog.AddContentView(newPicker, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent));
                dialog.Show( );
            };

            borderView = backgroundView.FindViewById <View>(Resource.Id.middle_border);
            borderView.SetBackgroundColor(Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BG_Layer_BorderColor));

            // Gender
            GenderField = view.FindViewById <EditText>(Resource.Id.genderText);
            ControlStyling.StyleTextField(GenderField, ProfileStrings.GenderPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            GenderField.FocusableInTouchMode = false;
            GenderField.Focusable            = false;
            Button genderButton = backgroundView.FindViewById <Button>(Resource.Id.genderButton);

            genderButton.Click += (object sender, EventArgs e) =>
            {
                AlertDialog.Builder        builder = new AlertDialog.Builder(Activity);
                Java.Lang.ICharSequence [] strings = new Java.Lang.ICharSequence[]
                {
                    new Java.Lang.String(RockLaunchData.Instance.Data.Genders[1]),
                    new Java.Lang.String(RockLaunchData.Instance.Data.Genders[2]),
                };

                builder.SetItems(strings, delegate(object s, DialogClickEventArgs clickArgs)
                {
                    Rock.Mobile.Threading.Util.PerformOnUIThread(delegate
                    {
                        GenderField.Text = RockLaunchData.Instance.Data.Genders[clickArgs.Which + 1];
                        Dirty            = true;
                    });
                });

                builder.Show( );
            };

            borderView = backgroundView.FindViewById <View>(Resource.Id.campus_middle_border);
            borderView.SetBackgroundColor(Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BG_Layer_BorderColor));

            // Campus
            CampusField = view.FindViewById <EditText>(Resource.Id.campusText);
            ControlStyling.StyleTextField(CampusField, ProfileStrings.CampusPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            CampusField.FocusableInTouchMode = false;
            CampusField.Focusable            = false;
            Button campusButton = backgroundView.FindViewById <Button>(Resource.Id.campusButton);

            campusButton.Click += (object sender, EventArgs e) =>
            {
                // build an alert dialog containing all the campus choices
                AlertDialog.Builder builder = new AlertDialog.Builder(Activity);
                builder.SetTitle(ProfileStrings.SelectCampus_SourceTitle);
                Java.Lang.ICharSequence [] campusStrings = new Java.Lang.ICharSequence[RockLaunchData.Instance.Data.Campuses.Count];
                for (int i = 0; i < RockLaunchData.Instance.Data.Campuses.Count; i++)
                {
                    campusStrings[i] = new Java.Lang.String(RockLaunchData.Instance.Data.Campuses[i].Name);
                }

                // launch the dialog, and on selection, update the viewing campus text.
                builder.SetItems(campusStrings, delegate(object s, DialogClickEventArgs clickArgs)
                {
                    Rock.Mobile.Threading.Util.PerformOnUIThread(delegate
                    {
                        int campusIndex  = clickArgs.Which;
                        CampusField.Text = RockLaunchData.Instance.Data.Campuses[campusIndex].Name;
                        Dirty            = true;
                    });
                });

                builder.Show( );
            };

            // Done buttons
            DoneButton = view.FindViewById <Button>(Resource.Id.doneButton);
            ControlStyling.StyleButton(DoneButton, ProfileStrings.DoneButtonTitle, ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize);

            LogoutButton = view.FindViewById <Button>(Resource.Id.logoutButton);
            ControlStyling.StyleButton(LogoutButton, ProfileStrings.LogoutButtonTitle, ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize);
            LogoutButton.Background = null;

            DoneButton.Click += (object sender, EventArgs e) =>
            {
                if (Dirty == true)
                {
                    if (ValidateInput( ))
                    {
                        // Since they made changes, confirm they want to save them.
                        AlertDialog.Builder builder = new AlertDialog.Builder(Activity);
                        builder.SetTitle(ProfileStrings.SubmitChangesTitle);

                        Java.Lang.ICharSequence [] strings = new Java.Lang.ICharSequence[]
                        {
                            new Java.Lang.String(GeneralStrings.Yes),
                            new Java.Lang.String(GeneralStrings.No),
                            new Java.Lang.String(GeneralStrings.Cancel)
                        };

                        builder.SetItems(strings, delegate(object s, DialogClickEventArgs clickArgs)
                        {
                            Rock.Mobile.Threading.Util.PerformOnUIThread(delegate
                            {
                                switch (clickArgs.Which)
                                {
                                case 0: SubmitChanges( ); SpringboardParent.ModalFragmentDone(null); break;

                                case 1: SpringboardParent.ModalFragmentDone(null); break;

                                case 2: break;
                                }
                            });
                        });

                        builder.Show( );
                    }
                }
                else
                {
                    SpringboardParent.ModalFragmentDone(null);
                }
            };

            LogoutButton.Click += (object sender, EventArgs e) =>
            {
                // Since they made changes, confirm they want to save them.
                AlertDialog.Builder builder = new AlertDialog.Builder(Activity);
                builder.SetTitle(ProfileStrings.LogoutTitle);

                Java.Lang.ICharSequence [] strings = new Java.Lang.ICharSequence[]
                {
                    new Java.Lang.String(GeneralStrings.Yes),
                    new Java.Lang.String(GeneralStrings.No)
                };

                builder.SetItems(strings, delegate(object s, DialogClickEventArgs clickArgs)
                {
                    Rock.Mobile.Threading.Util.PerformOnUIThread(delegate
                    {
                        switch (clickArgs.Which)
                        {
                        case 0: RockMobileUser.Instance.LogoutAndUnbind( ); SpringboardParent.ModalFragmentDone(null); break;

                        case 1: break;
                        }
                    });
                });

                builder.Show( );
            };

            // blocker and result views
            ScrollView = view.FindViewById <LockableScrollView>(Resource.Id.scroll_view);
            ScrollView.ScrollEnabled = false;

            // scroll to the top
            ScrollView.Post(new Action(delegate
            {
                ScrollView.ForceScrollTo(0, 0);
            }));

            RelativeLayout parentLayout = view.FindViewById <RelativeLayout>(Resource.Id.relative_layout);

            RectangleF bounds = new System.Drawing.RectangleF(0, 0, NavbarFragment.GetFullDisplayWidth( ), this.Resources.DisplayMetrics.HeightPixels);

            BlockerView = new UIBlockerView(parentLayout, bounds);
            BlockerView.Hide( );

            ResultView = new UIResultView(parentLayout, bounds, delegate
            {
                SpringboardParent.ModalFragmentDone(null);
            });
            ResultView.Hide( );

            return(view);
        }