use of com.android.systemui.shared.recents.model.ThumbnailData in project android_packages_apps_Launcher3 by crdroidandroid.
the class AbsSwipeUpHandler method onActivityInit.
protected boolean onActivityInit(Boolean alreadyOnHome) {
if (mStateCallback.hasStates(STATE_HANDLER_INVALIDATED)) {
return false;
}
T createdActivity = mActivityInterface.getCreatedActivity();
if (createdActivity != null) {
initTransitionEndpoints(createdActivity.getDeviceProfile());
}
final T activity = mActivityInterface.getCreatedActivity();
if (mActivity == activity) {
return true;
}
if (mActivity != null) {
if (mStateCallback.hasStates(STATE_GESTURE_COMPLETED)) {
// If the activity has restarted between setting the page scroll settling callback
// and actually receiving the callback, just mark the gesture completed
mGestureState.setState(STATE_RECENTS_SCROLLING_FINISHED);
return true;
}
// The launcher may have been recreated as a result of device rotation.
int oldState = mStateCallback.getState() & ~LAUNCHER_UI_STATES;
initStateCallbacks();
mStateCallback.setState(oldState);
}
mWasLauncherAlreadyVisible = alreadyOnHome;
mActivity = activity;
// up, or until we transition home and the home animation is composed
if (alreadyOnHome) {
mActivity.clearForceInvisibleFlag(STATE_HANDLER_INVISIBILITY_FLAGS);
} else {
mActivity.addForceInvisibleFlag(STATE_HANDLER_INVISIBILITY_FLAGS);
}
mRecentsView = activity.getOverviewPanel();
mRecentsView.setOnPageTransitionEndCallback(null);
mStateCallback.setState(STATE_LAUNCHER_PRESENT);
if (alreadyOnHome) {
onLauncherStart();
} else {
activity.runOnceOnStart(this::onLauncherStart);
}
// Set up a entire animation lifecycle callback to notify the current recents view when
// the animation is canceled
mGestureState.runOnceAtState(STATE_RECENTS_ANIMATION_CANCELED, () -> {
ThumbnailData snapshot = mGestureState.consumeRecentsAnimationCanceledSnapshot();
if (snapshot != null) {
mRecentsView.switchToScreenshot(snapshot, () -> {
if (mRecentsAnimationController != null) {
mRecentsAnimationController.cleanupScreenshot();
}
});
mRecentsView.onRecentsAnimationComplete();
}
});
setupRecentsViewUi();
linkRecentsViewScroll();
return true;
}
use of com.android.systemui.shared.recents.model.ThumbnailData in project android_packages_apps_Launcher3 by crdroidandroid.
the class OverviewCommandHelper method executeCommand.
/**
* Executes the task and returns true if next task can be executed. If false, then the next
* task is deferred until {@link #scheduleNextTask} is called
*/
private <T extends StatefulActivity<?>> boolean executeCommand(CommandInfo cmd) {
BaseActivityInterface<?, T> activityInterface = mOverviewComponentObserver.getActivityInterface();
RecentsView recents = activityInterface.getVisibleRecentsView();
if (recents == null) {
if (cmd.type == TYPE_HIDE) {
// already hidden
return true;
}
} else {
switch(cmd.type) {
case TYPE_SHOW:
// already visible
return true;
case TYPE_HIDE:
{
int currentPage = recents.getNextPage();
TaskView tv = (currentPage >= 0 && currentPage < recents.getTaskViewCount()) ? (TaskView) recents.getPageAt(currentPage) : null;
return launchTask(recents, tv, cmd);
}
case TYPE_TOGGLE:
return launchTask(recents, getNextTask(recents), cmd);
}
}
if (activityInterface.switchToRecentsIfVisible(() -> scheduleNextTask(cmd))) {
// If successfully switched, wait until animation finishes
return false;
}
final T activity = activityInterface.getCreatedActivity();
if (activity != null) {
InteractionJankMonitorWrapper.begin(activity.getRootView(), InteractionJankMonitorWrapper.CUJ_QUICK_SWITCH);
}
GestureState gestureState = mService.createGestureState(GestureState.DEFAULT_STATE);
gestureState.setHandlingAtomicEvent(true);
AbsSwipeUpHandler interactionHandler = mService.getSwipeUpHandlerFactory().newHandler(gestureState, cmd.createTime);
interactionHandler.setGestureEndCallback(() -> onTransitionComplete(cmd, interactionHandler));
interactionHandler.initWhenReady();
RecentsAnimationListener recentAnimListener = new RecentsAnimationListener() {
@Override
public void onRecentsAnimationStart(RecentsAnimationController controller, RecentsAnimationTargets targets) {
interactionHandler.onGestureEnded(0, new PointF(), new PointF());
cmd.removeListener(this);
}
@Override
public void onRecentsAnimationCanceled(ThumbnailData thumbnailData) {
interactionHandler.onGestureCancelled();
cmd.removeListener(this);
RecentsView createdRecents = activityInterface.getCreatedActivity().getOverviewPanel();
if (createdRecents != null) {
createdRecents.onRecentsAnimationComplete();
}
}
};
if (mTaskAnimationManager.isRecentsAnimationRunning()) {
cmd.mActiveCallbacks = mTaskAnimationManager.continueRecentsAnimation(gestureState);
cmd.mActiveCallbacks.addListener(interactionHandler);
mTaskAnimationManager.notifyRecentsAnimationState(interactionHandler);
interactionHandler.onGestureStarted(true);
cmd.mActiveCallbacks.addListener(recentAnimListener);
mTaskAnimationManager.notifyRecentsAnimationState(recentAnimListener);
} else {
Intent intent = new Intent(interactionHandler.getLaunchIntent());
intent.putExtra(INTENT_EXTRA_LOG_TRACE_ID, gestureState.getGestureId());
cmd.mActiveCallbacks = mTaskAnimationManager.startRecentsAnimation(gestureState, intent, interactionHandler);
interactionHandler.onGestureStarted(false);
cmd.mActiveCallbacks.addListener(recentAnimListener);
}
Trace.beginAsyncSection(TRANSITION_NAME, 0);
return false;
}
use of com.android.systemui.shared.recents.model.ThumbnailData in project android_packages_apps_Launcher3 by crdroidandroid.
the class TaskThumbnailCache method updateThumbnailInBackground.
private CancellableTask updateThumbnailInBackground(TaskKey key, boolean lowResolution, Consumer<ThumbnailData> callback) {
Preconditions.assertUIThread();
ThumbnailData cachedThumbnail = mCache.getAndInvalidateIfModified(key);
if (cachedThumbnail != null && (!cachedThumbnail.reducedResolution || lowResolution)) {
// Already cached, lets use that thumbnail
callback.accept(cachedThumbnail);
return null;
}
CancellableTask<ThumbnailData> request = new CancellableTask<ThumbnailData>() {
@Override
public ThumbnailData getResultOnBg() {
return ActivityManagerWrapper.getInstance().getTaskThumbnail(key.id, lowResolution);
}
@Override
public void handleResult(ThumbnailData result) {
mCache.put(key, result);
callback.accept(result);
}
};
mBgExecutor.execute(request);
return request;
}
use of com.android.systemui.shared.recents.model.ThumbnailData in project android_packages_apps_Launcher3 by crdroidandroid.
the class TaskAnimationManager method startRecentsAnimation.
/**
* Starts a new recents animation for the activity with the given {@param intent}.
*/
@UiThread
public RecentsAnimationCallbacks startRecentsAnimation(GestureState gestureState, Intent intent, RecentsAnimationCallbacks.RecentsAnimationListener listener) {
// Notify if recents animation is still running
if (mController != null) {
String msg = "New recents animation started before old animation completed";
if (FeatureFlags.IS_STUDIO_BUILD) {
throw new IllegalArgumentException(msg);
} else {
Log.e("TaskAnimationManager", msg, new Exception());
}
}
// But force-finish it anyways
finishRunningRecentsAnimation(false);
final BaseActivityInterface activityInterface = gestureState.getActivityInterface();
mLastGestureState = gestureState;
mCallbacks = new RecentsAnimationCallbacks(activityInterface.allowMinimizeSplitScreen());
mCallbacks.addListener(new RecentsAnimationCallbacks.RecentsAnimationListener() {
@Override
public void onRecentsAnimationStart(RecentsAnimationController controller, RecentsAnimationTargets targets) {
if (mCallbacks == null) {
// handling this call entirely
return;
}
mController = controller;
mTargets = targets;
mLastAppearedTaskTarget = mTargets.findTask(mLastGestureState.getRunningTaskId());
mLastGestureState.updateLastAppearedTaskTarget(mLastAppearedTaskTarget);
}
@Override
public void onRecentsAnimationCanceled(ThumbnailData thumbnailData) {
cleanUpRecentsAnimation();
}
@Override
public void onRecentsAnimationFinished(RecentsAnimationController controller) {
cleanUpRecentsAnimation();
}
@Override
public void onTaskAppeared(RemoteAnimationTargetCompat appearedTaskTarget) {
BaseActivityInterface activityInterface = mLastGestureState.getActivityInterface();
if (ENABLE_QUICKSTEP_LIVE_TILE.get() && activityInterface.isInLiveTileMode() && activityInterface.getCreatedActivity() != null) {
RecentsView recentsView = activityInterface.getCreatedActivity().getOverviewPanel();
if (recentsView != null) {
RemoteAnimationTargetCompat[] apps = new RemoteAnimationTargetCompat[1];
apps[0] = appearedTaskTarget;
recentsView.launchSideTaskInLiveTileMode(appearedTaskTarget.taskId, apps, new RemoteAnimationTargetCompat[0], /* wallpaper */
new RemoteAnimationTargetCompat[0]);
return;
}
}
if (mController != null) {
if (mLastAppearedTaskTarget == null || appearedTaskTarget.taskId != mLastAppearedTaskTarget.taskId) {
if (mLastAppearedTaskTarget != null) {
mController.removeTaskTarget(mLastAppearedTaskTarget);
}
mLastAppearedTaskTarget = appearedTaskTarget;
mLastGestureState.updateLastAppearedTaskTarget(mLastAppearedTaskTarget);
}
}
}
});
final long eventTime = gestureState.getSwipeUpStartTimeMs();
mCallbacks.addListener(gestureState);
mCallbacks.addListener(listener);
if (ENABLE_SHELL_TRANSITIONS) {
RemoteTransitionCompat transition = new RemoteTransitionCompat(mCallbacks, mController != null ? mController.getController() : null);
Bundle options = ActivityOptionsCompat.makeRemoteTransition(transition).setTransientLaunch().toBundle();
mCtx.startActivity(intent, options);
} else {
UI_HELPER_EXECUTOR.execute(() -> ActivityManagerWrapper.getInstance().startRecentsActivity(intent, eventTime, mCallbacks, null, null));
}
gestureState.setState(STATE_RECENTS_ANIMATION_INITIALIZED);
return mCallbacks;
}
use of com.android.systemui.shared.recents.model.ThumbnailData in project android_packages_apps_Launcher3 by crdroidandroid.
the class RecentsActivityTest method testRecents_showCurrentTask.
@Test
public void testRecents_showCurrentTask() {
ActivityController<RecentsActivity> controller = Robolectric.buildActivity(RecentsActivity.class);
RecentsActivity activity = controller.setup().get();
doLayout(activity);
FallbackRecentsView frv = activity.getOverviewPanel();
RunningTaskInfo placeholderTask = new RunningTaskInfo();
placeholderTask.taskId = 22;
frv.showCurrentTask(placeholderTask);
doLayout(activity);
ThumbnailData thumbnailData = new ThumbnailData();
ReflectionHelpers.setField(thumbnailData, "thumbnail", Bitmap.createBitmap(300, 500, Config.ARGB_8888));
frv.switchToScreenshot(thumbnailData, () -> {
});
ShadowLooper.idleMainLooper();
}
Aggregations