Search in sources :

Example 36 with WorkspaceItemInfo

use of com.android.launcher3.model.data.WorkspaceItemInfo in project android_packages_apps_Launcher3 by AOSPA.

the class ItemClickHandler method onClick.

private static void onClick(View v) {
    // view has detached (it's possible for this to happen if the view is removed mid touch).
    if (v.getWindowToken() == null)
        return;
    Launcher launcher = Launcher.getLauncher(v.getContext());
    if (!launcher.getWorkspace().isFinishedSwitchingState())
        return;
    Object tag = v.getTag();
    if (tag instanceof WorkspaceItemInfo) {
        onClickAppShortcut(v, (WorkspaceItemInfo) tag, launcher);
    } else if (tag instanceof FolderInfo) {
        if (v instanceof FolderIcon) {
            onClickFolderIcon(v);
        }
    } else if (tag instanceof AppInfo) {
        startAppShortcutOrInfoActivity(v, (AppInfo) tag, launcher);
    } else if (tag instanceof LauncherAppWidgetInfo) {
        if (v instanceof PendingAppWidgetHostView) {
            onClickPendingWidget((PendingAppWidgetHostView) v, launcher);
        }
    } else if (tag instanceof SearchActionItemInfo) {
        onClickSearchAction(launcher, (SearchActionItemInfo) tag);
    }
}
Also used : FolderIcon(com.android.launcher3.folder.FolderIcon) Launcher(com.android.launcher3.Launcher) LauncherAppWidgetInfo(com.android.launcher3.model.data.LauncherAppWidgetInfo) SearchActionItemInfo(com.android.launcher3.model.data.SearchActionItemInfo) PendingAppWidgetHostView(com.android.launcher3.widget.PendingAppWidgetHostView) FolderInfo(com.android.launcher3.model.data.FolderInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) AppInfo(com.android.launcher3.model.data.AppInfo)

Example 37 with WorkspaceItemInfo

use of com.android.launcher3.model.data.WorkspaceItemInfo in project android_packages_apps_Launcher3 by AOSPA.

the class PopupPopulator method createUpdateRunnable.

/**
 * Returns a runnable to update the provided shortcuts and notifications
 */
public static <T extends Context & ActivityContext> Runnable createUpdateRunnable(final T context, final ItemInfo originalInfo, final Handler uiHandler, final PopupContainerWithArrow container, final List<DeepShortcutView> shortcutViews, final List<NotificationKeyData> notificationKeys) {
    final ComponentName activity = originalInfo.getTargetComponent();
    final UserHandle user = originalInfo.user;
    return () -> {
        if (!notificationKeys.isEmpty()) {
            NotificationListener notificationListener = NotificationListener.getInstanceIfConnected();
            final List<NotificationInfo> infos;
            if (notificationListener == null) {
                infos = Collections.emptyList();
            } else {
                infos = notificationListener.getNotificationsForKeys(notificationKeys).stream().map(sbn -> new NotificationInfo(context, sbn, originalInfo)).collect(Collectors.toList());
            }
            uiHandler.post(() -> container.applyNotificationInfos(infos));
        }
        List<ShortcutInfo> shortcuts = new ShortcutRequest(context, user).withContainer(activity).query(ShortcutRequest.PUBLISHED);
        String shortcutIdToDeDupe = notificationKeys.isEmpty() ? null : notificationKeys.get(0).shortcutId;
        shortcuts = PopupPopulator.sortAndFilterShortcuts(shortcuts, shortcutIdToDeDupe);
        IconCache cache = LauncherAppState.getInstance(context).getIconCache();
        for (int i = 0; i < shortcuts.size() && i < shortcutViews.size(); i++) {
            final ShortcutInfo shortcut = shortcuts.get(i);
            final WorkspaceItemInfo si = new WorkspaceItemInfo(shortcut, context);
            cache.getUnbadgedShortcutIcon(si, shortcut);
            si.rank = i;
            si.container = CONTAINER_SHORTCUTS;
            final DeepShortcutView view = shortcutViews.get(i);
            uiHandler.post(() -> view.applyShortcutInfo(si, shortcut, container));
        }
    };
}
Also used : Context(android.content.Context) Iterator(java.util.Iterator) ActivityContext(com.android.launcher3.views.ActivityContext) ComponentName(android.content.ComponentName) ShortcutInfo(android.content.pm.ShortcutInfo) CONTAINER_SHORTCUTS(com.android.launcher3.LauncherSettings.Favorites.CONTAINER_SHORTCUTS) LauncherAppState(com.android.launcher3.LauncherAppState) ItemInfo(com.android.launcher3.model.data.ItemInfo) DeepShortcutView(com.android.launcher3.shortcuts.DeepShortcutView) IconCache(com.android.launcher3.icons.IconCache) Collectors(java.util.stream.Collectors) NotificationInfo(com.android.launcher3.notification.NotificationInfo) NotificationKeyData(com.android.launcher3.notification.NotificationKeyData) ArrayList(java.util.ArrayList) List(java.util.List) Nullable(androidx.annotation.Nullable) NotificationListener(com.android.launcher3.notification.NotificationListener) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) Handler(android.os.Handler) UserHandle(android.os.UserHandle) ShortcutRequest(com.android.launcher3.shortcuts.ShortcutRequest) Comparator(java.util.Comparator) VisibleForTesting(androidx.annotation.VisibleForTesting) Collections(java.util.Collections) NotificationInfo(com.android.launcher3.notification.NotificationInfo) ShortcutInfo(android.content.pm.ShortcutInfo) UserHandle(android.os.UserHandle) IconCache(com.android.launcher3.icons.IconCache) ComponentName(android.content.ComponentName) ArrayList(java.util.ArrayList) List(java.util.List) ShortcutRequest(com.android.launcher3.shortcuts.ShortcutRequest) DeepShortcutView(com.android.launcher3.shortcuts.DeepShortcutView) NotificationListener(com.android.launcher3.notification.NotificationListener) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 38 with WorkspaceItemInfo

use of com.android.launcher3.model.data.WorkspaceItemInfo in project android_packages_apps_Launcher3 by AOSPA.

the class InstantAppItemInfo method makeWorkspaceItem.

@Override
public WorkspaceItemInfo makeWorkspaceItem() {
    WorkspaceItemInfo workspaceItemInfo = super.makeWorkspaceItem();
    workspaceItemInfo.itemType = LauncherSettings.Favorites.ITEM_TYPE_APPLICATION;
    workspaceItemInfo.status = WorkspaceItemInfo.FLAG_AUTOINSTALL_ICON | WorkspaceItemInfo.FLAG_RESTORE_STARTED | WorkspaceItemInfo.FLAG_SUPPORTS_WEB_UI;
    workspaceItemInfo.getIntent().setPackage(componentName.getPackageName());
    return workspaceItemInfo;
}
Also used : WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 39 with WorkspaceItemInfo

use of com.android.launcher3.model.data.WorkspaceItemInfo in project android_packages_apps_Launcher3 by AOSPA.

the class HotseatPredictionController method pinPrediction.

/**
 * Pins a predicted app icon into place.
 */
public void pinPrediction(ItemInfo info) {
    PredictedAppIcon icon = (PredictedAppIcon) mHotseat.getChildAt(mHotseat.getCellXFromOrder(info.rank), mHotseat.getCellYFromOrder(info.rank));
    if (icon == null) {
        return;
    }
    WorkspaceItemInfo workspaceItemInfo = new WorkspaceItemInfo((WorkspaceItemInfo) info);
    mLauncher.getModelWriter().addItemToDatabase(workspaceItemInfo, LauncherSettings.Favorites.CONTAINER_HOTSEAT, workspaceItemInfo.screenId, workspaceItemInfo.cellX, workspaceItemInfo.cellY);
    ObjectAnimator.ofFloat(icon, SCALE_PROPERTY, 1, 0.8f, 1).start();
    icon.pin(workspaceItemInfo);
    mLauncher.getStatsLogManager().logger().withItemInfo(workspaceItemInfo).log(LAUNCHER_HOTSEAT_PREDICTION_PINNED);
}
Also used : PredictedAppIcon(com.android.launcher3.uioverrides.PredictedAppIcon) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 40 with WorkspaceItemInfo

use of com.android.launcher3.model.data.WorkspaceItemInfo in project android_packages_apps_Launcher3 by AOSPA.

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;
}
Also used : Rect(android.graphics.Rect) ItemInfo(com.android.launcher3.model.data.ItemInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) BubbleTextView(com.android.launcher3.BubbleTextView) BubbleTextView(com.android.launcher3.BubbleTextView) View(android.view.View) ArrowTipView(com.android.launcher3.views.ArrowTipView) ArrowTipView(com.android.launcher3.views.ArrowTipView) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Aggregations

WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)418 View (android.view.View)168 ArrayList (java.util.ArrayList)145 ItemInfo (com.android.launcher3.model.data.ItemInfo)125 Intent (android.content.Intent)119 FolderInfo (com.android.launcher3.model.data.FolderInfo)100 AppInfo (com.android.launcher3.model.data.AppInfo)94 BubbleTextView (com.android.launcher3.BubbleTextView)87 AppWidgetHostView (android.appwidget.AppWidgetHostView)84 SuppressLint (android.annotation.SuppressLint)78 DragView (com.android.launcher3.dragndrop.DragView)78 ComponentName (android.content.ComponentName)76 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)73 PendingAppWidgetHostView (com.android.launcher3.widget.PendingAppWidgetHostView)72 Rect (android.graphics.Rect)68 FolderIcon (com.android.launcher3.folder.FolderIcon)68 Context (android.content.Context)62 HashSet (java.util.HashSet)62 Point (android.graphics.Point)59 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)57