Skip to content
Browse files

Timezone notification only shown when tz has actually changed. Notifi…

…cation now includes tz name.
  • Loading branch information...
1 parent 325b7c2 commit 7858760ea497cdf9bb333625a9b81649d68385d1 @benjymous committed Apr 21, 2012
View
27 src/org/metawatch/manager/IntentReceiver.java
@@ -32,6 +32,8 @@
package org.metawatch.manager;
+import java.util.TimeZone;
+
import org.metawatch.manager.MetaWatchService.Preferences;
import android.content.BroadcastReceiver;
@@ -45,6 +47,8 @@
public class IntentReceiver extends BroadcastReceiver {
+ static String lastTimeZoneName = "";
+
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
@@ -195,12 +199,23 @@ else if (action.equals("android.intent.action.TIMEZONE_CHANGED") ) {
* Notify the watch.
*/
Protocol.sendRtcNow(context);
-
- SharedPreferences sharedPreferences = PreferenceManager
- .getDefaultSharedPreferences(context);
- if (sharedPreferences.getBoolean("settingsNotifyTimezoneChange",
- false)) {
- NotificationBuilder.createTimezonechange(context);
+
+ /*
+ * Check that the timezone has actually changed, so that we don't
+ * spam the user with notifications.
+ */
+
+ TimeZone tz = TimeZone.getDefault();
+ if (!tz.getDisplayName().equals(lastTimeZoneName))
+ {
+ lastTimeZoneName = tz.getDisplayName();
+
+ SharedPreferences sharedPreferences = PreferenceManager
+ .getDefaultSharedPreferences(context);
+ if (sharedPreferences.getBoolean("settingsNotifyTimezoneChange",
+ false)) {
+ NotificationBuilder.createTimezonechange(context);
+ }
}
return;
}
View
8 src/org/metawatch/manager/NotificationBuilder.java
@@ -35,6 +35,7 @@
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
+import java.util.TimeZone;
import org.metawatch.manager.FontCache.FontInfo;
import org.metawatch.manager.MetaWatchService.Preferences;
@@ -170,14 +171,15 @@ public static void createMusic(Context context, String artist, String track, Str
}
public static void createTimezonechange(Context context) {
- VibratePattern vibratePattern = createVibratePatternFromPreference(context, "settingsTimezoneNumberBuzzes");
+ VibratePattern vibratePattern = createVibratePatternFromPreference(context, "settingsTimezoneNumberBuzzes");
+ TimeZone tz = TimeZone.getDefault();
if (MetaWatchService.watchType == WatchType.DIGITAL) {
- Bitmap bitmap = smartLines(context, "timezone.bmp", "Timezone", new String[] {"Timezone Changed"});
+ Bitmap bitmap = smartLines(context, "timezone.bmp", "Timezone", new String[] {"Timezone Changed", tz.getDisplayName()});
Notification.addBitmapNotification(context, bitmap, vibratePattern, Notification.getDefaultNotificationTimeout(context));
} else {
Notification.addOledNotification(context, Protocol.createOled1line(
context, "timezone.bmp", "Timezone"), Protocol
- .createOled1line(context, null, "Changed"), null, 0,
+ .createOled1line(context, null, tz.getDisplayName()), null, 0,
vibratePattern);
}
}

0 comments on commit 7858760

Please sign in to comment.
Something went wrong with that request. Please try again.