示例#1
0
        private void TapAnimation(long duration, byte startAlpha = 255, byte endAlpha = 0)
        {
            if (IsDisposed)
            {
                return;
            }

            if (_viewOverlay.Parent == null)
            {
                Container.AddView(_viewOverlay);
            }
            _viewOverlay.BringToFront();

            var start = _color;
            var end   = _color;

            start.A = startAlpha;
            end.A   = endAlpha;

            _animator = ObjectAnimator.OfObject(_viewOverlay, "BackgroundColor", new ArgbEvaluator(), start.ToArgb(), end.ToArgb());
            _animator.SetDuration(duration);
            _animator.RepeatCount = 0;
            _animator.RepeatMode  = ValueAnimatorRepeatMode.Restart;
            _animator.Start();
            _animator.AnimationEnd += AnimationOnAnimationEnd;
        }
示例#2
0
        void ForceStartRipple(float x, float y)
        {
            if (IsDisposed || !(_viewOverlay.Background is RippleDrawable bc))
            {
                return;
            }

            _viewOverlay.BringToFront();
            bc.SetHotspot(x, y);
            _viewOverlay.Pressed = true;
        }
示例#3
0
        private void ForceStartRipple(float x, float y)
        {
            if (IsDisposed || !(viewOverlay.Background is RippleDrawable drawable))
            {
                return;
            }

            viewOverlay.BringToFront();

            drawable.SetHotspot(x, y);

            viewOverlay.Pressed = true;
        }
示例#4
0
        public static FrameLayout Add(ViewGroup group, object instance)
        {
            if (Collection.ContainsKey(group))
            {
                Collection[group].Objects.Add(instance);
                return(Collection[group].OverlayView);
            }

            var view = new FrameLayout(group.Context)
            {
                LayoutParameters = new ViewGroup.LayoutParams(-1, -1),
                Clickable        = true,
                LongClickable    = true,
            };

            group.LayoutChange += ViewOnLayoutChange;
            group.AddView(view);
            view.BringToFront();

            Collection.Add(group, new ViewContainer {
                OverlayView = view, Objects = { instance }
            });

            return(view);
        }
示例#5
0
        private void AddRipple()
        {
            var color = TouchEffect.GetColor(Element);

            if (color == Color.Default)
            {
                return;
            }
            _color = color.ToAndroid();

            if (Element is Layout)
            {
                _rippleOverlay = new FrameLayout(Container.Context)
                {
                    LayoutParameters = new ViewGroup.LayoutParams(-1, -1)
                };

                _rippleListener = new ContainerOnLayoutChangeListener(_rippleOverlay);
                _view.AddOnLayoutChangeListener(_rippleListener);

                ((ViewGroup)_view).AddView(_rippleOverlay);

                _rippleOverlay.BringToFront();
                _rippleOverlay.Foreground = CreateRipple(Color.Accent.ToAndroid());
            }
            else
            {
                _orgDrawable     = _view.Background;
                _view.Background = CreateRipple(Color.Accent.ToAndroid());
            }

            _ripple.SetColor(GetPressedColorSelector(_color));
        }
示例#6
0
        protected override void OnAttached()
        {
            _effect         = Element.GetTouchEff();
            _effect.Control = Element as VisualElement;
            _effect.ForceUpdateState(false);

            if (Container != null)
            {
                Container.Touch += OnTouch;
            }
            else if (Control != null)
            {
                Control.Touch += OnTouch;
            }

            if (_effect.NativeAnimation)
            {
                View.Clickable     = true;
                View.LongClickable = true;
                _viewOverlay       = new FrameLayout(Container.Context)
                {
                    LayoutParameters = new ViewGroup.LayoutParams(-1, -1),
                    Clickable        = false,
                    Focusable        = false,
                };
                View.LayoutChange += LayoutChange;

                _ripple                 = CreateRipple();
                _ripple.Radius          = (int)(View.Context.Resources.DisplayMetrics.Density * _effect.NativeAnimationRadius);
                _viewOverlay.Background = _ripple;

                Container.AddView(_viewOverlay);
                _viewOverlay.BringToFront();
            }
        }
示例#7
0
        protected override void OnAttached()
        {
            if (Touch.GetLongTap(Element) != null)
            {
                timer          = new System.Timers.Timer();
                timer.Elapsed += OnTimerEvent;
            }
            isEnabled                = Touch.GetIsEnabled(Element);
            View.Clickable           = true;
            View.LongClickable       = true;
            View.SoundEffectsEnabled = true;

            viewOverlay = new FrameLayout(Container.Context)
            {
                LayoutParameters = new ViewGroup.LayoutParams(-1, -1),
                Clickable        = false,
                Focusable        = false,
            };
            Container.LayoutChange += ViewOnLayoutChange;

            if (EnableRipple)
            {
                viewOverlay.Background = CreateRipple(color);
            }

            SetEffectColor();
            View.Touch += OnTouch;

            Container.AddView(viewOverlay);
            viewOverlay.BringToFront();
        }
示例#8
0
        protected override void OnAttached()
        {
            if (Control is ListView || Control is ScrollView)
            {
                return;
            }

            View.Clickable     = true;
            View.LongClickable = true;
            _viewOverlay       = new FrameLayout(Container.Context)
            {
                LayoutParameters = new ViewGroup.LayoutParams(-1, -1),
                Clickable        = false,
                Focusable        = false,
            };
            Container.LayoutChange += ViewOnLayoutChange;

            if (EnableRipple)
            {
                _viewOverlay.Background = CreateRipple(_color);
            }

            SetEffectColor();
            TouchCollector.Add(View, OnTouch);

            Container.AddView(_viewOverlay);
            _viewOverlay.BringToFront();
        }
示例#9
0
        protected override void OnAttached()
        {
            // Gesture touches
            gesture                  = new GestureTouchSam(this, null, View);
            View.TouchDelegate       = gesture;
            View.Clickable           = true;
            View.LongClickable       = true;
            View.SoundEffectsEnabled = true;

            // Animation tap
            overlayAnimation = new FrameLayout(Container.Context)
            {
                LayoutParameters = new ViewGroup.LayoutParams(-1, -1),
                Clickable        = false,
                Focusable        = false,
            };

            Container.AddView(overlayAnimation);
            Container.LayoutChange += OnViewLayoutChanged;
            overlayAnimation.BringToFront();

            if (IsSdk21)
            {
                tapColor = Touch.GetColor(Element).ToAndroid();
                overlayAnimation.Background = CreateRipple(tapColor);
            }

            // Updates
            UpdateAnimationColor();
            UpdateLongTapCommand();
            UpdateLongTapLatency();
        }
示例#10
0
 private bool StartRipple(float x, float y)
 {
     if (_effect.NativeAnimation && _viewOverlay.Background is RippleDrawable)
     {
         _viewOverlay.BringToFront();
         _ripple.SetHotspot(x, y);
         _viewOverlay.Pressed = true;
         return(true);
     }
     return(false);
 }
示例#11
0
        private void BringFrameToFront(int id)
        {
            FrameLayout frame = FindViewById <FrameLayout>(id);

            if (frame == null)
            {
                return;
            }

            frame.BringToFront();
        }
示例#12
0
        protected void InitControls()
        {
            // Register.
            _rootContainer  = (LinearLayout)FindViewById(Resource.Id.rootContainer);
            _loginContainer = (LinearLayout)FindViewById(Resource.Id.loginContainer);
            _email          = (EditText)FindViewById(Resource.Id.email);
            _password       = (EditText)FindViewById(Resource.Id.password);
            _loginButton    = (Button)FindViewById(Resource.Id.loginButton);
            _spinner        = (FrameLayout)FindViewById(Resource.Id.progress_overlay);
            _yourTeslas     = (TextView)FindViewById(Resource.Id.yourTeslas);

            _spinner.BringToFront();
        }
示例#13
0
        public override void AddView(View child)
        {
            /*if(child.Parent != null)
             *  ((ViewGroup)child.Parent).RemoveView(child);*/

            base.AddView(child);

            MainView = child;

            if (_Overlay != null)
            {
                _Overlay.BringToFront();
            }
        }
示例#14
0
        void StartRipple(float x, float y)
        {
            if (effect?.IsDisabled ?? true)
            {
                return;
            }

            if (effect.CanExecute && effect.NativeAnimation && viewOverlay?.Background is RippleDrawable)
            {
                UpdateRipple();
                viewOverlay.BringToFront();
                ripple.SetHotspot(x, y);
                viewOverlay.Pressed = true;
            }
        }
示例#15
0
        void View_Touch(object sender, Android.Views.View.TouchEventArgs e)
        {
            if (e.Event.Action == MotionEventActions.Down) {
                Container.AddView(_layer);
                _layer.Top = 0;
                _layer.Left = 0;
                _layer.Right = _view.Width;
                _layer.Bottom = _view.Height;
                _layer.BringToFront();
            }
            if (e.Event.Action == MotionEventActions.Up || e.Event.Action == MotionEventActions.Cancel) {
                Container.RemoveView(_layer);
            }

            e.Handled = false;
        }
        void AddRipple()
        {
            if (_ripple != null)
            {
                return;
            }

            if (Element is Layout || Element is BoxView)
            {
                _rippleOverlay = new FrameLayout(_view.Context);
                _rippleOverlay.LayoutParameters = new ViewGroup.LayoutParams(-1, -1);

                _rippleListener = new ContainerOnLayoutChangeListener(_rippleOverlay);
                _view.AddOnLayoutChangeListener(_rippleListener);

                (_view as ViewGroup).AddView(_rippleOverlay);

                _rippleOverlay.BringToFront();

                _rippleOverlay.Foreground    = CreateRipple(Color.Accent.ToAndroid());
                _rippleOverlay.Clickable     = true;
                _rippleOverlay.LongClickable = true;

                _view.Touch          -= _view_Touch;
                _rippleOverlay.Touch += _view_Touch;
            }
            else if (IsFastRenderer)
            {
                if (_fastListener == null)
                {
                    _fastListener = new FastRendererOnLayoutChangeListener(this);
                    _view.AddOnLayoutChangeListener(_fastListener);
                    _view.RequestLayout();
                    return;
                }
                _view.Foreground = CreateRipple(Color.Accent.ToAndroid());
                _view.Touch     += _view_Touch;
            }
            else
            {
                _orgDrawable     = _view.Background;
                _view.Background = CreateRipple(Color.Accent.ToAndroid());
            }
        }
示例#17
0
        protected override void OnAttached()
        {
            if (View == null)
            {
                return;
            }

            effect = TouchEffect.PickFrom(Element);
            if (effect?.IsDisabled ?? true)
            {
                return;
            }

            effect.Element = (VisualElement)Element;

            View.Touch += OnTouch;
            UpdateClickHandler();

            accessibilityManager = View.Context.GetSystemService(Context.AccessibilityService) as AccessibilityManager;
            if (accessibilityManager != null)
            {
                accessibilityListener = new AccessibilityListener(this);
                accessibilityManager.AddAccessibilityStateChangeListener(accessibilityListener);
                accessibilityManager.AddTouchExplorationStateChangeListener(accessibilityListener);
            }

            if (effect.NativeAnimation && Group != null && AndroidOS.Build.VERSION.SdkInt >= AndroidOS.BuildVersionCodes.Lollipop)
            {
                View.Clickable     = true;
                View.LongClickable = true;
                viewOverlay        = new FrameLayout(Group.Context)
                {
                    LayoutParameters = new ViewGroup.LayoutParams(-1, -1),
                    Clickable        = false,
                    Focusable        = false,
                };
                View.LayoutChange += LayoutChange;

                CreateRipple();
                viewOverlay.Background = ripple;
                Group.AddView(viewOverlay);
                viewOverlay.BringToFront();
            }
        }
示例#18
0
        void AddRipple()
        {
            if (Element is Layout) {
                _rippleOverlay = new FrameLayout(Container.Context);
                _rippleOverlay.LayoutParameters = new ViewGroup.LayoutParams(-1, -1);

                _rippleListener = new ContainerOnLayoutChangeListener(_rippleOverlay);
                _view.AddOnLayoutChangeListener(_rippleListener);

                (_view as ViewGroup).AddView(_rippleOverlay);

                _rippleOverlay.BringToFront();

                _rippleOverlay.Foreground = CreateRipple(Color.Accent.ToAndroid());
            }
            else {
                _orgDrawable = _view.Background;
                _view.Background = CreateRipple(Color.Accent.ToAndroid());
            }
        }
            // Because FastRenderer of Label or Image can't be set ClickListener,
            // insert FrameLayout with same position and same size on the view.
            public void OnLayoutChange(Android.Views.View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom)
            {
                _overlay.Layout(v.Left, v.Top, v.Right, v.Bottom);

                if (_alreadyGotParent)
                {
                    return;
                }

                _parent           = _effect.Control.Parent as Android.Views.ViewGroup;
                _alreadyGotParent = true;

                _parent.AddView(_overlay);

                _overlay.BringToFront();

                _effect._view.Touch -= _effect._view_Touch;
                _effect._view        = _overlay;
                _effect.UpdateEnableRipple();
            }
示例#20
0
        protected override void OnAttached()
        {
            if (View == null)
            {
                return;
            }
            _effect = Element.PickTouchEff();
            if (_effect.IsDisabled)
            {
                return;
            }

            _effect.Control = Element as VisualElement;

            _accessibilityManager = View.Context.GetSystemService(Context.AccessibilityService) as AccessibilityManager;

            _effect.ForceUpdateState(false);

            View.Touch += OnTouch;
            View.Click += OnClick;

            if (_effect.NativeAnimation && Group != null && AndroidOS.Build.VERSION.SdkInt >= AndroidOS.BuildVersionCodes.Lollipop)
            {
                View.Clickable     = true;
                View.LongClickable = true;
                _viewOverlay       = new FrameLayout(Group.Context)
                {
                    LayoutParameters = new ViewGroup.LayoutParams(-1, -1),
                    Clickable        = false,
                    Focusable        = false,
                };
                View.LayoutChange += LayoutChange;

                CreateRipple();
                _viewOverlay.Background = _ripple;
                Group.AddView(_viewOverlay);
                _viewOverlay.BringToFront();
            }
        }
示例#21
0
        protected override void OnAttached()
        {
            host = Touch.GetHost(Element);

            if (host.CommandLongTapItem != null)
            {
                timer          = new System.Timers.Timer();
                timer.Elapsed += OnTimerEvent;
            }
            //View.Clickable = true;
            //View.LongClickable = true;
            //View.SoundEffectsEnabled = true;

            viewOverlay = new FrameLayout(Container.Context)
            {
                LayoutParameters = new ViewGroup.LayoutParams(-1, -1),
                Clickable        = false,
                LongClickable    = false,
                Focusable        = false,
            };
            Container.LayoutChange += ViewOnLayoutChange;

            if (EnableRipple)
            {
                viewOverlay.Background = CreateRipple(color);
            }

            SetEffectColor();
            View.Clickable           = true;
            View.SoundEffectsEnabled = true;
            View.Touch += OnTouch;
            //View.SetOnTouchListener(new ClassClick());
            //View.SetOnLongClickListener(new ClassLongClick());

            Container.AddView(viewOverlay);
            viewOverlay.BringToFront();
        }