diff options
author | Paul Sliwowski <psliwowski@google.com> | 2013-06-26 18:59:18 -0700 |
---|---|---|
committer | Paul Sliwowski <psliwowski@google.com> | 2013-06-27 17:22:38 -0700 |
commit | 373e9dab4c22b74e0039427fd316544d93a5d318 (patch) | |
tree | 518549cc448a472da135a5e34dc15f3ae535f214 /src | |
parent | b8609e941d14444fa865acb08435120d16484280 (diff) | |
download | android_packages_apps_Calendar-373e9dab4c22b74e0039427fd316544d93a5d318.tar.gz android_packages_apps_Calendar-373e9dab4c22b74e0039427fd316544d93a5d318.tar.bz2 android_packages_apps_Calendar-373e9dab4c22b74e0039427fd316544d93a5d318.zip |
Add analytics tracking to calendar app.
Bug: 9486046
Change-Id: Icce29196849f7c43a1e5dc7ba12109f0a682df48
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/calendar/AllInOneActivity.java | 14 | ||||
-rw-r--r-- | src/com/android/calendar/AnalyticsLogger.java | 24 | ||||
-rw-r--r-- | src/com/android/calendar/ExtensionsFactory.java | 74 |
3 files changed, 86 insertions, 26 deletions
diff --git a/src/com/android/calendar/AllInOneActivity.java b/src/com/android/calendar/AllInOneActivity.java index d7d553f4..e61d69c8 100644 --- a/src/com/android/calendar/AllInOneActivity.java +++ b/src/com/android/calendar/AllInOneActivity.java @@ -16,11 +16,6 @@ package com.android.calendar; -import static android.provider.CalendarContract.EXTRA_EVENT_ALL_DAY; -import static android.provider.CalendarContract.EXTRA_EVENT_BEGIN_TIME; -import static android.provider.CalendarContract.EXTRA_EVENT_END_TIME; -import static android.provider.CalendarContract.Attendees.ATTENDEE_STATUS; - import android.accounts.AccountManager; import android.accounts.AccountManagerCallback; import android.accounts.AccountManagerFuture; @@ -82,6 +77,11 @@ import java.util.List; import java.util.Locale; import java.util.TimeZone; +import static android.provider.CalendarContract.Attendees.ATTENDEE_STATUS; +import static android.provider.CalendarContract.EXTRA_EVENT_ALL_DAY; +import static android.provider.CalendarContract.EXTRA_EVENT_BEGIN_TIME; +import static android.provider.CalendarContract.EXTRA_EVENT_END_TIME; + public class AllInOneActivity extends AbstractCalendarActivity implements EventHandler, OnSharedPreferenceChangeListener, SearchView.OnQueryTextListener, ActionBar.TabListener, ActionBar.OnNavigationListener, OnSuggestionListener { @@ -886,6 +886,7 @@ public class AllInOneActivity extends AbstractCalendarActivity implements EventH mActionBar.setSelectedNavigationItem(CalendarViewAdapter.AGENDA_BUTTON_INDEX); } frag = new AgendaFragment(timeMillis, false); + ExtensionsFactory.getAnalyticsLogger(getBaseContext()).trackView("agenda"); break; case ViewType.DAY: if (mActionBar != null && (mActionBar.getSelectedTab() != mDayTab)) { @@ -895,6 +896,7 @@ public class AllInOneActivity extends AbstractCalendarActivity implements EventH mActionBar.setSelectedNavigationItem(CalendarViewAdapter.DAY_BUTTON_INDEX); } frag = new DayFragment(timeMillis, 1); + ExtensionsFactory.getAnalyticsLogger(getBaseContext()).trackView("day"); break; case ViewType.MONTH: if (mActionBar != null && (mActionBar.getSelectedTab() != mMonthTab)) { @@ -907,6 +909,7 @@ public class AllInOneActivity extends AbstractCalendarActivity implements EventH if (mShowAgendaWithMonth) { secFrag = new AgendaFragment(timeMillis, false); } + ExtensionsFactory.getAnalyticsLogger(getBaseContext()).trackView("month"); break; case ViewType.WEEK: default: @@ -917,6 +920,7 @@ public class AllInOneActivity extends AbstractCalendarActivity implements EventH mActionBar.setSelectedNavigationItem(CalendarViewAdapter.WEEK_BUTTON_INDEX); } frag = new DayFragment(timeMillis, 7); + ExtensionsFactory.getAnalyticsLogger(getBaseContext()).trackView("week"); break; } diff --git a/src/com/android/calendar/AnalyticsLogger.java b/src/com/android/calendar/AnalyticsLogger.java new file mode 100644 index 00000000..c98984f2 --- /dev/null +++ b/src/com/android/calendar/AnalyticsLogger.java @@ -0,0 +1,24 @@ +package com.android.calendar; + +import android.content.Context; + +/** + * Interface for analytics logging. + */ +public interface AnalyticsLogger { + + /** + * Open backend of logger. + * + * @param context need to open backend of logger. + * @return true, if analytics logging is ready to be use. + */ + public boolean initialize(Context context); + + /** + * Track what view people are using. + * + * @param name of the view. + */ + public void trackView(String name); +} diff --git a/src/com/android/calendar/ExtensionsFactory.java b/src/com/android/calendar/ExtensionsFactory.java index c323e168..697e2b4e 100644 --- a/src/com/android/calendar/ExtensionsFactory.java +++ b/src/com/android/calendar/ExtensionsFactory.java @@ -42,9 +42,11 @@ public class ExtensionsFactory { private static String ALL_IN_ONE_MENU_KEY = "AllInOneMenuExtensions"; private static String CLOUD_NOTIFICATION_KEY = "CloudNotificationChannel"; + private static String ANALYTICS_LOGGER_KEY = "AnalyticsLogger"; private static Properties sProperties = new Properties(); private static AllInOneMenuExtensionsInterface sAllInOneMenuExtensions = null; + private static AnalyticsLogger sAnalyticsLogger = null; public static void init(AssetManager assetManager) { try { @@ -74,29 +76,30 @@ public class ExtensionsFactory { } public static AllInOneMenuExtensionsInterface getAllInOneMenuExtensions() { - if (sAllInOneMenuExtensions == null) { - String className = sProperties.getProperty(ALL_IN_ONE_MENU_KEY); - if (className != null) { - sAllInOneMenuExtensions = createInstance(className); - } else { - Log.d(TAG, ALL_IN_ONE_MENU_KEY + " not found in properties file."); - } - - if (sAllInOneMenuExtensions == null) { - sAllInOneMenuExtensions = new AllInOneMenuExtensionsInterface() { - @Override - public Integer getExtensionMenuResource(Menu menu) { - return null; - } - - @Override - public boolean handleItemSelected(MenuItem item, Context context) { - return false; - } - }; - } + if ((sAllInOneMenuExtensions != null)) { + return sAllInOneMenuExtensions; + } + + String className = sProperties.getProperty(ALL_IN_ONE_MENU_KEY); + if (className != null) { + sAllInOneMenuExtensions = createInstance(className); + } else { + Log.d(TAG, ALL_IN_ONE_MENU_KEY + " not found in properties file."); } + if (sAllInOneMenuExtensions == null) { + sAllInOneMenuExtensions = new AllInOneMenuExtensionsInterface() { + @Override + public Integer getExtensionMenuResource(Menu menu) { + return null; + } + + @Override + public boolean handleItemSelected(MenuItem item, Context context) { + return false; + } + }; + } return sAllInOneMenuExtensions; } @@ -134,4 +137,33 @@ public class ExtensionsFactory { return cnb; } + + public static AnalyticsLogger getAnalyticsLogger(Context context) { + if (sAnalyticsLogger != null) { + return sAnalyticsLogger; + } + + String className = sProperties.getProperty(ANALYTICS_LOGGER_KEY); + if (className != null) { + sAnalyticsLogger = createInstance(className); + } else { + Log.d(TAG, ANALYTICS_LOGGER_KEY + " not found in properties file."); + } + + if (sAnalyticsLogger == null) { + sAnalyticsLogger = new AnalyticsLogger() { + @Override + public boolean initialize(Context context) { + return true; + } + + @Override + public void trackView(String name) { + } + }; + } + + sAnalyticsLogger.initialize(context); + return sAnalyticsLogger; + } } |