Exemplo n.º 1
0
        private void BtnIncreaseIntake_Click(object sender, EventArgs e)
        {
            try
            {
                TextView txtWaterGlass = (TextView)FindViewById(Resource.Id.txtGlassOfWater);
                // increase water intake by 0.5 glass (8oz)
                if (txtWaterGlass.Text.Length > 0)
                {
                    glass  = Convert.ToDouble(txtWaterGlass.Text);
                    glass += 0.5;


                    txtWaterGlass.Text = glass.ToString();
                }
                else
                {
                    txtWaterGlass.Text = "0.5";
                }
            }
            catch (Exception ex)
            {
                Toast.MakeText(this, ex.Message, ToastLength.Long).Show();
            }
            SharedPrefManager.getInstance(Application.Context).SetWaterIntake(glass, DateTime.Now);
        }
Exemplo n.º 2
0
        private void BtnDecreaseIntake_Click(object sender, EventArgs e)
        {
            TextView txtWaterGlass = (TextView)FindViewById(Resource.Id.txtGlassOfWater);

            //holds initial value of water intake for day



            if (txtWaterGlass.Text.Length > 0 || txtWaterGlass.Text != "0.0")
            {
                glass  = Convert.ToDouble(txtWaterGlass.Text);
                glass -= 0.5;
                if (glass >= 0)
                {
                    txtWaterGlass.Text = glass.ToString();
                }
                else
                {
                    Toast.MakeText(this, "Water Intake for the day cannot go below 0", ToastLength.Long).Show();
                }
            }
            else
            {
                txtWaterGlass.Text = "0.0";
            }
            SharedPrefManager.getInstance(Application.Context).SetWaterIntake(glass, DateTime.Now);
        }
Exemplo n.º 3
0
        private void WebClient_UploadValuesCompleted(object sender, UploadValuesCompletedEventArgs e)
        {
            string message = Encoding.UTF8.GetString(e.Result);

            Toast.MakeText(this, message, ToastLength.Long).Show();
            if (message.Contains("Successfully changed information."))
            {
                SharedPrefManager.getInstance(Application.Context).UserProfileSetup(txtLastname.Text, txtFirstname.Text, txtAge.Text, txtHeight.Text);
                Intent home = new Intent(this, typeof(home));
                StartActivity(home);
                Finish();
            }
        }
Exemplo n.º 4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            SetContentView(Resource.Layout.weight_bmi);

            height    = Convert.ToDouble(SharedPrefManager.getInstance(Application.Context).Height);
            txtWeight = (EditText)FindViewById(Resource.Id.txtWeight);
            lblBMI    = (TextView)FindViewById(Resource.Id.lblBMI);
            Button submitBtn = (Button)FindViewById(Resource.Id.Submit);

            submitBtn.Click += SubmitBtn_Click;
            Button btnHome = (Button)FindViewById(Resource.Id.btnHome);

            btnHome.Click += BtnHome_Click;
        }
Exemplo n.º 5
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            SharedPrefManager sp = new SharedPrefManager(this);

            SetContentView(Resource.Layout.Home);
            TextView textView = (TextView)FindViewById(Resource.Id.textView1);

            textView.Append(" " + SharedPrefManager.getInstance(Application.Context).FirstName.Replace("\"", " "));
            Button weightBmi = (Button)FindViewById(Resource.Id.weight_bmi);

            weightBmi.Click += WeightBmi_Click;
            Button waterIntake = (Button)FindViewById(Resource.Id.water_intake);

            waterIntake.Click += WaterIntake_Click;
        }
Exemplo n.º 6
0
        private void Submit_Click(object sender, EventArgs e)
        {
            try
            {
                string userID = SharedPrefManager.getInstance(Application.Context).UserID;
                txtFirstname = (EditText)FindViewById(Resource.Id.firstName);
                txtLastname  = (EditText)FindViewById(Resource.Id.lastname);
                txtAge       = (EditText)FindViewById(Resource.Id.age);
                txtHeight    = (EditText)FindViewById(Resource.Id.height);

                CreateUserProfile(userID, txtFirstname.Text, txtLastname.Text, txtAge.Text, txtHeight.Text);
            }
            catch (Exception ex)
            {
                Toast.MakeText(this, ex.Message, ToastLength.Long).Show();
            }
        }
Exemplo n.º 7
0
        private void WebClient_UploadValuesCompleted(object sender, UploadValuesCompletedEventArgs e)
        {
            string message = Encoding.UTF8.GetString(e.Result);

            if (message.Contains("UserID"))
            {
                message.Replace("{", null);
                message.Replace("}", null);
                String[] logInfo   = message.Split(",");
                string   userID    = logInfo[1].Substring(logInfo[1].IndexOf(":") + 1);
                string   userEmail = logInfo[2].Substring(logInfo[2].IndexOf(":") + 1);

                SharedPrefManager.getInstance(Application.Context).userLogin(userID, userEmail);
                GetUserInfo(userID);
            }
            else if (message.Contains("LastName"))
            {
                message.Replace("{", null);
                message.Replace("}", null);
                String[] logInfo   = message.Split(",");
                string   lastName  = logInfo[1].Substring(logInfo[1].IndexOf(":") + 1);
                string   firstName = logInfo[2].Substring(logInfo[2].IndexOf(":") + 1);
                string   age       = logInfo[3].Substring(logInfo[3].IndexOf(":") + 1);
                string   height    = logInfo[4].Substring(logInfo[4].IndexOf(":") + 1);
                height = height.Substring(0, height.Length - 1);

                SharedPrefManager.getInstance(Application.Context).UserProfileSetup(lastName, firstName, age, height);

                Intent Home = new Intent(this, typeof(home));
                StartActivity(Home);
                Finish();
            }
            else if (message.Contains("Invalid username or password"))
            {
                Toast.MakeText(this, "Invalid username or password", ToastLength.Long).Show();
            }
            else if (message.Contains("No user info found"))
            {
                Intent UserSetup = new Intent(this, typeof(userprofilesetup));
                StartActivity(UserSetup);
                Finish();
            }
        }
Exemplo n.º 8
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            // Set our view from the "main" layout resource
            SharedPrefManager sp = new SharedPrefManager(this);

            SetContentView(Resource.Layout.UserLogin);
            Button btnRegister = (Button)FindViewById(Resource.Id.Register);

            btnRegister.Click += BtnRegister_Click;
            Button btnLogin = (Button)FindViewById(Resource.Id.Login);

            btnLogin.Click += BtnLogin_Click;

            if (SharedPrefManager.getInstance(Application.Context).LoggedIn)
            {
                GetUserInfo(SharedPrefManager.getInstance(Application.Context).UserID);
            }
        }
Exemplo n.º 9
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            //set view to water_intake.xml
            SetContentView(Resource.Layout.WaterIntake);
            TextView txtWaterGlass = (TextView)FindViewById(Resource.Id.txtGlassOfWater);

            txtWaterGlass.Text = SharedPrefManager.getInstance(Application.Context).GetWaterIntake(DateTime.Now).ToString();
            // Creating button Click event to decrease amount of water intake for day by 0.5 glasses with a glass being 8oz
            Button btnDecreaseIntake = (Button)FindViewById(Resource.Id.btnDecrease);

            btnDecreaseIntake.Click += BtnDecreaseIntake_Click;
            //increase water intake
            Button btnIncreaseIntake = (Button)FindViewById(Resource.Id.btnIncrease);

            btnIncreaseIntake.Click += BtnIncreaseIntake_Click;
            //Button to take user back to home
            Button btnHome = (Button)FindViewById(Resource.Id.btn_home);

            btnHome.Click += BtnHome_Click;
        }