Exemplo n.º 1
0
                    static float PrayerActionDimension = 100;//Rock.Mobile.Graphics.Util.UnitToPx( 50 );

                    public PrayerCard(Rock.Client.PrayerRequest prayer, RectangleF bounds)
                    {
                        PrayerRequest = prayer;

                        View                 = PlatformView.Create( );
                        View.Bounds          = bounds;
                        View.BackgroundColor = ControlStylingConfig.BG_Layer_Color;
                        View.BorderColor     = ControlStylingConfig.BG_Layer_BorderColor;
                        View.CornerRadius    = ControlStylingConfig.Button_CornerRadius;
                        View.BorderWidth     = ControlStylingConfig.BG_Layer_BorderWidth;

                        // create a vertically oriented linearLayout that will act as our root
                        RelativeLayout root = new RelativeLayout(Rock.Mobile.PlatformSpecific.Android.Core.Context);

                        //root.SetBackgroundColor( Android.Graphics.Color.GreenYellow );
                        root.LayoutParameters = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);


                        // create the bottom prayer layout
                        PrayerActionSize = new System.Drawing.SizeF(Rock.Mobile.Graphics.Util.UnitToPx(PrayerActionDimension),
                                                                    Rock.Mobile.Graphics.Util.UnitToPx(PrayerActionDimension));


                        // create the layout that will contain the circle, button and label
                        PrayerActionLayout = new RelativeLayout(Rock.Mobile.PlatformSpecific.Android.Core.Context);
                        //frameLayout.SetBackgroundColor( Android.Graphics.Color.Aqua );
                        PrayerActionLayout.LayoutParameters = new LinearLayout.LayoutParams((int)PrayerActionSize.Width, (int)PrayerActionSize.Height);
                        ((LinearLayout.LayoutParams)PrayerActionLayout.LayoutParameters).Weight = 1;
                        root.AddView(PrayerActionLayout);


                        // Pray Button
                        PrayerActionButton                  = new Button(Rock.Mobile.PlatformSpecific.Android.Core.Context);
                        PrayerActionButton.Enabled          = false;
                        PrayerActionButton.Background       = null;
                        PrayerActionButton.LayoutParameters = new RelativeLayout.LayoutParams((int)PrayerActionSize.Width, (int)PrayerActionSize.Height);
                        //Pray.SetBackgroundColor( Android.Graphics.Color.Green );
                        PrayerActionLayout.AddView(PrayerActionButton);


                        // Layout for the text and circle
                        PrayerActionCircle             = new Rock.Mobile.PlatformSpecific.Android.Graphics.CircleView(Rock.Mobile.PlatformSpecific.Android.Core.Context);
                        PrayerActionCircle.Color       = Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BG_Layer_BorderColor);
                        PrayerActionCircle.StrokeWidth = 1;
                        //PrayerActionCircle.SetBackgroundColor( Android.Graphics.Color.Blue );
                        PrayerActionCircle.LayoutParameters = new RelativeLayout.LayoutParams((int)PrayerActionSize.Width, (int)PrayerActionSize.Height);
                        PrayerActionLayout.AddView(PrayerActionCircle);

                        // Setup the "I Prayed" label
                        PrayerActionLabel = new TextView(Rock.Mobile.PlatformSpecific.Android.Core.Context);
                        PrayerActionLabel.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);
                        PrayerActionLabel.Text             = PrayerStrings.Prayer_Before;
                        PrayerActionLabel.Gravity          = GravityFlags.Center;
                        //PrayerActionLabel.SetBackgroundColor( Android.Graphics.Color.Orange );
                        PrayerActionLabel.SetTypeface(Rock.Mobile.PlatformSpecific.Android.Graphics.FontManager.Instance.GetFont(ControlStylingConfig.Font_Regular), TypefaceStyle.Normal);
                        PrayerActionLabel.SetTextSize(ComplexUnitType.Dip, ControlStylingConfig.Small_FontSize);
                        PrayerActionLabel.SetTextColor(Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.TextField_PlaceholderTextColor));
                        PrayerActionLayout.AddView(PrayerActionLabel);

                        PositionPrayedLabel( );

                        PrayerActionButton.Click += (object sender, EventArgs e) =>
                        {
                            TogglePrayed(true);
                        };
                        //

                        // add the controls
                        ViewGroup nativeView = View.PlatformNativeObject as ViewGroup;

                        nativeView.AddView(root);


                        // add it to this view
                        PrayerLayout = new PrayerLayoutRender(new RectangleF(bounds.Left, bounds.Top, bounds.Width, bounds.Height - PrayerActionSize.Height),
                                                              PrayerActionSize.Height * .75f,
                                                              prayer);
                        nativeView.AddView(PrayerLayout.LinearLayout);

                        PrayerActionButton.Enabled = true;
                    }
Exemplo n.º 2
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;
        }
                    static float PrayerActionDimension = 100;//Rock.Mobile.Graphics.Util.UnitToPx( 50 );

                    public PrayerCard( Rock.Client.PrayerRequest prayer, RectangleF bounds )
                    {
                        PrayerRequest = prayer;

                        View = PlatformView.Create( );
                        View.Bounds = bounds;
                        View.BackgroundColor = ControlStylingConfig.BG_Layer_Color;
                        View.BorderColor = ControlStylingConfig.BG_Layer_BorderColor;
                        View.CornerRadius = ControlStylingConfig.Button_CornerRadius;
                        View.BorderWidth = ControlStylingConfig.BG_Layer_BorderWidth;

                        // create a vertically oriented linearLayout that will act as our root
                        RelativeLayout root = new RelativeLayout( Rock.Mobile.PlatformSpecific.Android.Core.Context );
                        //root.SetBackgroundColor( Android.Graphics.Color.GreenYellow );
                        root.LayoutParameters = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent );


                        // create the bottom prayer layout
                        PrayerActionSize = new System.Drawing.SizeF( Rock.Mobile.Graphics.Util.UnitToPx( PrayerActionDimension ), 
                                                                     Rock.Mobile.Graphics.Util.UnitToPx( PrayerActionDimension ) );


                        // create the layout that will contain the circle, button and label
                        PrayerActionLayout = new RelativeLayout( Rock.Mobile.PlatformSpecific.Android.Core.Context );
                        //frameLayout.SetBackgroundColor( Android.Graphics.Color.Aqua );
                        PrayerActionLayout.LayoutParameters = new LinearLayout.LayoutParams( (int)PrayerActionSize.Width, (int)PrayerActionSize.Height );
                        ((LinearLayout.LayoutParams)PrayerActionLayout.LayoutParameters).Weight = 1;
                        root.AddView( PrayerActionLayout );


                        // Pray Button
                        PrayerActionButton = new Button( Rock.Mobile.PlatformSpecific.Android.Core.Context );
                        PrayerActionButton.Enabled = false;
                        PrayerActionButton.Background = null;
                        PrayerActionButton.LayoutParameters = new RelativeLayout.LayoutParams( (int)PrayerActionSize.Width, (int)PrayerActionSize.Height );
                        //Pray.SetBackgroundColor( Android.Graphics.Color.Green );
                        PrayerActionLayout.AddView( PrayerActionButton );
                            

                        // Layout for the text and circle
                        PrayerActionCircle = new Rock.Mobile.PlatformSpecific.Android.Graphics.CircleView( Rock.Mobile.PlatformSpecific.Android.Core.Context );
                        PrayerActionCircle.Color = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BG_Layer_BorderColor );
                        PrayerActionCircle.StrokeWidth = 1;
                        //PrayerActionCircle.SetBackgroundColor( Android.Graphics.Color.Blue );
                        PrayerActionCircle.LayoutParameters = new RelativeLayout.LayoutParams( (int)PrayerActionSize.Width, (int)PrayerActionSize.Height );
                        PrayerActionLayout.AddView( PrayerActionCircle );

                        // Setup the "I Prayed" label
                        PrayerActionLabel = new TextView( Rock.Mobile.PlatformSpecific.Android.Core.Context );
                        PrayerActionLabel.LayoutParameters = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent );
                        PrayerActionLabel.Text = PrayerStrings.Prayer_Before;
                        PrayerActionLabel.Gravity = GravityFlags.Center;
                        //PrayerActionLabel.SetBackgroundColor( Android.Graphics.Color.Orange );
                        PrayerActionLabel.SetTypeface( Rock.Mobile.PlatformSpecific.Android.Graphics.FontManager.Instance.GetFont( ControlStylingConfig.Font_Regular ), TypefaceStyle.Normal );
                        PrayerActionLabel.SetTextSize( ComplexUnitType.Dip, ControlStylingConfig.Small_FontSize );
                        PrayerActionLabel.SetTextColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.TextField_PlaceholderTextColor ) );
                        PrayerActionLayout.AddView( PrayerActionLabel );

                        PositionPrayedLabel( );

                        PrayerActionButton.Click += (object sender, EventArgs e) => 
                            {
                                TogglePrayed( true );
                            };
                        //

                        // add the controls
                        ViewGroup nativeView = View.PlatformNativeObject as ViewGroup;
                        nativeView.AddView( root );


                        // add it to this view
                        PrayerLayout = new PrayerLayoutRender( new RectangleF( bounds.Left, bounds.Top, bounds.Width, bounds.Height - PrayerActionSize.Height ), 
                                                               PrayerActionSize.Height * .75f, 
                                                               prayer );
                        nativeView.AddView( PrayerLayout.LinearLayout );

                        PrayerActionButton.Enabled = true;
                    }