protected override void OnCreate(Bundle bundle) { Log.Info("CreateCustomeGoalForm", "Create Custom Goal Form created"); base.OnCreate(bundle); SetContentView(Resource.Layout.CreateCustomGoalForm); var layout = FindViewById<LinearLayout>(Resource.Id.CreateCustomGoalFormLayout); layout.SetBackgroundResource(Resource.Color.darkred); var preferences = GetSharedPreferences("Preferences.zad", FileCreationMode.Private); var monsterMode = preferences.GetBoolean("MonsterMode", false); if (!preferences.Contains("Rank")) { var preferencesEditor = preferences.Edit(); preferencesEditor.PutInt("Rank", 0); preferencesEditor.Apply(); } var rank = preferences.GetInt("Rank", -1); var customGoalNumber = FindViewById<EditText>(Resource.Id.CustomGoalNumber); var customGoalItems = FindViewById<EditText>(Resource.Id.CustomGoalItems); var customGoalRepeatCheckbox = FindViewById<CheckBox>(Resource.Id.CustomGoalRepeatCheckbox); var customGoalInnerLayout2 = FindViewById<LinearLayout>(Resource.Id.CustomGoalInnerLayout2); customGoalInnerLayout2.Visibility = ViewStates.Gone; var customGoalDaysNumber = FindViewById<EditText>(Resource.Id.CustomGoalDaysNumber); var customGoalText4 = FindViewById<TextView>(Resource.Id.CustomGoalText4); _customGoalSelectDate = FindViewById<Button>(Resource.Id.CustomGoalSelectDate); _customGoalSelectDate.Click += delegate { ShowDialog(DATE_DIALOG_ID); }; customGoalRepeatCheckbox.Click += delegate { if (customGoalRepeatCheckbox.Checked) { customGoalInnerLayout2.Visibility = ViewStates.Visible; customGoalText4.Text = "until"; } else { customGoalInnerLayout2.Visibility = ViewStates.Gone; customGoalText4.Text = "by"; } }; var submitCustomGoalButton = FindViewById<Button>(Resource.Id.SubmitCustomGoalButton); submitCustomGoalButton.Click += delegate { if (_goalDate.CompareTo(DateTime.Today) > 0) { var goalNumber = int.Parse(customGoalNumber.Text); var items = customGoalItems.Text; var timespan = 0; if (customGoalRepeatCheckbox.Checked && customGoalDaysNumber.Text != "") { timespan = int.Parse(customGoalDaysNumber.Text); } try { var customGoal = new CustomGoal(_goalDate, goalNumber, items, timespan); customGoal.AssignMonsterData(rank); var goalsList = JavaIO.LoadData<List<Goal>>(this, "Goals.zad"); goalsList.Add(customGoal); var successfulSave = JavaIO.SaveData(this, "Goals.zad", goalsList); if (successfulSave) { Toast.MakeText(this, "Goal Saved", ToastLength.Long).Show(); if (monsterMode) MakeMonsterDialog(customGoal); Finish(); } else { Toast.MakeText(this, "Error saving goal", ToastLength.Long).Show(); } } catch (Exception e) { Toast.MakeText(this, "Error: " + e.Message, ToastLength.Long).Show(); } } else { Toast.MakeText(this, "Error: Date must be in future", ToastLength.Long).Show(); } }; }
protected override void OnCreate(Bundle bundle) { Log.Info("MainMenu", "Main Menu Created"); base.OnCreate(bundle); SetContentView(Resource.Layout.MainMenu); var preferences = GetSharedPreferences("Preferences.zad", FileCreationMode.Private); var preferencesEditor = preferences.Edit(); if (!preferences.Contains("Rank")) { preferencesEditor.PutInt("Rank", 0); preferencesEditor.Apply(); } if (!preferences.Contains("MonsterMode")) { preferencesEditor.PutBoolean("MonsterMode", true); preferencesEditor.Apply(); } var rank = preferences.GetInt("Rank", -1); try { var goalsList = JavaIO.LoadData<List<Goal>>(this, "Goals.zad"); if (goalsList == null) { goalsList = new List<Goal>(); JavaIO.SaveData(this, "Goals.zad", goalsList); } } catch (FileNotFoundException) { var goalsList = new List<Goal>(); JavaIO.SaveData(this, "Goals.zad", goalsList); } try { var rewardsList = JavaIO.LoadData<List<Goal>>(this, "Rewards.zad"); if (rewardsList == null) { rewardsList = new List<Goal>(); JavaIO.SaveData(this, "Rewards.zad", rewardsList); } } catch (FileNotFoundException) { var rewardsList = new List<Goal>(); JavaIO.SaveData(this, "Rewards.zad", rewardsList); } var goalsButton = FindViewById<Button>(Resource.Id.GoalsButton); goalsButton.Click += delegate { StartActivity(typeof (GoalsMenu)); }; var rewardsButton = FindViewById<Button>(Resource.Id.RewardsButton); rewardsButton.Click += delegate { StartActivity(typeof (RewardsMenu)); }; var socialButton = FindViewById<Button>(Resource.Id.SocialButton); // socialButton.Click += delegate { StartActivity(typeof (SocialMenu)); }; socialButton.Visibility = ViewStates.Gone; var settingsButton = FindViewById<Button>(Resource.Id.SettingsButton); settingsButton.Click += delegate { StartActivity(typeof (SettingsMenu)); }; var setupButton = FindViewById<Button>(Resource.Id.SetupButton); setupButton.Click += delegate { var idesOfMarch2020 = new DateTime(2020, 3, 15); var fitnessGoal = new FitnessGoal(DateTime.Today, 23, FitnessItems.Pullups, 7); var dietGoal = new DietGoal(idesOfMarch2020, -15, DietItems.Pounds, 7); var customGoal = new CustomGoal(DateTime.Today, 8, "good deeds", 8); var futureCustomGoal = new CustomGoal(idesOfMarch2020, 42, "paintings"); fitnessGoal.AssignMonsterData(rank); dietGoal.AssignMonsterData(rank); customGoal.AssignMonsterData(rank); futureCustomGoal.AssignMonsterData(rank); customGoal.UpdateProgress(15); var goalsList = new List<Goal> {fitnessGoal, dietGoal, customGoal, futureCustomGoal}; var successfulGoalSave = JavaIO.SaveData(this, "Goals.zad", goalsList); var completeLongDietReward = new Reward("Long Diet", "You are awesome", new List<Goal> {dietGoal}); var doGoodDeedsReward = new Reward("Good Deeds Game", "Psychonauts: 5e728-vvd79-6hwx2", new List<Goal> {customGoal}); var rewardsList = new List<Reward> {completeLongDietReward, doGoodDeedsReward}; var successfulRewardSave = JavaIO.SaveData(this, "Rewards.zad", rewardsList); if (successfulRewardSave && successfulGoalSave) { Toast.MakeText(this, "Setup Complete", ToastLength.Short).Show(); } else if (!successfulGoalSave) { Toast.MakeText(this, "Goal Setup Failed", ToastLength.Short).Show(); } else { Toast.MakeText(this, "Reward Setup Failed", ToastLength.Short).Show(); } }; var monsterDemoButton = FindViewById<Button>(Resource.Id.MonsterDemoButton); // monsterDemoButton.Click += delegate { StartActivity(typeof (MonsterDisplay)); }; monsterDemoButton.Visibility = ViewStates.Gone; var pushActivityButton = FindViewById<Button>(Resource.Id.PushActivityButton); pushActivityButton.Click += delegate { StartActivity(typeof (PushActivity)); }; pushActivityButton.Visibility = ViewStates.Gone; }