public async Task<string> GetStoredStravaAccessToken() { if (_settings != null) return _settings.StravaAccessToken; bool settingsExists = await this.SettingsServiceExists(); if (settingsExists) { string settingsAsString = await ServiceLocator.Current.GetInstance<IStorageService>().Local.ReadAllTextAsync(Constants.SETTINGSSTORE); _settings = JsonConvert.DeserializeObject<Settings>(settingsAsString); return _settings.StravaAccessToken; } return null; }
public async Task<DistanceUnitType> GetStoredDistanceUnitType() { if (_settings != null) return _settings.DistanceUnitType; bool settingsExists = await this.SettingsServiceExists(); if (settingsExists) { string settingsAsString = await ServiceLocator.Current.GetInstance<IStorageService>().Local.ReadAllTextAsync(Constants.SETTINGSSTORE); _settings = JsonConvert.DeserializeObject<Settings>(settingsAsString); return _settings.DistanceUnitType; } return DistanceUnitType.Kilometres; }
public async Task SetStravaAccessTokenAsync(string stravaAccessToken) { if (_settings == null) { bool settingsExists = await this.SettingsServiceExists(); if (settingsExists) { string settingsAsString = await ServiceLocator.Current.GetInstance<IStorageService>().Local.ReadAllTextAsync(Constants.SETTINGSSTORE); _settings = JsonConvert.DeserializeObject<Settings>(settingsAsString); } else _settings = new Settings(); } _settings.StravaAccessToken = stravaAccessToken; await ServiceLocator.Current.GetInstance<IStorageService>().Local.WriteAllTextAsync(Constants.SETTINGSSTORE, JsonConvert.SerializeObject(_settings)); }