Fix a crash due to absence of no-arg fragment init
Fix a crash due to absence of no-arg fragment constructor. e.g. if the dialog were shown and the device were rotated, the dialog could not be restored. Bug: 272439218 Test: Manual with repro steps before and after Change-Id: Idca052acff709af132fa72f7919aa71fe8060595
This commit is contained in:
@@ -77,7 +77,7 @@ public class LocationTimeZoneDetectionPreferenceController
|
|||||||
boolean isLocationEnabled =
|
boolean isLocationEnabled =
|
||||||
timeZoneCapabilitiesAndConfig.getCapabilities().isUseLocationEnabled();
|
timeZoneCapabilitiesAndConfig.getCapabilities().isUseLocationEnabled();
|
||||||
if (isChecked && !isLocationEnabled) {
|
if (isChecked && !isLocationEnabled) {
|
||||||
new LocationToggleDisabledDialogFragment(mContext)
|
new LocationToggleDisabledDialogFragment()
|
||||||
.show(mFragment.getFragmentManager(), TAG);
|
.show(mFragment.getFragmentManager(), TAG);
|
||||||
// Toggle status is not updated.
|
// Toggle status is not updated.
|
||||||
return false;
|
return false;
|
||||||
|
@@ -19,7 +19,6 @@ package com.android.settings.datetime;
|
|||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.app.settings.SettingsEnums;
|
import android.app.settings.SettingsEnums;
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
@@ -32,11 +31,7 @@ import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
|||||||
*/
|
*/
|
||||||
public class LocationToggleDisabledDialogFragment extends InstrumentedDialogFragment {
|
public class LocationToggleDisabledDialogFragment extends InstrumentedDialogFragment {
|
||||||
|
|
||||||
private final Context mContext;
|
public LocationToggleDisabledDialogFragment() {}
|
||||||
|
|
||||||
public LocationToggleDisabledDialogFragment(Context context) {
|
|
||||||
mContext = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
@@ -48,7 +43,7 @@ public class LocationToggleDisabledDialogFragment extends InstrumentedDialogFrag
|
|||||||
R.string.location_time_zone_detection_location_is_off_dialog_ok_button,
|
R.string.location_time_zone_detection_location_is_off_dialog_ok_button,
|
||||||
(dialog, which) -> {
|
(dialog, which) -> {
|
||||||
Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
|
Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
|
||||||
mContext.startActivity(intent);
|
getContext().startActivity(intent);
|
||||||
})
|
})
|
||||||
.setNegativeButton(
|
.setNegativeButton(
|
||||||
R.string.location_time_zone_detection_location_is_off_dialog_cancel_button,
|
R.string.location_time_zone_detection_location_is_off_dialog_cancel_button,
|
||||||
|
Reference in New Issue
Block a user