Merge "Restart Dialog reacts to Light/Dark theme" into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
99dc404b91
@@ -444,6 +444,7 @@ public class TaskInfo {
|
|||||||
&& Objects.equals(shouldDockBigOverlays, that.shouldDockBigOverlays)
|
&& Objects.equals(shouldDockBigOverlays, that.shouldDockBigOverlays)
|
||||||
&& Objects.equals(displayCutoutInsets, that.displayCutoutInsets)
|
&& Objects.equals(displayCutoutInsets, that.displayCutoutInsets)
|
||||||
&& getWindowingMode() == that.getWindowingMode()
|
&& getWindowingMode() == that.getWindowingMode()
|
||||||
|
&& configuration.uiMode == that.configuration.uiMode
|
||||||
&& Objects.equals(taskDescription, that.taskDescription)
|
&& Objects.equals(taskDescription, that.taskDescription)
|
||||||
&& isFocused == that.isFocused
|
&& isFocused == that.isFocused
|
||||||
&& isVisible == that.isVisible
|
&& isVisible == that.isVisible
|
||||||
@@ -472,6 +473,7 @@ public class TaskInfo {
|
|||||||
.equals(that.configuration.windowConfiguration.getBounds()))
|
.equals(that.configuration.windowConfiguration.getBounds()))
|
||||||
&& (!hasCompatUI() || configuration.getLayoutDirection()
|
&& (!hasCompatUI() || configuration.getLayoutDirection()
|
||||||
== that.configuration.getLayoutDirection())
|
== that.configuration.getLayoutDirection())
|
||||||
|
&& (!hasCompatUI() || configuration.uiMode == that.configuration.uiMode)
|
||||||
&& (!hasCompatUI() || isVisible == that.isVisible);
|
&& (!hasCompatUI() || isVisible == that.isVisible);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -126,14 +126,12 @@ public class CompatUIController implements OnDisplaysChangedListener,
|
|||||||
private final Lazy<Transitions> mTransitionsLazy;
|
private final Lazy<Transitions> mTransitionsLazy;
|
||||||
private final DockStateReader mDockStateReader;
|
private final DockStateReader mDockStateReader;
|
||||||
private final CompatUIConfiguration mCompatUIConfiguration;
|
private final CompatUIConfiguration mCompatUIConfiguration;
|
||||||
|
|
||||||
private CompatUICallback mCallback;
|
|
||||||
|
|
||||||
// Only show each hint once automatically in the process life.
|
// Only show each hint once automatically in the process life.
|
||||||
private final CompatUIHintsState mCompatUIHintsState;
|
private final CompatUIHintsState mCompatUIHintsState;
|
||||||
|
|
||||||
private final CompatUIShellCommandHandler mCompatUIShellCommandHandler;
|
private final CompatUIShellCommandHandler mCompatUIShellCommandHandler;
|
||||||
|
|
||||||
|
private CompatUICallback mCallback;
|
||||||
|
|
||||||
// Indicates if the keyguard is currently showing, in which case compat UIs shouldn't
|
// Indicates if the keyguard is currently showing, in which case compat UIs shouldn't
|
||||||
// be shown.
|
// be shown.
|
||||||
private boolean mKeyguardShowing;
|
private boolean mKeyguardShowing;
|
||||||
@@ -372,19 +370,20 @@ public class CompatUIController implements OnDisplaysChangedListener,
|
|||||||
RestartDialogWindowManager layout =
|
RestartDialogWindowManager layout =
|
||||||
mTaskIdToRestartDialogWindowManagerMap.get(taskInfo.taskId);
|
mTaskIdToRestartDialogWindowManagerMap.get(taskInfo.taskId);
|
||||||
if (layout != null) {
|
if (layout != null) {
|
||||||
// TODO(b/266262111) Handle theme change when taskListener changes
|
if (layout.needsToBeRecreated(taskInfo, taskListener)) {
|
||||||
if (layout.getTaskListener() != taskListener) {
|
|
||||||
mSetOfTaskIdsShowingRestartDialog.remove(taskInfo.taskId);
|
|
||||||
}
|
|
||||||
layout.setRequestRestartDialog(
|
|
||||||
mSetOfTaskIdsShowingRestartDialog.contains(taskInfo.taskId));
|
|
||||||
// UI already exists, update the UI layout.
|
|
||||||
if (!layout.updateCompatInfo(taskInfo, taskListener,
|
|
||||||
showOnDisplay(layout.getDisplayId()))) {
|
|
||||||
// The layout is no longer eligible to be shown, remove from active layouts.
|
|
||||||
mTaskIdToRestartDialogWindowManagerMap.remove(taskInfo.taskId);
|
mTaskIdToRestartDialogWindowManagerMap.remove(taskInfo.taskId);
|
||||||
|
layout.release();
|
||||||
|
} else {
|
||||||
|
layout.setRequestRestartDialog(
|
||||||
|
mSetOfTaskIdsShowingRestartDialog.contains(taskInfo.taskId));
|
||||||
|
// UI already exists, update the UI layout.
|
||||||
|
if (!layout.updateCompatInfo(taskInfo, taskListener,
|
||||||
|
showOnDisplay(layout.getDisplayId()))) {
|
||||||
|
// The layout is no longer eligible to be shown, remove from active layouts.
|
||||||
|
mTaskIdToRestartDialogWindowManagerMap.remove(taskInfo.taskId);
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
// Create a new UI layout.
|
// Create a new UI layout.
|
||||||
final Context context = getOrCreateDisplayContext(taskInfo.displayId);
|
final Context context = getOrCreateDisplayContext(taskInfo.displayId);
|
||||||
|
|||||||
@@ -151,7 +151,6 @@ public abstract class CompatUIWindowManagerAbstract extends WindowlessWindowMana
|
|||||||
@Override
|
@Override
|
||||||
public void setConfiguration(Configuration configuration) {
|
public void setConfiguration(Configuration configuration) {
|
||||||
super.setConfiguration(configuration);
|
super.setConfiguration(configuration);
|
||||||
// TODO(b/266262111): Investigate loss of theme configuration when switching TaskListener
|
|
||||||
mContext = mContext.createConfigurationContext(configuration);
|
mContext = mContext.createConfigurationContext(configuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -211,7 +210,8 @@ public abstract class CompatUIWindowManagerAbstract extends WindowlessWindowMana
|
|||||||
}
|
}
|
||||||
|
|
||||||
View layout = getLayout();
|
View layout = getLayout();
|
||||||
if (layout == null || prevTaskListener != taskListener) {
|
if (layout == null || prevTaskListener != taskListener
|
||||||
|
|| mTaskConfig.uiMode != prevTaskConfig.uiMode) {
|
||||||
// Layout wasn't created yet or TaskListener changed, recreate the layout for new
|
// Layout wasn't created yet or TaskListener changed, recreate the layout for new
|
||||||
// surface parent.
|
// surface parent.
|
||||||
release();
|
release();
|
||||||
|
|||||||
@@ -155,6 +155,11 @@ class RestartDialogWindowManager extends CompatUIWindowManagerAbstract {
|
|||||||
return super.updateCompatInfo(taskInfo, taskListener, canShow);
|
return super.updateCompatInfo(taskInfo, taskListener, canShow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean needsToBeRecreated(TaskInfo taskInfo, ShellTaskOrganizer.TaskListener taskListener) {
|
||||||
|
return taskInfo.configuration.uiMode != mTaskInfo.configuration.uiMode
|
||||||
|
|| !getTaskListener().equals(taskListener);
|
||||||
|
}
|
||||||
|
|
||||||
private void updateDialogMargins() {
|
private void updateDialogMargins() {
|
||||||
if (mLayout == null) {
|
if (mLayout == null) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -474,6 +474,36 @@ public class CompatUIControllerTest extends ShellTestCase {
|
|||||||
verify(mMockRestartDialogLayout).updateVisibility(true);
|
verify(mMockRestartDialogLayout).updateVisibility(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRestartLayoutRecreatedIfNeeded() {
|
||||||
|
final TaskInfo taskInfo = createTaskInfo(DISPLAY_ID, TASK_ID,
|
||||||
|
/* hasSizeCompat= */ true, CAMERA_COMPAT_CONTROL_HIDDEN);
|
||||||
|
doReturn(true).when(mMockRestartDialogLayout)
|
||||||
|
.needsToBeRecreated(any(TaskInfo.class),
|
||||||
|
any(ShellTaskOrganizer.TaskListener.class));
|
||||||
|
|
||||||
|
mController.onCompatInfoChanged(taskInfo, mMockTaskListener);
|
||||||
|
mController.onCompatInfoChanged(taskInfo, mMockTaskListener);
|
||||||
|
|
||||||
|
verify(mMockRestartDialogLayout, times(2))
|
||||||
|
.createLayout(anyBoolean());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRestartLayoutNotRecreatedIfNotNeeded() {
|
||||||
|
final TaskInfo taskInfo = createTaskInfo(DISPLAY_ID, TASK_ID,
|
||||||
|
/* hasSizeCompat= */ true, CAMERA_COMPAT_CONTROL_HIDDEN);
|
||||||
|
doReturn(false).when(mMockRestartDialogLayout)
|
||||||
|
.needsToBeRecreated(any(TaskInfo.class),
|
||||||
|
any(ShellTaskOrganizer.TaskListener.class));
|
||||||
|
|
||||||
|
mController.onCompatInfoChanged(taskInfo, mMockTaskListener);
|
||||||
|
mController.onCompatInfoChanged(taskInfo, mMockTaskListener);
|
||||||
|
|
||||||
|
verify(mMockRestartDialogLayout, times(1))
|
||||||
|
.createLayout(anyBoolean());
|
||||||
|
}
|
||||||
|
|
||||||
private static TaskInfo createTaskInfo(int displayId, int taskId, boolean hasSizeCompat,
|
private static TaskInfo createTaskInfo(int displayId, int taskId, boolean hasSizeCompat,
|
||||||
@CameraCompatControlState int cameraCompatControlState) {
|
@CameraCompatControlState int cameraCompatControlState) {
|
||||||
RunningTaskInfo taskInfo = new RunningTaskInfo();
|
RunningTaskInfo taskInfo = new RunningTaskInfo();
|
||||||
|
|||||||
Reference in New Issue
Block a user