diff --git a/Pixiview.iOS/AppDelegate.cs b/Pixiview.iOS/AppDelegate.cs index ce788b0..455b65e 100644 --- a/Pixiview.iOS/AppDelegate.cs +++ b/Pixiview.iOS/AppDelegate.cs @@ -26,7 +26,9 @@ namespace Pixiview.iOS public override bool OpenUrl(UIApplication app, NSUrl url, NSDictionary options) { +#if DEBUG App.DebugPrint($"url: {url}."); +#endif return App.OpenUrl(url); } } diff --git a/Pixiview/App.cs b/Pixiview/App.cs index 926dfeb..614dee7 100644 --- a/Pixiview/App.cs +++ b/Pixiview/App.cs @@ -44,7 +44,9 @@ namespace Pixiview if (!string.IsNullOrEmpty(host) && port > 0) { Configs.Proxy = new System.Net.WebProxy(host, port); +#if DEBUG DebugPrint($"load proxy: {host}:{port}"); +#endif } else { @@ -74,7 +76,9 @@ namespace Pixiview { return; } +#if DEBUG DebugPrint($"application theme: {theme}"); +#endif ThemeBase themeInstance; if (theme == AppTheme.Dark) { diff --git a/Pixiview/AppShell.xaml.cs b/Pixiview/AppShell.xaml.cs index e1da9c3..cd5e428 100644 --- a/Pixiview/AppShell.xaml.cs +++ b/Pixiview/AppShell.xaml.cs @@ -57,7 +57,10 @@ namespace Pixiview BindingContext = this; InitializeComponent(); +#if DEBUG App.DebugPrint($"folder: {Stores.PersonalFolder}"); + App.DebugPrint($"cache: {Stores.CacheFolder}"); +#endif } protected override void OnNavigated(ShellNavigatedEventArgs args) diff --git a/Pixiview/Illust/FavoritesPage.xaml.cs b/Pixiview/Illust/FavoritesPage.xaml.cs index ab47677..429635c 100644 --- a/Pixiview/Illust/FavoritesPage.xaml.cs +++ b/Pixiview/Illust/FavoritesPage.xaml.cs @@ -280,14 +280,18 @@ namespace Pixiview.Illust if (bookmarkId != null) { // not exists in remote any more +#if DEBUG App.DebugPrint($"remove bookmark ({bookmarkId}) - {b.Id}: {b.Title}"); +#endif nows.RemoveAt(i); } } else if (bookmarkId != bookmark.BookmarkId) { // update bookmark id +#if DEBUG App.DebugPrint($"change bookmark ({bookmarkId}) to ({bookmark.BookmarkId}) - {b.Id}: {b.Title}"); +#endif b.BookmarkId = bookmark.BookmarkId; } } @@ -299,7 +303,9 @@ namespace Pixiview.Illust for (var i = 0; i < list.Length; i++) { var item = list[i]; +#if DEBUG App.DebugPrint($"add bookmark ({item.BookmarkId}) - {item.Id}: {item.Title}"); +#endif item.Image = StyleDefinition.DownloadBackground; } nows.InsertRange(0, list); diff --git a/Pixiview/Illust/IllustCollectionPage.cs b/Pixiview/Illust/IllustCollectionPage.cs index 490a718..21c04ab 100644 --- a/Pixiview/Illust/IllustCollectionPage.cs +++ b/Pixiview/Illust/IllustCollectionPage.cs @@ -166,7 +166,9 @@ namespace Pixiview.Illust if (Columns != columns) { Columns = columns; +#if DEBUG App.DebugPrint($"change columns to {columns}"); +#endif } } @@ -521,7 +523,9 @@ namespace Pixiview.Illust protected void DoLoadIllusts(bool force = false, bool bottom = false) { +#if DEBUG App.DebugPrint($"start loading data, force: {force}"); +#endif illustData = DoLoadIllustData(force); if (illustData == null) { @@ -702,7 +706,9 @@ namespace Pixiview.Illust if (CheckRefresh()) { lastRefreshY = y; +#if DEBUG App.DebugPrint("start to load next page"); +#endif StartLoad(true, true); } } diff --git a/Pixiview/Illust/RankingPage.xaml.cs b/Pixiview/Illust/RankingPage.xaml.cs index 8663e4b..9dad8eb 100644 --- a/Pixiview/Illust/RankingPage.xaml.cs +++ b/Pixiview/Illust/RankingPage.xaml.cs @@ -320,7 +320,9 @@ namespace Pixiview.Illust if (nextPage == currentPage + 1) { currentPage = nextPage; +#if DEBUG App.DebugPrint($"loading page {nextPage}"); +#endif return true; } return false; @@ -353,7 +355,9 @@ namespace Pixiview.Illust { // query changed. lastQueryKey = query; +#if DEBUG App.DebugPrint($"query changed: {query}"); +#endif PrepareLoad(); } } diff --git a/Pixiview/Illust/RecommendsPage.xaml.cs b/Pixiview/Illust/RecommendsPage.xaml.cs index 4e4221d..b7f8eb5 100644 --- a/Pixiview/Illust/RecommendsPage.xaml.cs +++ b/Pixiview/Illust/RecommendsPage.xaml.cs @@ -190,7 +190,9 @@ namespace Pixiview.Illust if (UserColumns != columns) { UserColumns = columns; +#if DEBUG App.DebugPrint($"change user columns to {columns}"); +#endif } } diff --git a/Pixiview/Illust/RelatedIllustsPage.xaml.cs b/Pixiview/Illust/RelatedIllustsPage.xaml.cs index b34ce2e..815e4ce 100644 --- a/Pixiview/Illust/RelatedIllustsPage.xaml.cs +++ b/Pixiview/Illust/RelatedIllustsPage.xaml.cs @@ -64,7 +64,9 @@ namespace Pixiview.Illust if (ids.Length == 0 || nextIndex >= illustIds.Length) { // done +#if DEBUG App.DebugPrint($"download completed: {startIndex}"); +#endif startIndex = nextIndex; } } diff --git a/Pixiview/Illust/UserIllustPage.xaml.cs b/Pixiview/Illust/UserIllustPage.xaml.cs index bf7d77e..5f80b9e 100644 --- a/Pixiview/Illust/UserIllustPage.xaml.cs +++ b/Pixiview/Illust/UserIllustPage.xaml.cs @@ -61,7 +61,9 @@ namespace Pixiview.Illust return null; } illustIds = init.body.illusts.Keys.OrderByDescending(i => int.TryParse(i, out int id) ? id : -1).ToArray(); +#if DEBUG App.DebugPrint($"user has ({illustIds.Length}) illusts."); +#endif startIndex = 0; } @@ -75,7 +77,9 @@ namespace Pixiview.Illust if (ids.Length == 0 || nextIndex >= illustIds.Length) { // done +#if DEBUG App.DebugPrint($"download completed: {startIndex}"); +#endif startIndex = nextIndex; } return data; diff --git a/Pixiview/Illust/ViewIllustPage.xaml.cs b/Pixiview/Illust/ViewIllustPage.xaml.cs index 90c43e8..4bab17d 100644 --- a/Pixiview/Illust/ViewIllustPage.xaml.cs +++ b/Pixiview/Illust/ViewIllustPage.xaml.cs @@ -353,7 +353,9 @@ namespace Pixiview.Illust var reload = false; if (pages.body.Length > items.Length) { +#if DEBUG App.DebugPrint($"local page count ({items.Length}) is not equals the remote one ({pages.body.Length})"); +#endif var tmp = new IllustDetailItem[pages.body.Length]; items.CopyTo(items, 0); #if __IOS__ @@ -430,7 +432,9 @@ namespace Pixiview.Illust { if (item.Loading || item.Image != null) { +#if DEBUG App.DebugPrint($"skipped, loading or already loaded, index: {index}, loading: {item.Loading}"); +#endif return; } } diff --git a/Pixiview/OptionPage.xaml.cs b/Pixiview/OptionPage.xaml.cs index d7df4e8..127baf3 100644 --- a/Pixiview/OptionPage.xaml.cs +++ b/Pixiview/OptionPage.xaml.cs @@ -102,14 +102,18 @@ namespace Pixiview { Preferences.Set(Configs.IsOnR18Key, r18); Configs.IsOnR18 = r18; +#if DEBUG App.DebugPrint($"r-18 filter: {r18}"); +#endif } if ((int)Configs.SyncFavType != syncType) { Preferences.Set(Configs.SyncFavTypeKey, syncType); Configs.SyncFavType = (SyncType)syncType; +#if DEBUG App.DebugPrint($"favorite sync type changed to {Configs.SyncFavType}"); +#endif } var proxy = Configs.Proxy; @@ -130,7 +134,9 @@ namespace Pixiview if (!string.IsNullOrEmpty(h) && pt > 0) { Configs.Proxy = new System.Net.WebProxy(h, pt); +#if DEBUG App.DebugPrint($"set proxy to: {h}:{pt}"); +#endif } } } @@ -145,7 +151,9 @@ namespace Pixiview if (proxy != null) { Configs.Proxy = null; +#if DEBUG App.DebugPrint("clear proxy"); +#endif } } @@ -162,8 +170,9 @@ namespace Pixiview { session = session.Substring(0, index); Configs.SetUserId(session, true); - +#if DEBUG App.DebugPrint($"cookie changed, user id: {session}"); +#endif } } } diff --git a/Pixiview/UI/AdaptedPage.cs b/Pixiview/UI/AdaptedPage.cs index a65c891..808f708 100644 --- a/Pixiview/UI/AdaptedPage.cs +++ b/Pixiview/UI/AdaptedPage.cs @@ -132,7 +132,9 @@ namespace Pixiview.UI { if (Tap.IsBusy) { +#if DEBUG App.DebugPrint("gesture recognizer is now busy..."); +#endif return; } using (Tap.Start()) diff --git a/Pixiview/Utils/EnvironmentService.cs b/Pixiview/Utils/EnvironmentService.cs index 1bff761..2c3e601 100644 --- a/Pixiview/Utils/EnvironmentService.cs +++ b/Pixiview/Utils/EnvironmentService.cs @@ -109,8 +109,9 @@ namespace Pixiview.Utils { Thread.CurrentThread.CurrentCulture = ci; Thread.CurrentThread.CurrentUICulture = ci; - +#if DEBUG App.DebugPrint($"CurrentCulture set: {ci.Name}"); +#endif } public static CultureInfo GetCurrentCultureInfo() @@ -179,7 +180,9 @@ namespace Pixiview.Utils break; } +#if DEBUG App.DebugPrint($"iOS Language: {iOSLanguage}, .NET Language/Locale: {netLanguage}"); +#endif return netLanguage; } #elif __ANDROID__ @@ -207,7 +210,9 @@ namespace Pixiview.Utils netLanguage = androidLanguage; break; } +#if DEBUG App.DebugPrint($"Android Language: {androidLanguage}, .NET Language/Locale: {netLanguage}"); +#endif return netLanguage; } #endif @@ -232,7 +237,9 @@ namespace Pixiview.Utils break; } +#if DEBUG App.DebugPrint($".NET Fallback Language/Locale: {platCulture.LanguageCode} to {netLanguage} (application-specific)"); +#endif return netLanguage; } diff --git a/Pixiview/Utils/Extensions.cs b/Pixiview/Utils/Extensions.cs index 4782a1f..8702cbe 100644 --- a/Pixiview/Utils/Extensions.cs +++ b/Pixiview/Utils/Extensions.cs @@ -152,7 +152,9 @@ namespace Pixiview.Utils } if (disposed) { +#if DEBUG App.DebugPrint($"parallel task determinate, disposed"); +#endif return; } Thread.Sleep(100); @@ -183,7 +185,9 @@ namespace Pixiview.Utils } }); } +#if DEBUG App.DebugPrint($"parallel task done"); +#endif complete?.Invoke(); } diff --git a/Pixiview/Utils/Stores.cs b/Pixiview/Utils/Stores.cs index 76caf29..ccf1700 100644 --- a/Pixiview/Utils/Stores.cs +++ b/Pixiview/Utils/Stores.cs @@ -16,11 +16,7 @@ namespace Pixiview.Utils public static class Stores { public static readonly string PersonalFolder = Environment.GetFolderPath(Environment.SpecialFolder.Personal); -#if __IOS__ - public static readonly string CacheFolder = Environment.GetFolderPath(Environment.SpecialFolder.InternetCache); -#else public static readonly string CacheFolder = FileSystem.CacheDirectory; -#endif private const string favoriteFile = "favorites.json"; private const string globalFile = "global.json"; @@ -98,14 +94,7 @@ namespace Pixiview.Utils var file = Path.Combine(PersonalFolder, ugoiraFolder, zip, frame); if (File.Exists(file)) { - //try - //{ return file; - //} - //catch (Exception ex) - //{ - // App.DebugError("load.ugoira", $"failed to load ugoira frame: {zip}/{frame}, error: {ex.Message}"); - //} } return null; } @@ -314,7 +303,9 @@ namespace Pixiview.Utils } else { +#if DEBUG App.DebugPrint($"current csrf token: {result.token}"); +#endif Configs.CsrfToken = result.token; } return result; @@ -347,7 +338,9 @@ namespace Pixiview.Utils } else { +#if DEBUG App.DebugPrint($"successs, bookmark id: {result.body.last_bookmark_id}, status: {result.body.stacc_status_id}"); +#endif return result.body.last_bookmark_id; } return null; @@ -381,7 +374,9 @@ namespace Pixiview.Utils App.DebugPrint("failed to delete bookmark, result is null"); return false; } +#if DEBUG App.DebugPrint($"successs, delete bookmark"); +#endif return true; } diff --git a/Pixiview/Utils/Ugoira.cs b/Pixiview/Utils/Ugoira.cs index f648af9..04b67bf 100644 --- a/Pixiview/Utils/Ugoira.cs +++ b/Pixiview/Utils/Ugoira.cs @@ -178,7 +178,9 @@ namespace Pixiview.Utils var url = ugoira.originalSrc; var id = detailItem.Id; var (size, lastModified, client) = HttpUtility.GetUgoiraHeader(url, id); +#if DEBUG App.DebugPrint($"starting download ugoira: {size} bytes, last modified: {lastModified}"); +#endif var data = new byte[size]; @@ -284,7 +286,9 @@ namespace Pixiview.Utils ParallelTask.Start(0, inSegs.Count, 2, i => { var seg = inSegs[i]; +#if DEBUG App.DebugPrint($"start to download segment #{seg.Index}, from {seg.From} to {seg.To} / {size}"); +#endif using (var ms = new MemoryStream(data, (int)seg.From, seg.Count)) { HttpUtility.DownloadUgoiraImage(client, url, id, lastModified, seg.From, seg.To, ms); @@ -321,7 +325,9 @@ namespace Pixiview.Utils } } } +#if DEBUG App.DebugPrint("download over"); +#endif } }