Merge "Update titles and summaries of the Date and time settings page" into main

This commit is contained in:
Treehugger Robot
2024-09-25 16:54:05 +00:00
committed by Android (Google) Code Review
6 changed files with 41 additions and 13 deletions

View File

@@ -571,11 +571,15 @@
<string name="roaming_warning">Roaming charges may apply.</string>
<!-- Date & time setting screen setting switch title: whether the system clock (Unix epoch time) should be determined automatically [CHAR LIMIT=100] -->
<string name="date_time_auto">Set time automatically</string>
<string name="date_time_auto">Automatic date and time</string>
<!-- Date & time setting screen setting switch summary: whether the system clock (Unix epoch time) should be determined automatically [CHAR LIMIT=100] -->
<string name="date_time_auto_summary">Set automatically using your network and wireless signals</string>
<!-- Date & time setting screen setting switch title: whether the time zone should be determined automatically [CHAR LIMIT=100] -->
<string name="zone_auto_title">Set automatically</string>
<string name="zone_auto_title">Automatic time zone</string>
<!-- Date & time setting screen setting switch summary: whether the time zone should be determined automatically [CHAR LIMIT=100] -->
<string name="zone_auto_title_summary">Set automatically based on mobile networks near you</string>
<!-- Date & time setting screen setting switch summary for non-telephony devices [CHAR LIMIT=100] -->
<string name="auto_zone_requires_location_summary">Location will be used for setting the time zone when this toggle is on</string>
<string name="auto_zone_requires_location_summary">Set automatically using your device location, if available. An active Wifi connection may also be required.</string>
<!-- Date & time setting screen setting option summary text for the automatic 24 hour setting checkbox [CHAR LIMIT=100] -->
<string name="date_time_24hour_auto">Use locale default</string>
<!-- Date & time setting screen setting check box title -->
@@ -3772,7 +3776,7 @@
<string name="location_services_screen_title">Location services</string>
<!-- [CHAR LIMIT=60] Date&Time settings screen, toggle button title -->
<string name="location_time_zone_detection_toggle_title">Use location</string>
<string name="location_time_zone_detection_toggle_title">Use location for time zone</string>
<!-- [CHAR LIMIT=50] Date&Time settings screen, title of the dialog when AutoTimeZone is degraded -->
<string name="location_time_zone_detection_status_title">Cannot set the time zone automatically</string>
<!-- Date&Time settings screen, summary of the dialog when AutoTimeZone is degraded by settings-->
@@ -3800,7 +3804,7 @@
<!-- [CHAR LIMIT=NONE] Location settings screen, summary when location time zone detection is not
applicable due to other settings like the "automatic time zone detection enabled" setting
being set to "off". -->
<string name="location_time_zone_detection_auto_is_off">Automatic time zone is off</string>
<string name="location_time_zone_detection_auto_is_off">Not available when automatic time zone is off</string>
<!-- [CHAR LIMIT=NONE] Location settings screen, summary when location time zone detection is not
applicable for the user for unspecified reasons. More specific messages are used when there
is a clear reason. -->
@@ -3811,7 +3815,7 @@
allowed for the user, e.g. because of device policy -->
<string name="location_time_zone_detection_not_allowed">Location time zone detection changes are not allowed</string>
<!-- [CHAR LIMIT=NONE] Location settings screen, summary when location time zone detection is enabled. -->
<string name="location_time_zone_detection_auto_is_on">Location may be used to set time zone</string>
<string name="location_time_zone_detection_auto_is_on">If your device location is available, it may be used to set your time zone</string>
<!-- Main settings screen, setting summary for the user to go into the About phone screen-->
<string name="about_settings_summary">View legal info, status, software version</string>
<!-- About phone settings screen, setting option name to go to dialog that shows legal info -->

View File

@@ -23,7 +23,7 @@
<com.android.settingslib.RestrictedSwitchPreference
android:key="auto_time"
android:title="@string/date_time_auto"
settings:useAdditionalSummary="true"
android:summary="@string/summary_placeholder"
settings:userRestriction="no_config_date_time"
settings:controller="com.android.settings.datetime.AutoTimePreferenceController" />
@@ -48,6 +48,7 @@
<com.android.settingslib.RestrictedSwitchPreference
android:key="auto_zone"
android:title="@string/zone_auto_title"
android:summary="@string/summary_placeholder"
settings:userRestriction="no_config_date_time"
settings:controller="com.android.settings.datetime.AutoTimeZonePreferenceController" />
@@ -60,6 +61,7 @@
<SwitchPreferenceCompat
android:key="location_time_zone_detection"
android:title="@string/location_time_zone_detection_toggle_title"
android:summary="@string/summary_placeholder"
settings:controller="com.android.settings.datetime.LocationTimeZoneDetectionPreferenceController"/>
<com.android.settingslib.RestrictedPreference

View File

@@ -27,6 +27,8 @@ import android.app.time.TimeConfiguration;
import android.app.time.TimeManager;
import android.content.Context;
import androidx.preference.Preference;
import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.R;
import com.android.settings.core.TogglePreferenceController;
@@ -76,6 +78,17 @@ public class AutoTimePreferenceController extends TogglePreferenceController {
}
}
@Override
public void updateState(Preference preference) {
super.updateState(preference);
refreshSummary(preference);
}
@Override
public CharSequence getSummary() {
return mContext.getString(R.string.date_time_auto_summary);
}
@Override
public boolean isChecked() {
return isEnabled();

View File

@@ -129,11 +129,11 @@ public class AutoTimeZonePreferenceController extends TogglePreferenceController
// time zone must use location.
if (LocationProviderStatusPreferenceController.hasLocationTimeZoneNoTelephonyFallback(
mTimeManager.getTimeZoneCapabilitiesAndConfig().getDetectorStatus())) {
return mContext.getResources().getString(R.string.auto_zone_requires_location_summary);
return mContext.getString(R.string.auto_zone_requires_location_summary);
}
// If the user has a dedicated toggle to control location use, the summary can
// be empty because the use of location is explicit.
return "";
// If the user has a dedicated toggle to control location use, explain what it does.
return mContext.getString(R.string.zone_auto_title_summary);
}
@VisibleForTesting

View File

@@ -34,6 +34,8 @@ import android.os.UserHandle;
import androidx.preference.Preference;
import com.android.settings.R;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -153,6 +155,12 @@ public class AutoTimePreferenceControllerTest {
assertThat(mController.isEnabled()).isFalse();
}
@Test
public void getSummary() {
assertThat(mController.getSummary().toString()).isEqualTo(
mContext.getString(R.string.date_time_auto_summary));
}
private static TimeCapabilitiesAndConfig createCapabilitiesAndConfig(boolean autoSupported,
boolean autoEnabled) {
int configureAutoDetectionEnabledCapability =

View File

@@ -225,7 +225,8 @@ public class AutoTimeZonePreferenceControllerTest {
when(mTimeManager.getTimeZoneCapabilitiesAndConfig()).thenReturn(capabilitiesAndConfig);
when(mTimeManager.updateTimeZoneConfiguration(Mockito.any())).thenReturn(true);
assertThat(mController.getSummary()).isEqualTo("");
assertThat(mController.getSummary().toString()).isEqualTo(
mContext.getString(R.string.zone_auto_title_summary));
capabilitiesAndConfig = createCapabilitiesAndConfig(
/* autoSupported= */true, /* autoEnabled= */true, /* telephonySupported= */
@@ -233,7 +234,7 @@ public class AutoTimeZonePreferenceControllerTest {
when(mTimeManager.getTimeZoneCapabilitiesAndConfig()).thenReturn(capabilitiesAndConfig);
when(mTimeManager.updateTimeZoneConfiguration(Mockito.any())).thenReturn(true);
assertThat(mController.getSummary()).isEqualTo(
assertThat(mController.getSummary().toString()).isEqualTo(
mContext.getString(R.string.auto_zone_requires_location_summary));
}