示例#1
0
        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;
        }