use of android.app.ActivityOptions in project android_frameworks_base by ResurrectionRemix.
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);
}
}
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();
}
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);
}
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();
}
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;
}
Aggregations