Remove client context interface
This commit is contained in:
parent
3fe967d797
commit
e316c81d6f
21 changed files with 83 additions and 126 deletions
|
@ -48,4 +48,5 @@ public interface ClientContext {
|
||||||
|
|
||||||
public Location getLastKnownLocation();
|
public Location getLastKnownLocation();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,10 +37,10 @@ public class FavouritesDbHelper {
|
||||||
private List<FavouritePoint> favoritePointsFromGPXFile = null;
|
private List<FavouritePoint> favoritePointsFromGPXFile = null;
|
||||||
private List<FavouritePoint> cachedFavoritePoints = new ArrayList<FavouritePoint>();
|
private List<FavouritePoint> cachedFavoritePoints = new ArrayList<FavouritePoint>();
|
||||||
private Map<String, List<FavouritePoint>> favoriteGroups = null;
|
private Map<String, List<FavouritePoint>> favoriteGroups = null;
|
||||||
private final ClientContext context;
|
private final OsmandApplication context;
|
||||||
private SQLiteConnection conn;
|
private SQLiteConnection conn;
|
||||||
|
|
||||||
public FavouritesDbHelper(ClientContext context) {
|
public FavouritesDbHelper(OsmandApplication context) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -173,7 +173,7 @@ public class GPXUtilities {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String writeGpxFile(File fout, GPXFile file, ClientContext ctx) {
|
public static String writeGpxFile(File fout, GPXFile file, OsmandApplication ctx) {
|
||||||
FileOutputStream output = null;
|
FileOutputStream output = null;
|
||||||
try {
|
try {
|
||||||
SimpleDateFormat format = new SimpleDateFormat(GPX_TIME_FORMAT);
|
SimpleDateFormat format = new SimpleDateFormat(GPX_TIME_FORMAT);
|
||||||
|
|
|
@ -117,8 +117,7 @@ public class NavigationService extends Service implements LocationListener {
|
||||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||||
handler = new Handler();
|
handler = new Handler();
|
||||||
OsmandApplication app = (OsmandApplication) getApplication();
|
OsmandApplication app = (OsmandApplication) getApplication();
|
||||||
ClientContext cl = app;
|
settings = app.getSettings();
|
||||||
settings = cl.getSettings();
|
|
||||||
|
|
||||||
startedForNavigation = intent.getBooleanExtra(NAVIGATION_START_SERVICE_PARAM, false);
|
startedForNavigation = intent.getBooleanExtra(NAVIGATION_START_SERVICE_PARAM, false);
|
||||||
if (startedForNavigation) {
|
if (startedForNavigation) {
|
||||||
|
@ -159,12 +158,12 @@ public class NavigationService extends Service implements LocationListener {
|
||||||
// registering icon at top level
|
// registering icon at top level
|
||||||
// Leave icon visible even for navigation for proper display
|
// Leave icon visible even for navigation for proper display
|
||||||
// if (!startedForNavigation) {
|
// if (!startedForNavigation) {
|
||||||
showNotificationInStatusBar(cl);
|
showNotificationInStatusBar(app);
|
||||||
// }
|
// }
|
||||||
return START_REDELIVER_INTENT;
|
return START_REDELIVER_INTENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showNotificationInStatusBar(ClientContext cl) {
|
private void showNotificationInStatusBar(OsmandApplication cl) {
|
||||||
broadcastReceiver = new BroadcastReceiver() {
|
broadcastReceiver = new BroadcastReceiver() {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
|
|
@ -56,6 +56,7 @@ import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageInfo;
|
||||||
|
import android.content.pm.PackageManager.NameNotFoundException;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.graphics.Shader.TileMode;
|
import android.graphics.Shader.TileMode;
|
||||||
import android.graphics.drawable.BitmapDrawable;
|
import android.graphics.drawable.BitmapDrawable;
|
||||||
|
@ -841,4 +842,22 @@ public class OsmandApplication extends Application implements ClientContext {
|
||||||
}
|
}
|
||||||
return ((AccessibilityManager) getSystemService(Context.ACCESSIBILITY_SERVICE)).isEnabled();
|
return ((AccessibilityManager) getSystemService(Context.ACCESSIBILITY_SERVICE)).isEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getVersionName() {
|
||||||
|
try {
|
||||||
|
PackageInfo info = getPackageManager().getPackageInfo(getPackageName(), 0);
|
||||||
|
return info.versionName;
|
||||||
|
} catch (NameNotFoundException e) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getVersionCode() {
|
||||||
|
try {
|
||||||
|
PackageInfo info = getPackageManager().getPackageInfo(getPackageName(), 0);
|
||||||
|
return info.versionCode;
|
||||||
|
} catch (NameNotFoundException e) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,19 +11,19 @@ public class Version {
|
||||||
private final static String FREE_VERSION_NAME = "net.osmand";
|
private final static String FREE_VERSION_NAME = "net.osmand";
|
||||||
|
|
||||||
|
|
||||||
public static boolean isGpsStatusEnabled(ClientContext ctx) {
|
public static boolean isGpsStatusEnabled(OsmandApplication ctx) {
|
||||||
return ctx.getString(R.string.versionFeatures).contains("+gps_status") && !isBlackberry(ctx);
|
return ctx.getString(R.string.versionFeatures).contains("+gps_status") && !isBlackberry(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isBlackberry(ClientContext ctx) {
|
public static boolean isBlackberry(OsmandApplication ctx) {
|
||||||
return ctx.getString(R.string.versionFeatures).contains("+blackberry");
|
return ctx.getString(R.string.versionFeatures).contains("+blackberry");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isMarketEnabled(ClientContext ctx) {
|
public static boolean isMarketEnabled(OsmandApplication ctx) {
|
||||||
return isGooglePlayEnabled(ctx) || isAmazonEnabled(ctx);
|
return isGooglePlayEnabled(ctx) || isAmazonEnabled(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String marketPrefix(ClientContext ctx) {
|
public static String marketPrefix(OsmandApplication ctx) {
|
||||||
if (isAmazonEnabled(ctx)) {
|
if (isAmazonEnabled(ctx)) {
|
||||||
return "amzn://apps/android?p=";
|
return "amzn://apps/android?p=";
|
||||||
} else if (isGooglePlayEnabled(ctx)) {
|
} else if (isGooglePlayEnabled(ctx)) {
|
||||||
|
@ -32,56 +32,56 @@ public class Version {
|
||||||
return "http://osmand.net/apps?";
|
return "http://osmand.net/apps?";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isAmazonEnabled(ClientContext ctx) {
|
public static boolean isAmazonEnabled(OsmandApplication ctx) {
|
||||||
return ctx.getString(R.string.versionFeatures).contains("+amazon");
|
return ctx.getString(R.string.versionFeatures).contains("+amazon");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isGooglePlayEnabled(ClientContext ctx) {
|
public static boolean isGooglePlayEnabled(OsmandApplication ctx) {
|
||||||
return ctx.getString(R.string.versionFeatures).contains("+play_market");
|
return ctx.getString(R.string.versionFeatures).contains("+play_market");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isFreeVersionEnabled(ClientContext ctx) {
|
public static boolean isFreeVersionEnabled(OsmandApplication ctx) {
|
||||||
return ctx.getString(R.string.versionFeatures).contains("+free_version");
|
return ctx.getString(R.string.versionFeatures).contains("+free_version");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isParkingPluginInlined(ClientContext ctx) {
|
public static boolean isParkingPluginInlined(OsmandApplication ctx) {
|
||||||
return ctx.getString(R.string.versionFeatures).contains("+parking_plugin");
|
return ctx.getString(R.string.versionFeatures).contains("+parking_plugin");
|
||||||
}
|
}
|
||||||
|
|
||||||
private Version(ClientContext ctx) {
|
private Version(OsmandApplication ctx) {
|
||||||
appVersion = ctx.getString(R.string.app_version);
|
appVersion = ctx.getString(R.string.app_version);
|
||||||
appName = ctx.getString(R.string.app_name);
|
appName = ctx.getString(R.string.app_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Version ver = null;
|
private static Version ver = null;
|
||||||
private static Version getVersion(ClientContext ctx){
|
private static Version getVersion(OsmandApplication ctx){
|
||||||
if(ver == null){
|
if(ver == null){
|
||||||
ver = new Version(ctx);
|
ver = new Version(ctx);
|
||||||
}
|
}
|
||||||
return ver;
|
return ver;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getFullVersion(ClientContext ctx){
|
public static String getFullVersion(OsmandApplication ctx){
|
||||||
Version v = getVersion(ctx);
|
Version v = getVersion(ctx);
|
||||||
return v.appName + " " + v.appVersion;
|
return v.appName + " " + v.appVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getAppVersion(ClientContext ctx){
|
public static String getAppVersion(OsmandApplication ctx){
|
||||||
Version v = getVersion(ctx);
|
Version v = getVersion(ctx);
|
||||||
return v.appVersion;
|
return v.appVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getAppName(ClientContext ctx){
|
public static String getAppName(OsmandApplication ctx){
|
||||||
Version v = getVersion(ctx);
|
Version v = getVersion(ctx);
|
||||||
return v.appName;
|
return v.appName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isProductionVersion(ClientContext ctx){
|
public static boolean isProductionVersion(OsmandApplication ctx){
|
||||||
Version v = getVersion(ctx);
|
Version v = getVersion(ctx);
|
||||||
return !v.appVersion.contains("#");
|
return !v.appVersion.contains("#");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getVersionAsURLParam(ClientContext ctx) {
|
public static String getVersionAsURLParam(OsmandApplication ctx) {
|
||||||
try {
|
try {
|
||||||
return "osmandver=" + URLEncoder.encode(getVersionForTracker(ctx), "UTF-8");
|
return "osmandver=" + URLEncoder.encode(getVersionForTracker(ctx), "UTF-8");
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
@ -89,17 +89,17 @@ public class Version {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isFreeVersion(ClientContext ctx){
|
public static boolean isFreeVersion(OsmandApplication ctx){
|
||||||
return ctx.getInternalAPI().getPackageName().equals(FREE_VERSION_NAME) || isFreeVersionEnabled(ctx);
|
return ctx.getPackageName().equals(FREE_VERSION_NAME) || isFreeVersionEnabled(ctx);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isDeveloperVersion(ClientContext ctx){
|
public static boolean isDeveloperVersion(OsmandApplication ctx){
|
||||||
return "osmand~".equalsIgnoreCase(getAppName(ctx));
|
return "osmand~".equalsIgnoreCase(getAppName(ctx));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getVersionForTracker(ClientContext ctx) {
|
public static String getVersionForTracker(OsmandApplication ctx) {
|
||||||
String v = Version.getAppName(ctx);
|
String v = Version.getAppName(ctx);
|
||||||
if(Version.isProductionVersion(ctx)){
|
if(Version.isProductionVersion(ctx)){
|
||||||
v = Version.getFullVersion(ctx);
|
v = Version.getFullVersion(ctx);
|
||||||
|
|
|
@ -14,7 +14,6 @@ import java.util.TimeZone;
|
||||||
import net.osmand.IndexConstants;
|
import net.osmand.IndexConstants;
|
||||||
import net.osmand.access.AccessibleAlertBuilder;
|
import net.osmand.access.AccessibleAlertBuilder;
|
||||||
import net.osmand.access.AccessibleToast;
|
import net.osmand.access.AccessibleToast;
|
||||||
import net.osmand.plus.ClientContext;
|
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandPlugin;
|
import net.osmand.plus.OsmandPlugin;
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
|
@ -349,7 +348,7 @@ public class DownloadIndexActivity extends OsmandExpandableListActivity {
|
||||||
filtered.add(fileItem);
|
filtered.add(fileItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
listAdapter.setIndexFiles(filtered, IndexItemCategory.categorizeIndexItems(getClientContext(), filtered));
|
listAdapter.setIndexFiles(filtered, IndexItemCategory.categorizeIndexItems(getMyApplication(), filtered));
|
||||||
listAdapter.notifyDataSetChanged();
|
listAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -362,7 +361,7 @@ public class DownloadIndexActivity extends OsmandExpandableListActivity {
|
||||||
IndexItem es = listAdapter.getChild(j, i);
|
IndexItem es = listAdapter.getChild(j, i);
|
||||||
if (!getEntriesToDownload().containsKey(es)) {
|
if (!getEntriesToDownload().containsKey(es)) {
|
||||||
selected++;
|
selected++;
|
||||||
getEntriesToDownload().put(es, es.createDownloadEntry(getClientContext(), type, new ArrayList<DownloadEntry>(1)));
|
getEntriesToDownload().put(es, es.createDownloadEntry(getMyApplication(), type, new ArrayList<DownloadEntry>(1)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -502,7 +501,7 @@ public class DownloadIndexActivity extends OsmandExpandableListActivity {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<DownloadEntry> download = e.createDownloadEntry(getClientContext(), type, new ArrayList<DownloadEntry>());
|
List<DownloadEntry> download = e.createDownloadEntry(getMyApplication(), type, new ArrayList<DownloadEntry>());
|
||||||
if (download.size() > 0) {
|
if (download.size() > 0) {
|
||||||
// if(!fileToUnzip.exists()){
|
// if(!fileToUnzip.exists()){
|
||||||
// builder.setMessage(MessageFormat.format(getString(R.string.download_question), baseName, extractDateAndSize(e.getValue())));
|
// builder.setMessage(MessageFormat.format(getString(R.string.download_question), baseName, extractDateAndSize(e.getValue())));
|
||||||
|
@ -622,10 +621,6 @@ public class DownloadIndexActivity extends OsmandExpandableListActivity {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public ClientContext getClientContext() {
|
|
||||||
return getMyApplication();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void updateProgress(boolean updateOnlyProgress) {
|
public void updateProgress(boolean updateOnlyProgress) {
|
||||||
BasicProgressAsyncTask<?, ?, ?> basicProgressAsyncTask = downloadListIndexThread.getCurrentRunningTask();
|
BasicProgressAsyncTask<?, ?, ?> basicProgressAsyncTask = downloadListIndexThread.getCurrentRunningTask();
|
||||||
|
|
|
@ -13,6 +13,7 @@ import net.osmand.IndexConstants;
|
||||||
import net.osmand.access.AccessibleToast;
|
import net.osmand.access.AccessibleToast;
|
||||||
import net.osmand.plus.ApplicationMode;
|
import net.osmand.plus.ApplicationMode;
|
||||||
import net.osmand.plus.ClientContext;
|
import net.osmand.plus.ClientContext;
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.OsmandSettings.DrivingRegion;
|
import net.osmand.plus.OsmandSettings.DrivingRegion;
|
||||||
import net.osmand.plus.OsmandSettings.MetricsConstants;
|
import net.osmand.plus.OsmandSettings.MetricsConstants;
|
||||||
|
@ -185,7 +186,7 @@ public class SettingsGeneralActivity extends SettingsBaseActivity {
|
||||||
}
|
}
|
||||||
registerListPreference(settings.APPLICATION_MODE, screen, entries, appModes);
|
registerListPreference(settings.APPLICATION_MODE, screen, entries, appModes);
|
||||||
|
|
||||||
if (!Version.isBlackberry((ClientContext) getApplication())) {
|
if (!Version.isBlackberry((OsmandApplication) getApplication())) {
|
||||||
PreferenceScreen cat = getPreferenceScreen();
|
PreferenceScreen cat = getPreferenceScreen();
|
||||||
int nav = getResources().getConfiguration().navigation;
|
int nav = getResources().getConfiguration().navigation;
|
||||||
if (nav == Configuration.NAVIGATION_DPAD || nav == Configuration.NAVIGATION_TRACKBALL ||
|
if (nav == Configuration.NAVIGATION_DPAD || nav == Configuration.NAVIGATION_TRACKBALL ||
|
||||||
|
|
|
@ -165,7 +165,7 @@ public class SearchAddressOnlineFragment extends SherlockFragment implements Sea
|
||||||
URL url = new URL(b.toString());
|
URL url = new URL(b.toString());
|
||||||
URLConnection conn = url.openConnection();
|
URLConnection conn = url.openConnection();
|
||||||
conn.setDoInput(true);
|
conn.setDoInput(true);
|
||||||
conn.setRequestProperty("User-Agent", Version.getFullVersion((ClientContext) getActivity().getApplication())); //$NON-NLS-1$
|
conn.setRequestProperty("User-Agent", Version.getFullVersion((OsmandApplication) getActivity().getApplication())); //$NON-NLS-1$
|
||||||
conn.connect();
|
conn.connect();
|
||||||
InputStream is = conn.getInputStream();
|
InputStream is = conn.getInputStream();
|
||||||
XmlPullParser parser = Xml.newPullParser();
|
XmlPullParser parser = Xml.newPullParser();
|
||||||
|
|
|
@ -4,7 +4,6 @@ import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.osmand.NativeLibrary;
|
|
||||||
import net.osmand.ResultMatcher;
|
import net.osmand.ResultMatcher;
|
||||||
import net.osmand.data.Amenity;
|
import net.osmand.data.Amenity;
|
||||||
import net.osmand.plus.PoiFilter;
|
import net.osmand.plus.PoiFilter;
|
||||||
|
@ -19,17 +18,8 @@ public interface InternalOsmAndAPI {
|
||||||
|
|
||||||
public XmlPullParser newPullParser();
|
public XmlPullParser newPullParser();
|
||||||
|
|
||||||
public String getPackageName();
|
|
||||||
|
|
||||||
public String getVersionName();
|
|
||||||
|
|
||||||
public int getVersionCode();
|
|
||||||
|
|
||||||
public InputStream openAsset(String name) throws IOException;
|
public InputStream openAsset(String name) throws IOException;
|
||||||
|
|
||||||
public NativeLibrary getNativeLibrary();
|
|
||||||
|
|
||||||
|
|
||||||
public List<Amenity> searchAmenities(PoiFilter filter,
|
public List<Amenity> searchAmenities(PoiFilter filter,
|
||||||
double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude,
|
double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude,
|
||||||
double lat, double lon, ResultMatcher<Amenity> matcher);
|
double lat, double lon, ResultMatcher<Amenity> matcher);
|
||||||
|
@ -38,13 +28,6 @@ public interface InternalOsmAndAPI {
|
||||||
double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude,
|
double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude,
|
||||||
double lat, double lon, ResultMatcher<Amenity> matcher);
|
double lat, double lon, ResultMatcher<Amenity> matcher);
|
||||||
|
|
||||||
public String getDeviceName();
|
|
||||||
|
|
||||||
public String getBrandName();
|
|
||||||
|
|
||||||
public String getModelName();
|
|
||||||
|
|
||||||
public TargetPointsHelper getTargetPointsHelper();
|
|
||||||
|
|
||||||
public boolean isNavigationServiceStarted();
|
public boolean isNavigationServiceStarted();
|
||||||
|
|
||||||
|
@ -54,5 +37,4 @@ public interface InternalOsmAndAPI {
|
||||||
|
|
||||||
public void stopNavigationService();
|
public void stopNavigationService();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,23 +40,12 @@ public class InternalOsmAndAPIImpl implements InternalOsmAndAPI {
|
||||||
return Xml.newPullParser();
|
return Xml.newPullParser();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getPackageName() {
|
|
||||||
return app.getPackageName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InputStream openAsset(String name) throws IOException {
|
public InputStream openAsset(String name) throws IOException {
|
||||||
return app.getAssets().open(name);
|
return app.getAssets().open(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public NativeLibrary getNativeLibrary() {
|
|
||||||
return NativeOsmandLibrary.getLoadedLibrary();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Amenity> searchAmenities(PoiFilter filter, double topLatitude, double leftLongitude, double bottomLatitude,
|
public List<Amenity> searchAmenities(PoiFilter filter, double topLatitude, double leftLongitude, double bottomLatitude,
|
||||||
double rightLongitude, double lat, double lon, ResultMatcher<Amenity> matcher) {
|
double rightLongitude, double lat, double lon, ResultMatcher<Amenity> matcher) {
|
||||||
|
@ -69,45 +58,6 @@ public class InternalOsmAndAPIImpl implements InternalOsmAndAPI {
|
||||||
return app.getResourceManager().searchAmenitiesByName(searchQuery, topLatitude, leftLongitude, bottomLatitude, rightLongitude, lat, lon, matcher);
|
return app.getResourceManager().searchAmenitiesByName(searchQuery, topLatitude, leftLongitude, bottomLatitude, rightLongitude, lat, lon, matcher);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getVersionName() {
|
|
||||||
try {
|
|
||||||
PackageInfo info = app.getPackageManager().getPackageInfo(app.getPackageName(), 0);
|
|
||||||
return info.versionName;
|
|
||||||
} catch (NameNotFoundException e) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getVersionCode() {
|
|
||||||
try {
|
|
||||||
PackageInfo info = app.getPackageManager().getPackageInfo(app.getPackageName(), 0);
|
|
||||||
return info.versionCode;
|
|
||||||
} catch (NameNotFoundException e) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDeviceName() {
|
|
||||||
return Build.DEVICE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getBrandName() {
|
|
||||||
return Build.BRAND;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getModelName() {
|
|
||||||
return Build.MODEL;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TargetPointsHelper getTargetPointsHelper() {
|
|
||||||
return app.getTargetPointsHelper();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isNavigationServiceStarted() {
|
public boolean isNavigationServiceStarted() {
|
||||||
|
|
|
@ -15,6 +15,7 @@ import net.osmand.IProgress;
|
||||||
import net.osmand.IndexConstants;
|
import net.osmand.IndexConstants;
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.plus.ClientContext;
|
import net.osmand.plus.ClientContext;
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.Version;
|
import net.osmand.plus.Version;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
@ -27,11 +28,11 @@ public class DownloadFileHelper {
|
||||||
private static final int BUFFER_SIZE = 32256;
|
private static final int BUFFER_SIZE = 32256;
|
||||||
protected static final int TRIES_TO_DOWNLOAD = 15;
|
protected static final int TRIES_TO_DOWNLOAD = 15;
|
||||||
protected static final long TIMEOUT_BETWEEN_DOWNLOADS = 8000;
|
protected static final long TIMEOUT_BETWEEN_DOWNLOADS = 8000;
|
||||||
private final ClientContext ctx;
|
private final OsmandApplication ctx;
|
||||||
private boolean interruptDownloading = false;
|
private boolean interruptDownloading = false;
|
||||||
|
|
||||||
|
|
||||||
public DownloadFileHelper(ClientContext ctx){
|
public DownloadFileHelper(OsmandApplication ctx){
|
||||||
this.ctx = ctx;
|
this.ctx = ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -371,7 +371,7 @@ public class DownloadIndexesThread {
|
||||||
String dt = uiActivity.getMyApplication().getResourceManager().getIndexFileNames().get(basemap.getTargetFileName());
|
String dt = uiActivity.getMyApplication().getResourceManager().getIndexFileNames().get(basemap.getTargetFileName());
|
||||||
if (!basemapExists || !Algorithms.objectEquals(dt, basemap.getDate())) {
|
if (!basemapExists || !Algorithms.objectEquals(dt, basemap.getDate())) {
|
||||||
List<DownloadEntry> downloadEntry = basemap
|
List<DownloadEntry> downloadEntry = basemap
|
||||||
.createDownloadEntry(uiActivity.getClientContext(), uiActivity.getType(),
|
.createDownloadEntry(uiActivity.getMyApplication(), uiActivity.getType(),
|
||||||
new ArrayList<DownloadEntry>());
|
new ArrayList<DownloadEntry>());
|
||||||
uiActivity.getEntriesToDownload().put(basemap, downloadEntry);
|
uiActivity.getEntriesToDownload().put(basemap, downloadEntry);
|
||||||
AccessibleToast.makeText(uiActivity, R.string.basemap_was_selected_to_download,
|
AccessibleToast.makeText(uiActivity, R.string.basemap_was_selected_to_download,
|
||||||
|
|
|
@ -216,7 +216,7 @@ public class DownloadOsmandIndexesHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DownloadEntry> createDownloadEntry(ClientContext ctx, DownloadActivityType type, List<DownloadEntry> res) {
|
public List<DownloadEntry> createDownloadEntry(OsmandApplication ctx, DownloadActivityType type, List<DownloadEntry> res) {
|
||||||
res.add(new DownloadEntry(this, assetName, destFile, dateModified));
|
res.add(new DownloadEntry(this, assetName, destFile, dateModified));
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,24 +13,26 @@ import java.util.Map.Entry;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.plus.ClientContext;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.Version;
|
import net.osmand.plus.Version;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
|
import android.os.Build;
|
||||||
|
|
||||||
public class DownloadTracker {
|
public class DownloadTracker {
|
||||||
private static final Log log = PlatformUtil.getLog(DownloadTracker.class);
|
private static final Log log = PlatformUtil.getLog(DownloadTracker.class);
|
||||||
|
|
||||||
private Map<String, String> getCustomVars(ClientContext ctx) {
|
private Map<String, String> getCustomVars(OsmandApplication ctx) {
|
||||||
Map<String, String> map = new LinkedHashMap<String, String>();
|
Map<String, String> map = new LinkedHashMap<String, String>();
|
||||||
map.put("App", Version.getFullVersion(ctx));
|
map.put("App", Version.getFullVersion(ctx));
|
||||||
map.put("Device", ctx.getInternalAPI().getDeviceName());
|
map.put("Device", Build.DEVICE);
|
||||||
map.put("Brand", ctx.getInternalAPI().getBrandName());
|
map.put("Brand", Build.BRAND);
|
||||||
map.put("Model", ctx.getInternalAPI().getModelName());
|
map.put("Model", Build.MODEL);
|
||||||
map.put("Package", ctx.getInternalAPI().getPackageName());
|
map.put("Package", ctx.getPackageName());
|
||||||
|
|
||||||
map.put("Version name", ctx.getInternalAPI().getVersionName());
|
map.put("Version name", ctx.getVersionName());
|
||||||
map.put("Version code", ctx.getInternalAPI().getVersionCode()+"");
|
map.put("Version code", ctx.getVersionCode()+"");
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +43,7 @@ public class DownloadTracker {
|
||||||
static final String beaconUrl = "http://www.google-analytics.com/__utm.gif";
|
static final String beaconUrl = "http://www.google-analytics.com/__utm.gif";
|
||||||
static final String analyticsVersion = "4.3"; // Analytics version - AnalyticsVersion
|
static final String analyticsVersion = "4.3"; // Analytics version - AnalyticsVersion
|
||||||
|
|
||||||
public void trackEvent(ClientContext a,
|
public void trackEvent(OsmandApplication a,
|
||||||
String category, String action, String label, int value, String trackingAcount) {
|
String category, String action, String label, int value, String trackingAcount) {
|
||||||
Map<String, String> parameters = new LinkedHashMap<String, String>();
|
Map<String, String> parameters = new LinkedHashMap<String, String>();
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -15,6 +15,7 @@ import java.util.TimeZone;
|
||||||
import net.osmand.IndexConstants;
|
import net.osmand.IndexConstants;
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.plus.ClientContext;
|
import net.osmand.plus.ClientContext;
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.Version;
|
import net.osmand.plus.Version;
|
||||||
|
|
||||||
|
@ -141,7 +142,7 @@ public class IndexItem implements Comparable<IndexItem> {
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<DownloadEntry> createDownloadEntry(ClientContext ctx, DownloadActivityType type,
|
public List<DownloadEntry> createDownloadEntry(OsmandApplication ctx, DownloadActivityType type,
|
||||||
List<DownloadEntry> downloadEntries) {
|
List<DownloadEntry> downloadEntries) {
|
||||||
String fileName = this.fileName;
|
String fileName = this.fileName;
|
||||||
File parent = null;
|
File parent = null;
|
||||||
|
|
|
@ -8,6 +8,7 @@ import java.util.Map;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
|
||||||
import net.osmand.plus.ClientContext;
|
import net.osmand.plus.ClientContext;
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.Version;
|
import net.osmand.plus.Version;
|
||||||
|
|
||||||
|
@ -26,7 +27,7 @@ public class IndexItemCategory implements Comparable<IndexItemCategory> {
|
||||||
return order < another.order ? -1 : 1;
|
return order < another.order ? -1 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<IndexItemCategory> categorizeIndexItems(ClientContext ctx, Collection<IndexItem> indexItems) {
|
public static List<IndexItemCategory> categorizeIndexItems(OsmandApplication ctx, Collection<IndexItem> indexItems) {
|
||||||
boolean skipWiki = Version.isFreeVersion(ctx);
|
boolean skipWiki = Version.isFreeVersion(ctx);
|
||||||
final Map<String, IndexItemCategory> cats = new TreeMap<String, IndexItemCategory>();
|
final Map<String, IndexItemCategory> cats = new TreeMap<String, IndexItemCategory>();
|
||||||
for (IndexItem i : indexItems) {
|
for (IndexItem i : indexItems) {
|
||||||
|
|
|
@ -42,6 +42,7 @@ import net.osmand.plus.R;
|
||||||
import net.osmand.plus.TargetPointsHelper;
|
import net.osmand.plus.TargetPointsHelper;
|
||||||
import net.osmand.plus.Version;
|
import net.osmand.plus.Version;
|
||||||
import net.osmand.plus.activities.SettingsNavigationActivity;
|
import net.osmand.plus.activities.SettingsNavigationActivity;
|
||||||
|
import net.osmand.plus.render.NativeOsmandLibrary;
|
||||||
import net.osmand.router.GeneralRouter;
|
import net.osmand.router.GeneralRouter;
|
||||||
import net.osmand.router.GeneralRouter.GeneralRouterProfile;
|
import net.osmand.router.GeneralRouter.GeneralRouterProfile;
|
||||||
import net.osmand.router.GeneralRouter.RoutingParameter;
|
import net.osmand.router.GeneralRouter.RoutingParameter;
|
||||||
|
@ -612,14 +613,16 @@ public class RouteProvider {
|
||||||
//cf.planRoadDirection = 1;
|
//cf.planRoadDirection = 1;
|
||||||
}
|
}
|
||||||
// BUILD context
|
// BUILD context
|
||||||
RoutingContext ctx = router.buildRoutingContext(cf, params.ctx.getInternalAPI().getNativeLibrary(), files,
|
NativeOsmandLibrary lib = settings.SAFE_MODE.get() ? null : NativeOsmandLibrary.getLoadedLibrary();
|
||||||
|
RoutingContext ctx = router.buildRoutingContext(cf,
|
||||||
|
lib, files,
|
||||||
RouteCalculationMode.NORMAL);
|
RouteCalculationMode.NORMAL);
|
||||||
|
|
||||||
RoutingContext complexCtx = null;
|
RoutingContext complexCtx = null;
|
||||||
boolean complex = params.mode.isDerivedRoutingFrom(ApplicationMode.CAR) && !settings.DISABLE_COMPLEX_ROUTING.get()
|
boolean complex = params.mode.isDerivedRoutingFrom(ApplicationMode.CAR) && !settings.DISABLE_COMPLEX_ROUTING.get()
|
||||||
&& precalculated == null;
|
&& precalculated == null;
|
||||||
if(complex) {
|
if(complex) {
|
||||||
complexCtx = router.buildRoutingContext(cf, params.ctx.getInternalAPI().getNativeLibrary(), files,
|
complexCtx = router.buildRoutingContext(cf, lib,files,
|
||||||
RouteCalculationMode.COMPLEX);
|
RouteCalculationMode.COMPLEX);
|
||||||
complexCtx.calculationProgress = params.calculationProgress;
|
complexCtx.calculationProgress = params.calculationProgress;
|
||||||
complexCtx.leftSideNavigation = params.leftSide;
|
complexCtx.leftSideNavigation = params.leftSide;
|
||||||
|
|
|
@ -407,7 +407,7 @@ public class RoutingHelper {
|
||||||
showMessage(app.getString(R.string.arrived_at_intermediate_point));
|
showMessage(app.getString(R.string.arrived_at_intermediate_point));
|
||||||
route.passIntermediatePoint();
|
route.passIntermediatePoint();
|
||||||
|
|
||||||
TargetPointsHelper targets = app.getInternalAPI().getTargetPointsHelper();
|
TargetPointsHelper targets = app.getTargetPointsHelper();
|
||||||
List<String> ns = targets.getIntermediatePointNames();
|
List<String> ns = targets.getIntermediatePointNames();
|
||||||
int toDel = targets.getIntermediatePoints().size() - route.getIntermediatePointsToPass();
|
int toDel = targets.getIntermediatePoints().size() - route.getIntermediatePointsToPass();
|
||||||
int currentIndex = toDel - 1;
|
int currentIndex = toDel - 1;
|
||||||
|
@ -429,7 +429,7 @@ public class RoutingHelper {
|
||||||
Location lastPoint = routeNodes.get(routeNodes.size() - 1);
|
Location lastPoint = routeNodes.get(routeNodes.size() - 1);
|
||||||
if (currentRoute > routeNodes.size() - 3 && currentLocation.distanceTo(lastPoint) < POSITION_TOLERANCE * 1.5) {
|
if (currentRoute > routeNodes.size() - 3 && currentLocation.distanceTo(lastPoint) < POSITION_TOLERANCE * 1.5) {
|
||||||
showMessage(app.getString(R.string.arrived_at_destination));
|
showMessage(app.getString(R.string.arrived_at_destination));
|
||||||
TargetPointsHelper targets = app.getInternalAPI().getTargetPointsHelper();
|
TargetPointsHelper targets = app.getTargetPointsHelper();
|
||||||
String description = targets.getPointNavigateDescription();
|
String description = targets.getPointNavigateDescription();
|
||||||
if(isFollowingMode) {
|
if(isFollowingMode) {
|
||||||
voiceRouter.arrivedDestinationPoint(description);
|
voiceRouter.arrivedDestinationPoint(description);
|
||||||
|
|
|
@ -13,6 +13,7 @@ import net.osmand.IndexConstants;
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.plus.ApplicationMode;
|
import net.osmand.plus.ApplicationMode;
|
||||||
import net.osmand.plus.ClientContext;
|
import net.osmand.plus.ClientContext;
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.OsmandSettings.MetricsConstants;
|
import net.osmand.plus.OsmandSettings.MetricsConstants;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
@ -35,7 +36,7 @@ public abstract class AbstractPrologCommandPlayer implements CommandPlayer {
|
||||||
|
|
||||||
private static final Log log = PlatformUtil.getLog(AbstractPrologCommandPlayer.class);
|
private static final Log log = PlatformUtil.getLog(AbstractPrologCommandPlayer.class);
|
||||||
|
|
||||||
protected ClientContext ctx;
|
protected OsmandApplication ctx;
|
||||||
protected File voiceDir;
|
protected File voiceDir;
|
||||||
protected Prolog prologSystem;
|
protected Prolog prologSystem;
|
||||||
protected static final String P_VERSION = "version";
|
protected static final String P_VERSION = "version";
|
||||||
|
@ -56,7 +57,7 @@ public abstract class AbstractPrologCommandPlayer implements CommandPlayer {
|
||||||
protected int streamType;
|
protected int streamType;
|
||||||
private int currentVersion;
|
private int currentVersion;
|
||||||
|
|
||||||
protected AbstractPrologCommandPlayer(ClientContext ctx, String voiceProvider, String configFile, int[] sortedVoiceVersions)
|
protected AbstractPrologCommandPlayer(OsmandApplication ctx, String voiceProvider, String configFile, int[] sortedVoiceVersions)
|
||||||
throws CommandPlayerException
|
throws CommandPlayerException
|
||||||
{
|
{
|
||||||
this.ctx = ctx;
|
this.ctx = ctx;
|
||||||
|
|
|
@ -8,6 +8,7 @@ import java.util.List;
|
||||||
|
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.plus.ClientContext;
|
import net.osmand.plus.ClientContext;
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
|
@ -32,7 +33,7 @@ public class MediaCommandPlayerImpl extends AbstractPrologCommandPlayer implemen
|
||||||
private List<String> filesToPlay = Collections.synchronizedList(new ArrayList<String>());
|
private List<String> filesToPlay = Collections.synchronizedList(new ArrayList<String>());
|
||||||
|
|
||||||
|
|
||||||
public MediaCommandPlayerImpl(ClientContext ctx, String voiceProvider)
|
public MediaCommandPlayerImpl(OsmandApplication ctx, String voiceProvider)
|
||||||
throws CommandPlayerException
|
throws CommandPlayerException
|
||||||
{
|
{
|
||||||
super(ctx, voiceProvider, CONFIG_FILE, MEDIA_VOICE_VERSION);
|
super(ctx, voiceProvider, CONFIG_FILE, MEDIA_VOICE_VERSION);
|
||||||
|
|
Loading…
Reference in a new issue