Ejemplo n.º 1
0
        void SetupLayout()
        {
            var bundle   = new Bundle();
            var rotation = ScreenHelper.GetRotation(this);

            if (isDuo && screenHelper.IsDualMode)
            {
                switch (rotation)
                {
                case Android.Views.SurfaceOrientation.Rotation90:
                case Android.Views.SurfaceOrientation.Rotation270:
                    // Setting layout for double landscape
                    bundle.PutInt(AdaptiveFragment.KEY_LAYOUT_ID, Resource.Layout.fragment_dual_landscape);
                    break;

                default:
                    bundle.PutInt(AdaptiveFragment.KEY_LAYOUT_ID, Resource.Layout.fragment_dual_portrail);
                    break;
                }
            }
            else
            {
                bundle.PutInt(AdaptiveFragment.KEY_LAYOUT_ID, Resource.Layout.fragment_single_portrait);
            }

            Fragment adaptiveFragment = AdaptiveFragment.NewInstance();

            adaptiveFragment.Arguments = bundle;
            ShowFragment(adaptiveFragment);
        }
Ejemplo n.º 2
0
        public IScreenState GetScreenState()
        {
            var pixelDensisty = _activity?.Resources?.DisplayMetrics?.Density ?? 1;

            var rotation   = _screenHelper.GetRotation();
            var hinge      = _screenHelper.GetHingeBounds();
            var windowRect = GetWindowRect();

            if (IsDualMode)
            {
                return(new ScreenState
                {
                    Screen1Visible = true,
                    Screen1Bounds = new Rect(0, 0, PixelsToDip(hinge.Left), PixelsToDip(windowRect.Bottom)),
                    Screen2Visible = true,
                    Screen2Bounds = new Rect(PixelsToDip(hinge.Right), 0, PixelsToDip(windowRect.Right - hinge.Right), PixelsToDip(windowRect.Bottom))
                });
            }
            else
            {
                return(new ScreenState
                {
                    Screen1Visible = true,
                    Screen1Bounds = new Rect(0, 0, PixelsToDip(windowRect.Right), PixelsToDip(windowRect.Bottom)),
                    Screen2Visible = false,
                    Screen2Bounds = Rect.Empty
                });
            }
        }
Ejemplo n.º 3
0
        public Rectangle GetHinge()
        {
            if (!this.isDuo || helper == null)
            {
                return(Rectangle.Zero);
            }

            var rotation = ScreenHelper.GetRotation(helper.Activity);
            var hinge    = helper.DisplayMask.GetBoundingRectsForRotation(rotation).FirstOrDefault();
            var hingeDp  = new Rectangle(
                this.PixelsToDp(hinge.Left),
                this.PixelsToDp(hinge.Top),
                this.PixelsToDp(hinge.Width()),
                this.PixelsToDp(hinge.Height()));

            return(hingeDp);
        }
Ejemplo n.º 4
0
            void Update()
            {
                _isSpanned = IsDuo && (_helper?.IsDualMode ?? false);

                // Hinge
                if (!IsDuo)
                {
                    _hingeDp = Rectangle.Zero;
                }
                else
                {
                    var hinge = _helper.GetHingeBoundsDip();

                    if (hinge == null || !IsSpanned)
                    {
                        _hingeDp = Rectangle.Zero;
                    }
                    else
                    {
                        _hingeDp = new Rectangle((hinge.Left), (hinge.Top), (hinge.Width()), (hinge.Height()));
                    }
                }

                // Is Landscape
                if (!IsDuo)
                {
                    if (_mainActivity == null)
                    {
                        _isLandscape = false;
                    }
                    else
                    {
                        var orientation = _mainActivity.Resources.Configuration.Orientation;
                        _isLandscape = (orientation == global::Android.Content.Res.Orientation.Landscape);
                    }
                }
                else
                {
                    var rotation = ScreenHelper.GetRotation(_helper.Activity);
                    _isLandscape = (rotation == SurfaceOrientation.Rotation270 || rotation == SurfaceOrientation.Rotation90);
                }
            }
        private void SetupLayout()
        {
            var rotation = ScreenHelper.GetRotation(this);

            if (isDuo)
            {
                if (screenHelper.IsDualMode)
                {
                    UseDualMode(rotation);
                }
                else
                {
                    UseSingleMode();
                }
            }
            else
            {
                UseSingleMode();
            }
        }