OSDN Git Service

Will now update time format on resume
authorErik <roboerik@android.com>
Wed, 24 Mar 2010 00:03:28 +0000 (17:03 -0700)
committerErik <roboerik@android.com>
Wed, 24 Mar 2010 00:03:28 +0000 (17:03 -0700)
We weren't refreshing the time strings when the format changed to/from
24 hour mode. Now it will update in onResume to make sure we catch any
changes.

Change-Id: I829779fe09062cd65449810c94f90bbda42f84a2

src/com/android/calendar/CalendarActivity.java
src/com/android/calendar/CalendarView.java

index 02bfdbf..982268d 100644 (file)
@@ -140,8 +140,12 @@ public class CalendarActivity extends Activity implements Navigator {
         mEventLoader.startBackgroundThread();
         eventsChanged();
         CalendarView view = (CalendarView) mViewSwitcher.getCurrentView();
+        view.updateIs24HourFormat();
         view.restartCurrentTimeUpdates();
 
+        view = (CalendarView) mViewSwitcher.getNextView();
+        view.updateIs24HourFormat();
+
         // Register for Intent broadcasts
         IntentFilter filter = new IntentFilter();
 
index 4618454..da17af6 100644 (file)
@@ -475,9 +475,7 @@ public class CalendarView extends View
 
         p.setTextSize(HOURS_FONT_SIZE);
         p.setTypeface(null);
-        mIs24HourFormat = DateFormat.is24HourFormat(context);
-        mHourStrs = mIs24HourFormat ? CalendarData.s24Hours : CalendarData.s12HoursNoAmPm;
-        mHoursWidth = computeMaxStringWidth(0, mHourStrs, p);
+        updateIs24HourFormat();
 
         mAmString = DateUtils.getAMPMString(Calendar.AM);
         mPmString = DateUtils.getAMPMString(Calendar.PM);
@@ -526,6 +524,11 @@ public class CalendarView extends View
         }
     }
 
+    public void updateIs24HourFormat() {
+        mIs24HourFormat = DateFormat.is24HourFormat(mParentActivity);
+        mHourStrs = mIs24HourFormat ? CalendarData.s24Hours : CalendarData.s12HoursNoAmPm;
+    }
+
     /**
      * Returns the start of the selected time in milliseconds since the epoch.
      *