Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 99bb396d authored by Paul Sliwowski's avatar Paul Sliwowski Committed by Android Git Automerger
Browse files

am 373e9dab: Add analytics tracking to calendar app.

* commit '373e9dab':
  Add analytics tracking to calendar app.
parents 91a3550e 373e9dab
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -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;
        }

+24 −0
Original line number Diff line number Diff line
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);
}
+53 −21
Original line number Diff line number Diff line
@@ -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,7 +76,10 @@ public class ExtensionsFactory {
    }

    public static AllInOneMenuExtensionsInterface getAllInOneMenuExtensions() {
        if (sAllInOneMenuExtensions == null) {
        if ((sAllInOneMenuExtensions != null)) {
            return sAllInOneMenuExtensions;
        }

        String className = sProperties.getProperty(ALL_IN_ONE_MENU_KEY);
        if (className != null) {
            sAllInOneMenuExtensions = createInstance(className);
@@ -95,8 +100,6 @@ public class ExtensionsFactory {
                }
            };
        }
        }

        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;
    }
}