Add installation date to maps request to the server
This commit is contained in:
parent
cc81870348
commit
4a25848136
4 changed files with 52 additions and 28 deletions
|
@ -57,6 +57,8 @@ public class AppInitializer implements IProgress {
|
||||||
|
|
||||||
public static final boolean TIPS_AND_TRICKS = false;
|
public static final boolean TIPS_AND_TRICKS = false;
|
||||||
private static final String FIRST_TIME_APP_RUN = "FIRST_TIME_APP_RUN"; //$NON-NLS-1$
|
private static final String FIRST_TIME_APP_RUN = "FIRST_TIME_APP_RUN"; //$NON-NLS-1$
|
||||||
|
protected static final String NUMBER_OF_STARTS = "NUMBER_OF_STARTS"; //$NON-NLS-1$
|
||||||
|
protected static final String FIRST_INSTALLED = "FIRST_INSTALLED"; //$NON-NLS-1$
|
||||||
private static final String VECTOR_INDEXES_CHECK = "VECTOR_INDEXES_CHECK"; //$NON-NLS-1$
|
private static final String VECTOR_INDEXES_CHECK = "VECTOR_INDEXES_CHECK"; //$NON-NLS-1$
|
||||||
private static final String VERSION_INSTALLED = "VERSION_INSTALLED"; //$NON-NLS-1$
|
private static final String VERSION_INSTALLED = "VERSION_INSTALLED"; //$NON-NLS-1$
|
||||||
private static final String EXCEPTION_FILE_SIZE = "EXCEPTION_FS"; //$NON-NLS-1$
|
private static final String EXCEPTION_FILE_SIZE = "EXCEPTION_FS"; //$NON-NLS-1$
|
||||||
|
@ -112,6 +114,14 @@ public class AppInitializer implements IProgress {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SharedPreferences pref = activity.getPreferences(Context.MODE_WORLD_WRITEABLE);
|
SharedPreferences pref = activity.getPreferences(Context.MODE_WORLD_WRITEABLE);
|
||||||
|
if(!pref.contains(NUMBER_OF_STARTS)) {
|
||||||
|
pref.edit().putInt(NUMBER_OF_STARTS, 1).commit();
|
||||||
|
} else {
|
||||||
|
pref.edit().putInt(NUMBER_OF_STARTS, pref.getInt(NUMBER_OF_STARTS, 0) + 1).commit();
|
||||||
|
}
|
||||||
|
if (!pref.contains(FIRST_INSTALLED)) {
|
||||||
|
pref.edit().putLong(FIRST_INSTALLED, System.currentTimeMillis()).commit();
|
||||||
|
}
|
||||||
if (!pref.contains(FIRST_TIME_APP_RUN)) {
|
if (!pref.contains(FIRST_TIME_APP_RUN)) {
|
||||||
firstTime = true;
|
firstTime = true;
|
||||||
pref.edit().putBoolean(FIRST_TIME_APP_RUN, true).commit();
|
pref.edit().putBoolean(FIRST_TIME_APP_RUN, true).commit();
|
||||||
|
|
|
@ -30,7 +30,6 @@ import gnu.trove.list.array.TIntArrayList;
|
||||||
public class ContextMenuAdapter {
|
public class ContextMenuAdapter {
|
||||||
private static final Log LOG = PlatformUtil.getLog(ContextMenuAdapter.class);
|
private static final Log LOG = PlatformUtil.getLog(ContextMenuAdapter.class);
|
||||||
|
|
||||||
// Log log =
|
|
||||||
|
|
||||||
public interface OnContextMenuClick {
|
public interface OnContextMenuClick {
|
||||||
//boolean return type needed to desribe if drawer needed to be close or not
|
//boolean return type needed to desribe if drawer needed to be close or not
|
||||||
|
@ -296,7 +295,6 @@ public class ContextMenuAdapter {
|
||||||
|
|
||||||
|
|
||||||
public ArrayAdapter<?> createListAdapter(final Activity activity, final boolean holoLight) {
|
public ArrayAdapter<?> createListAdapter(final Activity activity, final boolean holoLight) {
|
||||||
// XXX layoutId does not effect layout inflated.
|
|
||||||
final int layoutId = defaultLayoutId;
|
final int layoutId = defaultLayoutId;
|
||||||
final OsmandApplication app = ((OsmandApplication) activity.getApplication());
|
final OsmandApplication app = ((OsmandApplication) activity.getApplication());
|
||||||
ArrayAdapter<String> listAdapter = new ContextMenuArrayAdapter(activity, layoutId, R.id.title,
|
ArrayAdapter<String> listAdapter = new ContextMenuArrayAdapter(activity, layoutId, R.id.title,
|
||||||
|
|
|
@ -1,15 +1,21 @@
|
||||||
package net.osmand.plus;
|
package net.osmand.plus;
|
||||||
|
|
||||||
|
|
||||||
import android.annotation.TargetApi;
|
import java.io.File;
|
||||||
import android.content.Context;
|
import java.io.IOException;
|
||||||
import android.content.res.Configuration;
|
import java.lang.ref.WeakReference;
|
||||||
import android.hardware.Sensor;
|
import java.util.ArrayList;
|
||||||
import android.hardware.SensorManager;
|
import java.util.Arrays;
|
||||||
import android.net.ConnectivityManager;
|
import java.util.Comparator;
|
||||||
import android.net.NetworkInfo;
|
import java.util.Iterator;
|
||||||
import android.os.Build;
|
import java.util.LinkedHashMap;
|
||||||
import android.os.Environment;
|
import java.util.LinkedHashSet;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
import net.osmand.IndexConstants;
|
import net.osmand.IndexConstants;
|
||||||
import net.osmand.StateChangedListener;
|
import net.osmand.StateChangedListener;
|
||||||
|
@ -28,22 +34,15 @@ import net.osmand.plus.helpers.SearchHistoryHelper;
|
||||||
import net.osmand.plus.render.RendererRegistry;
|
import net.osmand.plus.render.RendererRegistry;
|
||||||
import net.osmand.plus.routing.RouteProvider.RouteService;
|
import net.osmand.plus.routing.RouteProvider.RouteService;
|
||||||
import net.osmand.render.RenderingRulesStorage;
|
import net.osmand.render.RenderingRulesStorage;
|
||||||
|
import android.annotation.TargetApi;
|
||||||
import java.io.File;
|
import android.content.Context;
|
||||||
import java.io.IOException;
|
import android.content.res.Configuration;
|
||||||
import java.lang.ref.WeakReference;
|
import android.hardware.Sensor;
|
||||||
import java.util.ArrayList;
|
import android.hardware.SensorManager;
|
||||||
import java.util.Arrays;
|
import android.net.ConnectivityManager;
|
||||||
import java.util.Comparator;
|
import android.net.NetworkInfo;
|
||||||
import java.util.Iterator;
|
import android.os.Build;
|
||||||
import java.util.LinkedHashMap;
|
import android.os.Environment;
|
||||||
import java.util.LinkedHashSet;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.StringTokenizer;
|
|
||||||
|
|
||||||
public class OsmandSettings {
|
public class OsmandSettings {
|
||||||
|
|
||||||
|
@ -1876,6 +1875,9 @@ public class OsmandSettings {
|
||||||
new BooleanPreference("show_ruler", true).makeProfile().cache();
|
new BooleanPreference("show_ruler", true).makeProfile().cache();
|
||||||
|
|
||||||
|
|
||||||
|
public final OsmandPreference<Integer> NUMBER_OF_STARTS = new IntPreference(AppInitializer.NUMBER_OF_STARTS, 0).makeGlobal();
|
||||||
|
|
||||||
|
public final OsmandPreference<Long> FIRST_INSTALLED_DATE = new LongPreference(AppInitializer.FIRST_INSTALLED, 0).makeGlobal();
|
||||||
|
|
||||||
// public final OsmandPreference<Integer> NUMBER_OF_FREE_DOWNLOADS_V2 = new IntPreference("free_downloads_v2", 0).makeGlobal();
|
// public final OsmandPreference<Integer> NUMBER_OF_FREE_DOWNLOADS_V2 = new IntPreference("free_downloads_v2", 0).makeGlobal();
|
||||||
|
|
||||||
|
|
|
@ -12,22 +12,26 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.zip.GZIPInputStream;
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.IndexConstants;
|
import net.osmand.IndexConstants;
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.osm.io.NetworkUtils;
|
import net.osmand.osm.io.NetworkUtils;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.xmlpull.v1.XmlPullParser;
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
import org.xmlpull.v1.XmlPullParserException;
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
import org.xmlpull.v1.XmlPullParserFactory;
|
import org.xmlpull.v1.XmlPullParserFactory;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.PackageManager.NameNotFoundException;
|
import android.content.pm.PackageManager.NameNotFoundException;
|
||||||
import android.content.res.AssetManager;
|
import android.content.res.AssetManager;
|
||||||
|
import android.provider.Settings.Secure;
|
||||||
|
|
||||||
public class DownloadOsmandIndexesHelper {
|
public class DownloadOsmandIndexesHelper {
|
||||||
private final static Log log = PlatformUtil.getLog(DownloadOsmandIndexesHelper.class);
|
private final static Log log = PlatformUtil.getLog(DownloadOsmandIndexesHelper.class);
|
||||||
|
@ -178,7 +182,17 @@ public class DownloadOsmandIndexesHelper {
|
||||||
log.debug("Start loading list of index files"); //$NON-NLS-1$
|
log.debug("Start loading list of index files"); //$NON-NLS-1$
|
||||||
try {
|
try {
|
||||||
String strUrl = ctx.getAppCustomization().getIndexesUrl();
|
String strUrl = ctx.getAppCustomization().getIndexesUrl();
|
||||||
|
OsmandSettings settings = ctx.getSettings();
|
||||||
|
Long nd = settings.FIRST_INSTALLED_DATE.get();
|
||||||
|
if(nd > 0) {
|
||||||
|
strUrl += "&nd=" + ((System.currentTimeMillis() - nd) / (1000l * 24l * 60l * 60l));
|
||||||
|
}
|
||||||
|
strUrl += "&ns=" + settings.NUMBER_OF_STARTS.get();
|
||||||
|
try {
|
||||||
|
strUrl += "&aid=" + Secure.getString(ctx.getContentResolver(), Secure.ANDROID_ID);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
log.info(strUrl);
|
log.info(strUrl);
|
||||||
XmlPullParser parser = XmlPullParserFactory.newInstance().newPullParser();
|
XmlPullParser parser = XmlPullParserFactory.newInstance().newPullParser();
|
||||||
URLConnection connection = NetworkUtils.getHttpURLConnection(strUrl);
|
URLConnection connection = NetworkUtils.getHttpURLConnection(strUrl);
|
||||||
|
|
Loading…
Reference in a new issue