use of android.app.ActivityOptions in project android_frameworks_base by ResurrectionRemix.
the class RecentsImpl method showNextTask.
/**
* Transitions to the next recent task in the stack.
*/
public void 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
ActivityManager.RunningTaskInfo runningTask = ssp.getRunningTask();
if (runningTask == null)
return;
// Find the task in the recents list
boolean isRunningTaskInHomeStack = SystemServicesProxy.isHomeStack(runningTask.stackId);
ArrayList<Task> tasks = focusedStack.getStackTasks();
Task toTask = null;
ActivityOptions launchOpts = null;
int taskCount = tasks.size();
for (int i = taskCount - 1; i >= 1; i--) {
Task task = tasks.get(i);
if (isRunningTaskInHomeStack) {
toTask = tasks.get(i - 1);
launchOpts = ActivityOptions.makeCustomAnimation(mContext, R.anim.recents_launch_next_affiliated_task_target, R.anim.recents_fast_toggle_app_home_exit);
break;
} else if (task.key.id == runningTask.id) {
toTask = tasks.get(i - 1);
launchOpts = ActivityOptions.makeCustomAnimation(mContext, R.anim.recents_launch_prev_affiliated_task_target, R.anim.recents_launch_prev_affiliated_task_source);
break;
}
}
// Return early if there is no next task
if (toTask == null) {
ssp.startInPlaceAnimationOnFrontMostApplication(ActivityOptions.makeCustomInPlaceAnimation(mContext, R.anim.recents_launch_prev_affiliated_task_bounce));
return;
}
// Launch the task
ssp.startActivityFromRecents(mContext, toTask.key, toTask.title, launchOpts);
}
use of android.app.ActivityOptions in project android_frameworks_base by ResurrectionRemix.
the class RecentsImpl method startRecentsActivity.
/**
* Shows the recents activity
*/
protected void startRecentsActivity(ActivityManager.RunningTaskInfo runningTask, boolean isHomeStackVisible, boolean animate, int growTarget) {
RecentsTaskLoader loader = Recents.getTaskLoader();
RecentsActivityLaunchState launchState = Recents.getConfiguration().getLaunchState();
SystemServicesProxy ssp = Recents.getSystemServices();
boolean isBlacklisted = (runningTask != null) ? ssp.isBlackListedActivity(runningTask.baseActivity.getClassName()) : false;
int runningTaskId = !mLaunchedWhileDocking && !isBlacklisted && (runningTask != null) ? runningTask.id : -1;
// the stacks might have changed.
if (mLaunchedWhileDocking || mTriggeredFromAltTab || sInstanceLoadPlan == null) {
// Create a new load plan if preloadRecents() was never triggered
sInstanceLoadPlan = loader.createLoadPlan(mContext);
}
if (mLaunchedWhileDocking || mTriggeredFromAltTab || !sInstanceLoadPlan.hasTasks()) {
loader.preloadTasks(sInstanceLoadPlan, runningTaskId, !isHomeStackVisible);
}
TaskStack stack = sInstanceLoadPlan.getTaskStack();
boolean hasRecentTasks = stack.getTaskCount() > 0;
boolean useThumbnailTransition = (runningTask != null) && !isHomeStackVisible && hasRecentTasks;
// Update the launch state that we need in updateHeaderBarLayout()
launchState.launchedFromHome = !useThumbnailTransition && !mLaunchedWhileDocking;
launchState.launchedFromApp = useThumbnailTransition || mLaunchedWhileDocking;
launchState.launchedFromBlacklistedApp = launchState.launchedFromApp && isBlacklisted;
launchState.launchedViaDockGesture = mLaunchedWhileDocking;
launchState.launchedViaDragGesture = mDraggingInRecents;
launchState.launchedToTaskId = runningTaskId;
launchState.launchedWithAltTab = mTriggeredFromAltTab;
// Preload the icon (this will be a null-op if we have preloaded the icon already in
// preloadRecents())
preloadIcon(runningTaskId);
// Update the header bar if necessary
Rect windowOverrideRect = getWindowRectOverride(growTarget);
updateHeaderBarLayout(stack, windowOverrideRect);
// Prepare the dummy stack for the transition
TaskStackLayoutAlgorithm.VisibilityReport stackVr = mDummyStackView.computeStackVisibilityReport();
// Update the remaining launch state
launchState.launchedNumVisibleTasks = stackVr.numVisibleTasks;
launchState.launchedNumVisibleThumbnails = stackVr.numVisibleThumbnails;
if (!animate) {
startRecentsActivity(ActivityOptions.makeCustomAnimation(mContext, -1, -1));
return;
}
ActivityOptions opts;
if (isBlacklisted) {
opts = getUnknownTransitionActivityOptions();
} else if (useThumbnailTransition) {
// Try starting with a thumbnail transition
opts = getThumbnailTransitionActivityOptions(runningTask, mDummyStackView, windowOverrideRect);
} else {
// If there is no thumbnail transition, but is launching from home into recents, then
// use a quick home transition
opts = hasRecentTasks ? getHomeTransitionActivityOptions() : getUnknownTransitionActivityOptions();
}
startRecentsActivity(opts);
mLastToggleTime = SystemClock.elapsedRealtime();
}
use of android.app.ActivityOptions in project android_frameworks_base by ResurrectionRemix.
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);
}
use of android.app.ActivityOptions in project android_frameworks_base by ResurrectionRemix.
the class RecentController method openLastApptoBottom.
public void openLastApptoBottom() {
int taskid = 0;
boolean doWeHaveAtask = true;
final ActivityManager am = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
ActivityManager.RunningTaskInfo lastTask = getLastTask(am);
if (lastTask != null) {
//user already ran another app in this session, we can dock it to the other side
taskid = lastTask.id;
} else {
//no last app for this session, let's search in the previous session recent apps
List<ActivityManager.RecentTaskInfo> recentTasks = am.getRecentTasksForUser(ActivityManager.getMaxRecentTasksStatic(), ActivityManager.RECENT_IGNORE_HOME_STACK_TASKS | ActivityManager.RECENT_INGORE_DOCKED_STACK_TOP_TASK | ActivityManager.RECENT_INGORE_PINNED_STACK_TASKS | ActivityManager.RECENT_IGNORE_UNAVAILABLE | ActivityManager.RECENT_INCLUDE_PROFILES, UserHandle.CURRENT.getIdentifier());
if (recentTasks != null && recentTasks.size() > 1) {
ActivityManager.RecentTaskInfo recentInfo = recentTasks.get(1);
taskid = recentInfo.persistentId;
} else {
//user cleared all apps, we don't have any taskid to choose
doWeHaveAtask = false;
}
}
if (doWeHaveAtask) {
try {
ActivityOptions options = ActivityOptions.makeBasic();
ActivityManagerNative.getDefault().startActivityFromRecents(taskid, options.toBundle());
} catch (RemoteException e) {
}
} else {
Toast noLastapp = Toast.makeText(mContext, R.string.recents_multiwin_nolastapp, Toast.LENGTH_LONG);
noLastapp.show();
}
}
use of android.app.ActivityOptions in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ConfirmDeviceCredentialBaseFragment method checkForPendingIntent.
protected void checkForPendingIntent() {
int taskId = getActivity().getIntent().getIntExtra(Intent.EXTRA_TASK_ID, -1);
if (taskId != -1) {
try {
IActivityManager activityManager = ActivityManagerNative.getDefault();
final ActivityOptions options = ActivityOptions.makeBasic();
options.setLaunchStackId(ActivityManager.StackId.INVALID_STACK_ID);
activityManager.startActivityFromRecents(taskId, options.toBundle());
return;
} catch (RemoteException e) {
// Do nothing.
}
}
IntentSender intentSender = getActivity().getIntent().getParcelableExtra(Intent.EXTRA_INTENT);
if (intentSender != null) {
try {
getActivity().startIntentSenderForResult(intentSender, -1, null, 0, 0, 0);
} catch (IntentSender.SendIntentException e) {
/* ignore */
}
}
}
Aggregations