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

Commit 12731af3 authored by Saumya Prakash's avatar Saumya Prakash
Browse files

Removed disabled overview actions at end of scroll

Updated visibility of the overview action bar so that when viewing
the clear all button at the end of the tasks it becomes hidden.
Previously, the overview actions were disabled so they were not
usable anyways. Updated the corresponding tests because expected
behavior was changed.

Test: Manual
Fix: 230508197
Change-Id: I64c91c682009808690d696032ffadefc86dfbac9
parent 5db9942c
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -99,6 +99,10 @@ public class ClearAllButton extends Button {
        return false;
    }

    public float getScrollAlpha() {
        return mScrollAlpha;
    }

    public void setContentAlpha(float alpha) {
        if (mContentAlpha != alpha) {
            mContentAlpha = alpha;
+7 −1
Original line number Diff line number Diff line
@@ -82,6 +82,8 @@ public class OverviewActionsView<T extends OverlayUICallbacks> extends FrameLayo
    private static final int INDEX_FULLSCREEN_ALPHA = 2;
    private static final int INDEX_HIDDEN_FLAGS_ALPHA = 3;
    private static final int INDEX_SHARE_TARGET_ALPHA = 4;
    private static final int INDEX_SCROLL_ALPHA = 5;
    private static final int NUM_ALPHAS = 6;

    public @interface SplitButtonHiddenFlags { }
    public static final int FLAG_IS_NOT_TABLET = 1 << 0;
@@ -126,7 +128,7 @@ public class OverviewActionsView<T extends OverlayUICallbacks> extends FrameLayo
    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
        mMultiValueAlpha = new MultiValueAlpha(findViewById(R.id.action_buttons), 5);
        mMultiValueAlpha = new MultiValueAlpha(findViewById(R.id.action_buttons), NUM_ALPHAS);
        mMultiValueAlpha.setUpdateVisibility(true);

        findViewById(R.id.action_screenshot).setOnClickListener(this);
@@ -247,6 +249,10 @@ public class OverviewActionsView<T extends OverlayUICallbacks> extends FrameLayo
        return mMultiValueAlpha.get(INDEX_SHARE_TARGET_ALPHA);
    }

    public MultiProperty getIndexScrollAlpha() {
        return mMultiValueAlpha.get(INDEX_SCROLL_ALPHA);
    }

    /**
     * Offsets OverviewActionsView horizontal position based on 3 button nav container in taskbar.
     */
+3 −0
Original line number Diff line number Diff line
@@ -1913,6 +1913,9 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
        }
        int scroll = mOrientationHandler.getPrimaryScroll(this);
        mClearAllButton.onRecentsViewScroll(scroll, mOverviewGridEnabled);

        // Clear all button alpha was set by the previous line.
        mActionsView.getIndexScrollAlpha().setValue(1 - mClearAllButton.getScrollAlpha());
    }

    @Override
+14 −18
Original line number Diff line number Diff line
@@ -244,42 +244,38 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer {
     * Returns if clear all button is visible.
     */
    public boolean isClearAllVisible() {
        return mLauncher.hasLauncherObject(mLauncher.getOverviewObjectSelector("clear_all"));
        return verifyActiveContainer().hasObject(
                mLauncher.getOverviewObjectSelector("clear_all"));
    }

    protected boolean isActionsViewVisible() {
        if (!hasTasks() || isClearAllVisible()) {
            return false;
        }
        OverviewTask task = mLauncher.isTablet() ? getFocusedTaskForTablet() : getCurrentTask();
        if (task == null) {
            return false;
        }
        // In tablets, if focused task is not in center, overview actions aren't visible.
        if (mLauncher.isTablet()
                && Math.abs(task.getExactCenterX() - mLauncher.getExactScreenCenterX()) >= 1) {
            return false;
        }
        // Overview actions aren't visible for split screen tasks.
        return !task.isTaskSplit();
    }

    private void verifyActionsViewVisibility() {
        if (!hasTasks() || !isActionsViewVisible()) {
            return;
        }
        try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
                "want to assert overview actions view visibility")) {
            if (mLauncher.isTablet() && !isOverviewSnappedToFocusedTaskForTablet()) {
                mLauncher.waitUntilOverviewObjectGone("action_buttons");
            } else {
            if (isActionsViewVisible()) {
                mLauncher.waitForOverviewObject("action_buttons");
            } else {
                mLauncher.waitUntilOverviewObjectGone("action_buttons");
            }
        }
    }

    /**
     * Returns if focused task is currently snapped task in tablet grid overview.
     */
    private boolean isOverviewSnappedToFocusedTaskForTablet() {
        OverviewTask focusedTask = getFocusedTaskForTablet();
        if (focusedTask == null) {
            return false;
        }
        return Math.abs(focusedTask.getExactCenterX() - mLauncher.getExactScreenCenterX()) < 1;
    }

    /**
     * Returns Overview focused task if it exists.
     *