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

Commit 2060a4b9 authored by Vinit Nayak's avatar Vinit Nayak
Browse files

Prevent showing TaskMenuView if icon isn't present

Also fixed another bug where the wrong layout
orientation was being applied when overview rotated
when launcher was in fixed portrait orientation.

Fixes: 160182914
Test: Tested w/ PIP, split screen,
w/o split screen w/ and w/o home rotation

Change-Id: Iccffb637ae5c22d07745f2108facd4de716dc8d3
parent c3c15cc9
Loading
Loading
Loading
Loading
+16 −4
Original line number Diff line number Diff line
@@ -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());
    }
+2 −1
Original line number Diff line number Diff line
@@ -237,7 +237,8 @@ public class LandscapePagedViewHandler implements PagedOrientationHandler {
    }

    @Override
    public int getTaskMenuLayoutOrientation(LinearLayout taskMenuLayout) {
    public int getTaskMenuLayoutOrientation(boolean canRecentsActivityRotate,
        LinearLayout taskMenuLayout) {
        return LinearLayout.HORIZONTAL;
    }

+1 −1
Original line number Diff line number Diff line
@@ -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);

    /**
+3 −2
Original line number Diff line number Diff line
@@ -236,8 +236,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