summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xAndroidManifest.xml7
-rw-r--r--src/com/android/settings/DateChangeReceiver.java28
-rw-r--r--src/com/android/settings/DateTimeSettings.java13
3 files changed, 48 insertions, 0 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 451f370..349bca7 100755
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -529,6 +529,13 @@
android:value="true" />
</activity>
+ <receiver android:name=".DateChangeReceiver">
+ <intent-filter>
+ <action android:name="android.intent.action.DATE_CHANGED"/>
+ <action android:name="android.intent.action.LOCALE_CHANGED"/>
+ </intent-filter>
+ </receiver>
+
<activity android:name="DateTimeSettingsSetupWizard"
android:label="@string/date_and_time"
android:theme="@style/Theme.DateTimeSettingsSetupWizard"
diff --git a/src/com/android/settings/DateChangeReceiver.java b/src/com/android/settings/DateChangeReceiver.java
new file mode 100644
index 0000000..6a3ec88
--- /dev/null
+++ b/src/com/android/settings/DateChangeReceiver.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2016 The CyanogenMod Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+
+public class DateChangeReceiver extends BroadcastReceiver {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ DateTimeSettings.updateLocaleStrings();
+ }
+}
diff --git a/src/com/android/settings/DateTimeSettings.java b/src/com/android/settings/DateTimeSettings.java
index 8a9e2ad..34753ef 100644
--- a/src/com/android/settings/DateTimeSettings.java
+++ b/src/com/android/settings/DateTimeSettings.java
@@ -40,9 +40,12 @@ import android.widget.TimePicker;
import com.android.internal.logging.MetricsLogger;
import com.android.settingslib.datetime.ZoneGetter;
+import libcore.icu.TimeZoneNames;
+import java.text.DateFormatSymbols;
import java.util.Calendar;
import java.util.Date;
+import java.util.Locale;
public class DateTimeSettings extends SettingsPreferenceFragment
implements OnSharedPreferenceChangeListener,
@@ -329,6 +332,16 @@ public class DateTimeSettings extends SettingsPreferenceFragment
if (when / 1000 < Integer.MAX_VALUE) {
((AlarmManager) context.getSystemService(Context.ALARM_SERVICE)).setTime(when);
}
+ updateLocaleStrings();
+ }
+
+ static void updateLocaleStrings() {
+ // If a device was boot up with date 1970 and then date changes to some later time,
+ // the wrong string might be cached if the country's zones have changed.
+ // See external/icu/icu4c/source/data/misc/metaZones.txt for complete mapping
+ TimeZoneNames.clearLocaleCache();
+ Locale locale = Locale.getDefault();
+ DateFormatSymbols.getInstance(locale).setZoneStrings(TimeZoneNames.getZoneStrings(locale));
}
/* package */ static void setTime(Context context, int hourOfDay, int minute) {