use of com.android.launcher3.Utilities.getDescendantCoordRelativeToAncestor in project android_packages_apps_Launcher3 by ProtonAOSP.
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_404Launcher by P-404.
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_404Launcher by P-404.
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 ArrowOS.
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 ArrowOS.
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);
}
Aggregations