Fix mobile data toggle status not correct
When toggle off the switch and dismiss the confirmation dialog. This issue is caused by dialog's on dismiss listener not set, only confirm and cancel listener is set. Since confirm and cancel will also called dismiss listener, set a dismiss listener cannot fix this issue. So when need display confirmation dialog, change the toggle status back to on, and set to off when confirmed to fix this issue. Fix: 283259670 Test: Manually with InternetDialog Change-Id: Ic8f70518a22147f7f01936015d1ac6c341a30993
This commit is contained in:
@@ -286,7 +286,6 @@ public class InternetDialog extends SystemUIDialog implements
|
||||
mHandler.removeCallbacks(mHideProgressBarRunnable);
|
||||
mHandler.removeCallbacks(mHideSearchingRunnable);
|
||||
mMobileNetworkLayout.setOnClickListener(null);
|
||||
mMobileDataToggle.setOnCheckedChangeListener(null);
|
||||
mConnectedWifListLayout.setOnClickListener(null);
|
||||
if (mSecondaryMobileNetworkLayout != null) {
|
||||
mSecondaryMobileNetworkLayout.setOnClickListener(null);
|
||||
@@ -351,18 +350,16 @@ public class InternetDialog extends SystemUIDialog implements
|
||||
}
|
||||
mInternetDialogController.connectCarrierNetwork();
|
||||
});
|
||||
mMobileDataToggle.setOnCheckedChangeListener(
|
||||
(buttonView, isChecked) -> {
|
||||
if (!isChecked && shouldShowMobileDialog()) {
|
||||
showTurnOffMobileDialog();
|
||||
} else if (!shouldShowMobileDialog()) {
|
||||
if (mInternetDialogController.isMobileDataEnabled() == isChecked) {
|
||||
return;
|
||||
}
|
||||
mInternetDialogController.setMobileDataEnabled(mContext, mDefaultDataSubId,
|
||||
isChecked, false);
|
||||
}
|
||||
});
|
||||
mMobileDataToggle.setOnClickListener(v -> {
|
||||
boolean isChecked = mMobileDataToggle.isChecked();
|
||||
if (!isChecked && shouldShowMobileDialog()) {
|
||||
mMobileDataToggle.setChecked(true);
|
||||
showTurnOffMobileDialog();
|
||||
} else if (mInternetDialogController.isMobileDataEnabled() != isChecked) {
|
||||
mInternetDialogController.setMobileDataEnabled(mContext, mDefaultDataSubId,
|
||||
isChecked, false);
|
||||
}
|
||||
});
|
||||
mConnectedWifListLayout.setOnClickListener(this::onClickConnectedWifi);
|
||||
mSeeAllLayout.setOnClickListener(this::onClickSeeMoreButton);
|
||||
mWiFiToggle.setOnCheckedChangeListener(
|
||||
@@ -696,9 +693,7 @@ public class InternetDialog extends SystemUIDialog implements
|
||||
mAlertDialog = new Builder(mContext)
|
||||
.setTitle(R.string.mobile_data_disable_title)
|
||||
.setMessage(mContext.getString(R.string.mobile_data_disable_message, carrierName))
|
||||
.setNegativeButton(android.R.string.cancel, (d, w) -> {
|
||||
mMobileDataToggle.setChecked(true);
|
||||
})
|
||||
.setNegativeButton(android.R.string.cancel, (d, w) -> {})
|
||||
.setPositiveButton(
|
||||
com.android.internal.R.string.alert_windows_notification_turn_off_action,
|
||||
(d, w) -> {
|
||||
@@ -708,7 +703,6 @@ public class InternetDialog extends SystemUIDialog implements
|
||||
Prefs.putBoolean(mContext, QS_HAS_TURNED_OFF_MOBILE_DATA, true);
|
||||
})
|
||||
.create();
|
||||
mAlertDialog.setOnCancelListener(dialog -> mMobileDataToggle.setChecked(true));
|
||||
mAlertDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
|
||||
SystemUIDialog.setShowForAllUsers(mAlertDialog, true);
|
||||
SystemUIDialog.registerDismissListener(mAlertDialog);
|
||||
|
||||
Reference in New Issue
Block a user