/// <summary> /// This should be called when loading the stats picker. If this method returns true, the user should be able to track ALL stats. If this method returns /// false, the user should only be able to track Shots / Shot details. /// /// TODO: This needs to be hooked into in the following places: /// 1. When loading the stats picker /// 2. When loading the main screen: If this returns true, do not display the "Purchase" button /// 3. When loading the main screen: If this returns true, do not display the "Lite" icon, display the full icon /// </summary> /// <returns></returns> public static bool DoesUserHaveAbilityToTrackAllStats() { bool returnValue = false; //If the user of a free app has bought the full stats package, they have access to track all of the stats. if (FREE_VERSION) { if (Convert.ToBoolean(IS.GetSetting(FULL_STATS_FREE_VERSION))) { returnValue = true; } } else { returnValue = true; } //10/25/14 TJY Change so if user has rated app they get ALL stats now if (App.gHasAppBeenRated.ToUpper() == "YES") { returnValue = true; } return(returnValue); }
// Constructor public MainPage() { _mainPageInstance = this; string hasAppBeenRated = string.Empty; if (Rate.HasAppBeenRated().ToUpper() == "YES") { _rated = true; } else { _rated = false; } InitializeComponent(); //Initially show the msft control, if it fails, show google. AdvertisingVisibility = Visibility.Visible; GoogleAdVisibility = Visibility.Collapsed; MyAdControl.CountryOrRegion = RegionInfo.CurrentRegion.TwoLetterISORegionName; BuildLocalizedApplicationBar(_rated); SetLockScreenSetting(); MyAdControl.ErrorOccurred += MyAdControl_ErrorOccurred; GoogleAdControl.FailedToReceiveAd += GoogleAdControl_FailedToReceiveAd; this.DataContext = this; Trial.SaveStartDateOfTrial(); if (IS.GetSetting(RATED) != null) { if ((bool)IS.GetSetting(RATED)) { _rated = true; } } if (IS.GetSetting(NUMBEROFTIMESOPENED) == null) { IS.SaveSetting(NUMBEROFTIMESOPENED, 0); } else { IS.SaveSetting(NUMBEROFTIMESOPENED, (int)IS.GetSetting(NUMBEROFTIMESOPENED) + 1); _numberOfTimesOpened = (int)IS.GetSetting(NUMBEROFTIMESOPENED); } if (!(Application.Current as App).IsFreeVersion) { PaidAppInitialization(); } else { FreeAppInitialIzation(); } }
public void GetSettings() { if (IS.GetSetting("SentTextCount") == null) { App.gSentTextCount = 0; } else { App.gSentTextCount = (int)IS.GetSetting("SentTextCount"); } }
private void UpdateSentTextCount(int value) { if (IS.GetSetting("SentTextCount") == null) { IS.SaveSetting("SentTextCount", 1); } else { IS.SaveSetting("SentTextCount", (int)IS.GetSetting("SentTextCount") + value); } App.gSentTextCount = (int)IS.GetSetting("SentTextCount"); TextStatusMessage = AppResources.TrialTextSent + App.gSentTextCount.ToString() + "/" + App.gTextLimit; }
/// <summary> /// This method will return whether or not the APP is enabled at all. This should be called on init of the main screen. /// For Free apps, this will always return true, as they can always use the app. /// For the trial, we will return false after 3 days. /// TODO: Disable All buttons on the main screen if this returns FALSE. If the user clicks on a button, prompt them "Trial has expired, do you wish to purchase app?" /// If they click yes, navigate to the store. This method will automatically check licence information after the purchase has been completed. /// </summary> /// <returns></returns> public static bool IsAppEnabled() { bool appEnabled = false; //App is always enabled for free version. if (FREE_VERSION) { appEnabled = true; } //Paid version else { //If it is not a trial, it is the full paid version if (!_isTrial) { appEnabled = true; } else { // It is a trial. We need to have logic here to see if the trial is EXPIRED. If the trial is expired, we need to return FALSE to disable //The application. For now, we are only using a 3 day trial. //Step 1: Save the trial date if there is not one already. This will be the date the application is first opened. if (IS.GetSetting(TRIAL_START_DATE) == null) { //Save today IS.SaveSetting(TRIAL_START_DATE, DateTime.Today); } //Step 2: Check to see if the Trial Date + 4 days = Today. We do 4 days to actually allow them to use it on the 3rd day. DateTime trialStart = Convert.ToDateTime(IS.GetSetting(TRIAL_START_DATE)); DateTime trialEndDate = trialStart.AddDays(4); //Step 3: If the today is greater than or equal to the end date, trial is over if (DateTime.Today >= trialEndDate.Date) { //Trial OVER appEnabled = false; } } } return(appEnabled); }
public void LoadSettings() { if (IS.GetSetting(ONSTARTUPCHECKED) != null) { OnStartUpChecked = (bool)IS.GetSetting(ONSTARTUPCHECKED); } if (IS.GetSetting(HOLDONCHECKED) != null) { HoldOnChecked = (bool)IS.GetSetting(HOLDONCHECKED); } if (IS.GetSetting(STROBEFREQUENCY) != null) { StrobeFrequency = (int)IS.GetSetting(STROBEFREQUENCY); } else { StrobeFrequency = 1000; } if (IS.GetSetting(STROBEON) != null) { StrobeOn = (bool)IS.GetSetting(STROBEON); } else { StrobeOn = false; } if (IS.GetSetting(ONWHENLOCKED) != null) { OnWhenLockedChecked = (bool)IS.GetSetting(ONWHENLOCKED); } else { OnWhenLockedChecked = false; } }
private void LoadShowTextSetting() { string settingValue = string.Empty; if (IS.GetSetting("BabyApp-ShowText") == null) { gShowTextSetting = "On"; IS.SaveSetting("BabyApp-ShowText", "On"); } else { settingValue = IS.GetSetting("BabyApp-ShowText").ToString(); if (settingValue == "On") { gShowTextSetting = "On"; } else { gShowTextSetting = "Off"; } } }
private void LoadPlayMusicSetting() { string settingValue = string.Empty; if (IS.GetSetting("BabyApp-PlayMusic") == null) { gPlayMusicSetting = "On"; IS.SaveSetting("BabyApp-PlayMusic", "On"); } else { settingValue = IS.GetSetting("BabyApp-PlayMusic").ToString(); if (settingValue == "On") { gPlayMusicSetting = "On"; } else { gPlayMusicSetting = "Off"; } } }
private async void WriteUserInfoToCloud(bool trial) { try { bool isAppPaid = false; if (App.FREE_VERSION) { if (App.DoesUserHaveAbilityToTrackAllStats()) { isAppPaid = true; } } else { if (!App.IsTrial) { isAppPaid = true; } } if (IS.GetSetting(USER_ID) == null) { string newGuid = Guid.NewGuid().ToString(); AllUsers rowToInsert = new AllUsers() { Guid = newGuid, TimesOpened = 1, FreeVersion = App.FREE_VERSION, TrialVersion = App.IsTrial, TotalTimeInApp = new TimeSpan(0, 0, 0), Paid = isAppPaid, LastLogin = DateTime.Now }; await App.MobileService.GetTable <AllUsers>().InsertAsync(rowToInsert); var newUserRow = await allUsersTable .Where(x => x.Guid == newGuid).ToListAsync(); _clientRow = newUserRow.FirstOrDefault(); //Update IS IS.SaveSetting(USER_ID, _clientRow.Id); //Remove the GUID, we no longer need it rowToInsert.Guid = string.Empty; await App.MobileService.GetTable <AllUsers>().UpdateAsync(rowToInsert); } //Update else { var rows = await allUsersTable .Where(x => x.Id == IS.GetSettingStringValue(USER_ID)).ToListAsync(); AllUsers userRow = rows.ToList().FirstOrDefault(); userRow.LastLogin = DateTime.Now; userRow.TimesOpened += 1; userRow.FreeVersion = App.FREE_VERSION; userRow.TrialVersion = App.IsTrial; userRow.Paid = isAppPaid; _clientRow = userRow; await App.MobileService.GetTable <AllUsers>().UpdateAsync(userRow); } } catch (Exception ex) { } }
private void LoadLanguageSettings() { string settingValue = string.Empty; try { if (IS.GetSetting("BabyApp-English") == null) { gLanguages.Remove("English"); } else { settingValue = IS.GetSetting("BabyApp-English").ToString(); if (settingValue == "Yes") { gLanguages.Add("English"); } else { gLanguages.Remove("English"); } } if (IS.GetSetting("BabyApp-Spanish") == null) { gLanguages.Remove("Spanish"); } else { settingValue = IS.GetSetting("BabyApp-Spanish").ToString(); if (settingValue == "Yes") { gLanguages.Add("Spanish"); } else { gLanguages.Remove("Spanish"); } } if (IS.GetSetting("BabyApp-Italian") == null) { gLanguages.Remove("Italian"); } else { settingValue = IS.GetSetting("BabyApp-Italian").ToString(); if (settingValue == "Yes") { gLanguages.Add("Italian"); } else { gLanguages.Remove("Italian"); } } if (IS.GetSetting("BabyApp-French") == null) { gLanguages.Remove("French"); } else { settingValue = IS.GetSetting("BabyApp-French").ToString(); if (settingValue == "Yes") { gLanguages.Add("French"); } else { gLanguages.Remove("French"); } } if (IS.GetSetting("BabyApp-Polish") == null) { gLanguages.Remove("Polish"); } else { settingValue = IS.GetSetting("BabyApp-Polish").ToString(); if (settingValue == "Yes") { gLanguages.Add("Polish"); } else { gLanguages.Remove("Polish"); } } if (IS.GetSetting("BabyApp-German") == null) { gLanguages.Remove("German"); } else { settingValue = IS.GetSetting("BabyApp-German").ToString(); if (settingValue == "Yes") { gLanguages.Add("German"); } else { gLanguages.Remove("German"); } } if (IS.GetSetting("BabyApp-Portuguese") == null) { gLanguages.Remove("Portuguese"); } else { settingValue = IS.GetSetting("BabyApp-Portuguese").ToString(); if (settingValue == "Yes") { gLanguages.Add("Portuguese"); } else { gLanguages.Remove("Portuguese"); } } if (IS.GetSetting("BabyApp-Japanese") == null) { gLanguages.Remove("Japanese"); } else { settingValue = IS.GetSetting("BabyApp-Japanese").ToString(); if (settingValue == "Yes") { gLanguages.Add("Japanese"); } else { gLanguages.Remove("Japanese"); } } if (IS.GetSetting("BabyApp-Chinese") == null) { gLanguages.Remove("Chinese"); } else { settingValue = IS.GetSetting("BabyApp-Chinese").ToString(); if (settingValue == "Yes") { gLanguages.Add("Chinese"); } else { gLanguages.Remove("Chinese"); } } if (gLanguages.Count == 0) { gLanguages.Add("English"); IS.SaveSetting("BabyApp-English", "Yes"); } } catch (Exception ex) { throw; } }