Search in sources :

Example 46 with Point

use of android.graphics.Point in project platform_frameworks_base by android.

the class WallpaperManagerService method setDimensionHints.

public void setDimensionHints(int width, int height, String callingPackage) throws RemoteException {
    checkPermission(android.Manifest.permission.SET_WALLPAPER_HINTS);
    if (!isWallpaperSupported(callingPackage)) {
        return;
    }
    synchronized (mLock) {
        int userId = UserHandle.getCallingUserId();
        WallpaperData wallpaper = getWallpaperSafeLocked(userId, FLAG_SYSTEM);
        if (width <= 0 || height <= 0) {
            throw new IllegalArgumentException("width and height must be > 0");
        }
        // Make sure it is at least as large as the display.
        Point displaySize = getDefaultDisplaySize();
        width = Math.max(width, displaySize.x);
        height = Math.max(height, displaySize.y);
        if (width != wallpaper.width || height != wallpaper.height) {
            wallpaper.width = width;
            wallpaper.height = height;
            saveSettingsLocked(userId);
            // Don't change the properties now
            if (mCurrentUserId != userId)
                return;
            if (wallpaper.connection != null) {
                if (wallpaper.connection.mEngine != null) {
                    try {
                        wallpaper.connection.mEngine.setDesiredSize(width, height);
                    } catch (RemoteException e) {
                    }
                    notifyCallbacksLocked(wallpaper);
                } else if (wallpaper.connection.mService != null) {
                    // We've attached to the service but the engine hasn't attached back to us
                    // yet. This means it will be created with the previous dimensions, so we
                    // need to update it to the new dimensions once it attaches.
                    wallpaper.connection.mDimensionsChanged = true;
                }
            }
        }
    }
}
Also used : Point(android.graphics.Point) RemoteException(android.os.RemoteException) Point(android.graphics.Point)

Example 47 with Point

use of android.graphics.Point in project platform_frameworks_base by android.

the class TaskPositioner method register.

/**
     * @param display The Display that the window being dragged is on.
     */
void register(Display display) {
    if (DEBUG_TASK_POSITIONING) {
        Slog.d(TAG, "Registering task positioner");
    }
    if (mClientChannel != null) {
        Slog.e(TAG, "Task positioner already registered");
        return;
    }
    mDisplay = display;
    mDisplay.getMetrics(mDisplayMetrics);
    final InputChannel[] channels = InputChannel.openInputChannelPair(TAG);
    mServerChannel = channels[0];
    mClientChannel = channels[1];
    mService.mInputManager.registerInputChannel(mServerChannel, null);
    mInputEventReceiver = new WindowPositionerEventReceiver(mClientChannel, mService.mH.getLooper(), mService.mChoreographer);
    mDragApplicationHandle = new InputApplicationHandle(null);
    mDragApplicationHandle.name = TAG;
    mDragApplicationHandle.dispatchingTimeoutNanos = WindowManagerService.DEFAULT_INPUT_DISPATCHING_TIMEOUT_NANOS;
    mDragWindowHandle = new InputWindowHandle(mDragApplicationHandle, null, mDisplay.getDisplayId());
    mDragWindowHandle.name = TAG;
    mDragWindowHandle.inputChannel = mServerChannel;
    mDragWindowHandle.layer = mService.getDragLayerLocked();
    mDragWindowHandle.layoutParamsFlags = 0;
    mDragWindowHandle.layoutParamsType = WindowManager.LayoutParams.TYPE_DRAG;
    mDragWindowHandle.dispatchingTimeoutNanos = WindowManagerService.DEFAULT_INPUT_DISPATCHING_TIMEOUT_NANOS;
    mDragWindowHandle.visible = true;
    mDragWindowHandle.canReceiveKeys = false;
    mDragWindowHandle.hasFocus = true;
    mDragWindowHandle.hasWallpaper = false;
    mDragWindowHandle.paused = false;
    mDragWindowHandle.ownerPid = Process.myPid();
    mDragWindowHandle.ownerUid = Process.myUid();
    mDragWindowHandle.inputFeatures = 0;
    mDragWindowHandle.scaleFactor = 1.0f;
    // The drag window cannot receive new touches.
    mDragWindowHandle.touchableRegion.setEmpty();
    // The drag window covers the entire display
    mDragWindowHandle.frameLeft = 0;
    mDragWindowHandle.frameTop = 0;
    final Point p = new Point();
    mDisplay.getRealSize(p);
    mDragWindowHandle.frameRight = p.x;
    mDragWindowHandle.frameBottom = p.y;
    // Pause rotations before a drag.
    if (DEBUG_ORIENTATION) {
        Slog.d(TAG, "Pausing rotation during re-position");
    }
    mService.pauseRotationLocked();
    mDimLayer = new DimLayer(mService, this, mDisplay.getDisplayId(), TAG_LOCAL);
    mSideMargin = dipToPixel(SIDE_MARGIN_DIP, mDisplayMetrics);
    mMinVisibleWidth = dipToPixel(MINIMUM_VISIBLE_WIDTH_IN_DP, mDisplayMetrics);
    mMinVisibleHeight = dipToPixel(MINIMUM_VISIBLE_HEIGHT_IN_DP, mDisplayMetrics);
    mDragEnded = false;
}
Also used : InputApplicationHandle(com.android.server.input.InputApplicationHandle) InputChannel(android.view.InputChannel) Point(android.graphics.Point) InputWindowHandle(com.android.server.input.InputWindowHandle)

Example 48 with Point

use of android.graphics.Point in project weiciyuan by qii.

the class Calculator method getShowcasePointFromView.

public static final Point getShowcasePointFromView(View view, ShowcaseView.ConfigOptions options) {
    Point result = new Point();
    if (options.insert == ShowcaseView.INSERT_TO_VIEW) {
        result.x = view.getLeft() + view.getWidth() / 2;
        result.y = view.getTop() + view.getHeight() / 2;
    } else {
        int[] coordinates = new int[2];
        view.getLocationInWindow(coordinates);
        result.x = coordinates[0] + view.getWidth() / 2;
        result.y = coordinates[1] + view.getHeight() / 2;
    }
    return result;
}
Also used : Point(android.graphics.Point)

Example 49 with Point

use of android.graphics.Point in project weiciyuan by qii.

the class PointAnimator method ofPoints.

public static Animator ofPoints(Object object, String xMethod, String yMethod, Point... values) {
    AnimatorSet set = new AnimatorSet();
    int[] xValues = new int[values.length];
    int[] yValues = new int[values.length];
    for (int i = 0; i < values.length; i++) {
        xValues[i] = values[i].x;
        yValues[i] = values[i].y;
    }
    ObjectAnimator xAnimator = ObjectAnimator.ofInt(object, xMethod, xValues);
    ObjectAnimator yAnimator = ObjectAnimator.ofInt(object, yMethod, yValues);
    set.playTogether(xAnimator, yAnimator);
    return set;
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) AnimatorSet(android.animation.AnimatorSet) Point(android.graphics.Point)

Example 50 with Point

use of android.graphics.Point in project weiciyuan by qii.

the class GalleryActivity method animateClose.

private void animateClose(PhotoView imageView) {
    currentViewPositionLayout.setVisibility(View.INVISIBLE);
    animationView.setImageDrawable(imageView.getDrawable());
    pager.setVisibility(View.INVISIBLE);
    final Rect startBounds = rect;
    final Rect finalBounds = new Rect();
    final Point globalOffset = new Point();
    animationView.getGlobalVisibleRect(finalBounds, globalOffset);
    startBounds.offset(-globalOffset.x, -globalOffset.y);
    finalBounds.offset(-globalOffset.x, -globalOffset.y);
    float startScale;
    if ((float) finalBounds.width() / finalBounds.height() > (float) startBounds.width() / startBounds.height()) {
        // Extend start bounds horizontally
        startScale = (float) startBounds.height() / finalBounds.height();
        float startWidth = startScale * finalBounds.width();
        float deltaWidth = (startWidth - startBounds.width()) / 2;
        startBounds.left -= deltaWidth;
        startBounds.right += deltaWidth;
    } else {
        // Extend start bounds vertically
        startScale = (float) startBounds.width() / finalBounds.width();
        float startHeight = startScale * finalBounds.height();
        float deltaHeight = (startHeight - startBounds.height()) / 2;
        startBounds.top -= deltaHeight;
        startBounds.bottom += deltaHeight;
    }
    animationView.setPivotX(0f);
    animationView.setPivotY(0f);
    final float startScaleFinal = startScale;
    animationView.animate().setInterpolator(new DecelerateInterpolator()).x(startBounds.left).y(startBounds.top).scaleY(startScaleFinal).scaleX(startScaleFinal).setDuration(300).setListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            GalleryActivity.this.finish();
            overridePendingTransition(0, 0);
        }
    }).start();
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) Rect(android.graphics.Rect) Animator(android.animation.Animator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) Point(android.graphics.Point)

Aggregations

Point (android.graphics.Point)1151 Display (android.view.Display)217 Rect (android.graphics.Rect)194 Paint (android.graphics.Paint)170 WindowManager (android.view.WindowManager)138 RemoteException (android.os.RemoteException)76 RectF (android.graphics.RectF)62 Bitmap (android.graphics.Bitmap)54 Resources (android.content.res.Resources)41 View (android.view.View)41 ArrayList (java.util.ArrayList)40 ImageView (android.widget.ImageView)37 Camera (android.hardware.Camera)36 Canvas (android.graphics.Canvas)31 Matrix (android.graphics.Matrix)29 Animator (android.animation.Animator)27 SuppressLint (android.annotation.SuppressLint)27 Configuration (android.content.res.Configuration)26 IOException (java.io.IOException)24 Message (android.os.Message)22