Search in sources :

Example 71 with ActivityOptions

use of android.app.ActivityOptions in project android_frameworks_base by ResurrectionRemix.

the class ForcedResizableInfoActivityController method showPending.

private void showPending() {
    mHandler.removeCallbacks(mTimeoutRunnable);
    for (int i = mPendingTaskIds.size() - 1; i >= 0; i--) {
        Intent intent = new Intent(mContext, ForcedResizableInfoActivity.class);
        ActivityOptions options = ActivityOptions.makeBasic();
        options.setLaunchTaskId(mPendingTaskIds.valueAt(i));
        options.setTaskOverlay(true);
        mContext.startActivityAsUser(intent, options.toBundle(), UserHandle.CURRENT);
    }
    mPendingTaskIds.clear();
}
Also used : Intent(android.content.Intent) ActivityOptions(android.app.ActivityOptions)

Example 72 with ActivityOptions

use of android.app.ActivityOptions in project android_frameworks_base by ResurrectionRemix.

the class RecentPanelView method setupItemTouchHelper.

private void setupItemTouchHelper() {
    ItemTouchHelper touchHelper = new ItemTouchHelper(new ItemTouchHelper.Callback() {

        RecentCard card;

        int taskid;

        int initPos;

        int finalPos;

        boolean isSwipe;

        boolean unwantedDrag = true;

        @Override
        public boolean onMove(RecyclerView recyclerView, ViewHolder viewHolder, ViewHolder target) {
            /* We'll start multiwindow action in the clearView void, when the drag action
                and all animations are completed. Otherwise we'd do a loop action
                till the drag is completed for each onMove (wasting resources and making
                the drag not smooth).*/
            ExpandableCardAdapter.ViewHolder vh = (ExpandableCardAdapter.ViewHolder) viewHolder;
            vh.hideOptions(-1, -1);
            initPos = viewHolder.getAdapterPosition();
            card = (RecentCard) mCardAdapter.getCard(initPos);
            taskid = card.task.persistentTaskId;
            unwantedDrag = false;
            return true;
        }

        @Override
        public void onMoved(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, int fromPos, RecyclerView.ViewHolder target, int toPos, int x, int y) {
            finalPos = toPos;
            isSwipe = false;
        }

        @Override
        public float getMoveThreshold(RecyclerView.ViewHolder viewHolder) {
            // if less then this we consider it as unwanted drag
            return 0.2f;
        }

        @Override
        public void clearView(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
            super.clearView(recyclerView, viewHolder);
            if (isSwipe) {
                //don't start multiwindow on swipe
                return;
            }
            if (unwantedDrag) {
                /*this means MoveThreshold is less than needed, so onMove
                    has not been considered, so we don't consider the action as wanted drag*/
                return;
            }
            //restore the drag check
            unwantedDrag = true;
            boolean wasDocked = false;
            int dockSide = WindowManagerProxy.getInstance().getDockSide();
            if (dockSide != WindowManager.DOCKED_INVALID) {
                try {
                    //resize the docked stack to fullscreen to disable current multiwindow mode
                    ActivityManagerNative.getDefault().resizeStack(ActivityManager.StackId.DOCKED_STACK_ID, null, true, true, false, -1);
                } catch (RemoteException e) {
                }
                wasDocked = true;
            }
            ActivityOptions options = ActivityOptions.makeBasic();
            //0 means dock app to top, 1 to bottom
            options.setDockCreateMode(0);
            options.setLaunchStackId(ActivityManager.StackId.DOCKED_STACK_ID);
            Handler mHandler = new Handler();
            mHandler.postDelayed(new Runnable() {

                public void run() {
                    try {
                        card = (RecentCard) mCardAdapter.getCard(finalPos);
                        int newTaskid = card.task.persistentTaskId;
                        ActivityManagerNative.getDefault().startActivityFromRecents((finalPos > initPos) ? taskid : newTaskid, options.toBundle());
                        /*after we docked our main app, on the other side of the screen we
                            open the app we dragged the main app over*/
                        mController.openOnDraggedApptoOtherSide((finalPos > initPos) ? newTaskid : taskid);
                    } catch (RemoteException e) {
                    }
                }
            }, wasDocked ? 100 : 0);
        }

        @Override
        public boolean isLongPressDragEnabled() {
            return true;
        }

        @Override
        public void onSwiped(ViewHolder viewHolder, int direction) {
            int pos = viewHolder.getAdapterPosition();
            RecentCard card = (RecentCard) mCardAdapter.getCard(pos);
            mCardAdapter.removeCard(pos);
            removeApplication(card.task);
            isSwipe = true;
        }

        @Override
        public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
            // Set movement flags based on the layout manager
            final int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN;
            final int swipeFlags = ItemTouchHelper.START | ItemTouchHelper.END;
            return makeMovementFlags(dragFlags, swipeFlags);
        }
    });
    touchHelper.attachToRecyclerView(mCardRecyclerView);
}
Also used : Handler(android.os.Handler) Paint(android.graphics.Paint) ItemTouchHelper(android.support.v7.widget.helper.ItemTouchHelper) ViewHolder(android.support.v7.widget.RecyclerView.ViewHolder) RecyclerView(android.support.v7.widget.RecyclerView) RemoteException(android.os.RemoteException) ViewHolder(android.support.v7.widget.RecyclerView.ViewHolder) ActivityOptions(android.app.ActivityOptions)

Example 73 with ActivityOptions

use of android.app.ActivityOptions in project android_frameworks_base by ResurrectionRemix.

the class BaseStatusBar method getActivityOptions.

protected Bundle getActivityOptions() {
    // Anything launched from the notification shade should always go into the
    // fullscreen stack.
    ActivityOptions options = ActivityOptions.makeBasic();
    options.setLaunchStackId(StackId.FULLSCREEN_WORKSPACE_STACK_ID);
    return options.toBundle();
}
Also used : ActivityOptions(android.app.ActivityOptions)

Example 74 with ActivityOptions

use of android.app.ActivityOptions in project android_frameworks_base by ResurrectionRemix.

the class TaskRecord method performClearTaskLocked.

/**
     * Perform clear operation as requested by
     * {@link Intent#FLAG_ACTIVITY_CLEAR_TOP}: search from the top of the
     * stack to the given task, then look for
     * an instance of that activity in the stack and, if found, finish all
     * activities on top of it and return the instance.
     *
     * @param newR Description of the new activity being started.
     * @return Returns the old activity that should be continued to be used,
     * or null if none was found.
     */
final ActivityRecord performClearTaskLocked(ActivityRecord newR, int launchFlags) {
    int numActivities = mActivities.size();
    for (int activityNdx = numActivities - 1; activityNdx >= 0; --activityNdx) {
        ActivityRecord r = mActivities.get(activityNdx);
        if (r.finishing) {
            continue;
        }
        if (r.realActivity.equals(newR.realActivity)) {
            // Here it is!  Now finish everything in front...
            final ActivityRecord ret = r;
            for (++activityNdx; activityNdx < numActivities; ++activityNdx) {
                r = mActivities.get(activityNdx);
                if (r.finishing) {
                    continue;
                }
                ActivityOptions opts = r.takeOptionsLocked();
                if (opts != null) {
                    ret.updateOptionsLocked(opts);
                }
                if (stack != null && stack.finishActivityLocked(r, Activity.RESULT_CANCELED, null, "clear-task-stack", false)) {
                    --activityNdx;
                    --numActivities;
                }
            }
            // instance of the activity so a new fresh one can be started.
            if (ret.launchMode == ActivityInfo.LAUNCH_MULTIPLE && (launchFlags & Intent.FLAG_ACTIVITY_SINGLE_TOP) == 0) {
                if (!ret.finishing) {
                    if (stack != null) {
                        stack.finishActivityLocked(ret, Activity.RESULT_CANCELED, null, "clear-task-top", false);
                    }
                    return null;
                }
            }
            return ret;
        }
    }
    return null;
}
Also used : Point(android.graphics.Point) ActivityOptions(android.app.ActivityOptions)

Example 75 with ActivityOptions

use of android.app.ActivityOptions in project android_frameworks_base by ResurrectionRemix.

the class SystemServicesProxy method startTaskInDockedMode.

/** Docks a task to the side of the screen and starts it. */
public boolean startTaskInDockedMode(int taskId, int createMode) {
    if (mIam == null)
        return false;
    try {
        final ActivityOptions options = ActivityOptions.makeBasic();
        options.setDockCreateMode(createMode);
        options.setLaunchStackId(DOCKED_STACK_ID);
        mIam.startActivityFromRecents(taskId, options.toBundle());
        return true;
    } catch (Exception e) {
        Log.e(TAG, "Failed to dock task: " + taskId + " with createMode: " + createMode, e);
    }
    return false;
}
Also used : RemoteException(android.os.RemoteException) IOException(java.io.IOException) ActivityOptions(android.app.ActivityOptions)

Aggregations

ActivityOptions (android.app.ActivityOptions)178 Intent (android.content.Intent)88 RemoteException (android.os.RemoteException)33 Point (android.graphics.Point)30 RecentsTaskLoader (com.android.systemui.recents.model.RecentsTaskLoader)20 TaskStack (com.android.systemui.recents.model.TaskStack)20 PendingIntent (android.app.PendingIntent)18 SystemServicesProxy (com.android.systemui.recents.misc.SystemServicesProxy)15 ActivityManager (android.app.ActivityManager)14 ComponentName (android.content.ComponentName)13 ActivityInfo (android.content.pm.ActivityInfo)13 ResolveInfo (android.content.pm.ResolveInfo)12 UserHandle (android.os.UserHandle)12 Configuration (android.content.res.Configuration)10 ReferrerIntent (com.android.internal.content.ReferrerIntent)10 RecentsTaskLoadPlan (com.android.systemui.recents.model.RecentsTaskLoadPlan)10 Task (com.android.systemui.recents.model.Task)10 Bundle (android.os.Bundle)9 ActivityNotFoundException (android.content.ActivityNotFoundException)8 RecyclerView (android.support.v7.widget.RecyclerView)8