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

Commit 5d1873a8 authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Removing scrim overdraw

> Moving all the scrims to draglayer to avoid creating multiple layers during
  various animations
> Removing sys-ui scrim in various states which alread have a background scrim

Bug: 74556464
Bug: 78585335
Change-Id: I8a3fd34ed440f3c7d2e19b3cdb4b72723c535602
parent 522e388b
Loading
Loading
Loading
Loading
+0 −1
Original line number Original line Diff line number Diff line
@@ -18,7 +18,6 @@
    android:id="@+id/launcher"
    android:id="@+id/launcher"
    android:layout_width="match_parent"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_height="match_parent"
    android:background="?attr/workspaceStatusBarScrim"
    android:fitsSystemWindows="true">
    android:fitsSystemWindows="true">


    <com.android.launcher3.dragndrop.DragLayer
    <com.android.launcher3.dragndrop.DragLayer
+11 −58
Original line number Original line Diff line number Diff line
@@ -25,9 +25,7 @@ import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.logging.LoggerUtils.newContainerTarget;
import static com.android.launcher3.logging.LoggerUtils.newContainerTarget;


import android.animation.Animator;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.animation.ValueAnimator;
import android.annotation.TargetApi;
import android.annotation.TargetApi;
import android.app.ActivityOptions;
import android.app.ActivityOptions;
@@ -220,9 +218,6 @@ public class Launcher extends BaseDraggingActivity
    private IconCache mIconCache;
    private IconCache mIconCache;
    private LauncherAccessibilityDelegate mAccessibilityDelegate;
    private LauncherAccessibilityDelegate mAccessibilityDelegate;


    private ObjectAnimator mScrimAnimator;
    private boolean mShouldFadeInScrim;

    private PopupDataProvider mPopupDataProvider;
    private PopupDataProvider mPopupDataProvider;


    private int mSynchronouslyBoundPage = PagedView.INVALID_PAGE;
    private int mSynchronouslyBoundPage = PagedView.INVALID_PAGE;
@@ -244,12 +239,6 @@ public class Launcher extends BaseDraggingActivity


    private RotationHelper mRotationHelper;
    private RotationHelper mRotationHelper;


    // Used to keep track of the swipe up state
    private SharedPreferences.OnSharedPreferenceChangeListener mSharedPrefsListener =
            (sharedPreferences, s) -> {
                mDragLayer.setup(mDragController);
            };

    @Override
    @Override
    protected void onCreate(Bundle savedInstanceState) {
    protected void onCreate(Bundle savedInstanceState) {
        if (DEBUG_STRICT_MODE) {
        if (DEBUG_STRICT_MODE) {
@@ -277,7 +266,6 @@ public class Launcher extends BaseDraggingActivity
        initDeviceProfile(app.getInvariantDeviceProfile());
        initDeviceProfile(app.getInvariantDeviceProfile());


        mSharedPrefs = Utilities.getPrefs(this);
        mSharedPrefs = Utilities.getPrefs(this);
        mSharedPrefs.registerOnSharedPreferenceChangeListener(mSharedPrefsListener);
        mIconCache = app.getIconCache();
        mIconCache = app.getIconCache();
        mAccessibilityDelegate = new LauncherAccessibilityDelegate(this);
        mAccessibilityDelegate = new LauncherAccessibilityDelegate(this);


@@ -336,11 +324,7 @@ public class Launcher extends BaseDraggingActivity
        getRootView().dispatchInsets();
        getRootView().dispatchInsets();


        // Listen for broadcasts
        // Listen for broadcasts
        IntentFilter filter = new IntentFilter();
        registerReceiver(mScreenOffReceiver, new IntentFilter(Intent.ACTION_SCREEN_OFF));
        filter.addAction(Intent.ACTION_SCREEN_OFF);
        filter.addAction(Intent.ACTION_USER_PRESENT); // When the device wakes up + keyguard is gone
        registerReceiver(mReceiver, filter);
        mShouldFadeInScrim = true;


        getSystemUiController().updateUiState(SystemUiController.UI_STATE_BASE_WINDOW,
        getSystemUiController().updateUiState(SystemUiController.UI_STATE_BASE_WINDOW,
                Themes.getAttrBoolean(this, R.attr.isWorkspaceDarkText));
                Themes.getAttrBoolean(this, R.attr.isWorkspaceDarkText));
@@ -361,9 +345,7 @@ public class Launcher extends BaseDraggingActivity
            initDeviceProfile(mDeviceProfile.inv);
            initDeviceProfile(mDeviceProfile.inv);
            dispatchDeviceProfileChanged();
            dispatchDeviceProfileChanged();
            reapplyUi();
            reapplyUi();

            mDragLayer.recreateControllers();
            // Recreate touch controllers
            mDragLayer.setup(mDragController);


            // TODO: We can probably avoid rebind when only screen size changed.
            // TODO: We can probably avoid rebind when only screen size changed.
            rebindModel();
            rebindModel();
@@ -764,25 +746,6 @@ public class Launcher extends BaseDraggingActivity
        }
        }
        mAppWidgetHost.setListenIfResumed(true);
        mAppWidgetHost.setListenIfResumed(true);
        NotificationListener.setNotificationsChangedListener(mPopupDataProvider);
        NotificationListener.setNotificationsChangedListener(mPopupDataProvider);

        if (mShouldFadeInScrim && mLauncherView.getBackground() != null) {
            if (mScrimAnimator != null) {
                mScrimAnimator.cancel();
            }
            mLauncherView.getBackground().setAlpha(0);
            mScrimAnimator = ObjectAnimator.ofInt(mLauncherView.getBackground(),
                    LauncherAnimUtils.DRAWABLE_ALPHA, 0, 255);
            mScrimAnimator.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    mScrimAnimator = null;
                }
            });
            mScrimAnimator.setDuration(600);
            mScrimAnimator.setStartDelay(getWindow().getTransitionBackgroundFadeDuration());
            mScrimAnimator.start();
        }
        mShouldFadeInScrim = false;
        UiFactory.onStart(this);
        UiFactory.onStart(this);
    }
    }


@@ -939,9 +902,8 @@ public class Launcher extends BaseDraggingActivity
                | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
                | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);


        // Setup the drag layer
        // Setup the drag layer
        Runnable setupDragLayer = () -> mDragLayer.setup(mDragController);
        mDragLayer.setup(mDragController, mWorkspace);
        UiFactory.setOnTouchControllersChangedListener(this, setupDragLayer);
        UiFactory.setOnTouchControllersChangedListener(this, mDragLayer::recreateControllers);
        setupDragLayer.run();


        mWorkspace.setup(mDragController);
        mWorkspace.setup(mDragController);
        // Until the workspace is bound, ensure that we keep the wallpaper offset locked to the
        // Until the workspace is bound, ensure that we keep the wallpaper offset locked to the
@@ -1118,22 +1080,14 @@ public class Launcher extends BaseDraggingActivity
        hostView.setOnFocusChangeListener(mFocusHandler);
        hostView.setOnFocusChangeListener(mFocusHandler);
    }
    }


    private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
    private final BroadcastReceiver mScreenOffReceiver = new BroadcastReceiver() {
        @Override
        @Override
        public void onReceive(Context context, Intent intent) {
        public void onReceive(Context context, Intent intent) {
            final String action = intent.getAction();
            if (Intent.ACTION_SCREEN_OFF.equals(action)) {
            // Reset AllApps to its initial state only if we are not in the middle of
            // Reset AllApps to its initial state only if we are not in the middle of
            // processing a multi-step drop
            // processing a multi-step drop
                if (mAppsView != null && mPendingRequestArgs == null) {
            if (mPendingRequestArgs == null) {
                mStateManager.goToState(NORMAL);
                mStateManager.goToState(NORMAL);
            }
            }
                mShouldFadeInScrim = true;
            } else if (Intent.ACTION_USER_PRESENT.equals(action)) {
                // ACTION_USER_PRESENT is sent after onStart/onResume. This covers the case where
                // the user unlocked and the Launcher is not in the foreground.
                mShouldFadeInScrim = false;
            }
        }
        }
    };
    };


@@ -1267,7 +1221,7 @@ public class Launcher extends BaseDraggingActivity
                }
                }


                // Reset the apps view
                // Reset the apps view
                if (!alreadyOnHome && mAppsView != null) {
                if (!alreadyOnHome) {
                    mAppsView.reset(isStarted() /* animate */);
                    mAppsView.reset(isStarted() /* animate */);
                }
                }


@@ -1336,7 +1290,7 @@ public class Launcher extends BaseDraggingActivity
    public void onDestroy() {
    public void onDestroy() {
        super.onDestroy();
        super.onDestroy();


        unregisterReceiver(mReceiver);
        unregisterReceiver(mScreenOffReceiver);
        mWorkspace.removeFolderListeners();
        mWorkspace.removeFolderListeners();


        UiFactory.setOnTouchControllersChangedListener(this, null);
        UiFactory.setOnTouchControllersChangedListener(this, null);
@@ -1349,7 +1303,6 @@ public class Launcher extends BaseDraggingActivity
            LauncherAppState.getInstance(this).setLauncher(null);
            LauncherAppState.getInstance(this).setLauncher(null);
        }
        }
        mRotationHelper.destroy();
        mRotationHelper.destroy();
        mSharedPrefs.unregisterOnSharedPreferenceChangeListener(mSharedPrefsListener);


        try {
        try {
            mAppWidgetHost.stopListening();
            mAppWidgetHost.stopListening();
+0 −4
Original line number Original line Diff line number Diff line
@@ -14,8 +14,6 @@ import android.util.AttributeSet;
import android.view.View;
import android.view.View;
import android.view.ViewDebug;
import android.view.ViewDebug;


import com.android.launcher3.util.Themes;

public class LauncherRootView extends InsettableFrameLayout {
public class LauncherRootView extends InsettableFrameLayout {


    private final Launcher mLauncher;
    private final Launcher mLauncher;
@@ -103,8 +101,6 @@ public class LauncherRootView extends InsettableFrameLayout {
        if (!insets.equals(mInsets)) {
        if (!insets.equals(mInsets)) {
            super.setInsets(insets);
            super.setInsets(insets);
        }
        }
        setBackground(insets.top == 0 ? null
                : Themes.getAttrDrawable(getContext(), R.attr.workspaceStatusBarScrim));
    }
    }


    public void dispatchInsets() {
    public void dispatchInsets() {
+7 −2
Original line number Original line Diff line number Diff line
@@ -61,6 +61,7 @@ public class LauncherState {
    protected static final int FLAG_DISABLE_INTERACTION = 1 << 6;
    protected static final int FLAG_DISABLE_INTERACTION = 1 << 6;
    protected static final int FLAG_OVERVIEW_UI = 1 << 7;
    protected static final int FLAG_OVERVIEW_UI = 1 << 7;
    protected static final int FLAG_HIDE_BACK_BUTTON = 1 << 8;
    protected static final int FLAG_HIDE_BACK_BUTTON = 1 << 8;
    protected static final int FLAG_HAS_SYS_UI_SCRIM = 1 << 9;


    protected static final PageAlphaProvider DEFAULT_ALPHA_PROVIDER =
    protected static final PageAlphaProvider DEFAULT_ALPHA_PROVIDER =
            new PageAlphaProvider(ACCEL_2) {
            new PageAlphaProvider(ACCEL_2) {
@@ -75,8 +76,9 @@ public class LauncherState {
    /**
    /**
     * TODO: Create a separate class for NORMAL state.
     * TODO: Create a separate class for NORMAL state.
     */
     */
    public static final LauncherState NORMAL = new LauncherState(0, ContainerType.WORKSPACE,
    public static final LauncherState NORMAL = new LauncherState(0, ContainerType.WORKSPACE, 0,
            0, FLAG_DISABLE_RESTORE | FLAG_WORKSPACE_ICONS_CAN_BE_DRAGGED | FLAG_HIDE_BACK_BUTTON);
            FLAG_DISABLE_RESTORE | FLAG_WORKSPACE_ICONS_CAN_BE_DRAGGED | FLAG_HIDE_BACK_BUTTON |
            FLAG_HAS_SYS_UI_SCRIM);


    /**
    /**
     * Various Launcher states arranged in the increasing order of UI layers
     * Various Launcher states arranged in the increasing order of UI layers
@@ -147,6 +149,8 @@ public class LauncherState {
     */
     */
    public final boolean hideBackButton;
    public final boolean hideBackButton;


    public final boolean hasSysUiScrim;

    public LauncherState(int id, int containerType, int transitionDuration, int flags) {
    public LauncherState(int id, int containerType, int transitionDuration, int flags) {
        this.containerType = containerType;
        this.containerType = containerType;
        this.transitionDuration = transitionDuration;
        this.transitionDuration = transitionDuration;
@@ -162,6 +166,7 @@ public class LauncherState {
        this.disableInteraction = (flags & FLAG_DISABLE_INTERACTION) != 0;
        this.disableInteraction = (flags & FLAG_DISABLE_INTERACTION) != 0;
        this.overviewUi = (flags & FLAG_OVERVIEW_UI) != 0;
        this.overviewUi = (flags & FLAG_OVERVIEW_UI) != 0;
        this.hideBackButton = (flags & FLAG_HIDE_BACK_BUTTON) != 0;
        this.hideBackButton = (flags & FLAG_HIDE_BACK_BUTTON) != 0;
        this.hasSysUiScrim = (flags & FLAG_HAS_SYS_UI_SCRIM) != 0;


        this.ordinal = id;
        this.ordinal = id;
        sAllStates[id] = this;
        sAllStates[id] = this;
+1 −6
Original line number Original line Diff line number Diff line
@@ -75,8 +75,6 @@ import com.android.launcher3.folder.FolderIcon;
import com.android.launcher3.folder.PreviewBackground;
import com.android.launcher3.folder.PreviewBackground;
import com.android.launcher3.graphics.DragPreviewProvider;
import com.android.launcher3.graphics.DragPreviewProvider;
import com.android.launcher3.graphics.PreloadIconDrawable;
import com.android.launcher3.graphics.PreloadIconDrawable;
import com.android.launcher3.graphics.ViewScrim;
import com.android.launcher3.graphics.WorkspaceAndHotseatScrim;
import com.android.launcher3.pageindicators.WorkspacePageIndicator;
import com.android.launcher3.pageindicators.WorkspacePageIndicator;
import com.android.launcher3.popup.PopupContainerWithArrow;
import com.android.launcher3.popup.PopupContainerWithArrow;
import com.android.launcher3.shortcuts.ShortcutDragPreviewProvider;
import com.android.launcher3.shortcuts.ShortcutDragPreviewProvider;
@@ -279,9 +277,6 @@ public class Workspace extends PagedView<WorkspacePageIndicator>


        // Disable multitouch across the workspace/all apps/customize tray
        // Disable multitouch across the workspace/all apps/customize tray
        setMotionEventSplittingEnabled(true);
        setMotionEventSplittingEnabled(true);

        // Attach a scrim
        new WorkspaceAndHotseatScrim(this).attach();
        setOnTouchListener(new WorkspaceTouchListener(mLauncher, this));
        setOnTouchListener(new WorkspaceTouchListener(mLauncher, this));
    }
    }


@@ -2152,7 +2147,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
        }
        }
        // Invalidating the scrim will also force this CellLayout
        // Invalidating the scrim will also force this CellLayout
        // to be invalidated so that it is highlighted if necessary.
        // to be invalidated so that it is highlighted if necessary.
        ViewScrim.get(this).invalidate();
        mLauncher.getDragLayer().getScrim().invalidate();
    }
    }


    public CellLayout getCurrentDragOverlappingLayout() {
    public CellLayout getCurrentDragOverlappingLayout() {
Loading