Search in sources :

Example 16 with LayoutParams

use of com.android.launcher3.InsettableFrameLayout.LayoutParams in project android_packages_apps_Launcher3 by AOSPA.

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 17 with LayoutParams

use of com.android.launcher3.InsettableFrameLayout.LayoutParams in project android_packages_apps_Launcher3 by AOSPA.

the class FloatingSurfaceView method updateIconLocation.

private void updateIconLocation() {
    if (mContract == null) {
        return;
    }
    View icon = mLauncher.getFirstMatchForAppClose(-1, mContract.componentName.getPackageName(), mContract.user);
    boolean iconChanged = mIcon != icon;
    if (iconChanged) {
        setCurrentIconVisible(true);
        mIcon = icon;
        setCurrentIconVisible(false);
    }
    if (icon != null && icon.isAttachedToWindow()) {
        getLocationBoundsForView(mLauncher, icon, false, mTmpPosition, mIconBounds);
        if (!mTmpPosition.equals(mIconPosition)) {
            mIconPosition.set(mTmpPosition);
            sendIconInfo();
            LayoutParams lp = (LayoutParams) mSurfaceView.getLayoutParams();
            lp.width = Math.round(mIconPosition.width());
            lp.height = Math.round(mIconPosition.height());
            lp.leftMargin = Math.round(mIconPosition.left);
            lp.topMargin = Math.round(mIconPosition.top);
        }
    }
    if (mIcon != null && iconChanged && !mIconBounds.isEmpty()) {
        // Record the icon display
        setCurrentIconVisible(true);
        Canvas c = mPicture.beginRecording(mIconBounds.width(), mIconBounds.height());
        c.translate(-mIconBounds.left, -mIconBounds.top);
        mIcon.draw(c);
        mPicture.endRecording();
        setCurrentIconVisible(false);
        drawOnSurface();
    }
}
Also used : Canvas(android.graphics.Canvas) SurfaceView(android.view.SurfaceView) FloatingIconView.getLocationBoundsForView(com.android.launcher3.views.FloatingIconView.getLocationBoundsForView) View(android.view.View) AbstractFloatingView(com.android.launcher3.AbstractFloatingView)

Example 18 with LayoutParams

use of com.android.launcher3.InsettableFrameLayout.LayoutParams in project android_packages_apps_Launcher3 by AOSPA.

the class CellLayout method copyCurrentStateToSolution.

private void copyCurrentStateToSolution(ItemConfiguration solution, boolean temp) {
    int childCount = mShortcutsAndWidgets.getChildCount();
    for (int i = 0; i < childCount; i++) {
        View child = mShortcutsAndWidgets.getChildAt(i);
        LayoutParams lp = (LayoutParams) child.getLayoutParams();
        CellAndSpan c;
        if (temp) {
            c = new CellAndSpan(lp.tmpCellX, lp.tmpCellY, lp.cellHSpan, lp.cellVSpan);
        } else {
            c = new CellAndSpan(lp.cellX, lp.cellY, lp.cellHSpan, lp.cellVSpan);
        }
        solution.add(child, c);
    }
}
Also used : CellAndSpan(com.android.launcher3.util.CellAndSpan) DraggableView(com.android.launcher3.dragndrop.DraggableView) View(android.view.View) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point)

Example 19 with LayoutParams

use of com.android.launcher3.InsettableFrameLayout.LayoutParams in project android_packages_apps_Trebuchet by LineageOS.

the class TaskView method setContextualChip.

/**
 * Sets the contextual chip.
 *
 * @param view Wrapper view containing contextual chip.
 */
public void setContextualChip(View view) {
    if (mContextualChipWrapper != null) {
        removeView(mContextualChipWrapper);
    }
    if (view != null) {
        mContextualChipWrapper = view;
        LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
        layoutParams.gravity = BOTTOM | CENTER_HORIZONTAL;
        int expectedChipHeight = getExpectedViewHeight(view);
        float chipOffset = getResources().getDimension(R.dimen.chip_hint_vertical_offset);
        layoutParams.bottomMargin = (int) (((MarginLayoutParams) mSnapshotView.getLayoutParams()).bottomMargin - expectedChipHeight + chipOffset);
        mContextualChip = ((FrameLayout) mContextualChipWrapper).getChildAt(0);
        mContextualChip.setScaleX(0f);
        mContextualChip.setScaleY(0f);
        GradientDrawable scrimDrawable = (GradientDrawable) getResources().getDrawable(R.drawable.chip_scrim_gradient, mActivity.getTheme());
        float cornerRadius = getTaskCornerRadius();
        scrimDrawable.setCornerRadii(new float[] { 0, 0, 0, 0, cornerRadius, cornerRadius, cornerRadius, cornerRadius });
        InsetDrawable scrimDrawableInset = new InsetDrawable(scrimDrawable, 0, 0, 0, (int) (expectedChipHeight - chipOffset));
        mContextualChipWrapper.setBackground(scrimDrawableInset);
        mContextualChipWrapper.setPadding(0, 0, 0, 0);
        mContextualChipWrapper.setAlpha(0f);
        addView(view, getChildCount(), layoutParams);
        if (mContextualChip != null) {
            mContextualChip.animate().scaleX(1f).scaleY(1f).setDuration(50);
        }
        if (mContextualChipWrapper != null) {
            mChipTouchDelegate = new TransformingTouchDelegate(mContextualChipWrapper);
            mContextualChipWrapper.animate().alpha(1f).setDuration(50);
        }
    }
}
Also used : TransformingTouchDelegate(com.android.launcher3.util.TransformingTouchDelegate) InsetDrawable(android.graphics.drawable.InsetDrawable) GradientDrawable(android.graphics.drawable.GradientDrawable)

Example 20 with LayoutParams

use of com.android.launcher3.InsettableFrameLayout.LayoutParams in project android_packages_apps_Trebuchet by LineageOS.

the class CellLayout method beginOrAdjustReorderPreviewAnimations.

// This method starts or changes the reorder preview animations
private void beginOrAdjustReorderPreviewAnimations(ItemConfiguration solution, View dragView, int mode) {
    int childCount = mShortcutsAndWidgets.getChildCount();
    for (int i = 0; i < childCount; i++) {
        View child = mShortcutsAndWidgets.getChildAt(i);
        if (child == dragView)
            continue;
        CellAndSpan c = solution.map.get(child);
        boolean skip = mode == ReorderPreviewAnimation.MODE_HINT && solution.intersectingViews != null && !solution.intersectingViews.contains(child);
        LayoutParams lp = (LayoutParams) child.getLayoutParams();
        if (c != null && !skip && (child instanceof Reorderable)) {
            ReorderPreviewAnimation rha = new ReorderPreviewAnimation((Reorderable) child, mode, lp.cellX, lp.cellY, c.cellX, c.cellY, c.spanX, c.spanY);
            rha.animate();
        }
    }
}
Also used : CellAndSpan(com.android.launcher3.util.CellAndSpan) DraggableView(com.android.launcher3.dragndrop.DraggableView) View(android.view.View) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point)

Aggregations

View (android.view.View)79 SuppressLint (android.annotation.SuppressLint)61 Paint (android.graphics.Paint)59 Point (android.graphics.Point)58 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)49 DraggableView (com.android.launcher3.dragndrop.DraggableView)40 CellAndSpan (com.android.launcher3.util.CellAndSpan)35 Rect (android.graphics.Rect)23 BubbleTextView (com.android.launcher3.BubbleTextView)21 ItemInfo (com.android.launcher3.model.data.ItemInfo)17 Animator (android.animation.Animator)16 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)16 ObjectAnimator (android.animation.ObjectAnimator)15 AbstractFloatingView (com.android.launcher3.AbstractFloatingView)15 FrameLayout (android.widget.FrameLayout)13 DeviceProfile (com.android.launcher3.DeviceProfile)13 PagedOrientationHandler (com.android.launcher3.touch.PagedOrientationHandler)10 ValueAnimator (android.animation.ValueAnimator)9 AnimatorUpdateListener (android.animation.ValueAnimator.AnimatorUpdateListener)8 TimeInterpolator (android.animation.TimeInterpolator)7