void layoutStateChange(WindowLayoutInfo newLayoutInfo)
        {
            var wm = windowMetricsCalculator.ComputeCurrentWindowMetrics(ContextHelper.Current as Android.App.Activity);

            if (this.Log().IsEnabled(LogLevel.Debug))
            {
                this.Log().Debug($"DualMode:    CurrentWindowBounds: " + wm.Bounds.ToString());
                this.Log().Debug($"DualMode:    MaximumWindowBounds: " + windowMetricsCalculator.ComputeMaximumWindowMetrics(ContextHelper.Current as Android.App.Activity).Bounds.ToString());
            }

            FoldBounds     = null;
            IsSeparating   = false;
            HasFoldFeature = false;

            NativeFold lastFoldingFeature = null;

            foreach (var displayFeature in newLayoutInfo.DisplayFeatures)
            {
                var foldingFeature = displayFeature.JavaCast <IFoldingFeature>();

                if (foldingFeature != null)                 // HACK: requires JavaCast as shown above
                {
                    // Set properties for FoldableApplicationViewSpanningRects to reference
                    HasFoldFeature    = true;
                    IsSeparating      = foldingFeature.IsSeparating;
                    FoldBounds        = foldingFeature.Bounds;              // physical pixel values
                    FoldState         = foldingFeature.State;
                    FoldOcclusionType = foldingFeature.OcclusionType;

                    if (foldingFeature.Orientation == FoldingFeatureOrientation.Horizontal)
                    {
                        //Orientation = SurfaceOrientation.Rotation90;
                        IsFoldVertical  = false;
                        FoldOrientation = FoldingFeatureOrientation.Horizontal;
                    }
                    else
                    {
                        //Orientation = SurfaceOrientation.Rotation0; // HACK: what about 180 and 270?
                        IsFoldVertical  = true;
                        FoldOrientation = FoldingFeatureOrientation.Vertical;
                    }

                    lastFoldingFeature = new NativeFold
                    {
                        Bounds      = FoldBounds,
                        IsOccluding = foldingFeature.OcclusionType == FoldingFeatureOcclusionType.Full,
                        IsFlat      = foldingFeature.State == FoldingFeatureState.Flat,
                        IsVertical  = IsFoldVertical
                    };

                    if (this.Log().IsEnabled(LogLevel.Debug))
                    {
                        var summary = "\n    IsSeparating: " + foldingFeature.IsSeparating
                                      + "\n    OcclusionType: " + foldingFeature.OcclusionType    // FoldingFeatureOcclusionType.None or Full
                                      + "\n    Orientation: " + foldingFeature.Orientation        // FoldingFeatureOrientation.Vertical or Horizontal
                                      + "\n    State: " + foldingFeature.State;                   // FoldingFeatureState.Flat or HalfOpened
                        this.Log().Debug($"DualMode: {summary}");
                    }
                }
                else
                {
                    this.Log().Debug($"DualMode: DisplayFeature is not a fold or hinge");
                }
            }
            if (lastFoldingFeature is null)
            {
                this.Log().Debug($"DualMode: App is not spanned, on a single screen");
            }

            // FUTURE USE
            //_layoutChanged?.Invoke(this, lastFoldingFeature);
        }
コード例 #2
0
 public void UpdateWindowLayout(WindowLayoutInfo windowLayoutInfo)
 {
     this.windowLayoutInfo = windowLayoutInfo;
     RequestLayout();
 }