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

Commit 5d47a8dc authored by Adam Cohen's avatar Adam Cohen
Browse files

Cleaning up the overscroll effect

Change-Id: I685693fa178fb7b6418145554eb320b1a62d7462
parent db1c5d59
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -118,7 +118,7 @@
    <!-- keyguard overscroll widget pager -->
    <color name="kg_multi_user_text_active">#ffffffff</color>
    <color name="kg_multi_user_text_inactive">#ff808080</color>
    <color name="kg_widget_pager_gradient">#ff33B5E5</color>
    <color name="kg_widget_pager_gradient">#ffffffff</color>

    <!-- FaceLock -->
    <color name="facelock_spotlight_mask">#CC000000</color>
+15 −3
Original line number Diff line number Diff line
@@ -76,6 +76,7 @@ public class KeyguardWidgetFrame extends FrameLayout {
    private int mSmallFrameHeight;
    private boolean mWidgetLockedSmall = false;
    private int mMaxChallengeTop = -1;
    private int mFrameStrokeAdjustment;

    // This will hold the width value before we've actually been measured
    private int mFrameHeight;
@@ -103,9 +104,12 @@ public class KeyguardWidgetFrame extends FrameLayout {
        Resources res = context.getResources();
        // TODO: this padding should really correspond to the padding embedded in the background
        // drawable (ie. outlines).
        float density = res.getDisplayMetrics().density;
        int padding = (int) (res.getDisplayMetrics().density * 8);
        setPadding(padding, padding, padding, padding);

        mFrameStrokeAdjustment = (int) (2 * density);

        mBackgroundDrawable = res.getDrawable(R.drawable.kg_bouncer_bg_white);
        mGradientColor = res.getColor(com.android.internal.R.color.kg_widget_pager_gradient);
        mGradientPaint.setXfermode(sAddBlendMode);
@@ -394,8 +398,12 @@ public class KeyguardWidgetFrame extends FrameLayout {
    @Override
    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        super.onSizeChanged(w, h, oldw, oldh);
        mForegroundRect.set(getPaddingLeft(), getPaddingTop(),
                w - getPaddingRight(), h - getPaddingBottom());

        // mFrameStrokeAdjustment is a cludge to prevent the overlay from drawing outside the
        // rounded rect background.
        mForegroundRect.set(mFrameStrokeAdjustment, mFrameStrokeAdjustment,
                w - mFrameStrokeAdjustment, h - mFrameStrokeAdjustment);

        float x0 = mLeftToRight ? 0 : mForegroundRect.width();
        float x1 = mLeftToRight ? mForegroundRect.width(): 0;
        mLeftToRightGradient = new LinearGradient(x0, 0f, x1, 0f,
@@ -438,7 +446,11 @@ public class KeyguardWidgetFrame extends FrameLayout {
        if (Float.compare(mOverScrollAmount, r) != 0) {
            mOverScrollAmount = r;
            mForegroundGradient = left ? mLeftToRightGradient : mRightToLeftGradient;
            mForegroundAlpha = (int) Math.round((0.85f * r * 255));
            mForegroundAlpha = (int) Math.round((0.5f * r * 255));

            // We bump up the alpha of the outline to hide the fact that the overlay is drawing
            // over the rounded part of the frame.
            setBackgroundAlpha(OUTLINE_ALPHA_MULTIPLIER + r * (1 - OUTLINE_ALPHA_MULTIPLIER));
            invalidate();
        }
    }
+5 −5
Original line number Diff line number Diff line
@@ -379,14 +379,14 @@ public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwit
        }
    }

    protected void enablePageLayers() {
    protected void enablePageContentLayers() {
        int children = getChildCount();
        for (int i = 0; i < children; i++) {
            getWidgetPageAt(i).enableHardwareLayersForContent();
        }
    }

    protected void disablePageLayers() {
    protected void disablePageContentLayers() {
        int children = getChildCount();
        for (int i = 0; i < children; i++) {
            getWidgetPageAt(i).disableHardwareLayersForContent();
@@ -506,7 +506,7 @@ public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwit
    @Override
    protected void onStartReordering() {
        super.onStartReordering();
        enablePageLayers();
        enablePageContentLayers();
        reorderStarting();
    }

@@ -635,14 +635,14 @@ public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwit
            @Override
            public void onAnimationStart(Animator animation) {
                if (show) {
                    enablePageLayers();
                    enablePageContentLayers();
                }
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                if (!show) {
                    disablePageLayers();
                    disablePageContentLayers();
                    if (mWidgetToResetAfterFadeOut != null) {
                        if (!(getWidgetPageAt(mCurrentPage) == mWidgetToResetAfterFadeOut &&
                                mViewStateManager.isChallengeShowing())) {