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

Commit 9ed6e045 authored by Selim Cinek's avatar Selim Cinek
Browse files

Important conversations now also transform into the shelf

Instead of always using the small icon, important conversations
now transform from the conversationIcon

Bug: 150905003
Test: add a few notification, observe nice transitions
Change-Id: Ia8c5121a6bd415ccca9d959d291665b8ac43b000
parent 79d9863e
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -145,6 +145,7 @@ public class ConversationLayout extends FrameLayout
    private int mFacePileAvatarSizeExpandedGroup;
    private int mFacePileProtectionWidth;
    private int mFacePileProtectionWidthExpanded;
    private boolean mImportantConversation;

    public ConversationLayout(@NonNull Context context) {
        super(context);
@@ -255,9 +256,14 @@ public class ConversationLayout extends FrameLayout
     */
    @RemotableViewMethod
    public void setIsImportantConversation(boolean isImportantConversation) {
        mImportantConversation = isImportantConversation;
        mImportanceRingView.setVisibility(isImportantConversation ? VISIBLE : GONE);
    }

    public boolean isImportantConversation() {
        return mImportantConversation;
    }

    /**
     * Set this layout to show the collapsed representation.
     *
+1 −1
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@
        >

            <!-- Big icon: 52x52, 12dp padding left + top, 16dp padding right -->
            <ImageView
            <com.android.internal.widget.CachingIconView
                android:id="@+id/conversation_icon"
                android:layout_width="@dimen/conversation_avatar_size"
                android:layout_height="@dimen/conversation_avatar_size"
+2 −0
Original line number Diff line number Diff line
@@ -49,6 +49,8 @@ public class Interpolators {
    public static final Interpolator CUSTOM_40_40 = new PathInterpolator(0.4f, 0f, 0.6f, 1f);
    public static final Interpolator HEADS_UP_APPEAR = new HeadsUpAppearInterpolator();
    public static final Interpolator ICON_OVERSHOT = new PathInterpolator(0.4f, 0f, 0.2f, 1.4f);
    public static final Interpolator ICON_OVERSHOT_LESS
            = new PathInterpolator(0.4f, 0f, 0.2f, 1.1f);
    public static final Interpolator PANEL_CLOSE_ACCELERATED
            = new PathInterpolator(0.3f, 0, 0.5f, 1);
    public static final Interpolator BOUNCE = new BounceInterpolator();
+16 −1
Original line number Diff line number Diff line
@@ -680,7 +680,8 @@ public class NotificationShelf extends ActivatableNotificationView implements
        }
        boolean forceInShelf =
                iconState.isLastExpandIcon && !iconState.hasCustomTransformHeight();
        float clampedAmount = iconTransitionAmount > 0.5f ? 1.0f : 0.0f;
        boolean clampInShelf = iconTransitionAmount > 0.5f || isTargetClipped(view);
        float clampedAmount = clampInShelf ? 1.0f : 0.0f;
        if (iconTransitionAmount == clampedAmount) {
            iconState.noAnimations = (scrollingFast || expandingAnimated) && !forceInShelf;
            iconState.useFullTransitionAmount = iconState.noAnimations
@@ -725,6 +726,20 @@ public class NotificationShelf extends ActivatableNotificationView implements
                clampedAmount != transitionAmount, isLastChild);
    }

    private boolean isTargetClipped(ExpandableView view) {
        View target = view.getShelfTransformationTarget();
        if (target == null) {
            return false;
        }
        // We should never clip the target, let's instead put it into the shelf!
        float endOfTarget = view.getTranslationY()
                + view.getContentTranslation()
                + view.getRelativeTopPadding(target)
                + target.getHeight();

        return endOfTarget >= getTranslationY() - mPaddingBetweenElements;
    }

    private void setIconTransformationAmount(ExpandableView view,
            float transitionAmount, float iconTransformDistance, boolean usingLinearInterpolation,
            boolean isLastChild) {
+15 −7
Original line number Diff line number Diff line
@@ -159,7 +159,7 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi
    private boolean mDismissed;
    private Runnable mOnDismissListener;
    private boolean mIncreasedSize;
    private boolean mTintIcons = true;
    private boolean mShowsConversation;

    public StatusBarIconView(Context context, String slot, StatusBarNotification sbn) {
        this(context, slot, sbn, false);
@@ -613,7 +613,7 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi
    }

    private void updateIconColor() {
        if (!mTintIcons) {
        if (mShowsConversation) {
            setColorFilter(null);
            return;
        }
@@ -964,18 +964,26 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi
    }

    /**
     * Sets whether the icon should be tinted. If the state differs from the supplied setting, this
     * Sets whether this icon shows a person and should be tinted.
     * If the state differs from the supplied setting, this
     * will update the icon colors.
     *
     * @param shouldTint Whether the icon should be tinted.
     * @param showsConversation Whether the icon shows a person
     */
    public void setTintIcons(boolean shouldTint) {
        if (mTintIcons != shouldTint) {
            mTintIcons = shouldTint;
    public void setShowsConversation(boolean showsConversation) {
        if (mShowsConversation != showsConversation) {
            mShowsConversation = showsConversation;
            updateIconColor();
        }
    }

    /**
     * @return if this icon shows a conversation
     */
    public boolean showsConversation() {
        return mShowsConversation;
    }

    public interface OnVisibilityChangedListener {
        void onVisibilityChanged(int newVisibility);
    }
Loading