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

Commit a5d6c373 authored by Mady Mellor's avatar Mady Mellor Committed by Android (Google) Code Review
Browse files

Merge "Update the animation when showing / closing inline controls" into nyc-dev

parents 6cf85afc b53bc276
Loading
Loading
Loading
Loading
+19 −6
Original line number Original line Diff line number Diff line
@@ -959,7 +959,7 @@ public abstract class BaseStatusBar extends SystemUI implements
        }, false /* afterKeyguardGone */);
        }, false /* afterKeyguardGone */);
    }
    }


    private void bindGuts(ExpandableNotificationRow row) {
    private void bindGuts(final ExpandableNotificationRow row) {
        row.inflateGuts();
        row.inflateGuts();
        final StatusBarNotification sbn = row.getStatusBarNotification();
        final StatusBarNotification sbn = row.getStatusBarNotification();
        PackageManager pmUser = getPackageManagerForUser(mContext, sbn.getUser().getIdentifier());
        PackageManager pmUser = getPackageManagerForUser(mContext, sbn.getUser().getIdentifier());
@@ -1003,7 +1003,17 @@ public abstract class BaseStatusBar extends SystemUI implements
            @Override
            @Override
            public void onClick(View v) {
            public void onClick(View v) {
                guts.saveImportance(sbn);
                guts.saveImportance(sbn);
                dismissPopups();

                int[] rowLocation = new int[2];
                int[] doneLocation = new int[2];
                row.getLocationOnScreen(rowLocation);
                v.getLocationOnScreen(doneLocation);

                final int centerX = v.getWidth() / 2;
                final int centerY = v.getHeight() / 2;
                final int x = doneLocation[0] - rowLocation[0] + centerX;
                final int y = doneLocation[1] - rowLocation[1] + centerY;
                dismissPopups(x, y);
            }
            }
        });
        });


@@ -1049,7 +1059,7 @@ public abstract class BaseStatusBar extends SystemUI implements
                // Post to ensure the the guts are properly laid out.
                // Post to ensure the the guts are properly laid out.
                guts.post(new Runnable() {
                guts.post(new Runnable() {
                    public void run() {
                    public void run() {
                        dismissPopups();
                        dismissPopups(-1 /* x */, -1 /* y */, false /* resetGear */);
                        guts.setVisibility(View.VISIBLE);
                        guts.setVisibility(View.VISIBLE);
                        final double horz = Math.max(guts.getWidth() - x, x);
                        final double horz = Math.max(guts.getWidth() - x, x);
                        final double vert = Math.max(guts.getHeight() - y, y);
                        final double vert = Math.max(guts.getHeight() - y, y);
@@ -1083,10 +1093,14 @@ public abstract class BaseStatusBar extends SystemUI implements
    }
    }


    public void dismissPopups() {
    public void dismissPopups() {
        dismissPopups(-1, -1);
        dismissPopups(-1 /* x */, -1 /* y */, true /* resetGear */);
    }
    }


    private void dismissPopups(int x, int y) {
    private void dismissPopups(int x, int y) {
        dismissPopups(x, y, true /* resetGear */);
    }

    public void dismissPopups(int x, int y, boolean resetGear) {
        if (mNotificationGutsExposed != null) {
        if (mNotificationGutsExposed != null) {
            final NotificationGuts v = mNotificationGutsExposed;
            final NotificationGuts v = mNotificationGutsExposed;
            mNotificationGutsExposed = null;
            mNotificationGutsExposed = null;
@@ -1114,8 +1128,7 @@ public abstract class BaseStatusBar extends SystemUI implements
            v.setExposed(false);
            v.setExposed(false);
            mStackScroller.onHeightChanged(null, true /* needsAnimation */);
            mStackScroller.onHeightChanged(null, true /* needsAnimation */);
        }
        }

        if (resetGear && mNotificationGearDisplayed != null) {
        if (mNotificationGearDisplayed != null) {
            mNotificationGearDisplayed.resetTranslation();
            mNotificationGearDisplayed.resetTranslation();
            mNotificationGearDisplayed = null;
            mNotificationGearDisplayed = null;
        }
        }
+4 −2
Original line number Original line Diff line number Diff line
@@ -656,7 +656,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
                mGuts = (NotificationGuts) inflated;
                mGuts = (NotificationGuts) inflated;
                mGuts.setClipTopAmount(getClipTopAmount());
                mGuts.setClipTopAmount(getClipTopAmount());
                mGuts.setActualHeight(getActualHeight());
                mGuts.setActualHeight(getActualHeight());
                mTranslateableViews.add(mGuts);
                mGutsStub = null;
                mGutsStub = null;
            }
            }
        });
        });
@@ -1175,6 +1174,10 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
    @Override
    @Override
    public void setActualHeight(int height, boolean notifyListeners) {
    public void setActualHeight(int height, boolean notifyListeners) {
        super.setActualHeight(height, notifyListeners);
        super.setActualHeight(height, notifyListeners);
        if (mGuts != null && mGuts.areGutsExposed()) {
            mGuts.setActualHeight(height);
            return;
        }
        int contentHeight = Math.max(getMinHeight(), height);
        int contentHeight = Math.max(getMinHeight(), height);
        mPrivateLayout.setContentHeight(contentHeight);
        mPrivateLayout.setContentHeight(contentHeight);
        mPublicLayout.setContentHeight(contentHeight);
        mPublicLayout.setContentHeight(contentHeight);
@@ -1184,7 +1187,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
        if (mGuts != null) {
        if (mGuts != null) {
            mGuts.setActualHeight(height);
            mGuts.setActualHeight(height);
        }
        }
        invalidate();
    }
    }


    @Override
    @Override
+19 −8
Original line number Original line Diff line number Diff line
@@ -33,7 +33,7 @@ public class NotificationSettingsIconRow extends FrameLayout implements View.OnC
        /**
        /**
         * Called when the gear behind a notification is touched.
         * Called when the gear behind a notification is touched.
         */
         */
        public void onGearTouched(ExpandableNotificationRow row);
        public void onGearTouched(ExpandableNotificationRow row, int x, int y);
    }
    }


    private ExpandableNotificationRow mParent;
    private ExpandableNotificationRow mParent;
@@ -45,6 +45,8 @@ public class NotificationSettingsIconRow extends FrameLayout implements View.OnC
    private boolean mSettingsFadedIn = false;
    private boolean mSettingsFadedIn = false;
    private boolean mAnimating = false;
    private boolean mAnimating = false;
    private boolean mOnLeft = true;
    private boolean mOnLeft = true;
    private int[] mGearLocation = new int[2];
    private int[] mParentLocation = new int[2];


    public NotificationSettingsIconRow(Context context) {
    public NotificationSettingsIconRow(Context context) {
        this(context, null);
        this(context, null);
@@ -74,6 +76,12 @@ public class NotificationSettingsIconRow extends FrameLayout implements View.OnC
        resetState();
        resetState();
    }
    }


    public void resetState() {
        setGearAlpha(0f);
        mAnimating = false;
        setIconLocation(true /* on left */);
    }

    public void setGearListener(SettingsIconRowListener listener) {
    public void setGearListener(SettingsIconRowListener listener) {
        mListener = listener;
        mListener = listener;
    }
    }
@@ -86,12 +94,6 @@ public class NotificationSettingsIconRow extends FrameLayout implements View.OnC
        return mParent;
        return mParent;
    }
    }


    public void resetState() {
        setGearAlpha(0f);
        mAnimating = false;
        setIconLocation(true /* on left */);
    }

    private void setGearAlpha(float alpha) {
    private void setGearAlpha(float alpha) {
        if (alpha == 0) {
        if (alpha == 0) {
            mSettingsFadedIn = false; // Can fade in again once it's gone.
            mSettingsFadedIn = false; // Can fade in again once it's gone.
@@ -200,7 +202,16 @@ public class NotificationSettingsIconRow extends FrameLayout implements View.OnC
    public void onClick(View v) {
    public void onClick(View v) {
        if (v.getId() == R.id.gear_icon) {
        if (v.getId() == R.id.gear_icon) {
            if (mListener != null) {
            if (mListener != null) {
                mListener.onGearTouched(mParent);
                mGearIcon.getLocationOnScreen(mGearLocation);
                mParent.getLocationOnScreen(mParentLocation);

                final int centerX = (int) (mHorizSpaceForGear / 2);
                // Top / bottom padding are not equal, need to subtract them to get center of gear.
                final int centerY = (int) (mGearIcon.getHeight() - mGearIcon.getPaddingTop()
                        - mGearIcon.getPaddingBottom()) / 2 + mGearIcon.getPaddingTop();
                final int x = mGearLocation[0] - mParentLocation[0] + centerX;
                final int y = mGearLocation[1] - mParentLocation[1] + centerY;
                mListener.onGearTouched(mParent, x, y);
            }
            }
        } else {
        } else {
            // Do nothing when the background is touched.
            // Do nothing when the background is touched.
+2 −2
Original line number Original line Diff line number Diff line
@@ -361,9 +361,9 @@ public class NotificationStackScrollLayout extends ViewGroup
    }
    }


    @Override
    @Override
    public void onGearTouched(ExpandableNotificationRow row) {
    public void onGearTouched(ExpandableNotificationRow row, int x, int y) {
        if (mLongPressListener != null) {
        if (mLongPressListener != null) {
            mLongPressListener.onLongPress(row, 0, 0);
            mLongPressListener.onLongPress(row, x, y);
        }
        }
    }
    }