Search in sources :

Example 86 with BubbleTextView

use of com.android.launcher3.BubbleTextView in project android_packages_apps_404Launcher by P-404.

the class TaskbarDragController method startDragOnLongClick.

/**
 * Attempts to start a system drag and drop operation for the given View, using its tag to
 * generate the ClipDescription and Intent.
 * @return Whether {@link View#startDragAndDrop} started successfully.
 */
protected boolean startDragOnLongClick(View view) {
    if (!(view instanceof BubbleTextView)) {
        return false;
    }
    BubbleTextView btv = (BubbleTextView) view;
    mActivity.setTaskbarWindowFullscreen(true);
    btv.post(() -> {
        startInternalDrag(btv);
        btv.getIcon().setIsDisabled(true);
        mControllers.taskbarAutohideSuspendController.updateFlag(TaskbarAutohideSuspendController.FLAG_AUTOHIDE_SUSPEND_DRAGGING, true);
    });
    return true;
}
Also used : BubbleTextView(com.android.launcher3.BubbleTextView)

Example 87 with BubbleTextView

use of com.android.launcher3.BubbleTextView in project android_packages_apps_404Launcher by P-404.

the class BaseDraggingActivity method getActivityLaunchOptions.

@NonNull
public ActivityOptionsWrapper getActivityLaunchOptions(View v, @Nullable ItemInfo item) {
    int left = 0, top = 0;
    int width = v.getMeasuredWidth(), height = v.getMeasuredHeight();
    if (v instanceof BubbleTextView) {
        // Launch from center of icon, not entire view
        Drawable icon = ((BubbleTextView) v).getIcon();
        if (icon != null) {
            Rect bounds = icon.getBounds();
            left = (width - bounds.width()) / 2;
            top = v.getPaddingTop();
            width = bounds.width();
            height = bounds.height();
        }
    }
    ActivityOptions options = ActivityOptions.makeClipRevealAnimation(v, left, top, width, height);
    RunnableList callback = new RunnableList();
    addOnResumeCallback(callback::executeAllAndDestroy);
    return new ActivityOptionsWrapper(options, callback);
}
Also used : Rect(android.graphics.Rect) ActivityOptionsWrapper(com.android.launcher3.util.ActivityOptionsWrapper) Drawable(android.graphics.drawable.Drawable) RunnableList(com.android.launcher3.util.RunnableList) Point(android.graphics.Point) ActivityOptions(android.app.ActivityOptions) NonNull(androidx.annotation.NonNull)

Example 88 with BubbleTextView

use of com.android.launcher3.BubbleTextView in project android_packages_apps_404Launcher by P-404.

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 89 with BubbleTextView

use of com.android.launcher3.BubbleTextView in project android_packages_apps_404Launcher by P-404.

the class PopupContainerWithArrow method showForIcon.

/**
 * Shows the notifications and deep shortcuts associated with a Launcher {@param icon}.
 * @return the container if shown or null.
 */
public static PopupContainerWithArrow<Launcher> 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<Launcher> 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) 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) ActivityContext(com.android.launcher3.views.ActivityContext) 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) PackageUserKey(com.android.launcher3.util.PackageUserKey) Point(android.graphics.Point) DeepShortcutView(com.android.launcher3.shortcuts.DeepShortcutView) BaseDraggingActivity(com.android.launcher3.BaseDraggingActivity) 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 90 with BubbleTextView

use of com.android.launcher3.BubbleTextView in project android_packages_apps_404Launcher by P-404.

the class SecondaryDragLayer method onIconLongClicked.

private boolean onIconLongClicked(View v) {
    if (!(v instanceof BubbleTextView)) {
        return false;
    }
    if (PopupContainerWithArrow.getOpen(mActivity) != null) {
        // There is already an items container open, so don't open this one.
        v.clearFocus();
        return false;
    }
    ItemInfo item = (ItemInfo) v.getTag();
    if (!ShortcutUtil.supportsShortcuts(item)) {
        return false;
    }
    final PopupContainerWithArrow container = (PopupContainerWithArrow) mActivity.getLayoutInflater().inflate(R.layout.popup_container, mActivity.getDragLayer(), false);
    container.populateAndShow((BubbleTextView) v, mActivity.getPopupDataProvider().getShortcutCountForItem(item), Collections.emptyList(), Arrays.asList(mPinnedAppsAdapter.getSystemShortcut(item), APP_INFO.getShortcut(mActivity, item)));
    v.getParent().requestDisallowInterceptTouchEvent(true);
    return true;
}
Also used : ItemInfo(com.android.launcher3.model.data.ItemInfo) PopupContainerWithArrow(com.android.launcher3.popup.PopupContainerWithArrow) BubbleTextView(com.android.launcher3.BubbleTextView)

Aggregations

BubbleTextView (com.android.launcher3.BubbleTextView)157 View (android.view.View)82 Rect (android.graphics.Rect)62 Point (android.graphics.Point)61 Drawable (android.graphics.drawable.Drawable)60 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)57 ItemInfo (com.android.launcher3.model.data.ItemInfo)56 SuppressLint (android.annotation.SuppressLint)48 ArrayList (java.util.ArrayList)43 CellLayout (com.android.launcher3.CellLayout)39 Animator (android.animation.Animator)36 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)36 DragView (com.android.launcher3.dragndrop.DragView)34 FolderIcon (com.android.launcher3.folder.FolderIcon)34 Handler (android.os.Handler)33 ViewGroup (android.view.ViewGroup)30 DraggableView (com.android.launcher3.dragndrop.DraggableView)30 PreloadIconDrawable (com.android.launcher3.graphics.PreloadIconDrawable)30 AbstractFloatingView (com.android.launcher3.AbstractFloatingView)28 Folder (com.android.launcher3.folder.Folder)28