public LoginViewController(IAlertDialogFactory alertDialogService, IDefaultValueService defaultValueService) { _alertDialogService = alertDialogService; this.WhenAnyValue(x => x.ViewModel.ShowLoginOptionsCommand) .Select(x => x.ToBarButtonItem(UIBarButtonSystemItem.Action)) .Subscribe(x => NavigationItem.RightBarButtonItem = x); this.Appearing .Take(1) .Select(_ => this.WhenAnyValue(x => x.ViewModel.LoginUrl)) .Switch() .IsNotNull() .Subscribe(LoadRequest); bool hasSeenWelcome = false; if (!defaultValueService.TryGet(HasSeenWelcomeKey, out hasSeenWelcome)) { hasSeenWelcome = false; } this.Appeared .Where(_ => !hasSeenWelcome) .Take(1) .Subscribe(_ => BlurredAlertView.Display(OAuthWelcome, () => defaultValueService.Set(HasSeenWelcomeKey, true))); }
public MarkdownAccessoryViewModel( IImgurService imgurService, IMediaPickerFactory mediaPicker, IAlertDialogFactory alertDialogFactory, IDefaultValueService defaultValueService) { PostToImgurCommand = ReactiveCommand.CreateAsyncTask(async _ => { if (!defaultValueService.GetOrDefault(IMGUR_UPLOAD_WARN, false)) { defaultValueService.Set(IMGUR_UPLOAD_WARN, true); await alertDialogFactory.Alert("Please Read!", IMGUR_UPLOAD_WARN_MESSAGE); } var photo = await mediaPicker.PickPhoto(); var memoryStream = new MemoryStream(); await photo.Save(Splat.CompressedBitmapFormat.Jpeg, 0.8f, memoryStream); using (alertDialogFactory.Activate("Uploading...")) { var model = await imgurService.SendImage(memoryStream.ToArray()); if (model == null || model.Data == null || model.Data.Link == null) { throw new InvalidOperationException("Unable to upload to Imgur. Please try again later."); } return(model.Data.Link); } }); PostToImgurCommand.ThrownExceptions .Where(x => !(x is TaskCanceledException)) .Subscribe(x => alertDialogFactory.Alert("Upload Error", x.Message)); }
public MarkdownAccessoryViewModel( IImgurService imgurService, IMediaPickerFactory mediaPicker, IAlertDialogFactory alertDialogFactory, IDefaultValueService defaultValueService) { PostToImgurCommand = ReactiveCommand.CreateAsyncTask(async _ => { if (!defaultValueService.GetOrDefault(IMGUR_UPLOAD_WARN, false)) { defaultValueService.Set(IMGUR_UPLOAD_WARN, true); await alertDialogFactory.Alert("Please Read!", IMGUR_UPLOAD_WARN_MESSAGE); } var photo = await mediaPicker.PickPhoto(); var memoryStream = new MemoryStream(); await photo.Save(Splat.CompressedBitmapFormat.Jpeg, 0.8f, memoryStream); using (alertDialogFactory.Activate("Uploading...")) { var model = await imgurService.SendImage(memoryStream.ToArray()); if (model == null || model.Data == null || model.Data.Link == null) throw new InvalidOperationException("Unable to upload to Imgur. Please try again later."); return model.Data.Link; } }); PostToImgurCommand.ThrownExceptions .Where(x => !(x is TaskCanceledException)) .Subscribe(x => alertDialogFactory.Alert("Upload Error", x.Message)); }
public ApplicationService(IAccountsService accounts, IDefaultValueService defaultValueService) { _accountsService = accounts; _defaultValueService = defaultValueService; _timer = new Timer(1000 * 60 * 45); // 45 minutes _timer.AutoReset = true; _timer.Elapsed += (sender, e) => RefreshToken().RunSynchronously(); }
public StartupViewModel( ILoginFactory loginFactory, IApplicationService applicationService, IDefaultValueService defaultValueService) { _loginFactory = loginFactory; _applicationService = applicationService; _defaultValueService = defaultValueService; }
public ApplicationService(IDefaultValueService defaultValueService, IAccountsService accountsService) { DefaultValueService = defaultValueService; AccountsService = accountsService; AccountsService.WhenAnyObservable(x => x.ActiveAccountChanged).StartWith(AccountsService.ActiveAccount).Subscribe(account => { StashClient = account != null ? AtlassianStashSharp.StashClient.CrateBasic(new Uri(account.Domain), account.Username, account.Password) : null; }); }
public static T GetOrDefault <T>(this IDefaultValueService @this, string key, T defaultValue) { T val; if (@this.TryGet(key, out val)) { return(val); } return(defaultValue); }
public AccountsService(IDefaultValueService defaults, IAccountPreferencesService accountPreferences) { _defaults = defaults; _accountsPath = accountPreferences.AccountsDir; // Assure creation of the accounts path if (!Directory.Exists(_accountsPath)) Directory.CreateDirectory(_accountsPath); _userDatabase = new SQLiteConnection(Path.Combine(_accountsPath, "accounts.db")); _userDatabase.CreateTable<GitHubAccount>(); }
public static bool TryGet <T>(this IDefaultValueService @this, string key, out T value) { try { value = @this.Get <T>(key); return(true); } catch { value = default(T); return(false); } }
public StartupViewModel( ISessionService sessionService, IAccountsRepository accountsService, IAlertDialogFactory alertDialogFactory, IDefaultValueService defaultValueService) { _sessionService = sessionService; _accountsService = accountsService; _alertDialogFactory = alertDialogFactory; _defaultValueService = defaultValueService; StartupCommand = ReactiveCommand.CreateAsyncTask(x => Load()); }
public AccountsService(IDefaultValueService defaults, IAccountPreferencesService accountPreferences) { _defaults = defaults; _accountsPath = accountPreferences.AccountsDir; // Assure creation of the accounts path if (!Directory.Exists(_accountsPath)) { Directory.CreateDirectory(_accountsPath); } _userDatabase = new SQLiteConnection(Path.Combine(_accountsPath, "accounts.db")); _userDatabase.CreateTable <GitHubAccount>(); }
public SettingsViewModel(IApplicationService applicationService, IFeaturesService featuresService, IDefaultValueService defaultValueService, IAccountsService accountsService, IAnalyticsService analyticsService) { _applicationService = applicationService; _featuresService = featuresService; _defaultValueService = defaultValueService; _accountsService = accountsService; _analyticsService = analyticsService; GoToDefaultStartupViewCommand = ReactiveCommand.Create(); GoToDefaultStartupViewCommand.Subscribe(_ => ShowViewModel(CreateViewModel <DefaultStartupViewModel>())); DeleteAllCacheCommand = ReactiveCommand.Create(); }
public SettingsViewModel(IApplicationService applicationService, IFeaturesService featuresService, IDefaultValueService defaultValueService, IAccountsService accountsService, IAnalyticsService analyticsService) { _applicationService = applicationService; _featuresService = featuresService; _defaultValueService = defaultValueService; _accountsService = accountsService; _analyticsService = analyticsService; GoToDefaultStartupViewCommand = new ReactiveCommand(); GoToDefaultStartupViewCommand.Subscribe(_ => ShowViewModel(CreateViewModel<DefaultStartupViewModel>())); DeleteAllCacheCommand = new ReactiveCommand(); }
public AccountsService(IDefaultValueService defaults) { _defaults = defaults; var basePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), ".."); _accountsPath = Path.Combine(basePath, "Documents/accounts"); // Assure creation of the accounts path if (!Directory.Exists(_accountsPath)) { Directory.CreateDirectory(_accountsPath); } _userDatabase = new SQLiteConnection(Path.Combine(_accountsPath, "accounts.db")); _userDatabase.CreateTable <Account>(); }
public SettingsViewModel(IApplicationService applicationService, IFeaturesService featuresService, IDefaultValueService defaultValueService, IAccountsService accountsService, IAnalyticsService analyticsService, IEnvironmentalService environmentalService) { _applicationService = applicationService; _featuresService = featuresService; _defaultValueService = defaultValueService; _accountsService = accountsService; _analyticsService = analyticsService; _environmentService = environmentalService; GoToDefaultStartupViewCommand = ReactiveCommand.Create(); GoToDefaultStartupViewCommand.Subscribe(_ => ShowViewModel(CreateViewModel <DefaultStartupViewModel>())); DeleteAllCacheCommand = ReactiveCommand.Create(); GoToSourceCodeCommand = ReactiveCommand.Create().WithSubscription(_ => { var vm = CreateViewModel <RepositoryViewModel>(); vm.RepositoryOwner = "thedillonb"; vm.RepositoryName = "codehub"; ShowViewModel(vm); }); }
public StumbleViewModel(IApplicationService applicationService, INetworkActivityService networkActivity, IFeaturesService featuresService, IDefaultValueService defaultValues) : base(applicationService, networkActivity) { this._applicationService = applicationService; var localStumbleCount = 0; GoToPurchaseCommand = ReactiveCommand.Create(); GoToPurchaseCommand.Subscribe(_ => CreateAndShowViewModel <PurchaseProViewModel>()); StumbleCommand = ReactiveCommand.CreateAsyncTask(LoadCommand.IsExecuting.Select(x => !x), x => StumbleRepository()); StumbleCommand.Subscribe(x => { if (!featuresService.ProEditionEnabled) { var stumbleTimes = defaultValues.Get <nint>(StumbleKey) + 1; defaultValues.Set(StumbleKey, stumbleTimes); if (localStumbleCount > 0 && stumbleTimes % 50 == 0) { GoToPurchaseCommand.ExecuteIfCan(); } } localStumbleCount++; Reset(); RepositoryIdentifier = new RepositoryIdentifierModel(x.Repository.Owner, x.Repository.Name); LoadCommand.ExecuteIfCan(); }); StumbleCommand.TriggerNetworkActivity(networkActivity); DislikeCommand.Subscribe(_ => StumbleCommand.ExecuteIfCan()); LikeCommand.Subscribe(_ => StumbleCommand.ExecuteIfCan()); }
public StumbleViewModel(IApplicationService applicationService, INetworkActivityService networkActivity, IFeaturesService featuresService, IDefaultValueService defaultValues) : base(applicationService, networkActivity) { this._applicationService = applicationService; var localStumbleCount = 0; GoToPurchaseCommand = ReactiveCommand.Create(); GoToPurchaseCommand.Subscribe(_ => CreateAndShowViewModel<PurchaseProViewModel>()); StumbleCommand = ReactiveCommand.CreateAsyncTask(LoadCommand.IsExecuting.Select(x => !x), x => StumbleRepository()); StumbleCommand.Subscribe(x => { if (!featuresService.ProEditionEnabled) { var stumbleTimes = defaultValues.Get<nint>(StumbleKey) + 1; defaultValues.Set(StumbleKey, stumbleTimes); if (localStumbleCount > 0 && stumbleTimes % 50 == 0) { GoToPurchaseCommand.ExecuteIfCan(); } } localStumbleCount++; Reset(); RepositoryIdentifier = new RepositoryIdentifierModel(x.Repository.Owner, x.Repository.Name); LoadCommand.ExecuteIfCan(); }); StumbleCommand.TriggerNetworkActivity(networkActivity); DislikeCommand.Subscribe(_ => StumbleCommand.ExecuteIfCan()); LikeCommand.Subscribe(_ => StumbleCommand.ExecuteIfCan()); }
public InAppPurchaseService(IDefaultValueService defaultValueService) { _defaultValueService = defaultValueService; _observer = new TransactionObserver(this); SKPaymentQueue.DefaultQueue.AddTransactionObserver(_observer); }
public FeaturesService(IDefaultValueService defaultValueService = null, IInAppPurchaseService inAppPurchaseService = null) { _defaultValueService = defaultValueService ?? Locator.Current.GetService <IDefaultValueService>(); _inAppPurchaseService = inAppPurchaseService ?? Locator.Current.GetService <IInAppPurchaseService>(); }
public AccountsRepository(IDefaultValueService defaults) { _defaults = defaults; }
public FeaturesService(IDefaultValueService defaultValueService, IInAppPurchaseService inAppPurchaseService) { _defaultValueService = defaultValueService; _inAppPurchaseService = inAppPurchaseService; }
public FeaturesService(IDefaultValueService defaultValueService, IHttpClientService httpClientService, IJsonSerializationService jsonSerializationService) { _defaultValueService = defaultValueService; _httpClientService = httpClientService; _jsonSerializationService = jsonSerializationService; }
public SettingsViewModel(IFeaturesService featuresService, IDefaultValueService defaultValueService) { _featuresService = featuresService; _defaultValueService = defaultValueService; }
public GitHubAccountsService(IDefaultValueService defaults) { _defaults = defaults; }
public InAppPurchaseService(IDefaultValueService defaultValueService = null) { _defaultValueService = defaultValueService ?? Locator.Current.GetService <IDefaultValueService>(); _observer = new TransactionObserver(this); SKPaymentQueue.DefaultQueue.AddTransactionObserver(_observer); }
public GitHubAccountsService(IDefaultValueService defaults, IAccountPreferencesService accountPreferences) : base(defaults, accountPreferences) { }
public BitbucketAccountsService(IDefaultValueService defaults, IAccountPreferencesService accountPreferences) : base(defaults, accountPreferences) { }
public FeaturesService(IDefaultValueService defaultValueService) { _defaultValueService = defaultValueService; }