Loading res/values/strings.xml +10 −0 Original line number Diff line number Diff line Loading @@ -3943,6 +3943,16 @@ <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">If your device location is available, it may be used to set your time zone</string> <!-- Date&Time settings screen, title of the notification category [CHAR LIMIT=60] --> <string name="time_notifications_title">Notifications</string> <!-- Date&Time settings screen, title of the time zone change notification toggle [CHAR LIMIT=60] --> <string name="time_zone_change_notifications_toggle_title">Time zone change</string> <!-- Date&Time settings screen, summary of the time zone change notification toggle [CHAR_LIMIT=NONE] --> <string name="time_zone_change_notifications_toggle_summary">Receive a notification when your time zone is automatically updated</string> <!-- Search keywords for the time zone notification category / section in Date & Time settings. [CHAR_LIMIT=NONE] --> <string name="keywords_time_notification_category">notification, time, zone, timezone</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 --> res/xml/date_time_prefs.xml +23 −8 Original line number Diff line number Diff line Loading @@ -75,18 +75,33 @@ </PreferenceCategory> <!-- An optional preference category for notifications. Only displayed up if enabled via flags and config. --> <PreferenceCategory android:key="time_notifications_category" android:title="@string/time_notifications_title" settings:controller="com.android.settings.datetime.NotificationsPreferenceCategoryController"> <SwitchPreferenceCompat android:key="time_zone_change_notifications" android:summary="@string/summary_placeholder" android:title="@string/time_zone_change_notifications_toggle_title" settings:keywords="@string/keywords_time_notification_category" settings:controller="com.android.settings.datetime.TimeZoneNotificationsPreferenceController" /> </PreferenceCategory> <!-- An optional preference category for feedback. Only displayed up if enabled via flags and config. --> <PreferenceCategory android:key="time_feedback_preference_category" android:title="@string/time_feedback_category_title" settings:keywords="@string/keywords_time_feedback_category" settings:controller="com.android.settings.datetime.TimeFeedbackPreferenceCategoryController"> settings:controller="com.android.settings.datetime.TimeFeedbackPreferenceCategoryController" settings:keywords="@string/keywords_time_feedback_category"> <Preference android:key="time_feedback" android:title="@string/time_feedback_title" settings:keywords="@string/keywords_time_feedback" settings:controller="com.android.settings.datetime.TimeFeedbackPreferenceController" /> settings:controller="com.android.settings.datetime.TimeFeedbackPreferenceController" settings:keywords="@string/keywords_time_feedback" /> </PreferenceCategory> Loading src/com/android/settings/datetime/TimeFeedbackLaunchUtils.java→src/com/android/settings/datetime/DateTimeLaunchUtils.java +5 −5 Original line number Diff line number Diff line Loading @@ -22,7 +22,7 @@ import android.provider.DeviceConfig; import com.android.settings.flags.Flags; /** A class to avoid duplication of launch-control logic for "time feedback" support. */ final class TimeFeedbackLaunchUtils { final class DateTimeLaunchUtils { /** * A {@link DeviceConfig} flag that influences whether the settings entries related to help and * feedback are supported on this device / for this user. Loading @@ -30,21 +30,21 @@ final class TimeFeedbackLaunchUtils { public static final String KEY_HELP_AND_FEEDBACK_FEATURE_SUPPORTED = "time_help_and_feedback_feature_supported"; private TimeFeedbackLaunchUtils() {} private DateTimeLaunchUtils() {} static boolean isFeedbackFeatureSupported() { // Support is determined according to: // 1) A build-time flag to determine release feature availability. // 2) A runtime / server-side flag to determine which devices / who gets to see the feature. // This is launch control for limiting the feedback to droidfooding. return isFeatureSupportedThisRelease() && isFeatureSupportedOnThisDevice(); return isFeedbackFeatureSupportedThisRelease() && isFeedbackFeatureSupportedOnThisDevice(); } private static boolean isFeatureSupportedThisRelease() { private static boolean isFeedbackFeatureSupportedThisRelease() { return Flags.datetimeFeedback(); } private static boolean isFeatureSupportedOnThisDevice() { private static boolean isFeedbackFeatureSupportedOnThisDevice() { boolean defaultIsSupported = false; return DeviceConfig.getBoolean( NAMESPACE_SETTINGS_UI, KEY_HELP_AND_FEEDBACK_FEATURE_SUPPORTED, defaultIsSupported); Loading src/com/android/settings/datetime/DateTimeSettings.java +9 −0 Original line number Diff line number Diff line Loading @@ -74,6 +74,15 @@ public class DateTimeSettings extends DashboardFragment implements use(TimeFeedbackPreferenceCategoryController.class); use(TimeFeedbackPreferenceController.class) .registerWithOptionalCategoryController(helpAndFeedbackCategoryController); // All the elements in the category are optional, so we must ensure the category is only // available if any of the elements are available. NotificationsPreferenceCategoryController notificationsPreferenceCategoryController = use(NotificationsPreferenceCategoryController.class); use(TimeZoneNotificationsPreferenceController.class) .registerIn( notificationsPreferenceCategoryController); } @Override Loading src/com/android/settings/datetime/NotificationsPreferenceCategoryController.java 0 → 100644 +65 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.settings.datetime; import android.content.Context; import androidx.annotation.NonNull; import com.android.server.flags.Flags; import com.android.settings.core.BasePreferenceController; import com.android.settingslib.core.AbstractPreferenceController; import java.util.ArrayList; import java.util.List; import java.util.Objects; /** * A controller for the Settings category for "time notifications". */ public class NotificationsPreferenceCategoryController extends BasePreferenceController { private final List<AbstractPreferenceController> mChildControllers = new ArrayList<>(); public NotificationsPreferenceCategoryController(@NonNull Context context, @NonNull String preferenceKey) { super(context, preferenceKey); } /** * Adds a controller whose own availability can determine the category's availability status. */ void addChildController(@NonNull AbstractPreferenceController childController) { mChildControllers.add(Objects.requireNonNull(childController)); } @Override public int getAvailabilityStatus() { // Firstly, hide the category if it is not enabled by flags. if (!Flags.datetimeNotifications()) { return UNSUPPORTED_ON_DEVICE; } // Secondly, only show the category if there's one or more controllers available within it. for (AbstractPreferenceController childController : mChildControllers) { if (childController.isAvailable()) { return AVAILABLE; } } return UNSUPPORTED_ON_DEVICE; } } Loading
res/values/strings.xml +10 −0 Original line number Diff line number Diff line Loading @@ -3943,6 +3943,16 @@ <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">If your device location is available, it may be used to set your time zone</string> <!-- Date&Time settings screen, title of the notification category [CHAR LIMIT=60] --> <string name="time_notifications_title">Notifications</string> <!-- Date&Time settings screen, title of the time zone change notification toggle [CHAR LIMIT=60] --> <string name="time_zone_change_notifications_toggle_title">Time zone change</string> <!-- Date&Time settings screen, summary of the time zone change notification toggle [CHAR_LIMIT=NONE] --> <string name="time_zone_change_notifications_toggle_summary">Receive a notification when your time zone is automatically updated</string> <!-- Search keywords for the time zone notification category / section in Date & Time settings. [CHAR_LIMIT=NONE] --> <string name="keywords_time_notification_category">notification, time, zone, timezone</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 -->
res/xml/date_time_prefs.xml +23 −8 Original line number Diff line number Diff line Loading @@ -75,18 +75,33 @@ </PreferenceCategory> <!-- An optional preference category for notifications. Only displayed up if enabled via flags and config. --> <PreferenceCategory android:key="time_notifications_category" android:title="@string/time_notifications_title" settings:controller="com.android.settings.datetime.NotificationsPreferenceCategoryController"> <SwitchPreferenceCompat android:key="time_zone_change_notifications" android:summary="@string/summary_placeholder" android:title="@string/time_zone_change_notifications_toggle_title" settings:keywords="@string/keywords_time_notification_category" settings:controller="com.android.settings.datetime.TimeZoneNotificationsPreferenceController" /> </PreferenceCategory> <!-- An optional preference category for feedback. Only displayed up if enabled via flags and config. --> <PreferenceCategory android:key="time_feedback_preference_category" android:title="@string/time_feedback_category_title" settings:keywords="@string/keywords_time_feedback_category" settings:controller="com.android.settings.datetime.TimeFeedbackPreferenceCategoryController"> settings:controller="com.android.settings.datetime.TimeFeedbackPreferenceCategoryController" settings:keywords="@string/keywords_time_feedback_category"> <Preference android:key="time_feedback" android:title="@string/time_feedback_title" settings:keywords="@string/keywords_time_feedback" settings:controller="com.android.settings.datetime.TimeFeedbackPreferenceController" /> settings:controller="com.android.settings.datetime.TimeFeedbackPreferenceController" settings:keywords="@string/keywords_time_feedback" /> </PreferenceCategory> Loading
src/com/android/settings/datetime/TimeFeedbackLaunchUtils.java→src/com/android/settings/datetime/DateTimeLaunchUtils.java +5 −5 Original line number Diff line number Diff line Loading @@ -22,7 +22,7 @@ import android.provider.DeviceConfig; import com.android.settings.flags.Flags; /** A class to avoid duplication of launch-control logic for "time feedback" support. */ final class TimeFeedbackLaunchUtils { final class DateTimeLaunchUtils { /** * A {@link DeviceConfig} flag that influences whether the settings entries related to help and * feedback are supported on this device / for this user. Loading @@ -30,21 +30,21 @@ final class TimeFeedbackLaunchUtils { public static final String KEY_HELP_AND_FEEDBACK_FEATURE_SUPPORTED = "time_help_and_feedback_feature_supported"; private TimeFeedbackLaunchUtils() {} private DateTimeLaunchUtils() {} static boolean isFeedbackFeatureSupported() { // Support is determined according to: // 1) A build-time flag to determine release feature availability. // 2) A runtime / server-side flag to determine which devices / who gets to see the feature. // This is launch control for limiting the feedback to droidfooding. return isFeatureSupportedThisRelease() && isFeatureSupportedOnThisDevice(); return isFeedbackFeatureSupportedThisRelease() && isFeedbackFeatureSupportedOnThisDevice(); } private static boolean isFeatureSupportedThisRelease() { private static boolean isFeedbackFeatureSupportedThisRelease() { return Flags.datetimeFeedback(); } private static boolean isFeatureSupportedOnThisDevice() { private static boolean isFeedbackFeatureSupportedOnThisDevice() { boolean defaultIsSupported = false; return DeviceConfig.getBoolean( NAMESPACE_SETTINGS_UI, KEY_HELP_AND_FEEDBACK_FEATURE_SUPPORTED, defaultIsSupported); Loading
src/com/android/settings/datetime/DateTimeSettings.java +9 −0 Original line number Diff line number Diff line Loading @@ -74,6 +74,15 @@ public class DateTimeSettings extends DashboardFragment implements use(TimeFeedbackPreferenceCategoryController.class); use(TimeFeedbackPreferenceController.class) .registerWithOptionalCategoryController(helpAndFeedbackCategoryController); // All the elements in the category are optional, so we must ensure the category is only // available if any of the elements are available. NotificationsPreferenceCategoryController notificationsPreferenceCategoryController = use(NotificationsPreferenceCategoryController.class); use(TimeZoneNotificationsPreferenceController.class) .registerIn( notificationsPreferenceCategoryController); } @Override Loading
src/com/android/settings/datetime/NotificationsPreferenceCategoryController.java 0 → 100644 +65 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.settings.datetime; import android.content.Context; import androidx.annotation.NonNull; import com.android.server.flags.Flags; import com.android.settings.core.BasePreferenceController; import com.android.settingslib.core.AbstractPreferenceController; import java.util.ArrayList; import java.util.List; import java.util.Objects; /** * A controller for the Settings category for "time notifications". */ public class NotificationsPreferenceCategoryController extends BasePreferenceController { private final List<AbstractPreferenceController> mChildControllers = new ArrayList<>(); public NotificationsPreferenceCategoryController(@NonNull Context context, @NonNull String preferenceKey) { super(context, preferenceKey); } /** * Adds a controller whose own availability can determine the category's availability status. */ void addChildController(@NonNull AbstractPreferenceController childController) { mChildControllers.add(Objects.requireNonNull(childController)); } @Override public int getAvailabilityStatus() { // Firstly, hide the category if it is not enabled by flags. if (!Flags.datetimeNotifications()) { return UNSUPPORTED_ON_DEVICE; } // Secondly, only show the category if there's one or more controllers available within it. for (AbstractPreferenceController childController : mChildControllers) { if (childController.isAvailable()) { return AVAILABLE; } } return UNSUPPORTED_ON_DEVICE; } }