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

Commit 85265ad9 authored by Mindy Pereira's avatar Mindy Pereira Committed by Android (Google) Code Review
Browse files

Merge "Per designers, update the algorithm for when effect is clipped or stretched."

parents be53a95a 4e30d89c
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ package android.webkit;

import com.android.internal.R;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
@@ -40,13 +41,14 @@ public class OverScrollGlow {

    public OverScrollGlow(WebView host) {
        mHostView = host;
        final Resources res = host.getContext().getResources();
        Context context = host.getContext();
        final Resources res = context.getResources();
        final Drawable edge = res.getDrawable(R.drawable.overscroll_edge);
        final Drawable glow = res.getDrawable(R.drawable.overscroll_glow);
        mEdgeGlowTop = new EdgeGlow(edge, glow);
        mEdgeGlowBottom = new EdgeGlow(edge, glow);
        mEdgeGlowLeft = new EdgeGlow(edge, glow);
        mEdgeGlowRight = new EdgeGlow(edge, glow);
        mEdgeGlowTop = new EdgeGlow(context, edge, glow);
        mEdgeGlowBottom = new EdgeGlow(context, edge, glow);
        mEdgeGlowLeft = new EdgeGlow(context, edge, glow);
        mEdgeGlowRight = new EdgeGlow(context, edge, glow);
    }

    /**
+56 −55
Original line number Diff line number Diff line
@@ -764,11 +764,12 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
    public void setOverScrollMode(int mode) {
        if (mode != OVER_SCROLL_NEVER) {
            if (mEdgeGlowTop == null) {
                final Resources res = getContext().getResources();
                Context context = getContext();
                final Resources res = context.getResources();
                final Drawable edge = res.getDrawable(R.drawable.overscroll_edge);
                final Drawable glow = res.getDrawable(R.drawable.overscroll_glow);
                mEdgeGlowTop = new EdgeGlow(edge, glow);
                mEdgeGlowBottom = new EdgeGlow(edge, glow);
                mEdgeGlowTop = new EdgeGlow(context, edge, glow);
                mEdgeGlowBottom = new EdgeGlow(context, edge, glow);
            }
        } else {
            mEdgeGlowTop = null;
+29 −11
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.widget;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.view.animation.AnimationUtils;
@@ -44,7 +45,7 @@ public class EdgeGlow {
    private static final float HELD_GLOW_ALPHA = 0.5f;
    private static final float HELD_GLOW_SCALE_Y = 0.5f;

    private static final float MAX_GLOW_HEIGHT = 3.f;
    private static final float MAX_GLOW_HEIGHT = 4.f;

    private static final float PULL_GLOW_BEGIN = 1.f;
    private static final float PULL_EDGE_BEGIN = 0.6f;
@@ -58,6 +59,8 @@ public class EdgeGlow {
    private final Drawable mGlow;
    private int mWidth;
    private int mHeight;
    private final int MIN_WIDTH = 300;
    private final int mMinWidth;

    private float mEdgeAlpha;
    private float mEdgeScaleY;
@@ -86,12 +89,12 @@ public class EdgeGlow {

    // How much dragging should effect the height of the edge image.
    // Number determined by user testing.
    private static final int PULL_DISTANCE_EDGE_FACTOR = 5;
    private static final int PULL_DISTANCE_EDGE_FACTOR = 7;

    // How much dragging should effect the height of the glow image.
    // Number determined by user testing.
    private static final int PULL_DISTANCE_GLOW_FACTOR = 5;
    private static final float PULL_DISTANCE_ALPHA_GLOW_FACTOR = 0.8f;
    private static final int PULL_DISTANCE_GLOW_FACTOR = 7;
    private static final float PULL_DISTANCE_ALPHA_GLOW_FACTOR = 1.1f;

    private static final int VELOCITY_EDGE_FACTOR = 8;
    private static final int VELOCITY_GLOW_FACTOR = 16;
@@ -100,10 +103,11 @@ public class EdgeGlow {

    private float mPullDistance;

    public EdgeGlow(Drawable edge, Drawable glow) {
    public EdgeGlow(Context context, Drawable edge, Drawable glow) {
        mEdge = edge;
        mGlow = glow;

        mMinWidth = (int) (context.getResources().getDisplayMetrics().density * MIN_WIDTH + 0.5f);
        mInterpolator = new DecelerateInterpolator();
    }

@@ -251,17 +255,31 @@ public class EdgeGlow {

        mGlow.setAlpha((int) (Math.max(0, Math.min(mGlowAlpha, 1)) * 255));

        // Center the glow inside the width of the container.
        int glowLeft = (mWidth - glowWidth)/2;
        mGlow.setBounds(glowLeft, 0, mWidth - glowLeft, (int) Math.min(
        int glowBottom = (int) Math.min(
                glowHeight * mGlowScaleY * glowHeight/ glowWidth * 0.6f,
                glowHeight * MAX_GLOW_HEIGHT));
                glowHeight * MAX_GLOW_HEIGHT);
        if (mWidth < mMinWidth) {
            // Center the glow and clip it.
            int glowLeft = (mWidth - glowWidth)/2;
            mGlow.setBounds(glowLeft, 0, mWidth - glowLeft, glowBottom);
        } else {
            // Stretch the glow to fit.
            mGlow.setBounds(0, 0, mWidth, glowBottom);
        }

        mGlow.draw(canvas);

        mEdge.setAlpha((int) (Math.max(0, Math.min(mEdgeAlpha, 1)) * 255));

        int edgeBottom = (int) (edgeHeight * mEdgeScaleY);
        if (mWidth < mMinWidth) {
            // Center the edge and clip it.
            int edgeLeft = (mWidth - edgeWidth)/2;
        mEdge.setBounds(edgeLeft, 0, mWidth - edgeLeft, (int) (edgeHeight * mEdgeScaleY));
            mEdge.setBounds(edgeLeft, 0, mWidth - edgeLeft, edgeBottom);
        } else {
            // Stretch the edge to fit.
            mEdge.setBounds(0, 0, mWidth, edgeBottom);
        }
        mEdge.draw(canvas);

        return mState != STATE_IDLE;
+27 −26
Original line number Diff line number Diff line
@@ -1396,11 +1396,12 @@ public class HorizontalScrollView extends FrameLayout {
    public void setOverScrollMode(int mode) {
        if (mode != OVER_SCROLL_NEVER) {
            if (mEdgeGlowLeft == null) {
                final Resources res = getContext().getResources();
                Context context = getContext();
                final Resources res = context.getResources();
                final Drawable edge = res.getDrawable(R.drawable.overscroll_edge);
                final Drawable glow = res.getDrawable(R.drawable.overscroll_glow);
                mEdgeGlowLeft = new EdgeGlow(edge, glow);
                mEdgeGlowRight = new EdgeGlow(edge, glow);
                mEdgeGlowLeft = new EdgeGlow(context, edge, glow);
                mEdgeGlowRight = new EdgeGlow(context, edge, glow);
            }
        } else {
            mEdgeGlowLeft = null;
+26 −25
Original line number Diff line number Diff line
@@ -1444,11 +1444,12 @@ public class ScrollView extends FrameLayout {
    public void setOverScrollMode(int mode) {
        if (mode != OVER_SCROLL_NEVER) {
            if (mEdgeGlowTop == null) {
                final Resources res = getContext().getResources();
                Context context = getContext();
                final Resources res = context.getResources();
                final Drawable edge = res.getDrawable(R.drawable.overscroll_edge);
                final Drawable glow = res.getDrawable(R.drawable.overscroll_glow);
                mEdgeGlowTop = new EdgeGlow(edge, glow);
                mEdgeGlowBottom = new EdgeGlow(edge, glow);
                mEdgeGlowTop = new EdgeGlow(context, edge, glow);
                mEdgeGlowBottom = new EdgeGlow(context, edge, glow);
            }
        } else {
            mEdgeGlowTop = null;