import android.app.settings.SettingsEnums;
import android.content.Context;
import android.os.Bundle;
+import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
private PanelContent mPanel;
private MetricsFeatureProvider mMetricsProvider;
+ private String mPanelClosedKey;
@VisibleForTesting
PanelSlicesAdapter mAdapter;
return view;
}
+ @Override
+ public void onDestroyView() {
+ super.onDestroyView();
+
+ if (TextUtils.isEmpty(mPanelClosedKey)) {
+ mPanelClosedKey = PanelClosedKeys.KEY_OTHERS;
+ }
+
+ mMetricsProvider.action(
+ 0 /* attribution */,
+ SettingsEnums.PAGE_HIDE,
+ mPanel.getMetricsCategory(),
+ mPanelClosedKey,
+ 0 /* value */);
+ }
+
@VisibleForTesting
View.OnClickListener getSeeMoreListener() {
return (v) -> {
- mMetricsProvider.action(
- 0 /* attribution */,
- SettingsEnums.PAGE_HIDE ,
- mPanel.getMetricsCategory(),
- PanelClosedKeys.KEY_SEE_MORE,
- 0 /* value */);
+ mPanelClosedKey = PanelClosedKeys.KEY_SEE_MORE;
final FragmentActivity activity = getActivity();
activity.startActivityForResult(mPanel.getSeeMoreIntent(), 0);
activity.finish();
@VisibleForTesting
View.OnClickListener getCloseListener() {
return (v) -> {
- mMetricsProvider.action(
- 0 /* attribution */,
- SettingsEnums.PAGE_HIDE,
- mPanel.getMetricsCategory(),
- PanelClosedKeys.KEY_DONE,
- 0 /* value */);
+ mPanelClosedKey = PanelClosedKeys.KEY_DONE;
getActivity().finish();
};
}
fragmentManager.beginTransaction().add(R.id.main_content, panelFragment).commit();
}
}
-
- @Override
- public boolean onTouchEvent(MotionEvent event) {
- if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
- final PanelContent panelContent = FeatureFactory.getFactory(this)
- .getPanelFeatureProvider()
- .getPanel(this, getIntent().getAction(), null /* Media Package Name */);
- FeatureFactory.getFactory(this)
- .getMetricsFeatureProvider()
- .action(0 /* attribution */,
- SettingsEnums.PAGE_HIDE,
- panelContent.getMetricsCategory(),
- PanelClosedKeys.KEY_CLICKED_OUT,
- 0 /* value */);
- }
- return super.onTouchEvent(event);
- }
}
}
@Test
+ public void onDestroy_logCloseEvent() {
+ mPanelFragment.onDestroy();
+ verify(mFakeFeatureFactory.metricsFeatureProvider).action(
+ 0,
+ SettingsEnums.PAGE_VISIBLE,
+ mFakePanelContent.getMetricsCategory(),
+ any(String.class),
+ 0); }
+
+ @Test
public void panelSeeMoreClick_logsCloseEvent() {
final View.OnClickListener listener = mPanelFragment.getSeeMoreListener();