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

Commit 39fbf0e1 authored by Charlie Anderson's avatar Charlie Anderson Committed by Android (Google) Code Review
Browse files

Merge "Prevents cropping of shortcuts in the app popup menu by limiting rows...

Merge "Prevents cropping of shortcuts in the app popup menu by limiting rows to available screen space." into udc-dev
parents 4c61c48d 471b8826
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -22,15 +22,12 @@
        android:id="@+id/bubble_text"
        android:background="?android:attr/selectableItemBackground"
        android:gravity="start|center_vertical"
        android:paddingTop="@dimen/bg_popup_item_vertical_padding"
        android:paddingBottom="@dimen/bg_popup_item_vertical_padding"
        android:minHeight="@dimen/bg_popup_item_height"
        android:textAlignment="viewStart"
        android:paddingStart="@dimen/deep_shortcuts_text_padding_start"
        android:paddingEnd="@dimen/popup_padding_end"
        android:textSize="14sp"
        android:minLines="1"
        android:maxLines="2"
        android:lines="1"
        android:ellipsize="end"
        android:hyphenationFrequency="full"
        android:textColor="@color/system_shortcut_text"
+4 −4
Original line number Diff line number Diff line
@@ -109,7 +109,7 @@ public abstract class ArrowPopup<T extends Context & ActivityContext>
    protected final int mArrowPointRadius;
    protected final View mArrow;

    private final int mMargin;
    protected final int mChildContainerMargin;

    protected boolean mIsLeftAligned;
    protected boolean mIsAboveIcon;
@@ -145,7 +145,7 @@ public abstract class ArrowPopup<T extends Context & ActivityContext>
        // Initialize arrow view
        final Resources resources = getResources();
        mArrowColor = getColorStateList(getContext(), R.color.popup_shade_first).getDefaultColor();
        mMargin = resources.getDimensionPixelSize(R.dimen.popup_margin);
        mChildContainerMargin = resources.getDimensionPixelSize(R.dimen.popup_margin);
        mArrowWidth = resources.getDimensionPixelSize(R.dimen.popup_arrow_width);
        mArrowHeight = resources.getDimensionPixelSize(R.dimen.popup_arrow_height);
        mArrow = new View(context);
@@ -249,7 +249,7 @@ public abstract class ArrowPopup<T extends Context & ActivityContext>
            if (view.getVisibility() == VISIBLE) {
                if (lastView != null) {
                    MarginLayoutParams mlp = (MarginLayoutParams) lastView.getLayoutParams();
                    mlp.bottomMargin = mMargin;
                    mlp.bottomMargin = mChildContainerMargin;
                }
                lastView = view;
                MarginLayoutParams mlp = (MarginLayoutParams) lastView.getLayoutParams();
@@ -441,7 +441,7 @@ public abstract class ArrowPopup<T extends Context & ActivityContext>
                numVisibleChildren++;
            }
        }
        int childMargins = (numVisibleChildren - 1) * mMargin;
        int childMargins = (numVisibleChildren - 1) * mChildContainerMargin;
        int height = getMeasuredHeight() + extraVerticalSpace + childMargins;
        int width = getMeasuredWidth() + getPaddingLeft() + getPaddingRight();

+14 −4
Original line number Diff line number Diff line
@@ -95,6 +95,8 @@ public class PopupContainerWithArrow<T extends Context & ActivityContext>

    private static final int SHORTCUT_COLLAPSE_THRESHOLD = 6;

    private final float mShortcutHeight;

    private BubbleTextView mOriginalIcon;
    private int mNumNotifications;
    private NotificationContainer mNotificationContainer;
@@ -112,6 +114,7 @@ public class PopupContainerWithArrow<T extends Context & ActivityContext>
        mStartDragThreshold = getResources().getDimensionPixelSize(
                R.dimen.deep_shortcuts_start_drag_threshold);
        mContainerWidth = getResources().getDimensionPixelSize(R.dimen.bg_popup_item_width);
        mShortcutHeight = getResources().getDimension(R.dimen.system_shortcut_header_height);
    }

    public PopupContainerWithArrow(Context context, AttributeSet attrs) {
@@ -387,16 +390,18 @@ public class PopupContainerWithArrow<T extends Context & ActivityContext>
     */
    private void addAllShortcutsMaterialU(int deepShortcutCount,
            List<SystemShortcut> systemShortcuts) {

        if (deepShortcutCount + systemShortcuts.size() <= SHORTCUT_COLLAPSE_THRESHOLD) {
            // add all system shortcuts including widgets shortcut to same container
            addSystemShortcutsMaterialU(systemShortcuts,
                    R.layout.system_shortcut_rows_container_material_u,
                    R.layout.system_shortcut);
            addDeepShortcutsMaterialU(deepShortcutCount);
            float currentHeight = (mShortcutHeight * systemShortcuts.size())
                    + mChildContainerMargin;
            addDeepShortcutsMaterialU(deepShortcutCount, currentHeight);
            return;
        }

        float currentHeight = mShortcutHeight + mChildContainerMargin;
        List<SystemShortcut> nonWidgetSystemShortcuts =
                getNonWidgetSystemShortcuts(systemShortcuts);
        // If total shortcuts over threshold, collapse system shortcuts to single row
@@ -411,8 +416,9 @@ public class PopupContainerWithArrow<T extends Context & ActivityContext>
            mWidgetContainer = inflateAndAdd(R.layout.widget_shortcut_container_material_u,
                    this);
            initializeWidgetShortcut(mWidgetContainer, widgetShortcutOpt.get());
            currentHeight += mShortcutHeight + mChildContainerMargin;
        }
        addDeepShortcutsMaterialU(deepShortcutCount);
        addDeepShortcutsMaterialU(deepShortcutCount, currentHeight);
    }

    /**
@@ -497,10 +503,14 @@ public class PopupContainerWithArrow<T extends Context & ActivityContext>
    /**
     * Inflates and adds [deepShortcutCount] number of DeepShortcutView for the  to a new container
     * @param deepShortcutCount number of DeepShortcutView instances to add
     * @param currentHeight height of popup before adding deep shortcuts
     */
    private void addDeepShortcutsMaterialU(int deepShortcutCount) {
    private void addDeepShortcutsMaterialU(int deepShortcutCount, float currentHeight) {
        mDeepShortcutContainer = inflateAndAdd(R.layout.deep_shortcut_container, this);
        for (int i = deepShortcutCount; i > 0; i--) {
            currentHeight += mShortcutHeight;
            // when there is limited vertical screen space, limit total popup rows to fit
            if (currentHeight >= mActivityContext.getDeviceProfile().availableHeightPx) break;
            DeepShortcutView v = inflateAndAdd(R.layout.deep_shortcut_material_u,
                    mDeepShortcutContainer);
            v.getLayoutParams().width = mContainerWidth;
+6 −16
Original line number Diff line number Diff line
@@ -51,7 +51,6 @@ import com.android.launcher3.tapl.Folder;
import com.android.launcher3.tapl.FolderIcon;
import com.android.launcher3.tapl.HomeAllApps;
import com.android.launcher3.tapl.HomeAppIcon;
import com.android.launcher3.tapl.HomeAppIconMenu;
import com.android.launcher3.tapl.HomeAppIconMenuItem;
import com.android.launcher3.tapl.Widgets;
import com.android.launcher3.tapl.Workspace;
@@ -391,23 +390,14 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest {
                .switchToAllApps();
        allApps.freeze();
        try {
            final HomeAppIconMenu menu = allApps
            final HomeAppIconMenuItem menuItem = allApps
                    .getAppIcon(APP_NAME)
                    .openDeepShortcutMenu();
            final HomeAppIconMenuItem menuItem0 = menu.getMenuItem(0);
            final HomeAppIconMenuItem menuItem2 = menu.getMenuItem(2);

            final HomeAppIconMenuItem menuItem;

            final String expectedShortcutName = "Shortcut 3";
            if (menuItem0.getText().equals(expectedShortcutName)) {
                menuItem = menuItem0;
            } else {
                final String shortcutName2 = menuItem2.getText();
                assertEquals("Wrong menu item", expectedShortcutName, shortcutName2);
                menuItem = menuItem2;
            }
                    .openDeepShortcutMenu()
                    .getMenuItem(0);
            final String actualShortcutName = menuItem.getText();
            final String expectedShortcutName = "Shortcut 1";

            assertEquals(expectedShortcutName, actualShortcutName);
            menuItem.dragToWorkspace(false, false);
            mLauncher.getWorkspace().getWorkspaceAppIcon(expectedShortcutName)
                    .launch(getAppPackageName());