示例#1
0
        public override bool OnInterceptTouchEvent(MotionEvent @event)
        {
            StandOutLayoutParams @params = GetLayoutParams();

            // focus window
            if (@event.Action == MotionEventActions.Down)
            {
                if (mContext.FocusedWindow != this)
                {
                    mContext.focus(id);
                }
            }

            // multitouch
            if (@event.PointerCount >= 2 && Utils.isSet(flags, StandOutFlags.FLAG_WINDOW_PINCH_RESIZE_ENABLE) && (@event.Action & MotionEventActions.Mask) == MotionEventActions.PointerDown)
            {
                touchInfo.scale       = 1;
                touchInfo.dist        = -1;
                touchInfo.firstWidth  = @params.Width;
                touchInfo.firstHeight = @params.Height;
                return(true);
            }

            return(false);
        }
示例#2
0
            public void OnAnimationEnd(Animation animation)
            {
                Log.Debug("FloatingFolder", "Animation ended");
                Screenshot.Visibility = (ViewStates.Gone);

                // post so that screenshot is invisible
                // before anything else happens
                Screenshot.Post(() =>
                {
                    StandOutLayoutParams originalParams = OuterInstance.getParams(Id, Window);

                    Drawable drawable = Screenshot.Drawable;
                    Screenshot.SetImageDrawable(null);

                    @params.Y = @params.Y - originalParams.Height / 2 + drawable.IntrinsicHeight / 2;

                    @params.Width  = originalParams.Width;
                    @params.Height = originalParams.Height;

                    OuterInstance.updateViewLayout(Id, @params);

                    FolderView.Visibility = (ViewStates.Visible);

                    FolderView.StartAnimation(OuterInstance.MFadeIn);
                });
            }
示例#3
0
 public AnimationListenerAnonymousInnerClass2(FloatingFolder outerInstance, int id, Window window, StandOutLayoutParams @params, View folderView, ImageView screenshot)
 {
     this.OuterInstance = outerInstance;
     this.Id            = id;
     this.Window        = window;
     this.@params       = @params;
     this.FolderView    = folderView;
     this.Screenshot    = screenshot;
 }
示例#4
0
 public AnimationListenerAnonymousInnerClass(FloatingFolder outerInstance, int id, StandOutLayoutParams @params, View folderView, ImageView screenshot, Drawable drawable)
 {
     this.OuterInstance = outerInstance;
     this.Id            = id;
     this.@params       = @params;
     this.FolderView    = folderView;
     this.Screenshot    = screenshot;
     this.Drawable      = drawable;
 }
示例#5
0
        //JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
        //ORIGINAL LINE: private void resizeToGridAndSave(final int id, final int cols)
        private void ResizeToGridAndSave(int id, int cols)
        {
            //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
            //ORIGINAL LINE: final wei.mark.standout.ui.Window window = getWindow(id);
            Window window = getWindow(id);

            window.Post(() =>
            {
                FlowLayout flow = (FlowLayout)window.FindViewById(Resource.Id.flow);

                FolderModel folder = MFolders.Get(id);

                int count   = folder.Apps.Count;
                int columns = cols;

                if (cols == -1)
                {
                    columns = flow.GetCols();
                }

                if (columns < 2)
                {
                    columns = 2;
                }

                int rows = count / columns;
                if (count % columns > 0)
                {
                    rows++;
                }

                if (rows < 1)
                {
                    rows = 1;
                }

                int width  = flow.Left + (((ViewGroup)flow.Parent).Width - flow.Right) + columns * SquareWidth;
                int height = width;

                if (count > 0)
                {
                    height = flow.Top + (((ViewGroup)flow.Parent).Height - flow.Bottom) + rows * flow.GetChildHeight();
                }

                StandOutLayoutParams @params = window.GetLayoutParams();
                @params.Width  = width;
                @params.Height = height;
                updateViewLayout(id, @params);

                folder.Width  = width;
                folder.Height = height;

                SaveFolder(folder);
            });
        }
示例#6
0
        //JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
        //ORIGINAL LINE: @Override public boolean onTouchBody(final int id, final wei.mark.standout.ui.Window window, final Android.Views.View view, Android.Views.MotionEvent event)
        public bool OnTouchBody(int id, Window window, View view, MotionEvent @event)
        {
            if (id != APP_SELECTOR_ID && @event.Action == Android.Views.MotionEventActions.Move)
            {
                //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
                //ORIGINAL LINE: final StandOutLayoutParams params = (StandOutLayoutParams) window.getLayoutParams();
                StandOutLayoutParams @params = window.GetLayoutParams();

                //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
                //ORIGINAL LINE: final Android.Views.View folderView = window.findViewById(Resource.id.folder);
                View folderView = window.FindViewById(Resource.Id.folder);
                //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
                //ORIGINAL LINE: final Android.widget.ImageView screenshot = (Android.widget.ImageView) window.findViewById(Resource.id.preview);
                ImageView screenshot = (ImageView)window.FindViewById(Resource.Id.preview);

                FolderModel folder = MFolders.Get(id);

                // if touch edge
                if (@params.X <= 0)
                {
                    // first time touch edge
                    if (folder.FullSize)
                    {
                        folder.FullSize = false;

                        //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
                        //ORIGINAL LINE: final Android.graphics.drawable.Drawable drawable = getResources().getDrawable(Resource.drawable.ic_menu_archive);
                        Drawable drawable = Resources.GetDrawable(Resource.Drawable.ic_menu_archive);

                        screenshot.SetImageDrawable(drawable);

                        MFadeOut.SetAnimationListener(new AnimationListenerAnonymousInnerClass(this, id, @params, folderView, screenshot, drawable));

                        folderView.StartAnimation(MFadeOut);
                    }
                }
                else
                {                 // not touch edge
                    // first time not touch edge
                    if (!folder.FullSize)
                    {
                        folder.FullSize = true;

                        MFadeOut.SetAnimationListener(new AnimationListenerAnonymousInnerClass2(this, id, window, @params, folderView, screenshot));

                        screenshot.StartAnimation(MFadeOut);
                    }
                }
            }

            return(false);
        }
        public virtual void bringToFront(int id)
        {
            XWindow window = getWindow(id);

            if (window == null)
            {
                throw new System.Exception("Tried to bringToFront(" + id
                                           + ") a null window.");
            }

            if (window.visibility == XWindow.VISIBILITY_GONE)
            {
                throw new System.Exception("Tried to bringToFront(" + id
                                           + ") a window that is not shown.");
            }

            if (window.visibility == XWindow.VISIBILITY_TRANSITION)
            {
                return;
            }

            // alert callbacks and cancel if instructed
            if (onBringToFront(id, window))
            {
                //Log.w(TAG, "Window " + id
                //+ " bring to front cancelled by implementation.");
                return;
            }

            StandOutLayoutParams @params = (StandOutLayoutParams)window.getLayoutParams();

            // remove from window manager then add back
            try
            {
                mWindowManager.removeView(window);
            }
            catch // (Exception ex)
            {
                //ex.printStackTrace();
            }
            try
            {
                mWindowManager.addView(window, @params);
            }
            catch //(Exception ex)
            {
                //ex.printStackTrace();
            }
        }
        public virtual bool onTouchHandleResize(int id, XWindow window, View view, MotionEvent @event)
        {
            StandOutLayoutParams @params = (StandOutLayoutParams)window
                                           .getLayoutParams();

            if (@event.getAction() == MotionEvent.ACTION_DOWN)
            {
                window.touchInfo.lastX = (int)@event.getRawX();
                window.touchInfo.lastY = (int)@event.getRawY();

                window.touchInfo.firstX = window.touchInfo.lastX;
                window.touchInfo.firstY = window.touchInfo.lastY;
            }
            else
            if (@event.getAction() == MotionEvent.ACTION_MOVE)
            {
                int deltaX = (int)@event.getRawX() - window.touchInfo.lastX;
                int deltaY = (int)@event.getRawY() - window.touchInfo.lastY;

                // update the size of the window
                @params.width  += deltaX;
                @params.height += deltaY;

                // keep window between min/max width/height
                if (@params.width >= @params.minWidth &&
                    @params.width <= @params.maxWidth)
                {
                    window.touchInfo.lastX = (int)@event.getRawX();
                }

                if (@params.height >= @params.minHeight &&
                    @params.height <= @params.maxHeight)
                {
                    window.touchInfo.lastY = (int)@event.getRawY();
                }

                window.edit().setSize(@params.width, @params.height).commit();
            }

            onResize(id, window, view, @event);

            return(true);
        }
        public virtual XWindow show(int id)
        {
            // get the window corresponding to the id
            XWindow cachedWindow = getWindow(id);
            XWindow window;

            // check cache first
            if (cachedWindow != null)
            {
                window = cachedWindow;
            }
            else
            {
                window = new XWindow(this, id);
            }

            if (window.visibility == XWindow.VISIBILITY_VISIBLE)
            {
                throw new System.Exception("Tried to show(" + id
                                           + ") a window that is already shown.");
            }

            // alert callbacks and cancel if instructed
            if (onShow(id, window))
            {
                //Log.d(TAG, "Window " + id + " show cancelled by implementation.");
                return(null);
            }

            window.visibility = XWindow.VISIBILITY_VISIBLE;

            // get animation
            Animation animation = getShowAnimation(id);

            // get the params corresponding to the id
            StandOutLayoutParams @params = (StandOutLayoutParams)window.getLayoutParams();

            try
            {
                // add the view to the window manager
                mWindowManager.addView(window, @params);

                // animate
                if (animation != null)
                {
                    window.getChildAt(0).startAnimation(animation);
                }
            }
            catch // (Exception ex)
            {
                //ex.printStackTrace();
            }

            // add view to internal map
            sWindowCache.putCache(id, GetType().ToClass(), window);

            // get the persistent notification
            var nn           = getPersistentNotification(id);
            var notification = nn.Notification;

            // show the notification
            if (notification != null)
            {
                notification.flags = notification.flags
                                     | Notification.FLAG_NO_CLEAR;

                nn.update = delegate
                {
                    mNotificationManager.notify(
                        GetType().ToClass().GetHashCode()
                        + ONGOING_NOTIFICATION_ID, notification);
                };
                // only show notification if not shown before
                if (!startedForeground)
                {
                    // tell Android system to show notification
                    startForeground(
                        GetType().ToClass().GetHashCode() + ONGOING_NOTIFICATION_ID,
                        notification);
                    startedForeground = true;
                }
                else
                {
                    // update notification if shown before
                    nn.update();
                }
            }
            else
            {
                // notification can only be null if it was provided before
                if (!startedForeground)
                {
                    throw new System.Exception("Your StandOutWindow service must"
                                               + "provide a persistent notification."
                                               + "The notification prevents Android"
                                               + "from killing your service in low"
                                               + "memory situations.");
                }
            }

            focus(id);

            return(window);
        }