diff options
author | Erik <roboerik@android.com> | 2010-09-07 15:03:21 -0700 |
---|---|---|
committer | Erik <roboerik@android.com> | 2010-09-07 15:03:21 -0700 |
commit | 275232dae58bb24e3360a779ada9d24601a99bcf (patch) | |
tree | 7b22ca968bd46642ba8a6cc7ecaaeb6332391165 /src/com/android/calendar/Utils.java | |
parent | a546201601564de619c56d4bdaad3d41023c742e (diff) | |
parent | 9ccb1dd06d38173ce11f6a3e99a825c52f29da1b (diff) | |
download | android_packages_apps_Calendar-275232dae58bb24e3360a779ada9d24601a99bcf.tar.gz android_packages_apps_Calendar-275232dae58bb24e3360a779ada9d24601a99bcf.tar.bz2 android_packages_apps_Calendar-275232dae58bb24e3360a779ada9d24601a99bcf.zip |
resolved conflicts for merge of 9ccb1dd0 to master
Change-Id: Ifcc5c862dca3f296c87aa63dfa5bd6c54026d79a
Diffstat (limited to 'src/com/android/calendar/Utils.java')
-rw-r--r-- | src/com/android/calendar/Utils.java | 50 |
1 files changed, 48 insertions, 2 deletions
diff --git a/src/com/android/calendar/Utils.java b/src/com/android/calendar/Utils.java index b1c3d2f0..c6ea6d3d 100644 --- a/src/com/android/calendar/Utils.java +++ b/src/com/android/calendar/Utils.java @@ -41,6 +41,8 @@ import java.util.Map; import java.util.TimeZone; public class Utils { + private static final boolean DEBUG = true; + private static final String TAG = "CalUtils"; // Set to 0 until we have UI to perform undo public static final long UNDO_DELAY = 0; @@ -62,14 +64,13 @@ public class Utils { protected static final String OPEN_EMAIL_MARKER = " <"; protected static final String CLOSE_EMAIL_MARKER = ">"; - /* The corner should be rounded on the top right and bottom right */ private static final float[] CORNERS = new float[] {0, 0, 5, 5, 5, 5, 0, 0}; public static final String INTENT_KEY_DETAIL_VIEW = "DETAIL_VIEW"; public static final String INTENT_KEY_VIEW_TYPE = "VIEW"; public static final String INTENT_VALUE_VIEW_TYPE_DAY = "DAY"; - + private volatile static boolean mFirstTZRequest = true; private volatile static boolean mTZQueryInProgress = false; @@ -103,6 +104,44 @@ public class Utils { } /** + * Writes a new home time zone to the db. + * + * Updates the home time zone in the db asynchronously and updates + * the local cache. Sending a time zone of **tbd** will cause it to + * be set to the device's time zone. null or empty tz will be ignored. + * + * @param context The calling activity + * @param timeZone The time zone to set Calendar to, or **tbd** + */ + public static void setTimeZone(Context context, String timeZone) { + if (TextUtils.isEmpty(timeZone)) { + if (DEBUG) { + Log.d(TAG, "Empty time zone, nothing to be done."); + } + return; + } + synchronized (mTZCallbacks) { + if (CalendarPreferenceActivity.LOCAL_TZ.equals(timeZone)) { + if (!mUseHomeTZ) { + return; + } + mUseHomeTZ = false; + } else { + if (TextUtils.equals(mHomeTZ, timeZone)) { + return; + } + mUseHomeTZ = true; + mHomeTZ = timeZone; + } + } + setSharedPreference(context, CalendarPreferenceActivity.KEY_HOME_TZ_ENABLED, mUseHomeTZ); + if (mUseHomeTZ) { + setSharedPreference(context, CalendarPreferenceActivity.KEY_HOME_TZ, mHomeTZ); + } + // TODO async update db + } + + /** * Gets the time zone that Calendar should be displayed in * * This is a helper method to get the appropriate time zone for Calendar. If this @@ -164,6 +203,13 @@ public class Utils { prefs.edit().putString(key, value).apply(); } + static void setSharedPreference(Context context, String key, boolean value) { + SharedPreferences prefs = CalendarPreferenceActivity.getSharedPreferences(context); + SharedPreferences.Editor editor = prefs.edit(); + editor.putBoolean(key, value); + editor.apply(); + } + /** * Save default agenda/day/week/month view for next time * |