public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // grab our resource file View view = inflater.Inflate(Resource.Layout.Springboard, container, false); // let the springboard elements setup their buttons foreach( SpringboardElement element in Elements ) { element.OnCreateView( view ); element.Button.SetOnTouchListener( this ); } view.SetOnTouchListener( this ); view.SetBackgroundColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Springboard_BackgroundColor ) ); // set the task we wish to have active ActivateElement( Elements[ ActiveElementIndex ] ); // setup our profile pic button, which displays either their profile picture or an icon if they're not logged in / don't have a pic ProfileImageButton = view.FindViewById<Button>( Resource.Id.springboard_profile_image ); ProfileImageButton.Click += (object sender, EventArgs e) => { // if we're logged in, manage their profile pic if( RockMobileUser.Instance.LoggedIn == true ) { ManageProfilePic( ); } else { // otherwise, use it to let them log in StartModalFragment( LoginFragment ); } }; Typeface fontFace = Rock.Mobile.PlatformSpecific.Android.Graphics.FontManager.Instance.GetFont( PrivateControlStylingConfig.Icon_Font_Primary ); ProfileImageButton.SetTypeface( fontFace, TypefaceStyle.Normal ); ProfileImageButton.SetTextSize( Android.Util.ComplexUnitType.Dip, PrivateSpringboardConfig.ProfileSymbolFontSize ); ProfileImageButton.SetTextColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Springboard_InActiveElementTextColor ) ); ProfileImageButton.LayoutParameters.Width = (int)Rock.Mobile.Graphics.Util.UnitToPx( 140 ); ProfileImageButton.LayoutParameters.Height = (int)Rock.Mobile.Graphics.Util.UnitToPx( 140 ); ProfileImageButton.SetBackgroundColor( Color.Transparent ); // create and add a simple circle to border the image RelativeLayout layout = view.FindViewById<RelativeLayout>( Resource.Id.springboard_profile_image_layout ); layout.SetBackgroundColor( Color.Transparent ); CircleView circle = new Rock.Mobile.PlatformSpecific.Android.Graphics.CircleView( Activity.BaseContext ); //note: these are converted from dp to pixels, so don't do it here. circle.StrokeWidth = 4; circle.Color = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Springboard_InActiveElementTextColor ); circle.SetBackgroundColor( Color.Transparent ); circle.LayoutParameters = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent ); ( (RelativeLayout.LayoutParams)circle.LayoutParameters ).AddRule( LayoutRules.CenterInParent ); circle.LayoutParameters.Width = (int)Rock.Mobile.Graphics.Util.UnitToPx( 150 ); circle.LayoutParameters.Height = (int)Rock.Mobile.Graphics.Util.UnitToPx( 150 ); layout.AddView( circle ); // setup our login button LoginProfileButton = view.FindViewById<Button>( Resource.Id.springboard_login_button ); LoginProfileButton.Click += (object sender, EventArgs e) => { // if we're logged in, it'll be the profile one if( RockMobileUser.Instance.LoggedIn == true ) { // Because we aren't syncing RIGHT HERE, Rock data could technically be overwritten. // If WHILE they're running the app, their data is updated in Rock, those changes will // be lost when they submit their profile changes. // But, the odds that Rock data will update WHILE THE APP IS RUNNING, and they then decide to // update their profile without having even backgrounded the app, are extremely low. StartModalFragment( ProfileFragment ); } else { // else it'll be the login one StartModalFragment( LoginFragment ); } }; // setup the textView for rendering either "Tap to Personalize" or "View Profile" ViewProfileLabel = view.FindViewById<TextView>( Resource.Id.view_profile ); ViewProfileLabel.SetTextColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Springboard_InActiveElementTextColor ) ); ViewProfileLabel.SetTypeface( Rock.Mobile.PlatformSpecific.Android.Graphics.FontManager.Instance.GetFont( ControlStylingConfig.Font_Light ), TypefaceStyle.Normal ); ViewProfileLabel.SetTextSize( Android.Util.ComplexUnitType.Dip, ControlStylingConfig.Small_FontSize ); // get the size of the display. We will use this rather than Resources.DeviceManager because this // is absolute and won't change based on orientation Point displaySize = new Point( ); Activity.WindowManager.DefaultDisplay.GetSize( displaySize ); float displayWidth = displaySize.X; float revealPercent = MainActivity.IsLandscapeWide( ) ? PrivatePrimaryNavBarConfig.Landscape_RevealPercentage_Android : PrivatePrimaryNavBarConfig.Portrait_RevealPercentage_Android; // setup the width of the springboard area and campus selector ProfileContainer = view.FindViewById<LinearLayout>( Resource.Id.springboard_profile_image_container ); ProfileContainer.LayoutParameters.Width = (int) ( displayWidth * revealPercent ); // setup the textView for rendering the user's name when they're logged in "Welcome: Jered" ProfilePrefix = view.FindViewById<TextView>( Resource.Id.profile_prefix ); ProfilePrefix.SetTypeface( Rock.Mobile.PlatformSpecific.Android.Graphics.FontManager.Instance.GetFont( ControlStylingConfig.Font_Light ), TypefaceStyle.Normal ); ProfilePrefix.SetTextSize( Android.Util.ComplexUnitType.Dip, ControlStylingConfig.Large_FontSize ); ProfilePrefix.SetTextColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Springboard_InActiveElementTextColor ) ); ProfilePrefix.Text = SpringboardStrings.LoggedIn_Prefix; ProfilePrefix.Measure( 0, 0 ); ProfileName = view.FindViewById<TextView>( Resource.Id.profile_name ); ProfileName.SetTextColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Springboard_InActiveElementTextColor ) ); ProfileName.SetTypeface( Rock.Mobile.PlatformSpecific.Android.Graphics.FontManager.Instance.GetFont( ControlStylingConfig.Font_Bold ), TypefaceStyle.Normal ); ProfileName.SetTextSize( Android.Util.ComplexUnitType.Dip, ControlStylingConfig.Large_FontSize ); ProfileName.SetMaxLines( 1 ); ProfileName.Ellipsize = Android.Text.TextUtils.TruncateAt.End; CampusContainer = view.FindViewById<View>( Resource.Id.campus_container ); CampusContainer.LayoutParameters.Width = (int) ( displayWidth * revealPercent ); CampusContainer.SetBackgroundColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Springboard_BackgroundColor ) ); View seperator = view.FindViewById<View>( Resource.Id.end_seperator ); seperator.SetBackgroundColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BG_Layer_Color ) ); // setup the bottom campus / settings selector CampusText = CampusContainer.FindViewById<TextView>( Resource.Id.campus_selection_text ); CampusText.Ellipsize = Android.Text.TextUtils.TruncateAt.End; CampusText.SetTextColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Springboard_InActiveElementTextColor ) ); CampusText.SetTypeface( Rock.Mobile.PlatformSpecific.Android.Graphics.FontManager.Instance.GetFont( ControlStylingConfig.Font_Regular ), TypefaceStyle.Normal ); CampusText.SetTextSize(Android.Util.ComplexUnitType.Dip, ControlStylingConfig.Small_FontSize ); CampusText.SetSingleLine( ); TextView settingsIcon = CampusContainer.FindViewById<TextView>( Resource.Id.campus_selection_icon ); settingsIcon.SetTypeface( Rock.Mobile.PlatformSpecific.Android.Graphics.FontManager.Instance.GetFont( PrivateControlStylingConfig.Icon_Font_Primary ), TypefaceStyle.Normal ); settingsIcon.SetTextColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Springboard_InActiveElementTextColor ) ); settingsIcon.SetTextSize( Android.Util.ComplexUnitType.Dip, PrivateSpringboardConfig.CampusSelectSymbolSize ); settingsIcon.Text = PrivateSpringboardConfig.CampusSelectSymbol; // set the campus text to whatever their profile has set for viewing. CampusText.Text = string.Format( SpringboardStrings.Viewing_Campus, RockGeneralData.Instance.Data.CampusIdToName( RockMobileUser.Instance.ViewingCampus ) ).ToUpper( ); // setup the campus selection button. Button campusSelectionButton = CampusContainer.FindViewById<Button>( Resource.Id.campus_selection_button ); campusSelectionButton.Click += SelectCampus; Billboard = new NotificationBillboard( displayWidth, Rock.Mobile.PlatformSpecific.Android.Core.Context ); Billboard.SetLabel( SpringboardStrings.TakeNotesNotificationIcon, PrivateControlStylingConfig.Icon_Font_Primary, ControlStylingConfig.Small_FontSize, SpringboardStrings.TakeNotesNotificationLabel, ControlStylingConfig.Font_Light, ControlStylingConfig.Small_FontSize, ControlStylingConfig.TextField_ActiveTextColor, ControlStylingConfig.Springboard_Element_SelectedColor, delegate { // find the Notes task, activate it, and tell it to jump to the read page. foreach( SpringboardElement element in Elements ) { if ( element.Task as Droid.Tasks.Notes.NotesTask != null ) { ActivateElement( element ); PerformTaskAction( PrivateGeneralConfig.TaskAction_NotesRead ); } } } ); Billboard.Hide( ); return view; }
public override void ViewDidLoad() { base.ViewDidLoad( ); TraitSize = UIScreen.MainScreen.Bounds.Size; CurrentTraitCollection = TraitCollection; // if we're on an iphone and they're holding it landscape, force a portrait traitsize if ( UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone && IsDeviceLandscape( ) ) { UITraitCollection horzTrait = UITraitCollection.FromHorizontalSizeClass( UIUserInterfaceSizeClass.Compact ); UITraitCollection vertTrait = UITraitCollection.FromVerticalSizeClass( UIUserInterfaceSizeClass.Regular ); CurrentTraitCollection = UITraitCollection.FromTraitsFromCollections( new UITraitCollection[] { horzTrait, vertTrait } ); TraitSize = new CGSize( TraitSize.Height, TraitSize.Width ); } View.Layer.AnchorPoint = CGPoint.Empty; View.Bounds = new CGRect( View.Bounds.Left, View.Bounds.Top, TraitSize.Width, TraitSize.Height ); // create the login controller / profile view controllers LoginViewController = new LoginViewController( ); LoginViewController.Springboard = this; ProfileViewController = new ProfileViewController( ); ProfileViewController.Springboard = this; ImageCropViewController = new ImageCropViewController( ); ImageCropViewController.Springboard = this; RegisterViewController = new RegisterViewController( ); RegisterViewController.Springboard = this; OOBEViewController = new OOBEViewController( ); OOBEViewController.Springboard = this; OOBEViewController.View.Layer.Position = CGPoint.Empty; SplashViewController = new SplashViewController( ); SplashViewController.Springboard = this; SplashViewController.View.Layer.Position = CGPoint.Empty; ScrollView = new UIScrollViewWrapper( ); ScrollView.Layer.AnchorPoint = CGPoint.Empty; ScrollView.Parent = this; View.AddSubview( ScrollView ); // Instantiate all activities float elementWidth = 250; float elementHeight = 45; NewsElement = new UIView( new CGRect( 0, 0, elementWidth, elementHeight ) ); ScrollView.AddSubview( NewsElement ); MessagesElement = new UIView( new CGRect( 0, 0, elementWidth, elementHeight ) ); ScrollView.AddSubview( MessagesElement ); GiveElement = new UIView( new CGRect( 0, 0, elementWidth, elementHeight ) ); ScrollView.AddSubview( GiveElement ); ConnectElement = new UIView( new CGRect( 0, 0, elementWidth, elementHeight ) ); ScrollView.AddSubview( ConnectElement ); PrayerElement = new UIView( new CGRect( 0, 0, elementWidth, elementHeight ) ); ScrollView.AddSubview( PrayerElement ); MoreElement = new UIView( new CGRect( 0, 0, elementWidth, elementHeight ) ); ScrollView.AddSubview( MoreElement ); // EditPictureButton = new UIButton( new CGRect( 0, 0, 112, 112 ) ); ScrollView.AddSubview( EditPictureButton ); WelcomeField = new UILabel(); ScrollView.AddSubview( WelcomeField ); UserNameField = new UILabel(); ScrollView.AddSubview( UserNameField ); ViewProfileButton = new UIButton(); ScrollView.AddSubview( ViewProfileButton ); ViewProfileLabel = new UILabel(); ScrollView.AddSubview( ViewProfileLabel ); Elements.Add( new SpringboardElement( this, new NewsTask( "NewsStoryboard_iPhone" ) , NewsElement , SpringboardConfig.Element_News_Icon , SpringboardStrings.Element_News_Title ) ); Elements.Add( new SpringboardElement( this, new NotesTask( "NotesStoryboard_iPhone" ) , MessagesElement, SpringboardConfig.Element_Messages_Icon, SpringboardStrings.Element_Messages_Title ) ); Elements.Add( new SpringboardElement( this, new GiveTask( "GiveStoryboard_iPhone" ) , GiveElement , SpringboardConfig.Element_Give_Icon , SpringboardStrings.Element_Give_Title ) ); Elements.Add( new SpringboardElement( this, new ConnectTask( "ConnectStoryboard_iPhone" ), ConnectElement , SpringboardConfig.Element_Connect_Icon , SpringboardStrings.Element_Connect_Title ) ); Elements.Add( new SpringboardElement( this, new PrayerTask( "PrayerStoryboard_iPhone" ) , PrayerElement , SpringboardConfig.Element_Prayer_Icon , SpringboardStrings.Element_Prayer_Title ) ); Elements.Add( new SpringboardElement( this, new AboutTask( "" ) , MoreElement , SpringboardConfig.Element_More_Icon , SpringboardStrings.Element_More_Title ) ); // add a bottom seperator for the final element BottomSeperator = new UIView(); BottomSeperator.BackgroundColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BG_Layer_Color ); ScrollView.AddSubview( BottomSeperator ); BottomSeperator.Frame = new CGRect( 0, 0, View.Frame.Width, 1.0f ); // set the profile image mask so it's circular CALayer maskLayer = new CALayer(); maskLayer.AnchorPoint = new CGPoint( 0, 0 ); maskLayer.Bounds = EditPictureButton.Layer.Bounds; maskLayer.CornerRadius = EditPictureButton.Bounds.Width / 2; maskLayer.BackgroundColor = UIColor.Black.CGColor; EditPictureButton.Layer.Mask = maskLayer; // // setup the campus selector and settings button CampusSelectionText = new UILabel(); ControlStyling.StyleUILabel( CampusSelectionText, ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize ); CampusSelectionText.TextColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Springboard_InActiveElementTextColor ); ScrollView.AddSubview( CampusSelectionText ); CampusSelectionIcon = new UILabel(); ControlStyling.StyleUILabel( CampusSelectionIcon, PrivateControlStylingConfig.Icon_Font_Primary, ControlStylingConfig.Small_FontSize ); CampusSelectionIcon.TextColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Springboard_InActiveElementTextColor ); CampusSelectionIcon.Text = PrivateSpringboardConfig.CampusSelectSymbol; CampusSelectionIcon.SizeToFit( ); ScrollView.AddSubview( CampusSelectionIcon ); CampusSelectionButton = new UIButton(); ScrollView.AddSubview( CampusSelectionButton ); CampusSelectionButton.TouchUpInside += SelectCampus; // setup the image that will display when the user is logged in ProfileImageView = new UIImageView( ); ProfileImageView.ContentMode = UIViewContentMode.ScaleAspectFit; ProfileImageView.Layer.AnchorPoint = CGPoint.Empty; ProfileImageView.Bounds = EditPictureButton.Bounds; ProfileImageView.Layer.Position = CGPoint.Empty; EditPictureButton.AddSubview( ProfileImageView ); EditPictureButton.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( PrivateControlStylingConfig.Icon_Font_Primary, PrivateSpringboardConfig.ProfileSymbolFontSize ); EditPictureButton.SetTitleColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Springboard_InActiveElementTextColor ), UIControlState.Normal ); EditPictureButton.Layer.BorderColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Springboard_InActiveElementTextColor ).CGColor; EditPictureButton.Layer.CornerRadius = EditPictureButton.Bounds.Width / 2; EditPictureButton.Layer.BorderWidth = 4; WelcomeField.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( ControlStylingConfig.Font_Light, ControlStylingConfig.Large_FontSize ); WelcomeField.TextColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Springboard_InActiveElementTextColor ); UserNameField.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( ControlStylingConfig.Font_Bold, ControlStylingConfig.Large_FontSize ); UserNameField.TextColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Springboard_InActiveElementTextColor ); View.BackgroundColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Springboard_BackgroundColor ); AddChildViewController( NavViewController ); View.AddSubview( NavViewController.View ); SetNeedsStatusBarAppearanceUpdate( ); EditPictureButton.TouchUpInside += (object sender, EventArgs e) => { // don't allow launching a model view controller unless the springboard is open. if ( NavViewController.IsSpringboardOpen( ) ) { if( RockMobileUser.Instance.LoggedIn == true ) { // they're logged in, so let them set their profile pic ManageProfilePic( ); } else { //otherwise this button can double as a login button. PresentModalViewController( LoginViewController ); } } }; ViewProfileButton.TouchUpInside += (object sender, EventArgs e) => { // don't allow launching a model view controller unless the springboard is open. if ( NavViewController.IsSpringboardOpen( ) ) { if( RockMobileUser.Instance.LoggedIn == true ) { // Because we aren't syncing RIGHT HERE, Rock data could technically be overwritten. // If WHILE they're running the app, their data is updated in Rock, those changes will // be lost when they submit their profile changes. // But, the odds that Rock data will update WHILE THE APP IS RUNNING, and they then decide to // update their profile without having even backgrounded the app, are extremely low. PresentModalViewController( ProfileViewController ); } else { PresentModalViewController( LoginViewController ); } } }; // load our objects from disk Rock.Mobile.Util.Debug.WriteLine( "Loading objects from device." ); RockNetworkManager.Instance.LoadObjectsFromDevice( ); Rock.Mobile.Util.Debug.WriteLine( "Loading objects done." ); // set the viewing campus now that their profile has loaded (if they have already done the OOBE) CampusSelectionText.Text = string.Format( SpringboardStrings.Viewing_Campus, RockGeneralData.Instance.Data.CampusIdToName( RockMobileUser.Instance.ViewingCampus ) ).ToUpper( ); CampusSelectionText.SizeToFit( ); // seed the last sync time with now, so that when OnActivated gets called we don't do it again. LastRockSync = DateTime.Now; // setup the Notification Banner for Taking Notes Billboard = new NotificationBillboard( View.Bounds.Width, View.Bounds.Height ); Billboard.SetLabel( SpringboardStrings.TakeNotesNotificationIcon, PrivateControlStylingConfig.Icon_Font_Primary, ControlStylingConfig.Small_FontSize, SpringboardStrings.TakeNotesNotificationLabel, ControlStylingConfig.Font_Light, ControlStylingConfig.Small_FontSize, ControlStylingConfig.TextField_ActiveTextColor, ControlStylingConfig.Springboard_Element_SelectedColor, delegate { // find the Notes task, activate it, and tell it to jump to the read page. foreach( SpringboardElement element in Elements ) { if ( element.Task as NotesTask != null ) { ActivateElement( element, true ); PerformTaskAction( PrivateGeneralConfig.TaskAction_NotesRead ); } } } ); Billboard.Layer.Position = new CGPoint( Billboard.Layer.Position.X, NavViewController.NavigationBar.Frame.Height ); // only do the OOBE if the user hasn't seen it yet if ( RockMobileUser.Instance.OOBEComplete == false ) //if( RanOOBE == false ) { // sanity check for testers that didn't listen to me and delete / reinstall. // This will force them to be logged out so they experience the OOBE properly. RockMobileUser.Instance.LogoutAndUnbind( ); //RanOOBE = true; IsOOBERunning = true; AddChildViewController( OOBEViewController ); View.AddSubview( OOBEViewController.View ); } else { // kick off the splash screen animation AddChildViewController( SplashViewController ); View.AddSubview( SplashViewController.View ); } }