use of android.graphics.Rect in project android_frameworks_base by ParanoidAndroid.
the class PieMenu method onDraw.
@Override
protected void onDraw(Canvas canvas) {
if (mOpen) {
int state;
// Draw background
if (mStatusMode != -1 && !mNavbarZero && !mIsProtected) {
canvas.drawARGB((int) (mAnimators[ANIMATOR_DEC_SPEED15].fraction * 0xcc), 0, 0, 0);
}
// Snap points
if (mCenterDistance > mOuterChevronRadius) {
for (int i = 0; i < 3; i++) {
SnapPoint snap = mSnapPoint[i];
mSnapBackground.setAlpha((int) (snap.alpha + (snap.active ? mAnimators[ANIMATOR_SNAP_GROW].fraction * 80 : 0)));
canvas.drawCircle(snap.x, snap.y, (snap.active ? mAnimators[ANIMATOR_SNAP_GROW].fraction * Math.max(getWidth(), getHeight()) * 1.5f : 0), mSnapBackground);
float snapDistanceX = snap.x - mX;
float snapDistanceY = snap.y - mY;
float snapDistance = (float) Math.sqrt(Math.pow(snapDistanceX, 2) + Math.pow(snapDistanceY, 2));
float snapTouch = snapDistance < mSnapRadius * 7 ? 200 - (snapDistance * (200 - snap.alpha) / (mSnapRadius * 7)) : snap.alpha;
mSnapBackground.setAlpha((int) (snapTouch));
int len = (int) (snap.radius * 1.3f);
int thick = (int) (len * 0.2f);
Path plus = new Path();
plus.addRect(snap.x - len / 2, snap.y - thick / 2, snap.x + len / 2, snap.y + thick / 2, Path.Direction.CW);
plus.addRect(snap.x - thick / 2, snap.y - len / 2, snap.x + thick / 2, snap.y + len / 2, Path.Direction.CW);
canvas.drawPath(plus, mSnapBackground);
}
}
// Draw base menu
for (PieItem item : mItems) {
if (!canItemDisplay(item))
continue;
drawItem(canvas, item);
}
// Paint status report only if settings allow
if (mStatusMode != -1 && !mNavbarZero && !mIsProtected) {
// Draw chevron rings
mChevronBackgroundLeft.setAlpha((int) (mAnimators[ANIMATOR_DEC_SPEED15].fraction * mGlowOffsetLeft / 2 * (mPanelOrientation == Gravity.TOP ? 0.2 : 1)));
mChevronBackgroundRight.setAlpha((int) (mAnimators[ANIMATOR_DEC_SPEED15].fraction * mGlowOffsetRight * (mPanelOrientation == Gravity.TOP ? 0.2 : 1)));
if (mStatusPanel.getCurrentViewState() != PieStatusPanel.QUICK_SETTINGS_PANEL) {
state = canvas.save();
canvas.rotate(90, mCenter.x, mCenter.y);
for (int i = 0; i < CHEVRON_FRAGMENTS + 1; i++) {
canvas.drawPath(mChevronPathLeft[i], mChevronBackgroundLeft);
}
canvas.restoreToCount(state);
}
if (mStatusPanel.getCurrentViewState() != PieStatusPanel.NOTIFICATIONS_PANEL) {
state = canvas.save();
canvas.rotate(180 + (1 - mAnimators[ANIMATOR_BATTERY_METER].fraction) * 90, mCenter.x, mCenter.y);
canvas.drawPath(mChevronPathRight, mChevronBackgroundRight);
canvas.restoreToCount(state);
}
// Better not show inverted junk for top pies
if (mPanelOrientation != Gravity.TOP) {
// Draw Battery
mBatteryBackground.setAlpha((int) (mAnimators[ANIMATOR_DEC_SPEED15].fraction * 0x22));
mBatteryJuice.setAlpha((int) (mAnimators[ANIMATOR_ACC_SPEED15].fraction * 0x88));
state = canvas.save();
canvas.rotate(90, mCenter.x, mCenter.y);
canvas.drawPath(mBatteryPathBackground, mBatteryBackground);
canvas.restoreToCount(state);
state = canvas.save();
canvas.rotate(90, mCenter.x, mCenter.y);
canvas.drawPath(mBatteryPathJuice, mBatteryJuice);
canvas.restoreToCount(state);
// Draw clock && AM/PM
state = canvas.save();
canvas.rotate(mClockTextRotation - (1 - mAnimators[ANIMATOR_DEC_SPEED15].fraction) * 90, mCenter.x, mCenter.y);
mClockPaint.setAlpha((int) (mAnimators[ANIMATOR_DEC_SPEED15].fraction * 0xcc));
float lastPos = 0;
for (int i = 0; i < mClockText.length(); i++) {
canvas.drawTextOnPath("" + mClockText.charAt(i), mStatusPath, lastPos, mClockOffset, mClockPaint);
lastPos += mClockTextOffsets[i];
}
mAmPmPaint.setAlpha((int) (mAnimators[ANIMATOR_DEC_SPEED15].fraction * 0xaa));
canvas.drawTextOnPath(mClockTextAmPm, mStatusPath, lastPos - mClockTextAmPmSize, mAmPmOffset, mAmPmPaint);
canvas.restoreToCount(state);
// Device status information and date
mStatusPaint.setAlpha((int) (mAnimators[ANIMATOR_ACC_SPEED15].fraction * 0xaa));
state = canvas.save();
canvas.rotate(mPanel.getDegree() + 180 + (1 - mAnimators[ANIMATOR_DEC_SPEED15].fraction) * 90, mCenter.x, mCenter.y);
if (mPolicy.supportsTelephony()) {
canvas.drawTextOnPath(mPolicy.getNetworkProvider(), mStatusPath, 0, mStatusOffset * 4, mStatusPaint);
}
canvas.drawTextOnPath(mPolicy.getSimpleDate(), mStatusPath, 0, mStatusOffset * 3, mStatusPaint);
canvas.drawTextOnPath(mPanel.getBar().getNotificationData().size() - mHiddenNotification + " " + mContext.getString(R.string.status_bar_latest_events_title).toUpperCase(), mStatusPath, 0, mStatusOffset * 2, mStatusPaint);
canvas.drawTextOnPath(mContext.getString(R.string.quick_settings_wifi_label).toUpperCase() + ": " + mPolicy.getWifiSsid(), mStatusPath, 0, mStatusOffset * 1, mStatusPaint);
canvas.drawTextOnPath(mPolicy.getBatteryLevelReadable(), mStatusPath, 0, mStatusOffset * 0, mStatusPaint);
canvas.restoreToCount(state);
state = canvas.save();
canvas.rotate(mPanel.getDegree() + 180, mCenter.x, mCenter.y);
// Notifications
if (mStatusPanel.getCurrentViewState() != PieStatusPanel.NOTIFICATIONS_PANEL) {
for (int i = 0; i < mNotificationCount && i < 10; i++) {
mNotificationPaint.setAlpha((int) (mAnimators[ANIMATOR_ACC_INC_1 + i].fraction * mGlowOffsetRight));
canvas.drawTextOnPath(mNotificationText[i], mNotificationPath[i], 0, 0, mNotificationPaint);
int IconState = canvas.save();
int posX = (int) (mCenter.x + mNotificationsRadius + i * mNotificationsRowSize);
int posY = (int) (mCenter.y - mNotificationIconSize * 1.4f);
int iconCenter = mNotificationIconSize / 2;
canvas.rotate(90, posX + iconCenter, posY + iconCenter);
canvas.drawBitmap(mNotificationIcon[i], null, new Rect(posX, posY, posX + mNotificationIconSize, posY + mNotificationIconSize), mNotificationPaint);
canvas.restoreToCount(IconState);
}
}
canvas.restoreToCount(state);
}
}
}
}
use of android.graphics.Rect in project android_frameworks_base by ParanoidAndroid.
the class PhoneWindowManager method beginLayoutLw.
/** {@inheritDoc} */
@Override
public void beginLayoutLw(boolean isDefaultDisplay, int displayWidth, int displayHeight, int displayRotation) {
final int overscanLeft, overscanTop, overscanRight, overscanBottom;
if (isDefaultDisplay) {
switch(displayRotation) {
case Surface.ROTATION_90:
overscanLeft = mOverscanTop;
overscanTop = mOverscanRight;
overscanRight = mOverscanBottom;
overscanBottom = mOverscanLeft;
break;
case Surface.ROTATION_180:
overscanLeft = mOverscanRight;
overscanTop = mOverscanBottom;
overscanRight = mOverscanLeft;
overscanBottom = mOverscanTop;
break;
case Surface.ROTATION_270:
overscanLeft = mOverscanBottom;
overscanTop = mOverscanLeft;
overscanRight = mOverscanTop;
overscanBottom = mOverscanRight;
break;
default:
overscanLeft = mOverscanLeft;
overscanTop = mOverscanTop;
overscanRight = mOverscanRight;
overscanBottom = mOverscanBottom;
break;
}
} else {
overscanLeft = 0;
overscanTop = 0;
overscanRight = 0;
overscanBottom = 0;
}
mOverscanScreenLeft = mRestrictedOverscanScreenLeft = 0;
mOverscanScreenTop = mRestrictedOverscanScreenTop = 0;
mOverscanScreenWidth = mRestrictedOverscanScreenWidth = displayWidth;
mOverscanScreenHeight = mRestrictedOverscanScreenHeight = displayHeight;
mSystemLeft = 0;
mSystemTop = 0;
mSystemRight = displayWidth;
mSystemBottom = displayHeight;
mUnrestrictedScreenLeft = overscanLeft;
mUnrestrictedScreenTop = overscanTop;
mUnrestrictedScreenWidth = displayWidth - overscanLeft - overscanRight;
mUnrestrictedScreenHeight = displayHeight - overscanTop - overscanBottom;
mRestrictedScreenLeft = mUnrestrictedScreenLeft;
mRestrictedScreenTop = mUnrestrictedScreenTop;
mRestrictedScreenWidth = mUnrestrictedScreenWidth;
mRestrictedScreenHeight = mUnrestrictedScreenHeight;
mDockLeft = mContentLeft = mStableLeft = mStableFullscreenLeft = mCurLeft = mUnrestrictedScreenLeft;
mDockTop = mContentTop = mStableTop = mStableFullscreenTop = mCurTop = mUnrestrictedScreenTop;
mDockRight = mContentRight = mStableRight = mStableFullscreenRight = mCurRight = displayWidth - overscanRight;
mDockBottom = mContentBottom = mStableBottom = mStableFullscreenBottom = mCurBottom = displayHeight - overscanBottom;
mDockLayer = 0x10000000;
mStatusBarLayer = -1;
// start with the current dock rect, which will be (0,0,displayWidth,displayHeight)
final Rect pf = mTmpParentFrame;
final Rect df = mTmpDisplayFrame;
final Rect of = mTmpOverscanFrame;
final Rect vf = mTmpVisibleFrame;
pf.left = df.left = of.left = vf.left = mDockLeft;
pf.top = df.top = of.top = vf.top = mDockTop;
pf.right = df.right = of.right = vf.right = mDockRight;
pf.bottom = df.bottom = of.bottom = vf.bottom = mDockBottom;
if (isDefaultDisplay) {
// For purposes of putting out fake window up to steal focus, we will
// drive nav being hidden only by whether it is requested.
boolean navVisible = (mLastSystemUiFlags & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0;
// bar and ensure the application doesn't see the event.
if (navVisible) {
if (mHideNavFakeWindow != null) {
mHideNavFakeWindow.dismiss();
mHideNavFakeWindow = null;
}
} else if (mHideNavFakeWindow == null) {
mHideNavFakeWindow = mWindowManagerFuncs.addFakeWindow(mHandler.getLooper(), mHideNavInputEventReceiverFactory, "hidden nav", WindowManager.LayoutParams.TYPE_HIDDEN_NAV_CONSUMER, 0, false, false, true);
}
// For purposes of positioning and showing the nav bar, if we have
// decided that it can't be hidden (because of the screen aspect ratio),
// then take that into account.
navVisible |= !mCanHideNavigationBar;
navVisible &= (Settings.System.getInt(mContext.getContentResolver(), Settings.System.EXPANDED_DESKTOP_STATE, 0) == 0);
if (mNavigationBar != null) {
// Force the navigation bar to its appropriate place and
// size. We need to do this directly, instead of relying on
// it to bubble up from the nav bar, because this needs to
// change atomically with screen rotations.
mNavigationBarOnBottom = (!mNavigationBarCanMove || displayWidth < displayHeight);
if (mNavigationBarOnBottom) {
// It's a system nav bar or a portrait screen; nav bar goes on bottom.
int top = displayHeight - overscanBottom - mNavigationBarHeightForRotation[displayRotation];
mTmpNavigationFrame.set(0, top, displayWidth, displayHeight - overscanBottom);
mStableBottom = mStableFullscreenBottom = mTmpNavigationFrame.top;
if (navVisible) {
mNavigationBar.showLw(true);
mDockBottom = mTmpNavigationFrame.top;
mRestrictedScreenHeight = mDockBottom - mRestrictedScreenTop;
mRestrictedOverscanScreenHeight = mDockBottom - mRestrictedOverscanScreenTop;
} else {
// We currently want to hide the navigation UI.
mNavigationBar.hideLw(true);
}
if (navVisible && !mNavigationBar.isAnimatingLw()) {
// If the nav bar is currently requested to be visible,
// and not in the process of animating on or off, then
// we can tell the app that it is covered by it.
mSystemBottom = mTmpNavigationFrame.top;
}
} else {
// Landscape screen; nav bar goes to the right.
int left = displayWidth - overscanRight - mNavigationBarWidthForRotation[displayRotation];
mTmpNavigationFrame.set(left, 0, displayWidth - overscanRight, displayHeight);
mStableRight = mStableFullscreenRight = mTmpNavigationFrame.left;
if (navVisible) {
mNavigationBar.showLw(true);
mDockRight = mTmpNavigationFrame.left;
mRestrictedScreenWidth = mDockRight - mRestrictedScreenLeft;
mRestrictedOverscanScreenWidth = mDockRight - mRestrictedOverscanScreenLeft;
} else {
// We currently want to hide the navigation UI.
mNavigationBar.hideLw(true);
}
if (navVisible && !mNavigationBar.isAnimatingLw()) {
// If the nav bar is currently requested to be visible,
// and not in the process of animating on or off, then
// we can tell the app that it is covered by it.
mSystemRight = mTmpNavigationFrame.left;
}
}
// Make sure the content and current rectangles are updated to
// account for the restrictions from the navigation bar.
mContentTop = mCurTop = mDockTop;
mContentBottom = mCurBottom = mDockBottom;
mContentLeft = mCurLeft = mDockLeft;
mContentRight = mCurRight = mDockRight;
mStatusBarLayer = mNavigationBar.getSurfaceLayer();
// And compute the final frame.
mNavigationBar.computeFrameLw(mTmpNavigationFrame, mTmpNavigationFrame, mTmpNavigationFrame, mTmpNavigationFrame, mTmpNavigationFrame);
if (DEBUG_LAYOUT)
Log.i(TAG, "mNavigationBar frame: " + mTmpNavigationFrame);
}
if (DEBUG_LAYOUT)
Log.i(TAG, String.format("mDock rect: (%d,%d - %d,%d)", mDockLeft, mDockTop, mDockRight, mDockBottom));
// decide where the status bar goes ahead of time
if (mStatusBar != null) {
// apply any navigation bar insets
pf.left = df.left = of.left = mUnrestrictedScreenLeft;
pf.top = df.top = of.top = mUnrestrictedScreenTop;
pf.right = df.right = of.right = mUnrestrictedScreenWidth + mUnrestrictedScreenLeft;
pf.bottom = df.bottom = of.bottom = mUnrestrictedScreenHeight + mUnrestrictedScreenTop;
vf.left = mStableLeft;
vf.top = mStableTop;
vf.right = mStableRight;
vf.bottom = mStableBottom;
mStatusBarLayer = mStatusBar.getSurfaceLayer();
// Let the status bar determine its size.
mStatusBar.computeFrameLw(pf, df, vf, vf, vf);
// For layout, the status bar is always at the top with our fixed height.
mStableTop = mUnrestrictedScreenTop + mStatusBarHeight;
// windows behind it to scroll.
if (mStatusBar.isVisibleLw()) {
// Status bar may go away, so the screen area it occupies
// is available to apps but just covering them when the
// status bar is visible.
mDockTop = mUnrestrictedScreenTop + mStatusBarHeight;
mContentTop = mCurTop = mDockTop;
mContentBottom = mCurBottom = mDockBottom;
mContentLeft = mCurLeft = mDockLeft;
mContentRight = mCurRight = mDockRight;
if (DEBUG_LAYOUT)
Log.v(TAG, "Status bar: " + String.format("dock=[%d,%d][%d,%d] content=[%d,%d][%d,%d] cur=[%d,%d][%d,%d]", mDockLeft, mDockTop, mDockRight, mDockBottom, mContentLeft, mContentTop, mContentRight, mContentBottom, mCurLeft, mCurTop, mCurRight, mCurBottom));
}
if (mStatusBar.isVisibleLw() && !mStatusBar.isAnimatingLw()) {
// If the status bar is currently requested to be visible,
// and not in the process of animating on or off, then
// we can tell the app that it is covered by it.
mSystemTop = mUnrestrictedScreenTop + mStatusBarHeight;
}
}
}
}
use of android.graphics.Rect in project android_frameworks_base by ParanoidAndroid.
the class RecentApplicationsBackground method draw.
@Override
public void draw(Canvas canvas) {
final Drawable background = mBackground;
if (background != null) {
if (mBackgroundSizeChanged) {
mBackgroundSizeChanged = false;
Rect chld = mTmp0;
Rect bkg = mTmp1;
mBackground.getPadding(bkg);
getChildBounds(chld);
// This doesn't clamp to this view's bounds, which is what we want,
// so that the drawing is clipped.
final int top = chld.top - bkg.top;
final int bottom = chld.bottom + bkg.bottom;
// The background here is a gradient that wants to
// extend the full width of the screen (whatever that
// may be).
int left, right;
if (false) {
// This limits the width of the drawable.
left = chld.left - bkg.left;
right = chld.right + bkg.right;
} else {
// This expands it to full width.
left = 0;
right = getRight();
}
background.setBounds(left, top, right, bottom);
}
}
mBackground.draw(canvas);
if (false) {
android.graphics.Paint p = new android.graphics.Paint();
p.setColor(0x88ffff00);
canvas.drawRect(background.getBounds(), p);
}
canvas.drawARGB((int) (0.75 * 0xff), 0, 0, 0);
super.draw(canvas);
}
use of android.graphics.Rect in project android_frameworks_base by ParanoidAndroid.
the class ActivityRecord method applyOptionsLocked.
void applyOptionsLocked() {
if (pendingOptions != null) {
final int animationType = pendingOptions.getAnimationType();
switch(animationType) {
case ActivityOptions.ANIM_CUSTOM:
service.mWindowManager.overridePendingAppTransition(pendingOptions.getPackageName(), pendingOptions.getCustomEnterResId(), pendingOptions.getCustomExitResId(), pendingOptions.getOnAnimationStartListener());
break;
case ActivityOptions.ANIM_SCALE_UP:
service.mWindowManager.overridePendingAppTransitionScaleUp(pendingOptions.getStartX(), pendingOptions.getStartY(), pendingOptions.getStartWidth(), pendingOptions.getStartHeight());
if (intent.getSourceBounds() == null) {
intent.setSourceBounds(new Rect(pendingOptions.getStartX(), pendingOptions.getStartY(), pendingOptions.getStartX() + pendingOptions.getStartWidth(), pendingOptions.getStartY() + pendingOptions.getStartHeight()));
}
break;
case ActivityOptions.ANIM_THUMBNAIL_SCALE_UP:
case ActivityOptions.ANIM_THUMBNAIL_SCALE_DOWN:
boolean scaleUp = (animationType == ActivityOptions.ANIM_THUMBNAIL_SCALE_UP);
service.mWindowManager.overridePendingAppTransitionThumb(pendingOptions.getThumbnail(), pendingOptions.getStartX(), pendingOptions.getStartY(), pendingOptions.getOnAnimationStartListener(), scaleUp);
if (intent.getSourceBounds() == null) {
intent.setSourceBounds(new Rect(pendingOptions.getStartX(), pendingOptions.getStartY(), pendingOptions.getStartX() + pendingOptions.getThumbnail().getWidth(), pendingOptions.getStartY() + pendingOptions.getThumbnail().getHeight()));
}
break;
}
pendingOptions = null;
}
}
use of android.graphics.Rect in project android_frameworks_base by ParanoidAndroid.
the class DisplayDevice method setProjectionInTransactionLocked.
/**
* Sets the display projection while in a transaction.
*
* @param orientation defines the display's orientation
* @param layerStackRect defines which area of the window manager coordinate
* space will be used
* @param displayRect defines where on the display will layerStackRect be
* mapped to. displayRect is specified post-orientation, that is
* it uses the orientation seen by the end-user
*/
public final void setProjectionInTransactionLocked(int orientation, Rect layerStackRect, Rect displayRect) {
if (mCurrentOrientation != orientation || mCurrentLayerStackRect == null || !mCurrentLayerStackRect.equals(layerStackRect) || mCurrentDisplayRect == null || !mCurrentDisplayRect.equals(displayRect)) {
mCurrentOrientation = orientation;
if (mCurrentLayerStackRect == null) {
mCurrentLayerStackRect = new Rect();
}
mCurrentLayerStackRect.set(layerStackRect);
if (mCurrentDisplayRect == null) {
mCurrentDisplayRect = new Rect();
}
mCurrentDisplayRect.set(displayRect);
SurfaceControl.setDisplayProjection(mDisplayToken, orientation, layerStackRect, displayRect);
}
}
Aggregations