Loading quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java +5 −15 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_OPTIMIZE_MEAS import static android.view.accessibility.AccessibilityEvent.TYPE_VIEW_FOCUSED; import static com.android.app.animation.Interpolators.EMPHASIZED; import static com.android.launcher3.Flags.enablePredictiveBackGesture; import static com.android.launcher3.Flags.enableUnfoldStateAnimation; import static com.android.launcher3.LauncherConstants.SavedInstanceKeys.PENDING_SPLIT_SELECT_INFO; import static com.android.launcher3.LauncherConstants.SavedInstanceKeys.RUNTIME_STATE; Loading Loading @@ -61,7 +62,6 @@ import static com.android.quickstep.util.SplitAnimationTimings.TABLET_HOME_TO_SP import static com.android.quickstep.views.DesktopTaskView.isDesktopModeSupported; import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_HOME_KEY; import static com.android.wm.shell.common.split.SplitScreenConstants.SNAP_TO_50_50; import static com.android.launcher3.Flags.enablePredictiveBackGesture; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; Loading Loading @@ -1103,21 +1103,11 @@ public class QuickstepLauncher extends Launcher { // populating workspace. // TODO: Find a better place for this WellbeingModel.INSTANCE.get(this); } @Override public void onInitialBindComplete(IntSet boundPages, RunnableList pendingTasks, int workspaceItemCount, boolean isBindSync) { pendingTasks.add(() -> { // This is added in pending task as we need to wait for views to be positioned // correctly before registering them for the animation. if (mLauncherUnfoldAnimationController != null) { // This is needed in case items are rebound while the unfold animation is in // progress. // This is needed in case items are rebound while the unfold animation is in progress. mLauncherUnfoldAnimationController.updateRegisteredViewsIfNeeded(); } }); super.onInitialBindComplete(boundPages, pendingTasks, workspaceItemCount, isBindSync); } @Override Loading src/com/android/launcher3/Launcher.java +0 −7 Original line number Diff line number Diff line Loading @@ -237,7 +237,6 @@ import com.android.launcher3.util.Themes; import com.android.launcher3.util.Thunk; import com.android.launcher3.util.TouchController; import com.android.launcher3.util.TraceHelper; import com.android.launcher3.util.ViewOnDrawExecutor; import com.android.launcher3.views.ActivityContext; import com.android.launcher3.views.ComposeInitializer; import com.android.launcher3.views.FloatingIconView; Loading Loading @@ -2233,12 +2232,6 @@ public class Launcher extends StatefulActivity<LauncherState> return info; } public void clearPendingExecutor(ViewOnDrawExecutor executor) { if (mModelCallbacks.getPendingExecutor() == executor) { mModelCallbacks.setPendingExecutor(null); } } /** * Call back when ModelCallbacks finish binding the Launcher data. */ Loading src/com/android/launcher3/ModelCallbacks.kt +13 −20 Original line number Diff line number Diff line Loading @@ -3,7 +3,6 @@ package com.android.launcher3 import android.annotation.TargetApi import android.os.Build import android.os.Trace import android.view.ViewTreeObserver.OnDrawListener import androidx.annotation.UiThread import com.android.launcher3.LauncherConstants.TraceEvents import com.android.launcher3.WorkspaceLayoutManager.FIRST_SCREEN_ID Loading @@ -18,7 +17,6 @@ import com.android.launcher3.model.data.LauncherAppWidgetInfo import com.android.launcher3.model.data.WorkspaceItemInfo import com.android.launcher3.popup.PopupContainerWithArrow import com.android.launcher3.util.ComponentKey import com.android.launcher3.util.Executors import com.android.launcher3.util.IntArray as LIntArray import com.android.launcher3.util.IntSet as LIntSet import com.android.launcher3.util.PackageUserKey Loading Loading @@ -77,11 +75,15 @@ class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks { workspaceItemCount: Int, isBindSync: Boolean ) { if (Utilities.ATLEAST_S) { Trace.endAsyncSection( TraceEvents.DISPLAY_WORKSPACE_TRACE_METHOD_NAME, TraceEvents.DISPLAY_WORKSPACE_TRACE_COOKIE ) } synchronouslyBoundPages = boundPages pagesToBindSynchronously = LIntSet() clearPendingBinds() val executor = ViewOnDrawExecutor(pendingTasks) pendingExecutor = executor if (!launcher.isInState(LauncherState.ALL_APPS)) { launcher.appsView.appsStore.enableDeferUpdates(AllAppsStore.DEFER_UPDATES_NEXT_DRAW) pendingTasks.add { Loading @@ -90,24 +92,15 @@ class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks { ) } } executor.onLoadAnimationCompleted() executor.attachTo(launcher) if (Utilities.ATLEAST_S) { Trace.endAsyncSection( TraceEvents.DISPLAY_WORKSPACE_TRACE_METHOD_NAME, TraceEvents.DISPLAY_WORKSPACE_TRACE_COOKIE ) } launcher.bindComplete(workspaceItemCount, isBindSync) launcher.rootView.viewTreeObserver.addOnDrawListener( object : OnDrawListener { override fun onDraw() { Executors.MAIN_EXECUTOR.handler.postAtFrontOfQueue { launcher.rootView.getViewTreeObserver().removeOnDrawListener(this) } val executor = ViewOnDrawExecutor(pendingTasks) { if (pendingExecutor == it) { pendingExecutor = null } } ) pendingExecutor = executor executor.attachTo(launcher) launcher.bindComplete(workspaceItemCount, isBindSync) } /** Loading src/com/android/launcher3/util/ViewOnDrawExecutor.java +10 −19 Original line number Diff line number Diff line Loading @@ -20,6 +20,8 @@ import android.view.View; import android.view.View.OnAttachStateChangeListener; import android.view.ViewTreeObserver.OnDrawListener; import androidx.annotation.NonNull; import com.android.launcher3.Launcher; import java.util.function.Consumer; Loading @@ -31,26 +33,23 @@ public class ViewOnDrawExecutor implements OnDrawListener, Runnable, OnAttachStateChangeListener { private final RunnableList mTasks; private Consumer<ViewOnDrawExecutor> mOnClearCallback; private final Consumer<ViewOnDrawExecutor> mOnClearCallback; private View mAttachedView; private boolean mCompleted; private boolean mLoadAnimationCompleted; private boolean mFirstDrawCompleted; private boolean mCancelled; public ViewOnDrawExecutor(RunnableList tasks) { public ViewOnDrawExecutor(RunnableList tasks, @NonNull Consumer<ViewOnDrawExecutor> onClearCallback) { mTasks = tasks; mOnClearCallback = onClearCallback; } public void attachTo(Launcher launcher) { mOnClearCallback = launcher::clearPendingExecutor; mAttachedView = launcher.getWorkspace(); mAttachedView.addOnAttachStateChangeListener(this); if (mAttachedView.isAttachedToWindow()) { attachObserver(); } Loading @@ -77,17 +76,10 @@ public class ViewOnDrawExecutor implements OnDrawListener, Runnable, mAttachedView.post(this); } public void onLoadAnimationCompleted() { mLoadAnimationCompleted = true; if (mAttachedView != null) { mAttachedView.post(this); } } @Override public void run() { // Post the pending tasks after both onDraw and onLoadAnimationCompleted have been called. if (mLoadAnimationCompleted && mFirstDrawCompleted && !mCompleted) { // Post the pending tasks after first draw if (mFirstDrawCompleted && !mCompleted) { markCompleted(); } } Loading @@ -104,10 +96,9 @@ public class ViewOnDrawExecutor implements OnDrawListener, Runnable, mAttachedView.getViewTreeObserver().removeOnDrawListener(this); mAttachedView.removeOnAttachStateChangeListener(this); } if (mOnClearCallback != null) { mOnClearCallback.accept(this); } } public void cancel() { mCancelled = true; Loading Loading
quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java +5 −15 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_OPTIMIZE_MEAS import static android.view.accessibility.AccessibilityEvent.TYPE_VIEW_FOCUSED; import static com.android.app.animation.Interpolators.EMPHASIZED; import static com.android.launcher3.Flags.enablePredictiveBackGesture; import static com.android.launcher3.Flags.enableUnfoldStateAnimation; import static com.android.launcher3.LauncherConstants.SavedInstanceKeys.PENDING_SPLIT_SELECT_INFO; import static com.android.launcher3.LauncherConstants.SavedInstanceKeys.RUNTIME_STATE; Loading Loading @@ -61,7 +62,6 @@ import static com.android.quickstep.util.SplitAnimationTimings.TABLET_HOME_TO_SP import static com.android.quickstep.views.DesktopTaskView.isDesktopModeSupported; import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_HOME_KEY; import static com.android.wm.shell.common.split.SplitScreenConstants.SNAP_TO_50_50; import static com.android.launcher3.Flags.enablePredictiveBackGesture; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; Loading Loading @@ -1103,21 +1103,11 @@ public class QuickstepLauncher extends Launcher { // populating workspace. // TODO: Find a better place for this WellbeingModel.INSTANCE.get(this); } @Override public void onInitialBindComplete(IntSet boundPages, RunnableList pendingTasks, int workspaceItemCount, boolean isBindSync) { pendingTasks.add(() -> { // This is added in pending task as we need to wait for views to be positioned // correctly before registering them for the animation. if (mLauncherUnfoldAnimationController != null) { // This is needed in case items are rebound while the unfold animation is in // progress. // This is needed in case items are rebound while the unfold animation is in progress. mLauncherUnfoldAnimationController.updateRegisteredViewsIfNeeded(); } }); super.onInitialBindComplete(boundPages, pendingTasks, workspaceItemCount, isBindSync); } @Override Loading
src/com/android/launcher3/Launcher.java +0 −7 Original line number Diff line number Diff line Loading @@ -237,7 +237,6 @@ import com.android.launcher3.util.Themes; import com.android.launcher3.util.Thunk; import com.android.launcher3.util.TouchController; import com.android.launcher3.util.TraceHelper; import com.android.launcher3.util.ViewOnDrawExecutor; import com.android.launcher3.views.ActivityContext; import com.android.launcher3.views.ComposeInitializer; import com.android.launcher3.views.FloatingIconView; Loading Loading @@ -2233,12 +2232,6 @@ public class Launcher extends StatefulActivity<LauncherState> return info; } public void clearPendingExecutor(ViewOnDrawExecutor executor) { if (mModelCallbacks.getPendingExecutor() == executor) { mModelCallbacks.setPendingExecutor(null); } } /** * Call back when ModelCallbacks finish binding the Launcher data. */ Loading
src/com/android/launcher3/ModelCallbacks.kt +13 −20 Original line number Diff line number Diff line Loading @@ -3,7 +3,6 @@ package com.android.launcher3 import android.annotation.TargetApi import android.os.Build import android.os.Trace import android.view.ViewTreeObserver.OnDrawListener import androidx.annotation.UiThread import com.android.launcher3.LauncherConstants.TraceEvents import com.android.launcher3.WorkspaceLayoutManager.FIRST_SCREEN_ID Loading @@ -18,7 +17,6 @@ import com.android.launcher3.model.data.LauncherAppWidgetInfo import com.android.launcher3.model.data.WorkspaceItemInfo import com.android.launcher3.popup.PopupContainerWithArrow import com.android.launcher3.util.ComponentKey import com.android.launcher3.util.Executors import com.android.launcher3.util.IntArray as LIntArray import com.android.launcher3.util.IntSet as LIntSet import com.android.launcher3.util.PackageUserKey Loading Loading @@ -77,11 +75,15 @@ class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks { workspaceItemCount: Int, isBindSync: Boolean ) { if (Utilities.ATLEAST_S) { Trace.endAsyncSection( TraceEvents.DISPLAY_WORKSPACE_TRACE_METHOD_NAME, TraceEvents.DISPLAY_WORKSPACE_TRACE_COOKIE ) } synchronouslyBoundPages = boundPages pagesToBindSynchronously = LIntSet() clearPendingBinds() val executor = ViewOnDrawExecutor(pendingTasks) pendingExecutor = executor if (!launcher.isInState(LauncherState.ALL_APPS)) { launcher.appsView.appsStore.enableDeferUpdates(AllAppsStore.DEFER_UPDATES_NEXT_DRAW) pendingTasks.add { Loading @@ -90,24 +92,15 @@ class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks { ) } } executor.onLoadAnimationCompleted() executor.attachTo(launcher) if (Utilities.ATLEAST_S) { Trace.endAsyncSection( TraceEvents.DISPLAY_WORKSPACE_TRACE_METHOD_NAME, TraceEvents.DISPLAY_WORKSPACE_TRACE_COOKIE ) } launcher.bindComplete(workspaceItemCount, isBindSync) launcher.rootView.viewTreeObserver.addOnDrawListener( object : OnDrawListener { override fun onDraw() { Executors.MAIN_EXECUTOR.handler.postAtFrontOfQueue { launcher.rootView.getViewTreeObserver().removeOnDrawListener(this) } val executor = ViewOnDrawExecutor(pendingTasks) { if (pendingExecutor == it) { pendingExecutor = null } } ) pendingExecutor = executor executor.attachTo(launcher) launcher.bindComplete(workspaceItemCount, isBindSync) } /** Loading
src/com/android/launcher3/util/ViewOnDrawExecutor.java +10 −19 Original line number Diff line number Diff line Loading @@ -20,6 +20,8 @@ import android.view.View; import android.view.View.OnAttachStateChangeListener; import android.view.ViewTreeObserver.OnDrawListener; import androidx.annotation.NonNull; import com.android.launcher3.Launcher; import java.util.function.Consumer; Loading @@ -31,26 +33,23 @@ public class ViewOnDrawExecutor implements OnDrawListener, Runnable, OnAttachStateChangeListener { private final RunnableList mTasks; private Consumer<ViewOnDrawExecutor> mOnClearCallback; private final Consumer<ViewOnDrawExecutor> mOnClearCallback; private View mAttachedView; private boolean mCompleted; private boolean mLoadAnimationCompleted; private boolean mFirstDrawCompleted; private boolean mCancelled; public ViewOnDrawExecutor(RunnableList tasks) { public ViewOnDrawExecutor(RunnableList tasks, @NonNull Consumer<ViewOnDrawExecutor> onClearCallback) { mTasks = tasks; mOnClearCallback = onClearCallback; } public void attachTo(Launcher launcher) { mOnClearCallback = launcher::clearPendingExecutor; mAttachedView = launcher.getWorkspace(); mAttachedView.addOnAttachStateChangeListener(this); if (mAttachedView.isAttachedToWindow()) { attachObserver(); } Loading @@ -77,17 +76,10 @@ public class ViewOnDrawExecutor implements OnDrawListener, Runnable, mAttachedView.post(this); } public void onLoadAnimationCompleted() { mLoadAnimationCompleted = true; if (mAttachedView != null) { mAttachedView.post(this); } } @Override public void run() { // Post the pending tasks after both onDraw and onLoadAnimationCompleted have been called. if (mLoadAnimationCompleted && mFirstDrawCompleted && !mCompleted) { // Post the pending tasks after first draw if (mFirstDrawCompleted && !mCompleted) { markCompleted(); } } Loading @@ -104,10 +96,9 @@ public class ViewOnDrawExecutor implements OnDrawListener, Runnable, mAttachedView.getViewTreeObserver().removeOnDrawListener(this); mAttachedView.removeOnAttachStateChangeListener(this); } if (mOnClearCallback != null) { mOnClearCallback.accept(this); } } public void cancel() { mCancelled = true; Loading