Search in sources :

Example 96 with ActivityOptions

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

the class RecentsImpl method showRelativeAffiliatedTask.

/**
     * Transitions to the next affiliated task.
     */
public void showRelativeAffiliatedTask(boolean showNextTask) {
    SystemServicesProxy ssp = Recents.getSystemServices();
    RecentsTaskLoader loader = Recents.getTaskLoader();
    RecentsTaskLoadPlan plan = loader.createLoadPlan(mContext);
    loader.preloadTasks(plan, -1, false);
    TaskStack focusedStack = plan.getTaskStack();
    // Return early if there are no tasks in the focused stack
    if (focusedStack == null || focusedStack.getTaskCount() == 0)
        return;
    // Return early if there is no running task (can't determine affiliated tasks in this case)
    ActivityManager.RunningTaskInfo runningTask = ssp.getRunningTask();
    if (runningTask == null)
        return;
    // Return early if the running task is in the home stack (optimization)
    if (SystemServicesProxy.isHomeStack(runningTask.stackId))
        return;
    // Find the task in the recents list
    ArrayList<Task> tasks = focusedStack.getStackTasks();
    Task toTask = null;
    ActivityOptions launchOpts = null;
    int taskCount = tasks.size();
    int numAffiliatedTasks = 0;
    for (int i = 0; i < taskCount; i++) {
        Task task = tasks.get(i);
        if (task.key.id == runningTask.id) {
            TaskGrouping group = task.group;
            Task.TaskKey toTaskKey;
            if (showNextTask) {
                toTaskKey = group.getNextTaskInGroup(task);
                launchOpts = ActivityOptions.makeCustomAnimation(mContext, R.anim.recents_launch_next_affiliated_task_target, R.anim.recents_launch_next_affiliated_task_source);
            } else {
                toTaskKey = group.getPrevTaskInGroup(task);
                launchOpts = ActivityOptions.makeCustomAnimation(mContext, R.anim.recents_launch_prev_affiliated_task_target, R.anim.recents_launch_prev_affiliated_task_source);
            }
            if (toTaskKey != null) {
                toTask = focusedStack.findTaskWithId(toTaskKey.id);
            }
            numAffiliatedTasks = group.getTaskCount();
            break;
        }
    }
    // Return early if there is no next task
    if (toTask == null) {
        if (numAffiliatedTasks > 1) {
            if (showNextTask) {
                ssp.startInPlaceAnimationOnFrontMostApplication(ActivityOptions.makeCustomInPlaceAnimation(mContext, R.anim.recents_launch_next_affiliated_task_bounce));
            } else {
                ssp.startInPlaceAnimationOnFrontMostApplication(ActivityOptions.makeCustomInPlaceAnimation(mContext, R.anim.recents_launch_prev_affiliated_task_bounce));
            }
        }
        return;
    }
    // Keep track of actually launched affiliated tasks
    MetricsLogger.count(mContext, "overview_affiliated_task_launch", 1);
    // Launch the task
    ssp.startActivityFromRecents(mContext, toTask.key, toTask.title, launchOpts);
}
Also used : SystemServicesProxy(com.android.systemui.recents.misc.SystemServicesProxy) TaskStack(com.android.systemui.recents.model.TaskStack) Task(com.android.systemui.recents.model.Task) RecentsTaskLoadPlan(com.android.systemui.recents.model.RecentsTaskLoadPlan) RecentsTaskLoader(com.android.systemui.recents.model.RecentsTaskLoader) TaskGrouping(com.android.systemui.recents.model.TaskGrouping) ActivityManager(android.app.ActivityManager) ActivityOptions(android.app.ActivityOptions)

Example 97 with ActivityOptions

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

the class ActivityRecord method takeOptionsLocked.

ActivityOptions takeOptionsLocked() {
    ActivityOptions opts = pendingOptions;
    pendingOptions = null;
    return opts;
}
Also used : ActivityOptions(android.app.ActivityOptions)

Example 98 with ActivityOptions

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

the class PhoneStatusBar method startActivityDismissingKeyguard.

public void startActivityDismissingKeyguard(final Intent intent, boolean onlyProvisioned, final boolean dismissShade, final Callback callback) {
    if (onlyProvisioned && !isDeviceProvisioned())
        return;
    final boolean afterKeyguardGone = PreviewInflater.wouldLaunchResolverActivity(mContext, intent, mCurrentUserId);
    final boolean keyguardShowing = mStatusBarKeyguardViewManager.isShowing();
    Runnable runnable = new Runnable() {

        @Override
        public void run() {
            mAssistManager.hideAssist();
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
            int result = ActivityManager.START_CANCELED;
            ActivityOptions options = new ActivityOptions(getActivityOptions());
            if (intent == KeyguardBottomAreaView.INSECURE_CAMERA_INTENT) {
                // 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.
                options.setRotationAnimationHint(WindowManager.LayoutParams.ROTATION_ANIMATION_SEAMLESS);
            }
            try {
                result = ActivityManagerNative.getDefault().startActivityAsUser(null, mContext.getBasePackageName(), intent, intent.resolveTypeIfNeeded(mContext.getContentResolver()), null, null, 0, Intent.FLAG_ACTIVITY_NEW_TASK, null, options.toBundle(), UserHandle.CURRENT.getIdentifier());
            } catch (RemoteException e) {
                Log.w(TAG, "Unable to start activity", e);
            }
            overrideActivityPendingAppTransition(keyguardShowing && !afterKeyguardGone);
            if (callback != null) {
                callback.onActivityStarted(result);
            }
        }
    };
    Runnable cancelRunnable = new Runnable() {

        @Override
        public void run() {
            if (callback != null) {
                callback.onActivityStarted(ActivityManager.START_CANCELED);
            }
        }
    };
    executeRunnableDismissingKeyguard(runnable, cancelRunnable, dismissShade, afterKeyguardGone, true);
}
Also used : RemoteException(android.os.RemoteException) Point(android.graphics.Point) ActivityOptions(android.app.ActivityOptions)

Example 99 with ActivityOptions

use of android.app.ActivityOptions in project Launcher3 by chislon.

the class LauncherTransitionable method startActivity.

boolean startActivity(View v, Intent intent, Object tag) {
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    try {
        // Only launch using the new animation if the shortcut has not opted out (this is a
        // private contract between launcher and may be ignored in the future).
        boolean useLaunchAnimation = (v != null) && !intent.hasExtra(INTENT_EXTRA_IGNORE_LAUNCH_ANIMATION);
        if (useLaunchAnimation) {
            ActivityOptions opts = ActivityOptions.makeScaleUpAnimation(v, 0, 0, v.getMeasuredWidth(), v.getMeasuredHeight());
            startActivity(intent, opts.toBundle());
        } else {
            startActivity(intent);
        }
        return true;
    } catch (SecurityException e) {
        Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT).show();
        Log.e(TAG, "Launcher does not have the permission to launch " + intent + ". Make sure to create a MAIN intent-filter for the corresponding activity " + "or use the exported attribute for this activity. " + "tag=" + tag + " intent=" + intent, e);
    }
    return false;
}
Also used : ActivityOptions(android.app.ActivityOptions)

Example 100 with ActivityOptions

use of android.app.ActivityOptions in project cardslib by gabrielemariotti.

the class LPreviewUtilsBase method startActivityWithTransition.

//----------------------------------------------------------------------------
// Methods
//----------------------------------------------------------------------------
public void startActivityWithTransition(Intent intent, final View clickedView, final String transitionName) {
    ActivityOptions options = null;
    //        if (hasL() && clickedView != null && !TextUtils.isEmpty(transitionName)) {
    //            options = ActivityOptions.makeSceneTransitionAnimation(
    //                    mActivity, clickedView, transitionName);
    //        }
    mActivity.startActivity(intent, (options != null) ? options.toBundle() : null);
}
Also used : 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