Search in sources :

Example 1 with NotificationItemView

use of com.android.launcher3.notification.NotificationItemView in project Neo-Launcher by NeoApplications.

the class PopupContainerWithArrow method populateAndShow.

@TargetApi(Build.VERSION_CODES.P)
protected void populateAndShow(final BubbleTextView originalIcon, int shortcutCount, final List<NotificationKeyData> notificationKeys, List<SystemShortcut> systemShortcuts) {
    mNumNotifications = notificationKeys.size();
    mOriginalIcon = originalIcon;
    // Add views
    if (mNumNotifications > 0) {
        // Add notification entries
        View.inflate(getContext(), R.layout.notification_content, this);
        mNotificationItemView = new NotificationItemView(this);
        if (mNumNotifications == 1) {
            mNotificationItemView.removeFooter();
        }
        updateNotificationHeader();
    }
    int viewsToFlip = getChildCount();
    mSystemShortcutContainer = this;
    if (shortcutCount > 0) {
        if (mNotificationItemView != null) {
            mNotificationItemView.addGutter();
        }
        for (int i = shortcutCount; i > 0; i--) {
            mShortcuts.add(inflateAndAdd(R.layout.deep_shortcut, this));
        }
        updateHiddenShortcuts();
        if (!systemShortcuts.isEmpty()) {
            mSystemShortcutContainer = inflateAndAdd(R.layout.system_shortcut_icons, this);
            for (SystemShortcut shortcut : systemShortcuts) {
                initializeSystemShortcut(R.layout.system_shortcut_icon_only, mSystemShortcutContainer, shortcut);
            }
        }
    } else if (!systemShortcuts.isEmpty()) {
        if (mNotificationItemView != null) {
            mNotificationItemView.addGutter();
        }
        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());
    }
    mLauncher.getDragController().addDragListener(this);
    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(mLauncher, originalItemInfo, new Handler(Looper.getMainLooper()), this, mShortcuts, notificationKeys));
}
Also used : ItemInfo(com.android.launcher3.ItemInfo) NotificationItemView(com.android.launcher3.notification.NotificationItemView) Handler(android.os.Handler) ItemClickHandler(com.android.launcher3.touch.ItemClickHandler) LayoutTransition(android.animation.LayoutTransition) Point(android.graphics.Point) TargetApi(android.annotation.TargetApi)

Example 2 with NotificationItemView

use of com.android.launcher3.notification.NotificationItemView in project android_packages_apps_Trebuchet by LineageOS.

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
        View.inflate(getContext(), R.layout.notification_content, this);
        mNotificationItemView = new NotificationItemView(this);
        if (mNumNotifications == 1) {
            mNotificationItemView.removeFooter();
        } else {
            mNotificationItemView.setFooterWidth(containerWidth);
        }
        updateNotificationHeader();
    }
    int viewsToFlip = getChildCount();
    mSystemShortcutContainer = this;
    if (hasDeepShortcuts) {
        if (mNotificationItemView != null) {
            mNotificationItemView.addGutter();
        }
        for (int i = shortcutCount; i > 0; i--) {
            DeepShortcutView v = inflateAndAdd(R.layout.deep_shortcut, this);
            v.getLayoutParams().width = containerWidth;
            mShortcuts.add(v);
        }
        updateHiddenShortcuts();
        if (!systemShortcuts.isEmpty()) {
            mSystemShortcutContainer = inflateAndAdd(R.layout.system_shortcut_icons, this);
            for (SystemShortcut shortcut : systemShortcuts) {
                initializeSystemShortcut(R.layout.system_shortcut_icon_only, mSystemShortcutContainer, shortcut);
            }
        }
    } else if (!systemShortcuts.isEmpty()) {
        if (mNotificationItemView != null) {
            mNotificationItemView.addGutter();
        }
        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(mLauncher, originalItemInfo, new Handler(Looper.getMainLooper()), this, mShortcuts, notificationKeys));
}
Also used : ItemInfo(com.android.launcher3.model.data.ItemInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) NotificationItemView(com.android.launcher3.notification.NotificationItemView) Handler(android.os.Handler) LayoutTransition(android.animation.LayoutTransition) Point(android.graphics.Point) DeepShortcutView(com.android.launcher3.shortcuts.DeepShortcutView) TargetApi(android.annotation.TargetApi)

Aggregations

LayoutTransition (android.animation.LayoutTransition)2 TargetApi (android.annotation.TargetApi)2 Point (android.graphics.Point)2 Handler (android.os.Handler)2 NotificationItemView (com.android.launcher3.notification.NotificationItemView)2 ItemInfo (com.android.launcher3.ItemInfo)1 ItemInfo (com.android.launcher3.model.data.ItemInfo)1 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)1 DeepShortcutView (com.android.launcher3.shortcuts.DeepShortcutView)1 ItemClickHandler (com.android.launcher3.touch.ItemClickHandler)1