From 86ba541f78a318dfc796dab69ffe9dc903d02ce0 Mon Sep 17 00:00:00 2001 From: Dmitry Yunitsky Date: Mon, 10 Nov 2014 17:14:20 +0300 Subject: [PATCH] Prestigio preinstall statistics. --- android/build.gradle | 23 ++++++++++++++++++- .../country/BaseDownloadAdapter.java | 3 ++- .../com/mapswithme/maps/MWMApplication.java | 22 ++++++++++++++---- .../util/statistics/Statistics.java | 18 +++++++++++++-- 4 files changed, 57 insertions(+), 9 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 40377258b6..366ca12e1d 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -50,13 +50,13 @@ android { } productFlavors { - googlePro { applicationId 'com.mapswithme.maps.pro' buildConfigField 'boolean', 'IS_PRO', 'true' buildConfigField 'String', 'PRO_URL', '"market://details?id=com.mapswithme.maps.pro"' buildConfigField 'String', 'REVIEW_URL', '"market://details?id=com.mapswithme.maps.pro"' buildConfigField 'String', 'SUPPORT_MAIL', '"googleplay@maps.me"' + buildConfigField 'boolean', 'IS_PRESTIGIO_PREINSTALLED', 'false' android.sourceSets.googlePro.setRoot('flavors/pro') android.sourceSets.googlePro.assets.srcDirs = ['flavors/guides-assets'] } @@ -67,6 +67,7 @@ android { buildConfigField 'String', 'PRO_URL', '"market://details?id=com.mapswithme.maps.pro"' buildConfigField 'String', 'REVIEW_URL', '"market://details?id=com.mapswithme.maps"' buildConfigField 'String', 'SUPPORT_MAIL', '"googleplay@maps.me"' + buildConfigField 'boolean', 'IS_PRESTIGIO_PREINSTALLED', 'false' android.sourceSets.googleLite.setRoot('flavors/lite') android.sourceSets.googleLite.assets.srcDirs = ['flavors/guides-assets'] } @@ -77,6 +78,7 @@ android { buildConfigField 'String', 'PRO_URL', '"samsungapps://ProductDetail/com.mapswithme.maps.pro"' buildConfigField 'String', 'REVIEW_URL', '"samsungapps://ProductDetail/com.mapswithme.maps.pro"' buildConfigField 'String', 'SUPPORT_MAIL', '"samsung@maps.me"' + buildConfigField 'boolean', 'IS_PRESTIGIO_PREINSTALLED', 'false' android.sourceSets.samsungPro.setRoot('flavors/pro') android.sourceSets.samsungPro.assets.srcDirs = ['flavors/guides-assets', 'flavors/mwm-ttf-assets'] } @@ -97,6 +99,7 @@ android { buildConfigField 'String', 'PRO_URL', '"amzn://apps/android?p=com.mapswithme.maps.pro"' buildConfigField 'String', 'REVIEW_URL', '"amzn://apps/android?p=com.mapswithme.maps.pro"' buildConfigField 'String', 'SUPPORT_MAIL', '"amazon@maps.me"' + buildConfigField 'boolean', 'IS_PRESTIGIO_PREINSTALLED', 'false' android.sourceSets.amazonPro.setRoot('flavors/pro') // Do not include guides assets for Amazon, they don't like GP apps ads android.sourceSets.amazonPro.assets.srcDirs = ['flavors/mwm-ttf-assets'] @@ -108,6 +111,7 @@ android { buildConfigField 'String', 'PRO_URL', '"amzn://apps/android?p=com.mapswithme.maps.pro"' buildConfigField 'String', 'REVIEW_URL', '"amzn://apps/android?p=com.mapswithme.maps"' buildConfigField 'String', 'SUPPORT_MAIL', '"amazon@maps.me"' + buildConfigField 'boolean', 'IS_PRESTIGIO_PREINSTALLED', 'false' android.sourceSets.amazonLite.setRoot('flavors/lite') // Do not include guides assets for Amazon, they don't like GP apps ads android.sourceSets.amazonLite.assets.srcDirs = ['flavors/mwm-ttf-assets'] @@ -129,6 +133,7 @@ android { buildConfigField 'String', 'PRO_URL', '"appcenter://package/com.mapswithme.maps.pro"' buildConfigField 'String', 'REVIEW_URL', '"appcenter://package/com.mapswithme.maps"' buildConfigField 'String', 'SUPPORT_MAIL', '"android@maps.me"' + buildConfigField 'boolean', 'IS_PRESTIGIO_PREINSTALLED', 'false' android.sourceSets.androidpitLite.setRoot('flavors/lite') android.sourceSets.androidpitLite.assets.srcDirs = ['flavors/guides-assets', 'flavors/mwm-ttf-assets'] } @@ -139,6 +144,7 @@ android { buildConfigField 'String', 'PRO_URL', '"sam://details?bundleId=5eed1b74-8c8b-11e2-8af8-1670ef61174f"' buildConfigField 'String', 'REVIEW_URL', '"sam://details?bundleId=5eed1b74-8c8b-11e2-8af8-1670ef61174f"' buildConfigField 'String', 'SUPPORT_MAIL', '"android@maps.me"' + buildConfigField 'boolean', 'IS_PRESTIGIO_PREINSTALLED', 'false' android.sourceSets.slidemePro.setRoot('flavors/pro') android.sourceSets.slidemePro.assets.srcDirs = ['flavors/guides-assets', 'flavors/mwm-ttf-assets'] } @@ -149,6 +155,7 @@ android { buildConfigField 'String', 'PRO_URL', '"sam://details?bundleId=5eed1b74-8c8b-11e2-8af8-1670ef61174f"' buildConfigField 'String', 'REVIEW_URL', '"sam://details?bundleId=943fe9dc-9799-11e2-8af8-1670ef61174f"' buildConfigField 'String', 'SUPPORT_MAIL', '"android@maps.me"' + buildConfigField 'boolean', 'IS_PRESTIGIO_PREINSTALLED', 'false' android.sourceSets.slidemeLite.setRoot('flavors/lite') android.sourceSets.slidemeLite.assets.srcDirs = ['flavors/guides-assets'] } @@ -159,6 +166,7 @@ android { buildConfigField 'String', 'PRO_URL', '"yastore://details?id=com.mapswithme.maps.pro"' buildConfigField 'String', 'REVIEW_URL', '"yastore://details?id=com.mapswithme.maps.pro"' buildConfigField 'String', 'SUPPORT_MAIL', '"android@maps.me"' + buildConfigField 'boolean', 'IS_PRESTIGIO_PREINSTALLED', 'false' android.sourceSets.yandexPro.setRoot('flavors/pro') android.sourceSets.yandexPro.assets.srcDirs = ['flavors/guides-assets', 'flavors/mwm-ttf-assets'] } @@ -169,6 +177,7 @@ android { buildConfigField 'String', 'PRO_URL', '"yastore://details?id=com.mapswithme.maps.pro"' buildConfigField 'String', 'REVIEW_URL', '"yastore://details?id=com.mapswithme.maps"' buildConfigField 'String', 'SUPPORT_MAIL', '"android@maps.me"' + buildConfigField 'boolean', 'IS_PRESTIGIO_PREINSTALLED', 'false' android.sourceSets.yandexLite.setRoot('flavors/lite') android.sourceSets.yandexLite.assets.srcDirs = ['flavors/guides-assets', 'flavors/mwm-ttf-assets'] } @@ -179,9 +188,21 @@ android { buildConfigField 'String', 'PRO_URL', '"market://details?id=com.mapswithme.maps.pro"' buildConfigField 'String', 'REVIEW_URL', '"market://details?id=com.mapswithme.maps"' buildConfigField 'String', 'SUPPORT_MAIL', 'android@maps.me' + buildConfigField 'boolean', 'IS_PRESTIGIO_PREINSTALLED', 'false' android.sourceSets.yotaLite.setRoot('flavors/lite') android.sourceSets.yotaLite.assets.srcDirs = ['flavors/guides-assets', 'flavors/mwm-ttf-assets'] } + + prestigioPro { + applicationId 'com.mapswithme.maps.pro' + buildConfigField 'boolean', 'IS_PRO', 'true' + buildConfigField 'String', 'PRO_URL', '"market://details?id=com.mapswithme.maps.pro"' + buildConfigField 'String', 'REVIEW_URL', '"market://details?id=com.mapswithme.maps.pro"' + buildConfigField 'String', 'SUPPORT_MAIL', '"googleplay@maps.me"' + buildConfigField 'boolean', 'IS_PRESTIGIO_PREINSTALLED', 'true' + android.sourceSets.googlePro.setRoot('flavors/pro') + android.sourceSets.googlePro.assets.srcDirs = ['flavors/guides-assets'] + } } // TODO: Fix a lot of lint errors in our code diff --git a/android/src/com/mapswithme/country/BaseDownloadAdapter.java b/android/src/com/mapswithme/country/BaseDownloadAdapter.java index c2df417dfe..1372c01ec0 100644 --- a/android/src/com/mapswithme/country/BaseDownloadAdapter.java +++ b/android/src/com/mapswithme/country/BaseDownloadAdapter.java @@ -22,6 +22,7 @@ import android.widget.LinearLayout; import android.widget.ListView; import android.widget.TextView; +import com.mapswithme.maps.MWMApplication; import com.mapswithme.maps.MapStorage; import com.mapswithme.maps.R; import com.mapswithme.maps.guides.GuideInfo; @@ -150,7 +151,7 @@ abstract class BaseDownloadAdapter extends BaseAdapter { // TODO if download is greater then 50MB check 3g/WIFI connection startItemDownloading(holder, position, newOptions); - Statistics.INSTANCE.trackCountryDownload(); + Statistics.INSTANCE.trackCountryDownload(MWMApplication.get().nativeGetBoolean(MWMApplication.IS_PRESTIGIO_PREINSTALLED, false)); } protected void confirmDownloadCancelation(final ViewHolder holder, final int position, final String name) diff --git a/android/src/com/mapswithme/maps/MWMApplication.java b/android/src/com/mapswithme/maps/MWMApplication.java index 5cc25bb3e3..abb0d7f0ff 100644 --- a/android/src/com/mapswithme/maps/MWMApplication.java +++ b/android/src/com/mapswithme/maps/MWMApplication.java @@ -23,11 +23,14 @@ import com.mapswithme.util.FbUtil; import com.mapswithme.util.Utils; import com.mapswithme.util.log.Logger; import com.mapswithme.util.log.StubLogger; +import com.mapswithme.util.statistics.Statistics; import com.mobileapptracker.MobileAppTracker; import java.io.File; import java.io.IOException; +import java.util.Date; +import ru.mail.mrgservice.MRGSApplication; import ru.mail.mrgservice.MRGSMap; import ru.mail.mrgservice.MRGSServerData; import ru.mail.mrgservice.MRGService; @@ -37,6 +40,7 @@ public class MWMApplication extends android.app.Application implements ActiveCou private final static String TAG = "MWMApplication"; private static final String FOREGROUND_TIME_SETTING = "AllForegroundTime"; private static final String LAUNCH_NUMBER_SETTING = "LaunchNumber"; + public static final String IS_PRESTIGIO_PREINSTALLED = "IsPrestigioPreinstalled"; private static MWMApplication mSelf; @@ -111,8 +115,6 @@ public class MWMApplication extends android.app.Application implements ActiveCou mIsYota = Build.DEVICE.equals(Constants.DEVICE_YOTAPHONE); - initMrgs(); - final String extStoragePath = getDataStoragePath(); final String extTmpPath = getTempPath(); @@ -147,15 +149,19 @@ public class MWMApplication extends android.app.Application implements ActiveCou nativeAddLocalization("routing_failed_route_not_found", getString(R.string.routing_failed_route_not_found)); nativeAddLocalization("routing_failed_internal_error", getString(R.string.routing_failed_internal_error)); - // init BookmarkManager (automatically loads bookmarks) if (hasBookmarks()) BookmarkManager.getBookmarkManager(); - WorkerService.startActionUpdateAds(this); - updateLaunchNumbers(); + initMrgs(); + WorkerService.startActionUpdateAds(this); PreferenceManager.setDefaultValues(this, R.xml.preferences, false); + if (BuildConfig.IS_PRESTIGIO_PREINSTALLED && !nativeGetBoolean(IS_PRESTIGIO_PREINSTALLED, false)) + { + nativeSetBoolean(IS_PRESTIGIO_PREINSTALLED, true); + Statistics.INSTANCE.trackAppActivated(true); + } } private void initMrgs() @@ -169,6 +175,12 @@ public class MWMApplication extends android.app.Application implements ActiveCou @Override public void loadPromoBannersDidFinished(MRGSMap mrgsMap) {} }, getString(R.string.mrgs_id), getString(R.string.mrgs_key)); + + if (getLaunchesNumber() == 1) + { + Log.d("TEST", "Init mrgsApp!"); + MRGSApplication.instance().markAsUpdated(new Date()); + } } public String getApkPath() diff --git a/android/src/com/mapswithme/util/statistics/Statistics.java b/android/src/com/mapswithme/util/statistics/Statistics.java index 7651fd656a..f6556bd995 100644 --- a/android/src/com/mapswithme/util/statistics/Statistics.java +++ b/android/src/com/mapswithme/util/statistics/Statistics.java @@ -64,6 +64,7 @@ public enum Statistics public static final String SEARCH_ON_MAP_CLICKED = "Search on map clicked."; public static final String STATISTICS_STATUS_CHANGED = "Statistics status changed"; public static final String NO_FREE_SPACE = "Downloader. Not enough free space."; + public static final String APP_ACTIVATED = "Application activated."; } public static class EventParam @@ -81,6 +82,7 @@ public enum Statistics public static final String FG_TIME = "Foreground time"; public static final String PRO_STAT = "One time PRO stat"; public static final String ENABLED = "Enabled"; + public static final String PRESTIGIO_PREINSTALLED = "IsPrestigioPreinstalled"; } private Statistics() @@ -116,9 +118,12 @@ public enum Statistics trackIfEnabled(event); } - public void trackCountryDownload() + public void trackCountryDownload(boolean isPrestigioPreinstalled) { - trackIfEnabled(mEventBuilder.setName(EventName.COUNTRY_DOWNLOAD).buildEvent()); + trackIfEnabled(mEventBuilder. + setName(EventName.COUNTRY_DOWNLOAD). + addParam(EventParam.PRESTIGIO_PREINSTALLED, String.valueOf(isPrestigioPreinstalled)). + buildEvent()); } public void trackCountryUpdate() @@ -232,6 +237,15 @@ public enum Statistics trackIfEnabled(event); } + public void trackAppActivated(boolean isPrestigioPreinstalled) + { + final Event event = mEventBuilder. + setName(EventName.APP_ACTIVATED). + addParam(EventParam.PRESTIGIO_PREINSTALLED, String.valueOf(isPrestigioPreinstalled)). + buildEvent(); + trackIfEnabled(event); + } + public void trackDownloadCountryNotificationShown() { trackIfEnabled(mEventBuilder.setName(EventName.DOWNLOAD_COUNTRY_NOTIFICATION_SHOWN).buildEvent());