Beispiel #1
0
        protected virtual void OnElementSet(Shell shell)
        {
            Profile.FrameBegin();

            Profile.FramePartition("Flyout");
            _flyoutRenderer = CreateShellFlyoutRenderer();

            Profile.FramePartition("Frame");
            _frameLayout = new CustomFrameLayout(AndroidContext)
            {
                LayoutParameters = new LP(LP.MatchParent, LP.MatchParent),
                Id = Platform.GenerateViewId(),
            };

            Profile.FramePartition("SetFitsSystemWindows");
            _frameLayout.SetFitsSystemWindows(true);

            Profile.FramePartition("AttachFlyout");
            _flyoutRenderer.AttachFlyout(this, _frameLayout);

            Profile.FramePartition("AddAppearanceObserver");
            ((IShellController)shell).AddAppearanceObserver(this, shell);

            // Previewer Hack
            Profile.FramePartition("Previewer Hack");
            if (AndroidContext.GetActivity() != null && shell.CurrentItem != null)
            {
                SwitchFragment(FragmentManager, _frameLayout, shell.CurrentItem, false);
            }

            Profile.FrameEnd();
        }
Beispiel #2
0
        void UpdateStatusBarColor(ShellAppearance appearance)
        {
            var activity  = AndroidContext.GetActivity();
            var window    = activity?.Window;
            var decorView = window?.DecorView;

            int statusBarHeight     = AndroidContext.GetStatusBarHeight();
            int navigationBarHeight = AndroidContext.GetNavigationBarHeight();

            // we are using the split drawable here to avoid GPU overdraw.
            // All it really is is a drawable that only draws under the statusbar/bottom bar to make sure
            // we dont draw over areas we dont need to. This has very limited benefits considering its
            // only saving us a flat color fill BUT it helps people not freak out about overdraw.
            AColor color;

            if (appearance != null)
            {
                color = appearance.BackgroundColor.ToPlatform(Color.FromArgb("#03A9F4"));
            }
            else
            {
                color = Color.FromArgb("#03A9F4").ToPlatform();
            }

            if (!(decorView.Background is SplitDrawable splitDrawable) ||
                splitDrawable.Color != color || splitDrawable.TopSize != statusBarHeight || splitDrawable.BottomSize != navigationBarHeight)
            {
                var split = new SplitDrawable(color, statusBarHeight, navigationBarHeight);
                decorView.SetBackground(split);
            }
        }
Beispiel #3
0
        void UpdateStatusBarColor(ShellAppearance appearance)
        {
            Profile.FrameBegin("UpdtStatBarClr");

            var activity  = AndroidContext.GetActivity();
            var window    = activity?.Window;
            var decorView = window?.DecorView;
            var resources = AndroidContext.Resources;

            int statusBarHeight = 0;
            int resourceId      = resources.GetIdentifier("status_bar_height", "dimen", "android");

            if (resourceId > 0)
            {
                statusBarHeight = resources.GetDimensionPixelSize(resourceId);
            }

            int navigationBarHeight = 0;

            resourceId = resources.GetIdentifier("navigation_bar_height", "dimen", "android");
            if (resourceId > 0)
            {
                navigationBarHeight = resources.GetDimensionPixelSize(resourceId);
            }

            // TODO Previewer Hack
            if (decorView != null)
            {
                // we are using the split drawable here to avoid GPU overdraw.
                // All it really is is a drawable that only draws under the statusbar/bottom bar to make sure
                // we dont draw over areas we dont need to. This has very limited benefits considering its
                // only saving us a flat color fill BUT it helps people not freak out about overdraw.
                AColor color;
                if (appearance != null)
                {
                    color = appearance.BackgroundColor.ToAndroid(Color.FromHex("#03A9F4"));
                }
                else
                {
                    color = Color.FromHex("#03A9F4").ToAndroid();
                }

                if (!(decorView.Background is SplitDrawable splitDrawable) ||
                    splitDrawable.Color != color || splitDrawable.TopSize != statusBarHeight || splitDrawable.BottomSize != navigationBarHeight)
                {
                    Profile.FramePartition("Create SplitDrawable");
                    var split = new SplitDrawable(color, statusBarHeight, navigationBarHeight);
                    Profile.FramePartition("SetBackground");
                    decorView.SetBackground(split);
                }
            }

            Profile.FrameEnd("UpdtStatBarClr");
        }