Updated toggles in Date and time settings page
Design doc: go/dd-android-settings-time-2024 Changes: - toggling off "automatic time zone" now sets "use location" off and makes it unmodifiable - removing "use locale default" for time format Bug: 296835792 Test: on-device and atest Flag: com.android.settings.flags.revamp_toggles Change-Id: I31744f104fed06ee9980a6a0160501325175a02d
This commit is contained in:
@@ -32,6 +32,7 @@ import androidx.preference.Preference;
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.TogglePreferenceController;
|
||||
import com.android.settings.flags.Flags;
|
||||
|
||||
public class AutoTimeZonePreferenceController extends TogglePreferenceController {
|
||||
|
||||
@@ -46,7 +47,7 @@ public class AutoTimeZonePreferenceController extends TogglePreferenceController
|
||||
// setTimeAndDateCallback() isn't called, e.g. for slices and other cases where the
|
||||
// controller is instantiated outside of the context of the real Date & Time settings
|
||||
// screen.
|
||||
mCallback = (c) -> {};
|
||||
mCallback = (c) -> {};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -103,10 +104,25 @@ public class AutoTimeZonePreferenceController extends TogglePreferenceController
|
||||
|
||||
@Override
|
||||
public boolean setChecked(boolean isChecked) {
|
||||
TimeZoneConfiguration configuration = new TimeZoneConfiguration.Builder()
|
||||
.setAutoDetectionEnabled(isChecked)
|
||||
.build();
|
||||
boolean result = mTimeManager.updateTimeZoneConfiguration(configuration);
|
||||
TimeZoneConfiguration.Builder configuration = new TimeZoneConfiguration.Builder()
|
||||
.setAutoDetectionEnabled(isChecked);
|
||||
|
||||
if (Flags.revampToggles()) {
|
||||
// "Use location for time zone" is only used if "Automatic time zone" is enabled. If
|
||||
// the user toggles off automatic time zone, set the toggle off and disable the toggle.
|
||||
int geoDetectionCapability = mTimeManager
|
||||
.getTimeZoneCapabilitiesAndConfig()
|
||||
.getCapabilities()
|
||||
.getConfigureGeoDetectionEnabledCapability();
|
||||
|
||||
if (!isChecked
|
||||
&& (geoDetectionCapability == CAPABILITY_NOT_APPLICABLE
|
||||
|| geoDetectionCapability == CAPABILITY_POSSESSED)) {
|
||||
configuration.setGeoDetectionEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
boolean result = mTimeManager.updateTimeZoneConfiguration(configuration.build());
|
||||
|
||||
mCallback.updateTimeAndDateDisplay(mContext);
|
||||
return result;
|
||||
@@ -138,8 +154,10 @@ public class AutoTimeZonePreferenceController extends TogglePreferenceController
|
||||
|
||||
@VisibleForTesting
|
||||
boolean isEnabled() {
|
||||
TimeZoneConfiguration config = getTimeZoneCapabilitiesAndConfig().getConfiguration();
|
||||
return config.isAutoDetectionEnabled();
|
||||
return mTimeManager
|
||||
.getTimeZoneCapabilitiesAndConfig()
|
||||
.getConfiguration()
|
||||
.isAutoDetectionEnabled();
|
||||
}
|
||||
|
||||
private TimeZoneCapabilitiesAndConfig getTimeZoneCapabilitiesAndConfig() {
|
||||
|
||||
Reference in New Issue
Block a user