Merge "Remove old caption bar before adding a new one" into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
c3322a827a
@@ -98,9 +98,11 @@ public class FreeformTaskTransitionObserver implements Transitions.TransitionObs
|
||||
|
||||
switch (change.getMode()) {
|
||||
case WindowManager.TRANSIT_OPEN:
|
||||
case WindowManager.TRANSIT_TO_FRONT:
|
||||
onOpenTransitionReady(change, startT, finishT);
|
||||
break;
|
||||
case WindowManager.TRANSIT_TO_FRONT:
|
||||
onToFrontTransitionReady(change, startT, finishT);
|
||||
break;
|
||||
case WindowManager.TRANSIT_CLOSE: {
|
||||
taskInfoList.add(change.getTaskInfo());
|
||||
onCloseTransitionReady(change, startT, finishT);
|
||||
@@ -138,6 +140,21 @@ public class FreeformTaskTransitionObserver implements Transitions.TransitionObs
|
||||
change.getTaskInfo(), startT, finishT);
|
||||
}
|
||||
|
||||
private void onToFrontTransitionReady(
|
||||
TransitionInfo.Change change,
|
||||
SurfaceControl.Transaction startT,
|
||||
SurfaceControl.Transaction finishT) {
|
||||
boolean exists = mWindowDecorViewModel.setupWindowDecorationForTransition(
|
||||
change.getTaskInfo(),
|
||||
startT,
|
||||
finishT);
|
||||
if (!exists) {
|
||||
// Window caption does not exist, create it
|
||||
mWindowDecorViewModel.createWindowDecoration(
|
||||
change.getTaskInfo(), change.getLeash(), startT, finishT);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTransitionStarting(@NonNull IBinder transition) {}
|
||||
|
||||
|
||||
@@ -105,6 +105,11 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel {
|
||||
SurfaceControl.Transaction startT,
|
||||
SurfaceControl.Transaction finishT) {
|
||||
if (!shouldShowWindowDecor(taskInfo)) return false;
|
||||
CaptionWindowDecoration oldDecoration = mWindowDecorByTaskId.get(taskInfo.taskId);
|
||||
if (oldDecoration != null) {
|
||||
// close the old decoration if it exists to avoid two window decorations being added
|
||||
oldDecoration.close();
|
||||
}
|
||||
final CaptionWindowDecoration windowDecoration = new CaptionWindowDecoration(
|
||||
mContext,
|
||||
mDisplayController,
|
||||
@@ -141,23 +146,25 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupWindowDecorationForTransition(
|
||||
public boolean setupWindowDecorationForTransition(
|
||||
RunningTaskInfo taskInfo,
|
||||
SurfaceControl.Transaction startT,
|
||||
SurfaceControl.Transaction finishT) {
|
||||
final CaptionWindowDecoration decoration = mWindowDecorByTaskId.get(taskInfo.taskId);
|
||||
if (decoration == null) return;
|
||||
if (decoration == null) return false;
|
||||
|
||||
decoration.relayout(taskInfo, startT, finishT);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroyWindowDecoration(RunningTaskInfo taskInfo) {
|
||||
public boolean destroyWindowDecoration(RunningTaskInfo taskInfo) {
|
||||
final CaptionWindowDecoration decoration =
|
||||
mWindowDecorByTaskId.removeReturnOld(taskInfo.taskId);
|
||||
if (decoration == null) return;
|
||||
if (decoration == null) return false;
|
||||
|
||||
decoration.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
private class CaptionTouchEventListener implements
|
||||
|
||||
@@ -44,7 +44,7 @@ public interface WindowDecorViewModel {
|
||||
* @param taskSurface the surface of the task
|
||||
* @param startT the start transaction to be applied before the transition
|
||||
* @param finishT the finish transaction to restore states after the transition
|
||||
* @return the window decoration object
|
||||
* @return {@code true} if window decoration was created, {@code false} otherwise
|
||||
*/
|
||||
boolean createWindowDecoration(
|
||||
ActivityManager.RunningTaskInfo taskInfo,
|
||||
@@ -66,8 +66,9 @@ public interface WindowDecorViewModel {
|
||||
*
|
||||
* @param startT the start transaction to be applied before the transition
|
||||
* @param finishT the finish transaction to restore states after the transition
|
||||
* @return {@code true} if window decoration exists, {@code false} otherwise
|
||||
*/
|
||||
void setupWindowDecorationForTransition(
|
||||
boolean setupWindowDecorationForTransition(
|
||||
ActivityManager.RunningTaskInfo taskInfo,
|
||||
SurfaceControl.Transaction startT,
|
||||
SurfaceControl.Transaction finishT);
|
||||
@@ -76,6 +77,7 @@ public interface WindowDecorViewModel {
|
||||
* Destroys the window decoration of the give task.
|
||||
*
|
||||
* @param taskInfo the info of the task
|
||||
* @return {@code true} if window decoration was destroyed, {@code false} otherwise
|
||||
*/
|
||||
void destroyWindowDecoration(ActivityManager.RunningTaskInfo taskInfo);
|
||||
boolean destroyWindowDecoration(ActivityManager.RunningTaskInfo taskInfo);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user