use of com.android.launcher3.userevent.nano.LauncherLogProto.Target in project android_packages_apps_Launcher3 by ArrowOS.
the class HotseatEduController method showHotseatArrowTip.
/**
* Finds a child suitable child in hotseat and shows arrow tip pointing at it.
*
* @param usePinned used to determine target view. If true, will use the first matching pinned
* item. Otherwise, will use the first predicted child
* @param message String to be shown inside the arrowView
* @return whether suitable child was found and tip was shown
*/
private boolean showHotseatArrowTip(boolean usePinned, String message) {
int childCount = mHotseat.getShortcutsAndWidgets().getChildCount();
boolean isPortrait = !mLauncher.getDeviceProfile().isVerticalBarLayout();
BubbleTextView tipTargetView = null;
for (int i = childCount - 1; i > -1; i--) {
int x = isPortrait ? i : 0;
int y = isPortrait ? 0 : i;
View v = mHotseat.getShortcutsAndWidgets().getChildAt(x, y);
if (v instanceof BubbleTextView && v.getTag() instanceof WorkspaceItemInfo) {
ItemInfo info = (ItemInfo) v.getTag();
boolean isPinned = info.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT;
if (isPinned == usePinned) {
tipTargetView = (BubbleTextView) v;
break;
}
}
}
if (tipTargetView == null) {
Log.e(TAG, "Unable to find suitable view for ArrowTip");
return false;
}
Rect bounds = Utilities.getViewBounds(tipTargetView);
new ArrowTipView(mLauncher).show(message, Gravity.END, bounds.centerX(), bounds.top);
return true;
}
use of com.android.launcher3.userevent.nano.LauncherLogProto.Target in project android_packages_apps_Launcher3 by ArrowOS.
the class HotseatPredictionModel method convertDataModelToAppTargetBundle.
/**
* Creates and returns bundle using workspace items
*/
public static Bundle convertDataModelToAppTargetBundle(Context context, BgDataModel dataModel) {
Bundle bundle = new Bundle();
ArrayList<AppTargetEvent> events = new ArrayList<>();
ArrayList<ItemInfo> workspaceItems = dataModel.getAllWorkspaceItems();
for (ItemInfo item : workspaceItems) {
AppTarget target = getAppTargetFromItemInfo(context, item);
if (target != null && !isTrackedForHotseatPrediction(item))
continue;
events.add(wrapAppTargetWithItemLocation(target, AppTargetEvent.ACTION_PIN, item));
}
ArrayList<AppTarget> currentTargets = new ArrayList<>();
FixedContainerItems hotseatItems = dataModel.extraItems.get(CONTAINER_HOTSEAT_PREDICTION);
if (hotseatItems != null) {
for (ItemInfo itemInfo : hotseatItems.items) {
AppTarget target = getAppTargetFromItemInfo(context, itemInfo);
if (target != null)
currentTargets.add(target);
}
}
bundle.putParcelableArrayList(BUNDLE_KEY_PIN_EVENTS, events);
bundle.putParcelableArrayList(BUNDLE_KEY_CURRENT_ITEMS, currentTargets);
return bundle;
}
use of com.android.launcher3.userevent.nano.LauncherLogProto.Target in project android_packages_apps_Launcher3 by ArrowOS.
the class DragController method findDropTarget.
private DropTarget findDropTarget(int x, int y, int[] dropCoordinates) {
mDragObject.x = x;
mDragObject.y = y;
final Rect r = mRectTemp;
final ArrayList<DropTarget> dropTargets = mDropTargets;
final int count = dropTargets.size();
for (int i = count - 1; i >= 0; i--) {
DropTarget target = dropTargets.get(i);
if (!target.isDropEnabled())
continue;
target.getHitRectRelativeToDragLayer(r);
if (r.contains(x, y)) {
dropCoordinates[0] = x;
dropCoordinates[1] = y;
mActivity.getDragLayer().mapCoordInSelfToDescendant((View) target, dropCoordinates);
return target;
}
}
// Pass all unhandled drag to workspace. Workspace finds the correct
// cell layout to drop to in the existing drag/drop logic.
dropCoordinates[0] = x;
dropCoordinates[1] = y;
return getDefaultDropTarget(dropCoordinates);
}
use of com.android.launcher3.userevent.nano.LauncherLogProto.Target in project android_packages_apps_Launcher3 by ArrowOS.
the class Folder method onDrop.
@Override
public void onDrop(DragObject d, DragOptions options) {
// the target location again such that the icon is placed of the final page.
if (!mContent.rankOnCurrentPage(mEmptyCellRank)) {
// Reorder again.
mTargetRank = getTargetRank(d, null);
// Rearrange items immediately.
mReorderAlarmListener.onAlarm(mReorderAlarm);
mOnScrollHintAlarm.cancelAlarm();
mScrollPauseAlarm.cancelAlarm();
}
mContent.completePendingPageChanges();
Launcher launcher = mLauncherDelegate.getLauncher();
if (launcher == null) {
return;
}
PendingAddShortcutInfo pasi = d.dragInfo instanceof PendingAddShortcutInfo ? (PendingAddShortcutInfo) d.dragInfo : null;
WorkspaceItemInfo pasiSi = pasi != null ? pasi.activityInfo.createWorkspaceItemInfo() : null;
if (pasi != null && pasiSi == null) {
// There is no WorkspaceItemInfo, so we have to go through a configuration activity.
pasi.container = mInfo.id;
pasi.rank = mEmptyCellRank;
launcher.addPendingItem(pasi, pasi.container, pasi.screenId, null, pasi.spanX, pasi.spanY);
d.deferDragViewCleanupPostAnimation = false;
mRearrangeOnClose = true;
} else {
final WorkspaceItemInfo si;
if (pasiSi != null) {
si = pasiSi;
} else if (d.dragInfo instanceof AppInfo) {
// Came from all apps -- make a copy.
si = ((AppInfo) d.dragInfo).makeWorkspaceItem();
} else {
// WorkspaceItemInfo
si = (WorkspaceItemInfo) d.dragInfo;
}
View currentDragView;
if (mIsExternalDrag) {
currentDragView = mContent.createAndAddViewForRank(si, mEmptyCellRank);
// Actually move the item in the database if it was an external drag. Call this
// before creating the view, so that WorkspaceItemInfo is updated appropriately.
mLauncherDelegate.getModelWriter().addOrMoveItemInDatabase(si, mInfo.id, 0, si.cellX, si.cellY);
mIsExternalDrag = false;
} else {
currentDragView = mCurrentDragView;
mContent.addViewForRank(currentDragView, si, mEmptyCellRank);
}
if (d.dragView.hasDrawn()) {
// Temporarily reset the scale such that the animation target gets calculated
// correctly.
float scaleX = getScaleX();
float scaleY = getScaleY();
setScaleX(1.0f);
setScaleY(1.0f);
launcher.getDragLayer().animateViewIntoPosition(d.dragView, currentDragView, null);
setScaleX(scaleX);
setScaleY(scaleY);
} else {
d.deferDragViewCleanupPostAnimation = false;
currentDragView.setVisibility(VISIBLE);
}
mItemsInvalidated = true;
rearrangeChildren();
// Temporarily suppress the listener, as we did all the work already here.
try (SuppressInfoChanges s = new SuppressInfoChanges()) {
mInfo.add(si, mEmptyCellRank, false);
}
// #onDropCompleted.
if (d.dragSource != this) {
updateItemLocationsInDatabaseBatch(false);
}
}
// Clear the drag info, as it is no longer being dragged.
mDragInProgress = false;
if (mContent.getPageCount() > 1) {
// The animation has already been shown while opening the folder.
mInfo.setOption(FolderInfo.FLAG_MULTI_PAGE_ANIMATION, true, mLauncherDelegate.getModelWriter());
}
launcher.getStateManager().goToState(NORMAL, SPRING_LOADED_EXIT_DELAY);
if (d.stateAnnouncer != null) {
d.stateAnnouncer.completeAction(R.string.item_moved);
}
mStatsLogManager.logger().withItemInfo(d.dragInfo).withInstanceId(d.logInstanceId).log(LAUNCHER_ITEM_DROP_COMPLETED);
}
use of com.android.launcher3.userevent.nano.LauncherLogProto.Target in project android_packages_apps_Launcher3 by ArrowOS.
the class Folder method onDropCompleted.
@Override
public void onDropCompleted(final View target, final DragObject d, final boolean success) {
if (success) {
if (mDeleteFolderOnDropCompleted && !mItemAddedBackToSelfViaIcon && target != this) {
replaceFolderWithFinalItem();
}
} else {
// The drag failed, we need to return the item to the folder
WorkspaceItemInfo info = (WorkspaceItemInfo) d.dragInfo;
View icon = (mCurrentDragView != null && mCurrentDragView.getTag() == info) ? mCurrentDragView : mContent.createNewView(info);
ArrayList<View> views = getIconsInReadingOrder();
info.rank = Utilities.boundToRange(info.rank, 0, views.size());
views.add(info.rank, icon);
mContent.arrangeChildren(views);
mItemsInvalidated = true;
try (SuppressInfoChanges s = new SuppressInfoChanges()) {
mFolderIcon.onDrop(d, true);
}
}
if (target != this) {
if (mOnExitAlarm.alarmPending()) {
mOnExitAlarm.cancelAlarm();
if (!success) {
mSuppressFolderDeletion = true;
}
mScrollPauseAlarm.cancelAlarm();
completeDragExit();
}
}
mDeleteFolderOnDropCompleted = false;
mDragInProgress = false;
mItemAddedBackToSelfViaIcon = false;
mCurrentDragView = null;
// Reordering may have occured, and we need to save the new item locations. We do this once
// at the end to prevent unnecessary database operations.
updateItemLocationsInDatabaseBatch(false);
// been refreshed yet.
if (getItemCount() <= mContent.itemsPerPage()) {
// Show the animation, next time something is added to the folder.
mInfo.setOption(FolderInfo.FLAG_MULTI_PAGE_ANIMATION, false, mLauncherDelegate.getModelWriter());
}
}
Aggregations