/// <summary> /// Adjusts the container views based on how far along X they should move. /// Also updates the fade out view so it darkens or lightens as needed. /// </summary> /// <param name="xPos">X position.</param> void PanContainerViews(float xPos) { // there's a small chance of an exception being thrown // due to one of the below not being valid. Repro'ing this is not easy, // so the safer route is to just guard against all of them, and // worst case we'll skip a frame of animation if (DropShadowView != null && View != null && ActiveTaskFrame != null && NavToolbar != null && NavToolbar.ButtonLayout != null && FadeOutFrame != null) { DropShadowView.SetX(xPos - DropShadowXOffset); View.SetX(xPos); ActiveTaskFrame.SetX(xPos); NavToolbar.ButtonLayout.SetX(xPos); FadeOutFrame.SetX(xPos); // now determine the alpha float maxSlide = Springboard.GetSpringboardDisplayWidth( ); FadeOutFrame.Alpha = Math.Min(xPos / maxSlide, PrivatePrimaryContainerConfig.SlideDarkenAmount); } }
public void ToggleFullscreen(bool fullscreenEnabled) { // useful for when a video wants to be fullscreen if (fullscreenEnabled == true) { Navbar.Visibility = ViewStates.Gone; NavToolbar.ButtonLayout.Visibility = ViewStates.Gone; // if we're in landscape wide, ensure the springboard is closed while in fullscreen. if (MainActivity.IsLandscapeWide( ) == true) { PanContainerViews(0); Point displaySize = new Point(); Activity.WindowManager.DefaultDisplay.GetSize(displaySize); float displayWidth = displaySize.X; SetContainerWidth((int)displayWidth); } } else { Navbar.Visibility = ViewStates.Visible; NavToolbar.ButtonLayout.Visibility = ViewStates.Visible; // if we're in landscape wide, ensure the springboard is closed while in fullscreen. if (MainActivity.IsLandscapeWide( ) == true) { PanContainerViews(Springboard.GetSpringboardDisplayWidth( )); SetContainerWidth(GetCurrentContainerDisplayWidth( )); } } }
public void OnScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { // sanity check, as the events could be null. if (e1 != null && e2 != null) { // only allow it if we're NOT animating, the task is ok with us panning, and we're in portrait mode. if (Animating == false && ActiveTask.CanContainerPan( ) && Activity.Resources.Configuration.Orientation == Android.Content.Res.Orientation.Portrait) { switch (Panning) { case PanState.Monitoring: { TotalPanY += Math.Abs(e2.RawY - e1.RawY); TotalPanX += Math.Abs(e2.RawX - e1.RawX); FrameCount++; if (FrameCount > sNumPanTrackingFrames) { // decide how to proceed Panning = PanState.None; // put simply, if their total X was more than their total Y, well then, // lets pan. if (TotalPanX > TotalPanY) { Panning = PanState.Panning; // mark where the panning began, so we can move the field appropriately PanStartX = e2.RawX; PanelOriginX = View.GetX( ); } else { // Y was greater than X, so they probably intended to scroll, not pan. Panning = PanState.None; } } break; } case PanState.Panning: { distanceX = e2.RawX - PanStartX; float xPos = PanelOriginX + distanceX; float revealAmount = Springboard.GetSpringboardDisplayWidth( ); xPos = Math.Max(0, Math.Min(xPos, revealAmount)); PanContainerViews(xPos); break; } } } } }
public void LayoutChanged( ) { // if we just entered landscape wide mode if (MainActivity.IsLandscapeWide( ) == true) { // turn off the springboard button SpringboardRevealButton.Enabled = false; SpringboardRevealed = true; // move the container over so the springboard is revealed PanContainerViews(Springboard.GetSpringboardDisplayWidth( )); // turn off the shadow FadeOutFrame.Alpha = 0.0f; FadeOutFrame.Visibility = ViewStates.Invisible; // resize the containers to use the remaining width int containerWidth = GetCurrentContainerDisplayWidth( ); SetContainerWidth(containerWidth); ToggleInputViewChecker(false); } // we're going back to portrait (or normal landscape) else { // enable the springboard reveal button SpringboardRevealed = false; // close the springboard PanContainerViews(0); FadeOutFrame.Visibility = ViewStates.Visible; // resize the containers to use the full device width Point displaySize = new Point( ); Activity.WindowManager.DefaultDisplay.GetSize(displaySize); float displayWidth = displaySize.X; SetContainerWidth((int)displayWidth); // only allow the reveal button if the device is in portrait. if (MainActivity.IsPortrait( )) { SpringboardRevealButton.Enabled = true; } else { SpringboardRevealButton.Enabled = false; } } }
public void OnUp(MotionEvent e) { // if we were panning if (Panning == PanState.Panning) { float revealAmount = Springboard.GetSpringboardDisplayWidth( ); if (SpringboardRevealed == false) { // since the springboard wasn't revealed, require that they moved // at least 1/5th the amount before opening it if (View.GetX( ) > revealAmount * .20f) { RevealSpringboard(true); } else { RevealSpringboard(false); } } else { if (View.GetX( ) < revealAmount * .85f) { RevealSpringboard(false); } else { RevealSpringboard(true); } } } else { // if the task should allowe input, reveal the nav bar if (ShouldTaskAllowInput( ) == true) { // let the active task know that the user released input ActiveTask.OnUp(e); } else if (ShouldSpringboardAllowInput( ) == true) { // else close the springboard RevealSpringboard(false); } } // no matter what, we're done panning Panning = PanState.None; }
public void RevealSpringboard(bool wantReveal) { if (!Animating) { Animating = true; int xOffset = wantReveal ? (int)Springboard.GetSpringboardDisplayWidth( ) : 0; // setup an animation from our current mask scale to the new one. XPosAnimator = ValueAnimator.OfInt((int)View.GetX( ), xOffset); XPosAnimator.AddUpdateListener(this); XPosAnimator.AddListener(new NavbarAnimationListener( ) { NavbarFragment = this }); XPosAnimator.SetDuration((int)(PrivatePrimaryContainerConfig.SlideRate * 1000.0f)); XPosAnimator.Start(); } }