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

Commit a54c01ec authored by Chris Wren's avatar Chris Wren Committed by Android (Google) Code Review
Browse files

Merge "Invert the sense of the two-figner direction on tablets." into jb-dev

parents b44700f2 9b2cd15f
Loading
Loading
Loading
Loading
+22 −2
Original line number Diff line number Diff line
@@ -23,11 +23,14 @@ import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.util.Log;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.ScrollView;
import android.widget.FrameLayout;

public class ExpandHelper implements Gefingerpoken, OnClickListener {
    public interface Callback {
@@ -38,7 +41,7 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {
    }

    private static final String TAG = "ExpandHelper";
    protected static final boolean DEBUG = false;
    protected static final boolean DEBUG = true;
    private static final long EXPAND_DURATION = 250;
    private static final long GLOW_DURATION = 150;

@@ -82,8 +85,11 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {
    private int mLargeSize;
    private float mMaximumStretch;

    private int mGravity;

    private class ViewScaler {
        View mView;

        public ViewScaler() {}
        public void setView(View v) {
            mView = v;
@@ -119,6 +125,15 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {
        }
    }

    /**
     * Handle expansion gestures to expand and contract children of the callback.
     *
     * @param context application context
     * @param callback the container that holds the items to be manipulated
     * @param small the smallest allowable size for the manuipulated items.
     * @param large the largest allowable size for the manuipulated items.
     * @param scoller if non-null also manipulate the scroll position to obey the gravity.
     */
    public ExpandHelper(Context context, Callback callback, int small, int large) {
        mSmallSize = small;
        mMaximumStretch = mSmallSize * STRETCH_INTERVAL;
@@ -126,7 +141,7 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {
        mContext = context;
        mCallback = callback;
        mScaler = new ViewScaler();

        mGravity = Gravity.TOP;
        mScaleAnimation = ObjectAnimator.ofFloat(mScaler, "height", 0f);
        mScaleAnimation.setDuration(EXPAND_DURATION);

@@ -194,6 +209,7 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {
                span *= USE_SPAN ? 1f : 0f;
                float drag = detector.getFocusY() - mInitialTouchFocusY;
                drag *= USE_DRAG ? 1f : 0f;
                drag *= mGravity == Gravity.BOTTOM ? -1f : 1f;
                float pull = Math.abs(drag) + Math.abs(span) + 1f;
                float hand = drag * Math.abs(drag) / pull + span * Math.abs(span) / pull;
                if (DEBUG) Log.d(TAG, "current span handle is: " + hand);
@@ -227,6 +243,10 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {
        mEventSource = eventSource;
    }

    public void setGravity(int gravity) {
        mGravity = gravity;
    }

    public void setGlow(float glow) {
        if (!mGlowAnimationSet.isRunning() || glow == 0f) {
            if (mGlowAnimationSet.isRunning()) {
+2 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.widget.FrameLayout;
import android.widget.ScrollView;
import android.widget.TextSwitcher;

import com.android.systemui.ExpandHelper;
@@ -47,6 +48,7 @@ public class StatusBarWindowView extends FrameLayout
    protected void onAttachedToWindow () {
        super.onAttachedToWindow();
        latestItems = (NotificationRowLayout) findViewById(R.id.latestItems);
        ScrollView scroller = (ScrollView) findViewById(R.id.scroll);
        int minHeight = getResources().getDimensionPixelSize(R.dimen.notification_row_min_height);
        int maxHeight = getResources().getDimensionPixelSize(R.dimen.notification_row_max_height);
        mExpandHelper = new ExpandHelper(mContext, latestItems, minHeight, maxHeight);
+3 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.content.Context;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.util.Slog;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
@@ -33,6 +34,7 @@ import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
import android.widget.RelativeLayout;
import android.widget.ScrollView;

import com.android.systemui.ExpandHelper;
import com.android.systemui.R;
@@ -114,6 +116,7 @@ public class NotificationPanel extends RelativeLayout implements StatusBarPanel,
        int maxHeight = getResources().getDimensionPixelSize(R.dimen.notification_row_max_height);
        mExpandHelper = new ExpandHelper(mContext, latestItems, minHeight, maxHeight);
        mExpandHelper.setEventSource(this);
        mExpandHelper.setGravity(Gravity.BOTTOM);
    }

    private View.OnClickListener mClearButtonListener = new View.OnClickListener() {