Search in sources :

Example 1 with StatsLogger

use of com.android.launcher3.logging.StatsLogManager.StatsLogger in project android_packages_apps_Launcher3 by crdroidandroid.

the class Folder method onFocusChange.

@Override
public void onFocusChange(View v, boolean hasFocus) {
    if (v == mFolderName) {
        if (hasFocus) {
            mFromLabelState = mInfo.getFromLabelState();
            mFromTitle = mInfo.title;
            startEditingFolderName();
        } else {
            StatsLogger statsLogger = mStatsLogManager.logger().withItemInfo(mInfo).withFromState(mFromLabelState);
            // If the folder label is suggested, it is logged to improve prediction model.
            // When both old and new labels are logged together delimiter is used.
            StringJoiner labelInfoBuilder = new StringJoiner(FOLDER_LABEL_DELIMITER);
            if (mFromLabelState.equals(FromState.FROM_SUGGESTED)) {
                labelInfoBuilder.add(mFromTitle);
            }
            ToState toLabelState;
            if (mFromTitle != null && mFromTitle.equals(mInfo.title)) {
                toLabelState = ToState.UNCHANGED;
            } else {
                toLabelState = mInfo.getToLabelState();
                if (toLabelState.toString().startsWith("TO_SUGGESTION")) {
                    labelInfoBuilder.add(mInfo.title);
                }
            }
            statsLogger.withToState(toLabelState);
            if (labelInfoBuilder.length() > 0) {
                statsLogger.withEditText(labelInfoBuilder.toString());
            }
            statsLogger.log(LAUNCHER_FOLDER_LABEL_UPDATED);
            mFolderName.dispatchBackKey();
        }
    }
}
Also used : StatsLogger(com.android.launcher3.logging.StatsLogManager.StatsLogger) ToState(com.android.launcher3.logger.LauncherAtom.ToState) StringJoiner(java.util.StringJoiner)

Example 2 with StatsLogger

use of com.android.launcher3.logging.StatsLogManager.StatsLogger in project android_packages_apps_Launcher3 by crdroidandroid.

the class AbsSwipeUpHandler method doLogGesture.

private void doLogGesture(GestureEndTarget endTarget, @Nullable TaskView targetTask) {
    StatsLogManager.EventEnum event;
    switch(endTarget) {
        case HOME:
            event = LAUNCHER_HOME_GESTURE;
            break;
        case RECENTS:
            event = LAUNCHER_OVERVIEW_GESTURE;
            break;
        case LAST_TASK:
        case NEW_TASK:
            event = mLogDirectionUpOrLeft ? LAUNCHER_QUICKSWITCH_LEFT : LAUNCHER_QUICKSWITCH_RIGHT;
            break;
        default:
            event = IGNORE;
    }
    StatsLogger logger = StatsLogManager.newInstance(mContext).logger().withSrcState(LAUNCHER_STATE_BACKGROUND).withDstState(endTarget.containerType);
    if (targetTask != null) {
        logger.withItemInfo(targetTask.getItemInfo());
    }
    DeviceProfile dp = mDp;
    if (dp == null || mDownPos == null) {
        // We probably never received an animation controller, skip logging.
        return;
    }
    int pageIndex = endTarget == LAST_TASK ? LOG_NO_OP_PAGE_INDEX : mRecentsView.getNextPage();
    // TODO: set correct container using the pageIndex
    logger.log(event);
}
Also used : DeviceProfile(com.android.launcher3.DeviceProfile) StatsLogger(com.android.launcher3.logging.StatsLogManager.StatsLogger) StatsLogManager(com.android.launcher3.logging.StatsLogManager)

Example 3 with StatsLogger

use of com.android.launcher3.logging.StatsLogManager.StatsLogger in project android_packages_apps_Launcher3 by crdroidandroid.

the class ItemLongClickListener method onAllAppsItemLongClick.

private static boolean onAllAppsItemLongClick(View v) {
    TestLogging.recordEvent(TestProtocol.SEQUENCE_MAIN, "onAllAppsItemLongClick");
    v.cancelLongPress();
    Launcher launcher = Launcher.getLauncher(v.getContext());
    if (!canStartDrag(launcher))
        return false;
    // When we have exited all apps or are in transition, disregard long clicks
    if (!launcher.isInState(ALL_APPS) && !launcher.isInState(OVERVIEW))
        return false;
    if (launcher.getWorkspace().isSwitchingState())
        return false;
    StatsLogger logger = launcher.getStatsLogManager().logger();
    if (v.getTag() instanceof ItemInfo) {
        logger.withItemInfo((ItemInfo) v.getTag());
    }
    logger.log(LAUNCHER_ALLAPPS_ITEM_LONG_PRESSED);
    // Start the drag
    final DragController dragController = launcher.getDragController();
    dragController.addDragListener(new DragController.DragListener() {

        @Override
        public void onDragStart(DropTarget.DragObject dragObject, DragOptions options) {
            v.setVisibility(INVISIBLE);
        }

        @Override
        public void onDragEnd() {
            v.setVisibility(VISIBLE);
            dragController.removeDragListener(this);
        }
    });
    DeviceProfile grid = launcher.getDeviceProfile();
    DragOptions options = new DragOptions();
    options.intrinsicIconScaleFactor = (float) grid.allAppsIconSizePx / grid.iconSizePx;
    launcher.getWorkspace().beginDragShared(v, launcher.getAppsView(), options);
    return false;
}
Also used : DragOptions(com.android.launcher3.dragndrop.DragOptions) DeviceProfile(com.android.launcher3.DeviceProfile) StatsLogger(com.android.launcher3.logging.StatsLogManager.StatsLogger) ItemInfo(com.android.launcher3.model.data.ItemInfo) DragController(com.android.launcher3.dragndrop.DragController) Launcher(com.android.launcher3.Launcher) DropTarget(com.android.launcher3.DropTarget)

Example 4 with StatsLogger

use of com.android.launcher3.logging.StatsLogManager.StatsLogger in project android_packages_apps_Launcher3 by crdroidandroid.

the class LauncherDelegate method replaceFolderWithFinalItem.

void replaceFolderWithFinalItem(Folder folder) {
    // Add the last remaining child to the workspace in place of the folder
    Runnable onCompleteRunnable = new Runnable() {

        @Override
        public void run() {
            int itemCount = folder.getItemCount();
            FolderInfo info = folder.mInfo;
            if (itemCount <= 1) {
                View newIcon = null;
                WorkspaceItemInfo finalItem = null;
                if (itemCount == 1) {
                    // Move the item from the folder to the workspace, in the position of the
                    // folder
                    CellLayout cellLayout = mLauncher.getCellLayout(info.container, info.screenId);
                    finalItem = info.contents.remove(0);
                    newIcon = mLauncher.createShortcut(cellLayout, finalItem);
                    mLauncher.getModelWriter().addOrMoveItemInDatabase(finalItem, info.container, info.screenId, info.cellX, info.cellY);
                }
                // Remove the folder
                mLauncher.removeItem(folder.mFolderIcon, info, true);
                if (folder.mFolderIcon instanceof DropTarget) {
                    folder.mDragController.removeDropTarget((DropTarget) folder.mFolderIcon);
                }
                if (newIcon != null) {
                    // We add the child after removing the folder to prevent both from existing
                    // at the same time in the CellLayout.  We need to add the new item with
                    // addInScreenFromBind() to ensure that hotseat items are placed correctly.
                    mLauncher.getWorkspace().addInScreenFromBind(newIcon, info);
                    // Focus the newly created child
                    newIcon.requestFocus();
                }
                if (finalItem != null) {
                    StatsLogger logger = mLauncher.getStatsLogManager().logger().withItemInfo(finalItem);
                    ((Optional<InstanceId>) folder.mDragController.getLogInstanceId()).map(logger::withInstanceId).orElse(logger).log(LAUNCHER_FOLDER_CONVERTED_TO_ICON);
                }
            }
        }
    };
    View finalChild = folder.mContent.getLastItem();
    if (finalChild != null) {
        folder.mFolderIcon.performDestroyAnimation(onCompleteRunnable);
    } else {
        onCompleteRunnable.run();
    }
}
Also used : StatsLogger(com.android.launcher3.logging.StatsLogManager.StatsLogger) CellLayout(com.android.launcher3.CellLayout) Optional(java.util.Optional) DropTarget(com.android.launcher3.DropTarget) FolderInfo(com.android.launcher3.model.data.FolderInfo) View(android.view.View) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 5 with StatsLogger

use of com.android.launcher3.logging.StatsLogManager.StatsLogger in project android_packages_apps_Launcher3 by crdroidandroid.

the class QuickstepLauncher method logAppLaunch.

@Override
protected void logAppLaunch(ItemInfo info, InstanceId instanceId) {
    // LiveSearchManager to recreate the AllApps session on the server side.
    if (mAllAppsSessionLogId != null && ALL_APPS.equals(getStateManager().getCurrentStableState())) {
        instanceId = mAllAppsSessionLogId;
    }
    StatsLogger logger = getStatsLogManager().logger().withItemInfo(info).withInstanceId(instanceId);
    if (mAllAppsPredictions != null && (info.itemType == ITEM_TYPE_APPLICATION || info.itemType == ITEM_TYPE_SHORTCUT || info.itemType == ITEM_TYPE_DEEP_SHORTCUT)) {
        int count = mAllAppsPredictions.items.size();
        for (int i = 0; i < count; i++) {
            ItemInfo targetInfo = mAllAppsPredictions.items.get(i);
            if (targetInfo.itemType == info.itemType && targetInfo.user.equals(info.user) && Objects.equals(targetInfo.getIntent(), info.getIntent())) {
                logger.withRank(i);
                break;
            }
        }
    }
    logger.log(LAUNCHER_APP_LAUNCH_TAP);
    mHotseatPredictionController.logLaunchedAppRankingInfo(info, instanceId);
}
Also used : StatsLogger(com.android.launcher3.logging.StatsLogManager.StatsLogger) ItemInfo(com.android.launcher3.model.data.ItemInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Aggregations

StatsLogger (com.android.launcher3.logging.StatsLogManager.StatsLogger)6 DeviceProfile (com.android.launcher3.DeviceProfile)2 DropTarget (com.android.launcher3.DropTarget)2 StatsLogManager (com.android.launcher3.logging.StatsLogManager)2 ItemInfo (com.android.launcher3.model.data.ItemInfo)2 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)2 SharedPreferences (android.content.SharedPreferences)1 View (android.view.View)1 CellLayout (com.android.launcher3.CellLayout)1 Launcher (com.android.launcher3.Launcher)1 DragController (com.android.launcher3.dragndrop.DragController)1 DragOptions (com.android.launcher3.dragndrop.DragOptions)1 ToState (com.android.launcher3.logger.LauncherAtom.ToState)1 InstanceIdSequence (com.android.launcher3.logging.InstanceIdSequence)1 FolderInfo (com.android.launcher3.model.data.FolderInfo)1 Optional (java.util.Optional)1 StringJoiner (java.util.StringJoiner)1