From c8f686710e646cf0e4389089e98bc678ab2612ab Mon Sep 17 00:00:00 2001 From: Fedor Kudasov Date: Tue, 16 Nov 2021 14:48:16 +0000 Subject: [PATCH] Move FloatingTaskInit set up into init method This makes the code more tidy and consistent with other classes. Additionally, this allows for easier annotation of the initialization code. Bug: 205828770 Test: m LauncherGoResLib Change-Id: Ib7ecf32cffd5c6af67a4c2095d7cb3e3a2f387e4 (cherry picked from commit f50acd3ed855f21a4aca0d98ef9fc6c1099423d2) --- .../quickstep/views/FloatingTaskView.java | 49 ++++++++++--------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/quickstep/src/com/android/quickstep/views/FloatingTaskView.java b/quickstep/src/com/android/quickstep/views/FloatingTaskView.java index e2ffa18315..5a5e3da36a 100644 --- a/quickstep/src/com/android/quickstep/views/FloatingTaskView.java +++ b/quickstep/src/com/android/quickstep/views/FloatingTaskView.java @@ -74,6 +74,32 @@ public class FloatingTaskView extends FrameLayout { mSplitPlaceholderView.setBackgroundColor(getResources().getColor(android.R.color.white)); } + private void init(StatefulActivity launcher, TaskView originalView, RectF positionOut) { + mStartingPosition = positionOut; + updateInitialPositionForView(originalView); + final InsettableFrameLayout.LayoutParams lp = + (InsettableFrameLayout.LayoutParams) getLayoutParams(); + + mSplitPlaceholderView.setLayoutParams(new FrameLayout.LayoutParams(lp.width, lp.height)); + positionOut.round(mOutline); + setPivotX(0); + setPivotY(0); + + // Copy bounds of exiting thumbnail into ImageView + TaskThumbnailView thumbnail = originalView.getThumbnail(); + mImageView.setImageBitmap(thumbnail.getThumbnail()); + mImageView.setVisibility(VISIBLE); + + mOrientationHandler = originalView.getRecentsView().getPagedOrientationHandler(); + mSplitPlaceholderView.setIconView(originalView.getIconView(), + launcher.getDeviceProfile().overviewTaskIconDrawableSizePx); + mSplitPlaceholderView.getIconView().setRotation(mOrientationHandler.getDegreesRotated()); + } + + /** + * Configures and returns a an instance of {@link FloatingTaskView} initially matching the + * appearance of {@code originalView}. + */ public static FloatingTaskView getFloatingTaskView(StatefulActivity launcher, TaskView originalView, RectF positionOut) { final BaseDragLayer dragLayer = launcher.getDragLayer(); @@ -81,28 +107,7 @@ public class FloatingTaskView extends FrameLayout { final FloatingTaskView floatingView = (FloatingTaskView) launcher.getLayoutInflater() .inflate(R.layout.floating_split_select_view, parent, false); - floatingView.mStartingPosition = positionOut; - floatingView.updateInitialPositionForView(originalView); - final InsettableFrameLayout.LayoutParams lp = - (InsettableFrameLayout.LayoutParams) floatingView.getLayoutParams(); - - floatingView.mSplitPlaceholderView.setLayoutParams( - new FrameLayout.LayoutParams(lp.width, lp.height)); - positionOut.round(floatingView.mOutline); - floatingView.setPivotX(0); - floatingView.setPivotY(0); - - // Copy bounds of exiting thumbnail into ImageView - TaskThumbnailView thumbnail = originalView.getThumbnail(); - floatingView.mImageView.setImageBitmap(thumbnail.getThumbnail()); - floatingView.mImageView.setVisibility(VISIBLE); - - floatingView.mOrientationHandler = - originalView.getRecentsView().getPagedOrientationHandler(); - floatingView.mSplitPlaceholderView.setIconView(originalView.getIconView(), - launcher.getDeviceProfile().overviewTaskIconDrawableSizePx); - floatingView.mSplitPlaceholderView.getIconView() - .setRotation(floatingView.mOrientationHandler.getDegreesRotated()); + floatingView.init(launcher, originalView, positionOut); parent.addView(floatingView); return floatingView; }