summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYorke Lee <yorkelee@google.com>2014-11-06 18:42:04 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-11-06 18:42:05 +0000
commitb48f64c8dc3a7b17801222fe3be2c584054dcb66 (patch)
treee6461c0438b3051debc5bd73aa6244cbfaaa129b /src
parent29c37072dc82aee4cc2bf3da9c0c972c776d8b49 (diff)
parent7ee5c422e36cf3d40cbd24bbb5b87754b4820d02 (diff)
Merge "Improve Dialer analytics" into lmp-mr1-dev
Diffstat (limited to 'src')
-rw-r--r--src/com/android/dialer/DialtactsActivity.java28
-rw-r--r--src/com/android/dialer/calllog/CallLogActivity.java46
-rw-r--r--src/com/android/dialer/list/ListsFragment.java41
-rw-r--r--src/com/android/dialer/list/RegularSearchFragment.java7
-rw-r--r--src/com/android/dialer/list/SearchFragment.java1
-rw-r--r--src/com/android/dialer/voicemail/VoicemailPlaybackFragment.java8
6 files changed, 116 insertions, 15 deletions
diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java
index 5e20793b5..4b5b198a0 100644
--- a/src/com/android/dialer/DialtactsActivity.java
+++ b/src/com/android/dialer/DialtactsActivity.java
@@ -182,6 +182,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
* be commited.
*/
private boolean mStateSaved;
+ private boolean mIsRestarting;
private boolean mInDialpadSearch;
private boolean mInRegularSearch;
private boolean mClearSearchOnPause;
@@ -477,12 +478,27 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
mShowDialpadOnResume = false;
}
mFirstLaunch = false;
+
+ if (mIsRestarting) {
+ // 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);
+ }
+ mIsRestarting = false;
+ }
prepareVoiceSearchButton();
mDialerDatabaseHelper.startSmartDialUpdateThread();
updateFloatingActionButtonControllerAlignment(false /* animate */);
}
@Override
+ protected void onRestart() {
+ super.onRestart();
+ mIsRestarting = true;
+ }
+
+ @Override
protected void onPause() {
if (mClearSearchOnPause) {
hideDialpadAndSearchUi();
@@ -624,6 +640,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
}
mIsDialpadShown = true;
mDialpadFragment.setAnimate(animate);
+ mListsFragment.setUserVisibleHint(false);
AnalyticsUtil.sendScreenView(mDialpadFragment);
final FragmentTransaction ft = getFragmentManager().beginTransaction();
@@ -672,6 +689,8 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
}
mIsDialpadShown = false;
mDialpadFragment.setAnimate(animate);
+ mListsFragment.setUserVisibleHint(true);
+ mListsFragment.sendScreenViewForCurrentPosition();
updateSearchFragmentPosition();
@@ -899,6 +918,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
transaction.commit();
mListsFragment.getView().animate().alpha(0).withLayer();
+ mListsFragment.setUserVisibleHint(false);
}
/**
@@ -924,6 +944,14 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
transaction.commit();
mListsFragment.getView().animate().alpha(1).withLayer();
+ if (!mDialpadFragment.isVisible()) {
+ // If the dialpad fragment wasn't previously visible, then send a screen view because
+ // we are exiting regular search. Otherwise, the screen view will be sent by
+ // {@link #hideDialpadFragment}.
+ mListsFragment.sendScreenViewForCurrentPosition();
+ mListsFragment.setUserVisibleHint(true);
+ }
+
mActionBarController.onSearchUiExited();
}
diff --git a/src/com/android/dialer/calllog/CallLogActivity.java b/src/com/android/dialer/calllog/CallLogActivity.java
index c7862aee6..1131b0ee8 100644
--- a/src/com/android/dialer/calllog/CallLogActivity.java
+++ b/src/com/android/dialer/calllog/CallLogActivity.java
@@ -34,12 +34,14 @@ import android.view.MotionEvent;
import com.android.contacts.common.interactions.TouchPointManager;
import com.android.contacts.common.list.ViewPagerTabs;
+import com.android.contacts.commonbind.analytics.AnalyticsUtil;
import com.android.dialer.DialtactsActivity;
import com.android.dialer.R;
import com.android.dialer.voicemail.VoicemailStatusHelper;
import com.android.dialer.voicemail.VoicemailStatusHelperImpl;
-public class CallLogActivity extends Activity implements CallLogQueryHandler.Listener {
+public class CallLogActivity extends Activity implements CallLogQueryHandler.Listener,
+ ViewPager.OnPageChangeListener {
private Handler mHandler;
private ViewPager mViewPager;
private ViewPagerTabs mViewPagerTabs;
@@ -149,9 +151,9 @@ public class CallLogActivity extends Activity implements CallLogQueryHandler.Lis
mViewPagerAdapter = new ViewPagerAdapter(getFragmentManager());
mViewPager.setAdapter(mViewPagerAdapter);
mViewPager.setOffscreenPageLimit(2);
+ mViewPager.setOnPageChangeListener(this);
mViewPagerTabs = (ViewPagerTabs) findViewById(R.id.viewpager_header);
- mViewPager.setOnPageChangeListener(mViewPagerTabs);
if (startingTab == TAB_INDEX_VOICEMAIL) {
// The addition of the voicemail tab is an asynchronous process, so wait till the tab
@@ -174,6 +176,7 @@ public class CallLogActivity extends Activity implements CallLogQueryHandler.Lis
CallLogQueryHandler callLogQueryHandler =
new CallLogQueryHandler(this.getContentResolver(), this);
callLogQueryHandler.fetchVoicemailStatus();
+ sendScreenViewForChildFragment(mViewPager.getCurrentItem());
}
@Override
@@ -238,4 +241,43 @@ public class CallLogActivity extends Activity implements CallLogQueryHandler.Lis
// Return false; did not take ownership of cursor
return false;
}
+
+ @Override
+ public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
+ mViewPagerTabs.onPageScrolled(position, positionOffset, positionOffsetPixels);
+ }
+
+ @Override
+ public void onPageSelected(int position) {
+ if (isResumed()) {
+ sendScreenViewForChildFragment(position);
+ }
+ mViewPagerTabs.onPageSelected(position);
+ }
+
+ @Override
+ public void onPageScrollStateChanged(int state) {
+ mViewPagerTabs.onPageScrollStateChanged(state);
+ }
+
+ private void sendScreenViewForChildFragment(int position) {
+ AnalyticsUtil.sendScreenView(CallLogFragment.class.getSimpleName(), this,
+ getFragmentTagForPosition(position));
+ }
+
+ /**
+ * Returns the fragment located at the given position in the {@link ViewPagerAdapter}. May
+ * be null if the position is invalid.
+ */
+ private String getFragmentTagForPosition(int position) {
+ switch (position) {
+ case TAB_INDEX_ALL:
+ return "All";
+ case TAB_INDEX_MISSED:
+ return "Missed";
+ case TAB_INDEX_VOICEMAIL:
+ return "Voicemail";
+ }
+ return null;
+ }
}
diff --git a/src/com/android/dialer/list/ListsFragment.java b/src/com/android/dialer/list/ListsFragment.java
index 916c0346b..408d5b1f1 100644
--- a/src/com/android/dialer/list/ListsFragment.java
+++ b/src/com/android/dialer/list/ListsFragment.java
@@ -248,11 +248,6 @@ public class ListsFragment extends Fragment implements CallLogQueryHandler.Liste
}
@Override
- public void onStart() {
- super.onStart();
- }
-
- @Override
public void onResume() {
super.onResume();
final SharedPreferences prefs = getActivity().getSharedPreferences(
@@ -261,6 +256,9 @@ public class ListsFragment extends Fragment implements CallLogQueryHandler.Liste
mActionBar = getActivity().getActionBar();
fetchCalls();
mCallLogAdapter.setLoading(true);
+ if (getUserVisibleHint()) {
+ sendScreenViewForPosition(mViewPager.getCurrentItem());
+ }
}
@Override
@@ -359,17 +357,11 @@ public class ListsFragment extends Fragment implements CallLogQueryHandler.Liste
@Override
public void onPageSelected(int position) {
- if (position == TAB_INDEX_SPEED_DIAL && mSpeedDialFragment != null) {
- AnalyticsUtil.sendScreenView(mSpeedDialFragment);
- } else if (position == TAB_INDEX_RECENTS && mRecentsFragment != null) {
- AnalyticsUtil.sendScreenView(mRecentsFragment);
- } else if (position == TAB_INDEX_ALL_CONTACTS && mAllContactsFragment != null) {
- AnalyticsUtil.sendScreenView(mAllContactsFragment);
- }
final int count = mOnPageChangeListeners.size();
for (int i = 0; i < count; i++) {
mOnPageChangeListeners.get(i).onPageSelected(position);
}
+ sendScreenViewForPosition(position);
}
@Override
@@ -430,4 +422,29 @@ public class ListsFragment extends Fragment implements CallLogQueryHandler.Liste
}
return position;
}
+
+ public void sendScreenViewForCurrentPosition() {
+ sendScreenViewForPosition(mViewPager.getCurrentItem());
+ }
+
+ private void sendScreenViewForPosition(int position) {
+ if (!isResumed()) {
+ return;
+ }
+ String fragmentName;
+ switch (getRtlPosition(position)) {
+ case TAB_INDEX_SPEED_DIAL:
+ fragmentName = SpeedDialFragment.class.getSimpleName();
+ break;
+ case TAB_INDEX_RECENTS:
+ fragmentName = CallLogFragment.class.getSimpleName();
+ break;
+ case TAB_INDEX_ALL_CONTACTS:
+ fragmentName = AllContactsFragment.class.getSimpleName();
+ break;
+ default:
+ return;
+ }
+ AnalyticsUtil.sendScreenView(fragmentName, getActivity(), null);
+ }
}
diff --git a/src/com/android/dialer/list/RegularSearchFragment.java b/src/com/android/dialer/list/RegularSearchFragment.java
index 9f4e6bec9..19c7321a1 100644
--- a/src/com/android/dialer/list/RegularSearchFragment.java
+++ b/src/com/android/dialer/list/RegularSearchFragment.java
@@ -20,6 +20,7 @@ import android.view.ViewGroup;
import com.android.contacts.common.list.ContactEntryListAdapter;
import com.android.contacts.common.list.PinnedHeaderListView;
+import com.android.contacts.commonbind.analytics.AnalyticsUtil;
import com.android.dialerbind.ObjectFactory;
import com.android.dialer.service.CachedNumberLookupService;
@@ -34,6 +35,12 @@ public class RegularSearchFragment extends SearchFragment {
configureDirectorySearch();
}
+ @Override
+ public void onStart() {
+ super.onStart();
+ AnalyticsUtil.sendScreenView(this);
+ }
+
public void configureDirectorySearch() {
setDirectorySearchEnabled(true);
setDirectoryResultLimit(SEARCH_DIRECTORY_RESULT_LIMIT);
diff --git a/src/com/android/dialer/list/SearchFragment.java b/src/com/android/dialer/list/SearchFragment.java
index c655bbe5f..e50d0d89e 100644
--- a/src/com/android/dialer/list/SearchFragment.java
+++ b/src/com/android/dialer/list/SearchFragment.java
@@ -70,7 +70,6 @@ public class SearchFragment extends PhoneNumberPickerFragment {
setDarkTheme(false);
setPhotoPosition(ContactListItemView.getDefaultPhotoPosition(false /* opposite */));
setUseCallableUri(true);
- AnalyticsUtil.sendScreenView(this);
try {
mActivityScrollListener = (OnListFragmentScrolledListener) activity;
diff --git a/src/com/android/dialer/voicemail/VoicemailPlaybackFragment.java b/src/com/android/dialer/voicemail/VoicemailPlaybackFragment.java
index 51c15f497..31db17720 100644
--- a/src/com/android/dialer/voicemail/VoicemailPlaybackFragment.java
+++ b/src/com/android/dialer/voicemail/VoicemailPlaybackFragment.java
@@ -40,11 +40,13 @@ import android.widget.SeekBar;
import android.widget.TextView;
import com.android.common.io.MoreCloseables;
+import com.android.contacts.commonbind.analytics.AnalyticsUtil;
import com.android.dialer.ProximitySensorAware;
import com.android.dialer.R;
import com.android.dialer.util.AsyncTaskExecutors;
import com.android.ex.variablespeed.MediaPlayerProxy;
import com.android.ex.variablespeed.VariableSpeed;
+
import com.google.common.base.Preconditions;
import java.util.concurrent.Executors;
@@ -112,6 +114,12 @@ public class VoicemailPlaybackFragment extends Fragment {
}
@Override
+ public void onStart() {
+ super.onStart();
+ AnalyticsUtil.sendScreenView(this);
+ }
+
+ @Override
public void onDestroy() {
shutdownMediaPlayer();
mPresenter.onDestroy();