Search in sources :

Example 1 with Utilities.getDescendantCoordRelativeToAncestor

use of com.android.launcher3.Utilities.getDescendantCoordRelativeToAncestor in project android_packages_apps_Launcher3 by crdroidandroid.

the class KeyboardDragAndDropView method setCurrentSelection.

private void setCurrentSelection(VirtualNodeInfo nodeInfo) {
    mCurrentSelection = nodeInfo;
    ((TextView) findViewById(R.id.label)).setText(nodeInfo.populate(mTempNodeInfo).getContentDescription());
    Rect bounds = new Rect();
    mTempNodeInfo.getBoundsInParent(bounds);
    View host = nodeInfo.delegate.getHost();
    ViewParent parent = host.getParent();
    if (parent instanceof PagedView) {
        PagedView pv = (PagedView) parent;
        int pageIndex = pv.indexOfChild(host);
        pv.setCurrentPage(pageIndex);
        bounds.offset(pv.getScrollX() - pv.getScrollForPage(pageIndex), 0);
    }
    float[] pos = new float[] { bounds.left, bounds.top, bounds.right, bounds.bottom };
    Utilities.getDescendantCoordRelativeToAncestor(host, mLauncher.getDragLayer(), pos, true);
    new RectF(pos[0], pos[1], pos[2], pos[3]).roundOut(bounds);
    mFocusIndicator.changeFocus(bounds, true);
}
Also used : RectF(android.graphics.RectF) Rect(android.graphics.Rect) PagedView(com.android.launcher3.PagedView) ViewParent(android.view.ViewParent) TextView(android.widget.TextView) View(android.view.View) TextView(android.widget.TextView) PagedView(com.android.launcher3.PagedView) AbstractFloatingView(com.android.launcher3.AbstractFloatingView)

Example 2 with Utilities.getDescendantCoordRelativeToAncestor

use of com.android.launcher3.Utilities.getDescendantCoordRelativeToAncestor in project android_packages_apps_Launcher3 by crdroidandroid.

the class KeyboardDragAndDropView method showForIcon.

/**
 * Shows the keyboard drag popup for the provided view
 */
public void showForIcon(View icon, ItemInfo item, DragOptions dragOptions) {
    mIsOpen = true;
    mLauncher.getDragLayer().addView(this);
    mLauncher.getStateManager().addStateListener(this);
    // Find current selection
    CellLayout currentParent = (CellLayout) icon.getParent().getParent();
    float[] iconPos = new float[] { currentParent.getCellWidth() / 2, currentParent.getCellHeight() / 2 };
    Utilities.getDescendantCoordRelativeToAncestor(icon, currentParent, iconPos, false);
    ItemLongClickListener.beginDrag(icon, mLauncher, item, dragOptions);
    DragAndDropAccessibilityDelegate dndDelegate = currentParent.getDragAndDropAccessibilityDelegate();
    setCurrentSelection(new VirtualNodeInfo(dndDelegate, dndDelegate.getVirtualViewAt(iconPos[0], iconPos[1])));
    mLauncher.setDefaultKeyMode(Activity.DEFAULT_KEYS_DISABLE);
    requestFocus();
}
Also used : CellLayout(com.android.launcher3.CellLayout) DragAndDropAccessibilityDelegate(com.android.launcher3.accessibility.DragAndDropAccessibilityDelegate)

Example 3 with Utilities.getDescendantCoordRelativeToAncestor

use of com.android.launcher3.Utilities.getDescendantCoordRelativeToAncestor in project android_packages_apps_Launcher3 by AOSPA.

the class KeyboardDragAndDropView method showForIcon.

/**
 * Shows the keyboard drag popup for the provided view
 */
public void showForIcon(View icon, ItemInfo item, DragOptions dragOptions) {
    mIsOpen = true;
    mLauncher.getDragLayer().addView(this);
    mLauncher.getStateManager().addStateListener(this);
    // Find current selection
    CellLayout currentParent = (CellLayout) icon.getParent().getParent();
    float[] iconPos = new float[] { currentParent.getCellWidth() / 2, currentParent.getCellHeight() / 2 };
    Utilities.getDescendantCoordRelativeToAncestor(icon, currentParent, iconPos, false);
    ItemLongClickListener.beginDrag(icon, mLauncher, item, dragOptions);
    DragAndDropAccessibilityDelegate dndDelegate = currentParent.getDragAndDropAccessibilityDelegate();
    setCurrentSelection(new VirtualNodeInfo(dndDelegate, dndDelegate.getVirtualViewAt(iconPos[0], iconPos[1])));
    mLauncher.setDefaultKeyMode(Activity.DEFAULT_KEYS_DISABLE);
    requestFocus();
}
Also used : CellLayout(com.android.launcher3.CellLayout) DragAndDropAccessibilityDelegate(com.android.launcher3.accessibility.DragAndDropAccessibilityDelegate)

Example 4 with Utilities.getDescendantCoordRelativeToAncestor

use of com.android.launcher3.Utilities.getDescendantCoordRelativeToAncestor in project android_packages_apps_Launcher3 by AOSPA.

the class KeyboardDragAndDropView method setCurrentSelection.

private void setCurrentSelection(VirtualNodeInfo nodeInfo) {
    mCurrentSelection = nodeInfo;
    ((TextView) findViewById(R.id.label)).setText(nodeInfo.populate(mTempNodeInfo).getContentDescription());
    Rect bounds = new Rect();
    mTempNodeInfo.getBoundsInParent(bounds);
    View host = nodeInfo.delegate.getHost();
    ViewParent parent = host.getParent();
    if (parent instanceof PagedView) {
        PagedView pv = (PagedView) parent;
        int pageIndex = pv.indexOfChild(host);
        pv.setCurrentPage(pageIndex);
        bounds.offset(pv.getScrollX() - pv.getScrollForPage(pageIndex), 0);
    }
    float[] pos = new float[] { bounds.left, bounds.top, bounds.right, bounds.bottom };
    Utilities.getDescendantCoordRelativeToAncestor(host, mLauncher.getDragLayer(), pos, true);
    new RectF(pos[0], pos[1], pos[2], pos[3]).roundOut(bounds);
    mFocusIndicator.changeFocus(bounds, true);
}
Also used : RectF(android.graphics.RectF) Rect(android.graphics.Rect) PagedView(com.android.launcher3.PagedView) ViewParent(android.view.ViewParent) TextView(android.widget.TextView) View(android.view.View) TextView(android.widget.TextView) PagedView(com.android.launcher3.PagedView) AbstractFloatingView(com.android.launcher3.AbstractFloatingView)

Example 5 with Utilities.getDescendantCoordRelativeToAncestor

use of com.android.launcher3.Utilities.getDescendantCoordRelativeToAncestor in project Neo-Launcher by NeoApplications.

the class FloatingIconView method getLocationBoundsForView.

/**
 * Gets the location bounds of a view and returns the overall rotation.
 * - For DeepShortcutView, we return the bounds of the icon view.
 * - For BubbleTextView, we return the icon bounds.
 */
private static float getLocationBoundsForView(Launcher launcher, View v, boolean isOpening, RectF outRect) {
    boolean ignoreTransform = !isOpening;
    if (v instanceof DeepShortcutView) {
        v = ((DeepShortcutView) v).getBubbleText();
        ignoreTransform = false;
    } else if (v.getParent() instanceof DeepShortcutView) {
        v = ((DeepShortcutView) v.getParent()).getIconView();
        ignoreTransform = false;
    }
    if (v == null) {
        return 0;
    }
    Rect iconBounds = new Rect();
    if (v instanceof BubbleTextView) {
        ((BubbleTextView) v).getIconBounds(iconBounds);
    } else if (v instanceof FolderIcon) {
        ((FolderIcon) v).getPreviewBounds(iconBounds);
    } else {
        iconBounds.set(0, 0, v.getWidth(), v.getHeight());
    }
    float[] points = new float[] { iconBounds.left, iconBounds.top, iconBounds.right, iconBounds.bottom };
    float[] rotation = new float[] { 0 };
    Utilities.getDescendantCoordRelativeToAncestor(v, launcher.getDragLayer(), points, false, ignoreTransform, rotation);
    outRect.set(Math.min(points[0], points[2]), Math.min(points[1], points[3]), Math.max(points[0], points[2]), Math.max(points[1], points[3]));
    return rotation[0];
}
Also used : Rect(android.graphics.Rect) FolderIcon(com.android.launcher3.folder.FolderIcon) BubbleTextView(com.android.launcher3.BubbleTextView) DeepShortcutView(com.android.launcher3.shortcuts.DeepShortcutView)

Aggregations

Rect (android.graphics.Rect)6 RectF (android.graphics.RectF)5 View (android.view.View)5 ViewParent (android.view.ViewParent)5 TextView (android.widget.TextView)5 AbstractFloatingView (com.android.launcher3.AbstractFloatingView)5 CellLayout (com.android.launcher3.CellLayout)5 PagedView (com.android.launcher3.PagedView)5 DragAndDropAccessibilityDelegate (com.android.launcher3.accessibility.DragAndDropAccessibilityDelegate)5 BubbleTextView (com.android.launcher3.BubbleTextView)1 FolderIcon (com.android.launcher3.folder.FolderIcon)1 DeepShortcutView (com.android.launcher3.shortcuts.DeepShortcutView)1