From ae7da416b93a11b6b3a6c40fef63f066158f83b3 Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Tue, 14 Mar 2017 19:26:05 +0300 Subject: [PATCH] Added two settings and motd event --- OsmAnd/res/values/strings.xml | 4 ++++ OsmAnd/src/net/osmand/plus/OsmandApplication.java | 11 +++++++---- OsmAnd/src/net/osmand/plus/OsmandSettings.java | 3 +++ .../plus/activities/SettingsGeneralActivity.java | 6 +++++- .../net/osmand/plus/dialogs/XMasDialogFragment.java | 2 +- .../src/net/osmand/plus/helpers/DiscountHelper.java | 6 ++++++ 6 files changed, 26 insertions(+), 6 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 3cb7f64e69..b13e7367f2 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -9,6 +9,10 @@ 3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy --> + Do not send anonymous app usage + It sends general information about screen used during session. We do not collect any geolocation or user input related data. + Do not show messages at startup + It displays app discounts & special local events messages Parking options Thank you for purchasing full version of OsmAnd! Hills diff --git a/OsmAnd/src/net/osmand/plus/OsmandApplication.java b/OsmAnd/src/net/osmand/plus/OsmandApplication.java index c888634174..e22a3895d1 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandApplication.java +++ b/OsmAnd/src/net/osmand/plus/OsmandApplication.java @@ -793,7 +793,10 @@ public class OsmandApplication extends MultiDexApplication { public void logEvent(Activity ctx, String event) { try { - if(Version.isGooglePlayEnabled(this) && Version.isFreeVersion(this)) { + if (Version.isGooglePlayEnabled(this) && Version.isFreeVersion(this) + && !osmandSettings.DO_NOT_SEND_ANONYMOUS_APP_USAGE.get() + && !osmandSettings.FULL_VERSION_PURCHASED.get() + && !osmandSettings.LIVE_UPDATES_PURCHASED.get()) { Class cl = Class.forName("com.google.firebase.analytics.FirebaseAnalytics"); Method mm = cl.getMethod("getInstance", Context.class); Object inst = mm.invoke(null, ctx == null ? this : ctx); @@ -807,7 +810,7 @@ public class OsmandApplication extends MultiDexApplication { public void initRemoteConfig() { try { - if(Version.isGooglePlayEnabled(this) && Version.isFreeVersion(this)) { + if (Version.isGooglePlayEnabled(this) && Version.isFreeVersion(this)) { Class cl = Class.forName("com.google.firebase.remoteconfig.FirebaseRemoteConfig"); Method mm = cl.getMethod("getInstance"); Object inst = mm.invoke(null); @@ -837,7 +840,7 @@ public class OsmandApplication extends MultiDexApplication { public void activateFetchedRemoteParams() { try { - if(Version.isGooglePlayEnabled(this) && Version.isFreeVersion(this)) { + if (Version.isGooglePlayEnabled(this) && Version.isFreeVersion(this)) { Class cl = Class.forName("com.google.firebase.remoteconfig.FirebaseRemoteConfig"); Method mm = cl.getMethod("getInstance"); Object inst = mm.invoke(null); @@ -851,7 +854,7 @@ public class OsmandApplication extends MultiDexApplication { public boolean getRemoteBoolean(String key, boolean defaultValue) { try { - if(Version.isGooglePlayEnabled(this) && Version.isFreeVersion(this)) { + if (Version.isGooglePlayEnabled(this) && Version.isFreeVersion(this)) { Class cl = Class.forName("com.google.firebase.remoteconfig.FirebaseRemoteConfig"); Method mm = cl.getMethod("getInstance"); Object inst = mm.invoke(null); diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index 71e3763fc8..bfaf9512c8 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -871,6 +871,9 @@ public class OsmandSettings { public final OsmandPreference USE_MAGNETIC_FIELD_SENSOR_COMPASS = new BooleanPreference("use_magnetic_field_sensor_compass", false).makeGlobal().cache(); public final OsmandPreference USE_KALMAN_FILTER_FOR_COMPASS = new BooleanPreference("use_kalman_filter_compass", true).makeGlobal().cache(); + public final OsmandPreference DO_NOT_SHOW_STARTUP_MESSAGES = new BooleanPreference("do_not_show_startup_messages", false).makeGlobal().cache(); + public final OsmandPreference DO_NOT_SEND_ANONYMOUS_APP_USAGE = new BooleanPreference("do_not_send_anonymous_app_usage", false).makeGlobal().cache(); + public final CommonPreference TEXT_SCALE = new FloatPreference("text_scale", 1f).makeProfile().cache(); diff --git a/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java b/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java index df01ae392b..27bc33cd86 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java @@ -436,7 +436,11 @@ public class SettingsGeneralActivity extends SettingsBaseActivity implements OnR OsmandSettings.OSMAND_LIGHT_THEME}); misc.addPreference(createCheckBoxPreference(settings.USE_KALMAN_FILTER_FOR_COMPASS, R.string.use_kalman_filter_compass, R.string.use_kalman_filter_compass_descr)); - + if (Version.isGooglePlayEnabled(getMyApplication()) && Version.isFreeVersion(getMyApplication()) + && !settings.FULL_VERSION_PURCHASED.get() && !settings.LIVE_UPDATES_PURCHASED.get()) { + misc.addPreference(createCheckBoxPreference(settings.DO_NOT_SEND_ANONYMOUS_APP_USAGE, R.string.do_not_send_anonymous_app_usage, R.string.do_not_send_anonymous_app_usage_desc)); + } + misc.addPreference(createCheckBoxPreference(settings.DO_NOT_SHOW_STARTUP_MESSAGES, R.string.do_not_show_startup_messages, R.string.do_not_show_startup_messages_desc)); } diff --git a/OsmAnd/src/net/osmand/plus/dialogs/XMasDialogFragment.java b/OsmAnd/src/net/osmand/plus/dialogs/XMasDialogFragment.java index 0f39d2477a..b67f51be2b 100644 --- a/OsmAnd/src/net/osmand/plus/dialogs/XMasDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/dialogs/XMasDialogFragment.java @@ -22,7 +22,7 @@ public class XMasDialogFragment extends DialogFragment { private static boolean XmasDialogWasProcessed = false; public static boolean shouldShowXmasDialog(OsmandApplication app) { - if (XmasDialogWasProcessed) { + if (XmasDialogWasProcessed || app.getSettings().DO_NOT_SHOW_STARTUP_MESSAGES.get()) { return false; } int numberOfStarts = app.getAppInitializer().getNumberOfStarts(); diff --git a/OsmAnd/src/net/osmand/plus/helpers/DiscountHelper.java b/OsmAnd/src/net/osmand/plus/helpers/DiscountHelper.java index 290d661dcf..9b910dbee9 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/DiscountHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/DiscountHelper.java @@ -40,6 +40,9 @@ public class DiscountHelper { public static void checkAndDisplay(final MapActivity mapActivity) { + if (mapActivity.getMyApplication().getSettings().DO_NOT_SHOW_STARTUP_MESSAGES.get()) { + return; + } if (mBannerVisible) { showDiscountBanner(mapActivity, mTitle, mDescription, mIcon, mUrl); } @@ -161,6 +164,7 @@ public class DiscountHelper { toolbarController.setOnBackButtonClickListener(new View.OnClickListener() { @Override public void onClick(View v) { + mapActivity.getMyApplication().logEvent(mapActivity, "motd_click"); mBannerVisible = false; openUrl(mapActivity, url); } @@ -168,6 +172,7 @@ public class DiscountHelper { toolbarController.setOnTitleClickListener(new View.OnClickListener() { @Override public void onClick(View v) { + mapActivity.getMyApplication().logEvent(mapActivity, "motd_click"); mBannerVisible = false; openUrl(mapActivity, url); } @@ -176,6 +181,7 @@ public class DiscountHelper { toolbarController.setOnCloseButtonClickListener(new View.OnClickListener() { @Override public void onClick(View v) { + mapActivity.getMyApplication().logEvent(mapActivity, "motd_close"); mBannerVisible = false; mapActivity.hideTopToolbar(toolbarController); }