=> The entire DragLayer is translated during the -1 transition which creates a janky looking edge at the top of the screen => By bumping the scrim up a level, we avoid this => Separated WorkspaceAndHotseatScrim into two separate scrims, since only part of the scrim needed to be bumped up to a level. Further, it was an overloaded class. => We had previously been implicitly relying on the fact that the scrim was rendered in the Workspace parent; we need to make sure to propagate workspace inavlidations to the container of the scrim. While things would still work without this change, it's more correct to leave it, as we no longer assume a hierarchy for functinoality. Bug: 178215332 Test: manual verification. See video in bug. Change-Id: I0a76ddf35ceea8c9635367f69380ef24f42e9479
75 lines
2.4 KiB
Java
75 lines
2.4 KiB
Java
/*
|
|
* Copyright (C) 2018 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.
|
|
*/
|
|
|
|
package com.android.launcher3.graphics;
|
|
|
|
import android.graphics.Canvas;
|
|
import android.graphics.Rect;
|
|
import android.graphics.Region;
|
|
import android.view.View;
|
|
|
|
import com.android.launcher3.CellLayout;
|
|
import com.android.launcher3.Workspace;
|
|
|
|
/**
|
|
* Scrim drawn during SpringLoaded State (ie. Drag and Drop). Darkens the workspace except for
|
|
* the focused CellLayout.
|
|
*/
|
|
public class WorkspaceDragScrim extends Scrim {
|
|
|
|
private final Rect mHighlightRect = new Rect();
|
|
|
|
private Workspace mWorkspace;
|
|
|
|
public WorkspaceDragScrim(View view) {
|
|
super(view);
|
|
onExtractedColorsChanged(mWallpaperColorInfo);
|
|
}
|
|
|
|
/**
|
|
* Set the workspace that this scrim is acting on
|
|
* @param workspace
|
|
*/
|
|
public void setWorkspace(Workspace workspace) {
|
|
mWorkspace = workspace;
|
|
mWorkspace.setWorkspaceDragScrim(this);
|
|
}
|
|
|
|
/**
|
|
* Cut out the focused paged of the Workspace and then draw the scrim
|
|
* @param canvas
|
|
*/
|
|
public void draw(Canvas canvas) {
|
|
// Draw the background below children.
|
|
if (mScrimAlpha > 0) {
|
|
// Update the scroll position first to ensure scrim cutout is in the right place.
|
|
mWorkspace.computeScrollWithoutInvalidation();
|
|
CellLayout currCellLayout = mWorkspace.getCurrentDragOverlappingLayout();
|
|
canvas.save();
|
|
if (currCellLayout != null && currCellLayout != mLauncher.getHotseat()) {
|
|
// Cut a hole in the darkening scrim on the page that should be highlighted, if any.
|
|
mLauncher.getDragLayer()
|
|
.getDescendantRectRelativeToSelf(currCellLayout, mHighlightRect);
|
|
canvas.clipRect(mHighlightRect, Region.Op.DIFFERENCE);
|
|
}
|
|
|
|
super.draw(canvas);
|
|
canvas.restore();
|
|
}
|
|
}
|
|
|
|
}
|