use of com.android.systemui.recents.misc.SystemServicesProxy in project android_frameworks_base by crdroidandroid.
the class RecentsTvTransitionHelper method startTaskActivity.
private void startTaskActivity(TaskStack stack, Task task, @Nullable TaskCardView taskView, ActivityOptions opts, final ActivityOptions.OnAnimationStartedListener animStartedListener) {
SystemServicesProxy ssp = Recents.getSystemServices();
if (ssp.startActivityFromRecents(mContext, task.key, task.title, opts)) {
// Keep track of the index of the task launch
int taskIndexFromFront = 0;
int taskIndex = stack.indexOfStackTask(task);
if (taskIndex > -1) {
taskIndexFromFront = stack.getTaskCount() - taskIndex - 1;
}
EventBus.getDefault().send(new LaunchTaskSucceededEvent(taskIndexFromFront));
} else {
// Keep track of failed launches
EventBus.getDefault().send(new LaunchTaskFailedEvent());
}
Rect taskRect = taskView.getFocusedThumbnailRect();
// we do not override the transition.
if (taskRect == null || task.thumbnail == null) {
return;
}
IRemoteCallback.Stub callback = null;
if (animStartedListener != null) {
callback = new IRemoteCallback.Stub() {
@Override
public void sendResult(Bundle data) throws RemoteException {
mHandler.post(new Runnable() {
@Override
public void run() {
if (animStartedListener != null) {
animStartedListener.onAnimationStarted();
}
}
});
}
};
}
try {
Bitmap thumbnail = Bitmap.createScaledBitmap(task.thumbnail, taskRect.width(), taskRect.height(), false);
WindowManagerGlobal.getWindowManagerService().overridePendingAppTransitionAspectScaledThumb(thumbnail, taskRect.left, taskRect.top, taskRect.width(), taskRect.height(), callback, true);
} catch (RemoteException e) {
Log.w(TAG, "Failed to override transition: " + e);
}
}
use of com.android.systemui.recents.misc.SystemServicesProxy in project android_frameworks_base by crdroidandroid.
the class RecentsTvView method launchTaskFomRecents.
/**
* Launch the given task from recents with animation. If the task is not focused, this will
* attempt to scroll to focus the task before launching.
* @param task
*/
private void launchTaskFomRecents(final Task task, boolean animate) {
if (!animate) {
SystemServicesProxy ssp = Recents.getSystemServices();
ssp.startActivityFromRecents(getContext(), task.key, task.title, null);
return;
}
mTaskStackHorizontalView.requestFocus();
Task focusedTask = mTaskStackHorizontalView.getFocusedTask();
if (focusedTask != null && task != focusedTask) {
if (mScrollListener != null) {
mTaskStackHorizontalView.removeOnScrollListener(mScrollListener);
}
mScrollListener = new OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
TaskCardView cardView = mTaskStackHorizontalView.getChildViewForTask(task);
if (cardView != null) {
mTransitionHelper.launchTaskFromRecents(mStack, task, mTaskStackHorizontalView, cardView, null, INVALID_STACK_ID);
} else {
// This should not happen normally. If this happens then the data in
// the grid view was altered during the scroll. Log error and launch
// task with no animation.
Log.e(TAG, "Card view for task : " + task + ", returned null.");
SystemServicesProxy ssp = Recents.getSystemServices();
ssp.startActivityFromRecents(getContext(), task.key, task.title, null);
}
mTaskStackHorizontalView.removeOnScrollListener(mScrollListener);
}
}
};
mTaskStackHorizontalView.addOnScrollListener(mScrollListener);
mTaskStackHorizontalView.setSelectedPositionSmooth(((TaskStackHorizontalViewAdapter) mTaskStackHorizontalView.getAdapter()).getPositionOfTask(task));
} else {
mTransitionHelper.launchTaskFromRecents(mStack, task, mTaskStackHorizontalView, mTaskStackHorizontalView.getChildViewForTask(task), null, INVALID_STACK_ID);
}
}
use of com.android.systemui.recents.misc.SystemServicesProxy in project android_frameworks_base by crdroidandroid.
the class TaskCardView method onFinishInflate.
@Override
protected void onFinishInflate() {
super.onFinishInflate();
mThumbnailView = findViewById(R.id.card_view_thumbnail);
mInfoFieldView = findViewById(R.id.card_info_field);
mTitleTextView = (TextView) findViewById(R.id.card_title_text);
mBadgeView = (ImageView) findViewById(R.id.card_extra_badge);
mDismissIconView = findViewById(R.id.dismiss_icon);
mDismissAnimationsHolder = new DismissAnimationsHolder(this);
mCornerRadius = getResources().getDimensionPixelSize(R.dimen.recents_task_view_rounded_corners_radius);
mRecentsRowFocusAnimationHolder = new RecentsRowFocusAnimationHolder(this, mInfoFieldView);
SystemServicesProxy ssp = Recents.getSystemServices();
mTouchExplorationEnabled = ssp.isTouchExplorationEnabled();
if (!mTouchExplorationEnabled) {
mDismissIconView.setVisibility(VISIBLE);
} else {
mDismissIconView.setVisibility(GONE);
}
mViewFocusAnimator = new ViewFocusAnimator(this);
}
use of com.android.systemui.recents.misc.SystemServicesProxy in project android_frameworks_base by crdroidandroid.
the class TaskStackLayoutAlgorithm method getStackTransform.
/**
* Update/get the transform.
*
* @param ignoreSingleTaskCase When set, will ensure that the transform computed does not take
* into account the special single-task case. This is only used
* internally to ensure that we can calculate the transform for any
* position in the stack.
*/
public void getStackTransform(float taskProgress, float nonOverrideTaskProgress, float stackScroll, int focusState, TaskViewTransform transformOut, TaskViewTransform frontTransform, boolean ignoreSingleTaskCase, boolean forceUpdate) {
SystemServicesProxy ssp = Recents.getSystemServices();
// Ensure that the task is in range
mUnfocusedRange.offset(stackScroll);
mFocusedRange.offset(stackScroll);
boolean unfocusedVisible = mUnfocusedRange.isInRange(taskProgress);
boolean focusedVisible = mFocusedRange.isInRange(taskProgress);
// Skip if the task is not visible
if (!forceUpdate && !unfocusedVisible && !focusedVisible) {
transformOut.reset();
return;
}
// Map the absolute task progress to the normalized x at the stack scroll. We use this to
// calculate positions along the curve.
mUnfocusedRange.offset(stackScroll);
mFocusedRange.offset(stackScroll);
float unfocusedRangeX = mUnfocusedRange.getNormalizedX(taskProgress);
float focusedRangeX = mFocusedRange.getNormalizedX(taskProgress);
// Map the absolute task progress to the normalized x at the bounded stack scroll. We use
// this to calculate bounded properties, like translationZ and outline alpha.
float boundedStackScroll = Utilities.clamp(stackScroll, mMinScrollP, mMaxScrollP);
mUnfocusedRange.offset(boundedStackScroll);
mFocusedRange.offset(boundedStackScroll);
float boundedScrollUnfocusedRangeX = mUnfocusedRange.getNormalizedX(taskProgress);
float boundedScrollUnfocusedNonOverrideRangeX = mUnfocusedRange.getNormalizedX(nonOverrideTaskProgress);
// Map the absolute task progress to the normalized x at the upper bounded stack scroll.
// We use this to calculate the dim, which is bounded only on one end.
float lowerBoundedStackScroll = Utilities.clamp(stackScroll, -Float.MAX_VALUE, mMaxScrollP);
mUnfocusedRange.offset(lowerBoundedStackScroll);
mFocusedRange.offset(lowerBoundedStackScroll);
float lowerBoundedUnfocusedRangeX = mUnfocusedRange.getNormalizedX(taskProgress);
float lowerBoundedFocusedRangeX = mFocusedRange.getNormalizedX(taskProgress);
int x = (mStackRect.width() - mTaskRect.width()) / 2;
int y;
float z;
float dimAlpha;
float viewOutlineAlpha;
if (!ssp.hasFreeformWorkspaceSupport() && mNumStackTasks == 1 && !ignoreSingleTaskCase) {
// When there is exactly one task, then decouple the task from the stack and just move
// in screen space
float tmpP = (mMinScrollP - stackScroll) / mNumStackTasks;
int centerYOffset = (mStackRect.top - mTaskRect.top) + (mStackRect.height() - mSystemInsets.bottom - mTaskRect.height()) / 2;
y = centerYOffset + getYForDeltaP(tmpP, 0);
z = mMaxTranslationZ;
dimAlpha = 0f;
viewOutlineAlpha = OUTLINE_ALPHA_MIN_VALUE + (OUTLINE_ALPHA_MAX_VALUE - OUTLINE_ALPHA_MIN_VALUE) / 2f;
} else {
// Otherwise, update the task to the stack layout
int unfocusedY = (int) ((1f - mUnfocusedCurveInterpolator.getInterpolation(unfocusedRangeX)) * mStackRect.height());
int focusedY = (int) ((1f - mFocusedCurveInterpolator.getInterpolation(focusedRangeX)) * mStackRect.height());
float unfocusedDim = mUnfocusedDimCurveInterpolator.getInterpolation(lowerBoundedUnfocusedRangeX);
float focusedDim = mFocusedDimCurveInterpolator.getInterpolation(lowerBoundedFocusedRangeX);
// dim when the task is scrolled back towards the top of the screen
if (mNumStackTasks <= 2 && nonOverrideTaskProgress == 0f) {
if (boundedScrollUnfocusedRangeX >= 0.5f) {
unfocusedDim = 0f;
} else {
float offset = mUnfocusedDimCurveInterpolator.getInterpolation(0.5f);
unfocusedDim -= offset;
unfocusedDim *= MAX_DIM / (MAX_DIM - offset);
}
}
y = (mStackRect.top - mTaskRect.top) + (int) Utilities.mapRange(focusState, unfocusedY, focusedY);
z = Utilities.mapRange(Utilities.clamp01(boundedScrollUnfocusedNonOverrideRangeX), mMinTranslationZ, mMaxTranslationZ);
dimAlpha = Utilities.mapRange(focusState, unfocusedDim, focusedDim);
viewOutlineAlpha = Utilities.mapRange(Utilities.clamp01(boundedScrollUnfocusedRangeX), OUTLINE_ALPHA_MIN_VALUE, OUTLINE_ALPHA_MAX_VALUE);
}
// Fill out the transform
transformOut.scale = 1f;
transformOut.alpha = 1f;
transformOut.translationZ = z;
transformOut.dimAlpha = dimAlpha;
transformOut.viewOutlineAlpha = viewOutlineAlpha;
transformOut.rect.set(mTaskRect);
transformOut.rect.offset(x, y);
Utilities.scaleRectAboutCenter(transformOut.rect, transformOut.scale);
transformOut.visible = (transformOut.rect.top < mStackRect.bottom) && (frontTransform == null || transformOut.rect.top != frontTransform.rect.top);
}
use of com.android.systemui.recents.misc.SystemServicesProxy in project android_frameworks_base by crdroidandroid.
the class RecentsView method onBusEvent.
public final void onBusEvent(final DragEndEvent event) {
// Handle the case where we drop onto a dock region
if (event.dropTarget instanceof TaskStack.DockState) {
final TaskStack.DockState dockState = (TaskStack.DockState) event.dropTarget;
// Hide the dock region
updateVisibleDockRegions(null, false, /* isDefaultDockState */
-1, -1, false, /* animateAlpha */
false);
// We translated the view but we need to animate it back from the current layout-space
// rect to its final layout-space rect
Utilities.setViewFrameFromTranslation(event.taskView);
// Dock the task and launch it
SystemServicesProxy ssp = Recents.getSystemServices();
if (ssp.startTaskInDockedMode(event.task.key.id, dockState.createMode)) {
final OnAnimationStartedListener startedListener = new OnAnimationStartedListener() {
@Override
public void onAnimationStarted() {
EventBus.getDefault().send(new DockedFirstAnimationFrameEvent());
// Remove the task and don't bother relaying out, as all the tasks will be
// relaid out when the stack changes on the multiwindow change event
getStack().removeTask(event.task, null, true);
}
};
final Rect taskRect = getTaskRect(event.taskView);
IAppTransitionAnimationSpecsFuture future = mTransitionHelper.getAppTransitionFuture(new AnimationSpecComposer() {
@Override
public List<AppTransitionAnimationSpec> composeSpecs() {
return mTransitionHelper.composeDockAnimationSpec(event.taskView, taskRect);
}
});
ssp.overridePendingAppTransitionMultiThumbFuture(future, mTransitionHelper.wrapStartedListener(startedListener), true);
MetricsLogger.action(mContext, MetricsEvent.ACTION_WINDOW_DOCK_DRAG_DROP, event.task.getTopComponent().flattenToShortString());
} else {
EventBus.getDefault().send(new DragEndCancelledEvent(getStack(), event.task, event.taskView));
}
} else {
// Animate the overlay alpha back to 0
updateVisibleDockRegions(null, true, /* isDefaultDockState */
-1, -1, true, /* animateAlpha */
false);
}
// Show the stack action button again without changing visibility
if (mStackActionButton != null) {
mStackActionButton.animate().alpha(1f).setDuration(SHOW_STACK_ACTION_BUTTON_DURATION).setInterpolator(Interpolators.ALPHA_IN).start();
}
}
Aggregations