Search in sources :

Example 6 with SystemShortcut

use of com.android.launcher3.popup.SystemShortcut in project android_packages_apps_Launcher3 by crdroidandroid.

the class TaskOverlayFactory method getEnabledShortcuts.

public static List<SystemShortcut> getEnabledShortcuts(TaskView taskView, DeviceProfile deviceProfile) {
    final ArrayList<SystemShortcut> shortcuts = new ArrayList<>();
    final BaseDraggingActivity activity = BaseActivity.fromContext(taskView.getContext());
    for (TaskShortcutFactory menuOption : MENU_OPTIONS) {
        SystemShortcut shortcut = menuOption.getShortcut(activity, taskView);
        if (menuOption == TaskShortcutFactory.SPLIT_SCREEN && FeatureFlags.ENABLE_SPLIT_SELECT.get()) {
            addSplitOptions(shortcuts, activity, taskView, deviceProfile);
            continue;
        }
        if (shortcut != null) {
            shortcuts.add(shortcut);
        }
    }
    RecentsOrientedState orientedState = taskView.getRecentsView().getPagedViewOrientedState();
    boolean canLauncherRotate = orientedState.canRecentsActivityRotate();
    boolean isInLandscape = orientedState.getTouchRotation() != ROTATION_0;
    // Add overview actions to the menu when in in-place rotate landscape mode.
    if (!canLauncherRotate && isInLandscape) {
        // Add screenshot action to task menu.
        SystemShortcut screenshotShortcut = TaskShortcutFactory.SCREENSHOT.getShortcut(activity, taskView);
        if (screenshotShortcut != null) {
            screenshotShortcut.setHasFinishRecentsInAction(true);
            shortcuts.add(screenshotShortcut);
        }
        // Add modal action only if display orientation is the same as the device orientation.
        if (orientedState.getDisplayRotation() == ROTATION_0) {
            SystemShortcut modalShortcut = TaskShortcutFactory.MODAL.getShortcut(activity, taskView);
            if (modalShortcut != null) {
                modalShortcut.setHasFinishRecentsInAction(true);
                shortcuts.add(modalShortcut);
            }
        }
    }
    return shortcuts;
}
Also used : BaseDraggingActivity(com.android.launcher3.BaseDraggingActivity) SystemShortcut(com.android.launcher3.popup.SystemShortcut) SplitSelectSystemShortcut(com.android.quickstep.TaskShortcutFactory.SplitSelectSystemShortcut) ArrayList(java.util.ArrayList) RecentsOrientedState(com.android.quickstep.util.RecentsOrientedState)

Example 7 with SystemShortcut

use of com.android.launcher3.popup.SystemShortcut in project android_packages_apps_Launcher3 by crdroidandroid.

the class FloatingIconView method getIconResult.

/**
 * Loads the icon and saves the results to {@link #sIconLoadResult}.
 * Runs onIconLoaded callback (if any), which signifies that the FloatingIconView is
 * ready to display the icon. Otherwise, the FloatingIconView will grab the results when its
 * initialized.
 *
 * @param originalView The View that the FloatingIconView will replace.
 * @param info ItemInfo of the originalView
 * @param pos The position of the view.
 */
@WorkerThread
@SuppressWarnings("WrongThread")
private static void getIconResult(Launcher l, View originalView, ItemInfo info, RectF pos, Drawable btvIcon, IconLoadResult iconLoadResult) {
    Drawable drawable;
    boolean supportsAdaptiveIcons = ADAPTIVE_ICON_WINDOW_ANIM.get() && // Use original icon for disabled icons.
    !info.isDisabled();
    Drawable badge = null;
    if (info instanceof SystemShortcut) {
        if (originalView instanceof ImageView) {
            drawable = ((ImageView) originalView).getDrawable();
        } else if (originalView instanceof DeepShortcutView) {
            drawable = ((DeepShortcutView) originalView).getIconView().getBackground();
        } else {
            drawable = originalView.getBackground();
        }
    } else if (btvIcon instanceof PreloadIconDrawable) {
        // Force the progress bar to display.
        drawable = btvIcon;
    } else {
        int width = (int) pos.width();
        int height = (int) pos.height();
        if (supportsAdaptiveIcons) {
            drawable = getFullDrawable(l, info, width, height, sTmpObjArray);
            if (drawable instanceof AdaptiveIconDrawable) {
                badge = getBadge(l, info, sTmpObjArray[0]);
            } else {
                // The drawable we get back is not an adaptive icon, so we need to use the
                // BubbleTextView icon that is already legacy treated.
                drawable = btvIcon;
            }
        } else {
            if (originalView instanceof BubbleTextView) {
                // Similar to DragView, we simply use the BubbleTextView icon here.
                drawable = btvIcon;
            } else {
                drawable = getFullDrawable(l, info, width, height, sTmpObjArray);
            }
        }
    }
    drawable = drawable == null ? null : drawable.getConstantState().newDrawable();
    int iconOffset = getOffsetForIconBounds(l, drawable, pos);
    synchronized (iconLoadResult) {
        iconLoadResult.btvDrawable = btvIcon == null || drawable == btvIcon ? null : btvIcon.getConstantState().newDrawable();
        iconLoadResult.drawable = drawable;
        iconLoadResult.badge = badge;
        iconLoadResult.iconOffset = iconOffset;
        if (iconLoadResult.onIconLoaded != null) {
            l.getMainExecutor().execute(iconLoadResult.onIconLoaded);
            iconLoadResult.onIconLoaded = null;
        }
        iconLoadResult.isIconLoaded = true;
    }
}
Also used : SystemShortcut(com.android.launcher3.popup.SystemShortcut) AdaptiveIconDrawable(android.graphics.drawable.AdaptiveIconDrawable) Drawable(android.graphics.drawable.Drawable) PreloadIconDrawable(com.android.launcher3.graphics.PreloadIconDrawable) Utilities.getFullDrawable(com.android.launcher3.Utilities.getFullDrawable) FastBitmapDrawable(com.android.launcher3.icons.FastBitmapDrawable) ImageView(android.widget.ImageView) BubbleTextView(com.android.launcher3.BubbleTextView) AdaptiveIconDrawable(android.graphics.drawable.AdaptiveIconDrawable) DeepShortcutView(com.android.launcher3.shortcuts.DeepShortcutView) PreloadIconDrawable(com.android.launcher3.graphics.PreloadIconDrawable) WorkerThread(androidx.annotation.WorkerThread)

Aggregations

SystemShortcut (com.android.launcher3.popup.SystemShortcut)3 DeepShortcutView (com.android.launcher3.shortcuts.DeepShortcutView)3 ImageView (android.widget.ImageView)2 BubbleTextView (com.android.launcher3.BubbleTextView)2 SplitSelectSystemShortcut (com.android.quickstep.TaskShortcutFactory.SplitSelectSystemShortcut)2 LayoutTransition (android.animation.LayoutTransition)1 TargetApi (android.annotation.TargetApi)1 RemoteAction (android.app.RemoteAction)1 Context (android.content.Context)1 Point (android.graphics.Point)1 AdaptiveIconDrawable (android.graphics.drawable.AdaptiveIconDrawable)1 Drawable (android.graphics.drawable.Drawable)1 Handler (android.os.Handler)1 View (android.view.View)1 AccessibilityNodeInfo (android.view.accessibility.AccessibilityNodeInfo)1 MainThread (androidx.annotation.MainThread)1 WorkerThread (androidx.annotation.WorkerThread)1 AbstractFloatingView (com.android.launcher3.AbstractFloatingView)1 BaseDraggingActivity (com.android.launcher3.BaseDraggingActivity)1 Utilities.getFullDrawable (com.android.launcher3.Utilities.getFullDrawable)1