diff options
author | Mason Tang <masontang@google.com> | 2010-08-18 16:10:25 -0700 |
---|---|---|
committer | Mason Tang <masontang@google.com> | 2010-08-20 13:54:15 -0700 |
commit | 1df2ca65a852fda463b1d787cd4f81680103b6a2 (patch) | |
tree | e330db83b7666c00c686ced846e345bc6deccec5 /src | |
parent | c00ec3b69b75be7f58b97206dae4a7c70114b976 (diff) | |
download | android_packages_apps_Calendar-1df2ca65a852fda463b1d787cd4f81680103b6a2.tar.gz android_packages_apps_Calendar-1df2ca65a852fda463b1d787cd4f81680103b6a2.tar.bz2 android_packages_apps_Calendar-1df2ca65a852fda463b1d787cd4f81680103b6a2.zip |
Added in preliminary action bar support for search
Change-Id: I4b5b0ea40b5ef8b5f193eecf06617291fb7aa18f
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/calendar/EventInfoFragment.java | 13 | ||||
-rw-r--r-- | src/com/android/calendar/SearchActivity.java | 32 |
2 files changed, 41 insertions, 4 deletions
diff --git a/src/com/android/calendar/EventInfoFragment.java b/src/com/android/calendar/EventInfoFragment.java index 33332dd7..c96789b7 100644 --- a/src/com/android/calendar/EventInfoFragment.java +++ b/src/com/android/calendar/EventInfoFragment.java @@ -306,7 +306,7 @@ public class EventInfoFragment extends Fragment implements View.OnClickListener, // The cursor is empty. This can happen if the event was // deleted. // FRAG_TODO we should no longer rely on Activity.finish() - getActivity().finish(); + activity.finish(); return; } updateEvent(mView); @@ -323,6 +323,8 @@ public class EventInfoFragment extends Fragment implements View.OnClickListener, updateCalendar(mView); // FRAG_TODO fragments shouldn't set the title anymore updateTitle(); + // update the action bar since our option set might have changed + activity.invalidateOptionsMenu(); // this is used for both attendees and reminders args = new String[] { Long.toString(mEventId) }; @@ -356,7 +358,7 @@ public class EventInfoFragment extends Fragment implements View.OnClickListener, while (reminderCursor.moveToNext()) { int minutes = reminderCursor.getInt(REMINDERS_INDEX_MINUTES); EventViewUtils.addMinutesToList( - getActivity(), mReminderValues, mReminderLabels, minutes); + activity, mReminderValues, mReminderLabels, minutes); } // Second pass: create the reminder spinners @@ -364,7 +366,7 @@ public class EventInfoFragment extends Fragment implements View.OnClickListener, while (reminderCursor.moveToNext()) { int minutes = reminderCursor.getInt(REMINDERS_INDEX_MINUTES); mOriginalMinutes.add(minutes); - EventViewUtils.addReminder(getActivity(), mRemindersContainer, + EventViewUtils.addReminder(activity, mRemindersContainer, EventInfoFragment.this, mReminderItems, mReminderValues, mReminderLabels, minutes); } @@ -378,7 +380,7 @@ public class EventInfoFragment extends Fragment implements View.OnClickListener, String calendarName = mCalendarsCursor.getString(CALENDARS_INDEX_DISPLAY_NAME); String ownerAccount = mCalendarsCursor.getString(CALENDARS_INDEX_OWNER_ACCOUNT); if (mIsDuplicateName && !calendarName.equalsIgnoreCase(ownerAccount)) { - Resources res = getActivity().getResources(); + Resources res = activity.getResources(); TextView ownerText = (TextView) mView.findViewById(R.id.owner); ownerText.setText(ownerAccount); ownerText.setTextColor(res.getColor(R.color.calendar_owner_text_color)); @@ -685,13 +687,16 @@ public class EventInfoFragment extends Fragment implements View.OnClickListener, R.string.add_new_reminder); item.setIcon(R.drawable.ic_menu_reminder); item.setAlphabeticShortcut('r'); + item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); item = menu.add(MENU_GROUP_EDIT, MENU_EDIT, 0, R.string.edit_event_label); item.setIcon(android.R.drawable.ic_menu_edit); item.setAlphabeticShortcut('e'); + item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); item = menu.add(MENU_GROUP_DELETE, MENU_DELETE, 0, R.string.delete_event_label); item.setIcon(android.R.drawable.ic_menu_delete); + item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); super.onCreateOptionsMenu(menu, inflater); } diff --git a/src/com/android/calendar/SearchActivity.java b/src/com/android/calendar/SearchActivity.java index 880c1ad0..4239739d 100644 --- a/src/com/android/calendar/SearchActivity.java +++ b/src/com/android/calendar/SearchActivity.java @@ -46,6 +46,8 @@ import android.provider.Calendar.Events; import android.text.format.Time; import android.util.Log; import android.view.KeyEvent; +import android.view.Menu; +import android.view.MenuItem; import android.view.View; public class SearchActivity extends Activity implements CalendarController.EventHandler { @@ -203,6 +205,36 @@ public class SearchActivity extends Activity implements CalendarController.Event } @Override + public boolean onCreateOptionsMenu(Menu menu) { + super.onCreateOptionsMenu(menu); + getMenuInflater().inflate(R.menu.search_title_bar, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + Time t = null; + switch (item.getItemId()) { + case R.id.action_today: + t = new Time(); + t.setToNow(); + mController.sendEvent(this, EventType.GO_TO, t, null, -1, ViewType.CURRENT); + return true; + case R.id.action_search: + onSearchRequested(); + return true; + case R.id.action_manage_calendars: + mController.sendEvent(this, EventType.LAUNCH_MANAGE_CALENDARS, null, null, 0, 0); + return true; + case R.id.action_settings: + mController.sendEvent(this, EventType.LAUNCH_SETTINGS, null, null, 0, 0); + return true; + default: + return false; + } + } + + @Override protected void onNewIntent(Intent intent) { // From the Android Dev Guide: "It's important to note that when // onNewIntent(Intent) is called, the Activity has not been restarted, |