Search in sources :

Example 36 with ItemInfo

use of com.android.launcher3.ItemInfo in project android_packages_apps_Launcher3 by crdroidandroid.

the class QuickstepInteractionHandler method onInteraction.

@SuppressWarnings("NewApi")
@Override
public boolean onInteraction(View view, PendingIntent pendingIntent, RemoteViews.RemoteResponse remoteResponse) {
    LauncherAppWidgetHostView hostView = findHostViewAncestor(view);
    if (hostView == null) {
        Log.e(TAG, "View did not have a LauncherAppWidgetHostView ancestor.");
        return RemoteViews.startPendingIntent(hostView, pendingIntent, remoteResponse.getLaunchOptions(view));
    }
    Pair<Intent, ActivityOptions> options = remoteResponse.getLaunchOptions(view);
    ActivityOptionsWrapper activityOptions = mLauncher.getAppTransitionManager().getActivityLaunchOptions(hostView);
    if (Utilities.ATLEAST_S && !pendingIntent.isActivity()) {
        // use the Quickstep transition animation.
        try {
            ActivityTaskManager.getService().registerRemoteAnimationForNextActivityStart(pendingIntent.getCreatorPackage(), activityOptions.options.getRemoteAnimationAdapter());
        } catch (RemoteException e) {
        // Do nothing.
        }
    }
    activityOptions.options.setPendingIntentLaunchFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    activityOptions.options.setSplashscreenStyle(SplashScreen.SPLASH_SCREEN_STYLE_EMPTY);
    Object itemInfo = hostView.getTag();
    if (itemInfo instanceof ItemInfo) {
        mLauncher.addLaunchCookie((ItemInfo) itemInfo, activityOptions.options);
    }
    options = Pair.create(options.first, activityOptions.options);
    if (pendingIntent.isActivity()) {
        logAppLaunch(itemInfo);
    }
    return RemoteViews.startPendingIntent(hostView, pendingIntent, options);
}
Also used : ItemInfo(com.android.launcher3.model.data.ItemInfo) ActivityOptionsWrapper(com.android.launcher3.util.ActivityOptionsWrapper) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) RemoteException(android.os.RemoteException) ActivityOptions(android.app.ActivityOptions)

Example 37 with ItemInfo

use of com.android.launcher3.ItemInfo in project android_packages_apps_Launcher3 by crdroidandroid.

the class TaskbarView method updateHotseatItems.

/**
 * Inflates/binds the Hotseat views to show in the Taskbar given their ItemInfos.
 */
protected void updateHotseatItems(ItemInfo[] hotseatItemInfos) {
    for (int i = 0; i < hotseatItemInfos.length; i++) {
        ItemInfo hotseatItemInfo = hotseatItemInfos[!mIsRtl ? i : hotseatItemInfos.length - i - 1];
        View hotseatView = mHotseatIconsContainer.getChildAt(i);
        // Replace any Hotseat views with the appropriate type if it's not already that type.
        final int expectedLayoutResId;
        boolean isFolder = false;
        boolean needsReinflate = false;
        if (hotseatItemInfo != null && hotseatItemInfo.isPredictedItem()) {
            expectedLayoutResId = R.layout.taskbar_predicted_app_icon;
        } else if (hotseatItemInfo instanceof FolderInfo) {
            expectedLayoutResId = R.layout.folder_icon;
            isFolder = true;
            // Unlike for BubbleTextView, we can't reapply a new FolderInfo after inflation, so
            // if the info changes we need to reinflate. This should only happen if a new folder
            // is dragged to the position that another folder previously existed.
            needsReinflate = hotseatView != null && hotseatView.getTag() != hotseatItemInfo;
        } else {
            expectedLayoutResId = R.layout.taskbar_app_icon;
        }
        if (hotseatView == null || hotseatView.getSourceLayoutResId() != expectedLayoutResId || needsReinflate) {
            mHotseatIconsContainer.removeView(hotseatView);
            if (isFolder) {
                FolderInfo folderInfo = (FolderInfo) hotseatItemInfo;
                FolderIcon folderIcon = FolderIcon.inflateFolderAndIcon(expectedLayoutResId, mActivityContext, this, folderInfo);
                folderIcon.setTextVisible(false);
                hotseatView = folderIcon;
            } else {
                hotseatView = inflate(expectedLayoutResId);
            }
            int iconSize = mActivityContext.getDeviceProfile().iconSizePx;
            LayoutParams lp = new LayoutParams(iconSize, iconSize);
            lp.setMargins(mItemMarginLeftRight, 0, mItemMarginLeftRight, 0);
            mHotseatIconsContainer.addView(hotseatView, i, lp);
        }
        // Apply the Hotseat ItemInfos, or hide the view if there is none for a given index.
        if (hotseatView instanceof BubbleTextView && hotseatItemInfo instanceof WorkspaceItemInfo) {
            ((BubbleTextView) hotseatView).applyFromWorkspaceItem((WorkspaceItemInfo) hotseatItemInfo);
            hotseatView.setOnClickListener(mIconClickListener);
            hotseatView.setOnLongClickListener(mIconLongClickListener);
        } else if (isFolder) {
            hotseatView.setOnClickListener(mIconClickListener);
            hotseatView.setOnLongClickListener(mIconLongClickListener);
        } else {
            hotseatView.setOnClickListener(null);
            hotseatView.setOnLongClickListener(null);
            hotseatView.setTag(null);
        }
        updateHotseatItemVisibility(hotseatView);
    }
}
Also used : ItemInfo(com.android.launcher3.model.data.ItemInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) FolderIcon(com.android.launcher3.folder.FolderIcon) BubbleTextView(com.android.launcher3.BubbleTextView) BubbleTextView(com.android.launcher3.BubbleTextView) View(android.view.View) AbstractFloatingView(com.android.launcher3.AbstractFloatingView) FolderInfo(com.android.launcher3.model.data.FolderInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 38 with ItemInfo

use of com.android.launcher3.ItemInfo in project android_packages_apps_Launcher3 by crdroidandroid.

the class PopupContainerWithArrow method showForIcon.

/**
 * Shows the notifications and deep shortcuts associated with {@param icon}.
 * @return the container if shown or null.
 */
public static PopupContainerWithArrow showForIcon(BubbleTextView icon) {
    Launcher launcher = Launcher.getLauncher(icon.getContext());
    if (getOpen(launcher) != null) {
        // There is already an items container open, so don't open this one.
        icon.clearFocus();
        return null;
    }
    ItemInfo item = (ItemInfo) icon.getTag();
    if (!canShow(icon, item)) {
        return null;
    }
    final PopupContainerWithArrow container = (PopupContainerWithArrow) launcher.getLayoutInflater().inflate(R.layout.popup_container, launcher.getDragLayer(), false);
    container.configureForLauncher(launcher);
    PopupDataProvider popupDataProvider = launcher.getPopupDataProvider();
    container.populateAndShow(icon, popupDataProvider.getShortcutCountForItem(item), popupDataProvider.getNotificationKeysForItem(item), launcher.getSupportedShortcuts().map(s -> s.getShortcut(launcher, item)).filter(Objects::nonNull).collect(Collectors.toList()));
    launcher.refreshAndBindWidgetsForPackageUser(PackageUserKey.fromItemInfo(item));
    container.requestFocus();
    return container;
}
Also used : Rect(android.graphics.Rect) PointF(android.graphics.PointF) Arrays(java.util.Arrays) ImageView(android.widget.ImageView) DraggableView(com.android.launcher3.dragndrop.DraggableView) BubbleTextView(com.android.launcher3.BubbleTextView) LayoutTransition(android.animation.LayoutTransition) AttributeSet(android.util.AttributeSet) Handler(android.os.Handler) Looper(android.os.Looper) Map(java.util.Map) View(android.view.View) TargetApi(android.annotation.TargetApi) MAX_SHORTCUTS_IF_NOTIFICATIONS(com.android.launcher3.popup.PopupPopulator.MAX_SHORTCUTS_IF_NOTIFICATIONS) Utilities(com.android.launcher3.Utilities) ShortcutMenuAccessibilityDelegate(com.android.launcher3.accessibility.ShortcutMenuAccessibilityDelegate) Launcher(com.android.launcher3.Launcher) ShortcutDragPreviewProvider(com.android.launcher3.shortcuts.ShortcutDragPreviewProvider) Predicate(java.util.function.Predicate) Collectors(java.util.stream.Collectors) ViewGroup(android.view.ViewGroup) LauncherAccessibilityDelegate(com.android.launcher3.accessibility.LauncherAccessibilityDelegate) NotificationInfo(com.android.launcher3.notification.NotificationInfo) DragOptions(com.android.launcher3.dragndrop.DragOptions) Objects(java.util.Objects) List(java.util.List) ShortcutUtil(com.android.launcher3.util.ShortcutUtil) Context(android.content.Context) MODEL_EXECUTOR(com.android.launcher3.util.Executors.MODEL_EXECUTOR) ItemInfo(com.android.launcher3.model.data.ItemInfo) Utilities.squaredTouchSlop(com.android.launcher3.Utilities.squaredTouchSlop) NotificationKeyData(com.android.launcher3.notification.NotificationKeyData) ArrayList(java.util.ArrayList) BaseDragLayer(com.android.launcher3.views.BaseDragLayer) NotificationContainer(com.android.launcher3.notification.NotificationContainer) ItemLongClickListener(com.android.launcher3.touch.ItemLongClickListener) Utilities.squaredHypot(com.android.launcher3.Utilities.squaredHypot) MAX_SHORTCUTS(com.android.launcher3.popup.PopupPopulator.MAX_SHORTCUTS) MotionEvent(android.view.MotionEvent) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) DragObject(com.android.launcher3.DropTarget.DragObject) AnimatorSet(android.animation.AnimatorSet) Build(android.os.Build) DragSource(com.android.launcher3.DragSource) DropTarget(com.android.launcher3.DropTarget) PopupDataChangeListener(com.android.launcher3.popup.PopupDataProvider.PopupDataChangeListener) CONTAINER_SHORTCUTS(com.android.launcher3.LauncherSettings.Favorites.CONTAINER_SHORTCUTS) DragController(com.android.launcher3.dragndrop.DragController) StatefulActivity(com.android.launcher3.statemanager.StatefulActivity) PackageUserKey(com.android.launcher3.util.PackageUserKey) Point(android.graphics.Point) DeepShortcutView(com.android.launcher3.shortcuts.DeepShortcutView) BaseDraggingActivity(com.android.launcher3.BaseDraggingActivity) LauncherState(com.android.launcher3.LauncherState) R(com.android.launcher3.R) AbstractFloatingView(com.android.launcher3.AbstractFloatingView) DragView(com.android.launcher3.dragndrop.DragView) DotInfo(com.android.launcher3.dot.DotInfo) ItemInfoWithIcon(com.android.launcher3.model.data.ItemInfoWithIcon) ItemInfo(com.android.launcher3.model.data.ItemInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) Objects(java.util.Objects) Launcher(com.android.launcher3.Launcher)

Example 39 with ItemInfo

use of com.android.launcher3.ItemInfo in project android_packages_apps_Launcher3 by crdroidandroid.

the class PopupContainerWithArrow method updateNotificationHeader.

private void updateNotificationHeader() {
    ItemInfoWithIcon itemInfo = (ItemInfoWithIcon) mOriginalIcon.getTag();
    DotInfo dotInfo = mLauncher.getDotInfoForItem(itemInfo);
    if (mNotificationContainer != null && dotInfo != null) {
        mNotificationContainer.updateHeader(dotInfo.getNotificationCount());
    }
}
Also used : DotInfo(com.android.launcher3.dot.DotInfo) ItemInfoWithIcon(com.android.launcher3.model.data.ItemInfoWithIcon)

Example 40 with ItemInfo

use of com.android.launcher3.ItemInfo in project android_packages_apps_Launcher3 by crdroidandroid.

the class PopupPopulator method createUpdateRunnable.

/**
 * Returns a runnable to update the provided shortcuts and notifications
 */
public static Runnable createUpdateRunnable(final BaseDraggingActivity launcher, 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(launcher, sbn, originalInfo)).collect(Collectors.toList());
            }
            uiHandler.post(() -> container.applyNotificationInfos(infos));
        }
        List<ShortcutInfo> shortcuts = new ShortcutRequest(launcher, user).withContainer(activity).query(ShortcutRequest.PUBLISHED);
        String shortcutIdToDeDupe = notificationKeys.isEmpty() ? null : notificationKeys.get(0).shortcutId;
        shortcuts = PopupPopulator.sortAndFilterShortcuts(shortcuts, shortcutIdToDeDupe);
        IconCache cache = LauncherAppState.getInstance(launcher).getIconCache();
        for (int i = 0; i < shortcuts.size() && i < shortcutViews.size(); i++) {
            final ShortcutInfo shortcut = shortcuts.get(i);
            final WorkspaceItemInfo si = new WorkspaceItemInfo(shortcut, launcher);
            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 : Iterator(java.util.Iterator) 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) BaseDraggingActivity(com.android.launcher3.BaseDraggingActivity) 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)

Aggregations

ItemInfo (com.android.launcher3.model.data.ItemInfo)457 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)373 View (android.view.View)199 ArrayList (java.util.ArrayList)169 Point (android.graphics.Point)159 FolderInfo (com.android.launcher3.model.data.FolderInfo)113 SuppressLint (android.annotation.SuppressLint)110 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)100 DragView (com.android.launcher3.dragndrop.DragView)98 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)98 AppWidgetHostView (android.appwidget.AppWidgetHostView)94 PendingAppWidgetHostView (com.android.launcher3.widget.PendingAppWidgetHostView)94 BubbleTextView (com.android.launcher3.BubbleTextView)85 Context (android.content.Context)82 List (java.util.List)80 AppInfo (com.android.launcher3.model.data.AppInfo)79 Intent (android.content.Intent)78 Rect (android.graphics.Rect)76 DraggableView (com.android.launcher3.dragndrop.DraggableView)73 ComponentName (android.content.ComponentName)72