예제 #1
0
 public BackupViewModel(IBackupManager backupManager,
     IDialogService dialogService, IConnectivity connectivity)
 {
     this.backupManager = backupManager;
     this.dialogService = dialogService;
     this.connectivity = connectivity;
 }
예제 #2
0
 public BackupViewModel(IBackupManager backupManager,
     IDialogService dialogService,
     IConnectivity connectivity,
     ISettingsManager settingsManager)
 {
     this.backupManager = backupManager;
     this.dialogService = dialogService;
     this.connectivity = connectivity;
     this.settingsManager = settingsManager;
 }
예제 #3
0
 public BackupManager(IBackupService backupService,
     IMvxFileStore fileStore,
     IDatabaseManager databaseManager,
     ISettingsManager settingsManager,
     IPaymentRepository paymentRepository, 
     IConnectivity connectivity)
 {
     this.backupService = backupService;
     this.fileStore = fileStore;
     this.databaseManager = databaseManager;
     this.settingsManager = settingsManager;
     this.paymentRepository = paymentRepository;
     this.connectivity = connectivity;
 }
		public WorkoutContainerViewModel(IWorkoutCreatorContext workoutCreatorContext, IConnectivity current, bool createWorkoutOnly = false, User logFeedbackOnlyUser = null)
		{
			WorkoutCreatorContext = workoutCreatorContext;
			Current = current;

			if (createWorkoutOnly)
			{
				Header = "Create Workout";
			}
			else {
				if (logFeedbackOnlyUser == null)
				{
					Header = "Create/Record Workout";
				}
				else {
					Header = "Log Feedback";
				}
			}
		}
예제 #5
0
        public VaultListLoginsPage(bool favorites, string uri = null)
            : base(true)
        {
            _favorites              = favorites;
            _folderService          = Resolver.Resolve <IFolderService>();
            _loginService           = Resolver.Resolve <ILoginService>();
            _connectivity           = Resolver.Resolve <IConnectivity>();
            _userDialogs            = Resolver.Resolve <IUserDialogs>();
            _clipboardService       = Resolver.Resolve <IDeviceActionService>();
            _syncService            = Resolver.Resolve <ISyncService>();
            _pushNotification       = Resolver.Resolve <IPushNotification>();
            _deviceInfoService      = Resolver.Resolve <IDeviceInfoService>();
            _settings               = Resolver.Resolve <ISettings>();
            _googleAnalyticsService = Resolver.Resolve <IGoogleAnalyticsService>();

            var cryptoService = Resolver.Resolve <ICryptoService>();

            Uri = uri;

            Init();
        }
예제 #6
0
        public EnvironmentViewModel(IEnvironment environment,
                                    IConnectivity connectivity,
                                    IPowerManager powerManager)
        {
            this.environment = environment;

            connectivity
            .WhenAnyValue(x => x.Reach)
            .Select(x => x.ToString())
            .ToPropertyEx(this, x => x.NetworkReach)
            .DisposedBy(this.DeactivateWith);

            connectivity
            .WhenAnyValue(x => x.Access)
            .Select(x => x.ToString())
            .ToPropertyEx(this, x => x.NetworkAccess)
            .DisposedBy(this.DeactivateWith);

            connectivity
            .WhenAnyValue(x => x.CellularCarrier)
            .ToPropertyEx(this, x => x.CellularCarrier)
            .DisposedBy(this.DeactivateWith);

            powerManager
            .WhenAnyValue(x => x.IsEnergySavingEnabled)
            .ToPropertyEx(this, x => x.IsEnergySavingEnabled)
            .DisposedBy(this.DeactivateWith);

            powerManager
            .WhenAnyValue(x => x.Status)
            .Select(x => x.ToString())
            .ToPropertyEx(this, x => x.PowerStatus)
            .DisposedBy(this.DeactivateWith);

            powerManager
            .WhenAnyValue(x => x.BatteryLevel)
            .ToPropertyEx(this, x => x.BatteryPercentage)
            .DisposedBy(this.DeactivateWith);
        }
예제 #7
0
        public VaultListCiphersPage(bool folder         = false, string folderId    = null,
                                    string collectionId = null, string groupingName = null, bool favorites = false, string uri = null)
            : base(true)
        {
            _folder       = folder;
            _folderId     = folderId;
            _collectionId = collectionId;
            _favorites    = favorites;
            _groupingName = groupingName;
            _uri          = uri;

            _cipherService          = Resolver.Resolve <ICipherService>();
            _connectivity           = Resolver.Resolve <IConnectivity>();
            _syncService            = Resolver.Resolve <ISyncService>();
            _deviceInfoService      = Resolver.Resolve <IDeviceInfoService>();
            _settings               = Resolver.Resolve <ISettings>();
            _appSettingsService     = Resolver.Resolve <IAppSettingsService>();
            _googleAnalyticsService = Resolver.Resolve <IGoogleAnalyticsService>();
            _deviceActionService    = Resolver.Resolve <IDeviceActionService>();

            Init();
        }
예제 #8
0
        public VaultAddCipherPage(CipherType type, string defaultUri = null, string defaultName = null,
                                  bool fromAutofill = false, bool doInit = true, string defaultFolderId = null)
        {
            _defaultFolderId = defaultFolderId;
            _type            = type;
            _defaultUri      = defaultUri;
            _defaultName     = defaultName;
            _fromAutofill    = fromAutofill;

            _cipherService          = Resolver.Resolve <ICipherService>();
            _folderService          = Resolver.Resolve <IFolderService>();
            _connectivity           = Resolver.Resolve <IConnectivity>();
            _googleAnalyticsService = Resolver.Resolve <IGoogleAnalyticsService>();
            _settings            = Resolver.Resolve <ISettings>();
            _appInfoService      = Resolver.Resolve <IAppInfoService>();
            _deviceInfo          = Resolver.Resolve <IDeviceInfoService>();
            _deviceActionService = Resolver.Resolve <IDeviceActionService>();

            if (doInit)
            {
                Init();
            }
        }
예제 #9
0
        public VaultListLoginsPage(bool favorites, string uri = null)
            : base(true)
        {
            _favorites              = favorites;
            _folderService          = Resolver.Resolve <IFolderService>();
            _loginService           = Resolver.Resolve <ILoginService>();
            _connectivity           = Resolver.Resolve <IConnectivity>();
            _userDialogs            = Resolver.Resolve <IUserDialogs>();
            _clipboardService       = Resolver.Resolve <IClipboardService>();
            _syncService            = Resolver.Resolve <ISyncService>();
            _pushNotification       = Resolver.Resolve <IPushNotification>();
            _deviceInfoService      = Resolver.Resolve <IDeviceInfoService>();
            _settings               = Resolver.Resolve <ISettings>();
            _googleAnalyticsService = Resolver.Resolve <IGoogleAnalyticsService>();

            var cryptoService = Resolver.Resolve <ICryptoService>();

            _loadExistingData = !_settings.GetValueOrDefault(Constants.FirstVaultLoad, true) || !cryptoService.KeyChanged;

            Uri = uri;

            Init();
        }
예제 #10
0
        public NuGetService(
            ICacheService cacheProvider,
            IHttpHandlerService httpHandlerService,
            IPreferences preferences,
            IVersionTracking versionTracking,
            IConnectivity connectivity,
            IFileSystem fileSystem,
            ILogger logger)
        {
            _cache  = cacheProvider ?? throw new ArgumentNullException(nameof(cacheProvider));
            _logger = logger ?? throw new ArgumentNullException(nameof(logger));

            _preferences     = preferences;
            _versionTracking = versionTracking;
            _connectivity    = connectivity;

            _httpClient = new HttpClient(httpHandlerService.GetNativeHandler());

            var dbPath = Path.Combine(fileSystem.AppDataDirectory, "nugets.db");

            _db = new LiteDatabase($"Filename={dbPath};Upgrade=true;");
            _db.Pragma("UTC_DATE", true);

            _packageSourceRepo = new EntityRepository <PackageSource>(_db, TimeSpan.FromDays(7), _connectivity);
            _favouriteRepo     = new EntityRepository <FavouritePackage>(_db, TimeSpan.MaxValue, _connectivity);
            _recentRepo        = new EntityRepository <RecentPackage>(_db, TimeSpan.MaxValue, _connectivity);

            _retryPolicy =
                Policy.Handle <WebException>()
                .Or <HttpRequestException>()
                .WaitAndRetryAsync
                (
                    retryCount: 2,
                    sleepDurationProvider: retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt))
                );
        }
 public SplashScreenViewModel(IConnectivity connectivity, IPreferences preferences, IVersionTracking versionTracking,
                              IAuthentificationService authentificationService, IMvxNavigationService navigationService, IMvxMessenger messenger,
                              ISecureStorage secureStorage, IAppSettings appSettings, IUserSettingsService userSettingsService, IUserDialogs userDialogs,
                              WasabeeApiV1Service wasabeeApiV1Service, UsersDatabase usersDatabase, OperationsDatabase operationsDatabase, LinksDatabase linksDatabase,
                              MarkersDatabase markersDatabase, TeamsDatabase teamsDatabase, TeamAgentsDatabase teamAgentsDatabase)
 {
     _connectivity            = connectivity;
     _preferences             = preferences;
     _versionTracking         = versionTracking;
     _authentificationService = authentificationService;
     _navigationService       = navigationService;
     _messenger           = messenger;
     _secureStorage       = secureStorage;
     _appSettings         = appSettings;
     _userSettingsService = userSettingsService;
     _userDialogs         = userDialogs;
     _wasabeeApiV1Service = wasabeeApiV1Service;
     _usersDatabase       = usersDatabase;
     _operationsDatabase  = operationsDatabase;
     _linksDatabase       = linksDatabase;
     _markersDatabase     = markersDatabase;
     _teamsDatabase       = teamsDatabase;
     _teamAgentsDatabase  = teamAgentsDatabase;
 }
		public OrdersListViewModel()
		{
			_ordersRepository = new OrdersWebRepository ();
			_connectivity = CrossConnectivity.Current;
			Orders = new ReactiveList<OrderViewModel>();

			// Initial connectivity availability
			CanLoadOrders = _connectivity.IsConnected;

			// Convert a .NET event to an observable 
			// and subscribe to an observer *anonymous delegate extension*.
			IObservable<EventPattern<ConnectivityChangedEventArgs>> connectivityChangedObservable = 
				Observable.FromEventPattern<ConnectivityChangedEventArgs>(
					_connectivity, 
					"ConnectivityChanged",
					RxApp.MainThreadScheduler);

			// When the IConnectivity.ConnectivityChanged event is raised
			// the observable will push me the ConnectivityChangedEventArgs.
			_connectivityChangedDisposable = connectivityChangedObservable.Subscribe(evt => {
				// Set if we can load orders
				CanLoadOrders = evt.EventArgs.IsConnected;
			});

			// Cool stuff! ReactiveUI offers some Rx helpers.
			// When the CanLoadOrders property changes let me know.
			IObservable<bool> canLoadOrdersObservable = 
				this.WhenAny(x => x.CanLoadOrders, x => x.Value);

			// More Cool stuff! ReactiveCommands have built-in support for background
			// operations. RxCmd guarantees that this block will only run exactly
			// once at a time, and that the CanExecute will auto-disable while it
			// is running.
			LoadOrdersCommand = ReactiveCommand.CreateAsyncTask(
				canLoadOrdersObservable,
				async _ => 
				{
					return await _ordersRepository.GetAsync();;
				});

			// And if that is not Cool stuff! ReactiveCommands are themselves IObservables, whose value
			// are the results from the async method, guaranteed to arrive on the UI
			// thread. We're going to take the list of teams that the background
			// operation loaded, and put them into our TeamList.
			_loadOrdersCommandDisposable = LoadOrdersCommand.ObserveOn(RxApp.MainThreadScheduler).Subscribe(
				orders => {
					int currentCount = count;
					count++;

					IEnumerable<OrderViewModel> ordersTranformed = orders.Select(o => {
						o.OrderNumber = string.Format("{0} - {1}", o.OrderNumber, currentCount);
						return o;
					});

					Orders.InsertRange(0, ordersTranformed);
				},
				ex => {
					UserError.Throw("Fetching orders exception: " + ex.Message, ex);
				});

			// Niiiiice! Whenever the CanLoadOrders changes, we're going to wait
			// for one second of "dead airtime", then invoke the LoadOrdersCommand
			// command.
			_canLoadOrdersDisposable = canLoadOrdersObservable
				.Where(x => x)
				.Throttle(TimeSpan.FromSeconds(1), RxApp.MainThreadScheduler)
				.InvokeCommand(this, x => x.LoadOrdersCommand);
		}
 public FirstViewModel(IConnectivity connectivity)
 {
     _connectivity = connectivity;
 }
예제 #14
0
 public BaseViewModel(IConnectivity connectivity = null)
 {
     //Initializing dependencies
     _connectivity = (connectivity == null) ? new Connectivity() : connectivity;
 }
예제 #15
0
 public ManagerBase(IConnectivity connectivity, IServiceEntityMapper mapper)
 {
     Connectivity = connectivity;
     Mapper       = mapper;
 }
 public ConnectivityService(IConnectivity connectivity)
 {
     _connectivity = connectivity;
 }
예제 #17
0
 public WeatherService(IUserDialogs userDialogs, IConnectivity connectivity) : base(userDialogs, connectivity, AppSetting.WeatherHost)
 {
     Api = RestService.For <IWeatherService>(AppSetting.WeatherHost);
 }
예제 #18
0
        public ListPageViewModel(INavigationService navigationService,
                                 IJobManager jobManager,
                                 IDialogService dialogService,
                                 ILogger <ViewModelBase> logger, IConnectivity connectivity) : base(navigationService, dialogService, logger, connectivity)
        {
            this._jobManager = jobManager;

            //this.Create = _navigationService.NavigateCommand("CreateJob");

            this.LoadJobs = ReactiveCommand.CreateFromTask(async() =>
            {
                var jobs  = await jobManager.GetJobs();
                this.Jobs = jobs
                            .Select(x => new CommandItem
                {
                    Text             = x.Type.Name,
                    Detail           = $"上次运行:{x.LastRunUtc?.ToLocalTime().ToString("G") ?? "永久运行"}",
                    PrimaryCommand   = ReactiveCommand.CreateFromTask(() => jobManager.Run(x.Identifier)),
                    SecondaryCommand = ReactiveCommand.CreateFromTask(async() =>
                    {
                        await jobManager.Cancel(x.Identifier);
                        this.LoadJobs.Execute(null);
                    })
                })
                            .ToList();
            });
            this.BindBusyCommand(this.LoadJobs);

            this.RunAllJobs = ReactiveCommand.CreateFromTask(async() =>
            {
                if (!await this.AssertJobs())
                {
                    return;
                }

                if (this._jobManager.IsRunning)
                {
                    _dialogService.ShortAlert("作业管理器已在运行");
                }
                else
                {
                    await this._jobManager.RunAll();
                    _dialogService.ShortAlert("作业批处理已启动");
                }
            });

            this.CancelAllJobs = ReactiveCommand.CreateFromTask(async _ =>
            {
                if (!await this.AssertJobs())
                {
                    return;
                }

                var confirm = await _dialogService.ShowConfirmAsync("是否确实要取消所有作业?");
                if (confirm)
                {
                    await this._jobManager.CancelAll();
                    this.LoadJobs.Execute(null);
                }
            });
        }
 public ConnectivityService(IConnectivity connectivity = null)
 {
     Connectivity = connectivity ?? Plugin.Connectivity.CrossConnectivity.Current;
 }
예제 #20
0
 public DeviceApiRepository(IConnectivity connectivity)
     : base(connectivity)
 {
 }
예제 #21
0
 public WebAPIService(IConnectivity connectivity)
 {
     Connectivity = connectivity;
 }
예제 #22
0
        public override void ViewDidLoad()
        {
            _cipherService          = Resolver.Resolve <ICipherService>();
            _connectivity           = Resolver.Resolve <IConnectivity>();
            _folderService          = Resolver.Resolve <IFolderService>();
            _googleAnalyticsService = Resolver.Resolve <IGoogleAnalyticsService>();

            NavItem.Title         = AppResources.AddItem;
            CancelBarButton.Title = AppResources.Cancel;
            SaveBarButton.Title   = AppResources.Save;
            View.BackgroundColor  = new UIColor(red: 0.94f, green: 0.94f, blue: 0.96f, alpha: 1.0f);

            NameCell.TextField.Text          = Context?.Uri?.Host ?? string.Empty;
            NameCell.TextField.ReturnKeyType = UIReturnKeyType.Next;
            NameCell.TextField.ShouldReturn += (UITextField tf) =>
            {
                UriCell.TextField.BecomeFirstResponder();
                return(true);
            };

            UriCell.TextField.Text          = Context?.UrlString ?? string.Empty;
            UriCell.TextField.KeyboardType  = UIKeyboardType.Url;
            UriCell.TextField.ReturnKeyType = UIReturnKeyType.Next;
            UriCell.TextField.ShouldReturn += (UITextField tf) =>
            {
                UsernameCell.TextField.BecomeFirstResponder();
                return(true);
            };

            UsernameCell.TextField.AutocapitalizationType = UITextAutocapitalizationType.None;
            UsernameCell.TextField.AutocorrectionType     = UITextAutocorrectionType.No;
            UsernameCell.TextField.SpellCheckingType      = UITextSpellCheckingType.No;
            UsernameCell.TextField.ReturnKeyType          = UIReturnKeyType.Next;
            UsernameCell.TextField.ShouldReturn          += (UITextField tf) =>
            {
                PasswordCell.TextField.BecomeFirstResponder();
                return(true);
            };

            PasswordCell.TextField.SecureTextEntry = true;
            PasswordCell.TextField.ReturnKeyType   = UIReturnKeyType.Next;
            PasswordCell.TextField.ShouldReturn   += (UITextField tf) =>
            {
                NotesCell.TextView.BecomeFirstResponder();
                return(true);
            };

            GeneratePasswordCell.TextLabel.Text = AppResources.GeneratePassword;
            GeneratePasswordCell.Accessory      = UITableViewCellAccessory.DisclosureIndicator;

            _folders = _folderService.GetAllAsync().GetAwaiter().GetResult();
            var folderNames = _folders.Select(s => s.Name.Decrypt()).OrderBy(s => s).ToList();

            folderNames.Insert(0, AppResources.FolderNone);
            FolderCell.Items = folderNames;

            TableView.RowHeight          = UITableView.AutomaticDimension;
            TableView.EstimatedRowHeight = 70;
            TableView.Source             = new TableSource(this);
            TableView.AllowsSelection    = true;

            base.ViewDidLoad();
        }
예제 #23
0
 public MasterPageViewModel(INavigationService navigationService, IUserDialogs userDialogsService, IConnectivity connectivity) : base(navigationService, userDialogsService, connectivity)
 {
     Username  = Profile.Instance.Name;
     ImageUser = "******";
     CreatedMenu();
     OnSelectItemCommand = new DelegateCommand(OnSelectItemCommandExecuted);
     CloseSessionCommand = new DelegateCommand(CloseSessionCommandExecuted);
 }
예제 #24
0
        public MainPageViewModel(INavigationService navigationService, IPageDialogService pageDialogService, IConnectivity connectivity, IWeather weather)
            : base(navigationService, pageDialogService)
        {
            _weather      = weather;
            _connectivity = connectivity;

            NoInternet();

            GenerateRandomLocation = new DelegateCommand(async() => await GetWeatherConditions(true));
        }
예제 #25
0
파일: App.cs 프로젝트: maxlandry/mobile
        public App(
            string uri,
            IAuthService authService,
            IConnectivity connectivity,
            IUserDialogs userDialogs,
            IDatabaseService databaseService,
            ISyncService syncService,
            IFingerprint fingerprint,
            ISettings settings,
            ILockService lockService,
            IGoogleAnalyticsService googleAnalyticsService,
            ILocalizeService localizeService,
            IAppInfoService appInfoService)
        {
            _uri                    = uri;
            _databaseService        = databaseService;
            _connectivity           = connectivity;
            _userDialogs            = userDialogs;
            _syncService            = syncService;
            _authService            = authService;
            _fingerprint            = fingerprint;
            _settings               = settings;
            _lockService            = lockService;
            _googleAnalyticsService = googleAnalyticsService;
            _localizeService        = localizeService;
            _appInfoService         = appInfoService;

            SetCulture();
            SetStyles();

            if (authService.IsAuthenticated && _uri != null)
            {
                MainPage = new ExtendedNavigationPage(new VaultAutofillListLoginsPage(_uri));
            }
            else if (authService.IsAuthenticated)
            {
                MainPage = new MainPage();
            }
            else
            {
                MainPage = new ExtendedNavigationPage(new HomePage());
            }

            MessagingCenter.Subscribe <Application, bool>(Current, "Resumed", async(sender, args) =>
            {
                Device.BeginInvokeOnMainThread(async() => await CheckLockAsync(args));
                await Task.Run(() => FullSyncAsync()).ConfigureAwait(false);
            });

            MessagingCenter.Subscribe <Application, bool>(Current, "Lock", (sender, args) =>
            {
                Device.BeginInvokeOnMainThread(async() => await CheckLockAsync(args));
            });

            MessagingCenter.Subscribe <Application, string>(Current, "Logout", (sender, args) =>
            {
                Logout(args);
            });

            MessagingCenter.Subscribe <Application>(Current, "SetMainPage", (sender) =>
            {
                SetMainPageFromAutofill();
            });
        }
예제 #26
0
 public DeviceApiRepository(
     IConnectivity connectivity,
     IHttpService httpService)
     : base(connectivity, httpService)
 {
 }
 public AccountManager(IConnectivity connectivity, IServiceEntityMapper mapper, IAccountWebService accountWebService) : base(connectivity, mapper)
 {
     _accountWebService = accountWebService;
 }
예제 #28
0
 public AccountsApiRepository(
     IConnectivity connectivity,
     IHttpService httpService)
     : base(connectivity, httpService)
 {
 }
예제 #29
0
        public NewsReaderSourcePageViewModel(IDialogService dialogService, ILogger logger, INewsApiService newApiService, IConnectivity connectivity) : base(connectivity)
        {
            Logger        = logger;
            DialogService = dialogService;
            NewApiService = newApiService;
            SourceList    = new ObservableCollection <Source>();

            DisableSourceCommand = new DelegateCommand(OnDisableSourceCommandExecuted);
        }
예제 #30
0
 public InternetConnectionManager(ILogManager logManager, IConnectivity connectivity, ITimerFactory timerFactory) : base(logManager, connectivity, timerFactory)
 {
 }
 public TestViewModel(IConnectivity connectivity) { Connectivity = connectivity; }
예제 #32
0
 public JobManagerImpl(IServiceProvider container,
                       IRepository repository,
                       IPowerManager powerManager,
                       IConnectivity connectivity) : base(container, repository, powerManager, connectivity)
 {
 }
예제 #33
0
 protected ManagerBase(IConnectivity connectivity, IServiceMapper mapper)
 {
     _connectivity = connectivity;
     Mapper        = mapper;
 }
예제 #34
0
 public ConnectionService()
 {
     _connectivity = CrossConnectivity.Current;
     _connectivity.ConnectivityChanged += Connectivity_ConnectivityChanged;
 }
예제 #35
0
 public static void Init(IConnectivity storeObj)
 {
     InstanceObj = storeObj;
 }
예제 #36
0
 public SessionUpdateService(IDatabaseService databaseService, IDataUpdateService dataUpdateService, IConnectivity connectivity)
 {
     _databaseService   = databaseService;
     _dataUpdateService = dataUpdateService;
     _connectivity      = connectivity;
 }
 public BaseApiRepository(IConnectivity connectivity)
 {
     Connectivity = connectivity;
 }