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

Commit 5a1ca575 authored by Tony Wickham's avatar Tony Wickham
Browse files

Adjust some sizes in popup

- Increase main notification height and pad text/icon bottom
- Reduce shortcuts height when there are notifications to 48dp
  - When the last notification is dismissed, animate back to 56dp

Bug: 35766387
Change-Id: I84f843c042137fdf93fa720802eb2f19337197b4
parent 034d74da
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -30,7 +30,8 @@
        android:gravity="center_vertical"
        android:background="?attr/popupColorPrimary"
        android:paddingStart="@dimen/notification_padding_start"
        android:paddingEnd="@dimen/notification_main_text_padding_end">
        android:paddingEnd="@dimen/notification_main_text_padding_end"
        android:paddingBottom="16dp">
        <TextView
            android:id="@+id/title"
            android:layout_width="match_parent"
@@ -58,6 +59,7 @@
        android:layout_width="@dimen/notification_icon_size"
        android:layout_height="@dimen/notification_icon_size"
        android:layout_marginEnd="@dimen/notification_padding_end"
        android:layout_marginBottom="8dp"
        android:layout_gravity="center_vertical|end" />

</com.android.launcher3.notification.NotificationMainView>
+2 −1
Original line number Diff line number Diff line
@@ -155,6 +155,7 @@
    <dimen name="deep_shortcuts_elevation">9dp</dimen>
    <dimen name="bg_popup_item_width">220dp</dimen>
    <dimen name="bg_popup_item_height">56dp</dimen>
    <dimen name="bg_popup_item_condensed_height">48dp</dimen>
    <dimen name="pre_drag_view_scale">6dp</dimen>
    <!-- an icon with shortcuts must be dragged this far before the container is removed. -->
    <dimen name="deep_shortcuts_start_drag_threshold">16dp</dimen>
@@ -198,7 +199,7 @@
    <!-- notification_padding_end + (icon_size - footer_icon_size) / 2 -->
    <dimen name="notification_footer_icon_row_padding">15dp</dimen>
    <dimen name="notification_header_height">32dp</dimen>
    <dimen name="notification_main_height">80dp</dimen>
    <dimen name="notification_main_height">96dp</dimen>
    <dimen name="notification_footer_height">32dp</dimen>
    <dimen name="notification_header_text_size">13sp</dimen>
    <dimen name="notification_header_count_text_size">12sp</dimen>
+6 −0
Original line number Diff line number Diff line
@@ -306,6 +306,12 @@ public class PopupContainerWithArrow extends AbstractFloatingView implements Dra
                        shortcutsItemRoundedCorners &= ~ROUNDED_TOP_CORNERS;
                    }
                }
                if (itemTypeToPopulate != PopupPopulator.Item.SYSTEM_SHORTCUT_ICON
                        && numNotifications > 0) {
                    // Condense shortcuts height when there are notifications.
                    item.getLayoutParams().height = res.getDimensionPixelSize(
                            R.dimen.bg_popup_item_condensed_height);
                }
                mShortcutsItemView.addShortcutView(item, itemTypeToPopulate);
                if (shouldUnroundBottomCorners) {
                    shortcutsItemRoundedCorners &= ~ROUNDED_BOTTOM_CORNERS;
+41 −8
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.content.Context;
import android.graphics.Point;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
@@ -55,6 +56,8 @@ import java.util.List;
public class ShortcutsItemView extends PopupItemView implements View.OnLongClickListener,
        View.OnTouchListener, LogContainerProvider {

    private static final String TAG = "ShortcutsItem";

    private Launcher mLauncher;
    private LinearLayout mContent;
    private LinearLayout mShortcutsLayout;
@@ -183,14 +186,20 @@ public class ShortcutsItemView extends PopupItemView implements View.OnLongClick
    }

    /**
     * Hides shortcuts until only {@param maxShortcuts} are showing.
     * Hides shortcuts until only {@param maxShortcuts} are showing. Also sets
     * {@link #mHiddenShortcutsHeight} to be the amount of extra space that shortcuts will
     * require when {@link #showAllShortcuts(boolean)} is called.
     */
    public void hideShortcuts(boolean hideFromTop, int maxShortcuts) {
        // When shortcuts are shown, they get more space allocated to them.
        final int oldHeight = mShortcutsLayout.getChildAt(0).getLayoutParams().height;
        final int newHeight = getResources().getDimensionPixelSize(R.dimen.bg_popup_item_height);
        mHiddenShortcutsHeight = (newHeight - oldHeight) * mShortcutsLayout.getChildCount();

        int numToHide = mShortcutsLayout.getChildCount() - maxShortcuts;
        if (numToHide <= 0) {
            return;
        }
        mHiddenShortcutsHeight = 0;
        final int numShortcuts = mShortcutsLayout.getChildCount();
        final int dir = hideFromTop ? 1 : -1;
        for (int i = hideFromTop ? 0 : numShortcuts - 1; 0 <= i && i < numShortcuts; i += dir) {
@@ -224,8 +233,16 @@ public class ShortcutsItemView extends PopupItemView implements View.OnLongClick
    public Animator showAllShortcuts(boolean showFromTop) {
        // First set all the shortcuts to VISIBLE.
        final int numShortcuts = mShortcutsLayout.getChildCount();
        if (numShortcuts == 0) {
            Log.w(TAG, "Tried to show all shortcuts but there were no shortcuts to show");
            return null;
        }
        final int oldHeight = mShortcutsLayout.getChildAt(0).getLayoutParams().height;
        final int newHeight = getResources().getDimensionPixelSize(R.dimen.bg_popup_item_height);
        for (int i = 0; i < numShortcuts; i++) {
            DeepShortcutView view = (DeepShortcutView) mShortcutsLayout.getChildAt(i);
            view.getLayoutParams().height = newHeight;
            view.requestLayout();
            view.setVisibility(VISIBLE);
            if (i < numShortcuts - 1) {
                view.findViewById(R.id.divider).setVisibility(VISIBLE);
@@ -238,17 +255,13 @@ public class ShortcutsItemView extends PopupItemView implements View.OnLongClick
        if (showFromTop) {
            // The new shortcuts pushed the original shortcuts down, but we want to animate them
            // to that position. So we revert the translation and animate to the new.
            animation.play(ObjectAnimator.ofFloat(mShortcutsLayout, TRANSLATION_Y,
                    mShortcutsLayout.getTranslationY() - mHiddenShortcutsHeight,
                    mShortcutsLayout.getTranslationY()));
            animation.play(translateYFrom(mShortcutsLayout, -mHiddenShortcutsHeight));
        } else if (mSystemShortcutIcons != null) {
            // When adding the shortcuts from the bottom, things are a little trickier, since
            // that means they push the icons header down. To account for this, we do the same
            // translation trick as above, but on the header. Since this means leaving behind
            // a blank area where the header was, we also need to clip the background.
            animation.play(ObjectAnimator.ofFloat(mSystemShortcutIcons, TRANSLATION_Y,
                    mSystemShortcutIcons.getTranslationY() - mHiddenShortcutsHeight,
                    mSystemShortcutIcons.getTranslationY()));
            animation.play(translateYFrom(mSystemShortcutIcons, -mHiddenShortcutsHeight));
            // mPillRect is the bounds of this view before the new shortcuts were shown.
            Rect backgroundStartRect = new Rect(mPillRect);
            Rect backgroundEndRect = new Rect(mPillRect);
@@ -257,9 +270,29 @@ public class ShortcutsItemView extends PopupItemView implements View.OnLongClick
                    getBackgroundRadius(), backgroundStartRect, backgroundEndRect, mRoundedCorners)
                    .createRevealAnimator(this, false));
        }
        for (int i = 0; i < numShortcuts; i++) {
            // Animate each shortcut to its new height.
            DeepShortcutView shortcut = (DeepShortcutView) mShortcutsLayout.getChildAt(i);
            int heightDiff = newHeight - oldHeight;
            int heightAdjustmentIndex = showFromTop ? numShortcuts - i - 1 : i;
            int fromDir = showFromTop ? 1 : -1;
            animation.play(translateYFrom(shortcut, heightDiff * heightAdjustmentIndex * fromDir));
            // Make sure the text and icon stay centered in the shortcut.
            animation.play(translateYFrom(shortcut.getBubbleText(), heightDiff / 2 * fromDir));
            animation.play(translateYFrom(shortcut.getIconView(), heightDiff / 2 * fromDir));
        }
        return animation;
    }

    /**
     * Animates the translationY of the view from the given offset to the view's current translation
     * @return an Animator, which should be started by the caller.
     */
    private Animator translateYFrom(View v, int diff) {
        float finalY = v.getTranslationY();
        return ObjectAnimator.ofFloat(v, TRANSLATION_Y, finalY + diff, finalY);
    }

    /**
     * Adds a {@link SystemShortcut.Widgets} item if there are widgets for the given ItemInfo.
     */