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

Commit 99c4becf authored by vadimt's avatar vadimt
Browse files

Switch ScrimView to use view alpha

Using view alpha instead of background paint’s color alpha component
will make ScrimView alpha and visibility available to View Capture and
any analysis tool that’s based on it.

The change makes ScimView background completely opaque, and makes Scrim
View use variable alpha instead of always-1.0 alpha.

Changes some code that depends on the old way of representing ScrimView
opacity.

Also moves “updateSysUiColors()” call in ScrimView#setBackgroundColor
below updating alpha and background color so the new values are used in
the calculations.

Bug: 282991128
Test: local, presubmit
Change-Id: I6ca089bae55adfb9c3140d06da4fbb3b08f2bf8b
parent fde9d30f
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@
package com.android.launcher3.uioverrides.touchcontrollers;

import static android.view.MotionEvent.ACTION_DOWN;
import static android.view.MotionEvent.ACTION_MOVE;

import static com.android.app.animation.Interpolators.ACCELERATE_0_75;
import static com.android.app.animation.Interpolators.DECELERATE_3;
@@ -262,7 +261,7 @@ public class NoButtonQuickSwitchTouchController implements TouchController,
        xAnim.setFloat(mRecentsView, ADJACENT_PAGE_HORIZONTAL_OFFSET, scaleAndOffset[1], LINEAR);
        // Use QuickSwitchState instead of OverviewState to determine scrim color,
        // since we need to take potential taskbar into account.
        xAnim.setViewBackgroundColor(mLauncher.getScrimView(),
        xAnim.setScrimViewBackgroundColor(mLauncher.getScrimView(),
                QUICK_SWITCH_FROM_HOME.getWorkspaceScrimColor(mLauncher), LINEAR);
        if (mRecentsView.getTaskViewCount() == 0) {
            xAnim.addFloat(mRecentsView, CONTENT_ALPHA, 0f, 1f, LINEAR);
+1 −1
Original line number Diff line number Diff line
@@ -114,7 +114,7 @@ public class FallbackRecentsStateController implements StateHandler<RecentsState
        setter.setFloat(mRecentsView, TASK_THUMBNAIL_SPLASH_ALPHA,
                state.showTaskThumbnailSplash() ? 1f : 0f, INSTANT);

        setter.setViewBackgroundColor(mActivity.getScrimView(), state.getScrimColor(mActivity),
        setter.setScrimViewBackgroundColor(mActivity.getScrimView(), state.getScrimColor(mActivity),
                config.getInterpolator(ANIM_SCRIM_FADE, LINEAR));

        RecentsState currentState = mActivity.getStateManager().getState();
+5 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import android.widget.ImageView;
import android.widget.TextView;

import com.android.launcher3.util.MultiScalePropertyFactory;
import com.android.launcher3.views.ScrimView;

public class LauncherAnimUtils {
    /**
@@ -194,6 +195,10 @@ public class LauncherAnimUtils {

                @Override
                public Integer get(View view) {
                    if (view instanceof ScrimView) {
                        return ((ScrimView) view).getBackgroundColor();
                    }

                    if (!(view.getBackground() instanceof ColorDrawable)) {
                        return Color.TRANSPARENT;
                    }
+1 −1
Original line number Diff line number Diff line
@@ -199,7 +199,7 @@ public class WorkspaceStateTransitionAnimation {
        propertySetter.setFloat(sysUiScrim, SYSUI_PROGRESS,
                state.hasFlag(FLAG_HAS_SYS_UI_SCRIM) ? 1 : 0, LINEAR);

        propertySetter.setViewBackgroundColor(mLauncher.getScrimView(),
        propertySetter.setScrimViewBackgroundColor(mLauncher.getScrimView(),
                state.getWorkspaceScrimColor(mLauncher),
                config.getInterpolator(ANIM_SCRIM_FADE, ACCELERATE_2));
    }
+5 −4
Original line number Diff line number Diff line
@@ -24,13 +24,14 @@ import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.TimeInterpolator;
import android.animation.ValueAnimator;
import android.graphics.drawable.ColorDrawable;
import android.util.FloatProperty;
import android.util.IntProperty;
import android.view.View;

import androidx.annotation.NonNull;

import com.android.launcher3.views.ScrimView;

import java.util.function.Consumer;

/**
@@ -62,9 +63,9 @@ public class AnimatedPropertySetter extends PropertySetter {
    }

    @Override
    public Animator setViewBackgroundColor(View view, int color, TimeInterpolator interpolator) {
        if (view == null || (view.getBackground() instanceof ColorDrawable
                && ((ColorDrawable) view.getBackground()).getColor() == color)) {
    public Animator setScrimViewBackgroundColor(ScrimView view, int color,
            TimeInterpolator interpolator) {
        if (view == null || view.getBackgroundColor() == color) {
            return NO_OP;
        }
        ObjectAnimator anim = ObjectAnimator.ofArgb(view, VIEW_BACKGROUND_COLOR, color);
Loading