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

Commit b605d1d7 authored by Samuel Fufa's avatar Samuel Fufa Committed by Android (Google) Code Review
Browse files

Merge "Fix header protection interactions" into sc-dev

parents 3f4333bf 0a709374
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
<?xml version="1.0" encoding="utf-8"?><!--
  ~ Copyright (C) 2021 The Android Open Source Project
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,8 +14,7 @@
  ~ limitations under the License.
-->

<com.android.launcher3.workprofile.PersonalWorkSlidingTabStrip
    xmlns:android="http://schemas.android.com/apk/res/android"
<com.android.launcher3.workprofile.PersonalWorkSlidingTabStrip xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/tabs"
    android:layout_width="match_parent"
    android:layout_height="@dimen/all_apps_header_pill_height"
+1 −0
Original line number Diff line number Diff line
@@ -93,6 +93,7 @@
    <dimen name="all_apps_background_canvas_height">475dp</dimen>
    <dimen name="all_apps_header_pill_height">36dp</dimen>
    <dimen name="all_apps_header_pill_corner_radius">18dp</dimen>
    <dimen name="all_apps_header_pills_width">320dp</dimen>
    <dimen name="all_apps_header_tab_height">48dp</dimen>
    <dimen name="all_apps_tabs_indicator_height">2dp</dimen>
    <dimen name="all_apps_header_top_padding">36dp</dimen>
+6 −3
Original line number Diff line number Diff line
@@ -720,7 +720,7 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
        mHeaderPaint.setColor(mHeaderColor);
        mHeaderPaint.setAlpha((int) (getAlpha() * Color.alpha(mHeaderColor)));
        if (mHeaderPaint.getColor() != mScrimColor && mHeaderPaint.getColor() != 0) {
            canvas.drawRect(0, 0, getWidth(), mHeaderTopPadding + getTranslationY(),
            canvas.drawRect(0, 0, getWidth(), mSearchContainer.getTop() + getTranslationY(),
                    mHeaderPaint);
        }
    }
@@ -830,10 +830,13 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo

    protected void updateHeaderScroll(int scrolledOffset) {
        float prog = Math.max(0, Math.min(1, (float) scrolledOffset / mHeaderThreshold));
        int headerColor = ColorUtils.setAlphaComponent(mHeaderProtectionColor, (int) (prog * 255));
        int viewBG = ColorUtils.blendARGB(mScrimColor, mHeaderProtectionColor, prog);
        int headerColor = ColorUtils.setAlphaComponent(viewBG,
                (int) (getSearchView().getAlpha() * 255));
        if (headerColor != mHeaderColor) {
            mHeaderColor = headerColor;
            getSearchView().setBackgroundColor(mHeaderColor);
            getSearchView().setBackgroundColor(viewBG);
            getFloatingHeaderView().setHeaderColor(viewBG);
            invalidateHeader();
        }
    }
+44 −19
Original line number Diff line number Diff line
@@ -17,6 +17,9 @@ package com.android.launcher3.allapps;

import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.Rect;
import android.util.ArrayMap;
@@ -50,7 +53,9 @@ public class FloatingHeaderView extends LinearLayout implements
    private final Rect mClip = new Rect(0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE);
    private final ValueAnimator mAnimator = ValueAnimator.ofInt(0, 0);
    private final Point mTempOffset = new Point();
    private final RecyclerView.OnScrollListener mOnScrollListener = new RecyclerView.OnScrollListener() {
    private final Paint mBGPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    private final RecyclerView.OnScrollListener mOnScrollListener =
            new RecyclerView.OnScrollListener() {
                @Override
                public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
                }
@@ -80,9 +85,10 @@ public class FloatingHeaderView extends LinearLayout implements
    private AllAppsRecyclerView mWorkRV;
    private AllAppsRecyclerView mCurrentRV;
    private ViewGroup mParent;
    private boolean mHeaderCollapsed;
    public boolean mHeaderCollapsed;
    private int mSnappedScrolledY;
    private int mTranslationY;
    private int mHeaderColor;

    private boolean mForwardToRecyclerView;

@@ -262,6 +268,7 @@ public class FloatingHeaderView extends LinearLayout implements
                }
            } else {
                mHeaderCollapsed = false;
                invalidate();
            }
            mTranslationY = currentScrollY;
        } else if (!mHeaderCollapsed) {
@@ -274,10 +281,28 @@ public class FloatingHeaderView extends LinearLayout implements
            } else if (mTranslationY <= -mMaxTranslation) { // hide or stay hidden
                mHeaderCollapsed = true;
                mSnappedScrolledY = -mMaxTranslation;
                invalidate();
            }
        }
    }

    /**
     * Set current header protection background color
     */
    public void setHeaderColor(int color) {
        mHeaderColor = color;
        invalidate();
    }

    @Override
    protected void dispatchDraw(Canvas canvas) {
        if (mHeaderCollapsed && mHeaderColor != Color.TRANSPARENT) {
            mBGPaint.setColor(mHeaderColor);
            canvas.drawRect(0, 0, getWidth(), getHeight() + mTranslationY, mBGPaint);
        }
        super.dispatchDraw(canvas);
    }

    protected void applyVerticalMove() {
        int uncappedTranslationY = mTranslationY;
        mTranslationY = Math.max(mTranslationY, -mMaxTranslation);
+0 −10
Original line number Diff line number Diff line
@@ -29,14 +29,12 @@ import androidx.annotation.Nullable;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.pageindicators.PageIndicator;
import com.android.launcher3.util.Themes;

/**
 * Supports two indicator colors, dedicated for personal and work tabs.
 */
public class PersonalWorkSlidingTabStrip extends LinearLayout implements PageIndicator {
    private final Paint mSelectedIndicatorPaint;
    private final Paint mDividerPaint;

    private int mSelectedIndicatorHeight;
    private final int mSelectedIndicatorRadius;
@@ -52,7 +50,6 @@ public class PersonalWorkSlidingTabStrip extends LinearLayout implements PageInd

    public PersonalWorkSlidingTabStrip(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        setOrientation(HORIZONTAL);
        setWillNotDraw(false);

        mSelectedIndicatorHeight =
@@ -64,11 +61,6 @@ public class PersonalWorkSlidingTabStrip extends LinearLayout implements PageInd
        mSelectedIndicatorPaint = new Paint();
        mSelectedIndicatorPaint.setColor(context.getColor(R.color.all_apps_tab_bg));

        mDividerPaint = new Paint();
        mDividerPaint.setColor(Themes.getAttrColor(context, android.R.attr.colorControlHighlight));
        mDividerPaint.setStrokeWidth(
                getResources().getDimensionPixelSize(R.dimen.all_apps_divider_height));

        mIsRtl = Utilities.isRtl(getResources());
    }

@@ -120,8 +112,6 @@ public class PersonalWorkSlidingTabStrip extends LinearLayout implements PageInd
    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);

        float y = getHeight() - mDividerPaint.getStrokeWidth();
        canvas.drawRoundRect(mIndicatorLeft, getHeight() - mSelectedIndicatorHeight,
                mIndicatorRight, getHeight(), mSelectedIndicatorRadius, mSelectedIndicatorRadius,
                mSelectedIndicatorPaint);