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

Commit 4d35ac30 authored by Zak Cohen's avatar Zak Cohen
Browse files

Allow Workspace Scrim to be colored per state

Make it possible to set the color of workspace scrim to a different color
per state. Motivated by making Overview Scrim and All Apps scrims different
colors.

Bug: 186253733
Test: Local build and flash
Change-Id: Id7c38ce3c9173308eedfcb7592ececa7bd6bf220
parent 3b1df8d7
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -22,7 +22,9 @@ import android.content.Context;

import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
import com.android.launcher3.R;
import com.android.launcher3.allapps.AllAppsContainerView;
import com.android.launcher3.util.Themes;

/**
 * Definition for AllApps state
@@ -92,7 +94,7 @@ public class AllAppsState extends LauncherState {
    }

    @Override
    public float getWorkspaceScrimAlpha(Launcher launcher) {
        return 1;
    public int getWorkspaceScrimColor(Launcher launcher) {
        return Themes.getAttrColor(launcher, R.attr.allAppsScrimColor);
    }
}
+3 −2
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import com.android.launcher3.LauncherState;
import com.android.launcher3.R;
import com.android.launcher3.Workspace;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.util.Themes;
import com.android.quickstep.SysUINavigationMode;
import com.android.quickstep.util.LayoutUtils;
import com.android.quickstep.views.RecentsView;
@@ -108,8 +109,8 @@ public class OverviewState extends LauncherState {
    }

    @Override
    public float getWorkspaceScrimAlpha(Launcher launcher) {
        return 1f;
    public int getWorkspaceScrimColor(Launcher launcher) {
        return Themes.getAttrColor(launcher, R.attr.overviewScrimColor);
    }

    @Override
+5 −5
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@

package com.android.launcher3.uioverrides.touchcontrollers;

import static com.android.launcher3.LauncherAnimUtils.VIEW_ALPHA;
import static com.android.launcher3.LauncherAnimUtils.VIEW_BACKGROUND_COLOR;
import static com.android.launcher3.LauncherAnimUtils.newCancelListener;
import static com.android.launcher3.LauncherState.ALL_APPS;
import static com.android.launcher3.LauncherState.HINT_STATE;
@@ -127,11 +127,11 @@ public class NoButtonNavbarToOverviewTouchController extends PortraitStatesTouch
        }

        if (mFromState == NORMAL && mToState == HINT_STATE) {
            mNormalToHintOverviewScrimAnimator = ObjectAnimator.ofFloat(
            mNormalToHintOverviewScrimAnimator = ObjectAnimator.ofArgb(
                    mLauncher.getScrimView(),
                    VIEW_ALPHA,
                    mFromState.getWorkspaceScrimAlpha(mLauncher),
                    mToState.getWorkspaceScrimAlpha(mLauncher));
                    VIEW_BACKGROUND_COLOR,
                    mFromState.getWorkspaceScrimColor(mLauncher),
                    mToState.getWorkspaceScrimColor(mLauncher));
        }
        mStartedOverview = false;
        mReachedOverview = false;
+2 −3
Original line number Diff line number Diff line
@@ -15,7 +15,6 @@
 */
package com.android.launcher3.uioverrides.touchcontrollers;

import static com.android.launcher3.LauncherAnimUtils.VIEW_ALPHA;
import static com.android.launcher3.LauncherAnimUtils.newCancelListener;
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.LauncherState.OVERVIEW;
@@ -232,8 +231,8 @@ public class NoButtonQuickSwitchTouchController implements TouchController,
        //   - OverviewScrim
        PendingAnimation xAnim = new PendingAnimation((long) (mXRange * 2));
        xAnim.setFloat(mRecentsView, ADJACENT_PAGE_OFFSET, scaleAndOffset[1], LINEAR);
        xAnim.setFloat(mLauncher.getScrimView(), VIEW_ALPHA,
                toState.getWorkspaceScrimAlpha(mLauncher), LINEAR);
        xAnim.setViewBackgroundColor(mLauncher.getScrimView(),
                toState.getWorkspaceScrimColor(mLauncher), LINEAR);
        mXOverviewAnim = xAnim.createPlaybackController();
        mXOverviewAnim.dispatchOnStart();

+18 −0
Original line number Diff line number Diff line
<?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");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:color="@android:color/system_neutral2_500" android:lStar="87" />
</selector>
Loading