Ejemplo n.º 1
0
            public override void OnApplyWindowInsets(WindowInsets insets)
            {
                base.OnApplyWindowInsets(insets);
                if (Log.IsLoggable(Tag, LogPriority.Debug))
                {
                    Log.Debug(Tag, "OnApplyWindowInsets: " + (insets.IsRound ? "round" : "square"));
                }

                // Load resources that have alternate values for round watches.
                var  resources = owner.Resources;
                bool isRound   = insets.IsRound;

                xOffset = resources.GetDimension(isRound
                                        ? Resource.Dimension.DigitalXOffsetRound : Resource.Dimension.DigitalXOffset);
                var textSize = resources.GetDimension(isRound
                                        ? Resource.Dimension.DigitalTextSizeRound : Resource.Dimension.DigitalTextSize);
                var amPmSize = resources.GetDimension(isRound
                                        ? Resource.Dimension.DigitalAmPmSizeRound : Resource.Dimension.DigitalAmPmSize);

                hourPaint.TextSize   = textSize;
                minutePaint.TextSize = textSize;
                secondPaint.TextSize = textSize;
                amPmPaint.TextSize   = amPmSize;
                colonPaint.TextSize  = textSize;

                colonWidth = colonPaint.MeasureText(ColonString);
            }
Ejemplo n.º 2
0
        public override WindowInsets OnApplyWindowInsets(WindowInsets insets)
        {
            Android.Util.Log.Debug(this.GetType().Name, "OnApplyWindowInsets()");



            return(base.OnApplyWindowInsets(insets));
        }
Ejemplo n.º 3
0
            public WindowInsets OnApplyWindowInsets(View v, WindowInsets insets)
            {
                _insetsListener?.Invoke(this, insets);
                // We need to consume insets here since we will handle them in the Window.Android.cs
#pragma warning disable 618
                return(insets.ConsumeSystemWindowInsets());

#pragma warning restore 618
            }
Ejemplo n.º 4
0
            public WindowInsets OnApplyWindowInsets(View view, WindowInsets insets)
            {
                var c = insets.DisplayCutout;

                if (c != null)
                {
                    view.SetPadding(c.SafeInsetLeft, c.SafeInsetTop, c.SafeInsetRight, c.SafeInsetBottom);
                }
                return(insets);
            }
Ejemplo n.º 5
0
        public override WindowInsets OnApplyWindowInsets(WindowInsets insets)
        {
            var leftPadding = PaddingLeft;

            var result = base.OnApplyWindowInsets(insets);

            SetPadding(leftPadding, PaddingTop, PaddingRight, PaddingBottom);

            return(result);
        }
Ejemplo n.º 6
0
        private void MeasureInsets(PopupWindow sender, WindowInsets insets)
        {
            Insets = new Thickness(
                ViewHelper.PhysicalToLogicalPixels(insets.SystemWindowInsetLeft),
                ViewHelper.PhysicalToLogicalPixels(insets.SystemWindowInsetTop),
                ViewHelper.PhysicalToLogicalPixels(insets.SystemWindowInsetRight),
                ViewHelper.PhysicalToLogicalPixels(insets.SystemWindowInsetBottom)
                );

            InsetsChanged?.Invoke(Insets);
        }
Ejemplo n.º 7
0
		public WindowInsets OnApplyWindowInsets (View v, WindowInsets insets)
		{
			// Adjust page margins
			// A little extra horizontal spacing between pages looks a but less crouded on a round display
			bool round = insets.IsRound;
			int rowMargin = res.GetDimensionPixelOffset (Resource.Dimension.page_row_margin);
			int colMargin = res.GetDimensionPixelOffset (
				                round ? Resource.Dimension.page_column_margin_round : Resource.Dimension.page_column_margin);
			pager.SetPageMargins (rowMargin, colMargin);
			return insets;

		}
Ejemplo n.º 8
0
        public WindowInsets OnApplyWindowInsets(View v, WindowInsets insets)
        {
            // Adjust page margins
            // A little extra horizontal spacing between pages looks a but less crouded on a round display
            bool round     = insets.IsRound;
            int  rowMargin = res.GetDimensionPixelOffset(Resource.Dimension.page_row_margin);
            int  colMargin = res.GetDimensionPixelOffset(
                round ? Resource.Dimension.page_column_margin_round : Resource.Dimension.page_column_margin);

            pager.SetPageMargins(rowMargin, colMargin);
            return(insets);
        }
Ejemplo n.º 9
0
        private void MeasureInsets(PopupWindow sender, WindowInsets insets)
        {
#pragma warning disable 618
            Insets = new Thickness(
                ViewHelper.PhysicalToLogicalPixels(insets.SystemWindowInsetLeft),
                ViewHelper.PhysicalToLogicalPixels(insets.SystemWindowInsetTop),
                ViewHelper.PhysicalToLogicalPixels(insets.SystemWindowInsetRight),
                ViewHelper.PhysicalToLogicalPixels(insets.SystemWindowInsetBottom)
                );
#pragma warning restore 618

            InsetsChanged?.Invoke(Insets);
        }
            /// <summary>
            ///		Invoked when applying <see cref="WindowInsets"/>.
            /// </summary>
            /// <param name="insets">Applicable <see cref="WindowInsets"/> object</param>
            /// <remarks>It is possible to determine whether Android Wear's display is round.</remarks>
            public override void OnApplyWindowInsets(WindowInsets insets)
            {
                base.OnApplyWindowInsets(insets);

#if DEBUG
                if (Log.IsLoggable(logTag, LogPriority.Info))
                {
                    Log.Info(logTag, $"{nameof( OnApplyWindowInsets )}: Round = {insets.IsRound}");
                }
#endif

                // TODO: Writes here, the processing to set according to the shape of the window.
                //bool isRound = insets.IsRound;
            }
Ejemplo n.º 11
0
            /// <summary>
            ///		<see cref="WindowInsets"/>を適用する時に実行します。
            /// </summary>
            /// <param name="insets">適用される<see cref="WindowInsets"/>オブジェクト</param>
            /// <remarks>Android Wearが丸形がどうかを、このメソッド内で判別することができます。</remarks>
            public override void OnApplyWindowInsets(WindowInsets insets)
            {
                base.OnApplyWindowInsets(insets);

//#if DEBUG
//				if( Log.IsLoggable( logTag, LogPriority.Info ) ) {
//					Log.Info( logTag, $"{nameof( OnApplyWindowInsets )}: Round = {insets.IsRound}" );
//				}
//#endif

                // TODO: ウィンドウの形状によって設定する処理を入れます。
                // Android Wearが丸形かどうかを判別します。
                //bool isRound = insets.IsRound;
            }
Ejemplo n.º 12
0
        public override WindowInsets OnApplyWindowInsets(WindowInsets insets)
        {
            // We need to make sure we retain left padding.
            // Failure to do so will result in the padding being wrong if you set FlyoutBehavior to Locked
            // and then rotate the device.

            var leftPadding = PaddingLeft;

            var result = base.OnApplyWindowInsets(insets);

            SetPadding(leftPadding, PaddingTop, PaddingRight, PaddingBottom);

            return(result);
        }
            /// <summary>
            ///		Invoked when applying <see cref="WindowInsets"/>.
            /// </summary>
            /// <param name="insets">Applicable <see cref="WindowInsets"/> object</param>
            /// <remarks>It is possible to determine whether Android Wear's display is round.</remarks>
            public override void OnApplyWindowInsets(WindowInsets insets)
            {
                base.OnApplyWindowInsets(insets);

#if DEBUG
                if (Log.IsLoggable(logTag, LogPriority.Info))
                {
                    Log.Info(logTag, $"{nameof( OnApplyWindowInsets )}: Round = {insets.IsRound}");
                }
#endif

                // TODO: Writes here, the processing to set according to the shape of the window.
                bool isRound  = insets.IsRound;
                var  xOffset  = owner.Resources.GetDimension(isRound ? Resource.Dimension.digital_x_offset_round : Resource.Dimension.digital_x_offset);
                var  textSize = owner.Resources.GetDimension(isRound ? Resource.Dimension.digital_text_size_round : Resource.Dimension.digital_text_size);
                digitalTimeText.XOffset        = xOffset;
                digitalTimeText.Paint.TextSize = textSize;
            }
            /// <summary>
            ///		<see cref="WindowInsets"/>を適用する時に実行します。
            /// </summary>
            /// <param name="insets">適用される<see cref="WindowInsets"/>オブジェクト</param>
            /// <remarks>Android Wearが丸形がどうかを、このメソッド内で判別することができます。</remarks>
            public override void OnApplyWindowInsets(WindowInsets insets)
            {
                base.OnApplyWindowInsets(insets);

#if DEBUG
                if (Log.IsLoggable(logTag, LogPriority.Info))
                {
                    Log.Info(logTag, $"{nameof( OnApplyWindowInsets )}: Round = {insets.IsRound}");
                }
#endif

                // TODO: ウィンドウの形状によって設定する処理を入れます。
                // Android Wearが丸形かどうかを判別します。
                bool isRound  = insets.IsRound;
                var  xOffset  = owner.Resources.GetDimension(isRound ? Resource.Dimension.digital_x_offset_round : Resource.Dimension.digital_x_offset);
                var  textSize = owner.Resources.GetDimension(isRound ? Resource.Dimension.digital_text_size_round : Resource.Dimension.digital_text_size);
                digitalTimeText.XOffset        = xOffset;
                digitalTimeText.Paint.TextSize = textSize;
            }
Ejemplo n.º 15
0
            public WindowInsets OnApplyWindowInsets(View view, WindowInsets insets)
            {
                if (Build.VERSION.SdkInt < BuildVersionCodes.P || insets.DisplayCutout == null)
                {
                    owner.SafeAreaInsets = Rectangle.Empty;
                }
                else
                {
                    var   displayCutout = insets.DisplayCutout;
                    float pixelScale    = Current.PixelScale;

                    owner.SafeAreaInsets = new Rectangle(
                        displayCutout.SafeInsetLeft / pixelScale,
                        displayCutout.SafeInsetTop / pixelScale,
                        displayCutout.SafeInsetRight / pixelScale,
                        displayCutout.SafeInsetBottom / pixelScale
                        );
                }

                owner.RaiseSafeAreaInsetsChanged();
                return(view.OnApplyWindowInsets(insets));
            }
Ejemplo n.º 16
0
        public static (Int32 width, Int32 height) GetScreenPixelSize(IWindowManager manager)
        {
            if (Build.VERSION.SdkInt < BuildVersionCodes.R)
            {
                DisplayMetrics displayMetrics = new DisplayMetrics();

#pragma warning disable CS0618
                manager.DefaultDisplay.GetMetrics(displayMetrics);
#pragma warning restore CS0618

                return(displayMetrics.WidthPixels, displayMetrics.HeightPixels);
            }

            WindowMetrics windowMetrics = manager.CurrentWindowMetrics;
            WindowInsets  windowInsets  = windowMetrics.WindowInsets;

            Int32  mask   = WindowInsets.Type.NavigationBars() | WindowInsets.Type.DisplayCutout();
            Insets insets = windowInsets.GetInsetsIgnoringVisibility(mask);

            Size insetsSize = new Size(insets.Right + insets.Left, insets.Top + insets.Bottom);
            Rect bounds     = windowMetrics.Bounds;
            return(bounds.Width() - insetsSize.Width, bounds.Height() - insetsSize.Height);
        }
Ejemplo n.º 17
0
 public override WindowInsets OnApplyWindowInsets(WindowInsets insets)
 {
     if (Build.VERSION.SdkInt >= Build.VERSION_CODES.Lollipop)
     {
         int paddingSize = insets.SystemWindowInsetBottom;
         int barSize     = mNavigationView.DefaultBarSize;
         paddingSize = paddingSize == barSize ? 0 : paddingSize;
         mContentLayout.SetPaddingRelative(0, 0, 0, paddingSize);
         RelativeLayout.LayoutParams layoutParams = (LayoutParams)mContentLayout.LayoutParameters;
         if (paddingSize > 0 && !mNavigationView.Landscape)
         {
             layoutParams.BottomMargin = -barSize;
         }
         else
         {
             layoutParams.BottomMargin = 0;
         }
         return(base.OnApplyWindowInsets(insets.ReplaceSystemWindowInsets(0, 0, 0, 0)));
     }
     else
     {
         return(insets);
     }
 }
            public override void OnApplyWindowInsets(WindowInsets insets)
            {
                base.OnApplyWindowInsets (insets);
                if (Log.IsLoggable (Tag, LogPriority.Debug)) {
                    Log.Debug (Tag, "OnApplyWindowInsets: " + (insets.IsRound ? "round" : "square"));
                }

                // Load resources that have alternate values for round watches.
                var resources = owner.Resources;
                bool isRound = insets.IsRound;
                xOffset = resources.GetDimension (isRound
                    ? Resource.Dimension.DigitalXOffsetRound : Resource.Dimension.DigitalXOffset);
                var textSize = resources.GetDimension (isRound
                    ? Resource.Dimension.DigitalTextSizeRound : Resource.Dimension.DigitalTextSize);
                var amPmSize = resources.GetDimension (isRound
                    ? Resource.Dimension.DigitalAmPmSizeRound : Resource.Dimension.DigitalAmPmSize);

                hourPaint.TextSize = textSize;
                minutePaint.TextSize = textSize;
                secondPaint.TextSize = textSize;
                amPmPaint.TextSize = amPmSize;
                colonPaint.TextSize = textSize;

                colonWidth = colonPaint.MeasureText (ColonString);
            }
Ejemplo n.º 19
0
 public WindowInsets OnApplyWindowInsets(View v, WindowInsets insets)
 {
     _insetsListener?.Invoke(this, insets);
     // We need to consume insets here since we will handle them in the Window.Android.cs
     return(insets.ConsumeSystemWindowInsets());
 }
Ejemplo n.º 20
0
        public override WindowInsets OnApplyWindowInsets(WindowInsets insets)
        {
            Android.Util.Log.Debug(this.GetType().Name, "OnApplyWindowInsets()");



            return base.OnApplyWindowInsets(insets);
        }