summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--packages/CaptivePortalLogin/res/values-eu-rES/strings.xml2
-rw-r--r--packages/CaptivePortalLogin/res/values-kk-rKZ/strings.xml2
-rw-r--r--packages/CaptivePortalLogin/res/values-ky-rKG/strings.xml4
-rw-r--r--packages/CaptivePortalLogin/res/values-ne-rNP/strings.xml2
-rw-r--r--packages/CaptivePortalLogin/res/values-uz-rUZ/strings.xml2
-rw-r--r--packages/DocumentsUI/res/values-sk/strings.xml2
-rw-r--r--packages/DocumentsUI/res/values-ta-rIN/strings.xml2
-rw-r--r--packages/PrintSpooler/res/values-fa/strings.xml2
-rw-r--r--packages/PrintSpooler/res/values-ka-rGE/strings.xml3
-rw-r--r--packages/PrintSpooler/res/values-ky-rKG/strings.xml3
-rw-r--r--packages/PrintSpooler/res/values-ur-rPK/strings.xml2
-rw-r--r--packages/PrintSpooler/res/values-zh-rCN/strings.xml3
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/datetime/ZoneGetter.java182
13 files changed, 138 insertions, 73 deletions
diff --git a/packages/CaptivePortalLogin/res/values-eu-rES/strings.xml b/packages/CaptivePortalLogin/res/values-eu-rES/strings.xml
index f7083b6a..a46768f 100644
--- a/packages/CaptivePortalLogin/res/values-eu-rES/strings.xml
+++ b/packages/CaptivePortalLogin/res/values-eu-rES/strings.xml
@@ -6,6 +6,6 @@
<string name="action_do_not_use_network" msgid="4577366536956516683">"Ez erabili sare hau"</string>
<string name="action_bar_label" msgid="917235635415966620">"Hasi saioa sarean"</string>
<string name="ssl_error_warning" msgid="6653188881418638872">"Erabili nahi duzun sareak segurtasun-arazoak ditu."</string>
- <string name="ssl_error_example" msgid="647898534624078900">"Adibidez, litekeena da saioa hasteko orria adierazitako erakundearena ez izatea."</string>
+ <string name="ssl_error_example" msgid="647898534624078900">"Adibidez, baliteke saioa hasteko orria adierazitako erakundearena ez izatea."</string>
<string name="ssl_error_continue" msgid="6492718244923937110">"Jarraitu arakatzailearen bidez, halere"</string>
</resources>
diff --git a/packages/CaptivePortalLogin/res/values-kk-rKZ/strings.xml b/packages/CaptivePortalLogin/res/values-kk-rKZ/strings.xml
index 0fdd0f6..d1fb849 100644
--- a/packages/CaptivePortalLogin/res/values-kk-rKZ/strings.xml
+++ b/packages/CaptivePortalLogin/res/values-kk-rKZ/strings.xml
@@ -5,7 +5,7 @@
<string name="action_use_network" msgid="6076184727448466030">"Осы желіні бар күйінде пайдалану"</string>
<string name="action_do_not_use_network" msgid="4577366536956516683">"Осы желіні пайдаланбау"</string>
<string name="action_bar_label" msgid="917235635415966620">"Желіге кіру"</string>
- <string name="ssl_error_warning" msgid="6653188881418638872">"Қосылуға әрекет етіп жатқан желіде қауіпсіздік ақаулары бар."</string>
+ <string name="ssl_error_warning" msgid="6653188881418638872">"Қосылайын деп жатқан желіңіз қауіпсіз болуы мүмкін."</string>
<string name="ssl_error_example" msgid="647898534624078900">"Мысалы, кіру беті көрсетілген ұйымға тиесілі болмауы мүмкін."</string>
<string name="ssl_error_continue" msgid="6492718244923937110">"Бәрібір браузер арқылы жалғастыру"</string>
</resources>
diff --git a/packages/CaptivePortalLogin/res/values-ky-rKG/strings.xml b/packages/CaptivePortalLogin/res/values-ky-rKG/strings.xml
index f2be6bc..ab1c7ff 100644
--- a/packages/CaptivePortalLogin/res/values-ky-rKG/strings.xml
+++ b/packages/CaptivePortalLogin/res/values-ky-rKG/strings.xml
@@ -6,6 +6,6 @@
<string name="action_do_not_use_network" msgid="4577366536956516683">"Бул тармак колдонулбасын"</string>
<string name="action_bar_label" msgid="917235635415966620">"Тармакка кирүү"</string>
<string name="ssl_error_warning" msgid="6653188881418638872">"Кошулайын деген тармагыңызда коопсуздук көйгөйлөрү бар."</string>
- <string name="ssl_error_example" msgid="647898534624078900">"Мисалы, кирүү баракчасы уюм көрсөтүүсүнө таандык эмес болушу мүмкүн."</string>
- <string name="ssl_error_continue" msgid="6492718244923937110">"Баары бир браузер аркылуу улантуу"</string>
+ <string name="ssl_error_example" msgid="647898534624078900">"Мисалы, каттоо эсебине кирүү баракчасы көрсөтүлгөн уюмга таандык эмес болушу мүмкүн."</string>
+ <string name="ssl_error_continue" msgid="6492718244923937110">"Баары бир серепчи аркылуу улантуу"</string>
</resources>
diff --git a/packages/CaptivePortalLogin/res/values-ne-rNP/strings.xml b/packages/CaptivePortalLogin/res/values-ne-rNP/strings.xml
index 476b37e..02c2cf3 100644
--- a/packages/CaptivePortalLogin/res/values-ne-rNP/strings.xml
+++ b/packages/CaptivePortalLogin/res/values-ne-rNP/strings.xml
@@ -5,7 +5,7 @@
<string name="action_use_network" msgid="6076184727448466030">"यो सञ्जाल जस्तो छ प्रयोग गर्नुहोस्"</string>
<string name="action_do_not_use_network" msgid="4577366536956516683">"यो सञ्जाल प्रयोग नगर्नुहोस्"</string>
<string name="action_bar_label" msgid="917235635415966620">"सञ्जालमा साइन इन गर्नुहोस्"</string>
- <string name="ssl_error_warning" msgid="6653188881418638872">"तपाईँले सामिल हुन प्रयास गरिरहनु भएको नेटवर्कमा सुरक्षा मुद्दाहरू छन्।"</string>
+ <string name="ssl_error_warning" msgid="6653188881418638872">"तपाईँले सामेल हुन प्रयास गरिरहनु भएको नेटवर्कमा सुरक्षा मुद्दाहरू छन्।"</string>
<string name="ssl_error_example" msgid="647898534624078900">"उदाहरणका लागि, लग इन पृष्ठ देखाइएको संस्थाको नहुन सक्छ।"</string>
<string name="ssl_error_continue" msgid="6492718244923937110">"जे भए पनि ब्राउजर मार्फत जारी राख्नुहोस्"</string>
</resources>
diff --git a/packages/CaptivePortalLogin/res/values-uz-rUZ/strings.xml b/packages/CaptivePortalLogin/res/values-uz-rUZ/strings.xml
index 20eb034..0cbef0a 100644
--- a/packages/CaptivePortalLogin/res/values-uz-rUZ/strings.xml
+++ b/packages/CaptivePortalLogin/res/values-uz-rUZ/strings.xml
@@ -7,5 +7,5 @@
<string name="action_bar_label" msgid="917235635415966620">"Tarmoqqa kirish"</string>
<string name="ssl_error_warning" msgid="6653188881418638872">"Siz ulanmoqchi bo‘lgan tarmoqda xavfsizlik bilan bog‘liq muammolar mavjud."</string>
<string name="ssl_error_example" msgid="647898534624078900">"Masalan, tizimga kirish sahifasi ko‘rsatilgan tashkilotga tegishli bo‘lmasligi mumkin."</string>
- <string name="ssl_error_continue" msgid="6492718244923937110">"Brauzer orqali davom etaversin"</string>
+ <string name="ssl_error_continue" msgid="6492718244923937110">"E’tiborsiz qoldirilsin va brauzer ochilsin"</string>
</resources>
diff --git a/packages/DocumentsUI/res/values-sk/strings.xml b/packages/DocumentsUI/res/values-sk/strings.xml
index 3c86d7f..071c1fa 100644
--- a/packages/DocumentsUI/res/values-sk/strings.xml
+++ b/packages/DocumentsUI/res/values-sk/strings.xml
@@ -49,7 +49,7 @@
<string name="create_error" msgid="3735649141335444215">"Priečinok sa nepodarilo vytvoriť"</string>
<string name="query_error" msgid="1222448261663503501">"Zoznam dokumentov sa nepodarilo načítať"</string>
<string name="root_recent" msgid="4470053704320518133">"Nedávne"</string>
- <string name="root_available_bytes" msgid="8568452858617033281">"Voľné: <xliff:g id="SIZE">%1$s</xliff:g>"</string>
+ <string name="root_available_bytes" msgid="8568452858617033281">"Voľné <xliff:g id="SIZE">%1$s</xliff:g>"</string>
<string name="root_type_service" msgid="2178854894416775409">"Služby úložiska"</string>
<string name="root_type_shortcut" msgid="3318760609471618093">"Skratky"</string>
<string name="root_type_device" msgid="7121342474653483538">"Zariadenia"</string>
diff --git a/packages/DocumentsUI/res/values-ta-rIN/strings.xml b/packages/DocumentsUI/res/values-ta-rIN/strings.xml
index 2e012b3..ba0c09b 100644
--- a/packages/DocumentsUI/res/values-ta-rIN/strings.xml
+++ b/packages/DocumentsUI/res/values-ta-rIN/strings.xml
@@ -41,7 +41,7 @@
<string name="button_copy" msgid="8706475544635021302">"நகலெடு"</string>
<string name="mode_selected_count" msgid="459111894725594625">"<xliff:g id="COUNT">%1$d</xliff:g> தேர்ந்தெடுக்கப்பட்டன"</string>
<string name="sort_name" msgid="9183560467917256779">"பெயரின்படி"</string>
- <string name="sort_date" msgid="586080032956151448">"தேதியின்படி திருத்தப்பட்டது"</string>
+ <string name="sort_date" msgid="586080032956151448">"திருத்தப்பட்ட தேதியின்படி"</string>
<string name="sort_size" msgid="3350681319735474741">"அளவின்படி"</string>
<string name="drawer_open" msgid="4545466532430226949">"வழிகளைக் காட்டு"</string>
<string name="drawer_close" msgid="7602734368552123318">"வழிகளை மறை"</string>
diff --git a/packages/PrintSpooler/res/values-fa/strings.xml b/packages/PrintSpooler/res/values-fa/strings.xml
index a5a9f01..0e1629f 100644
--- a/packages/PrintSpooler/res/values-fa/strings.xml
+++ b/packages/PrintSpooler/res/values-fa/strings.xml
@@ -59,7 +59,7 @@
<item quantity="other"><xliff:g id="COUNT_1">%1$s</xliff:g> چاپگر یافت شد</item>
</plurals>
<string name="choose_print_service" msgid="3740309762324459694">"انتخاب سرویس چاپ"</string>
- <string name="print_searching_for_printers" msgid="6550424555079932867">"در حال جستجو برای چاپگرها"</string>
+ <string name="print_searching_for_printers" msgid="6550424555079932867">"درحال جستجوی چاپگرها"</string>
<string name="print_no_printers" msgid="4869403323900054866">"هیچ چاپگری یافت نشد"</string>
<string name="printing_notification_title_template" msgid="295903957762447362">"در حال چاپ <xliff:g id="PRINT_JOB_NAME">%1$s</xliff:g>"</string>
<string name="cancelling_notification_title_template" msgid="1821759594704703197">"در حال لغو <xliff:g id="PRINT_JOB_NAME">%1$s</xliff:g>"</string>
diff --git a/packages/PrintSpooler/res/values-ka-rGE/strings.xml b/packages/PrintSpooler/res/values-ka-rGE/strings.xml
index b18e614..b65d013 100644
--- a/packages/PrintSpooler/res/values-ka-rGE/strings.xml
+++ b/packages/PrintSpooler/res/values-ka-rGE/strings.xml
@@ -24,8 +24,7 @@
<string name="label_paper_size" msgid="908654383827777759">"ფურცლის ზომა"</string>
<string name="label_paper_size_summary" msgid="5668204981332138168">"ფურცლის ზომა:"</string>
<string name="label_color" msgid="1108690305218188969">"ფერი"</string>
- <!-- no translation found for label_duplex (5370037254347072243) -->
- <skip />
+ <string name="label_duplex" msgid="5370037254347072243">"ორმხრივი"</string>
<string name="label_orientation" msgid="2853142581990496477">"ორიენტაცია"</string>
<string name="label_pages" msgid="7768589729282182230">"გვერდები"</string>
<string name="template_all_pages" msgid="3322235982020148762">"ყველა <xliff:g id="PAGE_COUNT">%1$s</xliff:g>"</string>
diff --git a/packages/PrintSpooler/res/values-ky-rKG/strings.xml b/packages/PrintSpooler/res/values-ky-rKG/strings.xml
index bfcb49f..7f6eb10 100644
--- a/packages/PrintSpooler/res/values-ky-rKG/strings.xml
+++ b/packages/PrintSpooler/res/values-ky-rKG/strings.xml
@@ -24,8 +24,7 @@
<string name="label_paper_size" msgid="908654383827777759">"Барактын өлчөмү"</string>
<string name="label_paper_size_summary" msgid="5668204981332138168">"Барактын өлчөмү:"</string>
<string name="label_color" msgid="1108690305218188969">"Түс"</string>
- <!-- no translation found for label_duplex (5370037254347072243) -->
- <skip />
+ <string name="label_duplex" msgid="5370037254347072243">"Эки тараптуу"</string>
<string name="label_orientation" msgid="2853142581990496477">"Багыттоо"</string>
<string name="label_pages" msgid="7768589729282182230">"Баракчалар"</string>
<string name="template_all_pages" msgid="3322235982020148762">"Бардыгы <xliff:g id="PAGE_COUNT">%1$s</xliff:g>"</string>
diff --git a/packages/PrintSpooler/res/values-ur-rPK/strings.xml b/packages/PrintSpooler/res/values-ur-rPK/strings.xml
index c0fe2df..2c2c460 100644
--- a/packages/PrintSpooler/res/values-ur-rPK/strings.xml
+++ b/packages/PrintSpooler/res/values-ur-rPK/strings.xml
@@ -24,7 +24,7 @@
<string name="label_paper_size" msgid="908654383827777759">"کاغذ کا سائز"</string>
<string name="label_paper_size_summary" msgid="5668204981332138168">"کاغذ کا سائز:"</string>
<string name="label_color" msgid="1108690305218188969">"رنگ"</string>
- <string name="label_duplex" msgid="5370037254347072243">"دو طرفا"</string>
+ <string name="label_duplex" msgid="5370037254347072243">"دو طرف"</string>
<string name="label_orientation" msgid="2853142581990496477">"سمت بندی"</string>
<string name="label_pages" msgid="7768589729282182230">"صفحات"</string>
<string name="template_all_pages" msgid="3322235982020148762">"سبھی <xliff:g id="PAGE_COUNT">%1$s</xliff:g>"</string>
diff --git a/packages/PrintSpooler/res/values-zh-rCN/strings.xml b/packages/PrintSpooler/res/values-zh-rCN/strings.xml
index 9886be6..553bc89 100644
--- a/packages/PrintSpooler/res/values-zh-rCN/strings.xml
+++ b/packages/PrintSpooler/res/values-zh-rCN/strings.xml
@@ -24,8 +24,7 @@
<string name="label_paper_size" msgid="908654383827777759">"纸张尺寸"</string>
<string name="label_paper_size_summary" msgid="5668204981332138168">"纸张尺寸:"</string>
<string name="label_color" msgid="1108690305218188969">"颜色"</string>
- <!-- no translation found for label_duplex (5370037254347072243) -->
- <skip />
+ <string name="label_duplex" msgid="5370037254347072243">"双面"</string>
<string name="label_orientation" msgid="2853142581990496477">"方向"</string>
<string name="label_pages" msgid="7768589729282182230">"页数"</string>
<string name="template_all_pages" msgid="3322235982020148762">"全部<xliff:g id="PAGE_COUNT">%1$s</xliff:g>页"</string>
diff --git a/packages/SettingsLib/src/com/android/settingslib/datetime/ZoneGetter.java b/packages/SettingsLib/src/com/android/settingslib/datetime/ZoneGetter.java
index 12ead4e..7b5bfb5 100644
--- a/packages/SettingsLib/src/com/android/settingslib/datetime/ZoneGetter.java
+++ b/packages/SettingsLib/src/com/android/settingslib/datetime/ZoneGetter.java
@@ -32,13 +32,14 @@ import org.xmlpull.v1.XmlPullParserException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
-import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.List;
import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
import java.util.TimeZone;
+import java.util.TreeSet;
public class ZoneGetter {
private static final String TAG = "ZoneGetter";
@@ -50,17 +51,120 @@ public class ZoneGetter {
public static final String KEY_GMT = "gmt"; // value: String
public static final String KEY_OFFSET = "offset"; // value: int (Integer)
- private final List<HashMap<String, Object>> mZones = new ArrayList<>();
- private final HashSet<String> mLocalZones = new HashSet<>();
- private final Date mNow = Calendar.getInstance().getTime();
- private final SimpleDateFormat mZoneNameFormatter = new SimpleDateFormat("zzzz");
+ private ZoneGetter() {}
- public List<HashMap<String, Object>> getZones(Context context) {
- for (String olsonId : TimeZoneNames.forLocale(Locale.getDefault())) {
- mLocalZones.add(olsonId);
+ public static String getTimeZoneOffsetAndName(TimeZone tz, Date now) {
+ Locale locale = Locale.getDefault();
+ String gmtString = getGmtOffsetString(locale, tz, now);
+ String zoneNameString = getZoneLongName(locale, tz, now);
+ if (zoneNameString == null) {
+ return gmtString;
+ }
+
+ // We don't use punctuation here to avoid having to worry about localizing that too!
+ return gmtString + " " + zoneNameString;
+ }
+
+ public static List<Map<String, Object>> getZonesList(Context context) {
+ final Locale locale = Locale.getDefault();
+ final Date now = new Date();
+
+ // The display name chosen for each zone entry depends on whether the zone is one associated
+ // with the country of the user's chosen locale. For "local" zones we prefer the "long name"
+ // (e.g. "Europe/London" -> "British Summer Time" for people in the UK). For "non-local"
+ // zones we prefer the exemplar location (e.g. "Europe/London" -> "London" for English
+ // speakers from outside the UK). This heuristic is based on the fact that people are
+ // typically familiar with their local timezones and exemplar locations don't always match
+ // modern-day expectations for people living in the country covered. Large countries like
+ // China that mostly use a single timezone (olson id: "Asia/Shanghai") may not live near
+ // "Shanghai" and prefer the long name over the exemplar location. The only time we don't
+ // follow this policy for local zones is when Android supplies multiple olson IDs to choose
+ // from and the use of a zone's long name leads to ambiguity. For example, at the time of
+ // writing Android lists 5 olson ids for Australia which collapse to 2 different zone names
+ // in winter but 4 different zone names in summer. The ambiguity leads to the users
+ // selecting the wrong olson ids.
+
+ // Get the list of olson ids to display to the user.
+ List<String> olsonIdsToDisplay = readTimezonesToDisplay(context);
+
+ // Create a lookup of local zone IDs.
+ Set<String> localZoneIds = new TreeSet<String>();
+ for (String olsonId : TimeZoneNames.forLocale(locale)) {
+ localZoneIds.add(olsonId);
+ }
+
+ // Work out whether the long names for the local entries that we would show by default would
+ // be ambiguous.
+ Set<String> localZoneNames = new TreeSet<String>();
+ boolean localLongNamesAreAmbiguous = false;
+ for (String olsonId : olsonIdsToDisplay) {
+ if (localZoneIds.contains(olsonId)) {
+ TimeZone tz = TimeZone.getTimeZone(olsonId);
+ String zoneLongName = getZoneLongName(locale, tz, now);
+ boolean longNameIsUnique = localZoneNames.add(zoneLongName);
+ if (!longNameIsUnique) {
+ localLongNamesAreAmbiguous = true;
+ break;
+ }
+ }
+ }
+
+ // Generate the list of zone entries to return.
+ List<Map<String, Object>> zones = new ArrayList<Map<String, Object>>();
+ for (String olsonId : olsonIdsToDisplay) {
+ final TimeZone tz = TimeZone.getTimeZone(olsonId);
+ // Exemplar location display is the default. The only time we intend to display the long
+ // name is when the olsonId is local AND long names are not ambiguous.
+ boolean isLocalZoneId = localZoneIds.contains(olsonId);
+ boolean preferLongName = isLocalZoneId && !localLongNamesAreAmbiguous;
+ String displayName = getZoneDisplayName(locale, tz, now, preferLongName);
+
+ String gmtOffsetString = getGmtOffsetString(locale, tz, now);
+ int offsetMillis = tz.getOffset(now.getTime());
+ Map<String, Object> displayEntry =
+ createDisplayEntry(tz, gmtOffsetString, displayName, offsetMillis);
+ zones.add(displayEntry);
+ }
+ return zones;
+ }
+
+ private static Map<String, Object> createDisplayEntry(
+ TimeZone tz, String gmtOffsetString, String displayName, int offsetMillis) {
+ Map<String, Object> map = new HashMap<String, Object>();
+ map.put(KEY_ID, tz.getID());
+ map.put(KEY_DISPLAYNAME, displayName);
+ map.put(KEY_GMT, gmtOffsetString);
+ map.put(KEY_OFFSET, offsetMillis);
+ return map;
+ }
+
+ /**
+ * Returns a name for the specific zone. If {@code preferLongName} is {@code true} then the
+ * long display name for the timezone will be used, otherwise the exemplar location will be
+ * preferred.
+ */
+ private static String getZoneDisplayName(Locale locale, TimeZone tz, Date now,
+ boolean preferLongName) {
+ String zoneNameString;
+ if (preferLongName) {
+ zoneNameString = getZoneLongName(locale, tz, now);
+ } else {
+ zoneNameString = getZoneExemplarLocation(locale, tz);
+ if (zoneNameString == null || zoneNameString.isEmpty()) {
+ // getZoneExemplarLocation can return null.
+ zoneNameString = getZoneLongName(locale, tz, now);
+ }
}
- try {
- XmlResourceParser xrp = context.getResources().getXml(R.xml.timezones);
+ return zoneNameString;
+ }
+
+ private static String getZoneExemplarLocation(Locale locale, TimeZone tz) {
+ return TimeZoneNames.getExemplarLocation(locale.toString(), tz.getID());
+ }
+
+ private static List<String> readTimezonesToDisplay(Context context) {
+ List<String> olsonIds = new ArrayList<String>();
+ try (XmlResourceParser xrp = context.getResources().getXml(R.xml.timezones)) {
while (xrp.next() != XmlResourceParser.START_TAG) {
continue;
}
@@ -68,58 +172,34 @@ public class ZoneGetter {
while (xrp.getEventType() != XmlResourceParser.END_TAG) {
while (xrp.getEventType() != XmlResourceParser.START_TAG) {
if (xrp.getEventType() == XmlResourceParser.END_DOCUMENT) {
- return mZones;
+ return olsonIds;
}
xrp.next();
}
if (xrp.getName().equals(XMLTAG_TIMEZONE)) {
String olsonId = xrp.getAttributeValue(0);
- addTimeZone(olsonId);
+ olsonIds.add(olsonId);
}
while (xrp.getEventType() != XmlResourceParser.END_TAG) {
xrp.next();
}
xrp.next();
}
- xrp.close();
} catch (XmlPullParserException xppe) {
Log.e(TAG, "Ill-formatted timezones.xml file");
} catch (java.io.IOException ioe) {
Log.e(TAG, "Unable to read timezones.xml file");
}
- return mZones;
+ return olsonIds;
}
- private void addTimeZone(String olsonId) {
- // We always need the "GMT-07:00" string.
- final TimeZone tz = TimeZone.getTimeZone(olsonId);
-
- // For the display name, we treat time zones within the country differently
- // from other countries' time zones. So in en_US you'd get "Pacific Daylight Time"
- // but in de_DE you'd get "Los Angeles" for the same time zone.
- String displayName;
- if (mLocalZones.contains(olsonId)) {
- // Within a country, we just use the local name for the time zone.
- mZoneNameFormatter.setTimeZone(tz);
- displayName = mZoneNameFormatter.format(mNow);
- } else {
- // For other countries' time zones, we use the exemplar location.
- final String localeName = Locale.getDefault().toString();
- displayName = TimeZoneNames.getExemplarLocation(localeName, olsonId);
- }
-
- final HashMap<String, Object> map = new HashMap<>();
- map.put(KEY_ID, olsonId);
- map.put(KEY_DISPLAYNAME, displayName);
- map.put(KEY_GMT, getTimeZoneText(tz, false));
- map.put(KEY_OFFSET, tz.getOffset(mNow.getTime()));
-
- mZones.add(map);
+ private static String getZoneLongName(Locale locale, TimeZone tz, Date now) {
+ boolean daylight = tz.inDaylightTime(now);
+ // This returns a name if it can, or will fall back to GMT+0X:00 format.
+ return tz.getDisplayName(daylight, TimeZone.LONG, locale);
}
- public static String getTimeZoneText(TimeZone tz, boolean includeName) {
- Date now = new Date();
-
+ private static String getGmtOffsetString(Locale locale, TimeZone tz, Date now) {
// Use SimpleDateFormat to format the GMT+00:00 string.
SimpleDateFormat gmtFormatter = new SimpleDateFormat("ZZZZ");
gmtFormatter.setTimeZone(tz);
@@ -127,21 +207,9 @@ public class ZoneGetter {
// Ensure that the "GMT+" stays with the "00:00" even if the digits are RTL.
BidiFormatter bidiFormatter = BidiFormatter.getInstance();
- Locale l = Locale.getDefault();
- boolean isRtl = TextUtils.getLayoutDirectionFromLocale(l) == View.LAYOUT_DIRECTION_RTL;
+ boolean isRtl = TextUtils.getLayoutDirectionFromLocale(locale) == View.LAYOUT_DIRECTION_RTL;
gmtString = bidiFormatter.unicodeWrap(gmtString,
isRtl ? TextDirectionHeuristics.RTL : TextDirectionHeuristics.LTR);
-
- if (!includeName) {
- return gmtString;
- }
-
- // Optionally append the time zone name.
- SimpleDateFormat zoneNameFormatter = new SimpleDateFormat("zzzz");
- zoneNameFormatter.setTimeZone(tz);
- String zoneNameString = zoneNameFormatter.format(now);
-
- // We don't use punctuation here to avoid having to worry about localizing that too!
- return gmtString + " " + zoneNameString;
+ return gmtString;
}
}