diff options
author | Yorke Lee <yorkelee@google.com> | 2015-11-06 21:43:29 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2015-11-06 21:43:29 +0000 |
commit | df473ed12a747ed50e106dc065e2703748828b2d (patch) | |
tree | 3764020c66555b384dc664ed76a3e3914aba7d4c | |
parent | 6646ea2cda1bc56bf5b3980aaaf5ed62c5a01283 (diff) | |
parent | 6e0fd6b77759baf43cb37d407041be051b4856b5 (diff) |
Route all existing screen view events through the Logger
am: 6e0fd6b777
* commit '6e0fd6b77759baf43cb37d407041be051b4856b5':
Route all existing screen view events through the Logger
-rw-r--r-- | src/com/android/dialer/DialtactsActivity.java | 7 | ||||
-rw-r--r-- | src/com/android/dialer/calllog/CallLogActivity.java | 3 | ||||
-rw-r--r-- | src/com/android/dialer/list/ListsFragment.java | 10 | ||||
-rw-r--r-- | src/com/android/dialer/list/RegularSearchFragment.java | 3 | ||||
-rw-r--r-- | src/com/android/dialer/logging/Logger.java | 51 |
5 files changed, 60 insertions, 14 deletions
diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java index 84100b78f..b4dd6c9c8 100644 --- a/src/com/android/dialer/DialtactsActivity.java +++ b/src/com/android/dialer/DialtactsActivity.java @@ -81,6 +81,7 @@ import com.android.dialer.list.RegularSearchFragment; import com.android.dialer.list.SearchFragment; import com.android.dialer.list.SmartDialSearchFragment; import com.android.dialer.list.SpeedDialFragment; +import com.android.dialer.logging.Logger; import com.android.dialer.settings.DialerSettingsActivity; import com.android.dialer.util.DialerUtils; import com.android.dialer.util.IntentUtil; @@ -526,7 +527,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O // This is only called when the activity goes from resumed -> paused -> resumed, so it // will not cause an extra view to be sent out on rotation if (mIsDialpadShown) { - AnalyticsUtil.sendScreenView(mDialpadFragment, this); + Logger.logFragmentView(mDialpadFragment); } mIsRestarting = false; } @@ -741,7 +742,9 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O } mDialpadFragment.setAnimate(animate); - AnalyticsUtil.sendScreenView(mDialpadFragment); + // logScreenView is used here explicitly to provide the activity as the DialpadFragment + // might not have been attached yet. + Logger.logScreenView(DialpadFragment.class.getSimpleName(), this, null); ft.commit(); if (animate) { diff --git a/src/com/android/dialer/calllog/CallLogActivity.java b/src/com/android/dialer/calllog/CallLogActivity.java index c1923b2e4..f6defcfd9 100644 --- a/src/com/android/dialer/calllog/CallLogActivity.java +++ b/src/com/android/dialer/calllog/CallLogActivity.java @@ -40,6 +40,7 @@ import com.android.contacts.commonbind.analytics.AnalyticsUtil; import com.android.dialer.DialtactsActivity; import com.android.dialer.R; import com.android.dialer.TransactionSafeActivity; +import com.android.dialer.logging.Logger; import com.android.dialer.util.DialerUtils; public class CallLogActivity extends TransactionSafeActivity implements ViewPager.OnPageChangeListener { @@ -222,7 +223,7 @@ public class CallLogActivity extends TransactionSafeActivity implements ViewPage } private void sendScreenViewForChildFragment(int position) { - AnalyticsUtil.sendScreenView(CallLogFragment.class.getSimpleName(), this, + Logger.logScreenView(CallLogFragment.class.getSimpleName(), this, getFragmentTagForPosition(position)); } diff --git a/src/com/android/dialer/list/ListsFragment.java b/src/com/android/dialer/list/ListsFragment.java index 934792cdd..08a23732f 100644 --- a/src/com/android/dialer/list/ListsFragment.java +++ b/src/com/android/dialer/list/ListsFragment.java @@ -45,6 +45,7 @@ import com.android.dialer.R; import com.android.dialer.calllog.CallLogFragment; import com.android.dialer.calllog.CallLogQueryHandler; import com.android.dialer.calllog.ContactInfoHelper; +import com.android.dialer.logging.Logger; import com.android.dialer.util.DialerUtils; import com.android.dialer.voicemail.VoicemailStatusHelper; import com.android.dialer.voicemail.VoicemailStatusHelperImpl; @@ -403,21 +404,24 @@ public class ListsFragment extends Fragment } String fragmentName; + String tag = null; switch (getCurrentTabIndex()) { case TAB_INDEX_SPEED_DIAL: fragmentName = SpeedDialFragment.class.getSimpleName(); break; case TAB_INDEX_HISTORY: - fragmentName = CallLogFragment.class.getSimpleName() + "#History"; + fragmentName = CallLogFragment.class.getSimpleName(); + tag = "History"; break; case TAB_INDEX_ALL_CONTACTS: fragmentName = AllContactsFragment.class.getSimpleName(); break; case TAB_INDEX_VOICEMAIL: - fragmentName = CallLogFragment.class.getSimpleName() + "#Voicemail"; + fragmentName = CallLogFragment.class.getSimpleName(); + tag = "Voicemail"; default: return; } - AnalyticsUtil.sendScreenView(fragmentName, getActivity(), null); + Logger.logScreenView(fragmentName, getActivity(), tag); } } diff --git a/src/com/android/dialer/list/RegularSearchFragment.java b/src/com/android/dialer/list/RegularSearchFragment.java index ed88d8355..c0807c35c 100644 --- a/src/com/android/dialer/list/RegularSearchFragment.java +++ b/src/com/android/dialer/list/RegularSearchFragment.java @@ -30,6 +30,7 @@ import com.android.dialerbind.ObjectFactory; import com.android.incallui.Call.LogState; import com.android.dialer.R; +import com.android.dialer.logging.Logger; import com.android.dialer.service.CachedNumberLookupService; import com.android.dialer.widget.EmptyContentView; import com.android.dialer.widget.EmptyContentView.OnEmptyViewActionButtonClickedListener; @@ -57,7 +58,7 @@ public class RegularSearchFragment extends SearchFragment @Override public void onStart() { super.onStart(); - AnalyticsUtil.sendScreenView(this); + Logger.logFragmentView(this); } public void configureDirectorySearch() { diff --git a/src/com/android/dialer/logging/Logger.java b/src/com/android/dialer/logging/Logger.java index 300707779..ee23dc8e7 100644 --- a/src/com/android/dialer/logging/Logger.java +++ b/src/com/android/dialer/logging/Logger.java @@ -17,11 +17,18 @@ package com.android.dialer.logging; import android.app.Activity; +import android.app.Fragment; +import android.text.TextUtils; +import com.android.contacts.commonbind.analytics.AnalyticsUtil; import com.android.dialerbind.ObjectFactory; import com.android.incallui.Call; +/** + * Single entry point for all logging/analytics-related work for all user interactions. + */ public abstract class Logger { + public static final String FRAGMENT_TAG_SEPARATOR = "#"; public static Logger getInstance() { return ObjectFactory.getLoggerInstance(); @@ -40,19 +47,49 @@ public abstract class Logger { } /** - * Logs an event indicating that a screen/fragment was displayed. + * Logs an event indicating that a fragment was displayed. + * + * @param fragment to log an event for. + */ + public static void logFragmentView(Fragment fragment) { + if (fragment == null) { + return; + } + + logScreenView(fragment.getClass().getSimpleName(), fragment.getActivity(), null); + } + + /** + * Logs an event indicating that a screen was displayed. * - * @param fragmentName of the displayed fragment. - * @param activity Parent activity of the fragment. - * @param tag Optional string used to provide additional information about the fragment. + * @param screenName of the displayed screen. + * @param activity Parent activity of the displayed screen. + * @param tag Optional string used to provide additional information about the screen. */ - public static void logScreenView(String fragmentName, Activity activity, String tag) { + public static void logScreenView(String screenName, Activity activity, String tag) { final Logger logger = getInstance(); if (logger != null) { - logger.logScreenViewImpl(fragmentName, activity, tag); + logger.logScreenViewImpl(getScreenNameWithTag(screenName, tag)); + } + + AnalyticsUtil.sendScreenView(screenName, activity, tag); + } + + /** + * Build a tagged version of the provided screenName if the tag is non-empty. + * + * @param screenName Name of the screen. + * @param tag Optional tag describing the screen. + * @return the unchanged screenName if the tag is {@code null} or empty, the tagged version of + * the screenName otherwise. + */ + public static String getScreenNameWithTag(String screenName, String tag) { + if (TextUtils.isEmpty(tag)) { + return screenName; } + return screenName + FRAGMENT_TAG_SEPARATOR + tag; } public abstract void logCallImpl(Call call); - public abstract void logScreenViewImpl(String fragmentName, Activity activity, String tag); + public abstract void logScreenViewImpl(String screenName); } |