diff options
author | Sara Ting <sarating@google.com> | 2012-07-16 11:02:27 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-07-17 14:23:50 -0700 |
commit | 19da7825c58ff1caa463c75abcf31e579dea3a32 (patch) | |
tree | 61a636ab409c2c2a3d3c955e7a1218234ce22f41 | |
parent | cd1d934fce6c4ab2f231606a98a7d5af82e3d698 (diff) | |
download | android_packages_apps_Calendar-19da7825c58ff1caa463c75abcf31e579dea3a32.tar.gz android_packages_apps_Calendar-19da7825c58ff1caa463c75abcf31e579dea3a32.tar.bz2 android_packages_apps_Calendar-19da7825c58ff1caa463c75abcf31e579dea3a32.zip |
Adding hook for additional options in the AllInOne menu.
A new 'extensions_src' folder was added to contain skeletons for extensions.
Bug:5920207
Change-Id: Icaa377688b7a56a17db34dc954b844b059f07c33
-rw-r--r-- | Android.mk | 3 | ||||
-rw-r--r-- | extensions_src/com/android/calendar/extensions/AllInOneMenuExtensions.java | 41 | ||||
-rw-r--r-- | src/com/android/calendar/AllInOneActivity.java | 11 |
3 files changed, 53 insertions, 2 deletions
@@ -4,12 +4,13 @@ include $(CLEAR_VARS) # Include res dir from chips chips_dir := ../../../frameworks/ex/chips/res res_dirs := $(chips_dir) res +src_dirs := src extensions_src LOCAL_EMMA_COVERAGE_FILTER := +com.android.calendar.* LOCAL_MODULE_TAGS := optional -LOCAL_SRC_FILES := $(call all-java-files-under,src) +LOCAL_SRC_FILES := $(call all-java-files-under,$(src_dirs)) # bundled #LOCAL_STATIC_JAVA_LIBRARIES += \ diff --git a/extensions_src/com/android/calendar/extensions/AllInOneMenuExtensions.java b/extensions_src/com/android/calendar/extensions/AllInOneMenuExtensions.java new file mode 100644 index 00000000..61cd5672 --- /dev/null +++ b/extensions_src/com/android/calendar/extensions/AllInOneMenuExtensions.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.calendar.extensions; + +import android.content.Context; +import android.view.Menu; +import android.view.MenuItem; + +/* + * Skeleton for additional options in the AllInOne menu. + */ +public class AllInOneMenuExtensions { + + /** + * Hook for adding additional options. + */ + public Integer getExtensionMenuResource(Menu menu) { + return null; + } + + /** + * Hook for handling selection of the additional options. + */ + public boolean handleItemSelected(MenuItem item, Context context) { + return false; + } +} diff --git a/src/com/android/calendar/AllInOneActivity.java b/src/com/android/calendar/AllInOneActivity.java index ac53e11c..549fb4e5 100644 --- a/src/com/android/calendar/AllInOneActivity.java +++ b/src/com/android/calendar/AllInOneActivity.java @@ -76,6 +76,7 @@ import com.android.calendar.CalendarController.EventInfo; import com.android.calendar.CalendarController.EventType; import com.android.calendar.CalendarController.ViewType; import com.android.calendar.agenda.AgendaFragment; +import com.android.calendar.extensions.AllInOneMenuExtensions; import com.android.calendar.month.MonthByWeekFragment; import com.android.calendar.selectcalendars.SelectVisibleCalendarsFragment; @@ -167,6 +168,8 @@ public class AllInOneActivity extends Activity implements EventHandler, private LayoutParams mControlsParams; private LinearLayout.LayoutParams mVerticalControlsParams; + private AllInOneMenuExtensions mExtensions = new AllInOneMenuExtensions(); + private final AnimatorListener mSlideAnimationDoneListener = new AnimatorListener() { @Override @@ -730,6 +733,12 @@ public class AllInOneActivity extends Activity implements EventHandler, mOptionsMenu = menu; getMenuInflater().inflate(R.menu.all_in_one_title_bar, menu); + // Add additional options (if any). + Integer extensionMenuRes = mExtensions.getExtensionMenuResource(menu); + if (extensionMenuRes != null) { + getMenuInflater().inflate(extensionMenuRes, menu); + } + mSearchMenu = menu.findItem(R.id.action_search); mSearchView = (SearchView) mSearchMenu.getActionView(); if (mSearchView != null) { @@ -822,7 +831,7 @@ public class AllInOneActivity extends Activity implements EventHandler, case R.id.action_search: return false; default: - return false; + return mExtensions.handleItemSelected(item, this); } mController.sendEvent(this, EventType.GO_TO, t, null, t, -1, viewType, extras, null, null); return true; |