diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml
index f414b063da..c297b322d5 100644
--- a/OsmAnd/res/values/strings.xml
+++ b/OsmAnd/res/values/strings.xml
@@ -9,6 +9,8 @@
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
-->
+ Don\'t check any updates about new versions, discounts related to OsmAnd
+ Don\'t show updates
Do you want to update all maps now?
Clear all tiles
Fuel-efficient way
diff --git a/OsmAnd/src/net/osmand/plus/AppInitializer.java b/OsmAnd/src/net/osmand/plus/AppInitializer.java
index fbcd8f353f..c7d4a87f0b 100644
--- a/OsmAnd/src/net/osmand/plus/AppInitializer.java
+++ b/OsmAnd/src/net/osmand/plus/AppInitializer.java
@@ -10,7 +10,6 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.support.v7.app.AlertDialog;
-
import net.osmand.IProgress;
import net.osmand.IndexConstants;
import net.osmand.PlatformUtil;
@@ -60,7 +59,6 @@ import java.util.List;
import java.util.Random;
import btools.routingapp.BRouterServiceConnection;
-
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.getPendingIntent;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceLastCheck;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceLiveUpdatesOn;
@@ -181,11 +179,13 @@ public class AppInitializer implements IProgress {
return startPrefs.getInt(NUMBER_OF_STARTS, 1);
}
- public long getFirstInstalled() {
+ public long getFirstInstalledDays() {
if(startPrefs == null) {
return 0;
}
- return startPrefs.getLong(FIRST_INSTALLED, 0);
+ long nd = startPrefs.getLong(FIRST_INSTALLED, 0);
+
+ return (System.currentTimeMillis() - nd) / (1000l * 24l * 60l * 60l);
}
public void resetFirstTimeRun() {
diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java
index f154823642..1448be3dd9 100644
--- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java
+++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java
@@ -906,6 +906,7 @@ public class OsmandSettings {
public final OsmandPreference DISCOUNT_ID = new IntPreference("discount_id", 0).makeGlobal();
public final OsmandPreference DISCOUNT_SHOW_NUMBER_OF_STARTS = new IntPreference("number_of_starts_on_discount_show", 0).makeGlobal();
+ public final OsmandPreference DISCOUNT_TOTAL_SHOW = new IntPreference("discount_total_show", 0).makeGlobal();
public final OsmandPreference DISCOUNT_SHOW_DATETIME_MS = new LongPreference("show_discount_datetime_ms", 0).makeGlobal();
// this value string is synchronized with settings_pref.xml preference name
@@ -1082,6 +1083,8 @@ public class OsmandSettings {
public final OsmandPreference OSMO_GROUPS = new StringPreference("osmo_groups", "{}").makeGlobal();
+ public final OsmandPreference NO_DISCOUNT_INFO = new BooleanPreference("no_discount_info", false).makeGlobal();
+
// this value string is synchronized with settings_pref.xml preference name
public final OsmandPreference DEBUG_RENDERING_INFO = new BooleanPreference("debug_rendering", false).makeGlobal();
diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java
index 846f90959f..9ec3a95015 100644
--- a/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java
+++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java
@@ -419,7 +419,7 @@ public class MapActivityLayers {
adapter.addItem(builder.createItem());
}
- public void selectMapLayer(final OsmandMapTileView mapView, final ContextMenuItem it) {
+ public void selectMapLayer(final OsmandMapTileView mapView, final ContextMenuItem it, final ArrayAdapter adapter) {
if (OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class) == null) {
Toast.makeText(activity, R.string.map_online_plugin_is_not_installed, Toast.LENGTH_LONG).show();
return;
@@ -477,9 +477,8 @@ public class MapActivityLayers {
case layerOsmVector:
settings.MAP_ONLINE_DATA.set(false);
updateMapSource(mapView, null);
- if(it != null) {
- it.setDescription(null);
- }
+ it.setDescription(null);
+ adapter.notifyDataSetChanged();
break;
case layerEditInstall:
OsmandRasterMapsPlugin.defineNewEditLayer(activity, new ResultMatcher() {
@@ -513,12 +512,11 @@ public class MapActivityLayers {
if (count == 1) {
settings.MAP_TILE_SOURCES.set(template.getName());
settings.MAP_ONLINE_DATA.set(true);
- if(it != null) {
- it.setDescription(template.getName());
- }
+ it.setDescription(template.getName());
+ adapter.notifyDataSetChanged();
updateMapSource(mapView, settings.MAP_TILE_SOURCES);
} else {
- selectMapLayer(mapView, it);
+ selectMapLayer(mapView, it, adapter);
}
} else {
count++;
@@ -536,9 +534,8 @@ public class MapActivityLayers {
default:
settings.MAP_TILE_SOURCES.set(layerKey);
settings.MAP_ONLINE_DATA.set(true);
- if(it != null) {
- it.setDescription(layerKey);
- }
+ it.setDescription(layerKey);
+ adapter.notifyDataSetChanged();
updateMapSource(mapView, settings.MAP_TILE_SOURCES);
break;
}
diff --git a/OsmAnd/src/net/osmand/plus/development/SettingsDevelopmentActivity.java b/OsmAnd/src/net/osmand/plus/development/SettingsDevelopmentActivity.java
index 77f977fb26..82a5425284 100644
--- a/OsmAnd/src/net/osmand/plus/development/SettingsDevelopmentActivity.java
+++ b/OsmAnd/src/net/osmand/plus/development/SettingsDevelopmentActivity.java
@@ -39,7 +39,8 @@ public class SettingsDevelopmentActivity extends SettingsBaseActivity {
super.onCreate(savedInstanceState);
getToolbar().setTitle(R.string.debugging_and_development);
PreferenceScreen cat = getPreferenceScreen();
-
+
+
CheckBoxPreference dbg = createCheckBoxPreference(settings.DEBUG_RENDERING_INFO,
R.string.trace_rendering, R.string.trace_rendering_descr);
cat.addPreference(dbg);
@@ -81,6 +82,10 @@ public class SettingsDevelopmentActivity extends SettingsBaseActivity {
cat.addPreference(createCheckBoxPreference(settings.SHOULD_SHOW_FREE_VERSION_BANNER,
R.string.show_free_version_banner,
R.string.show_free_version_banner_description));
+
+ cat.addPreference(createCheckBoxPreference(settings.NO_DISCOUNT_INFO,
+ R.string.no_update_info, R.string.no_update_info_desc));
+
// FIXME delete USE_MAP_MARKERS
// cat.addPreference(createCheckBoxPreference(settings.USE_MAP_MARKERS,
@@ -110,6 +115,8 @@ public class SettingsDevelopmentActivity extends SettingsBaseActivity {
}
});
cat.addPreference(pref);
+
+
pref = new Preference(this);
pref.setTitle(R.string.test_voice_prompts);
diff --git a/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java b/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java
index 9111c5fcd2..15410d303c 100644
--- a/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java
+++ b/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java
@@ -164,7 +164,7 @@ public class ConfigureMapMenu {
ma.startActivity(intent);
} else {
ContextMenuItem it = adapter.getItem(pos);
- ma.getMapLayers().selectMapLayer(ma.getMapView(), it);
+ ma.getMapLayers().selectMapLayer(ma.getMapView(), it, adapter);
}
}
adapter.notifyDataSetChanged();
@@ -620,14 +620,20 @@ public class ConfigureMapMenu {
};
ContextMenuItem.ItemBuilder builder = new ContextMenuItem.ItemBuilder().setTitleId(strId, activity)
.setIcon(icon).setListener(clickListener);
+ boolean selected = false;
+ for(OsmandSettings.CommonPreference p : prefs) {
+ if(p.get()) {
+ selected = true;
+ break;
+ }
+ }
+ builder.setColor(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
if (useDescription) {
final String descr = getDescription(prefs);
builder.setDescription(descr);
builder.setLayout(R.layout.list_item_single_line_descrition_narrow);
} else {
- boolean selected = false;
builder.setListener(new OnRowItemClick() {
-
@Override
public boolean onContextMenuClick(ArrayAdapter a, int itemId, int pos, boolean isChecked) {
return clickListener.onContextMenuClick(a, itemId, pos, isChecked);
@@ -642,13 +648,6 @@ public class ConfigureMapMenu {
}
});
builder.setSecondaryIcon(R.drawable.ic_action_additional_option);
- for(OsmandSettings.CommonPreference p : prefs) {
- if(p.get()) {
- selected = true;
- break;
- }
- }
- builder.setColor(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
builder.setSelected(selected);
}
return builder.createItem();
diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadOsmandIndexesHelper.java b/OsmAnd/src/net/osmand/plus/download/DownloadOsmandIndexesHelper.java
index 77c862de86..433f929d3d 100644
--- a/OsmAnd/src/net/osmand/plus/download/DownloadOsmandIndexesHelper.java
+++ b/OsmAnd/src/net/osmand/plus/download/DownloadOsmandIndexesHelper.java
@@ -182,11 +182,9 @@ public class DownloadOsmandIndexesHelper {
log.debug("Start loading list of index files"); //$NON-NLS-1$
try {
String strUrl = ctx.getAppCustomization().getIndexesUrl();
- OsmandSettings settings = ctx.getSettings();
-
- long nd = ctx.getAppInitializer().getFirstInstalled();
+ long nd = ctx.getAppInitializer().getFirstInstalledDays();
if(nd > 0) {
- strUrl += "&nd=" + ((System.currentTimeMillis() - nd) / (1000l * 24l * 60l * 60l));
+ strUrl += "&nd=" + nd;
}
strUrl += "&ns=" + ctx.getAppInitializer().getNumberOfStarts();
try {
diff --git a/OsmAnd/src/net/osmand/plus/helpers/DiscountHelper.java b/OsmAnd/src/net/osmand/plus/helpers/DiscountHelper.java
index b14ca80d3c..b0c48f20ef 100644
--- a/OsmAnd/src/net/osmand/plus/helpers/DiscountHelper.java
+++ b/OsmAnd/src/net/osmand/plus/helpers/DiscountHelper.java
@@ -2,6 +2,8 @@ package net.osmand.plus.helpers;
import java.text.SimpleDateFormat;
import java.util.Date;
+import java.util.LinkedHashMap;
+import java.util.Map;
import net.osmand.AndroidNetworkUtils;
import net.osmand.plus.OsmandApplication;
@@ -33,24 +35,32 @@ public class DiscountHelper {
private static String mIcon;
private static String mUrl;
private static boolean mBannerVisible;
+ private static final String URL = "http://osmand.net/api/motd";
public static void checkAndDisplay(final MapActivity mapActivity) {
if (mBannerVisible) {
showDiscountBanner(mapActivity, mTitle, mDescription, mIcon, mUrl);
}
+ OsmandApplication app = mapActivity.getMyApplication();
if (System.currentTimeMillis() - mLastCheckTime < 1000 * 60 * 60 * 24
- || !mapActivity.getMyApplication().getSettings().isInternetConnectionAvailable()) {
+ || !app.getSettings().isInternetConnectionAvailable()
+ || app.getSettings().NO_DISCOUNT_INFO.get()) {
return;
}
mLastCheckTime = System.currentTimeMillis();
+ final Map pms = new LinkedHashMap<>();
+ pms.put("name", Version.getAppName(app));
+ pms.put("version", Version.getAppVersion(app));
+ pms.put("nd", app.getAppInitializer().getFirstInstalledDays() +"");
+ pms.put("ns", app.getAppInitializer().getNumberOfStarts() + "");
new AsyncTask() {
@Override
protected String doInBackground(Void... params) {
try {
String res = AndroidNetworkUtils.sendRequest(mapActivity.getMyApplication(),
- "http://osmand.net/api/motd", null, "Requesting discount info...", false);
+ URL, pms, "Requesting discount info...", false);
return res;
} catch (Exception e) {
logError("Requesting discount info error: ", e);
@@ -81,7 +91,8 @@ public class DiscountHelper {
Date start = df.parse(obj.getString("start"));
Date end = df.parse(obj.getString("end"));
int showStartFrequency = obj.getInt("show_start_frequency");
- int showDayFrequency = obj.getInt("show_day_frequency");
+ double showDayFrequency = obj.getDouble("show_day_frequency");
+ int maxTotalShow = obj.getInt("max_total_show");
JSONObject application = obj.getJSONObject("application");
String appName = app.getPackageName();
@@ -91,14 +102,21 @@ public class DiscountHelper {
OsmandSettings settings = app.getSettings();
int discountId = getDiscountId(message, description, start, end);
- if (settings.DISCOUNT_ID.get() != discountId
+ boolean discountChanged = settings.DISCOUNT_ID.get() != discountId;
+ if(discountChanged) {
+ settings.DISCOUNT_TOTAL_SHOW.set(0);
+ }
+ if (discountChanged
|| app.getAppInitializer().getNumberOfStarts() - settings.DISCOUNT_SHOW_NUMBER_OF_STARTS.get() >= showStartFrequency
|| System.currentTimeMillis() - settings.DISCOUNT_SHOW_DATETIME_MS.get() > 1000L * 60 * 60 * 24 * showDayFrequency) {
-
- settings.DISCOUNT_ID.set(discountId);
- settings.DISCOUNT_SHOW_NUMBER_OF_STARTS.set(app.getAppInitializer().getNumberOfStarts());
- settings.DISCOUNT_SHOW_DATETIME_MS.set(System.currentTimeMillis());
- showDiscountBanner(mapActivity, message, description, icon, url);
+ if(settings.DISCOUNT_TOTAL_SHOW.get() < maxTotalShow){
+ settings.DISCOUNT_ID.set(discountId);
+ settings.DISCOUNT_TOTAL_SHOW.set(settings.DISCOUNT_TOTAL_SHOW.get() + 1);
+ settings.DISCOUNT_SHOW_NUMBER_OF_STARTS.set(app.getAppInitializer().getNumberOfStarts());
+ settings.DISCOUNT_SHOW_DATETIME_MS.set(System.currentTimeMillis());
+ showDiscountBanner(mapActivity, message, description, icon, url);
+ }
+
}
}