Search in sources :

Example 6 with R

use of com.android.launcher3.R in project android_packages_apps_Launcher3 by crdroidandroid.

the class ArrowPopup method inflateAndAdd.

/**
 * Utility method for inflating and adding a view
 */
public <R extends View> R inflateAndAdd(int resId, ViewGroup container, int index) {
    View view = mInflater.inflate(resId, container, false);
    container.addView(view, index);
    return (R) view;
}
Also used : LINEAR(com.android.launcher3.anim.Interpolators.LINEAR) R(com.android.launcher3.R) View(android.view.View) DeepShortcutView(com.android.launcher3.shortcuts.DeepShortcutView) AbstractFloatingView(com.android.launcher3.AbstractFloatingView)

Example 7 with R

use of com.android.launcher3.R in project android_packages_apps_Launcher3 by crdroidandroid.

the class CellLayout method animateChildToPosition.

public boolean animateChildToPosition(final View child, int cellX, int cellY, int duration, int delay, boolean permanent, boolean adjustOccupied) {
    ShortcutAndWidgetContainer clc = getShortcutsAndWidgets();
    if (clc.indexOfChild(child) != -1 && (child instanceof Reorderable)) {
        final LayoutParams lp = (LayoutParams) child.getLayoutParams();
        final ItemInfo info = (ItemInfo) child.getTag();
        final Reorderable item = (Reorderable) child;
        // We cancel any existing animations
        if (mReorderAnimators.containsKey(lp)) {
            mReorderAnimators.get(lp).cancel();
            mReorderAnimators.remove(lp);
        }
        if (adjustOccupied) {
            GridOccupancy occupied = permanent ? mOccupied : mTmpOccupied;
            occupied.markCells(lp.cellX, lp.cellY, lp.cellHSpan, lp.cellVSpan, false);
            occupied.markCells(cellX, cellY, lp.cellHSpan, lp.cellVSpan, true);
        }
        // Compute the new x and y position based on the new cellX and cellY
        // We leverage the actual layout logic in the layout params and hence need to modify
        // state and revert that state.
        final int oldX = lp.x;
        final int oldY = lp.y;
        lp.isLockedToGrid = true;
        if (permanent) {
            lp.cellX = info.cellX = cellX;
            lp.cellY = info.cellY = cellY;
        } else {
            lp.tmpCellX = cellX;
            lp.tmpCellY = cellY;
        }
        clc.setupLp(child);
        final int newX = lp.x;
        final int newY = lp.y;
        lp.x = oldX;
        lp.y = oldY;
        lp.isLockedToGrid = false;
        // End compute new x and y
        item.getReorderPreviewOffset(mTmpPointF);
        final float initPreviewOffsetX = mTmpPointF.x;
        final float initPreviewOffsetY = mTmpPointF.y;
        final float finalPreviewOffsetX = newX - oldX;
        final float finalPreviewOffsetY = newY - oldY;
        // Exit early if we're not actually moving the view
        if (finalPreviewOffsetX == 0 && finalPreviewOffsetY == 0 && initPreviewOffsetX == 0 && initPreviewOffsetY == 0) {
            lp.isLockedToGrid = true;
            return true;
        }
        ValueAnimator va = ValueAnimator.ofFloat(0f, 1f);
        va.setDuration(duration);
        mReorderAnimators.put(lp, va);
        va.addUpdateListener(new AnimatorUpdateListener() {

            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                float r = (Float) animation.getAnimatedValue();
                float x = (1 - r) * initPreviewOffsetX + r * finalPreviewOffsetX;
                float y = (1 - r) * initPreviewOffsetY + r * finalPreviewOffsetY;
                item.setReorderPreviewOffset(x, y);
            }
        });
        va.addListener(new AnimatorListenerAdapter() {

            boolean cancelled = false;

            public void onAnimationEnd(Animator animation) {
                // place just yet.
                if (!cancelled) {
                    lp.isLockedToGrid = true;
                    item.setReorderPreviewOffset(0, 0);
                    child.requestLayout();
                }
                if (mReorderAnimators.containsKey(lp)) {
                    mReorderAnimators.remove(lp);
                }
            }

            public void onAnimationCancel(Animator animation) {
                cancelled = true;
            }
        });
        va.setStartDelay(delay);
        va.start();
        return true;
    }
    return false;
}
Also used : ItemInfo(com.android.launcher3.model.data.ItemInfo) AnimatorUpdateListener(android.animation.ValueAnimator.AnimatorUpdateListener) ValueAnimator(android.animation.ValueAnimator) GridOccupancy(com.android.launcher3.util.GridOccupancy) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter)

Example 8 with R

use of com.android.launcher3.R in project android_packages_apps_Launcher3 by crdroidandroid.

the class AppWidgetResizeFrame method onLayout.

@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
    super.onLayout(changed, l, t, r, b);
    if (Utilities.ATLEAST_Q) {
        for (int i = 0; i < HANDLE_COUNT; i++) {
            View dragHandle = mDragHandles[i];
            mSystemGestureExclusionRects.get(i).set(dragHandle.getLeft(), dragHandle.getTop(), dragHandle.getRight(), dragHandle.getBottom());
        }
        setSystemGestureExclusionRects(mSystemGestureExclusionRects);
    }
}
Also used : ImageView(android.widget.ImageView) View(android.view.View) ArrowTipView(com.android.launcher3.views.ArrowTipView) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView)

Example 9 with R

use of com.android.launcher3.R in project android_packages_apps_Launcher3 by crdroidandroid.

the class BaseDragLayer method onLayout.

protected void onLayout(boolean changed, int l, int t, int r, int b) {
    super.onLayout(changed, l, t, r, b);
    int count = getChildCount();
    for (int i = 0; i < count; i++) {
        View child = getChildAt(i);
        final FrameLayout.LayoutParams flp = (FrameLayout.LayoutParams) child.getLayoutParams();
        if (flp instanceof LayoutParams) {
            final LayoutParams lp = (LayoutParams) flp;
            if (lp.customPosition) {
                child.layout(lp.x, lp.y, lp.x + lp.width, lp.y + lp.height);
            }
        }
    }
}
Also used : FrameLayout(android.widget.FrameLayout) InsettableFrameLayout(com.android.launcher3.InsettableFrameLayout) View(android.view.View) AbstractFloatingView(com.android.launcher3.AbstractFloatingView)

Example 10 with R

use of com.android.launcher3.R in project Launcher3 by chislon.

the class CellLayout method onDraw.

@Override
protected void onDraw(Canvas canvas) {
    // backgrounds
    if (mBackgroundAlpha > 0.0f) {
        Drawable bg;
        if (mUseActiveGlowBackground) {
            // In the mini case, we draw the active_glow bg *over* the active background
            bg = mActiveGlowBackground;
        } else {
            bg = mNormalBackground;
        }
        bg.setAlpha((int) (mBackgroundAlpha * mBackgroundAlphaMultiplier * 255));
        bg.setBounds(mBackgroundRect);
        bg.draw(canvas);
    }
    final Paint paint = mDragOutlinePaint;
    for (int i = 0; i < mDragOutlines.length; i++) {
        final float alpha = mDragOutlineAlphas[i];
        if (alpha > 0) {
            final Rect r = mDragOutlines[i];
            mTempRect.set(r);
            Utilities.scaleRectAboutCenter(mTempRect, getChildrenScale());
            final Bitmap b = (Bitmap) mDragOutlineAnims[i].getTag();
            paint.setAlpha((int) (alpha + .5f));
            canvas.drawBitmap(b, null, mTempRect, paint);
        }
    }
    // requires an expanded clip rect (due to the glow's blur radius)
    if (mPressedOrFocusedIcon != null) {
        final int padding = mPressedOrFocusedIcon.getPressedOrFocusedBackgroundPadding();
        final Bitmap b = mPressedOrFocusedIcon.getPressedOrFocusedBackground();
        if (b != null) {
            int offset = getMeasuredWidth() - getPaddingLeft() - getPaddingRight() - (mCountX * mCellWidth);
            int left = getPaddingLeft() + (int) Math.ceil(offset / 2f);
            int top = getPaddingTop();
            canvas.drawBitmap(b, mPressedOrFocusedIcon.getLeft() + left - padding, mPressedOrFocusedIcon.getTop() + top - padding, null);
        }
    }
    if (DEBUG_VISUALIZE_OCCUPIED) {
        int[] pt = new int[2];
        ColorDrawable cd = new ColorDrawable(Color.RED);
        cd.setBounds(0, 0, mCellWidth, mCellHeight);
        for (int i = 0; i < mCountX; i++) {
            for (int j = 0; j < mCountY; j++) {
                if (mOccupied[i][j]) {
                    cellToPoint(i, j, pt);
                    canvas.save();
                    canvas.translate(pt[0], pt[1]);
                    cd.draw(canvas);
                    canvas.restore();
                }
            }
        }
    }
    int previewOffset = FolderRingAnimator.sPreviewSize;
    // The folder outer / inner ring image(s)
    LauncherAppState app = LauncherAppState.getInstance();
    DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
    for (int i = 0; i < mFolderOuterRings.size(); i++) {
        FolderRingAnimator fra = mFolderOuterRings.get(i);
        Drawable d;
        int width, height;
        cellToPoint(fra.mCellX, fra.mCellY, mTempLocation);
        View child = getChildAt(fra.mCellX, fra.mCellY);
        if (child != null) {
            int centerX = mTempLocation[0] + mCellWidth / 2;
            int centerY = mTempLocation[1] + previewOffset / 2 + child.getPaddingTop() + grid.folderBackgroundOffset;
            // Draw outer ring, if it exists
            if (FolderIcon.HAS_OUTER_RING) {
                d = FolderRingAnimator.sSharedOuterRingDrawable;
                width = (int) (fra.getOuterRingSize() * getChildrenScale());
                height = width;
                canvas.save();
                canvas.translate(centerX - width / 2, centerY - height / 2);
                d.setBounds(0, 0, width, height);
                d.draw(canvas);
                canvas.restore();
            }
            // Draw inner ring
            d = FolderRingAnimator.sSharedInnerRingDrawable;
            width = (int) (fra.getInnerRingSize() * getChildrenScale());
            height = width;
            canvas.save();
            canvas.translate(centerX - width / 2, centerY - width / 2);
            d.setBounds(0, 0, width, height);
            d.draw(canvas);
            canvas.restore();
        }
    }
    if (mFolderLeaveBehindCell[0] >= 0 && mFolderLeaveBehindCell[1] >= 0) {
        Drawable d = FolderIcon.sSharedFolderLeaveBehind;
        int width = d.getIntrinsicWidth();
        int height = d.getIntrinsicHeight();
        cellToPoint(mFolderLeaveBehindCell[0], mFolderLeaveBehindCell[1], mTempLocation);
        View child = getChildAt(mFolderLeaveBehindCell[0], mFolderLeaveBehindCell[1]);
        if (child != null) {
            int centerX = mTempLocation[0] + mCellWidth / 2;
            int centerY = mTempLocation[1] + previewOffset / 2 + child.getPaddingTop() + grid.folderBackgroundOffset;
            canvas.save();
            canvas.translate(centerX - width / 2, centerY - width / 2);
            d.setBounds(0, 0, width, height);
            d.draw(canvas);
            canvas.restore();
        }
    }
}
Also used : Rect(android.graphics.Rect) Bitmap(android.graphics.Bitmap) ColorDrawable(android.graphics.drawable.ColorDrawable) FolderRingAnimator(com.android.launcher3.FolderIcon.FolderRingAnimator) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) NinePatchDrawable(android.graphics.drawable.NinePatchDrawable) Paint(android.graphics.Paint) View(android.view.View) Point(android.graphics.Point) Paint(android.graphics.Paint)

Aggregations

View (android.view.View)6 Point (android.graphics.Point)5 Rect (android.graphics.Rect)5 Animator (android.animation.Animator)3 ValueAnimator (android.animation.ValueAnimator)3 Paint (android.graphics.Paint)3 GridOccupancy (com.android.launcher3.util.GridOccupancy)3 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)2 AnimatorUpdateListener (android.animation.ValueAnimator.AnimatorUpdateListener)2 AbstractFloatingView (com.android.launcher3.AbstractFloatingView)2 FolderRingAnimator (com.android.launcher3.FolderIcon.FolderRingAnimator)2 ItemInfo (com.android.launcher3.model.data.ItemInfo)2 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)2 ArrowTipView (com.android.launcher3.views.ArrowTipView)2 ObjectAnimator (android.animation.ObjectAnimator)1 SuppressLint (android.annotation.SuppressLint)1 Intent (android.content.Intent)1 Bitmap (android.graphics.Bitmap)1 ColorDrawable (android.graphics.drawable.ColorDrawable)1 Drawable (android.graphics.drawable.Drawable)1