/// <summary> /// Fired when someone wants to show the global content presenter /// </summary> /// <param name="link">What to show</param> public void ShowGlobalContent(RedditContentContainer container) { // We got reddit content, navigate to it! switch (container.Type) { case RedditContentType.Subreddit: Dictionary <string, object> args = new Dictionary <string, object>(); args.Add(PanelManager.NAV_ARGS_SUBREDDIT_NAME, container.Subreddit); m_panelManager.Navigate(typeof(SubredditPanel), container.Subreddit + SortTypes.Hot + SortTimeTypes.Week, args); break; case RedditContentType.Post: Dictionary <string, object> postArgs = new Dictionary <string, object>(); postArgs.Add(PanelManager.NAV_ARGS_SUBREDDIT_NAME, container.Subreddit); postArgs.Add(PanelManager.NAV_ARGS_FORCE_POST_ID, container.Post); m_panelManager.Navigate(typeof(FlipViewPanel), container.Subreddit + SortTypes.Hot + SortTimeTypes.Week + container.Post, postArgs); break; case RedditContentType.Comment: Dictionary <string, object> commentArgs = new Dictionary <string, object>(); commentArgs.Add(PanelManager.NAV_ARGS_SUBREDDIT_NAME, container.Subreddit); commentArgs.Add(PanelManager.NAV_ARGS_FORCE_POST_ID, container.Post); commentArgs.Add(PanelManager.NAV_ARGS_FORCE_COMMENT_ID, container.Comment); m_panelManager.Navigate(typeof(FlipViewPanel), container.Subreddit + SortTypes.Hot + SortTimeTypes.Week + container.Post + container.Comment, commentArgs); break; case RedditContentType.User: Dictionary <string, object> userArgs = new Dictionary <string, object>(); userArgs.Add(PanelManager.NAV_ARGS_USER_NAME, container.User); m_panelManager.Navigate(typeof(UserProfile), container.User, userArgs); break; } }
private void MarkdownText_OnMarkdownLinkTapped(object sender, UniversalMarkdown.OnMarkdownLinkTappedArgs e) { try { // See if what we have is a reddit link RedditContentContainer redditContent = MiscellaneousHelper.TryToFindRedditContentInLink(e.Link); if (redditContent != null && redditContent.Type != RedditContentType.Website) { // If we are opening a reddit link show the content and hide hide the message. App.BaconMan.ShowGlobalContent(redditContent); // Hide the box Close_OnIconTapped(null, null); } else { // If we have a link show it but don't close the message. App.BaconMan.ShowGlobalContent(e.Link); } } catch (Exception ex) { App.BaconMan.TelemetryMan.ReportUnexpectedEvent(this, "MOTDLinkFailedToOpen", ex); App.BaconMan.MessageMan.DebugDia("MOTDLinkFailedToOpen", ex); } }
/// <summary> /// Fired when someone wants to show the global content presenter /// </summary> /// <param name="link">What to show</param> public void ShowGlobalContent(RedditContentContainer container) { // We got reddit content, navigate to it! switch (container.Type) { case RedditContentType.Subreddit: var args = new Dictionary <string, object>(); args.Add(PanelManager.NavArgsSubredditName, container.Subreddit); _panelManager.Navigate(typeof(SubredditPanel), container.Subreddit + SortTypes.Hot + SortTimeTypes.Week, args); break; case RedditContentType.Post: var postArgs = new Dictionary <string, object>(); postArgs.Add(PanelManager.NavArgsSubredditName, container.Subreddit); postArgs.Add(PanelManager.NavArgsForcePostId, container.Post); _panelManager.Navigate(typeof(FlipViewPanel), container.Subreddit + SortTypes.Hot + SortTimeTypes.Week + container.Post, postArgs); break; case RedditContentType.Comment: var commentArgs = new Dictionary <string, object>(); commentArgs.Add(PanelManager.NavArgsSubredditName, container.Subreddit); commentArgs.Add(PanelManager.NavArgsForcePostId, container.Post); commentArgs.Add(PanelManager.NavArgsForceCommentId, container.Comment); _panelManager.Navigate(typeof(FlipViewPanel), container.Subreddit + SortTypes.Hot + SortTimeTypes.Week + container.Post + container.Comment, commentArgs); break; case RedditContentType.User: var userArgs = new Dictionary <string, object>(); userArgs.Add(PanelManager.NavArgsUserName, container.User); _panelManager.Navigate(typeof(UserProfile), container.User, userArgs); break; } }
/// <summary> /// Fired when we should load the content. /// </summary> public async void OnPrepareContent() { // Defer so we give the UI time to work. await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () => { var headerText = ""; var minorText = ""; if (_contentPanelBase.Source.IsSelf) { headerText = "There's no content here!"; minorText = "Scroll down to view the discussion."; } else { _content = MiscellaneousHelper.TryToFindRedditContentInLink(_contentPanelBase.Source.Url); switch (_content.Type) { case RedditContentType.Subreddit: headerText = "This post links to a subreddit"; minorText = $"Tap anywhere to view /r/{_content.Subreddit}"; break; case RedditContentType.Comment: headerText = "This post links to a comment thread"; minorText = "Tap anywhere to view it"; break; case RedditContentType.Post: headerText = "This post links to a reddit post"; minorText = $"Tap anywhere to view it"; break; case RedditContentType.User: headerText = "This post links to a reddit user page"; minorText = $"Tap anywhere to view {_content.User}"; break; case RedditContentType.Website: // This shouldn't happen App.BaconMan.MessageMan.DebugDia("Got website back when prepare on reddit content control"); TelemetryManager.ReportUnexpectedEvent(this, "GotWebsiteOnPrepareRedditContent"); break; default: throw new ArgumentOutOfRangeException(); } } ui_headerText.Text = headerText; ui_minorText.Text = minorText; // Hide loading _contentPanelBase.FireOnLoading(false); }); }
/// <summary> /// Tries to show any link globally. This will intelligently handle the link, it handle anything flip view can /// as well as subreddits. /// </summary> /// <param name="container">Content to be shown.</param> /// <returns>If the content was successfully shown.</returns> public bool ShowGlobalContent(RedditContentContainer container) { if (m_backendActionListener == null) { return(false); } m_backendActionListener.ShowGlobalContent(container); return(true); }
/// <summary> /// Fired when we should load the content. /// </summary> /// <param name="source"></param> public async void OnPrepareContent() { // Defer so we give the UI time to work. await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () => { string headerText = ""; string minorText = ""; if (m_base.Source.IsSelf) { headerText = "There's no content here!"; minorText = "Scroll down to view the discussion."; } else { m_content = MiscellaneousHelper.TryToFindRedditContentInLink(m_base.Source.Url); switch (m_content.Type) { case RedditContentType.Subreddit: headerText = "This post links to a subreddit"; minorText = $"Tap anywhere to view /r/{m_content.Subreddit}"; break; case RedditContentType.Comment: headerText = "This post links to a comment thread"; minorText = "Tap anywhere to view it"; break; case RedditContentType.Post: headerText = "This post links to a reddit post"; minorText = $"Tap anywhere to view it"; break; case RedditContentType.User: headerText = "This post links to a reddit user page"; minorText = $"Tap anywhere to view {m_content.User}"; break; case RedditContentType.Website: // This shouldn't happen App.BaconMan.MessageMan.DebugDia("Got website back when prepare on reddit content control"); break; } } ui_headerText.Text = headerText; ui_minorText.Text = minorText; // Hide loading m_base.FireOnLoading(false); }); }
/// <summary> /// Fired when someone wants to show the global content presenter /// </summary> /// <param name="link">What to show</param> public void ShowGlobalContent(string link) { // Validate that the link can't be opened by the subreddit viewer RedditContentContainer container = MiscellaneousHelper.TryToFindRedditContentInLink(link); if (container != null) { ShowGlobalContent(container); } else { ui_globalContentPresenter.ShowContent(link); } }
/// <summary> /// Called by the app when the page is reactivated. /// </summary> /// <param name="arguments"></param> public void OnReActivated(string arguments) { if (arguments != null && arguments.StartsWith(TileManager.c_subredditOpenArgument)) { string subredditDisplayName = arguments.Substring(TileManager.c_subredditOpenArgument.Length); RedditContentContainer content = new RedditContentContainer(); content.Subreddit = subredditDisplayName; content.Type = RedditContentType.Subreddit; App.BaconMan.ShowGlobalContent(content); } else if (arguments != null && arguments.StartsWith(BackgroundMessageUpdater.c_messageInboxOpenArgument)) { m_panelManager.Navigate(typeof(MessageInbox), "MessageInbox"); } }
/// <summary> /// Called when we should show the content /// </summary> /// <param name="post"></param> public void OnPrepareContent(Post post) { string headerText = ""; string minorText = ""; if (post.IsSelf) { headerText = "There's no content here!"; minorText = "Scroll down to view the discussion."; } else { m_content = MiscellaneousHelper.TryToFindRedditContentInLink(post.Url); switch (m_content.Type) { case RedditContentType.Subreddit: headerText = "This post links to a subreddit"; minorText = $"Tap anywhere to view /r/{m_content.Subreddit}"; break; case RedditContentType.Comment: headerText = "This post links to a comment thread"; minorText = "Tap anywhere to view it"; break; case RedditContentType.Post: headerText = "This post links to a reddit post"; minorText = $"Tap anywhere to view it"; break; case RedditContentType.Website: // This shouldn't happen App.BaconMan.MessageMan.DebugDia("Got website back when prepare on reddit content control"); App.BaconMan.TelemetryMan.ReportUnExpectedEvent(this, "GotWebsiteOnPrepareRedditContent"); break; } } ui_headerText.Text = headerText; ui_minorText.Text = minorText; }
/// <summary> /// Fired when someone wants to show the global content presenter /// </summary> /// <param name="link">What to show</param> public async void ShowGlobalContent(string link) { // Validate that the link can't be opened by the subreddit viewer RedditContentContainer container = MiscellaneousHelper.TryToFindRedditContentInLink(link); // If this is our special rate link, show rate and review. if (!String.IsNullOrWhiteSpace(link) && link.ToLower().Equals("ratebaconit")) { // Open the store await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { try { await Windows.System.Launcher.LaunchUriAsync(new Uri("ms-windows-store://review/?ProductId=9wzdncrfj0bc")); } catch (Exception) { } }); // Show a dialog. This will only work on devices that can show many windows. // So also set the time and if we restore fast enough we will show the dialog also App.BaconMan.MessageMan.ShowMessageSimple("Thanks ❤", "Thank you for reviewing Baconit, we really appreciate your support of the app!"); m_reviewLeaveTime = DateTime.Now; return; } // Make sure we got a response and it isn't a website if (container != null && container.Type != RedditContentType.Website) { ShowGlobalContent(container); } else { if (container != null && container.Type == RedditContentType.Website) { // We have a link from the reddit presenter, overwrite the link link = container.Website; } ui_globalContentPresenter.ShowContent(link); } }
/// <summary> /// Fired when someone wants to show the global content presenter /// </summary> /// <param name="link">What to show</param> public void ShowGlobalContent(string link) { // Validate that the link can't be opened by the subreddit viewer RedditContentContainer container = MiscellaneousHelper.TryToFindRedditContentInLink(link); // Make sure we got a response and it isn't a website if (container != null && container.Type != RedditContentType.Website) { ShowGlobalContent(container); } else { if (container != null && container.Type == RedditContentType.Website) { // We have a link from the reddit presenter, overwrite the link link = container.Website; } ui_globalContentPresenter.ShowContent(link); } }
/// <summary> /// Called by the host when it queries if we can handle a post. /// </summary> /// <param name="post"></param> /// <returns></returns> static public bool CanHandlePost(ContentPanelSource source) { // If this is a self post with no text we will handle this. if (source.IsSelf && String.IsNullOrWhiteSpace(source.SelfText)) { return(true); } // Check if this is a reddit content post, if so this is us if (!String.IsNullOrWhiteSpace(source.Url)) { // Check the content RedditContentContainer container = MiscellaneousHelper.TryToFindRedditContentInLink(source.Url); // If we got a container and it isn't a web site return it. if (container != null && container.Type != RedditContentType.Website) { return(true); } } return(false); }
/// <summary> /// Called when we should show the content /// </summary> /// <param name="post"></param> public void OnPrepareContent(Post post) { string headerText = ""; string minorText = ""; if (post.IsSelf) { headerText = "There's no content here!"; minorText = "Scroll down to view the discussion."; } else { m_content = MiscellaneousHelper.TryToFindRedditContentInLink(post.Url); switch (m_content.Type) { case RedditContentType.Subreddit: headerText = "This post links to a subreddit"; minorText = $"Tap anywhere to view /r/{m_content.Subreddit}"; break; case RedditContentType.Comment: headerText = "This post links to a comment thread"; minorText = "Tap anywhere to view it"; break; case RedditContentType.Post: headerText = "This post links to a reddit post"; minorText = $"Tap anywhere to view it"; break; } } ui_headerText.Text = headerText; ui_minorText.Text = minorText; }
/// <summary> /// Fired when we should destroy our content. /// </summary> public void OnDestroyContent() { m_content = null; }