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

Commit df537d24 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Reland "Update Split button visibility based on DeviceProfile change"" into 24D1-dev

parents 05bb8f39 ddb12d7a
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
@@ -1062,6 +1062,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;
    }
@@ -4020,10 +4022,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 (isDesktopModeSupported()) {
            boolean isCurrentDesktop = getCurrentPageTaskView() instanceof DesktopTaskView;
+3 −2
Original line number Diff line number Diff line
@@ -401,8 +401,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;