From 28b149fcfa7927589bf3061ae1d6ea5bf1518e22 Mon Sep 17 00:00:00 2001 From: Forrest Guice Date: Sun, 20 Feb 2022 12:33:35 -0700 Subject: [PATCH] getTimeZoneDisplay localized display values for LMT and LTST tzids (#561) --- .../forrestguice/suntimeswidget/LightMapDialog.java | 8 +++++--- .../suntimeswidget/SuntimesActivity.java | 2 +- .../suntimeswidget/map/WorldMapDialog.java | 8 +++++--- .../suntimeswidget/settings/WidgetTimezones.java | 12 ++++++++++++ 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/forrestguice/suntimeswidget/LightMapDialog.java b/app/src/main/java/com/forrestguice/suntimeswidget/LightMapDialog.java index 29f87021d..962ab4a3a 100644 --- a/app/src/main/java/com/forrestguice/suntimeswidget/LightMapDialog.java +++ b/app/src/main/java/com/forrestguice/suntimeswidget/LightMapDialog.java @@ -1015,10 +1015,12 @@ protected void updateTimeText(@NonNull SuntimesRiseSetDataset data) } SuntimesUtils.TimeDisplayText timeText = utils.calendarDateTimeDisplayString(context, mapTime); - if (sunTime != null) { + if (sunTime != null) + { + String tzDisplay = WidgetTimezones.getTimeZoneDisplay(context, mapTime.getTimeZone()); if (suffix.isEmpty()) - sunTime.setText(getString(R.string.datetime_format_verylong, timeText.toString(), mapTime.getTimeZone().getID())); - else sunTime.setText(SuntimesUtils.createBoldColorSpan(null, getString(R.string.datetime_format_verylong1, timeText.toString(), mapTime.getTimeZone().getID(), suffix), suffix, color_warning)); + sunTime.setText(getString(R.string.datetime_format_verylong, timeText.toString(), tzDisplay)); + else sunTime.setText(SuntimesUtils.createBoldColorSpan(null, getString(R.string.datetime_format_verylong1, timeText.toString(), tzDisplay, suffix), suffix, color_warning)); } if (offsetTime != null) diff --git a/app/src/main/java/com/forrestguice/suntimeswidget/SuntimesActivity.java b/app/src/main/java/com/forrestguice/suntimeswidget/SuntimesActivity.java index b93784d57..865104d73 100644 --- a/app/src/main/java/com/forrestguice/suntimeswidget/SuntimesActivity.java +++ b/app/src/main/java/com/forrestguice/suntimeswidget/SuntimesActivity.java @@ -1728,7 +1728,7 @@ protected void updateViews( Context context ) new SuntimesUtils.ImageSpanTag(SuntimesUtils.SPANTAG_DST, dstWarningIcon) }; - String timezoneString = getString(R.string.timezoneField, timezone.getID()); + String timezoneString = getString(R.string.timezoneField, WidgetTimezones.getTimeZoneDisplay(context, timezone)); SpannableStringBuilder timezoneSpan = SuntimesUtils.createSpan(this, timezoneString, timezoneTags); txt_timezone.setText(timezoneSpan); txt_timezone.setContentDescription(timezoneString.replaceAll(Pattern.quote(SuntimesUtils.SPANTAG_WARNING), "") diff --git a/app/src/main/java/com/forrestguice/suntimeswidget/map/WorldMapDialog.java b/app/src/main/java/com/forrestguice/suntimeswidget/map/WorldMapDialog.java index b7c0bedb1..4798a76a9 100644 --- a/app/src/main/java/com/forrestguice/suntimeswidget/map/WorldMapDialog.java +++ b/app/src/main/java/com/forrestguice/suntimeswidget/map/WorldMapDialog.java @@ -627,10 +627,12 @@ private void updateTimeText() } SuntimesUtils.TimeDisplayText timeText = utils.calendarDateTimeDisplayString(context, mapTime); - if (utcTime != null) { + if (utcTime != null) + { + String tzDisplay = WidgetTimezones.getTimeZoneDisplay(context, mapTime.getTimeZone()); if (suffix.isEmpty()) - utcTime.setText(getString(R.string.datetime_format_verylong, timeText.toString(), mapTime.getTimeZone().getID())); - else utcTime.setText(SuntimesUtils.createBoldColorSpan(null, getString(R.string.datetime_format_verylong1, timeText.toString(), mapTime.getTimeZone().getID(), suffix), suffix, color_warning)); + utcTime.setText(getString(R.string.datetime_format_verylong, timeText.toString(), tzDisplay)); + else utcTime.setText(SuntimesUtils.createBoldColorSpan(null, getString(R.string.datetime_format_verylong1, timeText.toString(), tzDisplay, suffix), suffix, color_warning)); } SuntimesUtils.TimeDisplayText offsetText = utils.timeDeltaLongDisplayString(nowMillis, mapTimeMillis, false, true, false); diff --git a/app/src/main/java/com/forrestguice/suntimeswidget/settings/WidgetTimezones.java b/app/src/main/java/com/forrestguice/suntimeswidget/settings/WidgetTimezones.java index 6f3ee6377..81fce07e9 100644 --- a/app/src/main/java/com/forrestguice/suntimeswidget/settings/WidgetTimezones.java +++ b/app/src/main/java/com/forrestguice/suntimeswidget/settings/WidgetTimezones.java @@ -94,6 +94,18 @@ public static TimeZone getTimeZone(String tzId, @Nullable Double longitude) } } + public static String getTimeZoneDisplay(Context context, TimeZone tz) { + if (tz != null) + { + switch (tz.getID()) + { + case LocalMeanTime.TIMEZONEID: return context.getString(R.string.time_localMean); + case ApparentSolarTime.TIMEZONEID: return context.getString(R.string.time_apparent); + default: return tz.getID(); + } + } else return ""; + } + /////////////////////////////////////// ///////////////////////////////////////