MenuHelperpublic class MenuHelper extends Object
Fields Summary |
---|
private static final int | MENU_GROUP_AGENDA | private static final int | MENU_GROUP_DAY | private static final int | MENU_GROUP_WEEK | private static final int | MENU_GROUP_MONTH | private static final int | MENU_GROUP_EVENT_CREATE | private static final int | MENU_GROUP_TODAY | private static final int | MENU_GROUP_SELECT_CALENDARS | private static final int | MENU_GROUP_PREFERENCES | public static final int | MENU_GOTO_TODAY | public static final int | MENU_AGENDA | public static final int | MENU_DAY | public static final int | MENU_WEEK | public static final int | MENU_EVENT_VIEW | public static final int | MENU_EVENT_CREATE | public static final int | MENU_EVENT_EDIT | public static final int | MENU_EVENT_DELETE | public static final int | MENU_MONTH | public static final int | MENU_SELECT_CALENDARS | public static final int | MENU_PREFERENCES |
Methods Summary |
---|
public static boolean | onCreateOptionsMenu(android.view.Menu menu)
MenuItem item;
item = menu.add(MENU_GROUP_AGENDA, MENU_AGENDA, 0, R.string.agenda_view);
item.setIcon(android.R.drawable.ic_menu_agenda);
item.setAlphabeticShortcut('a");
item = menu.add(MENU_GROUP_DAY, MENU_DAY, 0, R.string.day_view);
item.setIcon(android.R.drawable.ic_menu_day);
item.setAlphabeticShortcut('d");
item = menu.add(MENU_GROUP_WEEK, MENU_WEEK, 0, R.string.week_view);
item.setIcon(android.R.drawable.ic_menu_week);
item.setAlphabeticShortcut('w");
item = menu.add(MENU_GROUP_MONTH, MENU_MONTH, 0, R.string.month_view);
item.setIcon(android.R.drawable.ic_menu_month);
item.setAlphabeticShortcut('m");
item = menu.add(MENU_GROUP_EVENT_CREATE, MENU_EVENT_CREATE, 0, R.string.event_create);
item.setIcon(android.R.drawable.ic_menu_add);
item.setAlphabeticShortcut('n");
item = menu.add(MENU_GROUP_TODAY, MENU_GOTO_TODAY, 0, R.string.goto_today);
item.setIcon(android.R.drawable.ic_menu_today);
item.setAlphabeticShortcut('t");
item = menu.add(MENU_GROUP_SELECT_CALENDARS, MENU_SELECT_CALENDARS,
0, R.string.menu_select_calendars);
item.setIcon(android.R.drawable.ic_menu_manage);
item = menu.add(MENU_GROUP_PREFERENCES, MENU_PREFERENCES, 0, R.string.menu_preferences);
item.setIcon(android.R.drawable.ic_menu_preferences);
item.setAlphabeticShortcut('p");
return true;
| public static boolean | onOptionsItemSelected(android.app.Activity activity, android.view.MenuItem item, Navigator nav)
switch (item.getItemId()) {
case MENU_SELECT_CALENDARS: {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setClass(activity, SelectCalendarsActivity.class);
activity.startActivity(intent);
return true;
}
case MENU_GOTO_TODAY:
nav.goToToday();
return true;
case MENU_PREFERENCES:
switchTo(activity, CalendarPreferenceActivity.class.getName(), nav.getSelectedTime());
return true;
case MENU_AGENDA:
switchTo(activity, AgendaActivity.class.getName(), nav.getSelectedTime());
activity.finish();
return true;
case MENU_DAY:
switchTo(activity, DayActivity.class.getName(), nav.getSelectedTime());
activity.finish();
return true;
case MENU_WEEK:
switchTo(activity, WeekActivity.class.getName(), nav.getSelectedTime());
activity.finish();
return true;
case MENU_MONTH:
switchTo(activity, MonthActivity.class.getName(), nav.getSelectedTime());
activity.finish();
return true;
case MENU_EVENT_CREATE: {
long startMillis = nav.getSelectedTime();
long endMillis = startMillis + DateUtils.HOUR_IN_MILLIS;
Intent intent = new Intent(Intent.ACTION_EDIT);
intent.setClassName(activity, EditEvent.class.getName());
intent.putExtra(EVENT_BEGIN_TIME, startMillis);
intent.putExtra(EVENT_END_TIME, endMillis);
intent.putExtra(EditEvent.EVENT_ALL_DAY, nav.getAllDay());
activity.startActivity(intent);
return true;
}
}
return false;
| public static void | onPrepareOptionsMenu(android.app.Activity activity, android.view.Menu menu)
if (activity instanceof AgendaActivity) {
menu.setGroupVisible(MENU_GROUP_AGENDA, false);
menu.setGroupEnabled(MENU_GROUP_AGENDA, false);
} else {
menu.setGroupVisible(MENU_GROUP_AGENDA, true);
menu.setGroupEnabled(MENU_GROUP_AGENDA, true);
}
if (activity instanceof DayActivity) {
menu.setGroupVisible(MENU_GROUP_DAY, false);
menu.setGroupEnabled(MENU_GROUP_DAY, false);
} else {
menu.setGroupVisible(MENU_GROUP_DAY, true);
menu.setGroupEnabled(MENU_GROUP_DAY, true);
}
if (activity instanceof WeekActivity) {
menu.setGroupVisible(MENU_GROUP_WEEK, false);
menu.setGroupEnabled(MENU_GROUP_WEEK, false);
} else {
menu.setGroupVisible(MENU_GROUP_WEEK, true);
menu.setGroupEnabled(MENU_GROUP_WEEK, true);
}
if (activity instanceof MonthActivity) {
menu.setGroupVisible(MENU_GROUP_MONTH, false);
menu.setGroupEnabled(MENU_GROUP_MONTH, false);
} else {
menu.setGroupVisible(MENU_GROUP_MONTH, true);
menu.setGroupEnabled(MENU_GROUP_MONTH, true);
}
if (activity instanceof EventInfoActivity) {
menu.setGroupVisible(MENU_GROUP_TODAY, false);
menu.setGroupEnabled(MENU_GROUP_TODAY, false);
} else {
menu.setGroupVisible(MENU_GROUP_TODAY, true);
menu.setGroupEnabled(MENU_GROUP_TODAY, true);
}
| static void | switchTo(android.app.Activity activity, java.lang.String className, long startMillis)
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setClassName(activity, className);
intent.putExtra(EVENT_BEGIN_TIME, startMillis);
activity.startActivity(intent);
|
|