Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eabff5da authored by Neil Fuller's avatar Neil Fuller
Browse files

Fix missing zone strings in some cases

ICU's TimeZoneNames requires a "canonical" zone ID, otherwise it will
return no data. Usually the ID being used is the same as the canonical
ID so there's no problem. This change is based on an equivalent fix in
the newer SettingsUI code. It is for completeness, to ensure incorrect
code is not copied in future.

Bug: 155167041
Test: None
Change-Id: I2becbebb0213c4aa60031178a760ee12bfb7d295
parent ad00b4c7
Loading
Loading
Loading
Loading
+10 −1
Original line number Original line Diff line number Diff line
@@ -242,7 +242,16 @@ public class ZoneGetter {
        final TimeZoneNames.NameType nameType =
        final TimeZoneNames.NameType nameType =
                tz.inDaylightTime(now) ? TimeZoneNames.NameType.LONG_DAYLIGHT
                tz.inDaylightTime(now) ? TimeZoneNames.NameType.LONG_DAYLIGHT
                        : TimeZoneNames.NameType.LONG_STANDARD;
                        : TimeZoneNames.NameType.LONG_STANDARD;
        return names.getDisplayName(tz.getID(), nameType, now.getTime());
        return names.getDisplayName(getCanonicalZoneId(tz), nameType, now.getTime());
    }

    private static String getCanonicalZoneId(TimeZone timeZone) {
        final String id = timeZone.getID();
        final String canonicalId = android.icu.util.TimeZone.getCanonicalID(id);
        if (canonicalId != null) {
            return canonicalId;
        }
        return id;
    }
    }


    private static void appendWithTtsSpan(SpannableStringBuilder builder, CharSequence content,
    private static void appendWithTtsSpan(SpannableStringBuilder builder, CharSequence content,