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

Commit 3b8e5a1c authored by Winson Chung's avatar Winson Chung Committed by Android (Google) Code Review
Browse files

Merge "Moving more callbacks to animated events."

parents 5724fe9d ef06413a
Loading
Loading
Loading
Loading
+24 −43
Original line number Original line Diff line number Diff line
@@ -43,8 +43,10 @@ import com.android.systemui.recents.events.EventBus;
import com.android.systemui.recents.events.activity.AppWidgetProviderChangedEvent;
import com.android.systemui.recents.events.activity.AppWidgetProviderChangedEvent;
import com.android.systemui.recents.events.activity.CancelEnterRecentsWindowAnimationEvent;
import com.android.systemui.recents.events.activity.CancelEnterRecentsWindowAnimationEvent;
import com.android.systemui.recents.events.activity.DebugFlagsChangedEvent;
import com.android.systemui.recents.events.activity.DebugFlagsChangedEvent;
import com.android.systemui.recents.events.activity.DismissRecentsToHomeAnimationStarted;
import com.android.systemui.recents.events.activity.EnterRecentsWindowAnimationCompletedEvent;
import com.android.systemui.recents.events.activity.EnterRecentsWindowAnimationCompletedEvent;
import com.android.systemui.recents.events.activity.EnterRecentsWindowLastAnimationFrameEvent;
import com.android.systemui.recents.events.activity.EnterRecentsWindowLastAnimationFrameEvent;
import com.android.systemui.recents.events.activity.ExitRecentsWindowFirstAnimationFrameEvent;
import com.android.systemui.recents.events.activity.HideHistoryEvent;
import com.android.systemui.recents.events.activity.HideHistoryEvent;
import com.android.systemui.recents.events.activity.HideRecentsEvent;
import com.android.systemui.recents.events.activity.HideRecentsEvent;
import com.android.systemui.recents.events.activity.IterateRecentsEvent;
import com.android.systemui.recents.events.activity.IterateRecentsEvent;
@@ -56,8 +58,7 @@ import com.android.systemui.recents.events.activity.ToggleRecentsEvent;
import com.android.systemui.recents.events.component.RecentsVisibilityChangedEvent;
import com.android.systemui.recents.events.component.RecentsVisibilityChangedEvent;
import com.android.systemui.recents.events.component.ScreenPinningRequestEvent;
import com.android.systemui.recents.events.component.ScreenPinningRequestEvent;
import com.android.systemui.recents.events.ui.AllTaskViewsDismissedEvent;
import com.android.systemui.recents.events.ui.AllTaskViewsDismissedEvent;
import com.android.systemui.recents.events.ui.DismissTaskEvent;
import com.android.systemui.recents.events.ui.DeleteTaskDataEvent;
import com.android.systemui.recents.events.ui.DismissTaskViewEvent;
import com.android.systemui.recents.events.ui.ShowApplicationInfoEvent;
import com.android.systemui.recents.events.ui.ShowApplicationInfoEvent;
import com.android.systemui.recents.events.ui.StackViewScrolledEvent;
import com.android.systemui.recents.events.ui.StackViewScrolledEvent;
import com.android.systemui.recents.events.ui.UpdateFreeformTaskViewVisibilityEvent;
import com.android.systemui.recents.events.ui.UpdateFreeformTaskViewVisibilityEvent;
@@ -76,7 +77,6 @@ import com.android.systemui.recents.model.Task;
import com.android.systemui.recents.model.TaskStack;
import com.android.systemui.recents.model.TaskStack;
import com.android.systemui.recents.views.RecentsView;
import com.android.systemui.recents.views.RecentsView;
import com.android.systemui.recents.views.SystemBarScrimViews;
import com.android.systemui.recents.views.SystemBarScrimViews;
import com.android.systemui.recents.views.ViewAnimation;
import com.android.systemui.statusbar.BaseStatusBar;
import com.android.systemui.statusbar.BaseStatusBar;


import java.util.ArrayList;
import java.util.ArrayList;
@@ -274,7 +274,7 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
            // If we have a focused Task, launch that Task now
            // If we have a focused Task, launch that Task now
            if (mRecentsView.launchPreviousTask()) return true;
            if (mRecentsView.launchPreviousTask()) return true;
            // If none of the other cases apply, then just go Home
            // If none of the other cases apply, then just go Home
            dismissRecentsToHome(true);
            dismissRecentsToHome(true /* animateTaskViews */);
        }
        }
        return false;
        return false;
    }
    }
@@ -288,7 +288,7 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
            // If we have a focused Task, launch that Task now
            // If we have a focused Task, launch that Task now
            if (mRecentsView.launchFocusedTask()) return true;
            if (mRecentsView.launchFocusedTask()) return true;
            // If none of the other cases apply, then just go Home
            // If none of the other cases apply, then just go Home
            dismissRecentsToHome(true);
            dismissRecentsToHome(true /* animateTaskViews */);
            return true;
            return true;
        }
        }
        return false;
        return false;
@@ -297,32 +297,18 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
    /**
    /**
     * Dismisses Recents directly to Home without checking whether it is currently visible.
     * Dismisses Recents directly to Home without checking whether it is currently visible.
     */
     */
    void dismissRecentsToHome(boolean animated) {
    void dismissRecentsToHome(boolean animateTaskViews) {
        if (animated) {
        DismissRecentsToHomeAnimationStarted dismissEvent =
            ReferenceCountedTrigger exitTrigger = new ReferenceCountedTrigger();
                new DismissRecentsToHomeAnimationStarted(animateTaskViews);
            exitTrigger.increment();
        dismissEvent.addPostAnimationCallback(mFinishLaunchHomeRunnable);
            exitTrigger.addLastDecrementRunnable(mFinishLaunchHomeRunnable);
        dismissEvent.addPostAnimationCallback(new Runnable() {
            exitTrigger.addLastDecrementRunnable(new Runnable() {
            @Override
            @Override
            public void run() {
            public void run() {
                Recents.getSystemServices().sendCloseSystemWindows(
                Recents.getSystemServices().sendCloseSystemWindows(
                        BaseStatusBar.SYSTEM_DIALOG_REASON_HOME_KEY);
                        BaseStatusBar.SYSTEM_DIALOG_REASON_HOME_KEY);
            }
            }
        });
        });
            mRecentsView.startExitToHomeAnimation(
        EventBus.getDefault().send(dismissEvent);
                    new ViewAnimation.TaskViewExitContext(exitTrigger));
            exitTrigger.decrement();
        } else {
            mFinishLaunchHomeRunnable.run();
            Recents.getSystemServices().sendCloseSystemWindows(
                    BaseStatusBar.SYSTEM_DIALOG_REASON_HOME_KEY);
        }
    }

    /** Dismisses Recents directly to Home without transition animation. */
    void dismissRecentsToHomeWithoutTransitionAnimation() {
        finish();
        overridePendingTransition(0, 0);
    }
    }


    /** Dismisses Recents directly to Home if we currently aren't transitioning. */
    /** Dismisses Recents directly to Home if we currently aren't transitioning. */
@@ -609,7 +595,7 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
        if (!dismissHistory()) {
        if (!dismissHistory()) {
            RecentsActivityLaunchState launchState = Recents.getConfiguration().getLaunchState();
            RecentsActivityLaunchState launchState = Recents.getConfiguration().getLaunchState();
            if (launchState.launchedFromHome) {
            if (launchState.launchedFromHome) {
                dismissRecentsToHome(true);
                dismissRecentsToHome(true /* animateTaskViews */);
            } else {
            } else {
                dismissRecentsToLaunchTargetTaskOrHome();
                dismissRecentsToLaunchTargetTaskOrHome();
            }
            }
@@ -650,13 +636,13 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
                hideEvent.addPostAnimationCallback(new Runnable() {
                hideEvent.addPostAnimationCallback(new Runnable() {
                    @Override
                    @Override
                    public void run() {
                    public void run() {
                        dismissRecentsToHome(true /* animated */);
                        dismissRecentsToHome(true /* animateTaskViews */);
                    }
                    }
                });
                });
                EventBus.getDefault().send(hideEvent);
                EventBus.getDefault().send(hideEvent);


            } else {
            } else {
                dismissRecentsToHome(true /* animated */);
                dismissRecentsToHome(true /* animateTaskViews */);
            }
            }
        } else {
        } else {
            // Do nothing
            // Do nothing
@@ -665,12 +651,9 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD


    public final void onBusEvent(EnterRecentsWindowAnimationCompletedEvent event) {
    public final void onBusEvent(EnterRecentsWindowAnimationCompletedEvent event) {
        // Try and start the enter animation (or restart it on configuration changed)
        // Try and start the enter animation (or restart it on configuration changed)
        ReferenceCountedTrigger t = new ReferenceCountedTrigger();
        ViewAnimation.TaskViewEnterContext ctx = new ViewAnimation.TaskViewEnterContext(t);
        ctx.postAnimationTrigger.increment();
        if (RecentsDebugFlags.Static.EnableSearchBar) {
        if (RecentsDebugFlags.Static.EnableSearchBar) {
            if (mSearchWidgetInfo != null) {
            if (mSearchWidgetInfo != null) {
                ctx.postAnimationTrigger.addLastDecrementRunnable(new Runnable() {
                event.addPostAnimationCallback(new Runnable() {
                    @Override
                    @Override
                    public void run() {
                    public void run() {
                        // Start listening for widget package changes if there is one bound
                        // Start listening for widget package changes if there is one bound
@@ -681,8 +664,6 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
                });
                });
            }
            }
        }
        }
        mRecentsView.startEnterRecentsAnimation(ctx);
        ctx.postAnimationTrigger.decrement();
    }
    }


    public final void onBusEvent(EnterRecentsWindowLastAnimationFrameEvent event) {
    public final void onBusEvent(EnterRecentsWindowLastAnimationFrameEvent event) {
@@ -727,7 +708,7 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
        MetricsLogger.count(this, "overview_app_info", 1);
        MetricsLogger.count(this, "overview_app_info", 1);
    }
    }


    public final void onBusEvent(DismissTaskEvent event) {
    public final void onBusEvent(DeleteTaskDataEvent event) {
        // Remove any stored data from the loader
        // Remove any stored data from the loader
        RecentsTaskLoader loader = Recents.getTaskLoader();
        RecentsTaskLoader loader = Recents.getTaskLoader();
        loader.deleteTaskData(event.task, false);
        loader.deleteTaskData(event.task, false);
@@ -743,7 +724,7 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
            mRecentsView.showEmptyView();
            mRecentsView.showEmptyView();
        } else {
        } else {
            // Just go straight home (no animation necessary because there are no more task views)
            // Just go straight home (no animation necessary because there are no more task views)
            dismissRecentsToHome(false /* animated */);
            dismissRecentsToHome(false /* animateTaskViews */);
        }
        }


        // Keep track of all-deletions
        // Keep track of all-deletions
@@ -756,7 +737,7 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD


    public final void onBusEvent(LaunchTaskFailedEvent event) {
    public final void onBusEvent(LaunchTaskFailedEvent event) {
        // Return to Home
        // Return to Home
        dismissRecentsToHome(true);
        dismissRecentsToHome(true /* animateTaskViews */);


        MetricsLogger.count(this, "overview_task_launch_failed", 1);
        MetricsLogger.count(this, "overview_task_launch_failed", 1);
    }
    }
+8 −2
Original line number Original line Diff line number Diff line
@@ -21,6 +21,12 @@ import com.android.systemui.recents.events.EventBus;
/**
/**
 * This is sent when the task animation when dismissing Recents starts.
 * This is sent when the task animation when dismissing Recents starts.
 */
 */
public class DismissRecentsToHomeAnimationStarted extends EventBus.Event {
public class DismissRecentsToHomeAnimationStarted extends EventBus.AnimatedEvent {
    // Simple event

    public final boolean animated;

    public DismissRecentsToHomeAnimationStarted(boolean animated) {
        this.animated = animated;
    }

}
}
+1 −1
Original line number Original line Diff line number Diff line
@@ -23,6 +23,6 @@ import com.android.systemui.recents.events.EventBus;
 * we can start in-app animations so that they don't conflict with the window transition into
 * we can start in-app animations so that they don't conflict with the window transition into
 * Recents.
 * Recents.
 */
 */
public class EnterRecentsWindowAnimationCompletedEvent extends EventBus.Event {
public class EnterRecentsWindowAnimationCompletedEvent extends EventBus.AnimatedEvent {
    // Simple event
    // Simple event
}
}
+1 −1
Original line number Original line Diff line number Diff line
@@ -14,7 +14,7 @@
 * limitations under the License.
 * limitations under the License.
 */
 */


package com.android.systemui.recents;
package com.android.systemui.recents.events.activity;


import com.android.systemui.recents.events.EventBus;
import com.android.systemui.recents.events.EventBus;


+1 −1
Original line number Original line Diff line number Diff line
@@ -22,7 +22,7 @@ import com.android.systemui.recents.model.Task;
import com.android.systemui.recents.views.TaskView;
import com.android.systemui.recents.views.TaskView;


/**
/**
 * This is sent to launch a task from Recents.
 * This event is sent to request that a particular task is launched.
 */
 */
public class LaunchTaskEvent extends EventBus.Event {
public class LaunchTaskEvent extends EventBus.Event {


Loading