Search in sources :

Example 61 with ItemInfo

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

the class ItemClickHandler method onClickPendingAppItem.

private static void onClickPendingAppItem(View v, Launcher launcher, String packageName, boolean downloadStarted) {
    if (downloadStarted) {
        // If the download has started, simply direct to the market app.
        startMarketIntentForPackage(v, launcher, packageName);
        return;
    }
    UserHandle user = v.getTag() instanceof ItemInfo ? ((ItemInfo) v.getTag()).user : Process.myUserHandle();
    new AlertDialog.Builder(launcher).setTitle(R.string.abandoned_promises_title).setMessage(R.string.abandoned_promise_explanation).setPositiveButton(R.string.abandoned_search, (d, i) -> startMarketIntentForPackage(v, launcher, packageName)).setNeutralButton(R.string.abandoned_clean_this, (d, i) -> launcher.getWorkspace().removeAbandonedPromise(packageName, user)).create().show();
}
Also used : REQUEST_RECONFIGURE_APPWIDGET(com.android.launcher3.Launcher.REQUEST_RECONFIGURE_APPWIDGET) TestProtocol(com.android.launcher3.testing.TestProtocol) PendingIntent(android.app.PendingIntent) Process(android.os.Process) BubbleTextView(com.android.launcher3.BubbleTextView) FLAG_DISABLED_BY_PUBLISHER(com.android.launcher3.model.data.ItemInfoWithIcon.FLAG_DISABLED_BY_PUBLISHER) FolderInfo(com.android.launcher3.model.data.FolderInfo) View(android.view.View) Log(android.util.Log) LAUNCHER_APP_LAUNCH_TAP(com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_APP_LAUNCH_TAP) Utilities(com.android.launcher3.Utilities) Launcher(com.android.launcher3.Launcher) FLAG_DISABLED_SAFEMODE(com.android.launcher3.model.data.ItemInfoWithIcon.FLAG_DISABLED_SAFEMODE) PendingAppWidgetHostView(com.android.launcher3.widget.PendingAppWidgetHostView) AlertDialog(android.app.AlertDialog) LauncherApps(android.content.pm.LauncherApps) FLAG_DISABLED_QUIET_USER(com.android.launcher3.model.data.ItemInfoWithIcon.FLAG_DISABLED_QUIET_USER) LauncherAppWidgetProviderInfo(com.android.launcher3.widget.LauncherAppWidgetProviderInfo) LAUNCHER_FOLDER_OPEN(com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_FOLDER_OPEN) PackageManagerHelper(com.android.launcher3.util.PackageManagerHelper) Folder(com.android.launcher3.folder.Folder) LAUNCHER_ALLAPPS_SEARCHINAPP_LAUNCH(com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_SEARCHINAPP_LAUNCH) Context(android.content.Context) AppInfo(com.android.launcher3.model.data.AppInfo) WidgetAddFlowHandler(com.android.launcher3.widget.WidgetAddFlowHandler) ItemInfo(com.android.launcher3.model.data.ItemInfo) FolderIcon(com.android.launcher3.folder.FolderIcon) Intent(android.content.Intent) SearchActionItemInfo(com.android.launcher3.model.data.SearchActionItemInfo) SessionInfo(android.content.pm.PackageInstaller.SessionInfo) InstanceIdSequence(com.android.launcher3.logging.InstanceIdSequence) FLAG_DISABLED_SUSPENDED(com.android.launcher3.model.data.ItemInfoWithIcon.FLAG_DISABLED_SUSPENDED) IntentSender(android.content.IntentSender) FloatingIconView(com.android.launcher3.views.FloatingIconView) FLAG_DISABLED_LOCKED_USER(com.android.launcher3.model.data.ItemInfoWithIcon.FLAG_DISABLED_LOCKED_USER) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) UserHandle(android.os.UserHandle) Toast(android.widget.Toast) InstanceId(com.android.launcher3.logging.InstanceId) LauncherAppWidgetInfo(com.android.launcher3.model.data.LauncherAppWidgetInfo) TextUtils(android.text.TextUtils) REQUEST_BIND_PENDING_APPWIDGET(com.android.launcher3.Launcher.REQUEST_BIND_PENDING_APPWIDGET) WidgetManagerHelper(com.android.launcher3.widget.WidgetManagerHelper) StatsLogManager(com.android.launcher3.logging.StatsLogManager) R(com.android.launcher3.R) TestLogging(com.android.launcher3.testing.TestLogging) InstallSessionHelper(com.android.launcher3.pm.InstallSessionHelper) OnClickListener(android.view.View.OnClickListener) ItemInfoWithIcon(com.android.launcher3.model.data.ItemInfoWithIcon) ItemInfo(com.android.launcher3.model.data.ItemInfo) SearchActionItemInfo(com.android.launcher3.model.data.SearchActionItemInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) UserHandle(android.os.UserHandle)

Example 62 with ItemInfo

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

the class PinnedAppsAdapter method update.

private void update(ItemInfo info, Function<ComponentKey, Boolean> op) {
    ComponentKey key = new ComponentKey(info.getTargetComponent(), info.user);
    if (op.apply(key)) {
        createFilteredAppsList();
        Set<ComponentKey> copy = new HashSet<>(mPinnedApps);
        Executors.MODEL_EXECUTOR.submit(() -> mPrefs.edit().putStringSet(PINNED_APPS_KEY, copy.stream().map(this::encode).collect(Collectors.toSet())).apply());
    }
}
Also used : ComponentKey(com.android.launcher3.util.ComponentKey) HashSet(java.util.HashSet)

Example 63 with ItemInfo

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

the class PopupContainerWithArrow method populateAndShow.

@TargetApi(Build.VERSION_CODES.P)
public void populateAndShow(final BubbleTextView originalIcon, int shortcutCount, final List<NotificationKeyData> notificationKeys, List<SystemShortcut> systemShortcuts) {
    mNumNotifications = notificationKeys.size();
    mOriginalIcon = originalIcon;
    boolean hasDeepShortcuts = shortcutCount > 0;
    int containerWidth = (int) getResources().getDimension(R.dimen.bg_popup_item_width);
    // horizontally laid out system shortcuts.
    if (hasDeepShortcuts) {
        containerWidth = (int) Math.max(containerWidth, systemShortcuts.size() * getResources().getDimension(R.dimen.system_shortcut_header_icon_touch_size));
    }
    // Add views
    if (mNumNotifications > 0) {
        // Add notification entries
        if (mNotificationContainer == null) {
            mNotificationContainer = findViewById(R.id.notification_container);
            mNotificationContainer.setVisibility(VISIBLE);
            mNotificationContainer.setPopupView(this);
        } else {
            mNotificationContainer.setVisibility(GONE);
        }
        updateNotificationHeader();
    }
    int viewsToFlip = getChildCount();
    mSystemShortcutContainer = this;
    if (mDeepShortcutContainer == null) {
        mDeepShortcutContainer = findViewById(R.id.deep_shortcuts_container);
    }
    if (hasDeepShortcuts) {
        mDeepShortcutContainer.setVisibility(View.VISIBLE);
        for (int i = shortcutCount; i > 0; i--) {
            DeepShortcutView v = inflateAndAdd(R.layout.deep_shortcut, mDeepShortcutContainer);
            v.getLayoutParams().width = containerWidth;
            mShortcuts.add(v);
        }
        updateHiddenShortcuts();
        if (!systemShortcuts.isEmpty()) {
            for (SystemShortcut shortcut : systemShortcuts) {
                if (shortcut instanceof SystemShortcut.Widgets) {
                    if (mWidgetContainer == null) {
                        mWidgetContainer = inflateAndAdd(R.layout.widget_shortcut_container, this);
                    }
                    initializeSystemShortcut(R.layout.system_shortcut, mWidgetContainer, shortcut);
                }
            }
            mSystemShortcutContainer = inflateAndAdd(R.layout.system_shortcut_icons, this);
            for (SystemShortcut shortcut : systemShortcuts) {
                if (!(shortcut instanceof SystemShortcut.Widgets)) {
                    initializeSystemShortcut(R.layout.system_shortcut_icon_only, mSystemShortcutContainer, shortcut);
                }
            }
        }
    } else {
        mDeepShortcutContainer.setVisibility(View.GONE);
        if (!systemShortcuts.isEmpty()) {
            for (SystemShortcut shortcut : systemShortcuts) {
                initializeSystemShortcut(R.layout.system_shortcut, this, shortcut);
            }
        }
    }
    reorderAndShow(viewsToFlip);
    ItemInfo originalItemInfo = (ItemInfo) originalIcon.getTag();
    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
        setAccessibilityPaneTitle(getTitleForAccessibility());
    }
    mOriginalIcon.setForceHideDot(true);
    // All views are added. Animate layout from now on.
    setLayoutTransition(new LayoutTransition());
    // Load the shortcuts on a background thread and update the container as it animates.
    MODEL_EXECUTOR.getHandler().postAtFrontOfQueue(PopupPopulator.createUpdateRunnable(mActivityContext, originalItemInfo, new Handler(Looper.getMainLooper()), this, mShortcuts, notificationKeys));
}
Also used : ItemInfo(com.android.launcher3.model.data.ItemInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) Handler(android.os.Handler) LayoutTransition(android.animation.LayoutTransition) Point(android.graphics.Point) DeepShortcutView(com.android.launcher3.shortcuts.DeepShortcutView) TargetApi(android.annotation.TargetApi)

Example 64 with ItemInfo

use of com.android.launcher3.ItemInfo 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 65 with ItemInfo

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

the class PopupDataProvider method getShortcutCountForItem.

public int getShortcutCountForItem(ItemInfo info) {
    if (!ShortcutUtil.supportsDeepShortcuts(info)) {
        return 0;
    }
    ComponentName component = info.getTargetComponent();
    if (component == null) {
        return 0;
    }
    Integer count = mDeepShortcutMap.get(new ComponentKey(component, info.user));
    return count == null ? 0 : count;
}
Also used : ComponentKey(com.android.launcher3.util.ComponentKey) ComponentName(android.content.ComponentName)

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