[new downloader][android] add: Send statistics after the first start screen.

This commit is contained in:
Alexander Marchuk 2016-03-11 18:05:42 +03:00 committed by Sergey Yershov
parent add83e30e8
commit ebb7fa2c7f
4 changed files with 84 additions and 0 deletions

View file

@ -38,6 +38,7 @@ public enum LocationHelper implements SensorEventListener
public static final int ERROR_NOT_SUPPORTED = 1;
public static final int ERROR_DENIED = 2;
public static final int ERROR_GPS_OFF = 3;
public static final int ERROR_UNKNOWN = 0;
public static final String LOCATION_PREDICTOR_PROVIDER = "LocationPredictorProvider";
private static final float DISTANCE_TO_RECREATE_MAGNETIC_FIELD_M = 1000;

View file

@ -137,6 +137,8 @@ abstract class BaseNewsFragment extends BaseMwmDialogFragment
void onSwitchChanged(int index, boolean isChecked) {}
void onClosed() {}
private void update()
{
int cur = mPager.getCurrentItem();
@ -253,6 +255,7 @@ abstract class BaseNewsFragment extends BaseMwmDialogFragment
@Override
public void onClick(View v)
{
onClosed();
dismiss();
}
});

View file

@ -1,14 +1,41 @@
package com.mapswithme.maps.news;
import android.app.Dialog;
import android.content.DialogInterface;
import android.location.Location;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import com.mapswithme.maps.BuildConfig;
import com.mapswithme.maps.R;
import com.mapswithme.maps.location.LocationHelper;
import com.mapswithme.util.Config;
import com.mapswithme.util.statistics.Statistics;
public class FirstStartFragment extends BaseNewsFragment
{
private static Location sLocation;
private static int sError = LocationHelper.ERROR_UNKNOWN;
private final LocationHelper.LocationListener mLocationListener = new LocationHelper.SimpleLocationListener()
{
@Override
public void onLocationUpdated(Location loc)
{
sLocation = loc;
sError = LocationHelper.ERROR_UNKNOWN;
}
@Override
public void onLocationError(int errorCode)
{
sLocation = null;
sError = errorCode;
}
};
private class Adapter extends BaseNewsFragment.Adapter
{
@Override
@ -48,6 +75,51 @@ public class FirstStartFragment extends BaseNewsFragment
return new Adapter();
}
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState)
{
LocationHelper.INSTANCE.addLocationListener(mLocationListener, true);
return super.onCreateDialog(savedInstanceState);
}
@Override
public void onDismiss(DialogInterface dialog)
{
super.onDismiss(dialog);
LocationHelper.INSTANCE.removeLocationListener(mLocationListener);
}
@Override
void onClosed()
{
if (sLocation == null)
{
String reason;
switch (sError)
{
case LocationHelper.ERROR_GPS_OFF:
reason = "unavailable";
break;
case LocationHelper.ERROR_DENIED:
reason = "not_permitted";
break;
default:
Statistics.INSTANCE.trackEvent(Statistics.EventName.FIRST_START_DONT_ZOOM);
return;
}
Statistics.INSTANCE.trackEvent(Statistics.EventName.FIRST_START_NO_LOCATION, Statistics.params().add("reason", reason));
return;
}
// TODO (trashkalmar): Zoom to location
sLocation = null;
}
public static boolean showOn(FragmentActivity activity)
{
if (Config.getFirstInstallVersion() < BuildConfig.VERSION_CODE)
@ -64,6 +136,8 @@ public class FirstStartFragment extends BaseNewsFragment
create(activity, FirstStartFragment.class);
Config.setFirstStartDialogSeen();
Statistics.INSTANCE.trackEvent(Statistics.EventName.FIRST_START_SHOWN);
return true;
}
}

View file

@ -42,6 +42,12 @@ public enum Statistics
public static final String DOWNLOADER_ERROR = "Downloader_Map_error";
public static final String DOWNLOADER_ACTION = "Downloader_Map_action";
public static final String DOWNLOADER_CANCEL = "Downloader_Cancel_downloading";
// First start
public static final String FIRST_START_SHOWN = "FirstStart_Dialog_show";
public static final String FIRST_START_NO_LOCATION = "FirstStart_Location_disable";
public static final String FIRST_START_DONT_ZOOM = "FirstStart_ZAnimation_disable";
// bookmarks
public static final String BMK_DESCRIPTION_CHANGED = "Bookmark. Description changed";
public static final String BMK_GROUP_CREATED = "Bookmark. Group created";