Example #1
0
        protected override async Task NavigatedToAsync(CancellationToken cancelToken, NavigatedToEventArgs e, Dictionary <string, object> viewModelState)
        {
            await RefreshCacheSaveFolderStatus();

            if (IsRequireUpdateCacheSaveFolder.Value)
            {
                NotificationService.ShowInAppNotification(
                    InAppNotificationPayload.CreateReadOnlyNotification("キャッシュの保存先フォルダを選択してください。\n保存先が選択されると利用準備が完了します。",
                                                                        showDuration: TimeSpan.FromSeconds(30)
                                                                        ));

                if (await CacheSaveFolder.ChangeUserDataFolder())
                {
                    await Task.Delay(1000);

                    await RefreshCacheSaveFolderStatus();
                    await ResetList();

                    NotificationService.ShowInAppNotification(
                        InAppNotificationPayload.CreateReadOnlyNotification("キャッシュの利用準備が出来ました")
                        );
                }
            }

            await base.NavigatedToAsync(cancelToken, e, viewModelState);
        }
Example #2
0
        public override async Task OnNavigatedToAsync(INavigationParameters parameters)
        {
            await RefreshCacheSaveFolderStatus();

            if (IsRequireUpdateCacheSaveFolder.Value)
            {
                NotificationService.ShowInAppNotification(
                    InAppNotificationPayload.CreateReadOnlyNotification("ChoiceCacheSavingFolder".Translate(),
                                                                        showDuration: TimeSpan.FromSeconds(30)
                                                                        ));

                if (await CacheSaveFolder.ChangeUserDataFolder())
                {
                    await Task.Delay(1000);

                    await RefreshCacheSaveFolderStatus();
                    await ResetList();

                    NotificationService.ShowInAppNotification(
                        InAppNotificationPayload.CreateReadOnlyNotification("ReadyForVideoCache".Translate())
                        );
                }
            }

            await base.OnNavigatedToAsync(parameters);
        }
        public override async Task OnNavigatedToAsync(INavigationParameters parameters)
        {
            await RefreshCacheSaveFolderStatus();

            if (IsRequireUpdateCacheSaveFolder.Value)
            {
                NotificationService.ShowInAppNotification(
                    InAppNotificationPayload.CreateReadOnlyNotification("キャッシュの保存先フォルダを選択してください。\n保存先が選択されると利用準備が完了します。",
                                                                        showDuration: TimeSpan.FromSeconds(30)
                                                                        ));

                if (await CacheSaveFolder.ChangeUserDataFolder())
                {
                    await Task.Delay(1000);

                    await RefreshCacheSaveFolderStatus();
                    await ResetList();

                    NotificationService.ShowInAppNotification(
                        InAppNotificationPayload.CreateReadOnlyNotification("キャッシュの利用準備が出来ました")
                        );
                }
            }

            await base.OnNavigatedToAsync(parameters);
        }
Example #4
0
        public VideoCacheIntroductionPageViewModel(
            CacheSettings cacheSettings,
            CacheSaveFolder cacheSaveFolder,
            DialogService dialogService
            )
        {
            CacheSettings        = cacheSettings;
            CacheSaveFolder      = cacheSaveFolder;
            HohoemaDialogService = dialogService;

            var hasCacheFolder = Windows.Storage.AccessCache.StorageApplicationPermissions.
                                 FutureAccessList.Entries.Count > 0;

            IsCompleteCacheSettings = new ReactiveProperty <bool>(CacheSettings.IsUserAcceptedCache && hasCacheFolder)
                                      .AddTo(_Disposables);

            CanChangeCacheSettings = new ReactiveProperty <bool>(!IsCompleteCacheSettings.Value)
                                     .AddTo(_Disposables);
            RequireEnablingCacheCommand = CanChangeCacheSettings.ToAsyncReactiveCommand()
                                          .AddTo(_Disposables);

            RequireEnablingCacheCommand.Subscribe(async() =>
            {
                bool isAcceptedCache = CacheSettings.IsUserAcceptedCache;
                if (!isAcceptedCache)
                {
                    isAcceptedCache = await HohoemaDialogService.ShowAcceptCacheUsaseDialogAsync();
                    if (isAcceptedCache)
                    {
                        CacheSettings.IsEnableCache       = true;
                        CacheSettings.IsUserAcceptedCache = true;

                        (App.Current).Resources["IsCacheEnabled"] = true;
                    }
                }

                if (isAcceptedCache)
                {
                    if (await CacheSaveFolder.ChangeUserDataFolder())
                    {
                        IsCompleteCacheSettings.Value = true;
                    }
                }
            })
            .AddTo(_Disposables);
        }
Example #5
0
        public CacheManagementPageViewModel(
            ApplicationLayoutManager applicationLayoutManager,
            CacheSettings cacheSettings,
            VideoCacheManager videoCacheManager,
            CacheSaveFolder cacheSaveFolder,
            NicoVideoProvider nicoVideoProvider,
            PageManager pageManager,
            DialogService dialogService,
            NotificationService notificationService,
            HohoemaPlaylist hohoemaPlaylist
            )
        {
            ApplicationLayoutManager       = applicationLayoutManager;
            CacheSettings                  = cacheSettings;
            VideoCacheManager              = videoCacheManager;
            CacheSaveFolder                = cacheSaveFolder;
            NicoVideoProvider              = nicoVideoProvider;
            HohoemaDialogService           = dialogService;
            NotificationService            = notificationService;
            HohoemaPlaylist                = hohoemaPlaylist;
            IsRequireUpdateCacheSaveFolder = new ReactiveProperty <bool>(false);

            IsCacheUserAccepted = CacheSettings.ObserveProperty(x => x.IsUserAcceptedCache)
                                  .ToReadOnlyReactiveProperty();

            RequireEnablingCacheCommand = new DelegateCommand(async() =>
            {
                var result = await HohoemaDialogService.ShowAcceptCacheUsaseDialogAsync();
                if (result)
                {
                    CacheSettings.IsEnableCache               = true;
                    CacheSettings.IsUserAcceptedCache         = true;
                    (App.Current).Resources["IsCacheEnabled"] = true;

                    await RefreshCacheSaveFolderStatus();

                    NotificationService.ShowInAppNotification(
                        InAppNotificationPayload.CreateReadOnlyNotification("ChoiceCacheSavingFolder".Translate(),
                                                                            showDuration: TimeSpan.FromSeconds(30)
                                                                            ));

                    if (await CacheSaveFolder.ChangeUserDataFolder())
                    {
                        await RefreshCacheSaveFolderStatus();

                        await VideoCacheManager.CacheFolderChanged();

                        await ResetList();

                        NotificationService.ShowInAppNotification(
                            InAppNotificationPayload.CreateReadOnlyNotification("ReadyForVideoCache".Translate())
                            );
                    }
                }
            });

            ReadCacheAcceptTextCommand = new DelegateCommand(async() =>
            {
                var result = await HohoemaDialogService.ShowAcceptCacheUsaseDialogAsync(showWithoutConfirmButton: true);
            });



            CacheFolderStateDescription = new ReactiveProperty <string>("");
            CacheSaveFolderPath         = new ReactiveProperty <string>("");

            OpenCurrentCacheFolderCommand = new DelegateCommand(async() =>
            {
                await RefreshCacheSaveFolderStatus();

                var folder = await CacheSaveFolder.GetVideoCacheFolder();
                if (folder != null)
                {
                    await Launcher.LaunchFolderAsync(folder);
                }
            });


            ChangeCacheFolderCommand = new DelegateCommand(async() =>
            {
                var prevPath = CacheSaveFolderPath.Value;

                if (await CacheSaveFolder.ChangeUserDataFolder())
                {
                    NotificationService.ShowInAppNotification(
                        InAppNotificationPayload.CreateReadOnlyNotification("CacheSaveFolderChangeToX".Translate(CacheSaveFolderPath.Value))
                        );

                    await RefreshCacheSaveFolderStatus();

                    await VideoCacheManager.CacheFolderChanged();

                    await ResetList();
                }
            });
        }