private async Task <string> NavigationInterceptOpportunity(string targetUrl) { if (targetUrl != null) { var navArgs = MalLinkParser.GetNavigationParametersForUrl(targetUrl); if (navArgs != null) { var artArg = ViewModel.PrevWorkMode == ArticlePageWorkMode.Articles ? MalArticlesPageNavigationArgs.Articles : MalArticlesPageNavigationArgs.News; artArg.NewsId = _currentId; if (navArgs.Item1 != PageIndex.PageAnimeDetails) { ViewModelLocator.NavMgr.RegisterBackNav(PageIndex.PageArticles, artArg); } else { var arg = navArgs.Item2 as AnimeDetailsPageNavigationArgs; arg.Source = PageIndex.PageArticles; arg.PrevPageSetup = artArg; } ViewModelLocator.GeneralMain.Navigate(navArgs.Item1, navArgs.Item2); } else if (Settings.ArticlesLaunchExternalLinks) { ResourceLocator.SystemControlsLauncherService.LaunchUri(new Uri(targetUrl)); } } return(null); }
//private async void ClipboardOnContentChanged(object sender, object o) //{ // DataPackageView dataPackageView = Clipboard.GetContent(); // if (dataPackageView.Contains(StandardDataFormats.Text)) // { // string text = await dataPackageView.GetTextAsync(); // ViewModelLocator.GeneralMain.Navigate(PageIndex.PageSearch, new SearchPageNavigationArgs // { // Anime = !ViewModel.IsMangaBoard, // Query = text.Trim(), // ForceQuery = true, // }); // } //} private void TopicWebView_OnNavigationStarting(WebView sender, WebViewNavigationStartingEventArgs args) { try { if (args.Uri != null) { var uri = args.Uri.Host == string.Empty ? $"https://myanimelist.net" + args.Uri.AbsolutePath : args.ToString(); args.Cancel = true; var navArgs = MalLinkParser.GetNavigationParametersForUrl(uri); if (navArgs != null) { if (!navArgs.Item1.GetAttribute <EnumUtilities.PageIndexEnumMember>().OffPage) { ViewModel.RegisterSelfBackNav(); } ViewModelLocator.GeneralMain.Navigate(navArgs.Item1, navArgs.Item2); } else if (Settings.ArticlesLaunchExternalLinks) { ResourceLocator.SystemControlsLauncherService.LaunchUri(args.Uri); } } } catch (Exception) { args.Cancel = true; } }
private async Task <string> NavigationInterceptOpportunity(string targetUrl) { try { if (targetUrl != null) { var navArgs = MalLinkParser.GetNavigationParametersForUrl(targetUrl); if (navArgs != null) { if (navArgs.Item1 != PageIndex.PageAnimeDetails) { ViewModelLocator.ForumsTopic.RegisterSelfBackNav(); } else { var arg = navArgs.Item2 as AnimeDetailsPageNavigationArgs; arg.Source = PageIndex.PageForumIndex; arg.PrevPageSetup = ViewModelLocator.ForumsTopic.GetSelfBackNavArgs(); } ViewModelLocator.GeneralMain.Navigate(navArgs.Item1, navArgs.Item2); } else if (Settings.ArticlesLaunchExternalLinks) { ResourceLocator.SystemControlsLauncherService.LaunchUri(new Uri(targetUrl)); } } } catch (Exception) { } return(null); }
private void ProcessLaunchArgs(string args, bool startup) { if (!string.IsNullOrWhiteSpace(args)) { Tuple <int, string> navArgs = null; Tuple <PageIndex, object> fullNavArgs = null; if (args.Contains('~')) //from notification -> mark read { var arg = args; var pos = arg.IndexOf('~'); if (pos != -1) { var id = arg.Substring(0, pos); arg = arg.Substring(pos + 1); MalNotificationsQuery.MarkNotifiactionsAsRead(new MalNotification(id)); fullNavArgs = MalLinkParser.GetNavigationParametersForUrl(arg); } else { fullNavArgs = MalLinkParser.GetNavigationParametersForUrl(arg); } } else if (Regex.IsMatch(args, @"[OpenUrl,OpenDetails];.*")) { var options = args.Split(';'); if (args.Contains('|')) //legacy { var detailArgs = options[1].Split('|'); navArgs = new Tuple <int, string>(int.Parse(detailArgs[0]), detailArgs[1]); } else { fullNavArgs = MalLinkParser.GetNavigationParametersForUrl(options[1]); } } else { fullNavArgs = MalLinkParser.GetNavigationParametersForUrl(args); } if (startup) { MainViewModelBase.InitDetailsFull = fullNavArgs; MainViewModelBase.InitDetails = navArgs; } else { if (navArgs != null) { ViewModelLocator.GeneralMain.Navigate(PageIndex.PageAnimeDetails, new AnimeDetailsPageNavigationArgs(navArgs.Item1, navArgs.Item2, null, null)); } if (fullNavArgs != null) { ViewModelLocator.GeneralMain.Navigate(fullNavArgs.Item1, fullNavArgs.Item2); } } } }
private void AboutMeWebView_OnNavigationStarting(WebView sender, WebViewNavigationStartingEventArgs args) { if (args.Uri == null) { return; } args.Cancel = true; var arg = MalLinkParser.GetNavigationParametersForUrl(args.Uri.ToString()); if (arg == null) { ResourceLocator.SystemControlsLauncherService.LaunchUri(args.Uri); } else { if (ViewModelLocator.Mobile || !arg.Item1.GetAttribute <EnumUtilities.PageIndexEnumMember>().OffPage) { ViewModelLocator.NavMgr.RegisterBackNav(PageIndex.PageProfile, _lastArgs); } ViewModelLocator.GeneralMain.Navigate(arg.Item1, arg.Item2); } }
private async Task <string> NavigationInterceptOpportunity(string targetUrl) { if (targetUrl != null) { var navArgs = MalLinkParser.GetNavigationParametersForUrl(targetUrl); if (navArgs != null) { if (navArgs.Item1 != PageIndex.PageAnimeDetails) { ViewModelLocator.NavMgr.RegisterBackNav(PageIndex.PageClubDetails, ViewModel.LastArgs); } else { var arg = navArgs.Item2 as AnimeDetailsPageNavigationArgs; arg.Source = PageIndex.PageClubDetails; arg.PrevPageSetup = ViewModel.LastArgs; } ViewModelLocator.GeneralMain.Navigate(navArgs.Item1, navArgs.Item2); } } return(null); }
protected async void OnLaunchedOrActivated(IActivatedEventArgs e) { ApplicationView.GetForCurrentView().SetPreferredMinSize(new Size(500, 500)); var rootFrame = Window.Current.Content as Frame; Tuple <int, string> navArgs = null; Tuple <PageIndex, object> fullNavArgs = null; var launchArgs = e as LaunchActivatedEventArgs; if (!string.IsNullOrWhiteSpace(launchArgs?.Arguments)) { if (Regex.IsMatch(launchArgs.Arguments, @"[OpenUrl,OpenDetails];.*")) { var options = launchArgs.Arguments.Split(';'); if (options[0] == TileActions.OpenUrl.ToString()) { LaunchUri(options[1]); } else if (launchArgs.Arguments.Contains('|')) //legacy { var detailArgs = options[1].Split('|'); navArgs = new Tuple <int, string>(int.Parse(detailArgs[0]), detailArgs[1]); } else { fullNavArgs = MalLinkParser.GetNavigationParametersForUrl(options[1]); } } else { fullNavArgs = MalLinkParser.GetNavigationParametersForUrl(launchArgs.Arguments); } } else if (e is ProtocolActivatedEventArgs) { fullNavArgs = MalLinkParser.GetNavigationParametersForUrl("https:" + (e as ProtocolActivatedEventArgs).Uri.AbsolutePath); } else { var activationArgs = e as ToastNotificationActivatedEventArgs; if (activationArgs != null) { var arg = activationArgs.Argument; var pos = arg.IndexOf('~'); if (pos != -1) { var id = arg.Substring(0, pos); arg = arg.Substring(pos + 1); MalNotificationsQuery.MarkNotifiactionsAsRead(new MalNotification(id)); } if (arg.Contains(";")) { var options = activationArgs.Argument.Split(';'); if (options[0] == TileActions.OpenUrl.ToString()) { LaunchUri(options[1]); } } else { fullNavArgs = MalLinkParser.GetNavigationParametersForUrl(arg); } } } // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (rootFrame == null) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { //nothing } if (e.PreviousExecutionState == ApplicationExecutionState.NotRunning) //Crashed - we have to remove cached anime list { if (Settings.IsCachingEnabled) { await DataCache.ClearAnimeListData(); //clear all cached users data } } // Place the frame in the current Window Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter if (navArgs != null) { MainViewModelBase.InitDetails = navArgs; } else if (fullNavArgs != null) { MainViewModelBase.InitDetailsFull = fullNavArgs; } rootFrame.Navigate(typeof(MainPage)); } else if (navArgs != null) { ViewModelLocator.GeneralMain.Navigate(PageIndex.PageAnimeDetails, new AnimeDetailsPageNavigationArgs(navArgs.Item1, navArgs.Item2, null, null)); } if (_initialized && fullNavArgs != null) { ViewModelLocator.GeneralMain.Navigate(fullNavArgs.Item1, fullNavArgs.Item2); } // Ensure the current window is active if (_initialized) { return; } InitializationRoutines.InitApp(); NotificationTaskManager.StartNotificationTask(BgTasks.ToastActivation, false); NotificationTaskManager.StartNotificationTask(BgTasks.Notifications, false); NotificationTaskManager.OnNotificationTaskRequested += NotificationTaskManagerOnOnNotificationTaskRequested; ImageCache.PerformScheduledCacheCleanup(); LiveTilesManager.LoadTileCache(); Window.Current.Activate(); RateReminderPopUp.ProcessRatePopUp(); ProcessStatusBar(); ProcessUpdate(); StoreLogoWorkaroundHacker.Hack(); _initialized = true; }
private async void OnLaunchedOrActivated(IActivatedEventArgs e) { var rootFrame = Window.Current.Content as Frame; Tuple <int, string> navArgs = null; Tuple <PageIndex, object> fullNavArgs = null; var launchArgs = e as LaunchActivatedEventArgs; if (!string.IsNullOrWhiteSpace(launchArgs?.Arguments)) { if (Regex.IsMatch(launchArgs.Arguments, @"[OpenUrl,OpenDetails];.*")) { var options = launchArgs.Arguments.Split(';'); if (options[0] == TileActions.OpenUrl.ToString()) { LaunchUri(options[1]); } else if (launchArgs.Arguments.Contains('|')) //legacy { var detailArgs = options[1].Split('|'); navArgs = new Tuple <int, string>(int.Parse(detailArgs[0]), detailArgs[1]); } else { fullNavArgs = MalLinkParser.GetNavigationParametersForUrl(options[1]); } } else { fullNavArgs = MalLinkParser.GetNavigationParametersForUrl(launchArgs.Arguments); } } else if (e is ProtocolActivatedEventArgs) { fullNavArgs = MalLinkParser.GetNavigationParametersForUrl("https:" + (e as ProtocolActivatedEventArgs).Uri.OriginalString.Replace("malclient://", "")); } else { var activationArgs = e as ToastNotificationActivatedEventArgs; if (activationArgs != null) { var arg = activationArgs.Argument; var pos = arg.IndexOf('~'); if (pos != -1) { var id = arg.Substring(0, pos); arg = arg.Substring(pos + 1); await MalNotificationsQuery.MarkNotifiactionsAsRead(new MalNotification(id)); } if (arg.Contains(";")) { var options = activationArgs.Argument.Split(';'); if (options[0] == TileActions.OpenUrl.ToString()) { LaunchUri(options[1]); } } else { fullNavArgs = MalLinkParser.GetNavigationParametersForUrl(arg); } } } // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (rootFrame == null) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { //nothing } // Place the frame in the current Window Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter if (navArgs != null) { MainViewModelBase.InitDetails = navArgs; } else if (fullNavArgs != null) { MainViewModelBase.InitDetailsFull = fullNavArgs; } rootFrame.Navigate(typeof(MainPage)); } else if (navArgs != null) { ViewModelLocator.GeneralMain.Navigate(PageIndex.PageAnimeDetails, new AnimeDetailsPageNavigationArgs(navArgs.Item1, navArgs.Item2, null, null)); } if (_initialized && fullNavArgs != null) { ViewModelLocator.GeneralMain.Navigate(fullNavArgs.Item1, fullNavArgs.Item2); } // Ensure the current window is active if (_initialized) { return; } await InitializationRoutines.InitApp(); NotificationTaskManager.StartNotificationTask(BgTasks.ToastActivation, false); NotificationTaskManager.StartNotificationTask(BgTasks.Notifications, false); NotificationTaskManager.OnNotificationTaskRequested += NotificationTaskManagerOnOnNotificationTaskRequested; LiveTilesManager.LoadTileCache(); ImageCache.PerformScheduledCacheCleanup(); Window.Current.Activate(); RateReminderPopUp.ProcessRatePopUp(); JumpListManager.InitJumpList(); var tb = ApplicationView.GetForCurrentView().TitleBar; bool dark = Settings.SelectedTheme == (int)ApplicationTheme.Dark; if (dark) { tb.ButtonBackgroundColor = Colors.Transparent; tb.ButtonForegroundColor = Colors.White; tb.ButtonHoverBackgroundColor = Color.FromArgb(30, 255, 255, 255); tb.ButtonHoverForegroundColor = Colors.White; tb.ButtonInactiveBackgroundColor = Colors.Transparent; tb.ButtonInactiveForegroundColor = Colors.Gray; tb.ButtonPressedBackgroundColor = Color.FromArgb(80, 255, 255, 255); tb.ButtonPressedForegroundColor = Colors.White; } else { tb.ButtonBackgroundColor = Colors.Transparent; tb.ButtonForegroundColor = Colors.Black; tb.ButtonHoverBackgroundColor = Color.FromArgb(30, 0, 0, 0); tb.ButtonHoverForegroundColor = Colors.Black; tb.ButtonInactiveBackgroundColor = Colors.Transparent; tb.ButtonInactiveForegroundColor = Colors.Gray; tb.ButtonPressedBackgroundColor = Color.FromArgb(80, 0, 0, 0); tb.ButtonPressedForegroundColor = Colors.Black; } ProcessUpdate(); StoreLogoWorkaroundHacker.Hack(); _initialized = true; }