diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskMenuView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskMenuView.java index ef66b7a396..8b49f2c212 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskMenuView.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskMenuView.java @@ -169,7 +169,9 @@ public class TaskMenuView extends AbstractFloatingView { } if (mIsOpen) { mOptionLayout.removeAllViews(); - populateAndLayoutMenu(); + if (!populateAndLayoutMenu()) { + close(false); + } } } @@ -186,14 +188,22 @@ public class TaskMenuView extends AbstractFloatingView { } mActivity.getDragLayer().addView(this); mTaskView = taskView; - populateAndLayoutMenu(); + if (!populateAndLayoutMenu()) { + return false; + } post(this::animateOpen); return true; } - private void populateAndLayoutMenu() { + /** @return true if successfully able to populate task view menu, false otherwise */ + private boolean populateAndLayoutMenu() { + if (mTaskView.getTask().icon == null) { + // Icon may not be loaded + return false; + } addMenuOptions(mTaskView); orientAroundTaskView(mTaskView); + return true; } private void addMenuOptions(TaskView taskView) { @@ -240,8 +250,10 @@ public class TaskMenuView extends AbstractFloatingView { setLayoutParams(params); setScaleX(taskView.getScaleX()); setScaleY(taskView.getScaleY()); + boolean canActivityRotate = taskView.getRecentsView() + .mOrientationState.canRecentsActivityRotate(); mOptionLayout.setOrientation(orientationHandler - .getTaskMenuLayoutOrientation(mOptionLayout)); + .getTaskMenuLayoutOrientation(canActivityRotate, mOptionLayout)); setPosition(sTempRect.left - insets.left, sTempRect.top - insets.top, taskView.getPagedOrientationHandler()); } diff --git a/src/com/android/launcher3/touch/LandscapePagedViewHandler.java b/src/com/android/launcher3/touch/LandscapePagedViewHandler.java index c2bfb167a2..ac1ade260d 100644 --- a/src/com/android/launcher3/touch/LandscapePagedViewHandler.java +++ b/src/com/android/launcher3/touch/LandscapePagedViewHandler.java @@ -239,7 +239,8 @@ public class LandscapePagedViewHandler implements PagedOrientationHandler { } @Override - public int getTaskMenuLayoutOrientation(LinearLayout taskMenuLayout) { + public int getTaskMenuLayoutOrientation(boolean canRecentsActivityRotate, + LinearLayout taskMenuLayout) { return LinearLayout.HORIZONTAL; } diff --git a/src/com/android/launcher3/touch/PagedOrientationHandler.java b/src/com/android/launcher3/touch/PagedOrientationHandler.java index b650526fe1..d4f5cba40e 100644 --- a/src/com/android/launcher3/touch/PagedOrientationHandler.java +++ b/src/com/android/launcher3/touch/PagedOrientationHandler.java @@ -94,7 +94,7 @@ public interface PagedOrientationHandler { float getTaskMenuX(float x, View thumbnailView); float getTaskMenuY(float y, View thumbnailView); int getTaskMenuWidth(View view); - int getTaskMenuLayoutOrientation(LinearLayout taskMenuLayout); + int getTaskMenuLayoutOrientation(boolean canRecentsActivityRotate, LinearLayout taskMenuLayout); void setLayoutParamsForTaskMenuOptionItem(LinearLayout.LayoutParams lp); int getDistanceToBottomOfRect(DeviceProfile dp, Rect rect); diff --git a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java index e87c887d33..3341996383 100644 --- a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java +++ b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java @@ -237,8 +237,9 @@ public class PortraitPagedViewHandler implements PagedOrientationHandler { } @Override - public int getTaskMenuLayoutOrientation(LinearLayout taskMenuLayout) { - return taskMenuLayout.getOrientation(); + public int getTaskMenuLayoutOrientation(boolean canRecentsActivityRotate, + LinearLayout taskMenuLayout) { + return canRecentsActivityRotate ? taskMenuLayout.getOrientation() : LinearLayout.VERTICAL; } @Override