Search in sources :

Example 1 with SystemShortcut

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

the class PopupContainerWithArrow method initializeSystemShortcut.

private void initializeSystemShortcut(int resId, ViewGroup container, SystemShortcut info) {
    View view = inflateAndAdd(resId, container, getInsertIndexForSystemShortcut(container, info));
    if (view instanceof DeepShortcutView) {
        // Expanded system shortcut, with both icon and text shown on white background.
        final DeepShortcutView shortcutView = (DeepShortcutView) view;
        info.setIconAndLabelFor(shortcutView.getIconView(), shortcutView.getBubbleText());
    } else if (view instanceof ImageView) {
        // Only the system shortcut icon shows on a gray background header.
        info.setIconAndContentDescriptionFor((ImageView) view);
        view.setTooltipText(view.getContentDescription());
    }
    view.setTag(info);
    view.setOnClickListener(info);
}
Also used : ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) DraggableView(com.android.launcher3.dragndrop.DraggableView) BubbleTextView(com.android.launcher3.BubbleTextView) View(android.view.View) DeepShortcutView(com.android.launcher3.shortcuts.DeepShortcutView) AbstractFloatingView(com.android.launcher3.AbstractFloatingView) DragView(com.android.launcher3.dragndrop.DragView) DeepShortcutView(com.android.launcher3.shortcuts.DeepShortcutView)

Example 2 with SystemShortcut

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

the class TaskView method onInitializeAccessibilityNodeInfo.

@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
    super.onInitializeAccessibilityNodeInfo(info);
    info.addAction(new AccessibilityNodeInfo.AccessibilityAction(R.string.accessibility_close, getContext().getText(R.string.accessibility_close)));
    final Context context = getContext();
    for (SystemShortcut s : TaskOverlayFactory.getEnabledShortcuts(this, mActivity.getDeviceProfile())) {
        info.addAction(s.createAccessibilityAction(context));
    }
    if (mDigitalWellBeingToast.hasLimit()) {
        info.addAction(new AccessibilityNodeInfo.AccessibilityAction(R.string.accessibility_app_usage_settings, getContext().getText(R.string.accessibility_app_usage_settings)));
    }
    final RecentsView recentsView = getRecentsView();
    final AccessibilityNodeInfo.CollectionItemInfo itemInfo = AccessibilityNodeInfo.CollectionItemInfo.obtain(0, 1, recentsView.getTaskViewCount() - recentsView.indexOfChild(this) - 1, 1, false);
    info.setCollectionItemInfo(itemInfo);
}
Also used : Context(android.content.Context) SystemShortcut(com.android.launcher3.popup.SystemShortcut) AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo)

Example 3 with SystemShortcut

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

the class WellbeingModel method getShortcutForApp.

@MainThread
private SystemShortcut getShortcutForApp(String packageName, int userId, BaseDraggingActivity activity, ItemInfo info) {
    Preconditions.assertUIThread();
    // Work profile apps are not recognized by digital wellbeing.
    if (userId != UserHandle.myUserId()) {
        if (DEBUG || mIsInTest) {
            Log.d(TAG, "getShortcutForApp [" + packageName + "]: not current user");
        }
        return null;
    }
    synchronized (mModelLock) {
        String actionId = mPackageToActionId.get(packageName);
        final RemoteAction action = actionId != null ? mActionIdMap.get(actionId) : null;
        if (action == null) {
            if (DEBUG || mIsInTest) {
                Log.d(TAG, "getShortcutForApp [" + packageName + "]: no action");
            }
            return null;
        }
        if (DEBUG || mIsInTest) {
            Log.d(TAG, "getShortcutForApp [" + packageName + "]: action: '" + action.getTitle() + "'");
        }
        return new RemoteActionShortcut(action, activity, info);
    }
}
Also used : RemoteActionShortcut(com.android.launcher3.popup.RemoteActionShortcut) RemoteAction(android.app.RemoteAction) MainThread(androidx.annotation.MainThread)

Example 4 with SystemShortcut

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

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(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) Handler(android.os.Handler) LayoutTransition(android.animation.LayoutTransition) Point(android.graphics.Point) DeepShortcutView(com.android.launcher3.shortcuts.DeepShortcutView) TargetApi(android.annotation.TargetApi)

Example 5 with SystemShortcut

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

the class TaskOverlayFactory method addSplitOptions.

public static void addSplitOptions(List<SystemShortcut> outShortcuts, BaseDraggingActivity activity, TaskView taskView, DeviceProfile deviceProfile) {
    PagedOrientationHandler orientationHandler = taskView.getRecentsView().getPagedOrientationHandler();
    List<SplitPositionOption> positions = orientationHandler.getSplitPositionOptions(deviceProfile);
    for (SplitPositionOption option : positions) {
        outShortcuts.add(new SplitSelectSystemShortcut(activity, taskView, option));
    }
}
Also used : SplitPositionOption(com.android.launcher3.util.SplitConfigurationOptions.SplitPositionOption) PagedOrientationHandler(com.android.launcher3.touch.PagedOrientationHandler) SplitSelectSystemShortcut(com.android.quickstep.TaskShortcutFactory.SplitSelectSystemShortcut)

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