Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5a7d6e93 authored by Evan Rosky's avatar Evan Rosky Committed by Android (Google) Code Review
Browse files

Merge "Implement switchtoScreenshot recents callback" into tm-dev

parents 234889c8 e81d9679
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -145,6 +145,18 @@ public class RecentsAnimationCallbacks implements
        });
    }

    @BinderThread
    @Override
    public boolean onSwitchToScreenshot(Runnable onFinished) {
        Utilities.postAsyncCallback(MAIN_EXECUTOR.getHandler(), () -> {
            for (RecentsAnimationListener listener : getListeners()) {
                if (listener.onSwitchToScreenshot(onFinished)) return;
            }
            onFinished.run();
        });
        return true;
    }

    private final void onAnimationFinished(RecentsAnimationController controller) {
        Utilities.postAsyncCallback(MAIN_EXECUTOR.getHandler(), () -> {
            for (RecentsAnimationListener listener : getListeners()) {
@@ -180,5 +192,12 @@ public class RecentsAnimationCallbacks implements
         * Callback made when a task started from the recents is ready for an app transition.
         */
        default void onTasksAppeared(@NonNull RemoteAnimationTargetCompat[] appearedTaskTarget) {}

        /**
         * @return whether this will call onFinished or not (onFinished should only be called once).
         */
        default boolean onSwitchToScreenshot(Runnable onFinished) {
            return false;
        }
    }
}
+18 −0
Original line number Diff line number Diff line
@@ -203,6 +203,24 @@ public class TaskAnimationManager implements RecentsAnimationCallbacks.RecentsAn
                    }
                }
            }

            @Override
            public boolean onSwitchToScreenshot(Runnable onFinished) {
                if (!ENABLE_QUICKSTEP_LIVE_TILE.get() || !activityInterface.isInLiveTileMode()
                        || activityInterface.getCreatedActivity() == null) {
                    // No need to switch since tile is already a screenshot.
                    onFinished.run();
                } else {
                    final RecentsView recentsView =
                            activityInterface.getCreatedActivity().getOverviewPanel();
                    if (recentsView != null) {
                        recentsView.switchToScreenshot(onFinished);
                    } else {
                        onFinished.run();
                    }
                }
                return true;
            }
        });
        final long eventTime = gestureState.getSwipeUpStartTimeMs();
        mCallbacks.addListener(gestureState);