Toggle switch back when user dismisses dialog by tapping screen
The reboot dialog can be dismissed when user: 1) Clicks any button on the reboot dialog 2) Taps any screen area outside of reboot dialog We want to toggle back the "Enable ANGLE" switch whenever the user chooses to not reboot the device immetiately. This change adds the function to toggle the "Enable ANGLE" switch back when: 1) User clicks "Cancel" on reboot dialog. 2) User taps screen area outside of reboot dialog to dismiss the reboot dialog. Bug: b/270994705 Test: m; flash and device can boot. atest -c GraphicsDriverEnableAngleAsSystemDriverControllerJUnitTest Change-Id: I84fde5ea5bae9d8793bcef30f4c37d832152ae43
This commit is contained in:
@@ -28,11 +28,9 @@ import androidx.fragment.app.FragmentManager;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
||||
|
||||
/**
|
||||
* Dialog fragment for reboot confirmation when enabling certain features.
|
||||
*/
|
||||
/** Dialog fragment for reboot confirmation when enabling certain features. */
|
||||
public class RebootConfirmationDialogFragment extends InstrumentedDialogFragment
|
||||
implements DialogInterface.OnClickListener {
|
||||
implements DialogInterface.OnClickListener, DialogInterface.OnDismissListener {
|
||||
|
||||
private static final String TAG = "FreeformPrefRebootDlg";
|
||||
|
||||
@@ -40,18 +38,17 @@ public class RebootConfirmationDialogFragment extends InstrumentedDialogFragment
|
||||
private final int mCancelButtonId;
|
||||
private final RebootConfirmationDialogHost mHost;
|
||||
|
||||
/**
|
||||
* Show an instance of this dialog.
|
||||
*/
|
||||
/** Show an instance of this dialog. */
|
||||
public static void show(Fragment fragment, int messageId, RebootConfirmationDialogHost host) {
|
||||
show(fragment, messageId, R.string.reboot_dialog_reboot_later, host);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show an instance of this dialog with cancel button string set as cancelButtonId
|
||||
*/
|
||||
public static void show(Fragment fragment, int messageId,
|
||||
int cancelButtonId, RebootConfirmationDialogHost host) {
|
||||
/** Show an instance of this dialog with cancel button string set as cancelButtonId */
|
||||
public static void show(
|
||||
Fragment fragment,
|
||||
int messageId,
|
||||
int cancelButtonId,
|
||||
RebootConfirmationDialogHost host) {
|
||||
final FragmentManager manager = fragment.getActivity().getSupportFragmentManager();
|
||||
if (manager.findFragmentByTag(TAG) == null) {
|
||||
final RebootConfirmationDialogFragment dialog =
|
||||
@@ -60,8 +57,8 @@ public class RebootConfirmationDialogFragment extends InstrumentedDialogFragment
|
||||
}
|
||||
}
|
||||
|
||||
private RebootConfirmationDialogFragment(int messageId,
|
||||
int cancelButtonId, RebootConfirmationDialogHost host) {
|
||||
private RebootConfirmationDialogFragment(
|
||||
int messageId, int cancelButtonId, RebootConfirmationDialogHost host) {
|
||||
mMessageId = messageId;
|
||||
mCancelButtonId = cancelButtonId;
|
||||
mHost = host;
|
||||
@@ -89,4 +86,10 @@ public class RebootConfirmationDialogFragment extends InstrumentedDialogFragment
|
||||
mHost.onRebootCancelled();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
super.onDismiss(dialog);
|
||||
mHost.onRebootDialogDismissed();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user