diff options
| author | 2022-01-31 15:11:03 +0000 | |
|---|---|---|
| committer | 2022-01-31 15:11:03 +0000 | |
| commit | ff3c395e915251e6c608671137f0d5ecd9f965b6 (patch) | |
| tree | 2234d86da9413b1d920cbc9899c4a92430ebf429 | |
| parent | 083297ec6b392920831da2d29f62c32ca3463f33 (diff) | |
| parent | 89f60bd30eaf78a90e4ab25b8ea036e3207379f2 (diff) | |
Merge "Add dream complication title strings."
| -rw-r--r-- | packages/SettingsLib/res/values/strings.xml | 11 | ||||
| -rw-r--r-- | packages/SettingsLib/src/com/android/settingslib/dream/DreamBackend.java | 39 |
2 files changed, 50 insertions, 0 deletions
diff --git a/packages/SettingsLib/res/values/strings.xml b/packages/SettingsLib/res/values/strings.xml index 45f8f1debe34..af6a658f362a 100644 --- a/packages/SettingsLib/res/values/strings.xml +++ b/packages/SettingsLib/res/values/strings.xml @@ -1549,6 +1549,17 @@ <!-- Content description of the no calling for accessibility (not shown on the screen). [CHAR LIMIT=NONE] --> <string name="accessibility_no_calling">No calling.</string> + <!-- Screensaver overlay which displays the time. [CHAR LIMIT=20] --> + <string name="dream_complication_title_time">Time</string> + <!-- Screensaver overlay which displays the date. [CHAR LIMIT=20] --> + <string name="dream_complication_title_date">Date</string> + <!-- Screensaver overlay which displays the weather. [CHAR LIMIT=20] --> + <string name="dream_complication_title_weather">Weather</string> + <!-- Screensaver overlay which displays air quality. [CHAR LIMIT=20] --> + <string name="dream_complication_title_aqi">Air Quality</string> + <!-- Screensaver overlay which displays cast info. [CHAR LIMIT=20] --> + <string name="dream_complication_title_cast_info">Cast Info</string> + <!-- Title for a screen allowing the user to choose a profile picture. [CHAR LIMIT=NONE] --> <string name="avatar_picker_title">Choose a profile picture</string> </resources> diff --git a/packages/SettingsLib/src/com/android/settingslib/dream/DreamBackend.java b/packages/SettingsLib/src/com/android/settingslib/dream/DreamBackend.java index 46e31ceb7485..6bf43e528009 100644 --- a/packages/SettingsLib/src/com/android/settingslib/dream/DreamBackend.java +++ b/packages/SettingsLib/src/com/android/settingslib/dream/DreamBackend.java @@ -34,6 +34,7 @@ import android.os.ServiceManager; import android.provider.Settings; import android.service.dreams.DreamService; import android.service.dreams.IDreamManager; +import android.text.TextUtils; import android.util.AttributeSet; import android.util.Log; import android.util.Xml; @@ -50,6 +51,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; +import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.stream.Collectors; @@ -292,6 +294,11 @@ public class DreamBackend { } } + /** Returns whether a particular complication is enabled */ + public boolean isComplicationEnabled(@ComplicationType int complication) { + return getEnabledComplications().contains(complication); + } + /** Gets all complications which have been enabled by the user. */ public Set<Integer> getEnabledComplications() { final String enabledComplications = Settings.Secure.getString( @@ -331,6 +338,35 @@ public class DreamBackend { convertToString(enabledComplications)); } + /** + * Gets the title of a particular complication type to be displayed to the user. If there + * is no title, null is returned. + */ + @Nullable + public CharSequence getComplicationTitle(@ComplicationType int complicationType) { + int res = 0; + switch (complicationType) { + case COMPLICATION_TYPE_TIME: + res = R.string.dream_complication_title_time; + break; + case COMPLICATION_TYPE_DATE: + res = R.string.dream_complication_title_date; + break; + case COMPLICATION_TYPE_WEATHER: + res = R.string.dream_complication_title_weather; + break; + case COMPLICATION_TYPE_AIR_QUALITY: + res = R.string.dream_complication_title_aqi; + break; + case COMPLICATION_TYPE_CAST_INFO: + res = R.string.dream_complication_title_cast_info; + break; + default: + return null; + } + return mContext.getString(res); + } + private static String convertToString(Set<Integer> set) { return set.stream() .map(String::valueOf) @@ -338,6 +374,9 @@ public class DreamBackend { } private static Set<Integer> parseFromString(String string) { + if (TextUtils.isEmpty(string)) { + return new HashSet<>(); + } return Arrays.stream(string.split(",")) .map(Integer::parseInt) .collect(Collectors.toSet()); |