protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); FindViewById <Button>(Resource.Id.ButtonErrorToast).Click += delegate { Toasty.Error(this, "This is an error toast").Show(); }; FindViewById <Button>(Resource.Id.ButtonSuccessToast).Click += delegate { Toasty.Success(this, "Success").Show(); }; FindViewById <Button>(Resource.Id.ButtonInfoToast).Click += delegate { Toasty.Info(this, "Here is some info for you").Show(); }; FindViewById <Button>(Resource.Id.ButtonWarningToast).Click += delegate { Toasty.Warning(this, "Beware of the dog").Show(); }; FindViewById <Button>(Resource.Id.ButtonNormalToastWithoutIcon).Click += delegate { Toasty.Normal(this, "Normal toast without icon").Show(); }; FindViewById <Button>(Resource.Id.ButtonNormalToastWithIcon).Click += delegate { var icon = ToastyUtils.GetDrawable(this, Resource.Drawable.ic_pets_white_48dp); Toasty.Normal(this, "Normal toast with icon", icon).Show(); }; }
//Log-in process and validation email is clear public void GetAdmin(string email) { Query query = database.Collection("Users").WhereEqualTo("EMail", email); query.Get().AddOnCompleteListener(new QueryListener((task) => { if (task.IsSuccessful) { var snapshot = (QuerySnapshot)task.Result; if (!snapshot.IsEmpty) { var document = snapshot.Documents; foreach (DocumentSnapshot item in document) { string adminemail = item.GetString("EMail"); string adminName = item.GetString("Name"); string adminphonenum = item.GetString("PhoneNum"); string adminsport = item.GetString("Sport"); string profilepic = item.GetString("Profile"); Admin1 a = new Admin1(adminsport, adminName, adminphonenum, adminemail, profilepic); MyStuff.PutToShared(a); } } } Intent i = new Intent(this, typeof(MainPageActivity)); Toasty.Success(this, "Logged-In Successfully", 5, true).Show(); StartActivity(i); } )); }
//Build Main Page's Views #region Music Service private void Swi_CheckedChange(object sender, CompoundButton.CheckedChangeEventArgs e) { if (e.IsChecked) { Toasty.Success(this, "Music Started", 5, false).Show(); StartMyService(); } else { Toasty.Success(this, "Music Stopped", 5, false).Show(); StopMyService(); } }
//Building the AddStudent Screen private void AddStudentButton_Click(object sender, EventArgs e) { if (IsValidName(NameAddStudentET.Text) && MyStuff.isValidEmail(EmailAddStudentET.Text, this) && currGroup != "Choose Group") { if (Parent1NameAddStudentET.Text != "" && Parent2NameAddStudentET.Text != "") { student = new Student(NameAddStudentET.Text, PhoneNumAddStudentET.Text, EmailAddStudentET.Text, Parent1NameAddStudentET.Text, Parent2NameAddStudentET.Text, AddStudentExplenationET.Text, currGroup); } if (Parent1NameAddStudentET.Text == "" && Parent2NameAddStudentET.Text != "") { student = new Student(NameAddStudentET.Text, PhoneNumAddStudentET.Text, EmailAddStudentET.Text, Parent2NameAddStudentET.Text, AddStudentExplenationET.Text, currGroup); } if (Parent1NameAddStudentET.Text != "" && Parent2NameAddStudentET.Text == "") { student = new Student(NameAddStudentET.Text, PhoneNumAddStudentET.Text, EmailAddStudentET.Text, Parent1NameAddStudentET.Text, AddStudentExplenationET.Text, currGroup); } if (Parent1NameAddStudentET.Text == "" && Parent2NameAddStudentET.Text == "") { student = new Student(NameAddStudentET.Text, PhoneNumAddStudentET.Text, EmailAddStudentET.Text, AddStudentExplenationET.Text, currGroup); } HashMap map = new HashMap(); map.Put("Name", student.name); map.Put("PhoneNum", student.phoneNumber); map.Put("Email", student.email); map.Put("Parent1", student.parentName1); map.Put("Parent2", student.parentName2); map.Put("Notes", student.notes); map.Put("Group", student.group); DocumentReference docref = database.Collection("Users").Document(admin.email).Collection("Students").Document(student.name + " " + student.phoneNumber); docref.Set(map); Toasty.Config.Instance .TintIcon(true) .SetToastTypeface(Typeface.CreateFromAsset(Assets, "Katanf.ttf")); Toasty.Success(this, "Student Added Sucesfully", 5, true).Show(); NameAddStudentET.Text = ""; PhoneNumAddStudentET.Text = "05"; EmailAddStudentET.Text = ""; Parent1NameAddStudentET.Text = ""; Parent2NameAddStudentET.Text = ""; AddStudentExplenationET.Text = ""; spin.SetSelection(0); } else { Toasty.Config.Instance .TintIcon(true) .SetToastTypeface(Typeface.CreateFromAsset(Assets, "Katanf.ttf")); Toasty.Error(this, "Input InValid", 5, true).Show(); } }
private void SendButton_Click(object sender, EventArgs e) { if (Validinput() && c) { if (!CB1.Checked || !CB2.Checked) { Toasty.Error(this, "אנא סמן ווי בשתי בתיבות", 5, false).Show(); } else { List <string> ts = new List <string>(); ts.Add("שם: " + NameET.Text); ts.Add("\nת.ז: " + IDET.Text); ts.Add("\nאגודה: " + AGUDAET.Text); ts.Add("\nמצהיר כי ערכתי היום בדיקה למדידת חום גוף, בה נמצא כי חום גופי אינו עולה על 38 מעלות צלזיוס"); ts.Add("\nוכי איני משתעל/ת וכן כי אין לי קשיים בנשימה"); string toSend = ""; for (int i = 0; i < ts.Count; i++) { toSend += ts[i]; } var content = toSend; var destinationAdd = CurrNumber; SmsManager sm = SmsManager.Default; if (content.Length >= 150) { List <string> parts = new List <string>(); var enumerable = Enumerable.Range(0, content.Length / 20).Select(i => content.Substring(i * 20, 20)); parts = enumerable.ToList(); sm.SendMultipartTextMessage(destinationAdd, null, parts, null, null); } else { sm.SendTextMessage(destinationAdd /*מספר טלפון*/, null, content /*תכולה*/, null, null); } var editor = sp.Edit(); editor.PutString("Name", NameET.Text); editor.PutString("ID", IDET.Text); editor.PutString("AGUDA", AGUDAET.Text); editor.Commit(); Toasty.Success(this, "הצהרה נשלחה בהצלחה", 5, true).Show(); var activity = (Activity)this; activity.FinishAffinity(); } } else { Toasty.Error(this, "שגיאה", 5, true).Show(); } }
//Builds The Screen private void AddTrainingButton_Click(object sender, EventArgs e) { Exercise ex = new Exercise(AddTrainingNameET.Text, AddTrainingExplenationET.Text); HashMap map = new HashMap(); map.Put("Name", ex.name); map.Put("Explenation", ex.explenatiotn); DocumentReference DocRef = database.Collection("Users").Document(admin.email).Collection("Exercises").Document(ex.name); DocRef.Set(map); Toasty.Config.Instance .TintIcon(true) .SetToastTypeface(Typeface.CreateFromAsset(Assets, "Katanf.ttf")); Toasty.Success(this, "Exercise was added secessfully", 5, true).Show(); Intent intent1 = new Intent(this, typeof(MainPageActivity)); intent1.PutExtra("Email", admin.email); StartActivity(intent1); }
private void SendBtn_Click(object sender, EventArgs e) { if (DateBtn.Text != "Date") { //add to firebase HashMap map = new HashMap(); map.Put("Date", DateBtn.Text); map.Put("Group", LocationET.Text + " " + TimeBtn.Text + " " + AgeET.Text); DocumentReference docref = database.Collection("Users").Document(admin.email).Collection("Meetings").Document(); docref.Set(map); HashMap map2 = new HashMap(); Toasty.Success(this, "Meeting Added Sucesfully", 5, true).Show(); Intent intent1 = new Intent(this, typeof(MainPageActivity)); StartActivity(intent1); } else { Toasty.Error(this, "Pick Date", 5, true).Show(); } }
//Building Register Screen private void LoginButton_Click(object sender, System.EventArgs e) { if (!MyStuff.Emails.Contains(MailLoginET.Text)) { //validation of input if (MyStuff.IsValidName(NameLoginET.Text, NameLoginET, this) && MyStuff.IsValidSport(SportLoginET.Text, this) & MyStuff.isValidEmail(MailLoginET.Text, this) && PhoneNumberLoginET.Text.Length == 10 && PhoneNumberLoginET.Text.ToString().All(c => Char.IsLetterOrDigit(c))) { string image = ""; try { image = MyStuff.ConvertBitMapToString(BitProfilePic); } catch { }; Toasty.Config.Instance .TintIcon(true) .SetToastTypeface(Typeface.CreateFromAsset(Assets, "Katanf.ttf")); admin = new Admin1(SportLoginET.Text, NameLoginET.Text, PhoneNumberLoginET.Text, MailLoginET.Text, image); HashMap map = new HashMap(); map.Put("Name", admin.name); map.Put("EMail", admin.email); map.Put("PhoneNum", admin.phoneNumber); map.Put("Sport", admin.sport); map.Put("Profile", admin.ProfilePic); DocumentReference DocRef = database.Collection("Users").Document(admin.email); DocRef.Set(map); MyStuff.PutToShared(admin); Intent intent1 = new Intent(this, typeof(MainPageActivity)); Toasty.Success(this, "Edited successfully", 5, true).Show(); // SmsManager sm = SmsManager.Default; sm.SendTextMessage(PhoneNumberLoginET.Text /*מספר טלפון*/, null, "Welcome to T-POV, " + NameLoginET.Text + "!" /*תכולה*/, null, null); // StartActivity(intent1); } } else { Toasty.Error(this, "Email Already In Database", 5, true).Show(); MailLoginET.Text = ""; } }
private void Delete_Click(object sender, EventArgs e) { MyButton b = ((MyButton)sender); Query query = database.Collection("Users").Document(admin1.email).Collection("Groups"); query.Get().AddOnCompleteListener(new QueryListener((task) => { if (task.IsSuccessful) { var snapshot = (QuerySnapshot)task.Result; if (!snapshot.IsEmpty) { var document = snapshot.Documents; foreach (DocumentSnapshot item in document) { database.Collection("Users").Document(admin1.email).Collection("Groups").Document(groups[b.id].Location + " " + groups[b.id].time + " " + groups[b.id].age).Delete(); } } d.Dismiss(); Toasty.Success(this, "Deleted Successfully", 3, true).Show(); } })); }
//Building the AddGroup Screen private void AddGroupButton_Click(object sender, EventArgs e) { if (InputValid(LocationAddGroupET.Text, AgeAddGroupET.Text, GroupLevelAddGroupET.Text, c)) { //add to firebase Group group = new Group(AgeAddGroupET.Text, GroupLevelAddGroupET.Text, CompRBAddGroup.Selected, LocationAddGroupET.Text, AddGroupTimeButton.Text); HashMap map = new HashMap(); map.Put("Location", group.Location); map.Put("Level", group.geoupLevel); map.Put("Age", group.age); map.Put("Comp", group.competetive); map.Put("Time", group.time); DocumentReference docref = database.Collection("Users").Document(admin.email).Collection("Groups").Document(group.Location + " " + group.time + " " + group.age); docref.Set(map); HashMap map2 = new HashMap(); Toasty.Config.Instance .TintIcon(true) .SetToastTypeface(Typeface.CreateFromAsset(Assets, "Katanf.ttf")); Toasty.Success(this, "Group Added Sucesfully", 5, true).Show(); Intent intent1 = new Intent(this, typeof(MainPageActivity)); StartActivity(intent1); } }
private void SaveButton_Click(object sender, EventArgs e) { if (InputValid(LocET.Text, AgeET.Text, LVLET.Text, c)) { //add to firebase Group group = new Group(AgeET.Text, LVLET.Text, CompRB.Checked, LocET.Text, TimeButton.Text); HashMap map = new HashMap(); map.Put("Location", group.Location); map.Put("Level", group.geoupLevel); map.Put("Age", group.age); map.Put("Comp", group.competetive); map.Put("Time", group.time); DocumentReference docref = database.Collection("Users").Document(admin1.email).Collection("Groups").Document(group.Location + " " + group.time + " " + group.age); docref.Set(map); HashMap map2 = new HashMap(); Toasty.Config.Instance .TintIcon(true) .SetToastTypeface(Typeface.CreateFromAsset(Assets, "Katanf.ttf")); Toasty.Success(this, "Group Added Sucesfully", 5, true).Show(); GrouD.Dismiss(); d.Dismiss(); this.Recreate(); } }
//Spinner item changed private void Send_Click(object sender, System.EventArgs e) { if (InputLegit()) { if (OAdurationTV.Text != "") { if (int.Parse(OAdurationTV.Text) > 50 || int.Parse(OAdurationTV.Text) < 40) { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.SetTitle("Alert!"); alert.SetMessage("Are you sure you want to add a group\nwith time setting difrent from the recommended"); alert.SetCancelable(false); alert.SetIcon(Resource.Drawable.ShameLogo); alert.SetPositiveButton("YES", (senderAlert, args) => { HashMap map = new HashMap(); Training training = new Training(selectedExercises); for (int i = 0; i < selectedExercises.Count; i++) { map.Put("Ex" + i, selectedExercises[i].name); } DocumentReference doref = database.Collection("Users").Document(admin.email).Collection("Trainings").Document(currGroup); doref.Set(map); Intent inte = new Intent(this, typeof(MainPageActivity)); inte.PutExtra("Email", admin.email); StartActivity(inte); Toasty.Config.Instance .TintIcon(true) .SetToastTypeface(Typeface.CreateFromAsset(Assets, "Katanf.ttf")); Toasty.Success(this, "Training Built Successfuly", 10, true).Show(); }); alert.SetNegativeButton("NO", (senderAlert, args) => { Dialog d = alert.Create(); d.Dismiss(); }); Dialog dialog = alert.Create(); dialog.Show(); } else { HashMap map = new HashMap(); Training training = new Training(selectedExercises); for (int i = 0; i < groups.Count - 1; i++) { if (currGroup == Ggroups[i].Location + " " + Ggroups[i].time + " " + Ggroups[i].age) { Ggroups[i].CurrentTraining = training; } } for (int i = 0; i < selectedExercises.Count; i++) { map.Put("Ex" + i, selectedExercises[i].name); } DocumentReference doref = database.Collection("Users").Document(admin.email).Collection("Trainings").Document(currGroup); doref.Set(map); Intent inte = new Intent(this, typeof(MainPageActivity)); inte.PutExtra("Email", admin.email); StartActivity(inte); Toasty.Config.Instance .TintIcon(true) .SetToastTypeface(Typeface.CreateFromAsset(Assets, "Katanf.ttf")); Toasty.Success(this, "Training Built Successfuly", 10, true).Show(); } } } else { } }
public void ShowSucceedToast(string message, bool longToast = false) { var toastLength = GetToastLength(longToast); Toasty.Success(Application.Context, message, toastLength, true).Show(); }