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;
}
}
}
}
}
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;
}
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;
}
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;
}
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();
}
Aggregations