diff --git a/android/src/com/mapswithme/maps/MWMApplication.java b/android/src/com/mapswithme/maps/MWMApplication.java index 5f5b87d321..1b66b7aa9e 100644 --- a/android/src/com/mapswithme/maps/MWMApplication.java +++ b/android/src/com/mapswithme/maps/MWMApplication.java @@ -39,10 +39,11 @@ public class MWMApplication extends android.app.Application implements ActiveCou { private final static String TAG = "MWMApplication"; private static final String FOREGROUND_TIME_SETTING = "AllForegroundTime"; - public static final String LAUNCH_NUMBER_SETTING = "LaunchNumber"; // total number of app launches - public static final String SESSION_NUMBER_SETTING = "SessionNumber"; // session = number of days, when app was launched - public static final String LAST_SESSION_TIMESTAMP_SETTING = "LastSessionTimestamp"; // timestamp of last session + private static final String LAUNCH_NUMBER_SETTING = "LaunchNumber"; // total number of app launches + private static final String SESSION_NUMBER_SETTING = "SessionNumber"; // session = number of days, when app was launched + private static final String LAST_SESSION_TIMESTAMP_SETTING = "LastSessionTimestamp"; // timestamp of last session public static final String IS_PREINSTALLED = "IsPreinstalled"; + private static final String FIRST_INSTALL_VERSION = "FirstInstallVersion"; private static MWMApplication mSelf; @@ -285,7 +286,10 @@ public class MWMApplication extends android.app.Application implements ActiveCou { final int currentLaunches = nativeGetInt(LAUNCH_NUMBER_SETTING, 0); if (currentLaunches == 0) + { trackAppActivation(); + nativeSetInt(FIRST_INSTALL_VERSION, BuildConfig.VERSION_CODE); + } nativeSetInt(LAUNCH_NUMBER_SETTING, currentLaunches + 1); } @@ -305,7 +309,6 @@ public class MWMApplication extends android.app.Application implements ActiveCou } /** - * * @return total number of application launches */ public int getLaunchesNumber() @@ -315,6 +318,7 @@ public class MWMApplication extends android.app.Application implements ActiveCou /** * Session = single day, when app was started any number of times. + * * @return number of sessions. */ public int getSessionsNumber() @@ -322,6 +326,11 @@ public class MWMApplication extends android.app.Application implements ActiveCou return nativeGetInt(SESSION_NUMBER_SETTING, 0); } + public int getFirstInstallVersion() + { + return nativeGetInt(FIRST_INSTALL_VERSION, 0); + } + private void initMAT(Activity activity) { if (!Utils.hasAnyGoogleStoreInstalled()) diff --git a/android/src/com/mapswithme/util/Utils.java b/android/src/com/mapswithme/util/Utils.java index d289048bd8..395095c4bb 100644 --- a/android/src/com/mapswithme/util/Utils.java +++ b/android/src/com/mapswithme/util/Utils.java @@ -26,7 +26,6 @@ import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; -import java.util.Calendar; import java.util.List; import java.util.Locale; import java.util.Map; @@ -287,12 +286,17 @@ public class Utils return model; } - public static boolean isInstalledAfter(Calendar calendar) + /** + * + * @param timestamp in currentTimeMillis() format + * @return + */ + public static boolean isInstalledAfter(long timestamp) { try { final PackageInfo info = MWMApplication.get().getPackageManager().getPackageInfo(BuildConfig.APPLICATION_ID, 0); - return info.firstInstallTime > calendar.getTimeInMillis(); + return info.firstInstallTime > timestamp; } catch (PackageManager.NameNotFoundException e) { e.printStackTrace();