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);
}
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();
}
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();
}
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);
}
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];
}
Aggregations