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

Commit 0c5c6a6f authored by Daniel Sandler's avatar Daniel Sandler Committed by Android (Google) Code Review
Browse files

Merge "Clean up some effects in the phone notification panel."

parents 6a9a4a07 0761e4cd
Loading
Loading
Loading
Loading
+14 −21
Original line number Diff line number Diff line
@@ -86,36 +86,29 @@
        android:layout_height="wrap_content"
        android:layout_weight="1"
        >
        <ScrollView
            android:id="@+id/scroll"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fadingEdge="none"
            android:overScrollMode="ifContentScrolls"
            >
            <LinearLayout
                android:id="@+id/notificationLinearLayout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                >
                
        <TextView android:id="@+id/noNotificationsTitle"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textAppearance="@android:style/TextAppearance.Large"
            android:padding="8dp"
            android:layout_gravity="top"
            android:gravity="center"
            android:text="@string/status_bar_no_notifications_title"
            />

        <ScrollView
            android:id="@+id/scroll"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fadingEdge="none"
            android:overScrollMode="ifContentScrolls"
            >
            <com.android.systemui.statusbar.policy.NotificationRowLayout
                android:id="@+id/latestItems"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                systemui:rowHeight="@dimen/notification_height"
                />
            </LinearLayout>
        </ScrollView>

        <ImageView
+2 −1
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ public class SwipeHelper {

    private float SWIPE_ESCAPE_VELOCITY = 100f; // dp/sec
    private int MAX_ESCAPE_ANIMATION_DURATION = 500; // ms
    private int MAX_DISMISS_VELOCITY = 1000; // dp/sec
    private static final int SNAP_ANIM_LEN = SLOW_ANIMATIONS ? 1000 : 250; // ms

    public static float ALPHA_FADE_START = 0.8f; // fraction of thumbnail width
@@ -281,7 +282,7 @@ public class SwipeHelper {
            case MotionEvent.ACTION_UP:
            case MotionEvent.ACTION_CANCEL:
                if (mCurrView != null) {
                    float maxVelocity = 1000; // px/sec
                    float maxVelocity = MAX_DISMISS_VELOCITY * mDensityScale;
                    mVelocityTracker.computeCurrentVelocity(1000 /* px/sec */, maxVelocity);
                    float escapeVelocity = SWIPE_ESCAPE_VELOCITY * mDensityScale;
                    float velocity = getVelocity(mVelocityTracker);
+37 −11
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.systemui.statusbar.phone;

import android.animation.ObjectAnimator;
import android.app.ActivityManagerNative;
import android.app.Dialog;
import android.app.Notification;
@@ -137,7 +138,6 @@ public class PhoneStatusBar extends StatusBar {
    ExpandedView mExpandedView;
    WindowManager.LayoutParams mExpandedParams;
    ScrollView mScrollView;
    View mNotificationLinearLayout;
    View mExpandedContents;
    // top bar
    TextView mNoNotificationsTitle;
@@ -311,16 +311,18 @@ public class PhoneStatusBar extends StatusBar {

        mExpandedDialog = new ExpandedDialog(context);
        mExpandedView = expanded;
        mExpandedContents = expanded.findViewById(R.id.notificationLinearLayout);
        mPile = (ViewGroup)expanded.findViewById(R.id.latestItems);
        mExpandedContents = mPile; // was: expanded.findViewById(R.id.notificationLinearLayout);
        mNoNotificationsTitle = (TextView)expanded.findViewById(R.id.noNotificationsTitle);
        mNoNotificationsTitle.setAlpha(0f);
        mNoNotificationsTitle.setVisibility(View.VISIBLE);
        mClearButton = expanded.findViewById(R.id.clear_all_button);
        mClearButton.setOnClickListener(mClearButtonListener);
        mClearButton.setAlpha(0f);
        mDateView = (DateView)expanded.findViewById(R.id.date);
        mSettingsButton = expanded.findViewById(R.id.settings_button);
        mSettingsButton.setOnClickListener(mSettingsButtonListener);
        mScrollView = (ScrollView)expanded.findViewById(R.id.scroll);
        mNotificationLinearLayout = expanded.findViewById(R.id.notificationLinearLayout);

        mTicker = new MyTicker(context, sb);

@@ -707,9 +709,10 @@ public class PhoneStatusBar extends StatusBar {
            mTicker.removeEntry(old);

            // Recalculate the position of the sliding windows and the titles.
            setAreThereNotifications();
            updateExpandedViewPos(EXPANDED_LEAVE_ALONE);
        }

        setAreThereNotifications();
    }

    @Override
@@ -1014,13 +1017,37 @@ public class PhoneStatusBar extends StatusBar {
    }

    private void setAreThereNotifications() {
        mClearButton.setVisibility(mNotificationData.hasClearableItems() 
                ? View.VISIBLE 
                : View.INVISIBLE);
        final boolean any = mNotificationData.size() > 0;

        final boolean clearable = any && mNotificationData.hasClearableItems();

        if (DEBUG) {
            Slog.d(TAG, "setAreThereNotifications: N=" + mNotificationData.size()
                    + " any=" + any + " clearable=" + clearable);
        }

        mNoNotificationsTitle.setVisibility(mNotificationData.size() > 0
                ? View.GONE
                : View.VISIBLE);
        if (mClearButton.isShown()) {
            if (clearable != (mClearButton.getAlpha() == 1.0f)) {
                ObjectAnimator.ofFloat(mClearButton, "alpha",
                        clearable ? 1.0f : 0.0f)
                    .setDuration(250)
                    .start();
            }
        } else {
            mClearButton.setAlpha(clearable ? 1.0f : 0.0f);
        }

        if (mNoNotificationsTitle.isShown()) {
            if (any != (mNoNotificationsTitle.getAlpha() == 0.0f)) {
                ObjectAnimator a = ObjectAnimator.ofFloat(mNoNotificationsTitle, "alpha",
                            (any ? 0.0f : 0.75f));
                a.setDuration(any ? 0 : 500);
                a.setStartDelay(any ? 250 : 1000);
                a.start();
            }
        } else {
            mNoNotificationsTitle.setAlpha(any ? 0.0f : 0.75f);
        }
    }


@@ -1662,7 +1689,6 @@ public class PhoneStatusBar extends StatusBar {
            pw.println("  mTickerView: " + viewInfo(mTickerView));
            pw.println("  mScrollView: " + viewInfo(mScrollView)
                    + " scroll " + mScrollView.getScrollX() + "," + mScrollView.getScrollY());
            pw.println("mNotificationLinearLayout: " + viewInfo(mNotificationLinearLayout));
        }
        /*
        synchronized (mNotificationData) {
+6 −29
Original line number Diff line number Diff line
@@ -166,20 +166,16 @@ public class NotificationRowLayout extends ViewGroup implements SwipeHelper.Call
            mAppearingViews.add(child);

            child.setPivotY(0);
            AnimatorSet a = new AnimatorSet();
            a.playTogether(
                    ObjectAnimator.ofFloat(child, "alpha", 0f, 1f)
//                    ,ObjectAnimator.ofFloat(child, "scaleY", 0f, 1f)
            );
            a.setDuration(APPEAR_ANIM_LEN);
            a.addListener(new AnimatorListenerAdapter() {
            final ObjectAnimator alphaFade = ObjectAnimator.ofFloat(child, "alpha", 0f, 1f);
            alphaFade.setDuration(APPEAR_ANIM_LEN);
            alphaFade.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    mAppearingViews.remove(childF);
                    requestLayout(); // pick up any final changes in position
                }
            });
            a.start();
            alphaFade.start();
            requestLayout(); // start the container animation
        }
    }
@@ -195,23 +191,10 @@ public class NotificationRowLayout extends ViewGroup implements SwipeHelper.Call

            child.setPivotY(0);

            //final float velocity = (mSlidingChild == child)
             //       ? Math.min(mLiftoffVelocity, SWIPE_ANIM_VELOCITY_MIN)
            //        : SWIPE_ESCAPE_VELOCITY;
            final float velocity = 0f;
            final TimeAnimator zoom = new TimeAnimator();
            zoom.setTimeListener(new TimeAnimator.TimeListener() {
                @Override
                public void onTimeUpdate(TimeAnimator animation, long totalTime, long deltaTime) {
                    childF.setTranslationX(childF.getTranslationX() + deltaTime / 1000f * velocity);
                }
            });

            final ObjectAnimator alphaFade = ObjectAnimator.ofFloat(child, "alpha", 0f);
            alphaFade.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    zoom.cancel(); // it won't end on its own
                    if (DEBUG) Slog.d(TAG, "actually removing child: " + childF);
                    NotificationRowLayout.super.removeView(childF);
                    childF.setAlpha(1f);
@@ -220,14 +203,8 @@ public class NotificationRowLayout extends ViewGroup implements SwipeHelper.Call
                }
            });

            AnimatorSet a = new AnimatorSet();
            a.playTogether(alphaFade, zoom);
                    
//                    ,ObjectAnimator.ofFloat(child, "scaleY", 0f)
//                    ,ObjectAnimator.ofFloat(child, "translationX", child.getTranslationX() + 300f)

            a.setDuration(DISAPPEAR_ANIM_LEN);
            a.start();
            alphaFade.setDuration(DISAPPEAR_ANIM_LEN);
            alphaFade.start();
            requestLayout(); // start the container animation
        } else {
            super.removeView(child);