forked from organicmaps/organicmaps
[android] Added onboarding/deeplink statistic
This commit is contained in:
parent
14c2d083e2
commit
54932ed487
4 changed files with 70 additions and 15 deletions
|
@ -1,6 +1,7 @@
|
|||
package com.mapswithme.maps.news;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
|
@ -11,6 +12,7 @@ import android.widget.TextView;
|
|||
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.base.BaseMwmDialogFragment;
|
||||
import com.mapswithme.util.statistics.Statistics;
|
||||
|
||||
public class IntroductionDialogFragment extends BaseMwmDialogFragment
|
||||
{
|
||||
|
@ -26,6 +28,9 @@ public class IntroductionDialogFragment extends BaseMwmDialogFragment
|
|||
final IntroductionDialogFragment fragment = new IntroductionDialogFragment();
|
||||
fragment.setArguments(args);
|
||||
fragment.show(fm, IntroductionDialogFragment.class.getName());
|
||||
Statistics.INSTANCE.trackEvent(Statistics.EventName.ONBOARDING_DEEPLINK_SCREEN_SHOW,
|
||||
Statistics.params().add(Statistics.EventParam.TYPE,
|
||||
factory.getStatisticalName()));
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
@ -36,28 +41,50 @@ public class IntroductionDialogFragment extends BaseMwmDialogFragment
|
|||
|
||||
View content = View.inflate(getActivity(), R.layout.fragment_welcome, null);
|
||||
res.setContentView(content);
|
||||
Bundle args = getArgumentsOrThrow();
|
||||
int dataIndex = args.getInt(ARG_INTRODUCTION_FACTORY);
|
||||
IntroductionScreenFactory data = IntroductionScreenFactory.values()[dataIndex];
|
||||
IntroductionScreenFactory factory = getScreenFactory();
|
||||
TextView button = content.findViewById(R.id.btn__continue);
|
||||
button.setText(data.getAction());
|
||||
button.setOnClickListener(v -> {
|
||||
String deepLink = args.getString(ARG_DEEPLINK);
|
||||
if (TextUtils.isEmpty(deepLink))
|
||||
throw new AssertionError("Deeplink must non-empty within introduction fragment!");
|
||||
data.createButtonClickListener().onIntroductionButtonClick(requireActivity(), deepLink);
|
||||
dismissAllowingStateLoss();
|
||||
});
|
||||
button.setText(factory.getAction());
|
||||
button.setOnClickListener(v -> onAcceptClicked());
|
||||
ImageView image = content.findViewById(R.id.iv__image);
|
||||
image.setImageResource(data.getImage());
|
||||
image.setImageResource(factory.getImage());
|
||||
TextView title = content.findViewById(R.id.tv__title);
|
||||
title.setText(data.getTitle());
|
||||
title.setText(factory.getTitle());
|
||||
TextView subtitle = content.findViewById(R.id.tv__subtitle1);
|
||||
subtitle.setText(data.getSubtitle());
|
||||
subtitle.setText(factory.getSubtitle());
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private IntroductionScreenFactory getScreenFactory()
|
||||
{
|
||||
Bundle args = getArgumentsOrThrow();
|
||||
int dataIndex = args.getInt(ARG_INTRODUCTION_FACTORY);
|
||||
return IntroductionScreenFactory.values()[dataIndex];
|
||||
}
|
||||
|
||||
private void onAcceptClicked()
|
||||
{
|
||||
String deepLink = getArgumentsOrThrow().getString(ARG_DEEPLINK);
|
||||
if (TextUtils.isEmpty(deepLink))
|
||||
throw new AssertionError("Deeplink must non-empty within introduction fragment!");
|
||||
IntroductionScreenFactory factory = getScreenFactory();
|
||||
factory.createButtonClickListener().onIntroductionButtonClick(requireActivity(), deepLink);
|
||||
Statistics.INSTANCE.trackEvent(Statistics.EventName.ONBOARDING_DEEPLINK_SCREEN_ACCEPT,
|
||||
Statistics.params().add(Statistics.EventParam.TYPE,
|
||||
factory.getStatisticalName()));
|
||||
dismissAllowingStateLoss();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
super.onCancel(dialog);
|
||||
Statistics.INSTANCE.trackEvent(Statistics.EventName.ONBOARDING_DEEPLINK_SCREEN_DECLINE,
|
||||
Statistics.params().add(Statistics.EventParam.TYPE,
|
||||
getScreenFactory().getStatisticalName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getCustomTheme()
|
||||
{
|
||||
|
|
|
@ -9,11 +9,19 @@ import com.mapswithme.maps.R;
|
|||
import com.mapswithme.maps.bookmarks.BookmarkCategoriesActivity;
|
||||
import com.mapswithme.maps.bookmarks.BookmarksCatalogActivity;
|
||||
import com.mapswithme.maps.bookmarks.BookmarksPageFactory;
|
||||
import com.mapswithme.util.statistics.StatisticalNameProvider;
|
||||
|
||||
public enum IntroductionScreenFactory
|
||||
public enum IntroductionScreenFactory implements StatisticalNameProvider
|
||||
{
|
||||
FREE_GUIDE
|
||||
{
|
||||
@NonNull
|
||||
@Override
|
||||
public String getStatisticalName()
|
||||
{
|
||||
return "catalogue";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTitle()
|
||||
{
|
||||
|
@ -56,6 +64,13 @@ public enum IntroductionScreenFactory
|
|||
},
|
||||
GUIDES_PAGE
|
||||
{
|
||||
@NonNull
|
||||
@Override
|
||||
public String getStatisticalName()
|
||||
{
|
||||
return "guides_page";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTitle()
|
||||
{
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
package com.mapswithme.util.statistics;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
public interface StatisticalNameProvider
|
||||
{
|
||||
@NonNull
|
||||
public String getStatisticalName();
|
||||
}
|
|
@ -438,6 +438,10 @@ public enum Statistics
|
|||
static final String INAPP_PURCHASE_VALIDATION_ERROR = "InAppPurchase_Validation_error";
|
||||
static final String INAPP_PURCHASE_PRODUCT_DELIVERED = "InAppPurchase_Product_delivered";
|
||||
|
||||
public static final String ONBOARDING_DEEPLINK_SCREEN_SHOW = "OnboardingDeeplinkScreen_show";
|
||||
public static final String ONBOARDING_DEEPLINK_SCREEN_ACCEPT = "OnboardingDeeplinkScreen_accept";
|
||||
public static final String ONBOARDING_DEEPLINK_SCREEN_DECLINE = "OnboardingDeeplinkScreen_decline";
|
||||
|
||||
public static class Settings
|
||||
{
|
||||
public static final String WEB_SITE = "Setings. Go to website";
|
||||
|
|
Loading…
Add table
Reference in a new issue