Add dream complication title strings.
These are the strings which will be displayed in Settings for each complication type. Test: locally in settings. Bug: 215703483 Change-Id: I2ba87cc6e446e866d9accbfec8ecf17f26e10d20
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user