public override void PerformAction(string command, string[] arguments) { base.PerformAction(command, arguments); switch (command) { // is this a goto command? case PrivateGeneralConfig.App_URL_Commands_Goto: { // make sure the argument is for us if (arguments[0] == Command_Keyword( ) && arguments.Length > 1) { // check for groupfinder, because we support that one. if (PrivateGeneralConfig.App_URL_Page_GroupFinder == arguments[1]) { PresentFragment(GroupFinder, true); } else { List <ConnectLink> engagedEntries = ConnectLink.BuildGetEngagedList( ); ConnectLink connectLink = engagedEntries.Where(e => e.Command_Keyword == arguments[1]).SingleOrDefault( ); if (connectLink != null) { // now go to the requested URL TaskWebFragment.HandleUrl(false, true, connectLink.Url, this, WebFragment); } } } break; } } }
public NewsTask(NavbarFragment navFragment) : base(navFragment) { // create our fragments (which are basically equivalent to iOS ViewControllers) // Note: Fragment Tags must be the fully qualified name of the class, including its namespaces. // This is how Android will find it when searching. MainPage = navFragment.FragmentManager.FindFragmentByTag("Droid.Tasks.News.NewsPrimaryFragment") as NewsPrimaryFragment; if (MainPage == null) { MainPage = new NewsPrimaryFragment(); } MainPage.ParentTask = this; DetailsPage = navFragment.FragmentManager.FindFragmentByTag("Droid.Tasks.News.NewsDetailsFragment") as NewsDetailsFragment; if (DetailsPage == null) { DetailsPage = new NewsDetailsFragment(); } DetailsPage.ParentTask = this; WebFragment = new TaskWebFragment( ); WebFragment.ParentTask = this; // setup a list we can use to cache the news, so should it update we don't use the wrong set. News = new List <RockNews>(); }
public ConnectTask( NavbarFragment navFragment ) : base( navFragment ) { // create our fragments (which are basically equivalent to iOS ViewControllers) MainPage = navFragment.FragmentManager.FindFragmentByTag( "Droid.ConnectPrimaryFragment" ) as ConnectPrimaryFragment; if ( MainPage == null ) { MainPage = new ConnectPrimaryFragment(); } MainPage.ParentTask = this; GroupFinder = navFragment.FragmentManager.FindFragmentByTag( "Droid.GroupFinderFragment" ) as GroupFinderFragment; if ( GroupFinder == null ) { GroupFinder = new GroupFinderFragment(); } GroupFinder.ParentTask = this; JoinGroup = navFragment.FragmentManager.FindFragmentByTag( "Droid.JoinGroupFragment" ) as JoinGroupFragment; if ( JoinGroup == null ) { JoinGroup = new JoinGroupFragment(); } JoinGroup.ParentTask = this; WebFragment = new TaskWebFragment( ); WebFragment.ParentTask = this; }
public override void OnClick(Fragment source, int buttonId, object context) { base.OnClick(source, buttonId, context); // only handle input if the springboard is closed if (NavbarFragment.ShouldTaskAllowInput( )) { // decide what to do. if (source == MainPage) { ConnectLink linkEntry = (ConnectLink)context; // group finder is the only connect link that doesn't use an embedded webView. if (linkEntry.Title == ConnectStrings.Main_Connect_GroupFinder) { // launch group finder (and have it auto-show the search) GroupFinder.ShowSearchOnAppear = true; // if we're logged in, give it a starting address if (MobileApp.Shared.Network.RockMobileUser.Instance.LoggedIn == true && MobileApp.Shared.Network.RockMobileUser.Instance.HasFullAddress( )) { GroupFinder.SetSearchAddress(MobileApp.Shared.Network.RockMobileUser.Instance.Street1( ), MobileApp.Shared.Network.RockMobileUser.Instance.City( ), MobileApp.Shared.Network.RockMobileUser.Instance.State( ), MobileApp.Shared.Network.RockMobileUser.Instance.Zip( )); } PresentFragment(GroupFinder, true); } else { // launch the ConnectWebFragment. TaskWebFragment.HandleUrl(false, true, linkEntry.Url, this, WebFragment); } } else if (source == GroupFinder) { // turn off auto-show search so that if the user presses 'back', we don't pop it up again. GroupFinder.ShowSearchOnAppear = false; MobileAppApi.GroupSearchResult entry = (MobileAppApi.GroupSearchResult)context; GroupInfo.GroupEntry = entry; PresentFragment(GroupInfo, true); } else if (source == GroupInfo) { MobileAppApi.GroupSearchResult entry = (MobileAppApi.GroupSearchResult)context; JoinGroup.GroupTitle = entry.Name; JoinGroup.Distance = string.Format("{0:##.0} {1}", entry.DistanceFromSource, ConnectStrings.GroupFinder_MilesSuffix); JoinGroup.GroupID = entry.Id; JoinGroup.MeetingTime = string.IsNullOrEmpty(entry.MeetingTime) == false ? entry.MeetingTime : ConnectStrings.GroupFinder_ContactForTime; PresentFragment(JoinGroup, true); } } }
public AboutTask(NavbarFragment navFragment) : base(navFragment) { // create our fragments (which are basically equivalent to iOS ViewControllers) // Note: Fragment Tags must be the fully qualified name of the class, including its namespaces. // This is how Android will find it when searching. MainPage = navFragment.FragmentManager.FindFragmentByTag("Droid.Tasks.TaskWebFragment") as TaskWebFragment; if (MainPage == null) { MainPage = new TaskWebFragment( ); } MainPage.ParentTask = this; }
public NotesTask(NavbarFragment navFragment) : base(navFragment) { // create our fragments (which are basically equivalent to iOS ViewControllers) // Note: Fragment Tags must be the fully qualified name of the class, including its namespaces. // This is how Android will find it when searching. MainPage = navFragment.FragmentManager.FindFragmentByTag("Droid.Tasks.Notes.NotesPrimaryFragment") as NotesPrimaryFragment; if (MainPage == null) { MainPage = new NotesPrimaryFragment(); } MainPage.ParentTask = this; DetailsPage = navFragment.FragmentManager.FindFragmentByTag("Droid.Tasks.Notes.NotesDetailsFragment") as NotesDetailsFragment; if (DetailsPage == null) { DetailsPage = new NotesDetailsFragment(); } DetailsPage.ParentTask = this; NotesPage = navFragment.FragmentManager.FindFragmentByTag("Droid.Tasks.Notes.NotesFragment") as NotesFragment; if (NotesPage == null) { NotesPage = new NotesFragment( ); } NotesPage.ParentTask = this; WatchPage = navFragment.FragmentManager.FindFragmentByTag("Droid.Tasks.Notes.NotesWatchFragment") as NotesWatchFragment; if (WatchPage == null) { WatchPage = new NotesWatchFragment(); } WatchPage.ParentTask = this; ListenPage = navFragment.FragmentManager.FindFragmentByTag("Droid.Tasks.Notes.NotesListenFragment") as NotesListenFragment; if (ListenPage == null) { ListenPage = new NotesListenFragment(); } ListenPage.ParentTask = this; DiscGuidePage = navFragment.FragmentManager.FindFragmentByTag("Droid.Tasks.Notes.NotesDiscGuideFragment") as NotesDiscGuideFragment; if (DiscGuidePage == null) { DiscGuidePage = new NotesDiscGuideFragment(); } DiscGuidePage.ParentTask = this; WebViewPage = new TaskWebFragment( ); WebViewPage.ParentTask = this; }
public override void Activate(bool forResume) { base.Activate(forResume); if (forResume == false) { string fullUrl = Rock.Mobile.Util.Strings.Parsers.AddParamToURL(AboutConfig.Url, string.Format(PrivateGeneralConfig.RockCampusContext, MobileApp.Shared.Network.RockMobileUser.Instance.GetRelevantCampus( ))); TaskWebFragment.HandleUrl(false, true, fullUrl, this, MainPage); } }
/// <summary> /// Utility function to simplify handling a URL with or without an impersonation token, in an embedded webView OR external browser. /// </summary> /// <param name="launchesExternalBrowser">If set to <c>true</c> launches external browser.</param> /// <param name="usesImpersonationToken">If set to <c>true</c> uses impersonation token.</param> /// <param name="url">URL.</param> /// <param name="currTask">Curr task.</param> /// <param name="webFragment">Web fragment.</param> public static void HandleUrl( bool launchesExternalBrowser, bool usesImpersonationToken, string url, Task currTask, TaskWebFragment webFragment ) { // are we launching a seperate browser? if ( launchesExternalBrowser == true ) { // do they also want the impersonation token? if ( usesImpersonationToken ) { // try to get it MobileAppApi.TryGetImpersonationToken( delegate( string impersonationToken ) { // append the mobile platform string fullUrl = Rock.Mobile.Util.Strings.Parsers.AddParamToURL( url, PrivateGeneralConfig.MobilePlatform ); // append the campus (this is part of their identity) fullUrl = Rock.Mobile.Util.Strings.Parsers.AddParamToURL( fullUrl, string.Format( PrivateGeneralConfig.RockCampusContext, App.Shared.Network.RockMobileUser.Instance.GetRelevantCampus( ) ) ); // if we got the token, append it if( string.IsNullOrEmpty( impersonationToken ) == false ) { fullUrl += "&" + impersonationToken; } // now fire off an intent. Android.Net.Uri uri = Android.Net.Uri.Parse( fullUrl ); var intent = new Intent( Intent.ActionView, uri ); ((Activity)Rock.Mobile.PlatformSpecific.Android.Core.Context).StartActivity( intent ); } ); } else { // pretty easy, just fire off an intent. Android.Net.Uri uri = Android.Net.Uri.Parse( url ); var intent = new Intent( Intent.ActionView, uri ); ((Activity)Rock.Mobile.PlatformSpecific.Android.Core.Context).StartActivity( intent ); } } else { // otherwise we're not, so its simpler webFragment.DisplayUrl( url, usesImpersonationToken ); currTask.PresentFragment( webFragment, true ); } }
public ConnectTask( NavbarFragment navFragment ) : base(navFragment) { // create our fragments (which are basically equivalent to iOS ViewControllers) MainPage = new ConnectPrimaryFragment( ); MainPage.ParentTask = this; GroupFinder = new GroupFinderFragment( ); GroupFinder.ParentTask = this; JoinGroup = new JoinGroupFragment( ); JoinGroup.ParentTask = this; WebFragment = new TaskWebFragment( ); WebFragment.ParentTask = this; }
public NewsTask( NavbarFragment navFragment ) : base(navFragment) { // create our fragments (which are basically equivalent to iOS ViewControllers) MainPage = new NewsPrimaryFragment( ); MainPage.ParentTask = this; DetailsPage = new NewsDetailsFragment( ); DetailsPage.ParentTask = this; WebFragment = new TaskWebFragment( ); WebFragment.ParentTask = this; // setup a list we can use to cache the news, so should it update we don't use the wrong set. News = new List<RockNews>(); }
public NotesTask( NavbarFragment navFragment ) : base( navFragment ) { // create our fragments (which are basically equivalent to iOS ViewControllers) MainPage = navFragment.FragmentManager.FindFragmentByTag( "Droid.NotesPrimaryFragment" ) as NotesPrimaryFragment; if ( MainPage == null ) { MainPage = new NotesPrimaryFragment(); } MainPage.ParentTask = this; DetailsPage = navFragment.FragmentManager.FindFragmentByTag( "Droid.NotesDetailsFragment" ) as NotesDetailsFragment; if ( DetailsPage == null ) { DetailsPage = new NotesDetailsFragment(); } DetailsPage.ParentTask = this; NotesPage = navFragment.FragmentManager.FindFragmentByTag( "Droid.NotesFragment" ) as NotesFragment; if ( NotesPage == null ) { NotesPage = new NotesFragment( ); } NotesPage.ParentTask = this; WatchPage = navFragment.FragmentManager.FindFragmentByTag( "Droid.NotesWatchFragment" ) as NotesWatchFragment; if ( WatchPage == null ) { WatchPage = new NotesWatchFragment(); } WatchPage.ParentTask = this; ListenPage = navFragment.FragmentManager.FindFragmentByTag( "Droid.NotesListenFragment" ) as NotesListenFragment; if ( ListenPage == null ) { ListenPage = new NotesListenFragment(); } ListenPage.ParentTask = this; WebViewPage = new TaskWebFragment( ); WebViewPage.ParentTask = this; }
public NotesTask( NavbarFragment navFragment ) : base(navFragment) { // create our fragments (which are basically equivalent to iOS ViewControllers) MainPage = new NotesPrimaryFragment( ); MainPage.ParentTask = this; DetailsPage = new NotesDetailsFragment( ); DetailsPage.ParentTask = this; NotesPage = new NotesFragment( ); NotesPage.ParentTask = this; WatchPage = new NotesWatchFragment( ); WatchPage.ParentTask = this; ListenPage = new NotesListenFragment( ); ListenPage.ParentTask = this; WebViewPage = new TaskWebFragment( ); WebViewPage.ParentTask = this; }
public ConnectTask(NavbarFragment navFragment) : base(navFragment) { // create our fragments (which are basically equivalent to iOS ViewControllers) // Note: Fragment Tags must be the fully qualified name of the class, including its namespaces. // This is how Android will find it when searching. MainPage = navFragment.FragmentManager.FindFragmentByTag("Droid.Tasks.Connect.ConnectPrimaryFragment") as ConnectPrimaryFragment; if (MainPage == null) { MainPage = new ConnectPrimaryFragment(); } MainPage.ParentTask = this; GroupFinder = navFragment.FragmentManager.FindFragmentByTag("Droid.Tasks.Connect.GroupFinderFragment") as GroupFinderFragment; if (GroupFinder == null) { GroupFinder = new GroupFinderFragment(); } GroupFinder.ParentTask = this; GroupInfo = navFragment.FragmentManager.FindFragmentByTag("Droid.Tasks.Connect.GroupInfoFragment") as GroupInfoFragment; if (GroupInfo == null) { GroupInfo = new GroupInfoFragment(); } GroupInfo.ParentTask = this; JoinGroup = navFragment.FragmentManager.FindFragmentByTag("Droid.Tasks.Connect.JoinGroupFragment") as JoinGroupFragment; if (JoinGroup == null) { JoinGroup = new JoinGroupFragment(); } JoinGroup.ParentTask = this; WebFragment = new TaskWebFragment( ); WebFragment.ParentTask = this; }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (container == null) { // Currently in a layout without a container, so no reason to create our view. return(null); } View view = inflater.Inflate(Resource.Layout.Login, container, false); view.SetBackgroundColor(Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BackgroundColor)); view.SetOnTouchListener(this); RelativeLayout navBar = view.FindViewById <RelativeLayout>(Resource.Id.navbar_relative_layout); navBar.SetBackgroundColor(Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BackgroundColor)); RectangleF bounds = new System.Drawing.RectangleF(0, 0, NavbarFragment.GetFullDisplayWidth( ), this.Resources.DisplayMetrics.HeightPixels); BlockerView = new UIBlockerView(view, bounds); LoginResultLayer = view.FindViewById <View>(Resource.Id.result_background); ControlStyling.StyleBGLayer(LoginResultLayer); LoginResultLayer.Alpha = 0.0f; LoginButton = view.FindViewById <Button>(Resource.Id.loginButton); ControlStyling.StyleButton(LoginButton, LoginStrings.LoginButton, ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize); LoginButton.Click += (object sender, EventArgs e) => { TryRockBind( ); }; CancelButton = view.FindViewById <Button>(Resource.Id.cancelButton); ControlStyling.StyleButton(CancelButton, GeneralStrings.Cancel, ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize); CancelButton.Background = null; CancelButton.Click += (object sender, EventArgs e) => { SpringboardParent.ModalFragmentDone(null); }; TextView additionalOptions = view.FindViewById <TextView>(Resource.Id.additionalOptions); ControlStyling.StyleUILabel(additionalOptions, ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize); additionalOptions.Text = LoginStrings.AdditionalOptions; TextView orTextView = view.FindViewById <TextView>(Resource.Id.orTextView); ControlStyling.StyleUILabel(orTextView, ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize); orTextView.Text = LoginStrings.OrString; RegisterButton = view.FindViewById <Button>(Resource.Id.registerButton); ControlStyling.StyleButton(RegisterButton, LoginStrings.RegisterButton, ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize); RegisterButton.Click += (object sender, EventArgs e) => { SpringboardParent.ModalFragmentDone(null); SpringboardParent.RegisterNewUser( ); }; ForgotPasswordButton = view.FindViewById <Button>(Resource.Id.forgotPasswordButton); ControlStyling.StyleButton(ForgotPasswordButton, LoginStrings.ForgotPasswordButton, ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize); ForgotPasswordButton.Click += (object sender, EventArgs e) => { TaskWebFragment.HandleUrl(true, true, LoginConfig.ForgotPassword_Url, null, null); }; // get the username field and background UsernameLayer = view.FindViewById <View>(Resource.Id.login_background); ControlStyling.StyleBGLayer(UsernameLayer); UsernameField = view.FindViewById <EditText>(Resource.Id.usernameText); UserNameBGColor = ControlStylingConfig.BG_Layer_Color; ControlStyling.StyleTextField(UsernameField, LoginStrings.UsernamePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize); View borderView = UsernameLayer.FindViewById <View>(Resource.Id.middle_border); borderView.SetBackgroundColor(Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BG_Layer_BorderColor)); // get the password field and background PasswordLayer = view.FindViewById <View>(Resource.Id.password_background); ControlStyling.StyleBGLayer(PasswordLayer); PasswordField = view.FindViewById <EditText>(Resource.Id.passwordText); PasswordBGColor = ControlStylingConfig.BG_Layer_Color; ControlStyling.StyleTextField(PasswordField, LoginStrings.PasswordPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize); LoginResultLabel = view.FindViewById <TextView>(Resource.Id.loginResult); ControlStyling.StyleUILabel(LoginResultLabel, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize); // Setup the facebook button FacebookButton = view.FindViewById <ImageButton>(Resource.Id.facebookButton); FacebookButton.Background = null; FacebookButton.Click += (object sender, EventArgs e) => { TryFacebookBind( ); }; // invoke a webview WebLayout = new WebLayout(Rock.Mobile.PlatformSpecific.Android.Core.Context); WebLayout.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); WebLayout.SetBackgroundColor(Android.Graphics.Color.Black); return(view); }
public override void OnClick(Android.App.Fragment source, int buttonId, object context = null) { // only handle input if the springboard is closed if (NavbarFragment.ShouldTaskAllowInput( )) { // decide what to do. if (source == MainPage) { // on the main page, if the buttonId was -1, the user tapped the header, // so we need to either go to the Watch or Take Notes page if (buttonId == -1) { // the context is the button they clicked (watch or take notes) int buttonChoice = (int)context; // 0 is listen if (buttonChoice == 0) { ListenPage.MediaUrl = MainPage.SeriesEntries[0].Series.Messages[0].AudioUrl; ListenPage.ShareUrl = MainPage.SeriesEntries[0].Series.Messages[0].ShareUrl; ListenPage.Name = MainPage.SeriesEntries[0].Series.Messages[0].Name; PresentFragment(ListenPage, true); } // 1 is watch else if (buttonChoice == 1) { WatchPage.MediaUrl = MainPage.SeriesEntries[0].Series.Messages[0].WatchUrl; WatchPage.ShareUrl = MainPage.SeriesEntries[0].Series.Messages[0].ShareUrl; WatchPage.Name = MainPage.SeriesEntries[0].Series.Messages[0].Name; PresentFragment(WatchPage, true); } // 2 is read else if (buttonChoice == 2) { NotesPage.NoteUrl = MainPage.SeriesEntries[0].Series.Messages[0].NoteUrl; NotesPage.NoteName = MainPage.SeriesEntries[0].Series.Messages[0].Name; PresentFragment(NotesPage, true); } // 3 is discussion guide else if (buttonChoice == 3) { DiscGuidePage.DiscGuideURL = MainPage.SeriesEntries[0].Series.Messages[0].DiscussionGuideUrl; PresentFragment(DiscGuidePage, true); } } else { DetailsPage.Series = MainPage.SeriesEntries[buttonId].Series; PresentFragment(DetailsPage, true); } } else if (source == DetailsPage) { // the context is the button they clicked (watch or take notes) int buttonChoice = (int)context; // 0 is listen if (buttonChoice == 0) { ListenPage.MediaUrl = DetailsPage.Series.Messages[buttonId].AudioUrl; ListenPage.ShareUrl = DetailsPage.Series.Messages[buttonId].ShareUrl; ListenPage.Name = DetailsPage.Series.Messages[buttonId].Name; PresentFragment(ListenPage, true); } // 1 is watch else if (buttonChoice == 1) { WatchPage.MediaUrl = DetailsPage.Series.Messages[buttonId].WatchUrl; WatchPage.ShareUrl = DetailsPage.Series.Messages[buttonId].ShareUrl; WatchPage.Name = DetailsPage.Series.Messages[buttonId].Name; PresentFragment(WatchPage, true); } // 2 is read else if (buttonChoice == 2) { NotesPage.NoteUrl = DetailsPage.Series.Messages[buttonId].NoteUrl; NotesPage.NoteName = DetailsPage.Series.Messages[buttonId].Name; PresentFragment(NotesPage, true); } // 3 is discussion guide else if (buttonChoice == 3) { DiscGuidePage.DiscGuideURL = DetailsPage.Series.Messages[buttonId].DiscussionGuideUrl; PresentFragment(DiscGuidePage, true); } } else if (source == NotesPage) { NotesFragment.UrlClickParams clickParams = (NotesFragment.UrlClickParams)context; if (Springboard.IsAppURL(clickParams.Url) == true) { NavbarFragment.HandleAppURL(clickParams.Url); } else if (App.Shared.BibleRenderer.IsBiblePrefix(clickParams.Url)) { BiblePassagePage = new BiblePassageFragment(clickParams.Url); BiblePassagePage.ParentTask = this; PresentFragment(BiblePassagePage, true); } else { // the context is the activeURL to visit. WebViewPage.DisableIdleTimer = true; TaskWebFragment.HandleUrl(clickParams.UseExternalBrowser, clickParams.UseImpersonationToken, clickParams.Url, this, WebViewPage); } } else if (source == DiscGuidePage) { // Discussion Guide page only has one button, so if it was clicked, // let them view the guide. WebViewPage.DisableIdleTimer = true; TaskWebFragment.HandleUrl(true, false, DiscGuidePage.DiscGuideURL, this, WebViewPage); } } }
public AboutTask( NavbarFragment navFragment ) : base( navFragment ) { // create our fragments (which are basically equivalent to iOS ViewControllers) MainPage = new TaskWebFragment( ); MainPage.ParentTask = this; }
public override void OnClick(Android.App.Fragment source, int buttonId, object context = null) { // only handle input if the springboard is closed if (NavbarFragment.ShouldTaskAllowInput( )) { // if the main page had a VALID news item clicked, go to it if (source == MainPage && buttonId < News.Count) { // mark that they tapped this item. NewsAnalytic.Instance.Trigger(NewsAnalytic.Read, MainPage.News[buttonId].News.Title); // either take them to the details page, or skip it and go straight to Learn More. if (MainPage.News[buttonId].News.SkipDetailsPage == true && string.IsNullOrEmpty(MainPage.News[buttonId].News.ReferenceURL) == false) { if (Springboard.IsAppURL(MainPage.News[buttonId].News.ReferenceURL) == true) { NavbarFragment.HandleAppURL(MainPage.News[buttonId].News.ReferenceURL); } else { // copy the news item's relevant members. That way, if we're running in debug, // and they want to override the news item, we can do that below. string newsUrl = MainPage.News[buttonId].News.ReferenceURL; bool newsImpersonation = MainPage.News[buttonId].News.IncludeImpersonationToken; bool newsExternalBrowser = MainPage.News[buttonId].News.ReferenceUrlLaunchesBrowser; // If we're running a debug build, see if we should override the news #if DEBUG if (DebugConfig.News_Override_Item == true) { newsUrl = DebugConfig.News_Override_ReferenceURL; newsImpersonation = DebugConfig.News_Override_IncludeImpersonationToken; newsExternalBrowser = DebugConfig.News_Override_ReferenceUrlLaunchesBrowser; } #endif TaskWebFragment.HandleUrl(newsExternalBrowser, newsImpersonation, newsUrl, this, WebFragment); } } else { // store the news index they chose so we can manage the 'tap details' page. DetailsPage.SetNewsInfo(MainPage.News[buttonId].News.Title, MainPage.News[buttonId].News.Description, MainPage.News[buttonId].News.GetDeveloperInfo( ), MainPage.News[buttonId].News.ReferenceURL, MainPage.News[buttonId].News.ReferenceUrlLaunchesBrowser, MainPage.News[buttonId].News.IncludeImpersonationToken, MainPage.News[buttonId].News.ImageName, MainPage.News[buttonId].News.ImageURL); PresentFragment(DetailsPage, true); } } else if (source == DetailsPage) { // otherwise visit the reference URL if (buttonId == Resource.Id.news_details_launch_url || buttonId == Resource.Id.news_details_header_image_button) { // if this is an app url, handle it internally if (Springboard.IsAppURL(DetailsPage.ReferenceURL) == true) { NavbarFragment.HandleAppURL(DetailsPage.ReferenceURL); } else { // copy the news item's relevant members. That way, if we're running in debug, // and they want to override the news item, we can do that below. string newsUrl = DetailsPage.ReferenceURL; bool newsImpersonation = DetailsPage.IncludeImpersonationToken; bool newsExternalBrowser = DetailsPage.ReferenceURLLaunchesBrowser; // If we're running a debug build, see if we should override the news #if DEBUG if (DebugConfig.News_Override_Item == true) { newsUrl = DebugConfig.News_Override_ReferenceURL; newsImpersonation = DebugConfig.News_Override_IncludeImpersonationToken; newsExternalBrowser = DebugConfig.News_Override_ReferenceUrlLaunchesBrowser; } #endif TaskWebFragment.HandleUrl(newsExternalBrowser, newsImpersonation, newsUrl, this, WebFragment); } } } } }
/// <summary> /// Utility function to simplify handling a URL with or without an impersonation token, in an embedded webView OR external browser. /// </summary> public static void HandleUrl(bool launchesExternalBrowser, bool usesImpersonationToken, string url, Task currTask, TaskWebFragment webFragment) { // guard against malformed URLs if (url.StartsWith("http", StringComparison.InvariantCultureIgnoreCase) == true) { // run the url through our processor to see if it needs to be manipulated string processedUrl = Rock.Mobile.Util.URL.Override.ProcessURLOverrides(url); // see if it's external if (processedUrl.StartsWith(PrivateGeneralConfig.ExternalUrlToken, StringComparison.InvariantCultureIgnoreCase)) { // strip off the PrivateGeneralConfig.ExternalUrlToken and forward it processedUrl = processedUrl.Substring(PrivateGeneralConfig.ExternalUrlToken.Length); // and flag that we should launch externally, so that the rest of the function runs as normal launchesExternalBrowser = true; } // are we launching a seperate browser? if (launchesExternalBrowser == true) { // do they also want the impersonation token? if (usesImpersonationToken) { // try to get it MobileAppApi.TryGetImpersonationToken( delegate(string impersonationToken) { // append the mobile platform string fullUrl = Rock.Mobile.Util.Strings.Parsers.AddParamToURL(processedUrl, PrivateGeneralConfig.MobilePlatform); // if we got the token, append it if (string.IsNullOrEmpty(impersonationToken) == false) { fullUrl += "&" + impersonationToken; } // now fire off an intent. Android.Net.Uri uri = Android.Net.Uri.Parse(fullUrl); var intent = new Intent(Intent.ActionView, uri); ((Activity)Rock.Mobile.PlatformSpecific.Android.Core.Context).StartActivity(intent); }); } else { // pretty easy, just fire off an intent. Android.Net.Uri uri = Android.Net.Uri.Parse(processedUrl); var intent = new Intent(Intent.ActionView, uri); ((Activity)Rock.Mobile.PlatformSpecific.Android.Core.Context).StartActivity(intent); } } else { // otherwise we're not, so its simpler webFragment.DisplayUrl(processedUrl, usesImpersonationToken); currTask.PresentFragment(webFragment, true); } } }