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

Commit 8a2a5fa0 authored by Jorim Jaggi's avatar Jorim Jaggi Committed by Android (Google) Code Review
Browse files

Merge "Introduce AmbientState for StackScroller."

parents 607562a7 d552d9d8
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -18,11 +18,13 @@
<resources>
<resources>
    <item type="id" name="translation_y_animator_tag"/>
    <item type="id" name="translation_y_animator_tag"/>
    <item type="id" name="translation_z_animator_tag"/>
    <item type="id" name="translation_z_animator_tag"/>
    <item type="id" name="scale_animator_tag"/>
    <item type="id" name="alpha_animator_tag"/>
    <item type="id" name="alpha_animator_tag"/>
    <item type="id" name="top_inset_animator_tag"/>
    <item type="id" name="top_inset_animator_tag"/>
    <item type="id" name="height_animator_tag"/>
    <item type="id" name="height_animator_tag"/>
    <item type="id" name="translation_y_animator_end_value_tag"/>
    <item type="id" name="translation_y_animator_end_value_tag"/>
    <item type="id" name="translation_z_animator_end_value_tag"/>
    <item type="id" name="translation_z_animator_end_value_tag"/>
    <item type="id" name="scale_animator_end_value_tag"/>
    <item type="id" name="alpha_animator_end_value_tag"/>
    <item type="id" name="alpha_animator_end_value_tag"/>
    <item type="id" name="top_inset_animator_end_value_tag"/>
    <item type="id" name="top_inset_animator_end_value_tag"/>
    <item type="id" name="height_animator_end_value_tag"/>
    <item type="id" name="height_animator_end_value_tag"/>
+6 −11
Original line number Original line Diff line number Diff line
@@ -38,6 +38,7 @@ import com.android.internal.R;
public abstract class ActivatableNotificationView extends ExpandableOutlineView {
public abstract class ActivatableNotificationView extends ExpandableOutlineView {


    private static final long DOUBLETAP_TIMEOUT_MS = 1000;
    private static final long DOUBLETAP_TIMEOUT_MS = 1000;
    private static final int BACKGROUND_ANIMATION_LENGTH_MS = 220;


    private boolean mDimmed;
    private boolean mDimmed;


@@ -179,7 +180,7 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
            mActivated = false;
            mActivated = false;
        }
        }
        if (mOnActivatedListener != null) {
        if (mOnActivatedListener != null) {
            mOnActivatedListener.onReset(this);
            mOnActivatedListener.onActivationReset(this);
        }
        }
        removeCallbacks(mTapTimeoutRunnable);
        removeCallbacks(mTapTimeoutRunnable);
    }
    }
@@ -189,12 +190,6 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
                && Math.abs(event.getY() - mDownY) < mTouchSlop;
                && Math.abs(event.getY() - mDownY) < mTouchSlop;
    }
    }


    /**
     * Sets the notification as dimmed, meaning that it will appear in a more gray variant.
     *
     * @param dimmed Whether the notification should be dimmed.
     * @param fade Whether an animation should be played to change the state.
     */
    public void setDimmed(boolean dimmed, boolean fade) {
    public void setDimmed(boolean dimmed, boolean fade) {
        if (mDimmed != dimmed) {
        if (mDimmed != dimmed) {
            mDimmed = dimmed;
            mDimmed = dimmed;
@@ -226,7 +221,7 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
        }
        }
        int startAlpha = mDimmed ? 255 : 0;
        int startAlpha = mDimmed ? 255 : 0;
        int endAlpha = mDimmed ? 0 : 255;
        int endAlpha = mDimmed ? 0 : 255;
        int duration = NotificationActivator.ANIMATION_LENGTH_MS;
        int duration = BACKGROUND_ANIMATION_LENGTH_MS;
        // Check whether there is already a background animation running.
        // Check whether there is already a background animation running.
        if (mBackgroundAnimator != null) {
        if (mBackgroundAnimator != null) {
            startAlpha = (Integer) mBackgroundAnimator.getAnimatedValue();
            startAlpha = (Integer) mBackgroundAnimator.getAnimatedValue();
@@ -313,8 +308,8 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
    }
    }


    @Override
    @Override
    public void setActualHeight(int actualHeight) {
    public void setActualHeight(int actualHeight, boolean notifyListeners) {
        super.setActualHeight(actualHeight);
        super.setActualHeight(actualHeight, notifyListeners);
        invalidate();
        invalidate();
        setPivotY(actualHeight / 2);
        setPivotY(actualHeight / 2);
    }
    }
@@ -331,6 +326,6 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView


    public interface OnActivatedListener {
    public interface OnActivatedListener {
        void onActivated(View view);
        void onActivated(View view);
        void onReset(View view);
        void onActivationReset(View view);
    }
    }
}
}
+0 −38
Original line number Original line Diff line number Diff line
@@ -1067,7 +1067,6 @@ public abstract class BaseStatusBar extends SystemUI implements
                    entry.row.setSystemExpanded(top);
                    entry.row.setSystemExpanded(top);
                }
                }
            }
            }
            entry.row.setDimmed(onKeyguard, false /* fade */);
            boolean showOnKeyguard = shouldShowOnKeyguard(entry.notification);
            boolean showOnKeyguard = shouldShowOnKeyguard(entry.notification);
            if (onKeyguard && (visibleNotifications >= maxKeyguardNotifications
            if (onKeyguard && (visibleNotifications >= maxKeyguardNotifications
                    || !showOnKeyguard)) {
                    || !showOnKeyguard)) {
@@ -1087,48 +1086,11 @@ public abstract class BaseStatusBar extends SystemUI implements


        if (onKeyguard && mKeyguardIconOverflowContainer.getIconsView().getChildCount() > 0) {
        if (onKeyguard && mKeyguardIconOverflowContainer.getIconsView().getChildCount() > 0) {
            mKeyguardIconOverflowContainer.setVisibility(View.VISIBLE);
            mKeyguardIconOverflowContainer.setVisibility(View.VISIBLE);
            mKeyguardIconOverflowContainer.setDimmed(true /* dimmed */, false /* fade */);
        } else {
        } else {
            mKeyguardIconOverflowContainer.setVisibility(View.GONE);
            mKeyguardIconOverflowContainer.setVisibility(View.GONE);
        }
        }
    }
    }


    @Override
    public void onActivated(View view) {
        int n = mNotificationData.size();
        for (int i = 0; i < n; i++) {
            NotificationData.Entry entry = mNotificationData.get(i);
            if (entry.row.getVisibility() != View.GONE) {
                if (view == entry.row) {
                    entry.row.getActivator().activate();
                } else {
                    entry.row.getActivator().activateInverse();
                }
            }
        }
        if (mKeyguardIconOverflowContainer.getVisibility() != View.GONE) {
            if (view == mKeyguardIconOverflowContainer) {
                mKeyguardIconOverflowContainer.getActivator().activate();
            } else {
                mKeyguardIconOverflowContainer.getActivator().activateInverse();
            }
        }
    }

    @Override
    public void onReset(View view) {
        int n = mNotificationData.size();
        for (int i = 0; i < n; i++) {
            NotificationData.Entry entry = mNotificationData.get(i);
            if (entry.row.getVisibility() != View.GONE) {
                entry.row.getActivator().reset();
            }
        }
        if (mKeyguardIconOverflowContainer.getVisibility() != View.GONE) {
            mKeyguardIconOverflowContainer.getActivator().reset();
        }
    }

    private boolean shouldShowOnKeyguard(StatusBarNotification sbn) {
    private boolean shouldShowOnKeyguard(StatusBarNotification sbn) {
        return sbn.getNotification().priority >= Notification.PRIORITY_LOW;
        return sbn.getNotification().priority >= Notification.PRIORITY_LOW;
    }
    }
+3 −3
Original line number Original line Diff line number Diff line
@@ -117,7 +117,7 @@ public class DragDownHelper implements Gefingerpoken {
                } else {
                } else {
                    if (mDraggedFarEnough) {
                    if (mDraggedFarEnough) {
                        mDraggedFarEnough = false;
                        mDraggedFarEnough = false;
                        mOnDragDownListener.onReset();
                        mOnDragDownListener.onDragDownReset();
                    }
                    }
                }
                }
                return true;
                return true;
@@ -188,7 +188,7 @@ public class DragDownHelper implements Gefingerpoken {
            cancelExpansion(mStartingChild);
            cancelExpansion(mStartingChild);
        }
        }
        mDraggingDown = false;
        mDraggingDown = false;
        mOnDragDownListener.onReset();
        mOnDragDownListener.onDragDownReset();
    }
    }


    private ExpandableView findView(float x, float y) {
    private ExpandableView findView(float x, float y) {
@@ -200,7 +200,7 @@ public class DragDownHelper implements Gefingerpoken {


    public interface OnDragDownListener {
    public interface OnDragDownListener {
        void onDraggedDown(View startingChild);
        void onDraggedDown(View startingChild);
        void onReset();
        void onDragDownReset();
        void onThresholdReached();
        void onThresholdReached();
    }
    }
}
}
+3 −19
Original line number Original line Diff line number Diff line
@@ -52,7 +52,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
    private NotificationContentView mPublicLayout;
    private NotificationContentView mPublicLayout;
    private NotificationContentView mPrivateLayout;
    private NotificationContentView mPrivateLayout;
    private int mMaxExpandHeight;
    private int mMaxExpandHeight;
    private NotificationActivator mActivator;


    public ExpandableNotificationRow(Context context, AttributeSet attrs) {
    public ExpandableNotificationRow(Context context, AttributeSet attrs) {
        super(context, attrs);
        super(context, attrs);
@@ -63,8 +62,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
        super.onFinishInflate();
        super.onFinishInflate();
        mPublicLayout = (NotificationContentView) findViewById(R.id.expandedPublic);
        mPublicLayout = (NotificationContentView) findViewById(R.id.expandedPublic);
        mPrivateLayout = (NotificationContentView) findViewById(R.id.expanded);
        mPrivateLayout = (NotificationContentView) findViewById(R.id.expanded);

        mActivator = new NotificationActivator(this, this);
    }
    }


    @Override
    @Override
@@ -208,23 +205,10 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
        mPrivateLayout.setVisibility(show ? View.GONE : View.VISIBLE);
        mPrivateLayout.setVisibility(show ? View.GONE : View.VISIBLE);
    }
    }


    /**
     * Sets the notification as dimmed, meaning that it will appear in a more gray variant.
     */
    @Override
    public void setDimmed(boolean dimmed, boolean fade) {
        super.setDimmed(dimmed, fade);
        mActivator.setDimmed(dimmed, fade);
    }

    public int getMaxExpandHeight() {
    public int getMaxExpandHeight() {
        return mMaxExpandHeight;
        return mMaxExpandHeight;
    }
    }


    public NotificationActivator getActivator() {
        return mActivator;
    }

    /**
    /**
     * @return the potential height this view could expand in addition.
     * @return the potential height this view could expand in addition.
     */
     */
@@ -238,10 +222,10 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
    }
    }


    @Override
    @Override
    public void setActualHeight(int height) {
    public void setActualHeight(int height, boolean notifyListeners) {
        mPrivateLayout.setActualHeight(height);
        mPrivateLayout.setActualHeight(height, notifyListeners);
        invalidate();
        invalidate();
        super.setActualHeight(height);
        super.setActualHeight(height, notifyListeners);
    }
    }


    @Override
    @Override
Loading