From 9cc615f4acebd2215ff28c5a49f5c35a423b85b8 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Tue, 16 Apr 2013 21:46:59 +0200 Subject: [PATCH] New version support --- .../net/osmand/plus/OsmandApplication.java | 3 +- .../plus/activities/SettingsActivity.java | 4 +-- .../activities/search/SearchActivity.java | 4 +++ .../plus/render/MapRenderRepositories.java | 2 +- .../plus/render/NativeOsmandLibrary.java | 28 +++++++++++-------- 5 files changed, 25 insertions(+), 16 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/OsmandApplication.java b/OsmAnd/src/net/osmand/plus/OsmandApplication.java index 00b4f2c661..bb277cf29e 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandApplication.java +++ b/OsmAnd/src/net/osmand/plus/OsmandApplication.java @@ -56,7 +56,6 @@ import android.os.Message; import android.text.format.DateFormat; import android.widget.Toast; -import com.bidforfix.andorid.BidForFixHelper; public class OsmandApplication extends Application implements ClientContext { public static final String EXCEPTION_PATH = "exception.log"; //$NON-NLS-1$ @@ -485,7 +484,7 @@ public class OsmandApplication extends Application implements ClientContext { osmandSettings.NATIVE_RENDERING_FAILED.set(true); startDialog.startTask(getString(R.string.init_native_library), -1); RenderingRulesStorage storage = rendererRegistry.getCurrentSelectedRenderer(); - boolean initialized = NativeOsmandLibrary.getLibrary(storage) != null; + boolean initialized = NativeOsmandLibrary.getLibrary(storage, this) != null; osmandSettings.NATIVE_RENDERING_FAILED.set(false); if (!initialized) { LOG.info("Native library could not be loaded!"); diff --git a/OsmAnd/src/net/osmand/plus/activities/SettingsActivity.java b/OsmAnd/src/net/osmand/plus/activities/SettingsActivity.java index 2c19072d61..2f7dfd3b3c 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SettingsActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/SettingsActivity.java @@ -612,14 +612,14 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference @Override protected Void doInBackground(Void... params) { - NativeOsmandLibrary.getLibrary(storage); + NativeOsmandLibrary.getLibrary(storage, getMyApplication()); return null; } @Override protected void onPostExecute(Void result) { progressDlg.dismiss(); - if (!NativeOsmandLibrary.isNativeSupported(storage)) { + if (!NativeOsmandLibrary.isNativeSupported(storage, getMyApplication())) { AccessibleToast.makeText(SettingsActivity.this, R.string.native_library_not_supported, Toast.LENGTH_LONG).show(); } }; diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchActivity.java index c195cbc253..fcfa6b2fd2 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchActivity.java @@ -20,6 +20,7 @@ import android.app.Activity; import android.app.TabActivity; import android.content.Intent; import android.os.Bundle; +import android.util.Log; import android.view.View; import android.view.ViewGroup; import android.view.Window; @@ -89,6 +90,7 @@ public class SearchActivity extends TabActivity implements OsmAndLocationListene @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + long t = System.currentTimeMillis(); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.search_main); settings = ((OsmandApplication) getApplication()).getSettings(); @@ -205,6 +207,8 @@ public class SearchActivity extends TabActivity implements OsmAndLocationListene public void onNothingSelected(AdapterView parent) { } }); + + Log.i("net.osmand", "Start on create " + (System.currentTimeMillis() - t )); } @Override diff --git a/OsmAnd/src/net/osmand/plus/render/MapRenderRepositories.java b/OsmAnd/src/net/osmand/plus/render/MapRenderRepositories.java index 72f8265be1..b8078506d9 100644 --- a/OsmAnd/src/net/osmand/plus/render/MapRenderRepositories.java +++ b/OsmAnd/src/net/osmand/plus/render/MapRenderRepositories.java @@ -477,7 +477,7 @@ public class MapRenderRepositories { } } renderingReq.saveState(); - NativeOsmandLibrary nativeLib = !prefs.SAFE_MODE.get() ? NativeOsmandLibrary.getLibrary(storage) : null; + NativeOsmandLibrary nativeLib = !prefs.SAFE_MODE.get() ? NativeOsmandLibrary.getLibrary(storage, context) : null; // prevent editing requestedBox = new RotatedTileBox(tileRect); diff --git a/OsmAnd/src/net/osmand/plus/render/NativeOsmandLibrary.java b/OsmAnd/src/net/osmand/plus/render/NativeOsmandLibrary.java index 624fdbb958..416e5ed229 100644 --- a/OsmAnd/src/net/osmand/plus/render/NativeOsmandLibrary.java +++ b/OsmAnd/src/net/osmand/plus/render/NativeOsmandLibrary.java @@ -3,6 +3,8 @@ package net.osmand.plus.render; import net.osmand.NativeLibrary; import net.osmand.PlatformUtil; +import net.osmand.plus.ClientContext; +import net.osmand.plus.Version; import net.osmand.plus.render.OsmandRenderer.RenderingContext; import net.osmand.render.RenderingRuleSearchRequest; import net.osmand.render.RenderingRulesStorage; @@ -23,7 +25,7 @@ public class NativeOsmandLibrary extends NativeLibrary { } } - public static NativeOsmandLibrary getLibrary(RenderingRulesStorage storage) { + public static NativeOsmandLibrary getLibrary(RenderingRulesStorage storage, ClientContext ctx) { if (!isLoaded()) { synchronized (NativeOsmandLibrary.class) { if (!isLoaded()) { @@ -43,14 +45,18 @@ public class NativeOsmandLibrary extends NativeLibrary { } final String libCpuSuffix = cpuHasNeonSupport() ? "_neon" : ""; log.debug("Loading native libraries..."); //$NON-NLS-1$ - System.loadLibrary("Qt5Core" + libCpuSuffix); - System.loadLibrary("Qt5Network" + libCpuSuffix); - System.loadLibrary("Qt5Concurrent" + libCpuSuffix); - System.loadLibrary("Qt5Sql" + libCpuSuffix); - System.loadLibrary("Qt5Xml" + libCpuSuffix); - System.loadLibrary("OsmAndCore" + libCpuSuffix); - System.loadLibrary("OsmAndCoreUtils" + libCpuSuffix); - System.loadLibrary("OsmAndJNI" + libCpuSuffix); + if(Version.isOldCoreVersion(ctx)) { + System.loadLibrary("osmand" + libCpuSuffix); + } else { + System.loadLibrary("Qt5Core" + libCpuSuffix); + System.loadLibrary("Qt5Network" + libCpuSuffix); + System.loadLibrary("Qt5Concurrent" + libCpuSuffix); + System.loadLibrary("Qt5Sql" + libCpuSuffix); + System.loadLibrary("Qt5Xml" + libCpuSuffix); + System.loadLibrary("OsmAndCore" + libCpuSuffix); + System.loadLibrary("OsmAndCoreUtils" + libCpuSuffix); + System.loadLibrary("OsmAndJNI" + libCpuSuffix); + } log.debug("Creating NativeOsmandLibrary instance..."); //$NON-NLS-1$ library = new NativeOsmandLibrary(); log.debug("Initializing rendering rules storage..."); //$NON-NLS-1$ @@ -76,9 +82,9 @@ public class NativeOsmandLibrary extends NativeLibrary { return isNativeSupported != null; } - public static boolean isNativeSupported(RenderingRulesStorage storage) { + public static boolean isNativeSupported(RenderingRulesStorage storage, ClientContext ctx) { if(storage != null) { - getLibrary(storage); + getLibrary(storage, ctx); } return isSupported(); }