Пример #1
0
        public static async Task RunAsync()
        {
            var y       = YandeSettings.Current;
            var a       = AppSettings.Current;
            var key     = y.WallpaperUpdateTaskSearchKey;
            var shuffle = y.WallpaperUpdateTaskShuffleCount;

            var old = y.WallpaperUpdateTaskCurrentImageFileUri;

            y.WallpaperUpdateTaskCurrentImageID = "";

            try
            {
                // Search for posts
                var posts = await Posts.DownloadPostsAsync(1, $"https://yande.re/post.xml?tags={ WebUtility.UrlEncode(key) }");

                // Set wallpaper
                var result = await AnimePersonalization.SetBackgroundImageAsync(posts, shuffle, y.WallpaperUpdateTaskCropMethod, a.ScreenSize, false);

                // Notice the app that the wallpapaer was changed
                y.WallpaperUpdateTaskCurrentImageID = result;

                // Motice user about the change
                BigImageToast(result, y.WallpaperUpdateTaskCurrentImageFileUri, y.AvatarUri);
            }
            catch (Exception ex)
            {
                y.WallpaperUpdateTaskCurrentImageID = old;
                ToastService.ToastDebug("Cannot Update Wallpaper", ex.StackTrace);
                ToastService.ToastDebug("Cannot Update Wallpaper", ex.Message);
            }
        }
Пример #2
0
        private void App_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            e.Handled = false;

            ToastService.ToastDebug("應用閃退StackTrace", e.Exception.StackTrace);
            ToastService.ToastDebug("應用閃退Exception", e.Exception.Message);
        }
Пример #3
0
        public async void Run(IBackgroundTaskInstance taskInstance)
        {
            var d = taskInstance.GetDeferral();

            try
            {
                var cost = BackgroundWorkCost.CurrentBackgroundWorkCost;
                var p    = await Posts.DownloadPostsAsync(1, $"https://yande.re/post.xml?tags={ WebUtility.UrlEncode(YandeSettings.Current.TileUpdateTaskSearchKey) }");

                await AnimePersonalization.SetTileAsync(p);
            }
            catch (Exception ex)
            {
                ToastService.ToastDebug("Cannot Update Tile", ex.StackTrace);
                ToastService.ToastDebug("Cannot Update Tile", ex.Message);
            }

            d.Complete();
        }
Пример #4
0
        public static async Task RunAsync()
        {
            var yandeSettings = YandeSettings.Current;
            var key           = yandeSettings.TileUpdateTaskSearchKey;
            var filter        = yandeSettings.TilePostFilter;

            try
            {
                var cost  = BackgroundWorkCost.CurrentBackgroundWorkCost;
                var posts = await Posts.DownloadPostsAsync(1, $"{YandeClient.HOST}/post.xml?tags={ WebUtility.UrlEncode(key) }");

                var filteredPosts = new FilteredCollection <Post, Posts>(posts, filter);

                await AnimePersonalization.SetTileAsync(filteredPosts);
            }
            catch (Exception ex)
            {
                ToastService.ToastDebug("Cannot Update Tile", ex.StackTrace);
                ToastService.ToastDebug("Cannot Update Tile", ex.Message);
            }
        }
Пример #5
0
        public static async Task RunAsync()
        {
            var yandeSettings = YandeSettings.Current;
            var appSettings   = AppSettings.Current;
            var key           = yandeSettings.WallpaperUpdateTaskSearchKey;
            var shuffle       = yandeSettings.WallpaperUpdateTaskShuffleCount;
            var filter        = yandeSettings.WallpaperPostFilter;

            var old = yandeSettings.WallpaperUpdateTaskCurrentImageFileUri;

            yandeSettings.WallpaperUpdateTaskCurrentImageID = "";

            try
            {
                // Search for posts
                var posts = await Posts.DownloadPostsAsync(1, $"https://yande.re/post.xml?tags={ WebUtility.UrlEncode(key) }");

                var filteredPosts = new FilteredCollection <Post, Posts>(posts, filter);

                // Unset the previous wallpaper, so that the image file is no longer in use
                yandeSettings.WallpaperUpdateTaskCurrentImageID = "";

                // Set wallpaper
                var result = await AnimePersonalization.SetBackgroundImageAsync(filteredPosts, shuffle, yandeSettings.WallpaperUpdateTaskCropMethod, appSettings.ScreenSize, false, yandeSettings.WallpaperUpdateTaskQuality);

                // Notice the app that the wallpapaer was changed
                yandeSettings.WallpaperUpdateTaskCurrentImageID = result;

                // Motice user about the change
                // TODO: need opt out settings
                //BigImageToast(result, yandeSettings.WallpaperUpdateTaskCurrentImageFileUri, yandeSettings.AvatarUri);
            }
            catch (Exception ex)
            {
                yandeSettings.WallpaperUpdateTaskCurrentImageID = old;
                ToastService.ToastDebug("Cannot Update Wallpaper", ex.StackTrace);
                ToastService.ToastDebug("Cannot Update Wallpaper", ex.Message);
            }
        }
Пример #6
0
        protected override void OnBackgroundActivated(BackgroundActivatedEventArgs args)
        {
            base.OnBackgroundActivated(args);


            // Run the background task accordingly
            if (args.TaskInstance.Task.Name.CompareTo(nameof(TileUpdateTask)) == 0)
            {
                var activity = new TileUpdateTask();
                activity.Run(args.TaskInstance);
            }
            else if (args.TaskInstance.Task.Name.CompareTo(nameof(WallpaperUpdateTask)) == 0)
            {
                var activity = new WallpaperUpdateTask();
                activity.Run(args.TaskInstance);
            }
            else if (args.TaskInstance.Task.Name.CompareTo(nameof(LockscreenUpdateTask)) == 0)
            {
                var activity = new LockscreenUpdateTask();
                activity.Run(args.TaskInstance);
            }
            else if (args.TaskInstance.Task.Name.CompareTo("ToastActionTask") == 0)
            {
                ToastNotificationActionTriggerDetail d = (ToastNotificationActionTriggerDetail)args.TaskInstance.TriggerDetails;
                QueryString queryString = QueryString.Parse(d.Argument);

                switch (queryString["action"])
                {
                case "favorite":
                    var favoriteTask = new FavoriteTask();
                    favoriteTask.Run(args.TaskInstance);
                    break;

                case "undoLockscreen":
                    var wallpaperUndoTask = new LockscreenUndoTask();
                    wallpaperUndoTask.Run(args.TaskInstance);
                    break;

                case "undoWallpaper":
                    var lockscreenUndoTask = new WallpaperUndoTask();
                    lockscreenUndoTask.Run(args.TaskInstance);
                    break;

                default:
                    break;
                }
            }
            else if (args.TaskInstance.Task.Name.StartsWith(nameof(FavoriteTask)))
            {
                var activity = new FavoriteTask();
                activity.Run(args.TaskInstance);
            }
            else if (args.TaskInstance.Task.Name.StartsWith(nameof(WallpaperUndoTask)))
            {
                var activity = new WallpaperUndoTask();
                activity.Run(args.TaskInstance);
            }
            else
            {
                var x         = args.TaskInstance.Task.Trigger;
                var details   = args.TaskInstance.TriggerDetails as BackgroundTransferCompletionGroupTriggerDetails;
                var downloads = details.Downloads.ToList();
                // TODO: validate the download
                ToastService.ToastDebug("Download Finished", $"{downloads.Where(o => o.Progress.Status == BackgroundTransferStatus.Completed).Count()}/{downloads.Count} images downloaded successfully.");
            }
        }
Пример #7
0
 private async Task RunAsync(string id)
 {
     // Undo the bg
     ToastService.ToastDebug("Sorry", "This function is not finished yet.");
 }
Пример #8
0
        private void App_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            e.Handled = false;

            ToastService.ToastDebug("應用閃退,請聯絡開發者", e.Exception.Message);
        }