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

Commit 11c1e118 authored by Tony Wickham's avatar Tony Wickham Committed by android-build-merger
Browse files

Merge "Remove first icon from notification footer after it animates." into ub-launcher3-dorval

am: 1cabfa1d

Change-Id: I5b11c85440bc6261be4f802abaf0adedca726bd1
parents 1bba8686 1cabfa1d
Loading
Loading
Loading
Loading
+41 −34
Original line number Original line Diff line number Diff line
@@ -61,6 +61,7 @@ public class NotificationFooterLayout extends LinearLayout {
    private LinearLayout mIconRow;
    private LinearLayout mIconRow;
    private int mBackgroundColor;
    private int mBackgroundColor;
    private int mTextColor;
    private int mTextColor;
    private TextView mOverflowView;


    public NotificationFooterLayout(Context context) {
    public NotificationFooterLayout(Context context) {
        this(context, null, 0);
        this(context, null, 0);
@@ -120,10 +121,10 @@ public class NotificationFooterLayout extends LinearLayout {
        }
        }


        if (!mOverflowNotifications.isEmpty()) {
        if (!mOverflowNotifications.isEmpty()) {
            TextView overflowText = new TextView(getContext());
            mOverflowView = new TextView(getContext());
            overflowText.setTextColor(mTextColor);
            mOverflowView.setTextColor(mTextColor);
            updateOverflowText(overflowText);
            updateOverflowText();
            mIconRow.addView(overflowText, mIconLayoutParams);
            mIconRow.addView(mOverflowView, mIconLayoutParams);
        }
        }
    }
    }


@@ -142,8 +143,8 @@ public class NotificationFooterLayout extends LinearLayout {
        mIconRow.addView(icon, addIndex, mIconLayoutParams);
        mIconRow.addView(icon, addIndex, mIconLayoutParams);
    }
    }


    private void updateOverflowText(TextView overflowTextView) {
    private void updateOverflowText() {
        overflowTextView.setText(getResources().getString(R.string.deep_notifications_overflow,
        mOverflowView.setText(getResources().getString(R.string.deep_notifications_overflow,
                mOverflowNotifications.size()));
                mOverflowNotifications.size()));
    }
    }


@@ -162,6 +163,7 @@ public class NotificationFooterLayout extends LinearLayout {
            @Override
            @Override
            public void onAnimationEnd(Animator animation) {
            public void onAnimationEnd(Animator animation) {
                callback.onIconAnimationEnd((NotificationInfo) firstNotification.getTag());
                callback.onIconAnimationEnd((NotificationInfo) firstNotification.getTag());
                removeViewFromIconRow(firstNotification);
            }
            }
        });
        });
        animation.play(moveAndScaleIcon);
        animation.play(moveAndScaleIcon);
@@ -178,7 +180,6 @@ public class NotificationFooterLayout extends LinearLayout {
                public void onAnimationEnd(Animator animation) {
                public void onAnimationEnd(Animator animation) {
                    // We have to set the translation X to 0 when the new main notification
                    // We have to set the translation X to 0 when the new main notification
                    // is removed from the footer.
                    // is removed from the footer.
                    // TODO: remove it here instead of expecting trimNotifications to do so.
                    child.setTranslationX(0);
                    child.setTranslationX(0);
                }
                }
            });
            });
@@ -187,39 +188,20 @@ public class NotificationFooterLayout extends LinearLayout {
        animation.start();
        animation.start();
    }
    }


    public void trimNotifications(List<String> notifications) {
    private void removeViewFromIconRow(View child) {
        if (!isAttachedToWindow() || mIconRow.getChildCount() == 0) {
            return;
        }
        Iterator<NotificationInfo> overflowIterator = mOverflowNotifications.iterator();
        while (overflowIterator.hasNext()) {
            if (!notifications.contains(overflowIterator.next().notificationKey)) {
                overflowIterator.remove();
            }
        }
        TextView overflowView = null;
        for (int i = mIconRow.getChildCount() - 1; i >= 0; i--) {
            View child = mIconRow.getChildAt(i);
            if (child instanceof TextView) {
                overflowView = (TextView) child;
            } else {
                NotificationInfo childInfo = (NotificationInfo) child.getTag();
                if (!notifications.contains(childInfo.notificationKey)) {
        mIconRow.removeView(child);
        mIconRow.removeView(child);
                    mNotifications.remove(childInfo);
        mNotifications.remove((NotificationInfo) child.getTag());
        if (!mOverflowNotifications.isEmpty()) {
        if (!mOverflowNotifications.isEmpty()) {
            NotificationInfo notification = mOverflowNotifications.remove(0);
            NotificationInfo notification = mOverflowNotifications.remove(0);
            mNotifications.add(notification);
            mNotifications.add(notification);
            addNotificationIconForInfo(notification, true /* fromOverflow */);
            addNotificationIconForInfo(notification, true /* fromOverflow */);
        }
        }
                }
        if (mOverflowView != null) {
            }
        }
        if (overflowView != null) {
            if (mOverflowNotifications.isEmpty()) {
            if (mOverflowNotifications.isEmpty()) {
                mIconRow.removeView(overflowView);
                mIconRow.removeView(mOverflowView);
                mOverflowView = null;
            } else {
            } else {
                updateOverflowText(overflowView);
                updateOverflowText();
            }
            }
        }
        }
        if (mIconRow.getChildCount() == 0) {
        if (mIconRow.getChildCount() == 0) {
@@ -229,11 +211,36 @@ public class NotificationFooterLayout extends LinearLayout {
            int newHeight = getResources().getDimensionPixelSize(
            int newHeight = getResources().getDimensionPixelSize(
                    R.dimen.notification_footer_collapsed_height);
                    R.dimen.notification_footer_collapsed_height);
            AnimatorSet collapseSecondary = LauncherAnimUtils.createAnimatorSet();
            AnimatorSet collapseSecondary = LauncherAnimUtils.createAnimatorSet();
            collapseSecondary.play(popup.animateTranslationYBy(getHeight() - newHeight,
            collapseSecondary.play(popup.animateTranslationYBy(getHeight() - newHeight, 0));
                    getResources().getInteger(R.integer.config_removeNotificationViewDuration)));
            collapseSecondary.play(LauncherAnimUtils.animateViewHeight(
            collapseSecondary.play(LauncherAnimUtils.animateViewHeight(
                    this, getHeight(), newHeight));
                    this, getHeight(), newHeight));
            collapseSecondary.setDuration(getResources().getInteger(
                    R.integer.config_removeNotificationViewDuration));
            collapseSecondary.start();
            collapseSecondary.start();
        }
        }
    }
    }

    public void trimNotifications(List<String> notifications) {
        if (!isAttachedToWindow() || mIconRow.getChildCount() == 0) {
            return;
        }
        Iterator<NotificationInfo> overflowIterator = mOverflowNotifications.iterator();
        while (overflowIterator.hasNext()) {
            if (!notifications.contains(overflowIterator.next().notificationKey)) {
                overflowIterator.remove();
            }
        }
        TextView overflowView = null;
        for (int i = mIconRow.getChildCount() - 1; i >= 0; i--) {
            View child = mIconRow.getChildAt(i);
            if (child instanceof TextView) {
                overflowView = (TextView) child;
            } else {
                NotificationInfo childInfo = (NotificationInfo) child.getTag();
                if (!notifications.contains(childInfo.notificationKey)) {
                    removeViewFromIconRow(child);
                }
            }
        }
    }
}
}
+0 −7
Original line number Original line Diff line number Diff line
@@ -37,7 +37,6 @@ import com.android.launcher3.logging.UserEventDispatcher.LogContainerProvider;
import com.android.launcher3.popup.PopupItemView;
import com.android.launcher3.popup.PopupItemView;
import com.android.launcher3.userevent.nano.LauncherLogProto;
import com.android.launcher3.userevent.nano.LauncherLogProto;


import java.util.ArrayList;
import java.util.List;
import java.util.List;


import static com.android.launcher3.LauncherAnimUtils.animateViewHeight;
import static com.android.launcher3.LauncherAnimUtils.animateViewHeight;
@@ -145,12 +144,6 @@ public class NotificationItemView extends PopupItemView implements LogContainerP
                public void onIconAnimationEnd(NotificationInfo newMainNotification) {
                public void onIconAnimationEnd(NotificationInfo newMainNotification) {
                    if (newMainNotification != null) {
                    if (newMainNotification != null) {
                        mMainView.applyNotificationInfo(newMainNotification, mIconView, true);
                        mMainView.applyNotificationInfo(newMainNotification, mIconView, true);
                        // Remove the animated notification from the footer by calling trim
                        // TODO: Remove the notification in NotificationFooterLayout directly
                        // instead of relying on this hack.
                        List<String> footerNotificationKeys = new ArrayList<>(notificationKeys);
                        footerNotificationKeys.remove(newMainNotification.notificationKey);
                        mFooter.trimNotifications(footerNotificationKeys);
                        mMainView.setVisibility(VISIBLE);
                        mMainView.setVisibility(VISIBLE);
                    }
                    }
                    mAnimatingNextIcon = false;
                    mAnimatingNextIcon = false;