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

Commit 7d0edb46 authored by Alex Chau's avatar Alex Chau
Browse files

Reland "Update Split button visibility based on DeviceProfile change"

This reverts commit 38bc885d.

- Always request layout of action_buttons after changing visibility of its children
- Update Split button visibility based on DeviceProfile change in updateDimension() only
- Update Split button visibility based on 3P launcher in initialization only
- Also simplified action_buttons to wrap_content and layout in middle of parent
- Also removed the space between buttons and use marginStart
- Fixed TAPL to not expect save app pair button on phone. Before this CL actions_buttons are still on view hierarchy despite they're not visible on screen.

Fix: 321291049
Fix: 329255757
Test: Clear all tasks, fold, launch app, swipe up to Overivew; repeat in RTL
Test: OverviewImageTest
Flag: None
Change-Id: I9ecf872279f6f07d2d9bc33fb09031568023cb77
parent 75e48fc0
Loading
Loading
Loading
Loading
+3 −9
Original line number Diff line number Diff line
@@ -21,10 +21,9 @@

    <LinearLayout
        android:id="@+id/action_buttons"
        android:layout_width="match_parent"
        android:layout_width="wrap_content"
        android:layout_height="@dimen/overview_actions_height"
        android:layout_gravity="bottom"
        android:gravity="center_horizontal"
        android:layout_gravity="bottom|center_horizontal"
        android:orientation="horizontal">

        <Button
@@ -36,17 +35,12 @@
            android:text="@string/action_screenshot"
            android:theme="@style/ThemeControlHighlightWorkspaceColor" />

        <Space
            android:id="@+id/action_split_space"
            android:layout_width="@dimen/overview_actions_button_spacing"
            android:layout_height="1dp"
            android:visibility="gone" />

        <Button
            android:id="@+id/action_split"
            style="@style/OverviewActionButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="@dimen/overview_actions_button_spacing"
            android:text="@string/action_split"
            android:theme="@style/ThemeControlHighlightWorkspaceColor"
            android:visibility="gone" />
+23 −12
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.LinearLayout;

import androidx.annotation.IntDef;
import androidx.annotation.Nullable;
@@ -107,6 +108,7 @@ public class OverviewActionsView<T extends OverlayUICallbacks> extends FrameLayo

    private MultiValueAlpha mMultiValueAlpha;

    protected LinearLayout mActionButtons;
    // The screenshot button is implemented as a Button in launcher3 and NexusLauncher, but is an
    // ImageButton in go launcher (does not share a common class with Button). Take care when
    // casting this.
@@ -151,7 +153,8 @@ public class OverviewActionsView<T extends OverlayUICallbacks> extends FrameLayo
    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
        mMultiValueAlpha = new MultiValueAlpha(findViewById(R.id.action_buttons), NUM_ALPHAS);
        mActionButtons = findViewById(R.id.action_buttons);
        mMultiValueAlpha = new MultiValueAlpha(mActionButtons, NUM_ALPHAS);
        mMultiValueAlpha.setUpdateVisibility(true);

        mScreenshotButton = findViewById(R.id.action_screenshot);
@@ -243,13 +246,13 @@ public class OverviewActionsView<T extends OverlayUICallbacks> extends FrameLayo

    /**
     * Updates a batch of flags to hide and show actions buttons for tablet/non tablet case.
     * @param isSmallScreen True if the current display is a small screen.
     */
    public void updateForSmallScreen(boolean isSmallScreen) {
    private void updateForIsTablet() {
        assert mDp != null;
        // Update flags to see if split button should be hidden.
        updateSplitButtonHiddenFlags(FLAG_SMALL_SCREEN_HIDE_SPLIT, isSmallScreen);
        updateSplitButtonHiddenFlags(FLAG_SMALL_SCREEN_HIDE_SPLIT, !mDp.isTablet);
        // Update flags to see if save app pair button should be hidden.
        updateAppPairButtonHiddenFlags(FLAG_SMALL_SCREEN_HIDE_APP_PAIR, isSmallScreen);
        updateAppPairButtonHiddenFlags(FLAG_SMALL_SCREEN_HIDE_APP_PAIR, !mDp.isTablet);
    }

    /**
@@ -274,7 +277,10 @@ public class OverviewActionsView<T extends OverlayUICallbacks> extends FrameLayo
            mScreenshotButtonHiddenFlags &= ~flag;
        }
        int desiredVisibility = mScreenshotButtonHiddenFlags == 0 ? VISIBLE : GONE;
        if (mScreenshotButton.getVisibility() != desiredVisibility) {
            mScreenshotButton.setVisibility(desiredVisibility);
            mActionButtons.requestLayout();
        }
    }

    /**
@@ -292,8 +298,10 @@ public class OverviewActionsView<T extends OverlayUICallbacks> extends FrameLayo
            mSplitButtonHiddenFlags &= ~flag;
        }
        int desiredVisibility = mSplitButtonHiddenFlags == 0 ? VISIBLE : GONE;
        if (mSplitButton.getVisibility() != desiredVisibility) {
            mSplitButton.setVisibility(desiredVisibility);
        findViewById(R.id.action_split_space).setVisibility(desiredVisibility);
            mActionButtons.requestLayout();
        }
    }

    /**
@@ -315,7 +323,10 @@ public class OverviewActionsView<T extends OverlayUICallbacks> extends FrameLayo
            mAppPairButtonHiddenFlags &= ~flag;
        }
        int desiredVisibility = mAppPairButtonHiddenFlags == 0 ? VISIBLE : GONE;
        if (mSaveAppPairButton.getVisibility() != desiredVisibility) {
            mSaveAppPairButton.setVisibility(desiredVisibility);
            mActionButtons.requestLayout();
        }
    }

    public MultiProperty getContentAlpha() {
@@ -342,7 +353,7 @@ public class OverviewActionsView<T extends OverlayUICallbacks> extends FrameLayo
     * Returns the visibility of the overview actions buttons.
     */
    public @Visibility int getActionsButtonVisibility() {
        return findViewById(R.id.action_buttons).getVisibility();
        return mActionButtons.getVisibility();
    }

    /**
@@ -358,8 +369,7 @@ public class OverviewActionsView<T extends OverlayUICallbacks> extends FrameLayo
        if (mDp == null) {
            return;
        }
        LayoutParams actionParams = (LayoutParams) findViewById(
                R.id.action_buttons).getLayoutParams();
        LayoutParams actionParams = (LayoutParams) mActionButtons.getLayoutParams();
        actionParams.setMargins(
                actionParams.leftMargin, mDp.overviewActionsTopMarginPx,
                actionParams.rightMargin, getBottomMargin());
@@ -386,6 +396,7 @@ public class OverviewActionsView<T extends OverlayUICallbacks> extends FrameLayo
        mDp = dp;
        mTaskSize.set(taskSize);
        updateVerticalMargin(DisplayController.getNavigationMode(getContext()));
        updateForIsTablet();

        requestLayout();

+2 −4
Original line number Diff line number Diff line
@@ -1061,6 +1061,8 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
            @Nullable DesktopRecentsTransitionController desktopRecentsTransitionController) {
        mActionsView = actionsView;
        mActionsView.updateHiddenFlags(HIDDEN_NO_TASKS, getTaskViewCount() == 0);
        // Update flags for 1p/3p launchers
        mActionsView.updateFor3pLauncher(!supportsAppPairs());
        mSplitSelectStateController = splitController;
        mDesktopRecentsTransitionController = desktopRecentsTransitionController;
    }
@@ -3962,10 +3964,6 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
        // Update flags to see if actions bar should show buttons for a single task or a pair of
        // tasks.
        mActionsView.updateForGroupedTask(isCurrentSplit);
        // Update flags to see if actions bar should show buttons for tablets or phones.
        mActionsView.updateForSmallScreen(!mActivity.getDeviceProfile().isTablet);
        // Update flags for 1p/3p launchers
        mActionsView.updateFor3pLauncher(!supportsAppPairs());

        if (enableDesktopWindowingMode()) {
            boolean isCurrentDesktop = getCurrentPageTaskView() instanceof DesktopTaskView;
+3 −2
Original line number Diff line number Diff line
@@ -398,8 +398,9 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer {
        if (isTablet && Math.abs(task.getExactCenterX() - mLauncher.getExactScreenCenterX()) >= 1) {
            return false;
        }
        if (!mLauncher.isAppPairsEnabled() && task.isTaskSplit()) {
            // Overview actions aren't visible for split screen tasks.
        if (task.isTaskSplit() && (!mLauncher.isAppPairsEnabled() || !isTablet)) {
            // Overview actions aren't visible for split screen tasks, except for save app pair
            // button on tablets.
            return false;
        }
        return true;