Search in sources :

Example 81 with ActivityOptions

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

the class RecentsTvImpl method startRecentsActivity.

@Override
protected void startRecentsActivity(ActivityManager.RunningTaskInfo runningTask, boolean isHomeStackVisible, boolean animate, int growTarget) {
    RecentsTaskLoader loader = Recents.getTaskLoader();
    // the stacks might have changed.
    if (mTriggeredFromAltTab || sInstanceLoadPlan == null) {
        // Create a new load plan if preloadRecents() was never triggered
        sInstanceLoadPlan = loader.createLoadPlan(mContext);
    }
    if (mTriggeredFromAltTab || !sInstanceLoadPlan.hasTasks()) {
        loader.preloadTasks(sInstanceLoadPlan, runningTask.id, !isHomeStackVisible);
    }
    TaskStack stack = sInstanceLoadPlan.getTaskStack();
    if (!animate) {
        ActivityOptions opts = ActivityOptions.makeCustomAnimation(mContext, -1, -1);
        startRecentsActivity(runningTask, opts, false, /* fromHome */
        false);
        return;
    }
    boolean hasRecentTasks = stack.getTaskCount() > 0;
    boolean useThumbnailTransition = (runningTask != null) && !isHomeStackVisible && hasRecentTasks;
    if (useThumbnailTransition) {
        // Try starting with a thumbnail transition
        ActivityOptions opts = getThumbnailTransitionActivityOptionsForTV(runningTask, stack.getTaskCount());
        if (opts != null) {
            startRecentsActivity(runningTask, opts, false, /* fromHome */
            true);
        } else {
            // Fall through below to the non-thumbnail transition
            useThumbnailTransition = false;
        }
    }
    if (!useThumbnailTransition) {
        startRecentsActivity(runningTask, null, true, /* fromHome */
        false);
    }
    mLastToggleTime = SystemClock.elapsedRealtime();
}
Also used : TaskStack(com.android.systemui.recents.model.TaskStack) RecentsTaskLoader(com.android.systemui.recents.model.RecentsTaskLoader) ActivityOptions(android.app.ActivityOptions)

Example 82 with ActivityOptions

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

the class RecentsTvTransitionHelper method launchTaskFromRecents.

public void launchTaskFromRecents(final TaskStack stack, @Nullable final Task task, final TaskStackHorizontalGridView stackView, final TaskCardView taskView, final Rect bounds, int destinationStack) {
    final ActivityOptions opts = ActivityOptions.makeBasic();
    if (bounds != null) {
        opts.setLaunchBounds(bounds.isEmpty() ? null : bounds);
    }
    final ActivityOptions.OnAnimationStartedListener animStartedListener;
    if (task.thumbnail != null && task.thumbnail.getWidth() > 0 && task.thumbnail.getHeight() > 0) {
        animStartedListener = new ActivityOptions.OnAnimationStartedListener() {

            @Override
            public void onAnimationStarted() {
                // If we are launching into another task, cancel the previous task's
                // window transition
                EventBus.getDefault().send(new CancelEnterRecentsWindowAnimationEvent(task));
                EventBus.getDefault().send(new ExitRecentsWindowFirstAnimationFrameEvent());
            }
        };
    } else {
        // This is only the case if the task is not on screen (scrolled offscreen for example)
        animStartedListener = new ActivityOptions.OnAnimationStartedListener() {

            @Override
            public void onAnimationStarted() {
                EventBus.getDefault().send(new ExitRecentsWindowFirstAnimationFrameEvent());
            }
        };
    }
    if (taskView == null) {
        // If there is no task view, then we do not need to worry about animating out occluding
        // task views, and we can launch immediately
        startTaskActivity(stack, task, taskView, opts, animStartedListener);
    } else {
        LaunchTvTaskStartedEvent launchStartedEvent = new LaunchTvTaskStartedEvent(taskView);
        EventBus.getDefault().send(launchStartedEvent);
        startTaskActivity(stack, task, taskView, opts, animStartedListener);
    }
}
Also used : ActivityOptions(android.app.ActivityOptions)

Example 83 with ActivityOptions

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

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 84 with ActivityOptions

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

the class KeyguardBottomAreaView method launchCamera.

public void launchCamera(String source) {
    final Intent intent;
    if (source.equals(CAMERA_LAUNCH_SOURCE_POWER_DOUBLE_TAP) || source.equals(CAMERA_LAUNCH_SOURCE_SCREEN_GESTURE) || !mShortcutHelper.isTargetCustom(LockscreenShortcutsHelper.Shortcuts.RIGHT_SHORTCUT)) {
        intent = getCameraIntent();
    } else {
        intent = mShortcutHelper.getIntent(LockscreenShortcutsHelper.Shortcuts.RIGHT_SHORTCUT);
        intent.putExtra(EXTRA_CAMERA_LAUNCH_SOURCE, source);
    }
    boolean wouldLaunchResolverActivity = PreviewInflater.wouldLaunchResolverActivity(mContext, intent, KeyguardUpdateMonitor.getCurrentUser());
    if (intent == SECURE_CAMERA_INTENT && !wouldLaunchResolverActivity) {
        AsyncTask.execute(new Runnable() {

            @Override
            public void run() {
                int result = ActivityManager.START_CANCELED;
                // Normally an activity will set it's requested rotation
                // animation on its window. However when launching an activity
                // causes the orientation to change this is too late. In these cases
                // the default animation is used. This doesn't look good for
                // the camera (as it rotates the camera contents out of sync
                // with physical reality). So, we ask the WindowManager to
                // force the crossfade animation if an orientation change
                // happens to occur during the launch.
                ActivityOptions o = ActivityOptions.makeBasic();
                o.setRotationAnimationHint(WindowManager.LayoutParams.ROTATION_ANIMATION_SEAMLESS);
                try {
                    result = ActivityManagerNative.getDefault().startActivityAsUser(null, getContext().getBasePackageName(), intent, intent.resolveTypeIfNeeded(getContext().getContentResolver()), null, null, 0, Intent.FLAG_ACTIVITY_NEW_TASK, null, o.toBundle(), UserHandle.CURRENT.getIdentifier());
                } catch (RemoteException e) {
                    Log.w(TAG, "Unable to start camera activity", e);
                }
                mActivityStarter.preventNextAnimation();
                final boolean launched = isSuccessfulLaunch(result);
                post(new Runnable() {

                    @Override
                    public void run() {
                        unbindCameraPrewarmService(launched);
                    }
                });
            }
        });
    } else {
        // We need to delay starting the activity because ResolverActivity finishes itself if
        // launched behind lockscreen.
        mActivityStarter.startActivity(intent, false, /* dismissShade */
        new ActivityStarter.Callback() {

            @Override
            public void onActivityStarted(int resultCode) {
                unbindCameraPrewarmService(isSuccessfulLaunch(resultCode));
            }
        });
    }
}
Also used : Intent(android.content.Intent) RemoteException(android.os.RemoteException) ActivityOptions(android.app.ActivityOptions)

Example 85 with ActivityOptions

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

the class ActivityStarter method startConfirmCredentialIntent.

void startConfirmCredentialIntent(Intent intent) {
    intent.addFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS | FLAG_ACTIVITY_TASK_ON_HOME);
    final ActivityOptions options = ActivityOptions.makeBasic();
    options.setLaunchTaskId(mSupervisor.getHomeActivity().task.taskId);
    mService.mContext.startActivityAsUser(intent, options.toBundle(), UserHandle.CURRENT);
}
Also used : ActivityOptions(android.app.ActivityOptions)

Aggregations

ActivityOptions (android.app.ActivityOptions)179 Intent (android.content.Intent)89 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 View (android.view.View)9 ActivityNotFoundException (android.content.ActivityNotFoundException)8