Reformat timezone name to better distinguish GMT from timezone.
Bug: 8794160
Change-Id: If97efddb49ee05394666d95a83c74731f8501807
diff --git a/src/com/android/timezonepicker/TimeZoneInfo.java b/src/com/android/timezonepicker/TimeZoneInfo.java
index 5a019a6..9d302eb 100644
--- a/src/com/android/timezonepicker/TimeZoneInfo.java
+++ b/src/com/android/timezonepicker/TimeZoneInfo.java
@@ -165,7 +165,7 @@
// mFormatter writes to mSB
DateUtils.formatDateRange(context, mFormatter, now, now, flags, mTzId);
- mSB.append(' ');
+ mSB.append(" ");
int gmtStart = mSB.length();
TimeZonePickerUtils.appendGmtOffset(mSB, gmtOffset);
int gmtEnd = mSB.length();
diff --git a/src/com/android/timezonepicker/TimeZonePickerUtils.java b/src/com/android/timezonepicker/TimeZonePickerUtils.java
index 9dae7aa..e0f50ce 100644
--- a/src/com/android/timezonepicker/TimeZonePickerUtils.java
+++ b/src/com/android/timezonepicker/TimeZonePickerUtils.java
@@ -32,7 +32,7 @@
public class TimeZonePickerUtils {
private static final String TAG = "TimeZonePickerUtils";
- public static final int GMT_TEXT_COLOR = 0xFFAAAAAA;
+ public static final int GMT_TEXT_COLOR = 0xFF888888;
public static final int DST_SYMBOL_COLOR = 0xFFBFBFBF;
private static final Factory mSpannableFactory = Spannable.Factory.getInstance();
@@ -59,9 +59,11 @@
* @param context Context in case the override labels need to be re-cached.
* @param id The timezone id
* @param millis The time (daylight savings or not)
+ * @param grayGmt Whether the "GMT+x" part of the returned string should be colored gray.
* @return The display name of the timezone.
*/
- public CharSequence getGmtDisplayName(Context context, String id, long millis) {
+ public CharSequence getGmtDisplayName(Context context, String id, long millis,
+ boolean grayGmt) {
TimeZone timezone = TimeZone.getTimeZone(id);
if (timezone == null) {
return null;
@@ -74,10 +76,10 @@
mDefaultLocale = defaultLocale;
cacheOverrides(context);
}
- return buildGmtDisplayName(timezone, millis);
+ return buildGmtDisplayName(timezone, millis, grayGmt);
}
- private CharSequence buildGmtDisplayName(TimeZone tz, long timeMillis) {
+ private CharSequence buildGmtDisplayName(TimeZone tz, long timeMillis, boolean grayGmt) {
Time time = new Time(tz.getID());
time.set(timeMillis);
@@ -86,7 +88,7 @@
String displayName = getDisplayName(tz, time.isDst != 0);
sb.append(displayName);
- sb.append(" ");
+ sb.append(" ");
final int gmtOffset = tz.getOffset(timeMillis);
int gmtStart = sb.length();
appendGmtOffset(sb, gmtOffset);
@@ -103,8 +105,10 @@
// Set the gray colors.
Spannable spannableText = mSpannableFactory.newSpannable(sb);
- spannableText.setSpan(new ForegroundColorSpan(GMT_TEXT_COLOR),
- gmtStart, gmtEnd, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+ if (grayGmt) {
+ spannableText.setSpan(new ForegroundColorSpan(GMT_TEXT_COLOR),
+ gmtStart, gmtEnd, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+ }
if (tz.useDaylightTime()) {
spannableText.setSpan(new ForegroundColorSpan(DST_SYMBOL_COLOR),
symbolStart, symbolEnd, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);