Dimming on an embedded TaskFragment vs. parent Task

Migrate the dimmer to TaskFragment and the dim surface
needs to be offset relative to its parent task.

Bug: 202379687
Test: verify dim in two pane
Change-Id: I95fe47ebc66d419b42c1da8cc8216773c295f1d1
This commit is contained in:
Louis Chang
2021-12-20 09:48:00 +08:00
parent d0f4400f2e
commit 9b5881335d
2 changed files with 30 additions and 1 deletions

View File

@@ -473,7 +473,6 @@ class Task extends TaskFragment {
// to layout without loading all the task snapshots
final PersistedTaskSnapshotData mLastTaskSnapshotData;
private Dimmer mDimmer = new Dimmer(this);
private final Rect mTmpDimBoundsRect = new Rect();
/** @see #setCanAffectSystemUiFlags */

View File

@@ -161,6 +161,8 @@ class TaskFragment extends WindowContainer<WindowContainer> {
*/
int mMinHeight;
Dimmer mDimmer = new Dimmer(this);
/** This task fragment will be removed when the cleanup of its children are done. */
private boolean mIsRemovalRequested;
@@ -2337,6 +2339,34 @@ class TaskFragment extends WindowContainer<WindowContainer> {
sendTaskFragmentVanished();
}
@Override
Dimmer getDimmer() {
// If the window is in an embedded TaskFragment, we want to dim at the TaskFragment.
if (asTask() == null) {
return mDimmer;
}
return super.getDimmer();
}
@Override
void prepareSurfaces() {
if (asTask() != null) {
super.prepareSurfaces();
return;
}
mDimmer.resetDimStates();
super.prepareSurfaces();
// Bounds need to be relative, as the dim layer is a child.
final Rect dimBounds = getBounds();
dimBounds.offsetTo(0 /* newLeft */, 0 /* newTop */);
if (mDimmer.updateDims(getPendingTransaction(), dimBounds)) {
scheduleAnimation();
}
}
@Override
boolean canBeAnimationTarget() {
return true;