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

Commit 93160828 authored by Selim Cinek's avatar Selim Cinek Committed by Android (Google) Code Review
Browse files

Merge "Enabled the new notification shade and improved expanding logic"

parents ef4c0c9f b6d85ebf
Loading
Loading
Loading
Loading
+1 −24
Original line number Diff line number Diff line
@@ -24,19 +24,10 @@
    android:id="@+id/notification_panel"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:background="@drawable/notification_panel_bg"
    android:paddingTop="@dimen/notification_panel_padding_top"
    android:layout_marginStart="@dimen/notification_panel_margin_left"
    >

    <View
        android:id="@+id/handle"
        android:layout_width="match_parent"
        android:layout_height="@dimen/close_handle_height"
        android:background="@drawable/status_bar_close"
        android:visibility="invisible"
        />

    <include
        layout="@layout/carrier_label"
        android:layout_height="@dimen/carrier_label_height"
@@ -69,6 +60,7 @@
            />

        <FrameLayout
            android:id="@+id/notification_container_parent"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            >
@@ -78,21 +70,6 @@
                android:layout_height="wrap_content"
                />

            <ScrollView
                android:id="@+id/scroll"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                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_row_min_height"
                    />
            </ScrollView>

            <com.android.systemui.statusbar.stack.NotificationStackScrollLayout
                    android:id="@+id/notification_stack_scroller"
                    android:layout_width="match_parent"
+2 −14
Original line number Diff line number Diff line
@@ -34,6 +34,8 @@ import android.view.View.OnClickListener;
import android.view.ViewConfiguration;
import android.view.ViewGroup;

import com.android.systemui.statusbar.policy.ScrollAdapter;

public class ExpandHelper implements Gefingerpoken, OnClickListener {
    public interface Callback {
        View getChildAtRawPosition(float x, float y);
@@ -609,19 +611,5 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {
        }
        mVibrator.vibrate(duration, AudioManager.STREAM_SYSTEM);
    }

    public interface ScrollAdapter {

        /**
         * @return Whether the view returned by {@link #getHostView()} is scrolled to the top
         * and can therefore be expanded by a single finger drag
         */
        public boolean isScrolledToTop();

        /**
         * @return The view in which the scrolling is performed
         */
        public View getHostView();
    }
}
+3 −5
Original line number Diff line number Diff line
@@ -41,7 +41,6 @@ import android.os.Message;
import android.os.PowerManager;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Settings;
@@ -78,6 +77,7 @@ import com.android.systemui.RecentsComponent;
import com.android.systemui.SearchPanelView;
import com.android.systemui.SystemUI;
import com.android.systemui.statusbar.phone.KeyguardTouchDelegate;
import com.android.systemui.statusbar.stack.NotificationStackScrollLayout;

import java.util.ArrayList;
import java.util.Locale;
@@ -98,8 +98,6 @@ public abstract class BaseStatusBar extends SystemUI implements
    protected static final int MSG_HIDE_HEADS_UP = 1027;
    protected static final int MSG_ESCALATE_HEADS_UP = 1028;

    public static final boolean ENABLE_NOTIFICATION_STACK = SystemProperties
            .getBoolean("persist.notifications.use_stack", false);
    protected static final boolean ENABLE_HEADS_UP = true;
    // scores above this threshold should be displayed in heads up mode.
    protected static final int INTERRUPTION_THRESHOLD = 10;
@@ -120,7 +118,7 @@ public abstract class BaseStatusBar extends SystemUI implements

    // all notifications
    protected NotificationData mNotificationData = new NotificationData();
    protected ViewGroup mPile;
    protected NotificationStackScrollLayout mStackScroller;

    protected NotificationData.Entry mInterruptingNotificationEntry;
    protected long mInterruptingNotificationTime;
@@ -1033,7 +1031,7 @@ public abstract class BaseStatusBar extends SystemUI implements
        }
        // Construct the expanded view.
        NotificationData.Entry entry = new NotificationData.Entry(key, notification, iconView);
        if (!inflateViews(entry, mPile)) {
        if (!inflateViews(entry, mStackScroller)) {
            handleNotificationError(key, notification, "Couldn't expand RemoteViews for: "
                    + notification);
            return null;
+92 −61
Original line number Diff line number Diff line
@@ -17,45 +17,51 @@
package com.android.systemui.statusbar.phone;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.EventLog;
import android.view.MotionEvent;
import android.view.View;
import android.view.accessibility.AccessibilityEvent;

import com.android.systemui.EventLogTags;
import com.android.systemui.R;
import com.android.systemui.statusbar.GestureRecorder;
import com.android.systemui.statusbar.stack.NotificationStackScrollLayout;

public class NotificationPanelView extends PanelView {
    public static final boolean DEBUG_GESTURES = true;

    Drawable mHandleBar;
    int mHandleBarHeight;
    View mHandleView;
    int mFingers;
    PhoneStatusBar mStatusBar;
    boolean mOkToFlip;
    private NotificationStackScrollLayout mNotificationStackScroller;
    private int[] mTempLocation = new int[2];
    private int[] mTempChildLocation = new int[2];
    private View mNotificationParent;


    public NotificationPanelView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public void setStatusBar(PhoneStatusBar bar) {
        if (mStatusBar != null) {
            mStatusBar.setOnFlipRunnable(null);
        }
        mStatusBar = bar;
        if (bar != null) {
            mStatusBar.setOnFlipRunnable(new Runnable() {
                @Override
                public void run() {
                    requestPanelHeightUpdate();
                }
            });
        }
    }

    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();

        Resources resources = getContext().getResources();
        mHandleBar = resources.getDrawable(R.drawable.status_bar_close);
        mHandleBarHeight = resources.getDimensionPixelSize(R.dimen.close_handle_height);
        mHandleView = findViewById(R.id.handle);
        mNotificationStackScroller = (NotificationStackScrollLayout)
                findViewById(R.id.notification_stack_scroller);
        mNotificationParent = findViewById(R.id.notification_container_parent);
    }

    @Override
@@ -80,61 +86,86 @@ public class NotificationPanelView extends PanelView {
        return super.dispatchPopulateAccessibilityEvent(event);
    }

    // We draw the handle ourselves so that it's always glued to the bottom of the window.
    @Override
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
        super.onLayout(changed, left, top, right, bottom);
        if (changed) {
            final int pl = getPaddingLeft();
            final int pr = getPaddingRight();
            mHandleBar.setBounds(pl, 0, getWidth() - pr, (int) mHandleBarHeight);
    /**
     * Gets the relative position of a view on the screen in regard to this view.
     *
     * @param requestedView the view we want to find the relative position for
     * @return
     */
    private int getRelativeTop(View requestedView) {
        getLocationOnScreen(mTempLocation);
        requestedView.getLocationOnScreen(mTempChildLocation);
        return mTempChildLocation[1] - mTempLocation[1];
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        // TODO: Handle doublefinger swipe to notifications again. Look at history for a reference
        // implementation.
        return super.onTouchEvent(event);
    }

    @Override
    public void draw(Canvas canvas) {
        super.draw(canvas);
        final int off = (int) (getHeight() - mHandleBarHeight - getPaddingBottom());
        canvas.translate(0, off);
        mHandleBar.setState(mHandleView.getDrawableState());
        mHandleBar.draw(canvas);
        canvas.translate(0, -off);
    protected boolean isScrolledToBottom() {
        if (!isInSettings()) {
            return mNotificationStackScroller.isScrolledToBottom();
        }
        return super.isScrolledToBottom();
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        if (DEBUG_GESTURES) {
            if (event.getActionMasked() != MotionEvent.ACTION_MOVE) {
                EventLog.writeEvent(EventLogTags.SYSUI_NOTIFICATIONPANEL_TOUCH,
                       event.getActionMasked(), (int) event.getX(), (int) event.getY());
            }
        }
        if (PhoneStatusBar.SETTINGS_DRAG_SHORTCUT && mStatusBar.mHasFlipSettings) {
            switch (event.getActionMasked()) {
                case MotionEvent.ACTION_DOWN:
                    mOkToFlip = getExpandedHeight() == 0;
                    break;
                case MotionEvent.ACTION_POINTER_DOWN:
                    if (mOkToFlip) {
                        float miny = event.getY(0);
                        float maxy = miny;
                        for (int i=1; i<event.getPointerCount(); i++) {
                            final float y = event.getY(i);
                            if (y < miny) miny = y;
                            if (y > maxy) maxy = y;
                        }
                        if (maxy - miny < mHandleBarHeight) {
                            if (getMeasuredHeight() < mHandleBarHeight) {
                                mStatusBar.switchToSettings();
                            } else {
                                mStatusBar.flipToSettings();
    protected int getMaxPanelHeight() {
        if (!isInSettings()) {
            int maxPanelHeight = super.getMaxPanelHeight();
            int emptyBottomMargin = mNotificationStackScroller.getEmptyBottomMargin();
            return maxPanelHeight - emptyBottomMargin;
        }
        return super.getMaxPanelHeight();
    }
                            mOkToFlip = false;

    private boolean isInSettings() {
        return mStatusBar != null && mStatusBar.isFlippedToSettings();
    }

    @Override
    protected void onHeightUpdated(float expandedHeight) {
        updateNotificationStackHeight(expandedHeight);
    }
                    break;

    /**
     * Update the height of the {@link #mNotificationStackScroller} to the new expanded height.
     * This is much more efficient than doing it over the layout pass.
     *
     * @param expandedHeight the new expanded height
     */
    private void updateNotificationStackHeight(float expandedHeight) {
        float childOffset = getRelativeTop(mNotificationStackScroller)
                - mNotificationParent.getTranslationY();
        int newStackHeight = (int) (expandedHeight - childOffset);
        int itemHeight = mNotificationStackScroller.getItemHeight();
        int bottomStackPeekSize = mNotificationStackScroller.getBottomStackPeekSize();
        int minStackHeight = itemHeight + bottomStackPeekSize;
        if (newStackHeight >= minStackHeight) {
            mNotificationParent.setTranslationY(0);
            mNotificationStackScroller.setCurrentStackHeight(newStackHeight);
        } else {

            // We did not reach the position yet where we actually start growing,
            // so we translate the stack upwards.
            int translationY = (newStackHeight - minStackHeight);
            // A slight parallax effect is introduced in order for the stack to catch up with
            // the top card.
            float partiallyThere = (float) newStackHeight / minStackHeight;
            partiallyThere = Math.max(0, partiallyThere);
            translationY += (1 - partiallyThere) * bottomStackPeekSize;
            mNotificationParent.setTranslationY(translationY);
            mNotificationStackScroller.setCurrentStackHeight(
                    (int) (expandedHeight - (childOffset + translationY)));
        }
    }
        return mHandleView.dispatchTouchEvent(event);

    @Override
    protected int getDesiredMeasureHeight() {
        return mMaxPanelHeight;
    }
}
+268 −156

File changed.

Preview size limit exceeded, changes collapsed.

Loading