Search in sources :

Example 1 with IGNORE

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

the class LauncherAccessibilityDelegate method getSupportedResizeActions.

private List<OptionItem> getSupportedResizeActions(View host, LauncherAppWidgetInfo info) {
    List<OptionItem> actions = new ArrayList<>();
    AppWidgetProviderInfo providerInfo = ((LauncherAppWidgetHostView) host).getAppWidgetInfo();
    if (providerInfo == null) {
        return actions;
    }
    CellLayout layout;
    if (host.getParent() instanceof DragView) {
        layout = (CellLayout) ((DragView) host.getParent()).getContentViewParent().getParent();
    } else {
        layout = (CellLayout) host.getParent().getParent();
    }
    if ((providerInfo.resizeMode & AppWidgetProviderInfo.RESIZE_HORIZONTAL) != 0) {
        if (layout.isRegionVacant(info.cellX + info.spanX, info.cellY, 1, info.spanY) || layout.isRegionVacant(info.cellX - 1, info.cellY, 1, info.spanY)) {
            actions.add(new OptionItem(mLauncher, R.string.action_increase_width, R.drawable.ic_widget_width_increase, IGNORE, v -> performResizeAction(R.string.action_increase_width, host, info)));
        }
        if (info.spanX > info.minSpanX && info.spanX > 1) {
            actions.add(new OptionItem(mLauncher, R.string.action_decrease_width, R.drawable.ic_widget_width_decrease, IGNORE, v -> performResizeAction(R.string.action_decrease_width, host, info)));
        }
    }
    if ((providerInfo.resizeMode & AppWidgetProviderInfo.RESIZE_VERTICAL) != 0) {
        if (layout.isRegionVacant(info.cellX, info.cellY + info.spanY, info.spanX, 1) || layout.isRegionVacant(info.cellX, info.cellY - 1, info.spanX, 1)) {
            actions.add(new OptionItem(mLauncher, R.string.action_increase_height, R.drawable.ic_widget_height_increase, IGNORE, v -> performResizeAction(R.string.action_increase_height, host, info)));
        }
        if (info.spanY > info.minSpanY && info.spanY > 1) {
            actions.add(new OptionItem(mLauncher, R.string.action_decrease_height, R.drawable.ic_widget_height_decrease, IGNORE, v -> performResizeAction(R.string.action_decrease_height, host, info)));
        }
    }
    return actions;
}
Also used : Rect(android.graphics.Rect) Bundle(android.os.Bundle) AccessibilityDelegate(android.view.View.AccessibilityDelegate) KeyboardDragAndDropView(com.android.launcher3.keyboard.KeyboardDragAndDropView) AppWidgetProviderInfo(android.appwidget.AppWidgetProviderInfo) BubbleTextView(com.android.launcher3.BubbleTextView) OptionsPopupView(com.android.launcher3.views.OptionsPopupView) IGNORE(com.android.launcher3.logging.StatsLogManager.LauncherEvent.IGNORE) Handler(android.os.Handler) AccessibilityAction(android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction) FolderInfo(com.android.launcher3.model.data.FolderInfo) View(android.view.View) ButtonDropTarget(com.android.launcher3.ButtonDropTarget) Log(android.util.Log) PendingAddItemInfo(com.android.launcher3.PendingAddItemInfo) RectF(android.graphics.RectF) ACTION_LONG_CLICK(android.view.accessibility.AccessibilityNodeInfo.ACTION_LONG_CLICK) Launcher(com.android.launcher3.Launcher) Favorites(com.android.launcher3.LauncherSettings.Favorites) DragOptions(com.android.launcher3.dragndrop.DragOptions) SparseArray(android.util.SparseArray) WidgetSizes(com.android.launcher3.widget.util.WidgetSizes) List(java.util.List) NotificationListener(com.android.launcher3.notification.NotificationListener) ShortcutUtil(com.android.launcher3.util.ShortcutUtil) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) Workspace(com.android.launcher3.Workspace) NORMAL(com.android.launcher3.LauncherState.NORMAL) Folder(com.android.launcher3.folder.Folder) AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo) ArrowPopup(com.android.launcher3.popup.ArrowPopup) KeyEvent(android.view.KeyEvent) AppInfo(com.android.launcher3.model.data.AppInfo) ItemInfo(com.android.launcher3.model.data.ItemInfo) ArrayList(java.util.ArrayList) PopupContainerWithArrow(com.android.launcher3.popup.PopupContainerWithArrow) ItemLongClickListener(com.android.launcher3.touch.ItemLongClickListener) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) AnimatorListeners.forSuccessCallback(com.android.launcher3.anim.AnimatorListeners.forSuccessCallback) DragObject(com.android.launcher3.DropTarget.DragObject) DragListener(com.android.launcher3.dragndrop.DragController.DragListener) IntArray(com.android.launcher3.util.IntArray) LauncherAppWidgetInfo(com.android.launcher3.model.data.LauncherAppWidgetInfo) Point(android.graphics.Point) TextUtils(android.text.TextUtils) CellLayout(com.android.launcher3.CellLayout) OptionItem(com.android.launcher3.views.OptionsPopupView.OptionItem) R(com.android.launcher3.R) Thunk(com.android.launcher3.util.Thunk) Collections(java.util.Collections) DragView(com.android.launcher3.dragndrop.DragView) OptionItem(com.android.launcher3.views.OptionsPopupView.OptionItem) CellLayout(com.android.launcher3.CellLayout) ArrayList(java.util.ArrayList) AppWidgetProviderInfo(android.appwidget.AppWidgetProviderInfo) DragView(com.android.launcher3.dragndrop.DragView) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView)

Example 2 with IGNORE

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

the class LauncherAppWidgetProviderInfo method initSpans.

public void initSpans(Context context, InvariantDeviceProfile idp) {
    int minSpanX = 0;
    int minSpanY = 0;
    int maxSpanX = idp.numColumns;
    int maxSpanY = idp.numRows;
    int spanX = 0;
    int spanY = 0;
    Rect widgetPadding = new Rect();
    Rect localPadding = new Rect();
    AppWidgetHostView.getDefaultPaddingForWidget(context, provider, widgetPadding);
    Point cellSize = new Point();
    for (DeviceProfile dp : idp.supportedProfiles) {
        dp.getCellSize(cellSize);
        // If grids supports insetting widgets, we do not account for widget padding.
        if (dp.shouldInsetWidgets()) {
            localPadding.setEmpty();
        } else {
            localPadding.set(widgetPadding);
        }
        minSpanX = Math.max(minSpanX, getSpanX(localPadding, minResizeWidth, dp.cellLayoutBorderSpacingPx, cellSize.x));
        minSpanY = Math.max(minSpanY, getSpanY(localPadding, minResizeHeight, dp.cellLayoutBorderSpacingPx, cellSize.y));
        if (ATLEAST_S) {
            if (maxResizeWidth > 0) {
                maxSpanX = Math.min(maxSpanX, getSpanX(localPadding, maxResizeWidth, dp.cellLayoutBorderSpacingPx, cellSize.x));
            }
            if (maxResizeHeight > 0) {
                maxSpanY = Math.min(maxSpanY, getSpanY(localPadding, maxResizeHeight, dp.cellLayoutBorderSpacingPx, cellSize.y));
            }
        }
        spanX = Math.max(spanX, getSpanX(localPadding, minWidth, dp.cellLayoutBorderSpacingPx, cellSize.x));
        spanY = Math.max(spanY, getSpanY(localPadding, minHeight, dp.cellLayoutBorderSpacingPx, cellSize.y));
    }
    if (ATLEAST_S) {
        // Ensures maxSpan >= minSpan
        maxSpanX = Math.max(maxSpanX, minSpanX);
        maxSpanY = Math.max(maxSpanY, minSpanY);
        // Otherwise, use the span of minWidth/Height.
        if (targetCellWidth >= minSpanX && targetCellWidth <= maxSpanX && targetCellHeight >= minSpanY && targetCellHeight <= maxSpanY) {
            spanX = targetCellWidth;
            spanY = targetCellHeight;
        }
    }
    // If minSpanX/Y > spanX/Y, ignore the minSpanX/Y to match the behavior described in
    // minResizeWidth & minResizeHeight Android documentation. See
    // https://developer.android.com/reference/android/appwidget/AppWidgetProviderInfo
    this.minSpanX = Math.min(spanX, minSpanX);
    this.minSpanY = Math.min(spanY, minSpanY);
    this.maxSpanX = maxSpanX;
    this.maxSpanY = maxSpanY;
    this.mIsMinSizeFulfilled = Math.min(spanX, minSpanX) <= idp.numColumns && Math.min(spanY, minSpanY) <= idp.numRows;
    // Ensures the default span X and span Y will not exceed the current grid size.
    this.spanX = Math.min(spanX, idp.numColumns);
    this.spanY = Math.min(spanY, idp.numRows);
}
Also used : DeviceProfile(com.android.launcher3.DeviceProfile) InvariantDeviceProfile(com.android.launcher3.InvariantDeviceProfile) Rect(android.graphics.Rect) Point(android.graphics.Point) Point(android.graphics.Point)

Example 3 with IGNORE

use of com.android.launcher3.logging.StatsLogManager.LauncherEvent.IGNORE 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 4 with IGNORE

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

the class PackageInstallStateChangedTask method execute.

@Override
public void execute(LauncherAppState app, BgDataModel dataModel, AllAppsList apps) {
    if (mInstallInfo.state == PackageInstallInfo.STATUS_INSTALLED) {
        try {
            // For instant apps we do not get package-add. Use setting events to update
            // any pinned icons.
            ApplicationInfo ai = app.getContext().getPackageManager().getApplicationInfo(mInstallInfo.packageName, 0);
            if (InstantAppResolver.newInstance(app.getContext()).isInstantApp(ai)) {
                app.getModel().onPackageAdded(ai.packageName, mInstallInfo.user);
            }
        } catch (PackageManager.NameNotFoundException e) {
        // Ignore
        }
        // Ignore install success events as they are handled by Package add events.
        return;
    }
    synchronized (apps) {
        List<AppInfo> updatedAppInfos = apps.updatePromiseInstallInfo(mInstallInfo);
        if (!updatedAppInfos.isEmpty()) {
            for (AppInfo appInfo : updatedAppInfos) {
                scheduleCallbackTask(c -> c.bindIncrementalDownloadProgressUpdated(appInfo));
            }
        }
        bindApplicationsIfNeeded();
    }
    synchronized (dataModel) {
        final HashSet<ItemInfo> updates = new HashSet<>();
        dataModel.forAllWorkspaceItemInfos(mInstallInfo.user, si -> {
            if (si.hasPromiseIconUi() && mInstallInfo.packageName.equals(si.getTargetPackage())) {
                si.setProgressLevel(mInstallInfo);
                updates.add(si);
            }
        });
        for (LauncherAppWidgetInfo widget : dataModel.appWidgets) {
            if (widget.providerName.getPackageName().equals(mInstallInfo.packageName)) {
                widget.installProgress = mInstallInfo.progress;
                updates.add(widget);
            }
        }
        if (!updates.isEmpty()) {
            scheduleCallbackTask(callbacks -> callbacks.bindRestoreItemsChange(updates));
        }
    }
}
Also used : PackageManager(android.content.pm.PackageManager) ItemInfo(com.android.launcher3.model.data.ItemInfo) ApplicationInfo(android.content.pm.ApplicationInfo) LauncherAppWidgetInfo(com.android.launcher3.model.data.LauncherAppWidgetInfo) AppInfo(com.android.launcher3.model.data.AppInfo) HashSet(java.util.HashSet)

Example 5 with IGNORE

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

the class Launcher method dump.

/**
 * $ adb shell dumpsys activity com.android.launcher3.Launcher [--all]
 */
@Override
public void dump(String prefix, FileDescriptor fd, PrintWriter writer, String[] args) {
    super.dump(prefix, fd, writer, args);
    if (args.length > 0 && TextUtils.equals(args[0], "--all")) {
        writer.println(prefix + "Workspace Items");
        for (int i = 0; i < mWorkspace.getPageCount(); i++) {
            writer.println(prefix + "  Homescreen " + i);
            ViewGroup layout = ((CellLayout) mWorkspace.getPageAt(i)).getShortcutsAndWidgets();
            for (int j = 0; j < layout.getChildCount(); j++) {
                Object tag = layout.getChildAt(j).getTag();
                if (tag != null) {
                    writer.println(prefix + "    " + tag.toString());
                }
            }
        }
        writer.println(prefix + "  Hotseat");
        ViewGroup layout = mHotseat.getShortcutsAndWidgets();
        for (int j = 0; j < layout.getChildCount(); j++) {
            Object tag = layout.getChildAt(j).getTag();
            if (tag != null) {
                writer.println(prefix + "    " + tag.toString());
            }
        }
    }
    writer.println(prefix + "Misc:");
    dumpMisc(prefix + "\t", writer);
    writer.println(prefix + "\tmWorkspaceLoading=" + mWorkspaceLoading);
    writer.println(prefix + "\tmPendingRequestArgs=" + mPendingRequestArgs + " mPendingActivityResult=" + mPendingActivityResult);
    writer.println(prefix + "\tmRotationHelper: " + mRotationHelper);
    writer.println(prefix + "\tmAppWidgetHost.isListening: " + mAppWidgetHost.isListening());
    // Extra logging for general debugging
    mDragLayer.dump(prefix, writer);
    mStateManager.dump(prefix, writer);
    mPopupDataProvider.dump(prefix, writer);
    mDeviceProfile.dump(prefix, writer);
    try {
        FileLog.flushAll(writer);
    } catch (Exception e) {
    // Ignore
    }
    mModel.dumpState(prefix, fd, writer, args);
    if (mLauncherCallbacks != null) {
        mLauncherCallbacks.dump(prefix, fd, writer, args);
    }
    mOverlayManager.dump(prefix, writer);
}
Also used : ViewGroup(android.view.ViewGroup) DragObject(com.android.launcher3.DropTarget.DragObject) ActivityNotFoundException(android.content.ActivityNotFoundException)

Aggregations

Point (android.graphics.Point)3 Rect (android.graphics.Rect)3 View (android.view.View)3 LargeTest (androidx.test.filters.LargeTest)3 ShortcutInfo (android.content.pm.ShortcutInfo)2 ImageView (android.widget.ImageView)2 DeviceProfile (com.android.launcher3.DeviceProfile)2 DragObject (com.android.launcher3.DropTarget.DragObject)2 AllAppsPagedView (com.android.launcher3.allapps.AllAppsPagedView)2 ShortcutCachingLogic (com.android.launcher3.icons.ShortcutCachingLogic)2 AppInfo (com.android.launcher3.model.data.AppInfo)2 ItemInfo (com.android.launcher3.model.data.ItemInfo)2 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)2 Objects (java.util.Objects)2 Ignore (org.junit.Ignore)2 Test (org.junit.Test)2 Animator (android.animation.Animator)1 AnimatorSet (android.animation.AnimatorSet)1 ObjectAnimator (android.animation.ObjectAnimator)1 ValueAnimator (android.animation.ValueAnimator)1