blob: 00ee6f2b931166cbd06b7fded4bf6c348a479031 [file] [log] [blame]
Michael Chan49701592010-06-30 11:04:03 -07001/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.calendar;
18
RoboErika27a8862011-06-23 15:26:23 -070019import static android.provider.CalendarContract.EXTRA_EVENT_BEGIN_TIME;
20import static android.provider.CalendarContract.EXTRA_EVENT_END_TIME;
RoboErika7c03902011-06-14 11:06:44 -070021import static android.provider.CalendarContract.Attendees.ATTENDEE_STATUS;
Isaac Katzenelson60f01c22011-06-03 15:42:01 -070022import static com.android.calendar.CalendarController.EVENT_ATTENDEE_RESPONSE;
Erikdd95df52010-08-27 09:31:18 -070023
Michael Chan83b0fe32010-07-08 16:46:26 -070024import com.android.calendar.CalendarController.EventHandler;
Michael Chanab29d9e2010-07-21 06:08:47 -070025import com.android.calendar.CalendarController.EventInfo;
Michael Chan83b0fe32010-07-08 16:46:26 -070026import com.android.calendar.CalendarController.EventType;
Michael Chan3458a172010-07-13 17:58:21 -070027import com.android.calendar.CalendarController.ViewType;
Mason Tang00b8c1a2010-08-23 12:02:00 -070028import com.android.calendar.agenda.AgendaFragment;
Erik981874e2010-10-05 16:52:52 -070029import com.android.calendar.month.MonthByWeekFragment;
Michael Chan2aeb8d92011-07-10 13:32:09 -070030import com.android.calendar.selectcalendars.SelectSyncedCalendarsMultiAccountActivity;
31import com.android.calendar.selectcalendars.SelectVisibleCalendarsFragment;
Michael Chan83b0fe32010-07-08 16:46:26 -070032
Michael Chan5756bbc2011-03-02 18:22:07 -080033import android.animation.Animator;
34import android.animation.Animator.AnimatorListener;
RoboErikd97f7982011-03-02 15:13:05 -080035import android.animation.ObjectAnimator;
Michael Chanab29d9e2010-07-21 06:08:47 -070036import android.app.ActionBar;
Daisuke Miyakawa04ae7682010-10-19 14:15:39 -070037import android.app.ActionBar.Tab;
Michael Chan49701592010-06-30 11:04:03 -070038import android.app.Activity;
Michael Chan83b0fe32010-07-08 16:46:26 -070039import android.app.Fragment;
Erik63cd0532011-01-26 14:16:03 -080040import android.app.FragmentManager;
Michael Chan3458a172010-07-13 17:58:21 -070041import android.app.FragmentTransaction;
Erik954c8712010-08-06 10:12:34 -070042import android.content.ContentResolver;
Isaac Katzenelson60f01c22011-06-03 15:42:01 -070043import android.content.ContentUris;
Erikdd95df52010-08-27 09:31:18 -070044import android.content.Intent;
Mason Tang8e3d4302010-07-12 17:39:30 -070045import android.content.SharedPreferences;
46import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
Erikeaafa2b2010-12-23 14:30:37 -080047import android.content.res.Resources;
Erik954c8712010-08-06 10:12:34 -070048import android.database.ContentObserver;
Erikdd95df52010-08-27 09:31:18 -070049import android.net.Uri;
Michael Chan49701592010-06-30 11:04:03 -070050import android.os.Bundle;
Erik954c8712010-08-06 10:12:34 -070051import android.os.Handler;
RoboErika7c03902011-06-14 11:06:44 -070052import android.provider.CalendarContract;
53import android.provider.CalendarContract.Events;
Erik6c255102010-09-29 14:43:00 -070054import android.text.TextUtils;
55import android.text.format.DateFormat;
Michael Chan3458a172010-07-13 17:58:21 -070056import android.text.format.DateUtils;
Michael Chan83b0fe32010-07-08 16:46:26 -070057import android.text.format.Time;
Erik954c8712010-08-06 10:12:34 -070058import android.util.Log;
Erik2051f122010-07-02 13:45:45 -070059import android.view.Menu;
Michael Chan3458a172010-07-13 17:58:21 -070060import android.view.MenuItem;
Michael Chanab29d9e2010-07-21 06:08:47 -070061import android.view.View;
Erik259b8f92011-01-12 14:01:12 -080062import android.view.accessibility.AccessibilityEvent;
RoboErikde20d762011-02-08 17:52:25 -080063import android.widget.RelativeLayout;
64import android.widget.RelativeLayout.LayoutParams;
Daisuke Miyakawa6d2e6f72010-09-17 10:30:54 -070065import android.widget.SearchView;
RoboErike635aec2011-07-15 11:22:13 -070066import android.widget.SearchView.OnCloseListener;
Isaac Katzenelson2c5dd7c2011-06-16 17:56:06 -070067import android.widget.SpinnerAdapter;
Erik6c255102010-09-29 14:43:00 -070068import android.widget.TextView;
69
Michael Chan2c7c8512010-12-10 14:12:57 -080070import java.util.List;
Erik6c255102010-09-29 14:43:00 -070071import java.util.Locale;
72import java.util.TimeZone;
Michael Chan49701592010-06-30 11:04:03 -070073
Michael Chanab29d9e2010-07-21 06:08:47 -070074public class AllInOneActivity extends Activity implements EventHandler,
RoboErike635aec2011-07-15 11:22:13 -070075 OnSharedPreferenceChangeListener, SearchView.OnQueryTextListener, ActionBar.TabListener,
76 ActionBar.OnNavigationListener, OnCloseListener {
Michael Chand6734db2010-07-22 00:48:08 -070077 private static final String TAG = "AllInOneActivity";
Erik954c8712010-08-06 10:12:34 -070078 private static final boolean DEBUG = false;
Erik63cd0532011-01-26 14:16:03 -080079 private static final String EVENT_INFO_FRAGMENT_TAG = "EventInfoFragment";
Michael Chand6734db2010-07-22 00:48:08 -070080 private static final String BUNDLE_KEY_RESTORE_TIME = "key_restore_time";
Erik7b92da22010-09-23 14:55:22 -070081 private static final String BUNDLE_KEY_EVENT_ID = "key_event_id";
RoboErik277eb972011-02-24 16:05:04 -080082 private static final String BUNDLE_KEY_RESTORE_VIEW = "key_restore_view";
Erik3f348f32010-08-10 13:17:19 -070083 private static final int HANDLER_KEY = 0;
RoboErikde20d762011-02-08 17:52:25 -080084 private static final long CONTROLS_ANIMATE_DURATION = 400;
RoboErike9cd8f42011-07-01 16:36:11 -070085 private static int CONTROLS_ANIMATE_WIDTH = 280;
RoboErikde20d762011-02-08 17:52:25 -080086 private static float mScale = 0;
Erikeaafa2b2010-12-23 14:30:37 -080087
Isaac Katzenelson2c5dd7c2011-06-16 17:56:06 -070088 // Indices of buttons for the drop down menu (tabs replacement)
89 // Must match the strings in the array buttons_list in arrays.xml and the
90 // OnNavigationListener
91 private static final int BUTTON_DAY_INDEX = 0;
92 private static final int BUTTON_WEEK_INDEX = 1;
93 private static final int BUTTON_MONTH_INDEX = 2;
94 private static final int BUTTON_AGENDA_INDEX = 3;
95
Michael Chan0558def2010-07-22 21:30:32 -070096 private static CalendarController mController;
Erik9fc409f2010-07-28 11:40:47 -070097 private static boolean mIsMultipane;
Isaac Katzenelson62967cb2011-06-14 13:27:20 -070098 private static boolean mIsTabletConfig;
Isaac Katzenelson6a182582011-04-21 15:46:33 -070099 private static boolean mShowAgendaWithMonth;
Isaac Katzenelsonccf565b2011-04-27 14:40:08 -0700100 private static boolean mShowEventDetailsWithAgenda;
Michael Chan6191c122010-11-02 16:23:47 -0700101 private boolean mOnSaveInstanceStateCalled = false;
Erik954c8712010-08-06 10:12:34 -0700102 private ContentResolver mContentResolver;
Erik648c59c2010-08-13 12:49:26 -0700103 private int mPreviousView;
104 private int mCurrentView;
Erikcb811892010-09-28 13:44:19 -0700105 private boolean mPaused = true;
106 private boolean mUpdateOnResume = false;
RoboErikde20d762011-02-08 17:52:25 -0800107 private boolean mHideControls = false;
Michael Chan5756bbc2011-03-02 18:22:07 -0800108 private boolean mShowSideViews = true;
Erik6c255102010-09-29 14:43:00 -0700109 private TextView mHomeTime;
Erikeaafa2b2010-12-23 14:30:37 -0800110 private TextView mDateRange;
RoboErikde20d762011-02-08 17:52:25 -0800111 private View mMiniMonth;
112 private View mCalendarsList;
113 private View mMiniMonthContainer;
Isaac Katzenelson96a0b542011-04-13 13:43:20 -0700114 private View mSecondaryPane;
Erikc5f92d72010-11-11 16:18:34 -0800115 private String mTimeZone;
Isaac Katzenelson5ab87e32011-04-21 17:19:25 -0700116 private boolean mShowCalendarControls;
Isaac Katzenelson60f01c22011-06-03 15:42:01 -0700117 private boolean mShowEventInfoFullScreen;
Erik6c255102010-09-29 14:43:00 -0700118
Michael Chan2c7c8512010-12-10 14:12:57 -0800119 private long mViewEventId = -1;
120 private long mIntentEventStartMillis = -1;
121 private long mIntentEventEndMillis = -1;
Michael Chandeced892010-12-10 15:59:35 -0800122 private int mIntentAttendeeResponse = CalendarController.ATTENDEE_NO_RESPONSE;
Michael Chan2c7c8512010-12-10 14:12:57 -0800123
Daisuke Miyakawa04ae7682010-10-19 14:15:39 -0700124 // Action bar and Navigation bar (left side of Action bar)
125 private ActionBar mActionBar;
126 private ActionBar.Tab mDayTab;
127 private ActionBar.Tab mWeekTab;
128 private ActionBar.Tab mMonthTab;
Isaac Katzenelsonae7c1c62011-04-11 18:30:26 -0700129 private ActionBar.Tab mAgendaTab;
Erikcb830312011-01-19 14:41:41 -0800130 private SearchView mSearchView;
RoboErike635aec2011-07-15 11:22:13 -0700131 private MenuItem mSearchMenu;
RoboErikde20d762011-02-08 17:52:25 -0800132 private MenuItem mControlsMenu;
Isaac Katzenelsonccf565b2011-04-27 14:40:08 -0700133 private Menu mOptionsMenu;
Isaac Katzenelson9a39bdd2011-06-23 16:52:08 -0700134 private CalendarViewAdapter mActionBarMenuSpinnerAdapter;
RoboErikde20d762011-02-08 17:52:25 -0800135
Isaac Katzenelson5b2a9072011-04-08 15:23:57 -0700136 private String mHideString;
137 private String mShowString;
RoboErikde20d762011-02-08 17:52:25 -0800138
RoboErikb8549562011-02-15 14:25:23 -0800139 // Params for animating the controls on the right
Michael Chan5756bbc2011-03-02 18:22:07 -0800140 private LayoutParams mControlsParams = new LayoutParams(CONTROLS_ANIMATE_WIDTH, 0);
141
142 private AnimatorListener mSlideAnimationDoneListener = new AnimatorListener() {
143
144 @Override
145 public void onAnimationCancel(Animator animation) {
146 }
147
148 @Override
149 public void onAnimationEnd(android.animation.Animator animation) {
150 int visibility = mShowSideViews ? View.VISIBLE : View.GONE;
151 mMiniMonth.setVisibility(visibility);
152 mCalendarsList.setVisibility(visibility);
153 mMiniMonthContainer.setVisibility(visibility);
154 }
155
156 @Override
157 public void onAnimationRepeat(android.animation.Animator animation) {
158 }
159
160 @Override
161 public void onAnimationStart(android.animation.Animator animation) {
162 }
163 };
Daisuke Miyakawa04ae7682010-10-19 14:15:39 -0700164
Erik6c255102010-09-29 14:43:00 -0700165 private Runnable mHomeTimeUpdater = new Runnable() {
166 @Override
167 public void run() {
168 updateHomeClock();
169 }
170 };
Erik954c8712010-08-06 10:12:34 -0700171
172 // Create an observer so that we can update the views whenever a
173 // Calendar event changes.
Erik7b92da22010-09-23 14:55:22 -0700174 private ContentObserver mObserver = new ContentObserver(new Handler()) {
Erik954c8712010-08-06 10:12:34 -0700175 @Override
176 public boolean deliverSelfNotifications() {
177 return true;
178 }
179
180 @Override
181 public void onChange(boolean selfChange) {
182 eventsChanged();
183 }
184 };
Michael Chan83b0fe32010-07-08 16:46:26 -0700185
Michael Chan49701592010-06-30 11:04:03 -0700186 @Override
Erik63cd0532011-01-26 14:16:03 -0800187 protected void onNewIntent(Intent intent) {
188 String action = intent.getAction();
189 if (Intent.ACTION_VIEW.equals(action)) {
190 parseViewAction(intent);
191 }
192 }
193
194 @Override
Michael Chan83b0fe32010-07-08 16:46:26 -0700195 protected void onCreate(Bundle icicle) {
Erikca478672011-01-19 20:02:47 -0800196 if (Utils.getSharedPreference(this, OtherPreferences.KEY_OTHER_1, false)) {
197 setTheme(R.style.CalendarTheme_WithActionBarWallpaper);
198 }
Michael Chan83b0fe32010-07-08 16:46:26 -0700199 super.onCreate(icicle);
200
201 // This needs to be created before setContentView
Michael Chan0558def2010-07-22 21:30:32 -0700202 mController = CalendarController.getInstance(this);
Erik954c8712010-08-06 10:12:34 -0700203 // Get time from intent or icicle
Michael Chan2c7c8512010-12-10 14:12:57 -0800204 long timeMillis = -1;
205 int viewType = -1;
Michael Chan2c7c8512010-12-10 14:12:57 -0800206 final Intent intent = getIntent();
Erik954c8712010-08-06 10:12:34 -0700207 if (icicle != null) {
208 timeMillis = icicle.getLong(BUNDLE_KEY_RESTORE_TIME);
RoboErik277eb972011-02-24 16:05:04 -0800209 viewType = icicle.getInt(BUNDLE_KEY_RESTORE_VIEW, -1);
Erik7b92da22010-09-23 14:55:22 -0700210 } else {
Michael Chan2c7c8512010-12-10 14:12:57 -0800211 String action = intent.getAction();
212 if (Intent.ACTION_VIEW.equals(action)) {
213 // Open EventInfo later
214 timeMillis = parseViewAction(intent);
215 }
216
217 if (timeMillis == -1) {
218 timeMillis = Utils.timeFromIntentInMillis(intent);
219 }
220 }
221
RoboErik277eb972011-02-24 16:05:04 -0800222 if (viewType == -1) {
Erik7b92da22010-09-23 14:55:22 -0700223 viewType = Utils.getViewTypeFromIntentAndSharedPref(this);
224 }
Erikc5f92d72010-11-11 16:18:34 -0800225 mTimeZone = Utils.getTimeZone(this, mHomeTimeUpdater);
226 Time t = new Time(mTimeZone);
Erik954c8712010-08-06 10:12:34 -0700227 t.set(timeMillis);
228
Michael Chan2c7c8512010-12-10 14:12:57 -0800229 if (icicle != null && intent != null) {
230 Log.d(TAG, "both, icicle:" + icicle.toString() + " intent:" + intent.toString());
Erik7b92da22010-09-23 14:55:22 -0700231 } else {
Michael Chan2c7c8512010-12-10 14:12:57 -0800232 Log.d(TAG, "not both, icicle:" + icicle + " intent:" + intent);
Erik7b92da22010-09-23 14:55:22 -0700233 }
234
Erikeaafa2b2010-12-23 14:30:37 -0800235 Resources res = getResources();
RoboErikde20d762011-02-08 17:52:25 -0800236 if (mScale == 0) {
237 mScale = res.getDisplayMetrics().density;
238 CONTROLS_ANIMATE_WIDTH *= mScale;
RoboErikde20d762011-02-08 17:52:25 -0800239 }
240 mHideString = res.getString(R.string.hide_controls);
241 mShowString = res.getString(R.string.show_controls);
RoboErikb8549562011-02-15 14:25:23 -0800242 mControlsParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
RoboErikb8549562011-02-15 14:25:23 -0800243
Isaac Katzenelson96a0b542011-04-13 13:43:20 -0700244 mIsMultipane = Utils.isMultiPaneConfiguration(this);
Isaac Katzenelson62967cb2011-06-14 13:27:20 -0700245 mIsTabletConfig = Utils.getConfigBool(this, R.bool.tablet_config);
Isaac Katzenelson6a182582011-04-21 15:46:33 -0700246 mShowAgendaWithMonth = Utils.getConfigBool(this, R.bool.show_agenda_with_month);
Isaac Katzenelson5ab87e32011-04-21 17:19:25 -0700247 mShowCalendarControls = Utils.getConfigBool(this, R.bool.show_calendar_controls);
Isaac Katzenelsonccf565b2011-04-27 14:40:08 -0700248 mShowEventDetailsWithAgenda =
249 Utils.getConfigBool(this, R.bool.show_event_details_with_agenda);
Isaac Katzenelson60f01c22011-06-03 15:42:01 -0700250 mShowEventInfoFullScreen =
251 Utils.getConfigBool(this, R.bool.show_event_info_full_screen);
Erik9fc409f2010-07-28 11:40:47 -0700252
Erik63cd0532011-01-26 14:16:03 -0800253 Utils.setAllowWeekForDetailView(mIsMultipane);
Michael Chanb60218a2010-12-14 16:34:39 -0800254
Erikbe8191c2010-10-26 16:50:08 -0700255 // setContentView must be called before configureActionBar
256 setContentView(R.layout.all_in_one);
Isaac Katzenelson62967cb2011-06-14 13:27:20 -0700257
258 if (mIsTabletConfig) {
259 mDateRange = (TextView) findViewById(R.id.date_bar);
260 } else {
261 mDateRange = (TextView) getLayoutInflater().inflate(R.layout.date_range_title, null);
262 }
263
Erikbe8191c2010-10-26 16:50:08 -0700264 // configureActionBar auto-selects the first tab you add, so we need to
265 // call it before we set up our own fragments to make sure it doesn't
266 // overwrite us
Isaac Katzenelsona457a1b2011-06-21 15:13:57 -0700267 configureActionBar(viewType);
Erikbe8191c2010-10-26 16:50:08 -0700268
Erik3f348f32010-08-10 13:17:19 -0700269 // Must be the first to register because this activity can modify the
270 // list of event handlers in it's handle method. This affects who the
271 // rest of the handlers the controller dispatches to are.
272 mController.registerEventHandler(HANDLER_KEY, this);
Michael Chan83b0fe32010-07-08 16:46:26 -0700273
Erik6c255102010-09-29 14:43:00 -0700274 mHomeTime = (TextView) findViewById(R.id.home_time);
RoboErikde20d762011-02-08 17:52:25 -0800275 mMiniMonth = findViewById(R.id.mini_month);
276 mCalendarsList = findViewById(R.id.calendar_list);
277 mMiniMonthContainer = findViewById(R.id.mini_month_container);
Isaac Katzenelson96a0b542011-04-13 13:43:20 -0700278 mSecondaryPane = findViewById(R.id.secondary_pane);
Michael Chan83b0fe32010-07-08 16:46:26 -0700279
Erik7b92da22010-09-23 14:55:22 -0700280 initFragments(timeMillis, viewType, icicle);
Mason Tang8e3d4302010-07-12 17:39:30 -0700281
282 // Listen for changes that would require this to be refreshed
Daisuke Miyakawa4b441bd2010-09-16 14:55:36 -0700283 SharedPreferences prefs = GeneralPreferences.getSharedPreferences(this);
Mason Tang8e3d4302010-07-12 17:39:30 -0700284 prefs.registerOnSharedPreferenceChangeListener(this);
Erikcb811892010-09-28 13:44:19 -0700285
Erik954c8712010-08-06 10:12:34 -0700286 mContentResolver = getContentResolver();
Erikbe8191c2010-10-26 16:50:08 -0700287 }
Daisuke Miyakawa04ae7682010-10-19 14:15:39 -0700288
Michael Chan2c7c8512010-12-10 14:12:57 -0800289 private long parseViewAction(final Intent intent) {
290 long timeMillis = -1;
291 Uri data = intent.getData();
292 if (data != null && data.isHierarchical()) {
293 List<String> path = data.getPathSegments();
294 if (path.size() == 2 && path.get(0).equals("events")) {
295 try {
296 mViewEventId = Long.valueOf(data.getLastPathSegment());
Isaac Katzenelson96a0b542011-04-13 13:43:20 -0700297 if (mViewEventId != -1) {
RoboErika27a8862011-06-23 15:26:23 -0700298 mIntentEventStartMillis = intent.getLongExtra(EXTRA_EVENT_BEGIN_TIME, 0);
299 mIntentEventEndMillis = intent.getLongExtra(EXTRA_EVENT_END_TIME, 0);
Michael Chan2c7c8512010-12-10 14:12:57 -0800300 mIntentAttendeeResponse = intent.getIntExtra(
Michael Chandeced892010-12-10 15:59:35 -0800301 ATTENDEE_STATUS, CalendarController.ATTENDEE_NO_RESPONSE);
Michael Chan2c7c8512010-12-10 14:12:57 -0800302 timeMillis = mIntentEventStartMillis;
303 }
304 } catch (NumberFormatException e) {
305 // Ignore if mViewEventId can't be parsed
306 }
307 }
308 }
309 return timeMillis;
310 }
311
Isaac Katzenelsona457a1b2011-06-21 15:13:57 -0700312 private void configureActionBar(int viewType) {
Isaac Katzenelson2c5dd7c2011-06-16 17:56:06 -0700313 if (mIsTabletConfig) {
314 createTabs();
315 } else {
Isaac Katzenelsona457a1b2011-06-21 15:13:57 -0700316 createButtonsSpinner(viewType);
Isaac Katzenelson2c5dd7c2011-06-16 17:56:06 -0700317 mActionBar.setCustomView(mDateRange);
318 }
Isaac Katzenelson53aad912011-07-01 12:15:09 -0700319 if (mIsMultipane) {
320 mActionBar.setDisplayOptions(
321 ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME);
322 } else {
323 mActionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
324 }
Isaac Katzenelson2c5dd7c2011-06-16 17:56:06 -0700325 }
326
327 private void createTabs() {
Daisuke Miyakawa04ae7682010-10-19 14:15:39 -0700328 mActionBar = getActionBar();
Daisuke Miyakawa04ae7682010-10-19 14:15:39 -0700329 if (mActionBar == null) {
330 Log.w(TAG, "ActionBar is null.");
331 } else {
Isaac Katzenelson2c5dd7c2011-06-16 17:56:06 -0700332 mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
Daisuke Miyakawa04ae7682010-10-19 14:15:39 -0700333 mDayTab = mActionBar.newTab();
334 mDayTab.setText(getString(R.string.day_view));
335 mDayTab.setTabListener(this);
336 mActionBar.addTab(mDayTab);
337 mWeekTab = mActionBar.newTab();
338 mWeekTab.setText(getString(R.string.week_view));
339 mWeekTab.setTabListener(this);
340 mActionBar.addTab(mWeekTab);
341 mMonthTab = mActionBar.newTab();
342 mMonthTab.setText(getString(R.string.month_view));
343 mMonthTab.setTabListener(this);
344 mActionBar.addTab(mMonthTab);
Isaac Katzenelsonae7c1c62011-04-11 18:30:26 -0700345 mAgendaTab = mActionBar.newTab();
346 mAgendaTab.setText(getString(R.string.agenda_view));
347 mAgendaTab.setTabListener(this);
348 mActionBar.addTab(mAgendaTab);
Daisuke Miyakawa04ae7682010-10-19 14:15:39 -0700349 }
Erik954c8712010-08-06 10:12:34 -0700350 }
351
Isaac Katzenelsona457a1b2011-06-21 15:13:57 -0700352 private void createButtonsSpinner(int viewType) {
Isaac Katzenelson9a39bdd2011-06-23 16:52:08 -0700353 mActionBarMenuSpinnerAdapter = new CalendarViewAdapter (this, viewType);
Isaac Katzenelson2c5dd7c2011-06-16 17:56:06 -0700354 mActionBar = getActionBar();
355 mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
356 mActionBar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_HOME|ActionBar.DISPLAY_USE_LOGO|
357 ActionBar.DISPLAY_SHOW_TITLE);
Isaac Katzenelson9a39bdd2011-06-23 16:52:08 -0700358 mActionBar.setListNavigationCallbacks(mActionBarMenuSpinnerAdapter, this);
Isaac Katzenelsona457a1b2011-06-21 15:13:57 -0700359 switch (viewType) {
360 case ViewType.AGENDA:
361 mActionBar.setSelectedNavigationItem(BUTTON_AGENDA_INDEX);
362 break;
363 case ViewType.DAY:
364 mActionBar.setSelectedNavigationItem(BUTTON_DAY_INDEX);
365 break;
366 case ViewType.WEEK:
367 mActionBar.setSelectedNavigationItem(BUTTON_WEEK_INDEX);
368 break;
369 case ViewType.MONTH:
370 mActionBar.setSelectedNavigationItem(BUTTON_MONTH_INDEX);
371 break;
372 default:
373 mActionBar.setSelectedNavigationItem(BUTTON_DAY_INDEX);
374 break;
375 }
Isaac Katzenelson2c5dd7c2011-06-16 17:56:06 -0700376 }
Isaac Katzenelsonccf565b2011-04-27 14:40:08 -0700377 // Clear buttons used in the agenda view
378 private void clearOptionsMenu() {
379 if (mOptionsMenu == null) {
380 return;
381 }
382 MenuItem cancelItem = mOptionsMenu.findItem(R.id.action_cancel);
383 MenuItem deleteItem = mOptionsMenu.findItem(R.id.action_delete);
384 MenuItem editItem = mOptionsMenu.findItem(R.id.action_edit);
385 if (cancelItem != null) {
386 cancelItem.setVisible(false);
387 }
388 if (deleteItem != null) {
389 deleteItem.setVisible(false);
390 }
391 if (editItem != null) {
392 editItem.setVisible(false);
393 }
394 }
395
Erik954c8712010-08-06 10:12:34 -0700396 @Override
397 protected void onResume() {
398 super.onResume();
Isaac Katzenelson9a39bdd2011-06-23 16:52:08 -0700399 mContentResolver.registerContentObserver(CalendarContract.Events.CONTENT_URI,
400 true, mObserver);
Erikcb811892010-09-28 13:44:19 -0700401 if (mUpdateOnResume) {
402 initFragments(mController.getTime(), mController.getViewType(), null);
403 mUpdateOnResume = false;
404 }
Erik6c255102010-09-29 14:43:00 -0700405 updateHomeClock();
Isaac Katzenelson9a39bdd2011-06-23 16:52:08 -0700406 // Make sure the drop-down menu will get its date updated at midnight
407 if (mActionBarMenuSpinnerAdapter != null) {
408 mActionBarMenuSpinnerAdapter.setMidnightHandler();
409 }
410
RoboErik3b3af612011-02-24 13:42:57 -0800411 if (mControlsMenu != null) {
412 mControlsMenu.setTitle(mHideControls ? mShowString : mHideString);
413 }
Erikcb811892010-09-28 13:44:19 -0700414 mPaused = false;
Michael Chan6191c122010-11-02 16:23:47 -0700415 mOnSaveInstanceStateCalled = false;
Michael Chan2c7c8512010-12-10 14:12:57 -0800416
417 if (mViewEventId != -1 && mIntentEventStartMillis != -1 && mIntentEventEndMillis != -1) {
RoboErikf6b58a92011-02-24 14:22:11 -0800418 long currentMillis = System.currentTimeMillis();
419 long selectedTime = -1;
420 if (currentMillis > mIntentEventStartMillis && currentMillis < mIntentEventEndMillis) {
421 selectedTime = currentMillis;
422 }
Michael Chanf0868f62011-01-11 19:37:35 -0800423 mController.sendEventRelatedEventWithResponse(this, EventType.VIEW_EVENT, mViewEventId,
Isaac Katzenelson96a0b542011-04-13 13:43:20 -0700424 mIntentEventStartMillis, mIntentEventEndMillis, -1, -1,
425 mIntentAttendeeResponse, selectedTime);
Michael Chan2c7c8512010-12-10 14:12:57 -0800426 mViewEventId = -1;
427 mIntentEventStartMillis = -1;
428 mIntentEventEndMillis = -1;
429 }
Mason Tang8e3d4302010-07-12 17:39:30 -0700430 }
431
432 @Override
Michael Chand6734db2010-07-22 00:48:08 -0700433 protected void onPause() {
434 super.onPause();
Erikcb811892010-09-28 13:44:19 -0700435 mPaused = true;
Daisuke Miyakawac9e53072010-10-14 12:18:49 -0700436 mHomeTime.removeCallbacks(mHomeTimeUpdater);
Isaac Katzenelson9a39bdd2011-06-23 16:52:08 -0700437 if (mActionBarMenuSpinnerAdapter != null) {
438 mActionBarMenuSpinnerAdapter.resetMidnightHandler();
439 }
Erik954c8712010-08-06 10:12:34 -0700440 mContentResolver.unregisterContentObserver(mObserver);
Erikcb811892010-09-28 13:44:19 -0700441 if (isFinishing()) {
442 // Stop listening for changes that would require this to be refreshed
443 SharedPreferences prefs = GeneralPreferences.getSharedPreferences(this);
444 prefs.unregisterOnSharedPreferenceChangeListener(this);
445 }
Erik7b92da22010-09-23 14:55:22 -0700446 // FRAG_TODO save highlighted days of the week;
Erikdd95df52010-08-27 09:31:18 -0700447 if (mController.getViewType() != ViewType.EDIT) {
448 Utils.setDefaultView(this, mController.getViewType());
449 }
Michael Chand6734db2010-07-22 00:48:08 -0700450 }
451
452 @Override
Erik7b92da22010-09-23 14:55:22 -0700453 protected void onUserLeaveHint() {
454 mController.sendEvent(this, EventType.USER_HOME, null, null, -1, ViewType.CURRENT);
455 super.onUserLeaveHint();
456 }
457
458 @Override
Michael Chand6734db2010-07-22 00:48:08 -0700459 public void onSaveInstanceState(Bundle outState) {
Michael Chan6191c122010-11-02 16:23:47 -0700460 mOnSaveInstanceStateCalled = true;
Michael Chand6734db2010-07-22 00:48:08 -0700461 super.onSaveInstanceState(outState);
462
463 outState.putLong(BUNDLE_KEY_RESTORE_TIME, mController.getTime());
Erik7b92da22010-09-23 14:55:22 -0700464 if (mCurrentView == ViewType.EDIT) {
RoboErik277eb972011-02-24 16:05:04 -0800465 outState.putInt(BUNDLE_KEY_RESTORE_VIEW, mCurrentView);
Erik7b92da22010-09-23 14:55:22 -0700466 outState.putLong(BUNDLE_KEY_EVENT_ID, mController.getEventId());
467 }
Michael Chand6734db2010-07-22 00:48:08 -0700468 }
469
470 @Override
Mason Tang8e3d4302010-07-12 17:39:30 -0700471 protected void onDestroy() {
472 super.onDestroy();
473
Daisuke Miyakawa4b441bd2010-09-16 14:55:36 -0700474 SharedPreferences prefs = GeneralPreferences.getSharedPreferences(this);
Mason Tang8e3d4302010-07-12 17:39:30 -0700475 prefs.unregisterOnSharedPreferenceChangeListener(this);
Eriked61b482010-08-13 13:59:50 -0700476 CalendarController.removeInstance(this);
Mason Tang8e3d4302010-07-12 17:39:30 -0700477 }
478
Erik7b92da22010-09-23 14:55:22 -0700479 private void initFragments(long timeMillis, int viewType, Bundle icicle) {
Dianne Hackborn12b33302011-01-17 12:30:13 -0800480 FragmentTransaction ft = getFragmentManager().beginTransaction();
Michael Chan3458a172010-07-13 17:58:21 -0700481
Isaac Katzenelson5ab87e32011-04-21 17:19:25 -0700482 if (mShowCalendarControls) {
Erik40bcd102010-11-16 15:46:40 -0800483 Fragment miniMonthFrag = new MonthByWeekFragment(timeMillis, true);
Michael Chanab29d9e2010-07-21 06:08:47 -0700484 ft.replace(R.id.mini_month, miniMonthFrag);
Erik3f348f32010-08-10 13:17:19 -0700485 mController.registerEventHandler(R.id.mini_month, (EventHandler) miniMonthFrag);
Michael Chanab29d9e2010-07-21 06:08:47 -0700486
Michael Chan2aeb8d92011-07-10 13:32:09 -0700487 Fragment selectCalendarsFrag = new SelectVisibleCalendarsFragment();
Michael Chanab29d9e2010-07-21 06:08:47 -0700488 ft.replace(R.id.calendar_list, selectCalendarsFrag);
RoboErik8d1b2fd2011-02-25 10:24:43 -0800489 mController.registerEventHandler(
490 R.id.calendar_list, (EventHandler) selectCalendarsFrag);
Erikdd95df52010-08-27 09:31:18 -0700491 }
Isaac Katzenelson5ab87e32011-04-21 17:19:25 -0700492 if (!mShowCalendarControls || viewType == ViewType.EDIT) {
RoboErikde20d762011-02-08 17:52:25 -0800493 mMiniMonth.setVisibility(View.GONE);
494 mCalendarsList.setVisibility(View.GONE);
Michael Chanab29d9e2010-07-21 06:08:47 -0700495 }
Michael Chan3458a172010-07-13 17:58:21 -0700496
Erikdd95df52010-08-27 09:31:18 -0700497 EventInfo info = null;
498 if (viewType == ViewType.EDIT) {
Daisuke Miyakawa4b441bd2010-09-16 14:55:36 -0700499 mPreviousView = GeneralPreferences.getSharedPreferences(this).getInt(
Erik7b92da22010-09-23 14:55:22 -0700500 GeneralPreferences.KEY_START_VIEW, GeneralPreferences.DEFAULT_START_VIEW);
Erikdd95df52010-08-27 09:31:18 -0700501
Daisuke Miyakawa4143cfa2010-09-17 19:55:04 -0700502 long eventId = -1;
Erikdd95df52010-08-27 09:31:18 -0700503 Intent intent = getIntent();
504 Uri data = intent.getData();
505 if (data != null) {
506 try {
Daisuke Miyakawa4143cfa2010-09-17 19:55:04 -0700507 eventId = Long.parseLong(data.getLastPathSegment());
Erikdd95df52010-08-27 09:31:18 -0700508 } catch (NumberFormatException e) {
509 if (DEBUG) {
510 Log.d(TAG, "Create new event");
511 }
512 }
Erik7b92da22010-09-23 14:55:22 -0700513 } else if (icicle != null && icicle.containsKey(BUNDLE_KEY_EVENT_ID)) {
514 eventId = icicle.getLong(BUNDLE_KEY_EVENT_ID);
Erikdd95df52010-08-27 09:31:18 -0700515 }
Daisuke Miyakawa4143cfa2010-09-17 19:55:04 -0700516
RoboErika27a8862011-06-23 15:26:23 -0700517 long begin = intent.getLongExtra(EXTRA_EVENT_BEGIN_TIME, -1);
518 long end = intent.getLongExtra(EXTRA_EVENT_END_TIME, -1);
Erikdd95df52010-08-27 09:31:18 -0700519 info = new EventInfo();
520 if (end != -1) {
521 info.endTime = new Time();
522 info.endTime.set(end);
523 }
524 if (begin != -1) {
525 info.startTime = new Time();
526 info.startTime.set(begin);
527 }
528 info.id = eventId;
529 // We set the viewtype so if the user presses back when they are
530 // done editing the controller knows we were in the Edit Event
Erik7b92da22010-09-23 14:55:22 -0700531 // screen. Likewise for eventId
Erikdd95df52010-08-27 09:31:18 -0700532 mController.setViewType(viewType);
Erik7b92da22010-09-23 14:55:22 -0700533 mController.setEventId(eventId);
Erikdd95df52010-08-27 09:31:18 -0700534 } else {
535 mPreviousView = viewType;
536 }
Isaac Katzenelson96a0b542011-04-13 13:43:20 -0700537
Erik63cd0532011-01-26 14:16:03 -0800538 setMainPane(ft, R.id.main_pane, viewType, timeMillis, true);
Michael Chan3458a172010-07-13 17:58:21 -0700539 ft.commit(); // this needs to be after setMainPane()
540
Erikc5f92d72010-11-11 16:18:34 -0800541 Time t = new Time(mTimeZone);
Michael Chand6734db2010-07-22 00:48:08 -0700542 t.set(timeMillis);
Erikdd95df52010-08-27 09:31:18 -0700543 if (viewType != ViewType.EDIT) {
544 mController.sendEvent(this, EventType.GO_TO, t, null, -1, viewType);
545 }
Michael Chan49701592010-06-30 11:04:03 -0700546 }
Erik2051f122010-07-02 13:45:45 -0700547
548 @Override
Erik648c59c2010-08-13 12:49:26 -0700549 public void onBackPressed() {
Daisuke Miyakawa93e69eb2010-10-22 18:54:38 -0700550 if (mCurrentView == ViewType.EDIT || mCurrentView == ViewType.DETAIL) {
Erikdd95df52010-08-27 09:31:18 -0700551 mController.sendEvent(this, EventType.GO_TO, null, null, -1, mPreviousView);
Daisuke Miyakawa93e69eb2010-10-22 18:54:38 -0700552 } else {
553 super.onBackPressed();
Erik648c59c2010-08-13 12:49:26 -0700554 }
555 }
556
557 @Override
Erik2051f122010-07-02 13:45:45 -0700558 public boolean onCreateOptionsMenu(Menu menu) {
559 super.onCreateOptionsMenu(menu);
Isaac Katzenelsonccf565b2011-04-27 14:40:08 -0700560 mOptionsMenu = menu;
Erik2051f122010-07-02 13:45:45 -0700561 getMenuInflater().inflate(R.menu.all_in_one_title_bar, menu);
Daisuke Miyakawa6d2e6f72010-09-17 10:30:54 -0700562
RoboErike635aec2011-07-15 11:22:13 -0700563 mSearchMenu = menu.findItem(R.id.action_search);
564 mSearchView = (SearchView) mSearchMenu.getActionView();
Erikcb830312011-01-19 14:41:41 -0800565 if (mSearchView != null) {
566 mSearchView.setIconifiedByDefault(true);
Adam Powell28f9b352011-01-20 18:36:10 -0800567 mSearchView.setOnQueryTextListener(this);
Erikcb830312011-01-19 14:41:41 -0800568 mSearchView.setSubmitButtonEnabled(true);
RoboErike635aec2011-07-15 11:22:13 -0700569 mSearchView.setOnCloseListener(this);
Michael Chan71b221a2010-10-25 17:55:44 -0700570 }
Isaac Katzenelson5b2a9072011-04-08 15:23:57 -0700571
572 // Hide the "show/hide controls" button if this is a phone
Isaac Katzenelson9c163922011-07-07 11:19:19 -0700573 // or the view type is "Month" or "Agenda".
Isaac Katzenelson5b2a9072011-04-08 15:23:57 -0700574
RoboErikde20d762011-02-08 17:52:25 -0800575 mControlsMenu = menu.findItem(R.id.action_hide_controls);
Isaac Katzenelson5ab87e32011-04-21 17:19:25 -0700576 if (!mShowCalendarControls) {
Isaac Katzenelson5b2a9072011-04-08 15:23:57 -0700577 if (mControlsMenu != null) {
578 mControlsMenu.setVisible(false);
579 mControlsMenu.setEnabled(false);
580 }
581 } else if (mControlsMenu != null && mController != null
Isaac Katzenelson9c163922011-07-07 11:19:19 -0700582 && (mController.getViewType() == ViewType.MONTH ||
583 mController.getViewType() == ViewType.AGENDA)) {
RoboErikde20d762011-02-08 17:52:25 -0800584 mControlsMenu.setVisible(false);
585 mControlsMenu.setEnabled(false);
Isaac Katzenelson9c163922011-07-07 11:19:19 -0700586 } else if (mControlsMenu != null){
587 mControlsMenu.setTitle(mHideControls ? mShowString : mHideString);
RoboErikde20d762011-02-08 17:52:25 -0800588 }
Erik2051f122010-07-02 13:45:45 -0700589 return true;
590 }
Michael Chan3458a172010-07-13 17:58:21 -0700591
592 @Override
593 public boolean onOptionsItemSelected(MenuItem item) {
594 Time t = null;
595 int viewType = ViewType.CURRENT;
596 switch (item.getItemId()) {
Erikba1b94a2010-07-20 17:50:50 -0700597 case R.id.action_refresh:
598 mController.refreshCalendars();
599 return true;
Michael Chan3458a172010-07-13 17:58:21 -0700600 case R.id.action_today:
601 viewType = ViewType.CURRENT;
Erikc5f92d72010-11-11 16:18:34 -0800602 t = new Time(mTimeZone);
Michael Chan3458a172010-07-13 17:58:21 -0700603 t.setToNow();
604 break;
605 case R.id.action_create_event:
RoboErik0271b412011-03-01 15:34:53 -0800606 t = new Time();
607 t.set(mController.getTime());
608 if (t.minute >= 30) {
RoboErikd97f7982011-03-02 15:13:05 -0800609 t.hour++;
RoboErik0271b412011-03-01 15:34:53 -0800610 t.minute = 0;
RoboErikd97f7982011-03-02 15:13:05 -0800611 } else {
612 t.minute = 30;
RoboErik0271b412011-03-01 15:34:53 -0800613 }
614 mController.sendEventRelatedEvent(
615 this, EventType.CREATE_EVENT, -1, t.toMillis(true), 0, 0, 0, -1);
Michael Chan3458a172010-07-13 17:58:21 -0700616 return true;
Michael Chan2aeb8d92011-07-10 13:32:09 -0700617 case R.id.action_select_visible_calendars:
618 mController.sendEvent(this, EventType.LAUNCH_SELECT_VISIBLE_CALENDARS, null, null,
619 0, 0);
620 return true;
Michael Chanab29d9e2010-07-21 06:08:47 -0700621 case R.id.action_settings:
622 mController.sendEvent(this, EventType.LAUNCH_SETTINGS, null, null, 0, 0);
623 return true;
RoboErikde20d762011-02-08 17:52:25 -0800624 case R.id.action_hide_controls:
625 mHideControls = !mHideControls;
626 item.setTitle(mHideControls ? mShowString : mHideString);
RoboErikb8549562011-02-15 14:25:23 -0800627 final ObjectAnimator slideAnimation = ObjectAnimator.ofInt(this, "controlsOffset",
628 mHideControls ? 0 : CONTROLS_ANIMATE_WIDTH,
629 mHideControls ? CONTROLS_ANIMATE_WIDTH : 0);
630 slideAnimation.setDuration(CONTROLS_ANIMATE_DURATION);
631 ObjectAnimator.setFrameDelay(0);
632 slideAnimation.start();
RoboErikde20d762011-02-08 17:52:25 -0800633 return true;
RoboErike635aec2011-07-15 11:22:13 -0700634 case R.id.action_search:
635 if (!mIsMultipane && mSearchView != null) {
636 item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
637 mSearchView.setActivated(true);
638 mSearchView.setIconified(false);
639 }
Michael Chan3458a172010-07-13 17:58:21 -0700640 default:
641 return false;
642 }
Michael Chanab29d9e2010-07-21 06:08:47 -0700643 mController.sendEvent(this, EventType.GO_TO, t, null, -1, viewType);
Michael Chan3458a172010-07-13 17:58:21 -0700644 return true;
645 }
Mason Tang8e3d4302010-07-12 17:39:30 -0700646
RoboErikb8549562011-02-15 14:25:23 -0800647 /**
648 * Sets the offset of the controls on the right for animating them off/on
649 * screen. ProGuard strips this if it's not in proguard.flags
650 *
651 * @param controlsOffset The current offset in pixels
652 */
653 public void setControlsOffset(int controlsOffset) {
654 mMiniMonth.setTranslationX(controlsOffset);
655 mCalendarsList.setTranslationX(controlsOffset);
656 mHomeTime.setTranslationX(controlsOffset);
Michael Chan5756bbc2011-03-02 18:22:07 -0800657 mControlsParams.width = Math.max(0, CONTROLS_ANIMATE_WIDTH - controlsOffset);
RoboErikb8549562011-02-15 14:25:23 -0800658 mMiniMonthContainer.setLayoutParams(mControlsParams);
659 }
RoboErikde20d762011-02-08 17:52:25 -0800660
Mason Tang8e3d4302010-07-12 17:39:30 -0700661 @Override
662 public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
Daisuke Miyakawa4b441bd2010-09-16 14:55:36 -0700663 if (key.equals(GeneralPreferences.KEY_WEEK_START_DAY)) {
Erikcb811892010-09-28 13:44:19 -0700664 if (mPaused) {
665 mUpdateOnResume = true;
666 } else {
667 initFragments(mController.getTime(), mController.getViewType(), null);
668 }
Mason Tang8e3d4302010-07-12 17:39:30 -0700669 }
670 }
Michael Chanab29d9e2010-07-21 06:08:47 -0700671
Erik63cd0532011-01-26 14:16:03 -0800672 private void setMainPane(
673 FragmentTransaction ft, int viewId, int viewType, long timeMillis, boolean force) {
Michael Chan6191c122010-11-02 16:23:47 -0700674 if (mOnSaveInstanceStateCalled) {
675 return;
676 }
Erik7b92da22010-09-23 14:55:22 -0700677 if (!force && mCurrentView == viewType) {
Michael Chanab29d9e2010-07-21 06:08:47 -0700678 return;
679 }
680
Michael Chan5756bbc2011-03-02 18:22:07 -0800681 // Remove this when transition to and from month view looks fine.
682 boolean doTransition = viewType != ViewType.MONTH && mCurrentView != ViewType.MONTH;
RoboErikd725bfc2011-06-20 14:09:09 -0700683 FragmentManager fragmentManager = getFragmentManager();
684 // Check if our previous view was an Agenda view
685 // TODO remove this if framework ever supports nested fragments
686 if (mCurrentView == ViewType.AGENDA) {
687 // If it was, we need to do some cleanup on it to prevent the
688 // edit/delete buttons from coming back on a rotation.
689 Fragment oldFrag = fragmentManager.findFragmentById(viewId);
690 if (oldFrag instanceof AgendaFragment) {
691 ((AgendaFragment) oldFrag).removeFragments(fragmentManager);
692 }
693 }
Michael Chan5756bbc2011-03-02 18:22:07 -0800694
Erik648c59c2010-08-13 12:49:26 -0700695 if (viewType != mCurrentView) {
696 // The rules for this previous view are different than the
697 // controller's and are used for intercepting the back button.
Erikdd95df52010-08-27 09:31:18 -0700698 if (mCurrentView != ViewType.EDIT && mCurrentView > 0) {
699 mPreviousView = mCurrentView;
700 }
Erik648c59c2010-08-13 12:49:26 -0700701 mCurrentView = viewType;
702 }
Erik3f348f32010-08-10 13:17:19 -0700703 // Create new fragment
Isaac Katzenelson6a182582011-04-21 15:46:33 -0700704 Fragment frag = null;
705 Fragment secFrag = null;
Michael Chanab29d9e2010-07-21 06:08:47 -0700706 switch (viewType) {
707 case ViewType.AGENDA:
Isaac Katzenelsonae7c1c62011-04-11 18:30:26 -0700708 if (mActionBar != null && (mActionBar.getSelectedTab() != mAgendaTab)) {
709 mActionBar.selectTab(mAgendaTab);
710 }
Isaac Katzenelson01d36972011-06-29 11:29:35 -0700711 if (mActionBarMenuSpinnerAdapter != null) {
712 mActionBar.setSelectedNavigationItem(CalendarViewAdapter.AGENDA_BUTTON_INDEX);
713 }
Isaac Katzenelsonccf565b2011-04-27 14:40:08 -0700714 frag = new AgendaFragment(timeMillis, false);
Michael Chanab29d9e2010-07-21 06:08:47 -0700715 break;
716 case ViewType.DAY:
Daisuke Miyakawa40474a82010-10-25 17:07:34 -0700717 if (mActionBar != null && (mActionBar.getSelectedTab() != mDayTab)) {
718 mActionBar.selectTab(mDayTab);
719 }
Isaac Katzenelson01d36972011-06-29 11:29:35 -0700720 if (mActionBarMenuSpinnerAdapter != null) {
721 mActionBar.setSelectedNavigationItem(CalendarViewAdapter.DAY_BUTTON_INDEX);
722 }
Michael Chan75d9b562010-07-26 16:54:25 -0700723 frag = new DayFragment(timeMillis, 1);
724 break;
Michael Chanab29d9e2010-07-21 06:08:47 -0700725 case ViewType.WEEK:
Daisuke Miyakawa40474a82010-10-25 17:07:34 -0700726 if (mActionBar != null && (mActionBar.getSelectedTab() != mWeekTab)) {
727 mActionBar.selectTab(mWeekTab);
728 }
Isaac Katzenelson01d36972011-06-29 11:29:35 -0700729 if (mActionBarMenuSpinnerAdapter != null) {
730 mActionBar.setSelectedNavigationItem(CalendarViewAdapter.WEEK_BUTTON_INDEX);
731 }
Michael Chan75d9b562010-07-26 16:54:25 -0700732 frag = new DayFragment(timeMillis, 7);
Michael Chanab29d9e2010-07-21 06:08:47 -0700733 break;
734 case ViewType.MONTH:
Daisuke Miyakawa40474a82010-10-25 17:07:34 -0700735 if (mActionBar != null && (mActionBar.getSelectedTab() != mMonthTab)) {
736 mActionBar.selectTab(mMonthTab);
737 }
Isaac Katzenelson01d36972011-06-29 11:29:35 -0700738 if (mActionBarMenuSpinnerAdapter != null) {
739 mActionBar.setSelectedNavigationItem(CalendarViewAdapter.MONTH_BUTTON_INDEX);
740 }
Erik40bcd102010-11-16 15:46:40 -0800741 frag = new MonthByWeekFragment(timeMillis, false);
Isaac Katzenelson6a182582011-04-21 15:46:33 -0700742 if (mShowAgendaWithMonth) {
Isaac Katzenelsonccf565b2011-04-27 14:40:08 -0700743 secFrag = new AgendaFragment(timeMillis, false);
Isaac Katzenelson6a182582011-04-21 15:46:33 -0700744 }
Michael Chanab29d9e2010-07-21 06:08:47 -0700745 break;
746 default:
Michael Chand6734db2010-07-22 00:48:08 -0700747 throw new IllegalArgumentException(
748 "Must be Agenda, Day, Week, or Month ViewType, not " + viewType);
Michael Chanab29d9e2010-07-21 06:08:47 -0700749 }
750
Isaac Katzenelson9a39bdd2011-06-23 16:52:08 -0700751 // Update the current view so that the menu can update its look according to the
752 // current view.
753 if (!mIsTabletConfig && mActionBarMenuSpinnerAdapter != null) {
754 mActionBarMenuSpinnerAdapter.setMainView(viewType);
755 }
756
Isaac Katzenelson672ecfd2011-07-01 16:11:32 -0700757
758 // Show date only on tablet configurations in views different than Agenda
759 if (!mIsTabletConfig) {
760 mDateRange.setVisibility(View.GONE);
761 } else if (viewType != ViewType.AGENDA) {
762 mDateRange.setVisibility(View.VISIBLE);
763 } else {
764 mDateRange.setVisibility(View.GONE);
765 }
766
Isaac Katzenelsonccf565b2011-04-27 14:40:08 -0700767 // Clear unnecessary buttons from the option menu when switching from the agenda view
768 if (viewType != ViewType.AGENDA) {
769 clearOptionsMenu();
770 }
771
Michael Chanab29d9e2010-07-21 06:08:47 -0700772 boolean doCommit = false;
773 if (ft == null) {
774 doCommit = true;
RoboErikd725bfc2011-06-20 14:09:09 -0700775 ft = fragmentManager.beginTransaction();
Michael Chanab29d9e2010-07-21 06:08:47 -0700776 }
777
Michael Chan5756bbc2011-03-02 18:22:07 -0800778 if (doTransition) {
779 ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
780 }
781
Michael Chanab29d9e2010-07-21 06:08:47 -0700782 ft.replace(viewId, frag);
Isaac Katzenelson6a182582011-04-21 15:46:33 -0700783 if (mShowAgendaWithMonth) {
Daisuke Miyakawa93e69eb2010-10-22 18:54:38 -0700784
Isaac Katzenelson6a182582011-04-21 15:46:33 -0700785 // Show/hide secondary fragment
786
787 if (secFrag != null) {
788 ft.replace(R.id.secondary_pane, secFrag);
789 mSecondaryPane.setVisibility(View.VISIBLE);
790 } else {
791 mSecondaryPane.setVisibility(View.GONE);
RoboErikd725bfc2011-06-20 14:09:09 -0700792 Fragment f = fragmentManager.findFragmentById(R.id.secondary_pane);
Isaac Katzenelson5ab87e32011-04-21 17:19:25 -0700793 if (f != null) {
Isaac Katzenelson6a182582011-04-21 15:46:33 -0700794 ft.remove(f);
Isaac Katzenelson5ab87e32011-04-21 17:19:25 -0700795 }
Isaac Katzenelson6a182582011-04-21 15:46:33 -0700796 mController.deregisterEventHandler(R.id.secondary_pane);
797 }
798 }
Erik954c8712010-08-06 10:12:34 -0700799 if (DEBUG) {
800 Log.d(TAG, "Adding handler with viewId " + viewId + " and type " + viewType);
801 }
Erik3f348f32010-08-10 13:17:19 -0700802 // If the key is already registered this will replace it
803 mController.registerEventHandler(viewId, (EventHandler) frag);
Isaac Katzenelson6a182582011-04-21 15:46:33 -0700804 if (secFrag != null) {
805 mController.registerEventHandler(viewId, (EventHandler) secFrag);
806 }
Michael Chanab29d9e2010-07-21 06:08:47 -0700807
808 if (doCommit) {
Michael Chane8f45c62011-03-01 14:41:03 -0800809 Log.d(TAG, "setMainPane AllInOne=" + this + " finishing:" + this.isFinishing());
Michael Chanab29d9e2010-07-21 06:08:47 -0700810 ft.commit();
811 }
812 }
813
814 private void setTitleInActionBar(EventInfo event) {
Erikeaafa2b2010-12-23 14:30:37 -0800815 if (event.eventType != EventType.UPDATE_TITLE || mActionBar == null) {
Michael Chanab29d9e2010-07-21 06:08:47 -0700816 return;
817 }
818
Daisuke Miyakawa04ae7682010-10-19 14:15:39 -0700819 final long start = event.startTime.toMillis(false /* use isDst */);
820 final long end;
Michael Chand6734db2010-07-22 00:48:08 -0700821 if (event.endTime != null) {
Michael Chanab29d9e2010-07-21 06:08:47 -0700822 end = event.endTime.toMillis(false /* use isDst */);
Daisuke Miyakawa04ae7682010-10-19 14:15:39 -0700823 } else {
824 end = start;
Michael Chanab29d9e2010-07-21 06:08:47 -0700825 }
Michael Chanab29d9e2010-07-21 06:08:47 -0700826
Erikeaafa2b2010-12-23 14:30:37 -0800827 final String msg = Utils.formatDateRange(this, start, end, (int) event.extraLong);
Erik259b8f92011-01-12 14:01:12 -0800828 CharSequence oldDate = mDateRange.getText();
Erikeaafa2b2010-12-23 14:30:37 -0800829 mDateRange.setText(msg);
Erik259b8f92011-01-12 14:01:12 -0800830 if (!TextUtils.equals(oldDate, msg)) {
831 mDateRange.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED);
832 }
Michael Chanab29d9e2010-07-21 06:08:47 -0700833 }
834
Erik6c255102010-09-29 14:43:00 -0700835 private void updateHomeClock() {
Erikc5f92d72010-11-11 16:18:34 -0800836 mTimeZone = Utils.getTimeZone(this, mHomeTimeUpdater);
Erik6c255102010-09-29 14:43:00 -0700837 if (mIsMultipane && (mCurrentView == ViewType.DAY || mCurrentView == ViewType.WEEK)
Erikc5f92d72010-11-11 16:18:34 -0800838 && !TextUtils.equals(mTimeZone, Time.getCurrentTimezone())) {
839 Time time = new Time(mTimeZone);
Erik6c255102010-09-29 14:43:00 -0700840 time.setToNow();
841 long millis = time.toMillis(true);
842 boolean isDST = time.isDst != 0;
843 int flags = DateUtils.FORMAT_SHOW_TIME;
844 if (DateFormat.is24HourFormat(this)) {
845 flags |= DateUtils.FORMAT_24HOUR;
846 }
847 // Formats the time as
Erikc5f92d72010-11-11 16:18:34 -0800848 String timeString = (new StringBuilder(
849 Utils.formatDateRange(this, millis, millis, flags))).append(" ").append(
850 TimeZone.getTimeZone(mTimeZone).getDisplayName(
851 isDST, TimeZone.SHORT, Locale.getDefault())).toString();
Erik6c255102010-09-29 14:43:00 -0700852 mHomeTime.setText(timeString);
853 mHomeTime.setVisibility(View.VISIBLE);
854 // Update when the minute changes
855 mHomeTime.postDelayed(
Daisuke Miyakawac9e53072010-10-14 12:18:49 -0700856 mHomeTimeUpdater,
857 DateUtils.MINUTE_IN_MILLIS - (millis % DateUtils.MINUTE_IN_MILLIS));
Erik6c255102010-09-29 14:43:00 -0700858 } else {
RoboErike9cd8f42011-07-01 16:36:11 -0700859 mHomeTime.setVisibility(View.INVISIBLE);
Erik6c255102010-09-29 14:43:00 -0700860 }
861 }
862
Erik3f348f32010-08-10 13:17:19 -0700863 @Override
Michael Chanab29d9e2010-07-21 06:08:47 -0700864 public long getSupportedEventTypes() {
Erikeaafa2b2010-12-23 14:30:37 -0800865 return EventType.GO_TO | EventType.VIEW_EVENT | EventType.UPDATE_TITLE;
Michael Chanab29d9e2010-07-21 06:08:47 -0700866 }
867
Erik3f348f32010-08-10 13:17:19 -0700868 @Override
Michael Chanab29d9e2010-07-21 06:08:47 -0700869 public void handleEvent(EventInfo event) {
Michael Chane8f45c62011-03-01 14:41:03 -0800870 Log.d(TAG, "handleEvent AllInOne=" + this);
Michael Chanab29d9e2010-07-21 06:08:47 -0700871 if (event.eventType == EventType.GO_TO) {
Erik63cd0532011-01-26 14:16:03 -0800872 setMainPane(
873 null, R.id.main_pane, event.viewType, event.startTime.toMillis(false), false);
Erikaa3dde12011-02-03 11:16:23 -0800874 if (mSearchView != null) {
875 mSearchView.clearFocus();
876 }
Isaac Katzenelsonccf565b2011-04-27 14:40:08 -0700877
Isaac Katzenelson5ab87e32011-04-21 17:19:25 -0700878 if (mShowCalendarControls) {
Isaac Katzenelsonccf565b2011-04-27 14:40:08 -0700879 if (event.viewType == ViewType.MONTH || event.viewType == ViewType.AGENDA) {
Isaac Katzenelson5ab87e32011-04-21 17:19:25 -0700880 // hide minimonth and calendar frag
881 mShowSideViews = false;
882 if (mControlsMenu != null) {
883 mControlsMenu.setVisible(false);
884 mControlsMenu.setEnabled(false);
Michael Chan5756bbc2011-03-02 18:22:07 -0800885
Isaac Katzenelson5ab87e32011-04-21 17:19:25 -0700886 if (!mHideControls) {
887 final ObjectAnimator slideAnimation = ObjectAnimator.ofInt(this,
888 "controlsOffset", 0, CONTROLS_ANIMATE_WIDTH);
889 slideAnimation.addListener(mSlideAnimationDoneListener);
890 slideAnimation.setDuration(220);
891 ObjectAnimator.setFrameDelay(0);
892 slideAnimation.start();
893 }
894 } else {
895 mMiniMonth.setVisibility(View.GONE);
896 mCalendarsList.setVisibility(View.GONE);
897 mMiniMonthContainer.setVisibility(View.GONE);
Michael Chan100bdbe2011-03-04 22:30:10 -0800898 }
Michael Chan5756bbc2011-03-02 18:22:07 -0800899 } else {
Isaac Katzenelson5ab87e32011-04-21 17:19:25 -0700900 // show minimonth and calendar frag
901 mShowSideViews = true;
902 mMiniMonth.setVisibility(View.VISIBLE);
903 mCalendarsList.setVisibility(View.VISIBLE);
904 mMiniMonthContainer.setVisibility(View.VISIBLE);
905 if (mControlsMenu != null) {
906 mControlsMenu.setVisible(true);
907 mControlsMenu.setEnabled(true);
Isaac Katzenelsonccf565b2011-04-27 14:40:08 -0700908 if (!mHideControls &&
909 (mController.getPreviousViewType() == ViewType.MONTH ||
910 mController.getPreviousViewType() == ViewType.AGENDA)) {
Isaac Katzenelson5ab87e32011-04-21 17:19:25 -0700911 final ObjectAnimator slideAnimation = ObjectAnimator.ofInt(this,
912 "controlsOffset", CONTROLS_ANIMATE_WIDTH, 0);
913 slideAnimation.setDuration(220);
914 ObjectAnimator.setFrameDelay(0);
915 slideAnimation.start();
916 }
Michael Chan5756bbc2011-03-02 18:22:07 -0800917 }
RoboErikde20d762011-02-08 17:52:25 -0800918 }
Michael Chanab29d9e2010-07-21 06:08:47 -0700919 }
Michael Chan71d08832010-08-25 18:28:59 -0700920 } else if (event.eventType == EventType.VIEW_EVENT) {
Isaac Katzenelsonccf565b2011-04-27 14:40:08 -0700921
922 // If in Agenda view and "show_event_details_with_agenda" is "true",
923 // do not create the event info fragment here, it will be created by the Agenda
924 // fragment
925
926 if (mCurrentView == ViewType.AGENDA && mShowEventDetailsWithAgenda) {
927 if (event.selectedTime != null) {
928 mController.sendEvent(this, EventType.GO_TO, event.selectedTime,
929 event.selectedTime, event.id, ViewType.AGENDA);
930 }
931 } else {
Isaac Katzenelson60f01c22011-06-03 15:42:01 -0700932 if (mShowEventInfoFullScreen) {
933 // start event info as activity
934 Intent intent = new Intent(Intent.ACTION_VIEW);
935 Uri eventUri = ContentUris.withAppendedId(Events.CONTENT_URI, event.id);
936 intent.setData(eventUri);
937 intent.setClassName(this, EventInfoActivity.class.getName());
938 intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT |
939 Intent.FLAG_ACTIVITY_SINGLE_TOP);
RoboErika27a8862011-06-23 15:26:23 -0700940 intent.putExtra(EXTRA_EVENT_BEGIN_TIME, event.startTime.toMillis(false));
941 intent.putExtra(EXTRA_EVENT_END_TIME, event.endTime.toMillis(false));
Isaac Katzenelson60f01c22011-06-03 15:42:01 -0700942 intent.putExtra(EVENT_ATTENDEE_RESPONSE, (int)event.extraLong);
943 startActivity(intent);
944 } else {
945 // start event info as a dialog
946 EventInfoFragment fragment = new EventInfoFragment(this,
947 event.id, event.startTime.toMillis(false),
948 event.endTime.toMillis(false), (int) event.extraLong, true);
949 // TODO Fix the temp hack below: && mCurrentView !=
950 // ViewType.AGENDA
951 if (event.selectedTime != null && mCurrentView != ViewType.AGENDA) {
952 mController.sendEvent(this, EventType.GO_TO, event.selectedTime,
953 event.selectedTime, -1, ViewType.DETAIL);
954 }
955 fragment.setDialogParams(event.x, event.y);
956 FragmentManager fm = getFragmentManager();
957 FragmentTransaction ft = fm.beginTransaction();
958 // if we have an old popup close it
959 Fragment fOld = fm.findFragmentByTag(EVENT_INFO_FRAGMENT_TAG);
960 if (fOld != null && fOld.isAdded()) {
961 ft.remove(fOld);
962 }
963 ft.add(fragment, EVENT_INFO_FRAGMENT_TAG);
964 ft.commit();
Isaac Katzenelsonccf565b2011-04-27 14:40:08 -0700965 }
Erik63cd0532011-01-26 14:16:03 -0800966 }
Erikeaafa2b2010-12-23 14:30:37 -0800967 } else if (event.eventType == EventType.UPDATE_TITLE) {
968 setTitleInActionBar(event);
Isaac Katzenelson9a39bdd2011-06-23 16:52:08 -0700969 if (!mIsTabletConfig) {
970 mActionBarMenuSpinnerAdapter.setTime(event.startTime.toMillis(false));
971 }
Michael Chanab29d9e2010-07-21 06:08:47 -0700972 }
Erik6c255102010-09-29 14:43:00 -0700973 updateHomeClock();
Michael Chanab29d9e2010-07-21 06:08:47 -0700974 }
975
Michael Chan2aeb8d92011-07-10 13:32:09 -0700976 // Needs to be in proguard whitelist
977 // Specified as listener via android:onClick in a layout xml
978 public void handleSelectSyncedCalendarsClicked(View v) {
979 mController.sendEvent(this, EventType.LAUNCH_SETTINGS, null, null, null, 0, 0,
980 CalendarController.EXTRA_GOTO_TIME, null,
981 null);
982 }
983
Erik3f348f32010-08-10 13:17:19 -0700984 @Override
Michael Chanab29d9e2010-07-21 06:08:47 -0700985 public void eventsChanged() {
Erik954c8712010-08-06 10:12:34 -0700986 mController.sendEvent(this, EventType.EVENTS_CHANGED, null, null, -1, ViewType.CURRENT);
Michael Chanab29d9e2010-07-21 06:08:47 -0700987 }
988
Erik3f348f32010-08-10 13:17:19 -0700989 @Override
Adam Powell28f9b352011-01-20 18:36:10 -0800990 public boolean onQueryTextChange(String newText) {
Daisuke Miyakawa6d2e6f72010-09-17 10:30:54 -0700991 return false;
992 }
993
994 @Override
Adam Powell28f9b352011-01-20 18:36:10 -0800995 public boolean onQueryTextSubmit(String query) {
Michael Chanc03aab42011-04-21 15:59:29 -0700996 if ("TARDIS".equalsIgnoreCase(query)) {
Erikca478672011-01-19 20:02:47 -0800997 Utils.tardis();
998 }
Erikcb830312011-01-19 14:41:41 -0800999 mSearchView.clearFocus();
Michael Chan46a8b112010-12-14 16:36:27 -08001000 mController.sendEvent(this, EventType.SEARCH, null, null, -1, ViewType.CURRENT, -1, query,
Erik7b92da22010-09-23 14:55:22 -07001001 getComponentName());
Daisuke Miyakawa6d2e6f72010-09-17 10:30:54 -07001002 return false;
1003 }
Daisuke Miyakawa04ae7682010-10-19 14:15:39 -07001004
1005 @Override
1006 public void onTabSelected(Tab tab, FragmentTransaction ft) {
Michael Chane8f45c62011-03-01 14:41:03 -08001007 Log.w(TAG, "TabSelected AllInOne=" + this + " finishing:" + this.isFinishing());
Daisuke Miyakawa40474a82010-10-25 17:07:34 -07001008 if (tab == mDayTab && mCurrentView != ViewType.DAY) {
Daisuke Miyakawa04ae7682010-10-19 14:15:39 -07001009 mController.sendEvent(this, EventType.GO_TO, null, null, -1, ViewType.DAY);
Daisuke Miyakawa40474a82010-10-25 17:07:34 -07001010 } else if (tab == mWeekTab && mCurrentView != ViewType.WEEK) {
Daisuke Miyakawa04ae7682010-10-19 14:15:39 -07001011 mController.sendEvent(this, EventType.GO_TO, null, null, -1, ViewType.WEEK);
Daisuke Miyakawa40474a82010-10-25 17:07:34 -07001012 } else if (tab == mMonthTab && mCurrentView != ViewType.MONTH) {
Daisuke Miyakawa04ae7682010-10-19 14:15:39 -07001013 mController.sendEvent(this, EventType.GO_TO, null, null, -1, ViewType.MONTH);
Isaac Katzenelsonae7c1c62011-04-11 18:30:26 -07001014 } else if (tab == mAgendaTab && mCurrentView != ViewType.AGENDA) {
1015 mController.sendEvent(this, EventType.GO_TO, null, null, -1, ViewType.AGENDA);
Daisuke Miyakawa04ae7682010-10-19 14:15:39 -07001016 } else {
Michael Chanece2fbd2011-01-19 14:49:37 -08001017 Log.w(TAG, "TabSelected event from unknown tab: "
1018 + (tab == null ? "null" : tab.getText()));
1019 Log.w(TAG, "CurrentView:" + mCurrentView + " Tab:" + tab.toString() + " Day:" + mDayTab
Isaac Katzenelsonae7c1c62011-04-11 18:30:26 -07001020 + " Week:" + mWeekTab + " Month:" + mMonthTab + " Agenda:" + mAgendaTab);
Daisuke Miyakawa04ae7682010-10-19 14:15:39 -07001021 }
1022 }
1023
1024 @Override
1025 public void onTabReselected(Tab tab, FragmentTransaction ft) {
1026 }
1027
1028 @Override
1029 public void onTabUnselected(Tab tab, FragmentTransaction ft) {
1030 }
Isaac Katzenelson2c5dd7c2011-06-16 17:56:06 -07001031
1032
1033 @Override
1034 public boolean onNavigationItemSelected(int itemPosition, long itemId) {
1035 switch (itemPosition) {
Isaac Katzenelson9a39bdd2011-06-23 16:52:08 -07001036 case CalendarViewAdapter.DAY_BUTTON_INDEX:
Isaac Katzenelson2c5dd7c2011-06-16 17:56:06 -07001037 if (mCurrentView != ViewType.DAY) {
1038 mController.sendEvent(this, EventType.GO_TO, null, null, -1, ViewType.DAY);
1039 }
1040 break;
Isaac Katzenelson9a39bdd2011-06-23 16:52:08 -07001041 case CalendarViewAdapter.WEEK_BUTTON_INDEX:
Isaac Katzenelson2c5dd7c2011-06-16 17:56:06 -07001042 if (mCurrentView != ViewType.WEEK) {
1043 mController.sendEvent(this, EventType.GO_TO, null, null, -1, ViewType.WEEK);
1044 }
1045 break;
Isaac Katzenelson9a39bdd2011-06-23 16:52:08 -07001046 case CalendarViewAdapter.MONTH_BUTTON_INDEX:
Isaac Katzenelson2c5dd7c2011-06-16 17:56:06 -07001047 if (mCurrentView != ViewType.MONTH) {
1048 mController.sendEvent(this, EventType.GO_TO, null, null, -1, ViewType.MONTH);
1049 }
1050 break;
Isaac Katzenelson9a39bdd2011-06-23 16:52:08 -07001051 case CalendarViewAdapter.AGENDA_BUTTON_INDEX:
Isaac Katzenelson2c5dd7c2011-06-16 17:56:06 -07001052 if (mCurrentView != ViewType.AGENDA) {
1053 mController.sendEvent(this, EventType.GO_TO, null, null, -1, ViewType.AGENDA);
1054 }
1055 break;
1056 default:
1057 Log.w(TAG, "ItemSelected event from unknown button: " + itemPosition);
1058 Log.w(TAG, "CurrentView:" + mCurrentView + " Button:" + itemPosition +
1059 " Day:" + mDayTab + " Week:" + mWeekTab + " Month:" + mMonthTab +
1060 " Agenda:" + mAgendaTab);
1061 break;
1062 }
1063 return false;
1064 }
RoboErike635aec2011-07-15 11:22:13 -07001065
1066 /*
1067 * Handles the search view being closed.
1068 */
1069 @Override
1070 public boolean onClose() {
1071 if (!mIsMultipane) {
1072 mSearchMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
1073 invalidateOptionsMenu();
1074 }
1075 return false;
1076 }
Michael Chan49701592010-06-30 11:04:03 -07001077}