Merge "Add explicit SystemUIDialog dependencies as parameters" into tm-qpr-dev am: 6d6a373d25 am: bab6d2d2f4

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/19046029

Change-Id: Ide246dd3c82aaa698904bd6ccd01ad9c136e92c1
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Jordan Demeulenaere
2022-06-25 07:59:54 +00:00
committed by Automerger Merge Worker

View File

@@ -89,6 +89,17 @@ public class SystemUIDialog extends AlertDialog implements ViewRootImpl.ConfigCh
}
public SystemUIDialog(Context context, int theme, boolean dismissOnDeviceLock) {
// TODO(b/219008720): Remove those calls to Dependency.get by introducing a
// SystemUIDialogFactory and make all other dialogs create a SystemUIDialog to which we set
// the content and attach listeners.
this(context, theme, dismissOnDeviceLock, Dependency.get(SystemUIDialogManager.class),
Dependency.get(SysUiState.class), Dependency.get(BroadcastDispatcher.class),
Dependency.get(DialogLaunchAnimator.class));
}
public SystemUIDialog(Context context, int theme, boolean dismissOnDeviceLock,
SystemUIDialogManager dialogManager, SysUiState sysUiState,
BroadcastDispatcher broadcastDispatcher, DialogLaunchAnimator dialogLaunchAnimator) {
super(context, theme);
mContext = context;
@@ -97,13 +108,10 @@ public class SystemUIDialog extends AlertDialog implements ViewRootImpl.ConfigCh
attrs.setTitle(getClass().getSimpleName());
getWindow().setAttributes(attrs);
mDismissReceiver = dismissOnDeviceLock ? new DismissReceiver(this) : null;
// TODO(b/219008720): Remove those calls to Dependency.get by introducing a
// SystemUIDialogFactory and make all other dialogs create a SystemUIDialog to which we set
// the content and attach listeners.
mDialogManager = Dependency.get(SystemUIDialogManager.class);
mSysUiState = Dependency.get(SysUiState.class);
mDismissReceiver = dismissOnDeviceLock ? new DismissReceiver(this, broadcastDispatcher,
dialogLaunchAnimator) : null;
mDialogManager = dialogManager;
mSysUiState = sysUiState;
}
@Override
@@ -322,7 +330,10 @@ public class SystemUIDialog extends AlertDialog implements ViewRootImpl.ConfigCh
* @param dismissAction An action to run when the dialog is dismissed.
*/
public static void registerDismissListener(Dialog dialog, @Nullable Runnable dismissAction) {
DismissReceiver dismissReceiver = new DismissReceiver(dialog);
// TODO(b/219008720): Remove those calls to Dependency.get.
DismissReceiver dismissReceiver = new DismissReceiver(dialog,
Dependency.get(BroadcastDispatcher.class),
Dependency.get(DialogLaunchAnimator.class));
dialog.setOnDismissListener(d -> {
dismissReceiver.unregister();
if (dismissAction != null) dismissAction.run();
@@ -404,11 +415,11 @@ public class SystemUIDialog extends AlertDialog implements ViewRootImpl.ConfigCh
private final BroadcastDispatcher mBroadcastDispatcher;
private final DialogLaunchAnimator mDialogLaunchAnimator;
DismissReceiver(Dialog dialog) {
DismissReceiver(Dialog dialog, BroadcastDispatcher broadcastDispatcher,
DialogLaunchAnimator dialogLaunchAnimator) {
mDialog = dialog;
// TODO(b/219008720): Remove those calls to Dependency.get.
mBroadcastDispatcher = Dependency.get(BroadcastDispatcher.class);
mDialogLaunchAnimator = Dependency.get(DialogLaunchAnimator.class);
mBroadcastDispatcher = broadcastDispatcher;
mDialogLaunchAnimator = dialogLaunchAnimator;
}
void register() {