示例#1
0
        public LoginPageViewModel(
            ILoggingService logging,
            INavigationService navigation,
            IPlatformSpecific device,
            IWallabagClient client,
            IApiClientCreationService apiService,
            SQLiteConnection database)
        {
            _loggingService    = logging;
            _navigationService = navigation;
            _device            = device;
            _client            = client;
            _apiClientService  = apiService;
            _database          = database;

            _loggingService.WriteLine("Creating new instance of LoginPageViewModel.");

            Providers = new List <WallabagProvider>()
            {
                new WallabagProvider(new Uri("https://framabag.org"), "framabag", _device.GetLocalizedResource("FramabagProviderDescription")),
                new WallabagProvider(new Uri("https://app.wallabag.it"), "wallabag.it", _device.GetLocalizedResource("WallabagItProviderDescription")),
                WallabagProvider.GetOther(_device)
            };

            PreviousCommand       = new RelayCommand(() => Previous(), () => PreviousCanBeExecuted());
            NextCommand           = new RelayCommand(async() => await NextAsync(), () => NextCanBeExecuted());
            RegisterCommand       = new RelayCommand(() => _device.LaunchUri((SelectedProvider as WallabagProvider).Url.Append("/register")), () => RegistrationCanBeExecuted());
            WhatIsWallabagCommand = new RelayCommand(() => _device.LaunchUri(new Uri("vimeo://v/167435064"), new Uri("https://vimeo.com/167435064")));
            ScanQRCodeCommand     = new RelayCommand(() => _navigationService.Navigate(Navigation.Pages.QRScanPage));

            this.PropertyChanged += This_PropertyChanged;
        }
示例#2
0
 public OfflineTaskService(IWallabagClient client, SQLiteConnection database, ILoggingService loggingService, IPlatformSpecific platform)
 {
     _client         = client;
     _database       = database;
     _loggingService = loggingService;
     _platform       = platform;
 }
示例#3
0
        protected override void OnStart()
        {
            string StartPage = string.Empty;

            if (DataStore.DS.IsDataLoaded)
            {
                NavigationService.NavigateAsync("MainPage/NavigationPage/" + nameof(HubPage));
                return;
            }

            AppCenterInit();

            CardSizes.Current.ReCalculateCardWidths();

            // TODO create platform specific check for allowed rotations until xamarin.essentials
            // gives me the data

            IPlatformSpecific ps = Container.Resolve <IPlatformSpecific>();

            DataStore.CN = Container.Resolve <ICommonNotifications>();

            DataStore.NV = new NavCmd(Container.Resolve <IEventAggregator>());

            IDataRepositoryManager temp = Container.Resolve <IDataRepositoryManager>();

            // Start at the MessageLog Page and work from there
            StartPage = nameof(MessageLogPage);

            NavigationService.NavigateAsync("MainPage/NavigationPage/" + StartPage);
        }
 /// <inheritdoc />
 public RyukContainer(IDockerClient dockerClient, IPlatformSpecific platformSpecific, ILoggerFactory loggerFactory)
     : base(platformSpecific.RyukImage, dockerClient, loggerFactory)
 {
     _logger              = loggerFactory.CreateLogger <RyukContainer>();
     _sendToRyukWorker    = new BatchWorkerFromDelegate(SendToRyuk);
     _connectToRyukWorker = new BatchWorkerFromDelegate(ConnectToRyuk);
 }
示例#5
0
        protected override void OnStart()
        {
            if (DataStore.DS.IsDataLoaded)
            {
                NavigationService.NavigateAsync("MainPage/NavigationPage/" + nameof(HubPage));
                return;
            }

            AppCenterInit();

            CardSizes.Current.ReCalculateCardWidths();

            // TODO create platform specific check for allowed rotations until xamarin.essentials
            // gives me the data

            IPlatformSpecific ps = Container.Resolve <IPlatformSpecific>();

            DataStore.CN = Container.Resolve <ICommonNotifications>();

            DataStore.NV = new NavCmd(Container.Resolve <IEventAggregator>());

            IDataRepositoryManager temp = Container.Resolve <IDataRepositoryManager>();

            // Start at the MessageLog Page if no other paramaters and work from there
            if (!DataStore.NV.TargetNavParams.Any())
            {
                DataStore.NV.TargetNavParams.Add(CommonConstants.NavigationParameterTargetView, nameof(MessageLogPage));
            }

            DataStore.NV.TargetNavParams.TryGetValue(CommonConstants.NavigationParameterTargetView, out string targetView);

            NavigationService.NavigateAsync("MainPage/NavigationPage/" + targetView);
        }
示例#6
0
        public static ItemViewModel FromId(
            int itemId,
            ILoggingService logging,
            SQLiteConnection database,
            IOfflineTaskService offlineTaskService,
            INavigationService navigation,
            IPlatformSpecific platform)
        {
            logging.WriteLine($"Creating ItemViewModel from item id: {itemId}");

            var item = database.Find <Item>(itemId);

            if (item == null)
            {
                logging.WriteLine($"Failed! Item does not exist in database!", LoggingCategory.Critical);
            }

            if (item != null)
            {
                return(new ItemViewModel(item, offlineTaskService, navigation, logging, platform, database));
            }
            else
            {
                return(null);
            }
        }
        public ItemPageViewModel(
            IOfflineTaskService offlineTaskService,
            ILoggingService loggingService,
            IPlatformSpecific device,
            INavigationService navigationService,
            IWallabagClient client,
            SQLite.Net.SQLiteConnection database)
        {
            _offlineTaskService = offlineTaskService;
            _loggingService     = loggingService;
            _device             = device;
            _navigationService  = navigationService;
            _client             = client;
            _database           = database;

            _loggingService.WriteLine($"Initializing new instance of {nameof(ItemPageViewModel)}.");

            ChangeReadStatusCommand     = new RelayCommand(() => ChangeReadStatus());
            ChangeFavoriteStatusCommand = new RelayCommand(() => ChangeFavoriteStatus());
            EditTagsCommand             = new RelayCommand(() => _navigationService.Navigate(Navigation.Pages.EditTagsPage, Item.Model.Id));
            DeleteCommand = new RelayCommand(() =>
            {
                _loggingService.WriteLine("Deleting the current item.");
                Item.DeleteCommand.Execute();
                _navigationService.GoBack();
            });

            SaveRightClickLinkCommand          = new RelayCommand(() => _offlineTaskService.AddAsync(RightClickUri.ToString(), new List <string>()));
            OpenRightClickLinkInBrowserCommand = new RelayCommand(() => _device.LaunchUri(RightClickUri));
            CopyLinkToClipboardCommand         = new RelayCommand(() => _device.SetClipboardUri(RightClickUri));
        }
示例#8
0
 public MigrationService(
     ILoggingService loggingService,
     IPlatformSpecific device)
 {
     _logging    = loggingService;
     _device     = device;
     _migrations = new List <Migration>();
 }
示例#9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PersonDetailViewModel"/> class.
        /// </summary>
        /// <param name="iocCommonLogging">
        /// The common logging service.
        /// </param>
        public PersonDetailViewModel(ICommonLogging iocCommonLogging, IPlatformSpecific iocPlatformSpecific)
            : base(iocCommonLogging)
        {
            BaseTitle     = "Person Detail";
            BaseTitleIcon = CommonConstants.IconPeople;

            _PlatformSpecific = iocPlatformSpecific;
        }
 public LiveTileService(
     SQLiteConnection database,
     ILoggingService logging,
     IPlatformSpecific platform)
 {
     _database = database;
     _logging  = logging;
     _device   = platform;
 }
示例#11
0
 public ApiClientCreationService(
     ILoggingService loggingService,
     IWallabagClient client,
     IPlatformSpecific platform)
 {
     _loggingService = loggingService;
     _client         = client;
     _device         = platform;
 }
示例#12
0
 public StartPageViewModel()
 {
     _migrationService  = SimpleIoc.Default.GetInstance <IMigrationService>();
     _database          = SimpleIoc.Default.GetInstance <SQLiteConnection>();
     _navigationService = SimpleIoc.Default.GetInstance <INavigationService>();
     _client            = SimpleIoc.Default.GetInstance <IWallabagClient>();
     _device            = SimpleIoc.Default.GetInstance <IPlatformSpecific>();
     _logging           = SimpleIoc.Default.GetInstance <ILoggingService>();
 }
示例#13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="StorePostLoad"/> class.
        /// </summary>
        /// <param name="iocCommonLogging">
        /// The ioc common logging.
        /// </param>
        /// <param name="iocEventAggregator">
        /// The ioc event aggregator.
        /// </param>
        public StorePostLoad(ISharedLogging iocCommonLogging, IErrorNotifications iocCommonNotifications, IMessenger iocEventAggregator)
        {
            _EventAggregator     = iocEventAggregator;
            _CommonLogging       = iocCommonLogging;
            _commonNotifications = iocCommonNotifications;

            _iocPlatformSpecific = DependencyService.Get <IPlatformSpecific>();

            App.Current.Services.GetService <IMessenger>().Register <DataLoadXMLEvent>(this, (r, m) =>
            {
                if (m.Value == null)
                {
                    return;
                }

                LoadXMLUIItems(true);
            });
        }
示例#14
0
        public SettingsPageViewModel(
            ILoggingService logging,
            IBackgroundTaskService backgroundTask,
            IPlatformSpecific device,
            SQLiteConnection database)
        {
            _loggingService        = logging;
            _backgroundTaskService = backgroundTask;
            _device   = device;
            _database = database;

            _loggingService.WriteLine($"Creating a new instance of {nameof(SettingsPageViewModel)}.");

            OpenDocumentationCommand          = new RelayCommand(() => _device.LaunchUri(_documentationUri));
            OpenWallabagTwitterAccountCommand = new RelayCommand(() => _device.LaunchUri(_twitterAccountUri));
            ContactDeveloperCommand           = new RelayCommand(() => _device.LaunchUri(_mailUri));
            CreateIssueCommand    = new RelayCommand(() => _device.LaunchUri(_githubIssueUri));
            RateAppCommand        = new RelayCommand(() => _device.LaunchUri(_rateAppUri));
            LogoutCommand         = new RelayCommand(() => Logout());
            DeleteDatabaseCommand = new RelayCommand(() => DeleteDatabase());
        }
 public static WallabagProvider GetOther(IPlatformSpecific device)
 => new WallabagProvider(
     default(Uri),
     device.GetLocalizedResource("OtherProviderName"),
     device.GetLocalizedResource("OtherProviderDescription"));
 /// <summary>
 /// Initializes a new instance of the <see cref="FamilyDetailViewModel"/> class.
 /// </summary>
 /// <param name="iocCommonLogging">
 /// common logging.
 /// </param>
 /// <param name="iocEventAggregator">
 /// Prism event aggregator.
 /// </param>
 /// <param name="iocNavigationService">
 /// </param>
 /// <param name="iocPlatformSpecific">
 /// </param>
 public FamilyDetailViewModel(ICommonLogging iocCommonLogging, IEventAggregator iocEventAggregator, INavigationService iocNavigationService, IPlatformSpecific iocPlatformSpecific)
     : base(iocCommonLogging, iocEventAggregator, iocNavigationService)
 {
     _PlatformSpecific = iocPlatformSpecific;
 }
示例#17
0
        public ItemViewModel(Item item,
                             IOfflineTaskService offlineTaskService,
                             INavigationService navigation,
                             ILoggingService logging,
                             IPlatformSpecific device,
                             SQLiteConnection database)
        {
            Model = item;
            _offlineTaskService = offlineTaskService;
            _navigationService  = navigation;
            _loggingService     = logging;
            _device             = device;
            _database           = database;

            (item as INotifyPropertyChanged).PropertyChanged += (s, e) =>
            {
                _loggingService.WriteLine($"Model with ID {item.Id} was updated.");
                RaisePropertyChanged(nameof(item));
            };

            MarkAsReadCommand = new RelayCommand(async() =>
            {
                _loggingService.WriteLine($"Marking item {item.Id} as read.");
                item.IsRead = true;
                UpdateItem();
                await _offlineTaskService.AddAsync(item.Id, OfflineTask.OfflineTaskAction.MarkAsRead);
            });
            UnmarkAsReadCommand = new RelayCommand(async() =>
            {
                _loggingService.WriteLine($"Marking item {item.Id} as unread.");
                item.IsRead = false;
                UpdateItem();
                await _offlineTaskService.AddAsync(item.Id, OfflineTask.OfflineTaskAction.UnmarkAsRead);
            });
            MarkAsStarredCommand = new RelayCommand(async() =>
            {
                _loggingService.WriteLine($"Marking item {item.Id} as favorite.");
                item.IsStarred = true;
                UpdateItem();
                await _offlineTaskService.AddAsync(item.Id, OfflineTask.OfflineTaskAction.MarkAsStarred);
            });
            UnmarkAsStarredCommand = new RelayCommand(async() =>
            {
                _loggingService.WriteLine($"Marking item {item.Id} as unfavorite.");
                item.IsStarred = false;
                UpdateItem();
                await _offlineTaskService.AddAsync(item.Id, OfflineTask.OfflineTaskAction.UnmarkAsStarred);
            });
            DeleteCommand = new RelayCommand(async() =>
            {
                _loggingService.WriteLine($"Deleting item {item.Id}.");
                _database.Delete(item);
                await _offlineTaskService.AddAsync(item.Id, OfflineTask.OfflineTaskAction.Delete);
            });
            ShareCommand = new RelayCommand(() =>
            {
                _loggingService.WriteLine($"Sharing item {item.Id}.");
                _device.ShareItem(item);
            });
            EditTagsCommand = new RelayCommand(() =>
            {
                _loggingService.WriteLine($"Editing tags of item {item.Id}.");
                _navigationService.Navigate(Pages.EditTagsPage, Model.Id);
            });
            OpenInBrowserCommand = new RelayCommand(() =>
            {
                _loggingService.WriteLine($"Opening item {item.Id} in browser.");
                _device.LaunchUri(new Uri(item.Url));
            });
        }
示例#18
0
        public static void setupMocks()
        {
            /*
             * Mock Common Logging
             */
            ISharedLogging iocCommonLogging = new SharedLogging();

            /*
             * Mock Common Notifications
             */
            Mock <IErrorNotifications> mockCommonNotifications = new Mock <IErrorNotifications>();

            mockCommonNotifications
            .Setup(x => x.DataLogEntryAdd(It.IsAny <string>()));

            iocCommonNotifications = mockCommonNotifications.Object;

            /*
             * Mock Image Loading
             */
            Mock <IFFImageLoading> mocFFImageLoading = new Mock <IFFImageLoading>();
            IFFImageLoading        iocFFImageLoading = mocFFImageLoading.Object;

            /*
             * Mock Xamarin Essentials
             */
            Mock <IXamarinEssentials> mocXamarinEssentials = new Mock <IXamarinEssentials>();

            mocXamarinEssentials
            .Setup(x => x.FileSystemCacheDirectory)
            .Returns(Path.GetTempPath());

            IXamarinEssentials iocXamarinEssentials = mocXamarinEssentials.Object;

            /*
             * Mock Event Aggregator
             */
            Mock <DataLoadXMLEvent> mockedEventDataLoadXMLEvent = new Mock <DataLoadXMLEvent>();

            // TODO fix this

            //mocEventAggregator
            //      .Setup(x => x.Register<DataLoadXMLEvent>())
            //          .Returns(mockedEventDataLoadXMLEvent.Object);

            //Mock<DataLoadStartEvent> mockedEventDataLoadStartEvent = new Mock<DataLoadStartEvent>();
            //mocEventAggregator
            //      .Setup(x => x.GetEvent<DataLoadStartEvent>())
            //          .Returns(mockedEventDataLoadStartEvent.Object);

            //Mock<DataSaveSerialEvent> mockedEventDataSaveSerialEvent = new Mock<DataSaveSerialEvent>();
            //mocEventAggregator
            //    .Setup(x => x.GetEvent<DataSaveSerialEvent>())
            //        .Returns(mockedEventDataSaveSerialEvent.Object);

            //Mock<DataLoadCompleteEvent> mockedEventDataLoadCompleteEvent = new Mock<DataLoadCompleteEvent>();
            //mocEventAggregator
            //    .Setup(x => x.GetEvent<DataLoadCompleteEvent>())
            //        .Returns(mockedEventDataLoadCompleteEvent.Object);

            IMessenger iocEventAggregator = mocEventAggregator.Object;

            /*
             * Mock Platform specific
             */
            iocPlatformSpecific = mocPlatformSpecific.Object;

            /*
             * Configure DataStore
             */
            DataStore.Instance.ES   = iocXamarinEssentials;
            DataStore.Instance.FFIL = iocFFImageLoading;

            /*
             * Other setup
             */
            iocExternalStorage = new StoreXML(iocCommonLogging, iocCommonNotifications);

            iocGrampsStorePostLoad = new StorePostLoad(iocCommonLogging, iocCommonNotifications, iocEventAggregator);

            iocGrampsStoreSerial = new GrampsStoreSerial(iocCommonLogging);

            iocStoreFile = new StoreFile();

            newManager = new DataRepositoryManager(iocCommonLogging, iocCommonNotifications, iocEventAggregator, iocExternalStorage, iocGrampsStorePostLoad, iocGrampsStoreSerial, iocStoreFile);
        }