summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorErik <roboerik@android.com>2010-09-09 17:19:39 -0700
committerErik <roboerik@android.com>2010-09-09 17:19:39 -0700
commit32a73e62728d3fdba7952bb9cc9a224db22a8d0f (patch)
treec8af3ff94cf8f2afc283f90f2a5ad1c30632c601 /src/com
parent90e17ed5901d2356612cc2dbb635f7dddf037728 (diff)
downloadandroid_packages_apps_Calendar-32a73e62728d3fdba7952bb9cc9a224db22a8d0f.tar.gz
android_packages_apps_Calendar-32a73e62728d3fdba7952bb9cc9a224db22a8d0f.tar.bz2
android_packages_apps_Calendar-32a73e62728d3fdba7952bb9cc9a224db22a8d0f.zip
**DO NOT MERGE** Adds home tz info to agenda title
Change-Id: I66bd77566002d9149e851ad3aea5d6942e58080a
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/calendar/AgendaActivity.java31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/com/android/calendar/AgendaActivity.java b/src/com/android/calendar/AgendaActivity.java
index 2c68873e..7fbf3dff 100644
--- a/src/com/android/calendar/AgendaActivity.java
+++ b/src/com/android/calendar/AgendaActivity.java
@@ -30,12 +30,18 @@ import android.database.ContentObserver;
import android.os.Bundle;
import android.os.Handler;
import android.provider.Calendar.Events;
+import android.text.TextUtils;
+import android.text.format.DateFormat;
+import android.text.format.DateUtils;
import android.text.format.Time;
import android.util.Log;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
+import java.util.Locale;
+import java.util.TimeZone;
+
public class AgendaActivity extends Activity implements Navigator {
private static final String TAG = "AgendaActivity";
@@ -52,6 +58,8 @@ public class AgendaActivity extends Activity implements Navigator {
private Time mTime;
+ private String mTitle;
+
// This gets run if the time zone is updated in the db
private Runnable mUpdateTZ = new Runnable() {
@Override
@@ -59,6 +67,7 @@ public class AgendaActivity extends Activity implements Navigator {
long time = mTime.toMillis(true);
mTime = new Time(Utils.getTimeZone(AgendaActivity.this, this));
mTime.set(time);
+ updateTitle();
}
};
@@ -99,7 +108,7 @@ public class AgendaActivity extends Activity implements Navigator {
mContentResolver = getContentResolver();
- setTitle(R.string.agenda_view);
+ mTitle = getResources().getString(R.string.agenda_view);
long millis = 0;
mTime = new Time(Utils.getTimeZone(this, mUpdateTZ));
@@ -128,6 +137,25 @@ public class AgendaActivity extends Activity implements Navigator {
millis = System.currentTimeMillis();
}
mTime.set(millis);
+ updateTitle();
+ }
+
+ private void updateTitle() {
+ StringBuilder title = new StringBuilder(mTitle);
+ String tz = Utils.getTimeZone(this, mUpdateTZ);
+ if (!TextUtils.equals(tz, Time.getCurrentTimezone())) {
+ int flags = DateUtils.FORMAT_SHOW_TIME;
+ if (DateFormat.is24HourFormat(this)) {
+ flags |= DateUtils.FORMAT_24HOUR;
+ }
+ boolean isDST = mTime.isDst != 0;
+ long start = System.currentTimeMillis();
+ TimeZone timeZone = TimeZone.getTimeZone(tz);
+ title.append(" (").append(Utils.formatDateRange(this, start, start, flags)).append(" ")
+ .append(timeZone.getDisplayName(isDST, TimeZone.SHORT, Locale.getDefault()))
+ .append(")");
+ }
+ setTitle(title.toString());
}
@Override
@@ -163,6 +191,7 @@ public class AgendaActivity extends Activity implements Navigator {
registerReceiver(mIntentReceiver, filter);
mContentResolver.registerContentObserver(Events.CONTENT_URI, true, mObserver);
+ mUpdateTZ.run();
}
@Override