Esempio n. 1
0
                protected void ShutdownNotes(Bundle instanceBundle)
                {
                    if (TutorialImage != null)
                    {
                        TutorialOverlay.SetImageBitmap(null);
                        TutorialImage.Dispose( );
                        TutorialImage = null;
                    }

                    // shutdown notes ensures that user settings are saved
                    // the note is destroyed and references to it are cleared.
                    if (Note != null)
                    {
                        Note.SaveState((float)ScrollView.ScrollY / (float)ScrollViewLayout.LayoutParameters.Height);

                        Note.Destroy(ScrollViewLayout);
                        Note = null;
                    }
                }
Esempio n. 2
0
                protected void CreateNotes( )
                {
                    try
                    {
                        // expect the note and its style sheet to exist.
                        NoteFileName = Rock.Mobile.Util.Strings.Parsers.ParseURLToFileName(NoteUrl);
                        MemoryStream noteData = (MemoryStream)FileCache.Instance.LoadFile(NoteFileName);
                        string       noteXML  = Encoding.UTF8.GetString(noteData.ToArray( ), 0, (int)noteData.Length);
                        noteData.Dispose( );

                        Note = new Note(noteXML);

                        // Use the metrics and not ScrollView for dimensions, because depending on when this gets called the ScrollView
                        // may not have its dimensions set yet.
                        float scrollPercentOffset = Note.Create(NavbarFragment.GetCurrentContainerDisplayWidth( ),
                                                                this.Resources.DisplayMetrics.HeightPixels,
                                                                ScrollViewLayout,
                                                                NoteFileName + PrivateNoteConfig.UserNoteSuffix,
                                                                DisplayMessageBox,
                                                                UpdateScrollViewHeight);

                        // set the requested background color
                        ScrollView.SetBackgroundColor((Android.Graphics.Color)Rock.Mobile.UI.Util.GetUIColor(Note.mStyle.mBackgroundColor ?? 0x000000FF));

                        // update the height of the scroll view to fit all content
                        float noteBottom = Note.GetNoteAbsoluteHeight( );

                        int scrollFrameHeight = ( int )noteBottom + (this.Resources.DisplayMetrics.HeightPixels / 3);
                        ScrollViewLayout.LayoutParameters.Height = scrollFrameHeight;

                        // scroll to where the user left off
                        ScrollView.Post(new Action(delegate
                        {
                            ScrollView.ForceScrollTo(0, (int)(scrollPercentOffset * (float)scrollFrameHeight));
                        }));

                        FinishNotesCreation( );

                        // log the note they are reading.
                        MessageAnalytic.Instance.Trigger(MessageAnalytic.Read, NoteName);

                        // display the tutorial if it hasn't been shown this run of the app, and the user has never created their own note.
                        if (TutorialDisplayed == false && MobileApp.Shared.Network.RockMobileUser.Instance.UserNoteCreated == false)
                        {
                            TutorialDisplayed = true;

                            System.IO.Stream tutorialStream = Activity.BaseContext.Assets.Open(PrivateNoteConfig.TutorialOverlayImage);

                            TutorialImage = Android.Graphics.BitmapFactory.DecodeStream(tutorialStream);
                            TutorialOverlay.SetImageBitmap(TutorialImage);

                            // wait a second before revealing the tutorial overlay
                            System.Timers.Timer timer = new System.Timers.Timer();
                            timer.AutoReset = false;
                            timer.Interval  = 750;
                            timer.Elapsed  += (object sender, System.Timers.ElapsedEventArgs e) =>
                            {
                                Rock.Mobile.Threading.Util.PerformOnUIThread(delegate
                                {
                                    TutorialBacker.Visibility = ViewStates.Visible;
                                    AnimateTutorialScreen(true);
                                    ScrollView.ScrollEnabled = false;
                                });
                            };
                            timer.Start( );
                        }

                        ParentTask.NavbarFragment.NavToolbar.Reveal(true);
                    }
                    catch (Exception ex)
                    {
                        ReportException("", ex);
                    }
                }