Search in sources :

Example 46 with LayoutParams

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

the class CellLayout method getViewsIntersectingRegion.

// For a given cell and span, fetch the set of views intersecting the region.
private void getViewsIntersectingRegion(int cellX, int cellY, int spanX, int spanY, View dragView, Rect boundingRect, ArrayList<View> intersectingViews) {
    if (boundingRect != null) {
        boundingRect.set(cellX, cellY, cellX + spanX, cellY + spanY);
    }
    intersectingViews.clear();
    Rect r0 = new Rect(cellX, cellY, cellX + spanX, cellY + spanY);
    Rect r1 = new Rect();
    final int count = mShortcutsAndWidgets.getChildCount();
    for (int i = 0; i < count; i++) {
        View child = mShortcutsAndWidgets.getChildAt(i);
        if (child == dragView)
            continue;
        LayoutParams lp = (LayoutParams) child.getLayoutParams();
        r1.set(lp.cellX, lp.cellY, lp.cellX + lp.cellHSpan, lp.cellY + lp.cellVSpan);
        if (Rect.intersects(r0, r1)) {
            mIntersectingViews.add(child);
            if (boundingRect != null) {
                boundingRect.union(r1);
            }
        }
    }
}
Also used : Rect(android.graphics.Rect) 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 47 with LayoutParams

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

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) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point)

Example 48 with LayoutParams

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

the class CellLayout method pushViewsToTempLocation.

private boolean pushViewsToTempLocation(ArrayList<View> views, Rect rectOccupiedByPotentialDrop, int[] direction, View dragView, ItemConfiguration currentState) {
    ViewCluster cluster = new ViewCluster(views, currentState);
    Rect clusterRect = cluster.getBoundingRect();
    int whichEdge;
    int pushDistance;
    boolean fail = false;
    // the cluster must be shifted.
    if (direction[0] < 0) {
        whichEdge = ViewCluster.LEFT;
        pushDistance = clusterRect.right - rectOccupiedByPotentialDrop.left;
    } else if (direction[0] > 0) {
        whichEdge = ViewCluster.RIGHT;
        pushDistance = rectOccupiedByPotentialDrop.right - clusterRect.left;
    } else if (direction[1] < 0) {
        whichEdge = ViewCluster.TOP;
        pushDistance = clusterRect.bottom - rectOccupiedByPotentialDrop.top;
    } else {
        whichEdge = ViewCluster.BOTTOM;
        pushDistance = rectOccupiedByPotentialDrop.bottom - clusterRect.top;
    }
    // Break early for invalid push distance.
    if (pushDistance <= 0) {
        return false;
    }
    // Mark the occupied state as false for the group of views we want to move.
    for (View v : views) {
        CellAndSpan c = currentState.map.get(v);
        mTmpOccupied.markCells(c, false);
    }
    // We save the current configuration -- if we fail to find a solution we will revert
    // to the initial state. The process of finding a solution modifies the configuration
    // in place, hence the need for revert in the failure case.
    currentState.save();
    // The pushing algorithm is simplified by considering the views in the order in which
    // they would be pushed by the cluster. For example, if the cluster is leading with its
    // left edge, we consider sort the views by their right edge, from right to left.
    cluster.sortConfigurationForEdgePush(whichEdge);
    while (pushDistance > 0 && !fail) {
        for (View v : currentState.sortedViews) {
            // cluster.
            if (!cluster.views.contains(v) && v != dragView) {
                if (cluster.isViewTouchingEdge(v, whichEdge)) {
                    LayoutParams lp = (LayoutParams) v.getLayoutParams();
                    if (!lp.canReorder) {
                        // The push solution includes the all apps button, this is not viable.
                        fail = true;
                        break;
                    }
                    cluster.addView(v);
                    CellAndSpan c = currentState.map.get(v);
                    // Adding view to cluster, mark it as not occupied.
                    mTmpOccupied.markCells(c, false);
                }
            }
        }
        pushDistance--;
        // The cluster has been completed, now we move the whole thing over in the appropriate
        // direction.
        cluster.shift(whichEdge, 1);
    }
    boolean foundSolution = false;
    clusterRect = cluster.getBoundingRect();
    // is to ensure that completed shifted cluster lies completely within the cell layout.
    if (!fail && clusterRect.left >= 0 && clusterRect.right <= mCountX && clusterRect.top >= 0 && clusterRect.bottom <= mCountY) {
        foundSolution = true;
    } else {
        currentState.restore();
    }
    // In either case, we set the occupied array as marked for the location of the views
    for (View v : cluster.views) {
        CellAndSpan c = currentState.map.get(v);
        mTmpOccupied.markCells(c, true);
    }
    return foundSolution;
}
Also used : Rect(android.graphics.Rect) 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 49 with LayoutParams

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

the class CellLayout method commitTempPlacement.

private void commitTempPlacement(View dragView) {
    mTmpOccupied.copyTo(mOccupied);
    int screenId = Launcher.cast(mActivity).getWorkspace().getIdForScreen(this);
    int container = Favorites.CONTAINER_DESKTOP;
    if (mContainerType == HOTSEAT) {
        screenId = -1;
        container = Favorites.CONTAINER_HOTSEAT;
    }
    int childCount = mShortcutsAndWidgets.getChildCount();
    for (int i = 0; i < childCount; i++) {
        View child = mShortcutsAndWidgets.getChildAt(i);
        LayoutParams lp = (LayoutParams) child.getLayoutParams();
        ItemInfo info = (ItemInfo) child.getTag();
        // AllApps button in the hotseat.
        if (info != null && child != dragView) {
            final boolean requiresDbUpdate = (info.cellX != lp.tmpCellX || info.cellY != lp.tmpCellY || info.spanX != lp.cellHSpan || info.spanY != lp.cellVSpan);
            info.cellX = lp.cellX = lp.tmpCellX;
            info.cellY = lp.cellY = lp.tmpCellY;
            info.spanX = lp.cellHSpan;
            info.spanY = lp.cellVSpan;
            if (requiresDbUpdate) {
                Launcher.cast(mActivity).getModelWriter().modifyItemInDatabase(info, container, screenId, info.cellX, info.cellY, info.spanX, info.spanY);
            }
        }
    }
}
Also used : ItemInfo(com.android.launcher3.model.data.ItemInfo) 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 50 with LayoutParams

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

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)

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