Search in sources :

Example 1 with TaskSystemShortcut

use of com.android.quickstep.TaskSystemShortcut in project Neo-Launcher by NeoApplications.

the class TaskView method performAccessibilityAction.

@Override
public boolean performAccessibilityAction(int action, Bundle arguments) {
    if (action == R.string.accessibility_close_task) {
        getRecentsView().dismissTask(this, true, /*animateTaskView*/
        true);
        return true;
    }
    if (action == R.string.accessibility_app_usage_settings) {
        mDigitalWellBeingToast.openAppUsageSettings(this);
        return true;
    }
    final List<TaskSystemShortcut> shortcuts = TaskOverlayFactory.INSTANCE.get(getContext()).getEnabledShortcuts(this);
    final int count = shortcuts.size();
    for (int i = 0; i < count; ++i) {
        final TaskSystemShortcut menuOption = shortcuts.get(i);
        if (menuOption.hasHandlerForAction(action)) {
            OnClickListener onClickListener = menuOption.getOnClickListener(mActivity, this);
            if (onClickListener != null) {
                onClickListener.onClick(this);
            }
            return true;
        }
    }
    return super.performAccessibilityAction(action, arguments);
}
Also used : TaskSystemShortcut(com.android.quickstep.TaskSystemShortcut)

Example 2 with TaskSystemShortcut

use of com.android.quickstep.TaskSystemShortcut in project Neo-Launcher by NeoApplications.

the class TaskView method onInitializeAccessibilityNodeInfo.

@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
    super.onInitializeAccessibilityNodeInfo(info);
    info.addAction(new AccessibilityNodeInfo.AccessibilityAction(R.string.accessibility_close_task, getContext().getText(R.string.accessibility_close_task)));
    final Context context = getContext();
    final List<TaskSystemShortcut> shortcuts = TaskOverlayFactory.INSTANCE.get(getContext()).getEnabledShortcuts(this);
    final int count = shortcuts.size();
    for (int i = 0; i < count; ++i) {
        final TaskSystemShortcut menuOption = shortcuts.get(i);
        OnClickListener onClickListener = menuOption.getOnClickListener(mActivity, this);
        if (onClickListener != null) {
            info.addAction(menuOption.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.getChildCount() - recentsView.indexOfChild(this) - 1, 1, false);
    info.setCollectionItemInfo(itemInfo);
}
Also used : Context(android.content.Context) TaskSystemShortcut(com.android.quickstep.TaskSystemShortcut) AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo)

Example 3 with TaskSystemShortcut

use of com.android.quickstep.TaskSystemShortcut in project Neo-Launcher by NeoApplications.

the class TaskMenuView method addMenuOptions.

private void addMenuOptions(TaskView taskView) {
    Drawable icon = taskView.getTask().icon.getConstantState().newDrawable();
    mTaskIcon.setDrawable(icon);
    mTaskIcon.setOnClickListener(v -> close(true));
    mTaskName.setText(TaskUtils.getTitle(getContext(), taskView.getTask()));
    mTaskName.setOnClickListener(v -> close(true));
    // Set the icons to match scale by listening to each other's changes
    mMenuIconDrawable = icon instanceof FastBitmapDrawable ? (FastBitmapDrawable) icon : null;
    taskView.getIconView().addUpdateScaleListener(mTaskViewIconScaleListener);
    mTaskIcon.addUpdateScaleListener(mMenuIconScaleListener);
    // Move the icon and text up half an icon size to lay over the TaskView
    LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) mTaskIcon.getLayoutParams();
    params.topMargin = (int) -mThumbnailTopMargin;
    mTaskIcon.setLayoutParams(params);
    final BaseDraggingActivity activity = BaseDraggingActivity.fromContext(getContext());
    final List<TaskSystemShortcut> shortcuts = TaskOverlayFactory.INSTANCE.get(getContext()).getEnabledShortcuts(taskView);
    final int count = shortcuts.size();
    for (int i = 0; i < count; ++i) {
        final TaskSystemShortcut menuOption = shortcuts.get(i);
        addMenuOption(menuOption, menuOption.getOnClickListener(activity, taskView));
    }
}
Also used : FastBitmapDrawable(com.android.launcher3.FastBitmapDrawable) BaseDraggingActivity(com.android.launcher3.BaseDraggingActivity) TaskSystemShortcut(com.android.quickstep.TaskSystemShortcut) Drawable(android.graphics.drawable.Drawable) FastBitmapDrawable(com.android.launcher3.FastBitmapDrawable) LinearLayout(android.widget.LinearLayout)

Aggregations

TaskSystemShortcut (com.android.quickstep.TaskSystemShortcut)3 Context (android.content.Context)1 Drawable (android.graphics.drawable.Drawable)1 AccessibilityNodeInfo (android.view.accessibility.AccessibilityNodeInfo)1 LinearLayout (android.widget.LinearLayout)1 BaseDraggingActivity (com.android.launcher3.BaseDraggingActivity)1 FastBitmapDrawable (com.android.launcher3.FastBitmapDrawable)1