AllInOneActivity.java revision ab29d9ea9a4fe6b835c7f484a2273e92e8bc323d
14970159b2e6674fc5d61425aa0fcff8e5fc15bdbMichael Chan/* 24970159b2e6674fc5d61425aa0fcff8e5fc15bdbMichael Chan * Copyright (C) 2010 The Android Open Source Project 34970159b2e6674fc5d61425aa0fcff8e5fc15bdbMichael Chan * 44970159b2e6674fc5d61425aa0fcff8e5fc15bdbMichael Chan * Licensed under the Apache License, Version 2.0 (the "License"); 54970159b2e6674fc5d61425aa0fcff8e5fc15bdbMichael Chan * you may not use this file except in compliance with the License. 64970159b2e6674fc5d61425aa0fcff8e5fc15bdbMichael Chan * You may obtain a copy of the License at 74970159b2e6674fc5d61425aa0fcff8e5fc15bdbMichael Chan * 84970159b2e6674fc5d61425aa0fcff8e5fc15bdbMichael Chan * http://www.apache.org/licenses/LICENSE-2.0 94970159b2e6674fc5d61425aa0fcff8e5fc15bdbMichael Chan * 104970159b2e6674fc5d61425aa0fcff8e5fc15bdbMichael Chan * Unless required by applicable law or agreed to in writing, software 114970159b2e6674fc5d61425aa0fcff8e5fc15bdbMichael Chan * distributed under the License is distributed on an "AS IS" BASIS, 124970159b2e6674fc5d61425aa0fcff8e5fc15bdbMichael Chan * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 134970159b2e6674fc5d61425aa0fcff8e5fc15bdbMichael Chan * See the License for the specific language governing permissions and 144970159b2e6674fc5d61425aa0fcff8e5fc15bdbMichael Chan * limitations under the License. 154970159b2e6674fc5d61425aa0fcff8e5fc15bdbMichael Chan */ 164970159b2e6674fc5d61425aa0fcff8e5fc15bdbMichael Chan 174970159b2e6674fc5d61425aa0fcff8e5fc15bdbMichael Chanpackage com.android.calendar; 184970159b2e6674fc5d61425aa0fcff8e5fc15bdbMichael Chan 1983b0fe36b523192a504a1d2baf2f36676a80b9d5Michael Chanimport static android.provider.Calendar.EVENT_BEGIN_TIME; 2083b0fe36b523192a504a1d2baf2f36676a80b9d5Michael Chan 2183b0fe36b523192a504a1d2baf2f36676a80b9d5Michael Chanimport com.android.calendar.CalendarController.EventHandler; 22ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chanimport com.android.calendar.CalendarController.EventInfo; 2383b0fe36b523192a504a1d2baf2f36676a80b9d5Michael Chanimport com.android.calendar.CalendarController.EventType; 243458a1775920dda53099b7f1913cd4ec4c8b4095Michael Chanimport com.android.calendar.CalendarController.ViewType; 253458a1775920dda53099b7f1913cd4ec4c8b4095Michael Chanimport com.android.calendar.SelectCalendars.SelectCalendarsFragment; 2683b0fe36b523192a504a1d2baf2f36676a80b9d5Michael Chan 27ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chanimport android.app.ActionBar; 284970159b2e6674fc5d61425aa0fcff8e5fc15bdbMichael Chanimport android.app.Activity; 2983b0fe36b523192a504a1d2baf2f36676a80b9d5Michael Chanimport android.app.Fragment; 303458a1775920dda53099b7f1913cd4ec4c8b4095Michael Chanimport android.app.FragmentTransaction; 318e3d430a020744faa21bf4ca24f1a99c36ec5c4fMason Tangimport android.content.SharedPreferences; 328e3d430a020744faa21bf4ca24f1a99c36ec5c4fMason Tangimport android.content.SharedPreferences.OnSharedPreferenceChangeListener; 33ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chanimport android.content.res.Configuration; 344970159b2e6674fc5d61425aa0fcff8e5fc15bdbMichael Chanimport android.os.Bundle; 353458a1775920dda53099b7f1913cd4ec4c8b4095Michael Chanimport android.text.format.DateUtils; 3683b0fe36b523192a504a1d2baf2f36676a80b9d5Michael Chanimport android.text.format.Time; 372051f1275ec5e5eeffe5bbf5773860b855316d95Erikimport android.view.Menu; 383458a1775920dda53099b7f1913cd4ec4c8b4095Michael Chanimport android.view.MenuItem; 39ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chanimport android.view.View; 404970159b2e6674fc5d61425aa0fcff8e5fc15bdbMichael Chan 41ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chanpublic class AllInOneActivity extends Activity implements EventHandler, 42ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan OnSharedPreferenceChangeListener { 433458a1775920dda53099b7f1913cd4ec4c8b4095Michael Chan private static String TAG = "AllInOneActivity"; 4483b0fe36b523192a504a1d2baf2f36676a80b9d5Michael Chan public static CalendarController mController; // FRAG_TODO make private 4583b0fe36b523192a504a1d2baf2f36676a80b9d5Michael Chan 464970159b2e6674fc5d61425aa0fcff8e5fc15bdbMichael Chan @Override 4783b0fe36b523192a504a1d2baf2f36676a80b9d5Michael Chan protected void onCreate(Bundle icicle) { 4883b0fe36b523192a504a1d2baf2f36676a80b9d5Michael Chan super.onCreate(icicle); 4983b0fe36b523192a504a1d2baf2f36676a80b9d5Michael Chan 5083b0fe36b523192a504a1d2baf2f36676a80b9d5Michael Chan // This needs to be created before setContentView 5183b0fe36b523192a504a1d2baf2f36676a80b9d5Michael Chan mController = new CalendarController(this); 52ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan // Must be the first to register. Needed to remove other eventhandlers 53ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan mController.registerEventHandler(this); 5483b0fe36b523192a504a1d2baf2f36676a80b9d5Michael Chan 554970159b2e6674fc5d61425aa0fcff8e5fc15bdbMichael Chan setContentView(R.layout.all_in_one); 5683b0fe36b523192a504a1d2baf2f36676a80b9d5Michael Chan 573458a1775920dda53099b7f1913cd4ec4c8b4095Michael Chan // Get time from intent or icicle 5883b0fe36b523192a504a1d2baf2f36676a80b9d5Michael Chan long timeMillis; 5983b0fe36b523192a504a1d2baf2f36676a80b9d5Michael Chan if (icicle != null) { 6083b0fe36b523192a504a1d2baf2f36676a80b9d5Michael Chan timeMillis = icicle.getLong(EVENT_BEGIN_TIME); 6183b0fe36b523192a504a1d2baf2f36676a80b9d5Michael Chan } else { 6283b0fe36b523192a504a1d2baf2f36676a80b9d5Michael Chan timeMillis = Utils.timeFromIntentInMillis(getIntent()); 6383b0fe36b523192a504a1d2baf2f36676a80b9d5Michael Chan } 6483b0fe36b523192a504a1d2baf2f36676a80b9d5Michael Chan 658e3d430a020744faa21bf4ca24f1a99c36ec5c4fMason Tang initFragments(timeMillis); 668e3d430a020744faa21bf4ca24f1a99c36ec5c4fMason Tang 678e3d430a020744faa21bf4ca24f1a99c36ec5c4fMason Tang // Listen for changes that would require this to be refreshed 688e3d430a020744faa21bf4ca24f1a99c36ec5c4fMason Tang SharedPreferences prefs = CalendarPreferenceActivity.getSharedPreferences(this); 698e3d430a020744faa21bf4ca24f1a99c36ec5c4fMason Tang prefs.registerOnSharedPreferenceChangeListener(this); 708e3d430a020744faa21bf4ca24f1a99c36ec5c4fMason Tang } 718e3d430a020744faa21bf4ca24f1a99c36ec5c4fMason Tang 728e3d430a020744faa21bf4ca24f1a99c36ec5c4fMason Tang @Override 738e3d430a020744faa21bf4ca24f1a99c36ec5c4fMason Tang protected void onDestroy() { 748e3d430a020744faa21bf4ca24f1a99c36ec5c4fMason Tang super.onDestroy(); 758e3d430a020744faa21bf4ca24f1a99c36ec5c4fMason Tang 768e3d430a020744faa21bf4ca24f1a99c36ec5c4fMason Tang SharedPreferences prefs = CalendarPreferenceActivity.getSharedPreferences(this); 778e3d430a020744faa21bf4ca24f1a99c36ec5c4fMason Tang prefs.unregisterOnSharedPreferenceChangeListener(this); 788e3d430a020744faa21bf4ca24f1a99c36ec5c4fMason Tang } 798e3d430a020744faa21bf4ca24f1a99c36ec5c4fMason Tang 808e3d430a020744faa21bf4ca24f1a99c36ec5c4fMason Tang private void initFragments(long timeMillis) { 813458a1775920dda53099b7f1913cd4ec4c8b4095Michael Chan FragmentTransaction ft = openFragmentTransaction(); 823458a1775920dda53099b7f1913cd4ec4c8b4095Michael Chan 83ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan boolean multipane = (getResources().getConfiguration().screenLayout & 84ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan Configuration.SCREENLAYOUT_SIZE_XLARGE) != 0; 853458a1775920dda53099b7f1913cd4ec4c8b4095Michael Chan 86ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan if (multipane) { 87ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan Fragment miniMonthFrag = new MonthFragment(false, timeMillis); 88ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan ft.replace(R.id.mini_month, miniMonthFrag); 89ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan mController.registerEventHandler((EventHandler) miniMonthFrag); 90ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan 91ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan Fragment selectCalendarsFrag = new SelectCalendarsFragment(); 92ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan ft.replace(R.id.calendar_list, selectCalendarsFrag); 93ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan } else { 94ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan findViewById(R.id.mini_month).setVisibility(View.GONE); 95ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan findViewById(R.id.calendar_list).setVisibility(View.GONE); 96ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan } 973458a1775920dda53099b7f1913cd4ec4c8b4095Michael Chan 9883b0fe36b523192a504a1d2baf2f36676a80b9d5Michael Chan // FRAG_TODO restore event.viewType from icicle 99ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan setMainPane(ft, R.id.main_pane, ViewType.WEEK, timeMillis, true); 1003458a1775920dda53099b7f1913cd4ec4c8b4095Michael Chan 1013458a1775920dda53099b7f1913cd4ec4c8b4095Michael Chan ft.commit(); // this needs to be after setMainPane() 1023458a1775920dda53099b7f1913cd4ec4c8b4095Michael Chan 1033458a1775920dda53099b7f1913cd4ec4c8b4095Michael Chan // Set title 1043458a1775920dda53099b7f1913cd4ec4c8b4095Michael Chan String msg = DateUtils.formatDateRange(this, timeMillis, timeMillis, 1053458a1775920dda53099b7f1913cd4ec4c8b4095Michael Chan DateUtils.FORMAT_SHOW_DATE); 1063458a1775920dda53099b7f1913cd4ec4c8b4095Michael Chan setTitle(msg); 1074970159b2e6674fc5d61425aa0fcff8e5fc15bdbMichael Chan } 1082051f1275ec5e5eeffe5bbf5773860b855316d95Erik 1092051f1275ec5e5eeffe5bbf5773860b855316d95Erik @Override 1102051f1275ec5e5eeffe5bbf5773860b855316d95Erik public boolean onCreateOptionsMenu(Menu menu) { 1112051f1275ec5e5eeffe5bbf5773860b855316d95Erik super.onCreateOptionsMenu(menu); 1122051f1275ec5e5eeffe5bbf5773860b855316d95Erik 1132051f1275ec5e5eeffe5bbf5773860b855316d95Erik getMenuInflater().inflate(R.menu.all_in_one_title_bar, menu); 1142051f1275ec5e5eeffe5bbf5773860b855316d95Erik return true; 1152051f1275ec5e5eeffe5bbf5773860b855316d95Erik } 1163458a1775920dda53099b7f1913cd4ec4c8b4095Michael Chan 1173458a1775920dda53099b7f1913cd4ec4c8b4095Michael Chan @Override 1183458a1775920dda53099b7f1913cd4ec4c8b4095Michael Chan public boolean onOptionsItemSelected(MenuItem item) { 1193458a1775920dda53099b7f1913cd4ec4c8b4095Michael Chan Time t = null; 1203458a1775920dda53099b7f1913cd4ec4c8b4095Michael Chan int viewType = ViewType.CURRENT; 1213458a1775920dda53099b7f1913cd4ec4c8b4095Michael Chan switch (item.getItemId()) { 1223458a1775920dda53099b7f1913cd4ec4c8b4095Michael Chan case R.id.action_day: 1233458a1775920dda53099b7f1913cd4ec4c8b4095Michael Chan viewType = ViewType.DAY; 1243458a1775920dda53099b7f1913cd4ec4c8b4095Michael Chan break; 1253458a1775920dda53099b7f1913cd4ec4c8b4095Michael Chan case R.id.action_week: 1263458a1775920dda53099b7f1913cd4ec4c8b4095Michael Chan viewType = ViewType.WEEK; 1273458a1775920dda53099b7f1913cd4ec4c8b4095Michael Chan break; 1283458a1775920dda53099b7f1913cd4ec4c8b4095Michael Chan case R.id.action_month: 1293458a1775920dda53099b7f1913cd4ec4c8b4095Michael Chan viewType = ViewType.MONTH; 1303458a1775920dda53099b7f1913cd4ec4c8b4095Michael Chan break; 131ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan case R.id.action_agenda: 132ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan viewType = ViewType.AGENDA; 133ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan break; 1343458a1775920dda53099b7f1913cd4ec4c8b4095Michael Chan case R.id.action_today: 1353458a1775920dda53099b7f1913cd4ec4c8b4095Michael Chan viewType = ViewType.CURRENT; 1363458a1775920dda53099b7f1913cd4ec4c8b4095Michael Chan t = new Time(); 1373458a1775920dda53099b7f1913cd4ec4c8b4095Michael Chan t.setToNow(); 1383458a1775920dda53099b7f1913cd4ec4c8b4095Michael Chan break; 1393458a1775920dda53099b7f1913cd4ec4c8b4095Michael Chan case R.id.action_create_event: 1403458a1775920dda53099b7f1913cd4ec4c8b4095Michael Chan mController.sendEventRelatedEvent(this, EventType.CREATE_EVENT, -1, 0, 0, 0, 0); 1413458a1775920dda53099b7f1913cd4ec4c8b4095Michael Chan return true; 1422c477fc6410f4da175d8a9856561aab230ff1c19Michael Chan case R.id.action_manage_calendars: 1432c477fc6410f4da175d8a9856561aab230ff1c19Michael Chan mController.sendEvent(this, EventType.LAUNCH_MANAGE_CALENDARS, null, null, 0, 0); 1442c477fc6410f4da175d8a9856561aab230ff1c19Michael Chan return true; 145ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan case R.id.action_settings: 146ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan mController.sendEvent(this, EventType.LAUNCH_SETTINGS, null, null, 0, 0); 147ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan return true; 1483458a1775920dda53099b7f1913cd4ec4c8b4095Michael Chan default: 1493458a1775920dda53099b7f1913cd4ec4c8b4095Michael Chan return false; 1503458a1775920dda53099b7f1913cd4ec4c8b4095Michael Chan } 151ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan mController.sendEvent(this, EventType.GO_TO, t, null, -1, viewType); 1523458a1775920dda53099b7f1913cd4ec4c8b4095Michael Chan return true; 1533458a1775920dda53099b7f1913cd4ec4c8b4095Michael Chan } 1548e3d430a020744faa21bf4ca24f1a99c36ec5c4fMason Tang 1558e3d430a020744faa21bf4ca24f1a99c36ec5c4fMason Tang @Override 1568e3d430a020744faa21bf4ca24f1a99c36ec5c4fMason Tang public void onSharedPreferenceChanged(SharedPreferences prefs, String key) { 1578e3d430a020744faa21bf4ca24f1a99c36ec5c4fMason Tang if (key.equals(CalendarPreferenceActivity.KEY_WEEK_START_DAY)) { 1588e3d430a020744faa21bf4ca24f1a99c36ec5c4fMason Tang initFragments(mController.getTime()); 1598e3d430a020744faa21bf4ca24f1a99c36ec5c4fMason Tang } 1608e3d430a020744faa21bf4ca24f1a99c36ec5c4fMason Tang } 161ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan 162ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan private void setMainPane(FragmentTransaction ft, int viewId, int viewType, 163ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan long timeMillis, boolean force) { 164ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan if(!force && mController.getPreviousViewType() == viewType) { 165ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan return; 166ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan } 167ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan 168ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan // Deregister old view 169ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan Fragment frag = findFragmentById(viewId); 170ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan if (frag != null) { 171ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan mController.deregisterEventHandler((EventHandler) frag); 172ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan } 173ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan 174ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan // Create new one 175ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan switch (viewType) { 176ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan case ViewType.AGENDA: 177ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan// FRAG_TODO Change this to agenda when we have AgendaFragment 178ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan frag = new MonthFragment(false, timeMillis); 179ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan break; 180ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan case ViewType.DAY: 181ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan case ViewType.WEEK: 182ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan frag = new DayFragment(timeMillis); 183ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan break; 184ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan case ViewType.MONTH: 185ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan frag = new MonthFragment(false, timeMillis); 186ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan break; 187ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan default: 188ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan throw new IllegalArgumentException("Must be Agenda, Day, Week, or Month ViewType"); 189ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan } 190ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan 191ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan boolean doCommit = false; 192ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan if (ft == null) { 193ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan doCommit = true; 194ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan ft = openFragmentTransaction(); 195ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan } 196ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan 197ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan ft.replace(viewId, frag); 198ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan mController.registerEventHandler((EventHandler) frag); 199ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan 200ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan if (doCommit) { 201ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan ft.commit(); 202ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan } 203ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan } 204ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan 205ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan private void setTitleInActionBar(EventInfo event) { 206ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan if (event.eventType != EventType.GO_TO) { 207ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan return; 208ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan } 209ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan 210ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan long start = event.startTime.toMillis(false /* use isDst */); 211ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan long end = start; 212ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan 213ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan if (event.endTime != null && !event.startTime.equals(event.endTime)) { 214ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan end = event.endTime.toMillis(false /* use isDst */); 215ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan } 216ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan String msg = DateUtils.formatDateRange(this, start, end, DateUtils.FORMAT_SHOW_DATE); 217ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan 218ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan ActionBar ab = getActionBar(); 219ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan if (ab != null) { 220ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan ab.setTitle(msg); 221ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan } 222ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan } 223ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan 224ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan // EventHandler Interface 225ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan public long getSupportedEventTypes() { 226ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan return EventType.GO_TO; 227ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan } 228ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan 229ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan // EventHandler Interface 230ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan public void handleEvent(EventInfo event) { 231ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan if (event.eventType == EventType.GO_TO) { 232ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan // Set title bar 233ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan setTitleInActionBar(event); 234ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan 235ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan setMainPane(null, R.id.main_pane, event.viewType, 236ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan event.startTime.toMillis(false), false); 237ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan 238ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan // FRAG_TODO only for XL screen 239ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan if (event.viewType == ViewType.MONTH) { 240ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan // hide minimonth and calendar frag 241ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan // show agenda view 242ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan } else { 243ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan // show minimonth and calendar frag 244ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan } 245ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan } 246ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan } 247ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan 248ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan // EventHandler Interface 249ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan public void eventsChanged() { 250ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan } 251ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan 252ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan // EventHandler Interface 253ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan public boolean getAllDay() { 254ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan return false; 255ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan } 256ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan 257ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan // EventHandler Interface 258ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan public long getSelectedTime() { 259ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan return 0; 260ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan } 261ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan 262ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan // EventHandler Interface 263ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan public void goTo(Time time, boolean animate) { 264ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan } 265ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan 266ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan // EventHandler Interface 267ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan public void goToToday() { 268ab29d9ea9a4fe6b835c7f484a2273e92e8bc323dMichael Chan } 2694970159b2e6674fc5d61425aa0fcff8e5fc15bdbMichael Chan} 270