protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.SignIn);

            webService = WebServiceFactory.Create();

            editTextUsername = FindViewById <EditText> (Resource.Id.editTextUsername);
            editTextPassword = FindViewById <EditText> (Resource.Id.editTextPassword);
            buttonSignIn     = FindViewById <Button> (Resource.Id.buttonSignIn);
            buttonRegister   = FindViewById <Button> (Resource.Id.buttonRegister);

            buttonSignIn.Click += async delegate {
                var r = await webService.SignInAsync(new SignInRequest {
                    Username = editTextUsername.Text
                });

                if (!r.Succeeded)
                {
                    Toast.MakeText(this, "SignIn Failed: " + r.Exception, ToastLength.Short).Show();
                    return;
                }

                App.Settings.SignedInUsername = editTextUsername.Text;
                StartActivity(typeof(CommitmentsActivity));
            };

            buttonRegister.Click += delegate {
                StartActivity(typeof(RegisterActivity));
            };
        }
Beispiel #2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.CommitmentDetails);

            webService = WebServiceFactory.Create();

            //Deserialize the commitment that was passed in
            commitment = JsonSerializer.Deserialize <Commitment> (this.Intent.GetStringExtra("COMMITMENT"));

            textViewName        = FindViewById <TextView> (Resource.Id.textViewName);
            textViewDescription = FindViewById <TextView> (Resource.Id.textViewDescription);
            textViewStartDate   = FindViewById <TextView> (Resource.Id.textViewStartDate);
            textViewEndDate     = FindViewById <TextView> (Resource.Id.textViewEndDate);
            textViewCluster     = FindViewById <TextView> (Resource.Id.textViewCluster);
            buttonCheckIn       = FindViewById <Button> (Resource.Id.buttonCheckIn);

            //TODO: Need to add meaningful name/descriptions
            textViewName.Text        = "TODO: Put in Name";
            textViewDescription.Text = "TODO: Put in Desc";
            textViewStartDate.Text   = commitment.StartDate.ToString("ddd MMM d, yyyy");
            textViewEndDate.Text     = commitment.EndDate.ToString("ddd MMM d, yyyy");
            textViewCluster.Text     = "TODO: Put in Cluster";

            buttonCheckIn.Click += async delegate {
                //TODO: Create confirmation dialog  (Are you sure: Yes/No)

                var confirm = true;

                if (confirm)
                {
                    var checkedIn = commitment.IsActive;

                    if (checkedIn)
                    {
                        var r = await webService.CheckOutAsync(new CheckOutRequest { Username = App.Settings.SignedInUsername });

                        checkedIn = !(r.Succeeded && r.Result);
                    }
                    else
                    {
                        var r = await webService.CheckInAsync(new CheckInRequest { Username = App.Settings.SignedInUsername });

                        checkedIn = r.Succeeded && r.Result;
                    }

                    buttonCheckIn.Text  = checkedIn ? "Check Out" : "Check In";
                    commitment.IsActive = checkedIn;
                }
            };
        }
        public CommitmentsViewController() :
            base(MonoTouch.UIKit.UITableViewStyle.Grouped, new RootElement("Commitments"), true)
        {
            webService = WebServiceFactory.Create();

            Root = new RootElement("Commitments")
            {
                new Section("Active Commitments")
                {
                },
                new Section("Inactive / Past Commitments")
                {
                }
            };
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.Register);

            webService = WebServiceFactory.Create();

            editTextFirstName = FindViewById <EditText> (Resource.Id.editTextFirstName);
            editTextLastName  = FindViewById <EditText> (Resource.Id.editTextLastName);
            editTextEmail     = FindViewById <EditText> (Resource.Id.editTextEmail);
            editTextPhone     = FindViewById <EditText> (Resource.Id.editTextPhone);
            editTextUsername  = FindViewById <EditText> (Resource.Id.editTextUsername);
            editTextPassword  = FindViewById <EditText> (Resource.Id.editTextPassword);
            editTextPassword2 = FindViewById <EditText> (Resource.Id.editTextPassword2);
            spinnerCluster    = FindViewById <Spinner> (Resource.Id.spinnerCluster);
            buttonCreate      = FindViewById <Button> (Resource.Id.buttonCreate);

            //Let's disable the button until the clusters have loaded
            buttonCreate.Enabled = false;

            Refresh();
        }
Beispiel #5
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.Commitments);

            webService = WebServiceFactory.Create();

            buttonVolunteer = FindViewById <Button> (Resource.Id.buttonVolunteer);
            listActive      = FindViewById <ListView> (Resource.Id.listActive);
            listInactive    = FindViewById <ListView> (Resource.Id.listInactive);

            activeAdapter   = new CommitmentsAdapter(this);
            inactiveAdapter = new CommitmentsAdapter(this);

            listActive.Adapter   = activeAdapter;
            listInactive.Adapter = inactiveAdapter;

            listActive.ItemClick += (sender, e) => {
                var c             = activeAdapter[e.Position];
                var detailsIntent = new Intent(this, typeof(CommitmentDetailsActivity));
                detailsIntent.PutExtra("COMMITMENT", JsonSerializer.Serialize(c));
                StartActivity(detailsIntent);
            };
            listInactive.ItemClick += (sender, e) => {
                var c             = inactiveAdapter[e.Position];
                var detailsIntent = new Intent(this, typeof(CommitmentDetailsActivity));
                detailsIntent.PutExtra("COMMITMENT", JsonSerializer.Serialize(c));
                StartActivity(detailsIntent);
            };
            buttonVolunteer.Click += delegate {
                StartActivity(typeof(DisastersActivity));
            };

            Refresh();
        }
Beispiel #6
0
        public SignInViewController() :
            base(UITableViewStyle.Grouped, new RootElement("Crisis Checkin"), false)
        {
            webService = WebServiceFactory.Create();

            username = new EntryElement("Email", "*****@*****.**", "")
            {
                KeyboardType       = UIKeyboardType.EmailAddress,
                AutocorrectionType = UITextAutocorrectionType.No
            };
            password = new EntryElement("Password", "password", "", true)
            {
                AutocorrectionType = UITextAutocorrectionType.No
            };


            Root = new RootElement("Crisis Checkin")
            {
                new Section("Already have an account?")
                {
                    username,
                    password,
                    new StyledStringElement("Sign In", async() => {
                        username.ResignFirstResponder(true);
                        password.ResignFirstResponder(true);

                        //TODO: Show progress HUD
                        ProgressHud.Show("Signing In");

                        // You have to fetch values first from MonoTouch.Dialog elements
                        username.FetchValue();
                        password.FetchValue();

                        // Actually sign in
                        var r = await webService.SignInAsync(new SignInRequest {
                            Username = username.Value,
                            Password = password.Value
                        });

                        if (!r.Succeeded)
                        {
                            // Show failure message
                            Utility.ShowError("Sign In Failed", "Invalid Username or Password");
                            return;
                        }

                        // Store our credentials for future web service calls
                        AppDelegate.Settings.SignedInUsername = username.Value;
                        AppDelegate.Settings.SignedInPassword = password.Value;

                        //TODO: Hide progress hud
                        ProgressHud.Dismiss();

                        // Navigate to commitments after successfuly login
                        commitmentsViewController = new CommitmentsViewController();
                        NavigationController.PushViewController(commitmentsViewController, true);
                    })
                    {
                        Alignment = UITextAlignment.Center
                    }
                },
                new Section("Don't have an account yet?")
                {
                    new StyledStringElement("Create an Account", () => {
                        // Navigate to registration controller
                        registerViewController = new RegisterViewController();
                        NavigationController.PushViewController(registerViewController, true);
                    })
                    {
                        Alignment = UITextAlignment.Center
                    }
                }
            };
        }